~ubuntu-branches/ubuntu/lucid/fpc/lucid-proposed

« back to all changes in this revision

Viewing changes to fpcsrc/packages/univint/src/CGDisplayFades.pas

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-10-09 23:29:00 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081009232900-553f61m37jkp6upv
Tags: 2.2.2-4
[ Torsten Werner ]
* Update ABI version in fpc-depends automatically.
* Remove empty directories from binary package fpc-source.

[ Mazen Neifer ]
* Removed leading path when calling update-alternatives to remove a Linitian
  error.
* Fixed clean target.
* Improved description of packages. (Closes: #498882)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{
 
2
 *  CGDisplayFade.h
 
3
 *  CoreGraphics
 
4
 *
 
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.
 
7
 *
 
8
 *  These APIs should be used in perference to manipulating the gamma tables
 
9
 *  for purposes of performing fade effects.
 
10
 *
 
11
 *  Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
 
12
 *
 
13
 }
 
14
{       Pascal Translation:  Peter N Lewis, <peter@stairways.com.au>, August 2005 }
 
15
{
 
16
    Modified for use with Free Pascal
 
17
    Version 210
 
18
    Please report any bugs to <gpc@microbizz.nl>
 
19
}
 
20
 
 
21
{$mode macpas}
 
22
{$packenum 1}
 
23
{$macro on}
 
24
{$inline on}
 
25
{$calling mwpascal}
 
26
 
 
27
unit CGDisplayFades;
 
28
interface
 
29
{$setc UNIVERSAL_INTERFACES_VERSION := $0342}
 
30
{$setc GAP_INTERFACES_VERSION := $0210}
 
31
 
 
32
{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
 
33
    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
 
34
{$endc}
 
35
 
 
36
{$ifc defined CPUPOWERPC and defined CPUI386}
 
37
        {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
 
38
{$endc}
 
39
{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
 
40
        {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
 
41
{$endc}
 
42
 
 
43
{$ifc not defined __ppc__ and defined CPUPOWERPC}
 
44
        {$setc __ppc__ := 1}
 
45
{$elsec}
 
46
        {$setc __ppc__ := 0}
 
47
{$endc}
 
48
{$ifc not defined __i386__ and defined CPUI386}
 
49
        {$setc __i386__ := 1}
 
50
{$elsec}
 
51
        {$setc __i386__ := 0}
 
52
{$endc}
 
53
 
 
54
{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
 
55
        {$error Conflicting definitions for __ppc__ and __i386__}
 
56
{$endc}
 
57
 
 
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}
 
64
{$elsec}
 
65
        {$error Neither __ppc__ nor __i386__ is defined.}
 
66
{$endc}
 
67
{$setc TARGET_CPU_PPC_64 := FALSE}
 
68
 
 
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}
 
75
{$elsec}
 
76
        {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
 
77
{$endc}
 
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;
 
104
{$ALIGN POWER}
 
105
 
 
106
 
 
107
type
 
108
        CGDisplayFadeReservationToken = UInt32;
 
109
const
 
110
        kCGDisplayFadeReservationInvalidToken = 0;
 
111
 
 
112
type
 
113
        CGDisplayBlendFraction = Float32;
 
114
{
 
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
 
118
 }
 
119
const
 
120
        kCGDisplayBlendNormal = 0.0;
 
121
const
 
122
        kCGDisplayBlendSolidColor = 1.0;
 
123
 
 
124
{
 
125
 * Time in seconds to perform a fade operation.
 
126
 }
 
127
type
 
128
        CGDisplayFadeInterval = Float32;
 
129
 
 
130
{
 
131
 *
 
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.
 
135
 *
 
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.
 
139
 *
 
140
 * CGConfigureDisplayFadeEffect sets the display fade time and color
 
141
 * for a display reconfigure operation.
 
142
 * Call after CGBeginDisplayConfiguration() and before
 
143
 * calling CGCompleteDisplayConfiguration().
 
144
 *
 
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.
 
149
 }
 
150
function CGConfigureDisplayFadeEffect( configRef: CGDisplayConfigRef; fadeOutSeconds: CGDisplayFadeInterval; fadeInSeconds: CGDisplayFadeInterval; fadeRed: Float32; fadeGreen: Float32; fadeBlue: Float32 ): CGError; external name '_CGConfigureDisplayFadeEffect';
 
151
 
 
152
{
 
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.
 
157
 }
 
158
type
 
159
        CGDisplayReservationInterval = Float32;
 
160
const
 
161
        kCGMaxDisplayReservationInterval = 15.0;
 
162
{
 
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
 
165
 *
 
166
 * A reservation token is returned that must be passed in on subsequent calls.
 
167
 *
 
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.
 
172
 *
 
173
 * Returns kCGErrorNoneAvailable if another reservation is in effect,
 
174
 * and kCGErrorSuccess on success.
 
175
 }
 
176
function CGAcquireDisplayFadeReservation( seconds: CGDisplayReservationInterval; var pNewToken: CGDisplayFadeReservationToken ): CGError; external name '_CGAcquireDisplayFadeReservation';
 
177
 
 
178
{
 
179
 * Releases a display fade reservation, and unfades the display if needed
 
180
 * The reservation token myToken is no longer valid after this operation.
 
181
 *
 
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.
 
186
 *
 
187
 * Returns kCGErrorIllegalArgument if myToken is not the valid reservation token,
 
188
 * and kCGErrorSuccess on success.
 
189
 }
 
190
function CGReleaseDisplayFadeReservation( myToken: CGDisplayFadeReservationToken ): CGError; external name '_CGReleaseDisplayFadeReservation';
 
191
 
 
192
{
 
193
 * The actual fade mechanism:
 
194
 *
 
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.
 
199
 *
 
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.
 
204
 *
 
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.
 
207
 *
 
208
 * The maximum allowable time interval is 15 seconds.
 
209
 *
 
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.
 
213
 *
 
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.
 
218
 *
 
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.
 
222
 *
 
223
 * To perform a 2 second fade to black, waiting til complete:
 
224
 *
 
225
 *      CGDisplayFade(myToken,
 
226
 *                    2.0,                      // 2 seconds 
 
227
 *                    kCGDisplayBlendNormal,    // Starting state 
 
228
 *                    kCGDisplayBlendSolidColor, // Ending state 
 
229
 *                    0.0, 0.0, 0.0,            // black 
 
230
 *                    true);                    // Wait for completion 
 
231
 *
 
232
 * To perform a 2 second fade from black to normal, without waiting for completion:
 
233
 *
 
234
 *      CGDisplayFade(myToken,
 
235
 *                    2.0,                      // 2 seconds 
 
236
 *                    kCGDisplayBlendSolidColor, // Starting state 
 
237
 *                    kCGDisplayBlendNormal,    // Ending state 
 
238
 *                    0.0, 0.0, 0.0,            // black 
 
239
 *                    false);                   // Don't wait for completion 
 
240
 }
 
241
function CGDisplayFade( myToken: CGDisplayFadeReservationToken; seconds: CGDisplayFadeInterval; startBlend: CGDisplayBlendFraction; endBlend: CGDisplayBlendFraction; redBlend: Float32; greenBlend: Float32; blueBlend: Float32; synchronous: boolean_t ): CGError; external name '_CGDisplayFade';
 
242
 
 
243
{
 
244
 * Returns true if a fade operation is currently in progress.
 
245
 }
 
246
function CGDisplayFadeOperationInProgress: boolean_t; external name '_CGDisplayFadeOperationInProgress';
 
247
 
 
248
 
 
249
end.