CGPattern.pas 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. { CoreGraphics - CGPattern.h
  2. Copyright (c) 2000-2011 Apple Inc.
  3. All rights reserved. }
  4. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, August 2005 }
  5. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, October 2009 }
  6. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, October 2012 }
  7. {
  8. Modified for use with Free Pascal
  9. Version 308
  10. Please report any bugs to <[email protected]>
  11. }
  12. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  13. {$mode macpas}
  14. {$packenum 1}
  15. {$macro on}
  16. {$inline on}
  17. {$calling mwpascal}
  18. unit CGPattern;
  19. interface
  20. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  21. {$setc GAP_INTERFACES_VERSION := $0308}
  22. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  23. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  24. {$endc}
  25. {$ifc defined CPUPOWERPC and defined CPUI386}
  26. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  27. {$endc}
  28. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  29. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  30. {$endc}
  31. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  32. {$setc __ppc__ := 1}
  33. {$elsec}
  34. {$setc __ppc__ := 0}
  35. {$endc}
  36. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  37. {$setc __ppc64__ := 1}
  38. {$elsec}
  39. {$setc __ppc64__ := 0}
  40. {$endc}
  41. {$ifc not defined __i386__ and defined CPUI386}
  42. {$setc __i386__ := 1}
  43. {$elsec}
  44. {$setc __i386__ := 0}
  45. {$endc}
  46. {$ifc not defined __x86_64__ and defined CPUX86_64}
  47. {$setc __x86_64__ := 1}
  48. {$elsec}
  49. {$setc __x86_64__ := 0}
  50. {$endc}
  51. {$ifc not defined __arm__ and defined CPUARM}
  52. {$setc __arm__ := 1}
  53. {$elsec}
  54. {$setc __arm__ := 0}
  55. {$endc}
  56. {$ifc defined cpu64}
  57. {$setc __LP64__ := 1}
  58. {$elsec}
  59. {$setc __LP64__ := 0}
  60. {$endc}
  61. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  62. {$error Conflicting definitions for __ppc__ and __i386__}
  63. {$endc}
  64. {$ifc defined __ppc__ and __ppc__}
  65. {$setc TARGET_CPU_PPC := TRUE}
  66. {$setc TARGET_CPU_PPC64 := FALSE}
  67. {$setc TARGET_CPU_X86 := FALSE}
  68. {$setc TARGET_CPU_X86_64 := FALSE}
  69. {$setc TARGET_CPU_ARM := FALSE}
  70. {$setc TARGET_OS_MAC := TRUE}
  71. {$setc TARGET_OS_IPHONE := FALSE}
  72. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  73. {$setc TARGET_OS_EMBEDDED := FALSE}
  74. {$elifc defined __ppc64__ and __ppc64__}
  75. {$setc TARGET_CPU_PPC := FALSE}
  76. {$setc TARGET_CPU_PPC64 := TRUE}
  77. {$setc TARGET_CPU_X86 := FALSE}
  78. {$setc TARGET_CPU_X86_64 := FALSE}
  79. {$setc TARGET_CPU_ARM := FALSE}
  80. {$setc TARGET_OS_MAC := TRUE}
  81. {$setc TARGET_OS_IPHONE := FALSE}
  82. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  83. {$setc TARGET_OS_EMBEDDED := FALSE}
  84. {$elifc defined __i386__ and __i386__}
  85. {$setc TARGET_CPU_PPC := FALSE}
  86. {$setc TARGET_CPU_PPC64 := FALSE}
  87. {$setc TARGET_CPU_X86 := TRUE}
  88. {$setc TARGET_CPU_X86_64 := FALSE}
  89. {$setc TARGET_CPU_ARM := FALSE}
  90. {$ifc defined(iphonesim)}
  91. {$setc TARGET_OS_MAC := FALSE}
  92. {$setc TARGET_OS_IPHONE := TRUE}
  93. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  94. {$elsec}
  95. {$setc TARGET_OS_MAC := TRUE}
  96. {$setc TARGET_OS_IPHONE := FALSE}
  97. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  98. {$endc}
  99. {$setc TARGET_OS_EMBEDDED := FALSE}
  100. {$elifc defined __x86_64__ and __x86_64__}
  101. {$setc TARGET_CPU_PPC := FALSE}
  102. {$setc TARGET_CPU_PPC64 := FALSE}
  103. {$setc TARGET_CPU_X86 := FALSE}
  104. {$setc TARGET_CPU_X86_64 := TRUE}
  105. {$setc TARGET_CPU_ARM := FALSE}
  106. {$setc TARGET_OS_MAC := TRUE}
  107. {$setc TARGET_OS_IPHONE := FALSE}
  108. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  109. {$setc TARGET_OS_EMBEDDED := FALSE}
  110. {$elifc defined __arm__ and __arm__}
  111. {$setc TARGET_CPU_PPC := FALSE}
  112. {$setc TARGET_CPU_PPC64 := FALSE}
  113. {$setc TARGET_CPU_X86 := FALSE}
  114. {$setc TARGET_CPU_X86_64 := FALSE}
  115. {$setc TARGET_CPU_ARM := TRUE}
  116. { will require compiler define when/if other Apple devices with ARM cpus ship }
  117. {$setc TARGET_OS_MAC := FALSE}
  118. {$setc TARGET_OS_IPHONE := TRUE}
  119. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  120. {$setc TARGET_OS_EMBEDDED := TRUE}
  121. {$elsec}
  122. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.}
  123. {$endc}
  124. {$ifc defined __LP64__ and __LP64__ }
  125. {$setc TARGET_CPU_64 := TRUE}
  126. {$elsec}
  127. {$setc TARGET_CPU_64 := FALSE}
  128. {$endc}
  129. {$ifc defined FPC_BIG_ENDIAN}
  130. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  131. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  132. {$elifc defined FPC_LITTLE_ENDIAN}
  133. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  134. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  135. {$elsec}
  136. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  137. {$endc}
  138. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  139. {$setc CALL_NOT_IN_CARBON := FALSE}
  140. {$setc OLDROUTINENAMES := FALSE}
  141. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  142. {$setc OPAQUE_UPP_TYPES := TRUE}
  143. {$setc OTCARBONAPPLICATION := TRUE}
  144. {$setc OTKERNEL := FALSE}
  145. {$setc PM_USE_SESSION_APIS := TRUE}
  146. {$setc TARGET_API_MAC_CARBON := TRUE}
  147. {$setc TARGET_API_MAC_OS8 := FALSE}
  148. {$setc TARGET_API_MAC_OSX := TRUE}
  149. {$setc TARGET_CARBON := TRUE}
  150. {$setc TARGET_CPU_68K := FALSE}
  151. {$setc TARGET_CPU_MIPS := FALSE}
  152. {$setc TARGET_CPU_SPARC := FALSE}
  153. {$setc TARGET_OS_UNIX := FALSE}
  154. {$setc TARGET_OS_WIN32 := FALSE}
  155. {$setc TARGET_RT_MAC_68881 := FALSE}
  156. {$setc TARGET_RT_MAC_CFM := FALSE}
  157. {$setc TARGET_RT_MAC_MACHO := TRUE}
  158. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  159. {$setc TYPE_BOOL := FALSE}
  160. {$setc TYPE_EXTENDED := FALSE}
  161. {$setc TYPE_LONGLONG := TRUE}
  162. uses MacTypes,CFBase,CGGeometry,CGAffineTransforms,CGBase,CGContext;
  163. {$endc} {not MACOSALLINCLUDE}
  164. {$ALIGN POWER}
  165. // CGPatternRef defined in CGBase
  166. { kCGPatternTilingNoDistortion: The pattern cell is not distorted when
  167. painted, however the spacing between pattern cells may vary by as much as
  168. 1 device pixel.
  169. kCGPatternTilingConstantSpacingMinimalDistortion: Pattern cells are
  170. spaced consistently, however the pattern cell may be distorted by as much
  171. as 1 device pixel when the pattern is painted.
  172. kCGPatternTilingConstantSpacing: Pattern cells are spaced consistently as
  173. with kCGPatternTilingConstantSpacingMinimalDistortion, however the
  174. pattern cell may be distorted additionally to permit a more efficient
  175. implementation. }
  176. type
  177. CGPatternTiling = SInt32;
  178. const
  179. kCGPatternTilingNoDistortion = 0;
  180. kCGPatternTilingConstantSpacingMinimalDistortion = 1;
  181. kCGPatternTilingConstantSpacing = 2;
  182. { The drawing of the pattern is delegated to the callbacks. The callbacks
  183. may be called one or many times to draw the pattern.
  184. `version' is the version number of the structure passed in as a
  185. parameter to the CGPattern creation functions. The structure defined
  186. below is version 0.
  187. `drawPattern' should draw the pattern in the context `c'. `info' is the
  188. parameter originally passed to the CGPattern creation functions.
  189. `releaseInfo' is called when the pattern is deallocated. }
  190. type
  191. CGPatternDrawPatternCallback = procedure( info: UnivPtr; c: CGContextRef );
  192. CGPatternReleaseInfoCallback = procedure( info: UnivPtr );
  193. type
  194. CGPatternCallbacksPtr = ^CGPatternCallbacks;
  195. CGPatternCallbacks = record
  196. version: UInt32;
  197. {$ifc TARGET_CPU_64}
  198. __alignment_dummy: UInt32;
  199. {$endc}
  200. drawPattern: CGPatternDrawPatternCallback;
  201. releaseInfo: CGPatternReleaseInfoCallback;
  202. end;
  203. { Return the CFTypeID for CGPatternRefs. }
  204. function CGPatternGetTypeID: CFTypeID; external name '_CGPatternGetTypeID';
  205. (* CG_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0) *)
  206. { Create a pattern. }
  207. function CGPatternCreate( info: UnivPtr; bounds: CGRect; matrix: CGAffineTransform; xStep: CGFloat; yStep: CGFloat; tiling: CGPatternTiling; isColored: CBool; const (*var*) callbacks: CGPatternCallbacks ): CGPatternRef; external name '_CGPatternCreate';
  208. (* CG_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0) *)
  209. { Equivalent to `CFRetain(pattern)', except it doesn't crash (as CF does)
  210. if `pattern' is NULL. }
  211. function CGPatternRetain( pattern: CGPatternRef ): CGPatternRef; external name '_CGPatternRetain';
  212. (* CG_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0) *)
  213. { Equivalent to `CFRelease(pattern)', except it doesn't crash (as CF does)
  214. if `pattern' is NULL. }
  215. procedure CGPatternRelease( pattern: CGPatternRef ); external name '_CGPatternRelease';
  216. (* CG_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0) *)
  217. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  218. end.
  219. {$endc} {not MACOSALLINCLUDE}