PageRenderTime 22ms CodeModel.GetById 20ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/packages/univint/src/CGPattern.pas

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