comparison src/video/x11/SDL_x11gamma.c @ 1668:4da1ee79c9af SDL-1.3

more tweaking indent options
author Sam Lantinga <slouken@libsdl.org>
date Mon, 29 May 2006 04:04:35 +0000
parents 782fd950bd46
children
comparison
equal deleted inserted replaced
1667:1fddae038bc8 1668:4da1ee79c9af
29 /* From the X server sources... */ 29 /* From the X server sources... */
30 #define MAX_GAMMA 10.0 30 #define MAX_GAMMA 10.0
31 #define MIN_GAMMA (1.0/MAX_GAMMA) 31 #define MIN_GAMMA (1.0/MAX_GAMMA)
32 32
33 static int 33 static int
34 X11_SetGammaNoLock (_THIS, float red, float green, float blue) 34 X11_SetGammaNoLock(_THIS, float red, float green, float blue)
35 { 35 {
36 #if SDL_VIDEO_DRIVER_X11_VIDMODE 36 #if SDL_VIDEO_DRIVER_X11_VIDMODE
37 if (use_vidmode >= 200) { 37 if (use_vidmode >= 200) {
38 SDL_NAME (XF86VidModeGamma) gamma; 38 SDL_NAME(XF86VidModeGamma) gamma;
39 Bool succeeded; 39 Bool succeeded;
40 40
41 /* Clamp the gamma values */ 41 /* Clamp the gamma values */
42 if (red < MIN_GAMMA) { 42 if (red < MIN_GAMMA) {
43 gamma.red = MIN_GAMMA; 43 gamma.red = MIN_GAMMA;
58 } else if (blue > MAX_GAMMA) { 58 } else if (blue > MAX_GAMMA) {
59 gamma.blue = MAX_GAMMA; 59 gamma.blue = MAX_GAMMA;
60 } else { 60 } else {
61 gamma.blue = blue; 61 gamma.blue = blue;
62 } 62 }
63 if (SDL_GetAppState () & SDL_APPACTIVE) { 63 if (SDL_GetAppState() & SDL_APPACTIVE) {
64 succeeded = 64 succeeded =
65 SDL_NAME (XF86VidModeSetGamma) (SDL_Display, SDL_Screen, 65 SDL_NAME(XF86VidModeSetGamma) (SDL_Display, SDL_Screen,
66 &gamma); 66 &gamma);
67 XSync (SDL_Display, False); 67 XSync(SDL_Display, False);
68 } else { 68 } else {
69 gamma_saved[0] = gamma.red; 69 gamma_saved[0] = gamma.red;
70 gamma_saved[1] = gamma.green; 70 gamma_saved[1] = gamma.green;
71 gamma_saved[2] = gamma.blue; 71 gamma_saved[2] = gamma.blue;
72 succeeded = True; 72 succeeded = True;
75 ++gamma_changed; 75 ++gamma_changed;
76 } 76 }
77 return succeeded ? 0 : -1; 77 return succeeded ? 0 : -1;
78 } 78 }
79 #endif 79 #endif
80 SDL_SetError ("Gamma correction not supported"); 80 SDL_SetError("Gamma correction not supported");
81 return -1; 81 return -1;
82 } 82 }
83 83
84 int 84 int
85 X11_SetVidModeGamma (_THIS, float red, float green, float blue) 85 X11_SetVidModeGamma(_THIS, float red, float green, float blue)
86 { 86 {
87 int result; 87 int result;
88 88
89 SDL_Lock_EventThread (); 89 SDL_Lock_EventThread();
90 result = X11_SetGammaNoLock (this, red, green, blue); 90 result = X11_SetGammaNoLock(this, red, green, blue);
91 SDL_Unlock_EventThread (); 91 SDL_Unlock_EventThread();
92 92
93 return (result); 93 return (result);
94 } 94 }
95 95
96 static int 96 static int
97 X11_GetGammaNoLock (_THIS, float *red, float *green, float *blue) 97 X11_GetGammaNoLock(_THIS, float *red, float *green, float *blue)
98 { 98 {
99 #if SDL_VIDEO_DRIVER_X11_VIDMODE 99 #if SDL_VIDEO_DRIVER_X11_VIDMODE
100 if (use_vidmode >= 200) { 100 if (use_vidmode >= 200) {
101 SDL_NAME (XF86VidModeGamma) gamma; 101 SDL_NAME(XF86VidModeGamma) gamma;
102 if (SDL_NAME (XF86VidModeGetGamma) 102 if (SDL_NAME(XF86VidModeGetGamma)
103 (SDL_Display, SDL_Screen, &gamma)) { 103 (SDL_Display, SDL_Screen, &gamma)) {
104 *red = gamma.red; 104 *red = gamma.red;
105 *green = gamma.green; 105 *green = gamma.green;
106 *blue = gamma.blue; 106 *blue = gamma.blue;
107 return 0; 107 return 0;
111 #endif 111 #endif
112 return -1; 112 return -1;
113 } 113 }
114 114
115 int 115 int
116 X11_GetVidModeGamma (_THIS, float *red, float *green, float *blue) 116 X11_GetVidModeGamma(_THIS, float *red, float *green, float *blue)
117 { 117 {
118 int result; 118 int result;
119 119
120 SDL_Lock_EventThread (); 120 SDL_Lock_EventThread();
121 result = X11_GetGammaNoLock (this, red, green, blue); 121 result = X11_GetGammaNoLock(this, red, green, blue);
122 SDL_Unlock_EventThread (); 122 SDL_Unlock_EventThread();
123 123
124 return (result); 124 return (result);
125 } 125 }
126 126
127 void 127 void
128 X11_SaveVidModeGamma (_THIS) 128 X11_SaveVidModeGamma(_THIS)
129 { 129 {
130 /* Try to save the current gamma, otherwise disable gamma control */ 130 /* Try to save the current gamma, otherwise disable gamma control */
131 if (X11_GetGammaNoLock (this, 131 if (X11_GetGammaNoLock(this,
132 &gamma_saved[0], &gamma_saved[1], 132 &gamma_saved[0], &gamma_saved[1],
133 &gamma_saved[2]) < 0) { 133 &gamma_saved[2]) < 0) {
134 this->SetGamma = 0; 134 this->SetGamma = 0;
135 this->GetGamma = 0; 135 this->GetGamma = 0;
136 } 136 }
137 gamma_changed = 0; 137 gamma_changed = 0;
138 } 138 }
139 139
140 void 140 void
141 X11_SwapVidModeGamma (_THIS) 141 X11_SwapVidModeGamma(_THIS)
142 { 142 {
143 float new_gamma[3]; 143 float new_gamma[3];
144 144
145 if (gamma_changed) { 145 if (gamma_changed) {
146 new_gamma[0] = gamma_saved[0]; 146 new_gamma[0] = gamma_saved[0];
147 new_gamma[1] = gamma_saved[1]; 147 new_gamma[1] = gamma_saved[1];
148 new_gamma[2] = gamma_saved[2]; 148 new_gamma[2] = gamma_saved[2];
149 X11_GetGammaNoLock (this, &gamma_saved[0], &gamma_saved[1], 149 X11_GetGammaNoLock(this, &gamma_saved[0], &gamma_saved[1],
150 &gamma_saved[2]); 150 &gamma_saved[2]);
151 X11_SetGammaNoLock (this, new_gamma[0], new_gamma[1], new_gamma[2]); 151 X11_SetGammaNoLock(this, new_gamma[0], new_gamma[1], new_gamma[2]);
152 } 152 }
153 } 153 }
154 154
155 /* vi: set ts=4 sw=4 expandtab: */ 155 /* vi: set ts=4 sw=4 expandtab: */