annotate src/video/maccommon/SDL_macwm.c @ 4072:6930cd5ab933 SDL-1.2

Final fix for bug #373 ------- Comment #13 From Christian Walther 2007-07-15 10:04:56 [reply] ------- Created an attachment (id=229) [details] patch to reinstate the SDL cursor after an NSApplicationActivatedEvent Oops, you're right. My testcursor.c has diverged so far from the original that I missed that. In fact, now that I think about it, that issue isn't even addressed by the cursor rectangle patch - it is only concerned with windowed mode (and fixes the problem there as a side effect). The problem in fullscreen is still the same as before. How about the attachment for a fix? (I can confirm that [NSCursor set] doesn't seem to have any effect when called from QZ_DoActivate().)
author Sam Lantinga <slouken@libsdl.org>
date Sun, 15 Jul 2007 17:22:39 +0000
parents 7cdb1d7fc93b
children a1b03ba2fcd0
rev   line source
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1133
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1133
diff changeset
6 modify it under the terms of the GNU Lesser General Public
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1133
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1133
diff changeset
13 Lesser General Public License for more details.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1133
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1133
diff changeset
16 License along with this library; if not, write to the Free Software
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1133
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
19 Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 0
diff changeset
20 slouken@libsdl.org
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
21 */
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
22 #include "SDL_config.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23
1133
609c060fd2a2 The MacOSX Carbon/Cocoa/X11 all in one library patch. Relevant emails:
Ryan C. Gordon <icculus@icculus.org>
parents: 769
diff changeset
24 #if defined(__APPLE__) && defined(__MACH__)
609c060fd2a2 The MacOSX Carbon/Cocoa/X11 all in one library patch. Relevant emails:
Ryan C. Gordon <icculus@icculus.org>
parents: 769
diff changeset
25 #include <Carbon/Carbon.h>
609c060fd2a2 The MacOSX Carbon/Cocoa/X11 all in one library patch. Relevant emails:
Ryan C. Gordon <icculus@icculus.org>
parents: 769
diff changeset
26 #elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27 #include <Carbon.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 #else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29 #include <Windows.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30 #include <Strings.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
32
3962
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
33 #if SDL_MACCLASSIC_GAMMA_SUPPORT
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
34 #include <Devices.h>
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
35 #include <Files.h>
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
36 #include <MacTypes.h>
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
37 #include <QDOffscreen.h>
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
38 #include <Quickdraw.h>
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
39 #include <Video.h>
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
40 #endif
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
41
1358
c71e05b4dc2e More header massaging... works great on Windows. ;-)
Sam Lantinga <slouken@libsdl.org>
parents: 1338
diff changeset
42 #include "SDL_stdinc.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
43 #include "SDL_macwm_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
44
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
45 void Mac_SetCaption(_THIS, const char *title, const char *icon)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
46 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
47 /* Don't convert C to P string in place, because it may be read-only */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
48 Str255 ptitle; /* MJS */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
49 ptitle[0] = strlen (title);
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
50 SDL_memcpy(ptitle+1, title, ptitle[0]); /* MJS */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
51 if (SDL_Window)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
52 SetWTitle(SDL_Window, ptitle); /* MJS */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
53 }
3962
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
54
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
55 #if SDL_MACCLASSIC_GAMMA_SUPPORT
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
56 /*
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
57 * ADC Gamma Ramp support...
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
58 *
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
59 * Mac Gamma Ramp code was originally from sample code provided by
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
60 * Apple Developer Connection, and not written specifically for SDL:
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
61 * "Contains: Functions to enable Mac OS device gamma adjustments using 3 channel 256 element 8 bit gamma ramps
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
62 * Written by: Geoff Stahl (ggs)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
63 * Copyright: Copyright (c) 1999 Apple Computer, Inc., All Rights Reserved
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
64 * Disclaimer: You may incorporate this sample code into your applications without
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
65 * restriction, though the sample code has been provided "AS IS" and the
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
66 * responsibility for its operation is 100% yours. However, what you are
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
67 * not permitted to do is to redistribute the source as "DSC Sample Code"
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
68 * after having made changes. If you're going to re-distribute the source,
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
69 * we require that you make it clear in the source that the code was
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
70 * descended from Apple Sample Code, but that you've made changes."
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
71 * (The sample code has been integrated into this file, and thus is modified from the original Apple sources.)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
72 */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
73
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
74 typedef struct recDeviceGamma /* storage for device handle and gamma table */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
75 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
76 GDHandle hGD; /* handle to device */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
77 GammaTblPtr pDeviceGamma; /* pointer to device gamma table */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
78 } recDeviceGamma;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
79 typedef recDeviceGamma * precDeviceGamma;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
80
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
81 typedef struct recSystemGamma /* storage for system devices and gamma tables */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
82 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
83 short numDevices; /* number of devices */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
84 precDeviceGamma * devGamma; /* array of pointers to device gamma records */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
85 } recSystemGamma;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
86 typedef recSystemGamma * precSystemGamma;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
87
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
88 static Ptr CopyGammaTable (GammaTblPtr pTableGammaIn)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
89 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
90 GammaTblPtr pTableGammaOut = NULL;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
91 short tableSize, dataWidth;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
92
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
93 if (pTableGammaIn) /* if there is a table to copy */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
94 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
95 dataWidth = (pTableGammaIn->gDataWidth + 7) / 8; /* number of bytes per entry */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
96 tableSize = sizeof (GammaTbl) + pTableGammaIn->gFormulaSize +
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
97 (pTableGammaIn->gChanCnt * pTableGammaIn->gDataCnt * dataWidth);
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
98 pTableGammaOut = (GammaTblPtr) NewPtr (tableSize); /* allocate new table */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
99 if (pTableGammaOut)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
100 BlockMove( (Ptr)pTableGammaIn, (Ptr)pTableGammaOut, tableSize); /* move everything */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
101 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
102 return (Ptr)pTableGammaOut; /* return whatever we allocated, could be NULL */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
103 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
104
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
105 static OSErr GetGammaTable (GDHandle hGD, GammaTblPtr * ppTableGammaOut)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
106 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
107 VDGammaRecord DeviceGammaRec;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
108 CntrlParam cParam;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
109 OSErr err;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
110
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
111 cParam.ioCompletion = NULL; /* set up control params */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
112 cParam.ioNamePtr = NULL;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
113 cParam.ioVRefNum = 0;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
114 cParam.ioCRefNum = (**hGD).gdRefNum;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
115 cParam.csCode = cscGetGamma; /* Get Gamma commnd to device */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
116 *(Ptr *)cParam.csParam = (Ptr) &DeviceGammaRec; /* record for gamma */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
117
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
118 err = PBStatusSync( (ParmBlkPtr)&cParam ); /* get gamma */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
119
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
120 *ppTableGammaOut = (GammaTblPtr)(DeviceGammaRec.csGTable); /* pull table out of record */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
121
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
122 return err;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
123 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
124
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
125 static Ptr GetDeviceGamma (GDHandle hGD)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
126 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
127 GammaTblPtr pTableGammaDevice = NULL;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
128 GammaTblPtr pTableGammaReturn = NULL;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
129 OSErr err;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
130
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
131 err = GetGammaTable (hGD, &pTableGammaDevice); /* get a pointer to the devices table */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
132 if ((noErr == err) && pTableGammaDevice) /* if succesful */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
133 pTableGammaReturn = (GammaTblPtr) CopyGammaTable (pTableGammaDevice); /* copy to global */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
134
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
135 return (Ptr) pTableGammaReturn;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
136 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
137
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
138 static void DisposeGammaTable (Ptr pGamma)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
139 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
140 if (pGamma)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
141 DisposePtr((Ptr) pGamma); /* get rid of it */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
142 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
143
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
144 static void DisposeSystemGammas (Ptr* ppSystemGammas)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
145 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
146 precSystemGamma pSysGammaIn;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
147 if (ppSystemGammas)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
148 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
149 pSysGammaIn = (precSystemGamma) *ppSystemGammas;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
150 if (pSysGammaIn)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
151 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
152 short i;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
153 for (i = 0; i < pSysGammaIn->numDevices; i++) /* for all devices */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
154 if (pSysGammaIn->devGamma [i]) /* if pointer is valid */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
155 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
156 DisposeGammaTable ((Ptr) pSysGammaIn->devGamma [i]->pDeviceGamma); /* dump gamma table */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
157 DisposePtr ((Ptr) pSysGammaIn->devGamma [i]); /* dump device info */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
158 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
159 DisposePtr ((Ptr) pSysGammaIn->devGamma); /* dump device pointer array */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
160 DisposePtr ((Ptr) pSysGammaIn); /* dump system structure */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
161 *ppSystemGammas = NULL;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
162 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
163 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
164 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
165
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
166 static Boolean GetDeviceGammaRampGD (GDHandle hGD, Ptr pRamp)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
167 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
168 GammaTblPtr pTableGammaTemp = NULL;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
169 long indexChan, indexEntry;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
170 OSErr err;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
171
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
172 if (pRamp) /* ensure pRamp is allocated */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
173 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
174 err = GetGammaTable (hGD, &pTableGammaTemp); /* get a pointer to the current gamma */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
175 if ((noErr == err) && pTableGammaTemp) /* if successful */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
176 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
177 /* fill ramp */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
178 unsigned char * pEntry = (unsigned char *) &pTableGammaTemp->gFormulaData + pTableGammaTemp->gFormulaSize; /* base of table */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
179 short bytesPerEntry = (pTableGammaTemp->gDataWidth + 7) / 8; /* size, in bytes, of the device table entries */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
180 short shiftRightValue = pTableGammaTemp->gDataWidth - 8; /* number of right shifts device -> ramp */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
181 short channels = pTableGammaTemp->gChanCnt;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
182 short entries = pTableGammaTemp->gDataCnt;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
183 if (3 == channels) /* RGB format */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
184 { /* note, this will create runs of entries if dest. is bigger (not linear interpolate) */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
185 for (indexChan = 0; indexChan < channels; indexChan++)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
186 for (indexEntry = 0; indexEntry < 256; indexEntry++)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
187 *((unsigned char *) pRamp + (indexChan * 256) + indexEntry) =
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
188 *(pEntry + indexChan * entries * bytesPerEntry + indexEntry * entries * bytesPerEntry / 256) >> shiftRightValue;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
189 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
190 else /* single channel format */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
191 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
192 for (indexChan = 0; indexChan < 768; indexChan += 256) /* repeat for all 3 channels (step by ramp size) */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
193 for (indexEntry = 0; indexEntry < 256; indexEntry++) /* for all entries set vramp value */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
194 *((unsigned char *) pRamp + indexChan + indexEntry) =
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
195 *(pEntry + indexEntry * entries * bytesPerEntry / 256) >> shiftRightValue;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
196 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
197 return true;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
198 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
199 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
200 return false;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
201 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
202
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
203 static Ptr GetSystemGammas (void)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
204 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
205 precSystemGamma pSysGammaOut; /* return pointer to system device gamma info */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
206 short devCount = 0; /* number of devices attached */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
207 Boolean fail = false;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
208 GDHandle hGDevice;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
209
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
210 pSysGammaOut = (precSystemGamma) NewPtr (sizeof (recSystemGamma)); /* allocate for structure */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
211
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
212 hGDevice = GetDeviceList (); /* top of device list */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
213 do /* iterate */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
214 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
215 devCount++; /* count devices */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
216 hGDevice = GetNextDevice (hGDevice); /* next device */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
217 } while (hGDevice);
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
218
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
219 pSysGammaOut->devGamma = (precDeviceGamma *) NewPtr (sizeof (precDeviceGamma) * devCount); /* allocate for array of pointers to device records */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
220 if (pSysGammaOut)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
221 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
222 pSysGammaOut->numDevices = devCount; /* stuff count */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
223
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
224 devCount = 0; /* reset iteration */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
225 hGDevice = GetDeviceList ();
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
226 do
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
227 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
228 pSysGammaOut->devGamma [devCount] = (precDeviceGamma) NewPtr (sizeof (recDeviceGamma)); /* new device record */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
229 if (pSysGammaOut->devGamma [devCount]) /* if we actually allocated memory */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
230 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
231 pSysGammaOut->devGamma [devCount]->hGD = hGDevice; /* stuff handle */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
232 pSysGammaOut->devGamma [devCount]->pDeviceGamma = (GammaTblPtr)GetDeviceGamma (hGDevice); /* copy gamma table */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
233 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
234 else /* otherwise dump record on exit */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
235 fail = true;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
236 devCount++; /* next device */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
237 hGDevice = GetNextDevice (hGDevice);
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
238 } while (hGDevice);
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
239 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
240 if (!fail) /* if we did not fail */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
241 return (Ptr) pSysGammaOut; /* return pointer to structure */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
242 else
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
243 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
244 DisposeSystemGammas ((Ptr *) &pSysGammaOut); /* otherwise dump the current structures (dispose does error checking) */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
245 return NULL; /* could not complete */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
246 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
247 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
248
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
249 static void RestoreDeviceGamma (GDHandle hGD, Ptr pGammaTable)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
250 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
251 VDSetEntryRecord setEntriesRec;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
252 VDGammaRecord gameRecRestore;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
253 CTabHandle hCTabDeviceColors;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
254 Ptr csPtr;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
255 OSErr err = noErr;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
256
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
257 if (pGammaTable) /* if we have a table to restore */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
258 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
259 gameRecRestore.csGTable = pGammaTable; /* setup restore record */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
260 csPtr = (Ptr) &gameRecRestore;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
261 err = Control((**hGD).gdRefNum, cscSetGamma, (Ptr) &csPtr); /* restore gamma */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
262
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
263 if ((noErr == err) && (8 == (**(**hGD).gdPMap).pixelSize)) /* if successful and on an 8 bit device */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
264 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
265 hCTabDeviceColors = (**(**hGD).gdPMap).pmTable; /* do SetEntries to force CLUT update */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
266 setEntriesRec.csTable = (ColorSpec *) &(**hCTabDeviceColors).ctTable;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
267 setEntriesRec.csStart = 0;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
268 setEntriesRec.csCount = (**hCTabDeviceColors).ctSize;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
269 csPtr = (Ptr) &setEntriesRec;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
270
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
271 err = Control((**hGD).gdRefNum, cscSetEntries, (Ptr) &csPtr); /* SetEntries in CLUT */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
272 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
273 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
274 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
275
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
276 static void RestoreSystemGammas (Ptr pSystemGammas)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
277 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
278 short i;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
279 precSystemGamma pSysGammaIn = (precSystemGamma) pSystemGammas;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
280 if (pSysGammaIn)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
281 for (i = 0; i < pSysGammaIn->numDevices; i++) /* for all devices */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
282 RestoreDeviceGamma (pSysGammaIn->devGamma [i]->hGD, (Ptr) pSysGammaIn->devGamma [i]->pDeviceGamma); /* restore gamma */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
283 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
284
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
285 static Ptr CreateEmptyGammaTable (short channels, short entries, short bits)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
286 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
287 GammaTblPtr pTableGammaOut = NULL;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
288 short tableSize, dataWidth;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
289
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
290 dataWidth = (bits + 7) / 8; /* number of bytes per entry */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
291 tableSize = sizeof (GammaTbl) + (channels * entries * dataWidth);
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
292 pTableGammaOut = (GammaTblPtr) NewPtrClear (tableSize); /* allocate new tabel */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
293
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
294 if (pTableGammaOut) /* if we successfully allocated */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
295 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
296 pTableGammaOut->gVersion = 0; /* set parameters based on input */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
297 pTableGammaOut->gType = 0;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
298 pTableGammaOut->gFormulaSize = 0;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
299 pTableGammaOut->gChanCnt = channels;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
300 pTableGammaOut->gDataCnt = entries;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
301 pTableGammaOut->gDataWidth = bits;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
302 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
303 return (Ptr)pTableGammaOut; /* return whatever we allocated */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
304 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
305
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
306 static Boolean SetDeviceGammaRampGD (GDHandle hGD, Ptr pRamp)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
307 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
308 VDSetEntryRecord setEntriesRec;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
309 VDGammaRecord gameRecRestore;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
310 GammaTblPtr pTableGammaNew;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
311 GammaTblPtr pTableGammaCurrent = NULL;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
312 CTabHandle hCTabDeviceColors;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
313 Ptr csPtr;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
314 OSErr err;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
315 short dataBits, entries, channels = 3; /* force three channels in the gamma table */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
316
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
317 if (pRamp) /* ensure pRamp is allocated */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
318 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
319 err= GetGammaTable (hGD, &pTableGammaCurrent); /* get pointer to current table */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
320 if ((noErr == err) && pTableGammaCurrent)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
321 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
322 dataBits = pTableGammaCurrent->gDataWidth; /* table must have same data width */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
323 entries = pTableGammaCurrent->gDataCnt; /* table must be same size */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
324 pTableGammaNew = (GammaTblPtr) CreateEmptyGammaTable (channels, entries, dataBits); /* our new table */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
325 if (pTableGammaNew) /* if successful fill table */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
326 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
327 unsigned char * pGammaBase = (unsigned char *) &pTableGammaNew->gFormulaData + pTableGammaNew->gFormulaSize; /* base of table */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
328 if ((256 == entries) && (8 == dataBits)) /* simple case: direct mapping */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
329 BlockMove ((Ptr)pRamp, (Ptr)pGammaBase, channels * entries); /* move everything */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
330 else /* tough case handle entry, channel and data size disparities */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
331 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
332 short indexChan, indexEntry;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
333 short bytesPerEntry = (dataBits + 7) / 8; /* size, in bytes, of the device table entries */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
334 short shiftRightValue = 8 - dataBits; /* number of right shifts ramp -> device */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
335 shiftRightValue += ((bytesPerEntry - 1) * 8); /* multibyte entries and the need to map a byte at a time most sig. to least sig. */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
336 for (indexChan = 0; indexChan < channels; indexChan++) /* for all the channels */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
337 for (indexEntry = 0; indexEntry < entries; indexEntry++) /* for all the entries */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
338 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
339 short currentShift = shiftRightValue; /* reset current bit shift */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
340 long temp = *((unsigned char *)pRamp + (indexChan << 8) + (indexEntry << 8) / entries); /* get data from ramp */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
341 short indexByte;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
342 for (indexByte = 0; indexByte < bytesPerEntry; indexByte++) /* for all bytes */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
343 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
344 if (currentShift < 0) /* shift data correctly for current byte */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
345 *(pGammaBase++) = temp << -currentShift;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
346 else
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
347 *(pGammaBase++) = temp >> currentShift;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
348 currentShift -= 8; /* increment shift to align to next less sig. byte */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
349 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
350 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
351 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
352
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
353 /* set gamma */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
354 gameRecRestore.csGTable = (Ptr) pTableGammaNew; /* setup restore record */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
355 csPtr = (Ptr) &gameRecRestore;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
356 err = Control((**hGD).gdRefNum, cscSetGamma, (Ptr) &csPtr); /* restore gamma (note, display drivers may delay returning from this until VBL) */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
357
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
358 if ((8 == (**(**hGD).gdPMap).pixelSize) && (noErr == err)) /* if successful and on an 8 bit device */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
359 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
360 hCTabDeviceColors = (**(**hGD).gdPMap).pmTable; /* do SetEntries to force CLUT update */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
361 setEntriesRec.csTable = (ColorSpec *) &(**hCTabDeviceColors).ctTable;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
362 setEntriesRec.csStart = 0;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
363 setEntriesRec.csCount = (**hCTabDeviceColors).ctSize;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
364 csPtr = (Ptr) &setEntriesRec;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
365 err = Control((**hGD).gdRefNum, cscSetEntries, (Ptr) &csPtr); /* SetEntries in CLUT */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
366 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
367 DisposeGammaTable ((Ptr) pTableGammaNew); /* dump table */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
368 if (noErr == err)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
369 return true;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
370 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
371 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
372 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
373 else /* set NULL gamma -> results in linear map */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
374 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
375 gameRecRestore.csGTable = (Ptr) NULL; /* setup restore record */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
376 csPtr = (Ptr) &gameRecRestore;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
377 err = Control((**hGD).gdRefNum, cscSetGamma, (Ptr) &csPtr); /* restore gamma */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
378
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
379 if ((8 == (**(**hGD).gdPMap).pixelSize) && (noErr == err)) /* if successful and on an 8 bit device */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
380 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
381 hCTabDeviceColors = (**(**hGD).gdPMap).pmTable; /* do SetEntries to force CLUT update */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
382 setEntriesRec.csTable = (ColorSpec *) &(**hCTabDeviceColors).ctTable;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
383 setEntriesRec.csStart = 0;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
384 setEntriesRec.csCount = (**hCTabDeviceColors).ctSize;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
385 csPtr = (Ptr) &setEntriesRec;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
386 err = Control((**hGD).gdRefNum, cscSetEntries, (Ptr) &csPtr); /* SetEntries in CLUT */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
387 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
388 if (noErr == err)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
389 return true;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
390 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
391 return false; /* memory allocation or device control failed if we get here */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
392 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
393
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
394 /* end of ADC Gamma Ramp support code... */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
395
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
396 static Ptr systemGammaPtr;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
397
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
398 void Mac_QuitGamma(_THIS)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
399 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
400 if (systemGammaPtr)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
401 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
402 RestoreSystemGammas(systemGammaPtr);
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
403 DisposeSystemGammas(&systemGammaPtr);
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
404 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
405 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
406
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
407 static unsigned char shiftedRamp[3 * 256];
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
408
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
409 int Mac_SetGammaRamp(_THIS, Uint16 *ramp)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
410 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
411 int i;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
412 if (!systemGammaPtr)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
413 systemGammaPtr = GetSystemGammas();
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
414 for (i = 0; i < 3 * 256; i++)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
415 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
416 shiftedRamp[i] = ramp[i] >> 8;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
417 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
418
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
419 if (SetDeviceGammaRampGD(GetMainDevice(), (Ptr) shiftedRamp))
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
420 return 0;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
421 else
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
422 return -1;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
423 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
424
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
425 int Mac_GetGammaRamp(_THIS, Uint16 *ramp)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
426 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
427 if (GetDeviceGammaRampGD(GetMainDevice(), (Ptr) shiftedRamp))
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
428 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
429 int i;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
430 for (i = 0; i < 3 * 256; i++)
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
431 {
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
432 ramp[i] = shiftedRamp[i] << 8;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
433 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
434 return 0;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
435 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
436 else
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
437 return -1;
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
438 }
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
439
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
440 #endif /* SDL_MACCLASSIC_GAMMA_SUPPORT */
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
441
7cdb1d7fc93b Support for Gamma Ramps on Mac OS Classic in both the macrom and macdsp video
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
442