CGFunction.pas 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. { CoreGraphics - CGFunction.h
  2. * Copyright (c) 1999-2002 Apple Computer, Inc. (unpublished)
  3. * All rights reserved.
  4. }
  5. { Pascal Translation: 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 CGFunction;
  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,CGBase,CFBase;
  87. {$ALIGN POWER}
  88. {! @header CGFunction
  89. * A general floating-point function evaluator, using a callback mapping
  90. * an arbitrary number of float inputs to an arbitrary number of float
  91. * outputs.
  92. }
  93. type
  94. CGFunctionRef = ^SInt32; { an opaque 32-bit type }
  95. {! @typedef CGFunctionEvaluateCallback
  96. * This callback evaluates a function, using <tt>in</tt> as inputs, and
  97. * places the result in <tt>out</tt>.
  98. *
  99. * @param info
  100. * The info parameter passed to CGFunctionCreate.
  101. *
  102. * @param inData
  103. * An array of <tt>domainDimension</tt> floats.
  104. *
  105. * @param outData
  106. * An array of <tt>rangeDimension</tt> floats.
  107. }
  108. type
  109. CGFunctionEvaluateCallback = procedure( info: UnivPtr; inp: {const} Float32Ptr; out: Float32Ptr );
  110. {! @typedef CGFunctionReleaseInfoCallback
  111. * This callback releases the info parameter passed to the CGFunction
  112. * creation functions when the function is deallocated.
  113. *
  114. * @param info
  115. * The info parameter passed to CGFunctionCreate.
  116. }
  117. type
  118. CGFunctionReleaseInfoCallback = procedure( info: UnivPtr );
  119. {! @typedef CGFunctionCallbacks
  120. * Structure containing the callbacks of a CGFunction.
  121. *
  122. * @field version
  123. * The version number of the structure passed to the CGFunction creation
  124. * functions. This structure is version 0.
  125. *
  126. * @field evaluate
  127. * The callback used to evaluate the function.
  128. *
  129. * @field releaseInfo
  130. * If non-NULL, the callback used to release the info parameter passed to
  131. * the CGFunction creation functions when the function is deallocated.
  132. }
  133. type
  134. CGFunctionCallbacks = record
  135. version: UInt32;
  136. evaluate: CGFunctionEvaluateCallback;
  137. releaseInfo: CGFunctionReleaseInfoCallback;
  138. end;
  139. {! @function CGFunctionGetTypeID
  140. * Return the CFTypeID for CGFunctionRefs.
  141. }
  142. function CGFunctionGetTypeID: CFTypeID; external name '_CGFunctionGetTypeID'; (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
  143. {! @function CGFunctionCreate
  144. * Create a function.
  145. *
  146. * @param info
  147. * The parameter passed to the callback functions.
  148. *
  149. * @param domainDimension
  150. * The number of inputs to the function.
  151. *
  152. * @param domain
  153. * An array of <tt>2*domainDimension</tt> floats used to specify the
  154. * valid intervals of input values. For each <tt>k</tt> from <tt>0</tt>
  155. * to <tt>domainDimension - 1</tt>, <tt>domain[2*k]</tt> must be less
  156. * than or equal to <tt>domain[2*k+1]</tt>, and the <tt>k</tt>'th input
  157. * value <tt>in[k]</tt> will be clipped to lie in the interval
  158. * <tt>domain[2*k] <= in[k] <= domain[2*k+1]</tt>. If this parameter is
  159. * NULL, then the input values are not clipped. However, it's strongly
  160. * recommended that this parameter be specified; each domain interval
  161. * should specify reasonable values for the minimum and maximum in each
  162. * dimension.
  163. *
  164. * @param rangeDimension
  165. * The number of outputs from the function.
  166. *
  167. * @param range
  168. * An array of <tt>2*rangeDimension</tt> floats used to specify the valid
  169. * intervals of output values. For each <tt>k</tt> from <tt>0</tt> to
  170. * <tt>rangeDimension - 1</tt>, <tt>range[2*k]</tt> must be less than or
  171. * equal to <tt>range[2*k+1]</tt>, and the <tt>k</tt>'th output value
  172. * <tt>out[k]</tt> will be clipped to lie in the interval <tt>range[2*k]
  173. * <= out[k] <= range[2*k+1]</tt>. If this parameter is NULL, then the
  174. * output values are not clipped. However, it's strongly recommended
  175. * that this parameter be specified; each range interval should specify
  176. * reasonable values for the minimum and maximum in each dimension.
  177. *
  178. * @param callbacks
  179. * A pointer to a CGFunctionCallbacks structure. The function uses these
  180. * callbacks to evaluate values. The contents of the callbacks structure
  181. * is copied, so, for example, a pointer to a structure on the stack can
  182. * be passed in. }
  183. function CGFunctionCreate( info: UnivPtr; domainDimension: size_t; domain: {const} Float32Ptr; rangeDimension: size_t; range: {const} Float32Ptr; const (*var*) callbacks: CGFunctionCallbacks ): CGFunctionRef; external name '_CGFunctionCreate'; (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
  184. {! @function CGFunctionRetain
  185. *
  186. * Equivalent to <tt>CFRetain(function)</tt>.
  187. }
  188. function CGFunctionRetain( func: CGFunctionRef ): CGFunctionRef; external name '_CGFunctionRetain'; (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
  189. {! @function CGFunctionRelease
  190. *
  191. * Equivalent to <tt>CFRelease(function)</tt>.
  192. }
  193. procedure CGFunctionRelease( func: CGFunctionRef ); external name '_CGFunctionRelease'; (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
  194. end.