Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11gamma.c @ 4499:c2ebe3e020c6
Added Mac OS X implementation of clipboard support
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 08 Jul 2010 00:35:58 -0700 |
parents | f7b03b6838cb |
children |
rev | line source |
---|---|
2162
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
1 /* |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
3697 | 3 Copyright (C) 1997-2010 Sam Lantinga |
2162
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
4 |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
9 |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
14 |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
18 |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
19 Sam Lantinga |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
20 slouken@libsdl.org |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
21 */ |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
23 #include "../SDL_sysvideo.h" |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
24 #include "SDL_x11video.h" |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
25 |
3044
b36579172f27
Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents:
3010
diff
changeset
|
26 /* The size of *all* SDL gamma ramps */ |
b36579172f27
Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents:
3010
diff
changeset
|
27 #define SDL_GammaRampSize (3 * 256 * sizeof(Uint16)) |
b36579172f27
Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents:
3010
diff
changeset
|
28 |
2213 | 29 static int numCmaps = 0; |
30 | |
31 typedef struct | |
32 { | |
33 Display *display; | |
34 int scrNum; | |
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
35 Colormap colormap; |
2213 | 36 Visual visual; |
3010
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
37 Uint16 *ramp; |
2213 | 38 } cmapTableEntry; |
39 | |
40 cmapTableEntry *cmapTable = NULL; | |
41 | |
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
42 /* To reduce the overhead as much as possible lets do as little as |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
43 possible. When we do have to create a colormap keep track of it and |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
44 reuse it. We're going to do this for both DirectColor and |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
45 PseudoColor colormaps. */ |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
46 |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
47 Colormap |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
48 X11_LookupColormap(Display * display, int scrNum, VisualID vid) |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
49 { |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
50 int i; |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
51 |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
52 for (i = 0; i < numCmaps; i++) { |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
53 if (cmapTable[i].display == display && |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
54 cmapTable[i].scrNum == scrNum && |
3010
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
55 cmapTable[i].visual.visualid == vid) { |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
56 return cmapTable[i].colormap; |
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
57 } |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
58 } |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
59 |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
60 return 0; |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
61 } |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
62 |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
63 |
2213 | 64 void |
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
65 X11_TrackColormap(Display * display, int scrNum, Colormap colormap, |
3010
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
66 Visual * visual, XColor * ramp) |
2213 | 67 { |
68 int i; | |
3010
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
69 Uint16 *newramp; |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
70 int ncolors; |
2213 | 71 |
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
72 /* search the table to find out if we already have this one. We |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
73 only want one entry for each display, screen number, visualid, |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
74 and colormap combination */ |
2213 | 75 for (i = 0; i < numCmaps; i++) { |
76 if (cmapTable[i].display == display && | |
77 cmapTable[i].scrNum == scrNum && | |
3010
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
78 cmapTable[i].visual.visualid == visual->visualid && |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
79 cmapTable[i].colormap == colormap) { |
2213 | 80 return; |
81 } | |
82 } | |
83 | |
84 /* increase the table by one entry. If the table is NULL create the | |
85 first entrty */ | |
2221 | 86 cmapTable = |
87 SDL_realloc(cmapTable, (numCmaps + 1) * sizeof(cmapTableEntry)); | |
2216
82a133b784c9
changed to use SDL_realloc()
Bob Pendleton <bob@pendleton.com>
parents:
2214
diff
changeset
|
88 if (NULL == cmapTable) { |
2213 | 89 SDL_SetError("Out of memory in X11_TrackColormap()"); |
90 return; | |
91 } | |
92 | |
93 cmapTable[numCmaps].display = display; | |
94 cmapTable[numCmaps].scrNum = scrNum; | |
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
95 cmapTable[numCmaps].colormap = colormap; |
2213 | 96 SDL_memcpy(&cmapTable[numCmaps].visual, visual, sizeof(Visual)); |
3010
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
97 cmapTable[numCmaps].ramp = NULL; |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
98 |
3044
b36579172f27
Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents:
3010
diff
changeset
|
99 if (ramp != NULL) { |
3052 | 100 newramp = SDL_malloc(SDL_GammaRampSize); |
101 if (NULL == newramp) { | |
102 SDL_SetError("Out of memory in X11_TrackColormap()"); | |
103 return; | |
104 } | |
105 SDL_memset(newramp, 0, SDL_GammaRampSize); | |
106 cmapTable[numCmaps].ramp = newramp; | |
3010
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
107 |
3052 | 108 ncolors = cmapTable[numCmaps].visual.map_entries; |
3010
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
109 |
3052 | 110 for (i = 0; i < ncolors; i++) { |
111 newramp[(0 * 256) + i] = ramp[i].red; | |
112 newramp[(1 * 256) + i] = ramp[i].green; | |
113 newramp[(2 * 256) + i] = ramp[i].blue; | |
114 } | |
3010
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
115 } |
2213 | 116 |
117 numCmaps++; | |
118 } | |
119 | |
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
120 /* The problem is that you have to have at least one DirectColor |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
121 colormap before you can set the gamma ramps or read the gamma |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
122 ramps. If the application has created a DirectColor window then the |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
123 cmapTable will have at least one colormap in it and everything is |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
124 cool. If not, then we just fail */ |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
125 |
2162
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
126 int |
3500
4b594623401b
Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents:
3052
diff
changeset
|
127 X11_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * sdl_display, Uint16 * ramp) |
2162
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
128 { |
3010
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
129 Visual *visual; |
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
130 Display *display; |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
131 Colormap colormap; |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
132 XColor *colorcells; |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
133 int ncolors; |
3010
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
134 int rmask, gmask, bmask; |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
135 int rshift, gshift, bshift; |
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
136 int i; |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
137 int j; |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
138 |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
139 for (j = 0; j < numCmaps; j++) { |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
140 if (cmapTable[j].visual.class == DirectColor) { |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
141 display = cmapTable[j].display; |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
142 colormap = cmapTable[j].colormap; |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
143 ncolors = cmapTable[j].visual.map_entries; |
3010
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
144 visual = &cmapTable[j].visual; |
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
145 |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
146 colorcells = SDL_malloc(ncolors * sizeof(XColor)); |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
147 if (NULL == colorcells) { |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
148 SDL_SetError("out of memory in X11_SetDisplayGammaRamp"); |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
149 return -1; |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
150 } |
3010
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
151 /* remember the new ramp */ |
3052 | 152 if (cmapTable[j].ramp == NULL) { |
153 Uint16 *newramp = SDL_malloc(SDL_GammaRampSize); | |
154 if (NULL == newramp) { | |
155 SDL_SetError("Out of memory in X11_TrackColormap()"); | |
156 return -1; | |
157 } | |
158 cmapTable[j].ramp = newramp; | |
159 } | |
3044
b36579172f27
Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents:
3010
diff
changeset
|
160 SDL_memcpy(cmapTable[j].ramp, ramp, SDL_GammaRampSize); |
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
161 |
3010
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
162 rshift = 0; |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
163 rmask = visual->red_mask; |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
164 while (0 == (rmask & 1)) { |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
165 rshift++; |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
166 rmask >>= 1; |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
167 } |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
168 |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
169 /* printf("rmask = %4x rshift = %4d\n", rmask, rshift); */ |
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
170 |
3010
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
171 gshift = 0; |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
172 gmask = visual->green_mask; |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
173 while (0 == (gmask & 1)) { |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
174 gshift++; |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
175 gmask >>= 1; |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
176 } |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
177 |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
178 /* printf("gmask = %4x gshift = %4d\n", gmask, gshift); */ |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
179 |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
180 bshift = 0; |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
181 bmask = visual->blue_mask; |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
182 while (0 == (bmask & 1)) { |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
183 bshift++; |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
184 bmask >>= 1; |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
185 } |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
186 |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
187 /* printf("bmask = %4x bshift = %4d\n", bmask, bshift); */ |
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
188 |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
189 /* build the color table pixel values */ |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
190 for (i = 0; i < ncolors; i++) { |
3010
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
191 Uint32 rbits = (rmask * i) / (ncolors - 1); |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
192 Uint32 gbits = (gmask * i) / (ncolors - 1); |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
193 Uint32 bbits = (bmask * i) / (ncolors - 1); |
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
194 |
3010
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
195 Uint32 pix = |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
196 (rbits << rshift) | (gbits << gshift) | (bbits << bshift); |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
197 |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
198 colorcells[i].pixel = pix; |
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
199 |
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
200 colorcells[i].flags = DoRed | DoGreen | DoBlue; |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
201 |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
202 colorcells[i].red = ramp[(0 * 256) + i]; |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
203 colorcells[i].green = ramp[(1 * 256) + i]; |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
204 colorcells[i].blue = ramp[(2 * 256) + i]; |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
205 } |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
206 |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
207 XStoreColors(display, colormap, colorcells, ncolors); |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
208 XFlush(display); |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
209 SDL_free(colorcells); |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
210 } |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
211 } |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
212 |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
213 return 0; |
2162
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
214 } |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
215 |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
216 int |
3500
4b594623401b
Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents:
3052
diff
changeset
|
217 X11_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp) |
2162
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
218 { |
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
219 int i; |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
220 |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
221 /* find the first DirectColor colormap and use it to get the gamma |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
222 ramp */ |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
223 |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
224 for (i = 0; i < numCmaps; i++) { |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
225 if (cmapTable[i].visual.class == DirectColor) { |
3044
b36579172f27
Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents:
3010
diff
changeset
|
226 SDL_memcpy(ramp, cmapTable[i].ramp, SDL_GammaRampSize); |
3010
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
227 return 0; |
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
228 } |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
229 } |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
230 |
3010
a6694a812119
Modified and totally untested code to load the color tables for DirectColor and PseudoColor windows.
Bob Pendleton <bob@pendleton.com>
parents:
2859
diff
changeset
|
231 return -1; |
2162
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
232 } |