diff src/video/x11/SDL_x11gamma.c @ 1895:c121d94672cb

SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 10 Jul 2006 21:04:37 +0000
parents 3ba88cb7eb1b
children
line wrap: on
line diff
--- a/src/video/x11/SDL_x11gamma.c	Thu Jul 06 18:01:37 2006 +0000
+++ b/src/video/x11/SDL_x11gamma.c	Mon Jul 10 21:04:37 2006 +0000
@@ -30,40 +30,40 @@
 #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;
         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);
+        /* 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;
@@ -71,7 +71,7 @@
             gamma_saved[2] = gamma.blue;
             succeeded = True;
         }
-        if ( succeeded ) {
+        if (succeeded) {
             ++gamma_changed;
         }
         return succeeded ? 0 : -1;
@@ -80,7 +80,9 @@
     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;
 
@@ -88,18 +90,20 @@
     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;
+        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,7 +111,9 @@
 #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;
 
@@ -115,28 +121,35 @@
     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_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: */