CGDataProvider.pas 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. { CoreGraphics - CGDataProvider.h
  2. * Copyright (c) 1999-2004 Apple Computer, Inc.
  3. * All rights reserved.
  4. }
  5. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, August 2005 }
  6. {
  7. Modified for use with Free Pascal
  8. Version 200
  9. Please report any bugs to <[email protected]>
  10. }
  11. {$mode macpas}
  12. {$packenum 1}
  13. {$macro on}
  14. {$inline on}
  15. {$CALLING MWPASCAL}
  16. unit CGDataProvider;
  17. interface
  18. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  19. {$setc GAP_INTERFACES_VERSION := $0200}
  20. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  21. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  22. {$endc}
  23. {$ifc defined CPUPOWERPC and defined CPUI386}
  24. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  25. {$endc}
  26. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  27. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  28. {$endc}
  29. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  30. {$setc __ppc__ := 1}
  31. {$elsec}
  32. {$setc __ppc__ := 0}
  33. {$endc}
  34. {$ifc not defined __i386__ and defined CPUI386}
  35. {$setc __i386__ := 1}
  36. {$elsec}
  37. {$setc __i386__ := 0}
  38. {$endc}
  39. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  40. {$error Conflicting definitions for __ppc__ and __i386__}
  41. {$endc}
  42. {$ifc defined __ppc__ and __ppc__}
  43. {$setc TARGET_CPU_PPC := TRUE}
  44. {$setc TARGET_CPU_X86 := FALSE}
  45. {$elifc defined __i386__ and __i386__}
  46. {$setc TARGET_CPU_PPC := FALSE}
  47. {$setc TARGET_CPU_X86 := TRUE}
  48. {$elsec}
  49. {$error Neither __ppc__ nor __i386__ is defined.}
  50. {$endc}
  51. {$setc TARGET_CPU_PPC_64 := FALSE}
  52. {$ifc defined FPC_BIG_ENDIAN}
  53. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  54. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  55. {$elifc defined FPC_LITTLE_ENDIAN}
  56. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  57. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  58. {$elsec}
  59. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  60. {$endc}
  61. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  62. {$setc CALL_NOT_IN_CARBON := FALSE}
  63. {$setc OLDROUTINENAMES := FALSE}
  64. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  65. {$setc OPAQUE_UPP_TYPES := TRUE}
  66. {$setc OTCARBONAPPLICATION := TRUE}
  67. {$setc OTKERNEL := FALSE}
  68. {$setc PM_USE_SESSION_APIS := TRUE}
  69. {$setc TARGET_API_MAC_CARBON := TRUE}
  70. {$setc TARGET_API_MAC_OS8 := FALSE}
  71. {$setc TARGET_API_MAC_OSX := TRUE}
  72. {$setc TARGET_CARBON := TRUE}
  73. {$setc TARGET_CPU_68K := FALSE}
  74. {$setc TARGET_CPU_MIPS := FALSE}
  75. {$setc TARGET_CPU_SPARC := FALSE}
  76. {$setc TARGET_OS_MAC := TRUE}
  77. {$setc TARGET_OS_UNIX := FALSE}
  78. {$setc TARGET_OS_WIN32 := FALSE}
  79. {$setc TARGET_RT_MAC_68881 := FALSE}
  80. {$setc TARGET_RT_MAC_CFM := FALSE}
  81. {$setc TARGET_RT_MAC_MACHO := TRUE}
  82. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  83. {$setc TYPE_BOOL := FALSE}
  84. {$setc TYPE_EXTENDED := FALSE}
  85. {$setc TYPE_LONGLONG := TRUE}
  86. uses MacTypes,CFBase,CFData,CGBase,CFURL;
  87. {$ALIGN POWER}
  88. type
  89. CGDataProviderRef = ^SInt32; { an opaque 32-bit type }
  90. { This callback is called to copy `count' bytes from the sequential data
  91. * stream to `buffer'. }
  92. type
  93. CGDataProviderGetBytesCallback = function( info: UnivPtr; buffer: UnivPtr; count: size_t ): size_t;
  94. { This callback is called to skip `count' bytes forward in the sequential
  95. * data stream. }
  96. type
  97. CGDataProviderSkipBytesCallback = procedure( info: UnivPtr; count: size_t );
  98. { This callback is called to rewind to the beginning of sequential data
  99. * stream. }
  100. type
  101. CGDataProviderRewindCallback = procedure( info: UnivPtr );
  102. { This callback is called to release the `info' pointer when the data
  103. * provider is freed. }
  104. type
  105. CGDataProviderReleaseInfoCallback = procedure( info: UnivPtr );
  106. { Callbacks for sequentially accessing data.
  107. * `getBytes' is called to copy `count' bytes from the sequential data
  108. * stream to `buffer'. It should return the number of bytes copied, or 0
  109. * if there's no more data.
  110. * `skipBytes' is called to skip ahead in the sequential data stream by
  111. * `count' bytes.
  112. * `rewind' is called to rewind the sequential data stream to the beginning
  113. * of the data.
  114. * `releaseProvider', if non-NULL, is called to release the `info' pointer
  115. * when the provider is freed. }
  116. type
  117. CGDataProviderCallbacks = record
  118. getBytes: CGDataProviderGetBytesCallback;
  119. skipBytes: CGDataProviderSkipBytesCallback;
  120. rewind: CGDataProviderRewindCallback;
  121. releaseProvider: CGDataProviderReleaseInfoCallback;
  122. end;
  123. { This callback is called to get a pointer to the entire block of data. }
  124. type
  125. CGDataProviderGetBytePointerCallback = function( info: UnivPtr ): UnivPtr;
  126. { This callback is called to release the pointer to entire block of
  127. * data. }
  128. type
  129. CGDataProviderReleaseBytePointerCallback = procedure( info: UnivPtr; pointr: {const} UnivPtr );
  130. { This callback is called to copy `count' bytes at byte offset `offset'
  131. * into `buffer'. }
  132. type
  133. CGDataProviderGetBytesAtOffsetCallback = function( info: UnivPtr; buffer: UnivPtr; offset: size_t; count: size_t ): size_t;
  134. { Callbacks for directly accessing data.
  135. * `getBytePointer', if non-NULL, is called to return a pointer to the
  136. * provider's entire block of data.
  137. * `releaseBytePointer', if non-NULL, is called to release a pointer to
  138. * the provider's entire block of data.
  139. * `getBytes', if non-NULL, is called to copy `count' bytes at offset
  140. * `offset' from the provider's data to `buffer'. It should return the
  141. * number of bytes copied, or 0 if there's no more data.
  142. * `releaseProvider', if non-NULL, is called when the provider is freed.
  143. *
  144. * At least one of `getBytePointer' or `getBytes' must be non-NULL. }
  145. type
  146. CGDataProviderDirectAccessCallbacks = record
  147. getBytePointer: CGDataProviderGetBytePointerCallback;
  148. releaseBytePointer: CGDataProviderReleaseBytePointerCallback;
  149. getBytes: CGDataProviderGetBytesAtOffsetCallback;
  150. releaseProvider: CGDataProviderReleaseInfoCallback;
  151. end;
  152. { Return the CFTypeID for CGDataProviderRefs. }
  153. function CGDataProviderGetTypeID: CFTypeID; external name '_CGDataProviderGetTypeID'; (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
  154. { Create a sequential-access data provider using `callbacks' to provide
  155. * the data. `info' is passed to each of the callback functions. }
  156. function CGDataProviderCreate( info: UnivPtr; const (*var*) callbacks: CGDataProviderCallbacks ): CGDataProviderRef; external name '_CGDataProviderCreate';
  157. { Create a direct-access data provider using `callbacks' to supply `size'
  158. * bytes of data. `info' is passed to each of the callback functions. }
  159. function CGDataProviderCreateDirectAccess( info: UnivPtr; size: size_t; const (*var*) callbacks: CGDataProviderDirectAccessCallbacks ): CGDataProviderRef; external name '_CGDataProviderCreateDirectAccess';
  160. { The callback used by `CGDataProviderCreateWithData'. }
  161. type
  162. CGDataProviderReleaseDataCallback = procedure( info: UnivPtr; data: {const} UnivPtr; size: size_t );
  163. { Create a direct-access data provider using `data', an array of `size'
  164. * bytes. `releaseData' is called when the data provider is freed, and is
  165. * passed `info' as its first argument. }
  166. function CGDataProviderCreateWithData( info: UnivPtr; data: {const} UnivPtr; size: size_t; releaseData: CGDataProviderReleaseDataCallback ): CGDataProviderRef; external name '_CGDataProviderCreateWithData';
  167. { Create a direct-access data provider which reads from `data'. }
  168. function CGDataProviderCreateWithCFData( data: CFDataRef ): CGDataProviderRef; external name '_CGDataProviderCreateWithCFData'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  169. { Create a data provider using `url'. }
  170. function CGDataProviderCreateWithURL( url: CFURLRef ): CGDataProviderRef; external name '_CGDataProviderCreateWithURL';
  171. { Equivalent to `CFRetain(provider)'. }
  172. function CGDataProviderRetain( provider: CGDataProviderRef ): CGDataProviderRef; external name '_CGDataProviderRetain';
  173. { Equivalent to `CFRelease(provider)'. }
  174. procedure CGDataProviderRelease( provider: CGDataProviderRef ); external name '_CGDataProviderRelease';
  175. {* DEPRECATED FUNCTIONS *}
  176. { Don't use this function; use CGDataProviderCreateWithURL instead. }
  177. function CGDataProviderCreateWithFilename( filename: ConstCStringPtr ): CGDataProviderRef; external name '_CGDataProviderCreateWithFilename';
  178. end.