Mercurial > sdl-ios-xcode
diff src/video/x11/SDL_x11gamma.c @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | 3ba88cb7eb1b |
children | 4da1ee79c9af |
line wrap: on
line diff
--- a/src/video/x11/SDL_x11gamma.c Sun May 21 17:27:13 2006 +0000 +++ b/src/video/x11/SDL_x11gamma.c Sun May 28 13:04:16 2006 +0000 @@ -30,76 +30,80 @@ #define MAX_GAMMA 10.0 #define MIN_GAMMA (1.0/MAX_GAMMA) -static int X11_SetGammaNoLock(_THIS, float red, float green, float blue) +static int +X11_SetGammaNoLock (_THIS, float red, float green, float blue) { #if SDL_VIDEO_DRIVER_X11_VIDMODE if (use_vidmode >= 200) { - SDL_NAME(XF86VidModeGamma) gamma; + SDL_NAME (XF86VidModeGamma) gamma; Bool succeeded; - /* Clamp the gamma values */ - if ( red < MIN_GAMMA ) { - gamma.red = MIN_GAMMA; - } else - if ( red > MAX_GAMMA ) { - gamma.red = MAX_GAMMA; - } else { - gamma.red = red; - } - if ( green < MIN_GAMMA ) { - gamma.green = MIN_GAMMA; - } else - if ( green > MAX_GAMMA ) { - gamma.green = MAX_GAMMA; - } else { - gamma.green = green; - } - if ( blue < MIN_GAMMA ) { - gamma.blue = MIN_GAMMA; - } else - if ( blue > MAX_GAMMA ) { - gamma.blue = MAX_GAMMA; - } else { - gamma.blue = blue; - } - if ( SDL_GetAppState() & SDL_APPACTIVE ) { - succeeded = SDL_NAME(XF86VidModeSetGamma)(SDL_Display, SDL_Screen, &gamma); - XSync(SDL_Display, False); + /* Clamp the gamma values */ + if (red < MIN_GAMMA) { + gamma.red = MIN_GAMMA; + } else if (red > MAX_GAMMA) { + gamma.red = MAX_GAMMA; + } else { + gamma.red = red; + } + if (green < MIN_GAMMA) { + gamma.green = MIN_GAMMA; + } else if (green > MAX_GAMMA) { + gamma.green = MAX_GAMMA; + } else { + gamma.green = green; + } + if (blue < MIN_GAMMA) { + gamma.blue = MIN_GAMMA; + } else if (blue > MAX_GAMMA) { + gamma.blue = MAX_GAMMA; + } else { + gamma.blue = blue; + } + if (SDL_GetAppState () & SDL_APPACTIVE) { + succeeded = + SDL_NAME (XF86VidModeSetGamma) (SDL_Display, SDL_Screen, + &gamma); + XSync (SDL_Display, False); } else { gamma_saved[0] = gamma.red; gamma_saved[1] = gamma.green; gamma_saved[2] = gamma.blue; succeeded = True; } - if ( succeeded ) { + if (succeeded) { ++gamma_changed; } return succeeded ? 0 : -1; } #endif - SDL_SetError("Gamma correction not supported"); + SDL_SetError ("Gamma correction not supported"); return -1; } -int X11_SetVidModeGamma(_THIS, float red, float green, float blue) + +int +X11_SetVidModeGamma (_THIS, float red, float green, float blue) { int result; - SDL_Lock_EventThread(); - result = X11_SetGammaNoLock(this, red, green, blue); - SDL_Unlock_EventThread(); + SDL_Lock_EventThread (); + result = X11_SetGammaNoLock (this, red, green, blue); + SDL_Unlock_EventThread (); - return(result); + return (result); } -static int X11_GetGammaNoLock(_THIS, float *red, float *green, float *blue) +static int +X11_GetGammaNoLock (_THIS, float *red, float *green, float *blue) { #if SDL_VIDEO_DRIVER_X11_VIDMODE if (use_vidmode >= 200) { - SDL_NAME(XF86VidModeGamma) gamma; - if (SDL_NAME(XF86VidModeGetGamma)(SDL_Display, SDL_Screen, &gamma)) { - *red = gamma.red; + SDL_NAME (XF86VidModeGamma) gamma; + if (SDL_NAME (XF86VidModeGetGamma) + (SDL_Display, SDL_Screen, &gamma)) { + *red = gamma.red; *green = gamma.green; - *blue = gamma.blue; + *blue = gamma.blue; return 0; } return -1; @@ -107,36 +111,45 @@ #endif return -1; } -int X11_GetVidModeGamma(_THIS, float *red, float *green, float *blue) + +int +X11_GetVidModeGamma (_THIS, float *red, float *green, float *blue) { int result; - SDL_Lock_EventThread(); - result = X11_GetGammaNoLock(this, red, green, blue); - SDL_Unlock_EventThread(); + SDL_Lock_EventThread (); + result = X11_GetGammaNoLock (this, red, green, blue); + SDL_Unlock_EventThread (); - return(result); + return (result); } -void X11_SaveVidModeGamma(_THIS) +void +X11_SaveVidModeGamma (_THIS) { /* Try to save the current gamma, otherwise disable gamma control */ - if ( X11_GetGammaNoLock(this, - &gamma_saved[0], &gamma_saved[1], &gamma_saved[2]) < 0 ) { + if (X11_GetGammaNoLock (this, + &gamma_saved[0], &gamma_saved[1], + &gamma_saved[2]) < 0) { this->SetGamma = 0; this->GetGamma = 0; } gamma_changed = 0; } -void X11_SwapVidModeGamma(_THIS) + +void +X11_SwapVidModeGamma (_THIS) { float new_gamma[3]; - if ( gamma_changed ) { + if (gamma_changed) { new_gamma[0] = gamma_saved[0]; new_gamma[1] = gamma_saved[1]; new_gamma[2] = gamma_saved[2]; - X11_GetGammaNoLock(this, &gamma_saved[0], &gamma_saved[1], &gamma_saved[2]); - X11_SetGammaNoLock(this, new_gamma[0], new_gamma[1], new_gamma[2]); + X11_GetGammaNoLock (this, &gamma_saved[0], &gamma_saved[1], + &gamma_saved[2]); + X11_SetGammaNoLock (this, new_gamma[0], new_gamma[1], new_gamma[2]); } } + +/* vi: set ts=4 sw=4 expandtab: */