5
* API to fade displays to and from a solid color, without resorting
6
* to playing with the gamma table APIs and losing ColorSync calibration.
8
* These APIs should be used in perference to manipulating the gamma tables
9
* for purposes of performing fade effects.
11
* Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
14
{ Pascal Translation: Peter N Lewis, <peter@stairways.com.au>, August 2005 }
16
Modified for use with Free Pascal
18
Please report any bugs to <gpc@microbizz.nl>
29
{$setc UNIVERSAL_INTERFACES_VERSION := $0342}
30
{$setc GAP_INTERFACES_VERSION := $0210}
32
{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
33
{$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
36
{$ifc defined CPUPOWERPC and defined CPUI386}
37
{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
39
{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
40
{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
43
{$ifc not defined __ppc__ and defined CPUPOWERPC}
48
{$ifc not defined __i386__ and defined CPUI386}
54
{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
55
{$error Conflicting definitions for __ppc__ and __i386__}
58
{$ifc defined __ppc__ and __ppc__}
59
{$setc TARGET_CPU_PPC := TRUE}
60
{$setc TARGET_CPU_X86 := FALSE}
61
{$elifc defined __i386__ and __i386__}
62
{$setc TARGET_CPU_PPC := FALSE}
63
{$setc TARGET_CPU_X86 := TRUE}
65
{$error Neither __ppc__ nor __i386__ is defined.}
67
{$setc TARGET_CPU_PPC_64 := FALSE}
69
{$ifc defined FPC_BIG_ENDIAN}
70
{$setc TARGET_RT_BIG_ENDIAN := TRUE}
71
{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
72
{$elifc defined FPC_LITTLE_ENDIAN}
73
{$setc TARGET_RT_BIG_ENDIAN := FALSE}
74
{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
76
{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
78
{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
79
{$setc CALL_NOT_IN_CARBON := FALSE}
80
{$setc OLDROUTINENAMES := FALSE}
81
{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
82
{$setc OPAQUE_UPP_TYPES := TRUE}
83
{$setc OTCARBONAPPLICATION := TRUE}
84
{$setc OTKERNEL := FALSE}
85
{$setc PM_USE_SESSION_APIS := TRUE}
86
{$setc TARGET_API_MAC_CARBON := TRUE}
87
{$setc TARGET_API_MAC_OS8 := FALSE}
88
{$setc TARGET_API_MAC_OSX := TRUE}
89
{$setc TARGET_CARBON := TRUE}
90
{$setc TARGET_CPU_68K := FALSE}
91
{$setc TARGET_CPU_MIPS := FALSE}
92
{$setc TARGET_CPU_SPARC := FALSE}
93
{$setc TARGET_OS_MAC := TRUE}
94
{$setc TARGET_OS_UNIX := FALSE}
95
{$setc TARGET_OS_WIN32 := FALSE}
96
{$setc TARGET_RT_MAC_68881 := FALSE}
97
{$setc TARGET_RT_MAC_CFM := FALSE}
98
{$setc TARGET_RT_MAC_MACHO := TRUE}
99
{$setc TYPED_FUNCTION_POINTERS := TRUE}
100
{$setc TYPE_BOOL := FALSE}
101
{$setc TYPE_EXTENDED := FALSE}
102
{$setc TYPE_LONGLONG := TRUE}
103
uses MacTypes,CGBase,CGErrors,CGDirectDisplay,CGDisplayConfiguration;
108
CGDisplayFadeReservationToken = UInt32;
110
kCGDisplayFadeReservationInvalidToken = 0;
113
CGDisplayBlendFraction = Float32;
115
* Values for the limits of the fade.
116
* kCGDisplayBlendNormal represents a normal display state
117
* kCGDisplayBlendSolidColor represents a display blended to a solid color
120
kCGDisplayBlendNormal = 0.0;
122
kCGDisplayBlendSolidColor = 1.0;
125
* Time in seconds to perform a fade operation.
128
CGDisplayFadeInterval = Float32;
132
* Most fade operations done by apps and games are done around display
133
* configuration changes. This API adds control over a built-in fade
134
* effect when performing display configuration changes.
136
* The default fade effect on a display mode change uses a fade-out of
137
* 0.3 seconds and a fade-in of 0.5 seconds. Color fades to French Blue
138
* for a normal desktop, and black when displays are captured.
140
* CGConfigureDisplayFadeEffect sets the display fade time and color
141
* for a display reconfigure operation.
142
* Call after CGBeginDisplayConfiguration() and before
143
* calling CGCompleteDisplayConfiguration().
145
* When CGCompleteDisplayConfiguration() is called, a fade-out effect will be
146
* done prior to the display reconfiguration. When the display reconfiguration
147
* is complete, control returns to the calling program, while a fade-in effect
148
* runs asynchronously.
150
function CGConfigureDisplayFadeEffect( configRef: CGDisplayConfigRef; fadeOutSeconds: CGDisplayFadeInterval; fadeInSeconds: CGDisplayFadeInterval; fadeRed: Float32; fadeGreen: Float32; fadeBlue: Float32 ): CGError; external name '_CGConfigureDisplayFadeEffect';
153
* It may also be desirable to perform fade operations at other times, as when
154
* transitioning between game play and cinematic sequences. The following API
155
* provides a mechanism for controlling display fade operations outside of display
156
* mode reconfigurations.
159
CGDisplayReservationInterval = Float32;
161
kCGMaxDisplayReservationInterval = 15.0;
163
* Before performing fade operation, the caller must reserve the hardware
164
* for the expected period of time that the program will be doing fades
166
* A reservation token is returned that must be passed in on subsequent calls.
168
* Failing to release the hardware by the end of the reservation interval will
169
* result in the reservation token becomingn invalid, and the hardware being
170
* unfaded back to a normal state. The reservation interval is limited (clipped)
171
* to 15 seconds maximum, and should be greater than zero.
173
* Returns kCGErrorNoneAvailable if another reservation is in effect,
174
* and kCGErrorSuccess on success.
176
function CGAcquireDisplayFadeReservation( seconds: CGDisplayReservationInterval; var pNewToken: CGDisplayFadeReservationToken ): CGError; external name '_CGAcquireDisplayFadeReservation';
179
* Releases a display fade reservation, and unfades the display if needed
180
* The reservation token myToken is no longer valid after this operation.
182
* CGReleaseDisplayFadeReservation may be safely called while an async fade
183
* operation is running, and if the ending blend value is kCGDisplayBlendNormal,
184
* will not disturb the running operation. The reservation is dropped when the
185
* fade opertion completes.
187
* Returns kCGErrorIllegalArgument if myToken is not the valid reservation token,
188
* and kCGErrorSuccess on success.
190
function CGReleaseDisplayFadeReservation( myToken: CGDisplayFadeReservationToken ): CGError; external name '_CGReleaseDisplayFadeReservation';
193
* The actual fade mechanism:
195
* The function takes the current reservation token,
196
* a time interval to perform the fade operation in seconds,
197
* a starting and ending blend coefficient, an RGB color in device space,
198
* and a boolean to indicate that the operation should be done synchronously.
200
* Over the fade operation time interval, the system will interpolate a
201
* blending coefficient between the starting and ending values given,
202
* applying a nonlinear (sine-based) bias term, and will blend the video output
203
* with the specified color based on the resulting value.
205
* If the time interval is specifed as 0.0, then the ending state blend value is
206
* applied at once and the function returns.
208
* The maximum allowable time interval is 15 seconds.
210
* If the parameter 'synchronous' is true, the function does not return
211
* til the fade operation is complete. If false, the function returns at once,
212
* and the fade operation runs asynchronously.
214
* CGReleaseDisplayFadeReservation may be safely called while an async fade
215
* operation is running, and if the ending blend value is kCGDisplayBlendNormal,
216
* will not disturb the running operation. The reservation is dropped when the
217
* fade opertion completes.
219
* Invalid parameters result in a return value of kCGErrorIllegalArgument.
220
* Trying to start a fade operation while an asynchronous fade operation is running
221
* results in a return value of kCGErrorNoneAvailable.
223
* To perform a 2 second fade to black, waiting til complete:
225
* CGDisplayFade(myToken,
227
* kCGDisplayBlendNormal, // Starting state
228
* kCGDisplayBlendSolidColor, // Ending state
229
* 0.0, 0.0, 0.0, // black
230
* true); // Wait for completion
232
* To perform a 2 second fade from black to normal, without waiting for completion:
234
* CGDisplayFade(myToken,
236
* kCGDisplayBlendSolidColor, // Starting state
237
* kCGDisplayBlendNormal, // Ending state
238
* 0.0, 0.0, 0.0, // black
239
* false); // Don't wait for completion
241
function CGDisplayFade( myToken: CGDisplayFadeReservationToken; seconds: CGDisplayFadeInterval; startBlend: CGDisplayBlendFraction; endBlend: CGDisplayBlendFraction; redBlend: Float32; greenBlend: Float32; blueBlend: Float32; synchronous: boolean_t ): CGError; external name '_CGDisplayFade';
244
* Returns true if a fade operation is currently in progress.
246
function CGDisplayFadeOperationInProgress: boolean_t; external name '_CGDisplayFadeOperationInProgress';