Mercurial > sdl-ios-xcode
diff src/video/SDL_gamma.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 | 8e754b82cecc |
line wrap: on
line diff
--- a/src/video/SDL_gamma.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_gamma.c Mon May 29 04:04:35 2006 +0000 @@ -39,7 +39,7 @@ static void -CalculateGammaRamp (float gamma, Uint16 * ramp) +CalculateGammaRamp(float gamma, Uint16 * ramp) { int i; @@ -62,7 +62,7 @@ int value; gamma = 1.0f / gamma; for (i = 0; i < 256; ++i) { - value = (int) (pow ((double) i / 256.0, gamma) * 65535.0 + 0.5); + value = (int) (pow((double) i / 256.0, gamma) * 65535.0 + 0.5); if (value > 65535) { value = 65535; } @@ -71,7 +71,7 @@ } } static void -CalculateGammaFromRamp (float *gamma, Uint16 * ramp) +CalculateGammaFromRamp(float *gamma, Uint16 * ramp) { /* The following is adapted from a post by Garrett Bass on OpenGL Gamedev list, March 4, 2000. @@ -84,7 +84,7 @@ if ((ramp[i] != 0) && (ramp[i] != 65535)) { double B = (double) i / 256.0; double A = ramp[i] / 65535.0; - sum += (float) (log (A) / log (B)); + sum += (float) (log(A) / log(B)); count++; } } @@ -94,9 +94,9 @@ } int -SDL_SetGamma (float red, float green, float blue) +SDL_SetGamma(float red, float green, float blue) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); int succeeded; succeeded = -1; @@ -104,14 +104,14 @@ { Uint16 ramp[3][256]; - CalculateGammaRamp (red, ramp[0]); - CalculateGammaRamp (green, ramp[1]); - CalculateGammaRamp (blue, ramp[2]); - succeeded = SDL_SetGammaRamp (ramp[0], ramp[1], ramp[2]); + CalculateGammaRamp(red, ramp[0]); + CalculateGammaRamp(green, ramp[1]); + CalculateGammaRamp(blue, ramp[2]); + succeeded = SDL_SetGammaRamp(ramp[0], ramp[1], ramp[2]); } if ((succeeded < 0) && _this->SetGamma) { - SDL_ClearError (); - succeeded = _this->SetGamma (_this, red, green, blue); + SDL_ClearError(); + succeeded = _this->SetGamma(_this, red, green, blue); } return succeeded; } @@ -120,9 +120,9 @@ so this function isn't officially supported. */ int -SDL_GetGamma (float *red, float *green, float *blue) +SDL_GetGamma(float *red, float *green, float *blue) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); int succeeded; succeeded = -1; @@ -130,79 +130,79 @@ { Uint16 ramp[3][256]; - succeeded = SDL_GetGammaRamp (ramp[0], ramp[1], ramp[2]); + succeeded = SDL_GetGammaRamp(ramp[0], ramp[1], ramp[2]); if (succeeded >= 0) { - CalculateGammaFromRamp (red, ramp[0]); - CalculateGammaFromRamp (green, ramp[1]); - CalculateGammaFromRamp (blue, ramp[2]); + CalculateGammaFromRamp(red, ramp[0]); + CalculateGammaFromRamp(green, ramp[1]); + CalculateGammaFromRamp(blue, ramp[2]); } } if ((succeeded < 0) && _this->GetGamma) { - SDL_ClearError (); - succeeded = _this->GetGamma (_this, red, green, blue); + SDL_ClearError(); + succeeded = _this->GetGamma(_this, red, green, blue); } return succeeded; } int -SDL_SetGammaRamp (const Uint16 * red, const Uint16 * green, - const Uint16 * blue) +SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green, + const Uint16 * blue) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); int succeeded; SDL_Surface *screen = SDL_PublicSurface; /* Verify the screen parameter */ if (!screen) { - SDL_SetError ("No video mode has been set"); + SDL_SetError("No video mode has been set"); return -1; } /* Lazily allocate the gamma tables */ if (!SDL_CurrentWindow.gamma) { - SDL_GetGammaRamp (0, 0, 0); + SDL_GetGammaRamp(0, 0, 0); } /* Fill the gamma table with the new values */ if (red) { - SDL_memcpy (&SDL_CurrentWindow.gamma[0 * 256], red, - 256 * sizeof (*SDL_CurrentWindow.gamma)); + SDL_memcpy(&SDL_CurrentWindow.gamma[0 * 256], red, + 256 * sizeof(*SDL_CurrentWindow.gamma)); } if (green) { - SDL_memcpy (&SDL_CurrentWindow.gamma[1 * 256], green, - 256 * sizeof (*SDL_CurrentWindow.gamma)); + SDL_memcpy(&SDL_CurrentWindow.gamma[1 * 256], green, + 256 * sizeof(*SDL_CurrentWindow.gamma)); } if (blue) { - SDL_memcpy (&SDL_CurrentWindow.gamma[2 * 256], blue, - 256 * sizeof (*SDL_CurrentWindow.gamma)); + SDL_memcpy(&SDL_CurrentWindow.gamma[2 * 256], blue, + 256 * sizeof(*SDL_CurrentWindow.gamma)); } /* Try to set the gamma ramp in the driver */ succeeded = -1; if (_this->SetGammaRamp) { - succeeded = _this->SetGammaRamp (_this, SDL_CurrentWindow.gamma); + succeeded = _this->SetGammaRamp(_this, SDL_CurrentWindow.gamma); } else { - SDL_SetError ("Gamma ramp manipulation not supported"); + SDL_SetError("Gamma ramp manipulation not supported"); } return succeeded; } int -SDL_GetGammaRamp (Uint16 * red, Uint16 * green, Uint16 * blue) +SDL_GetGammaRamp(Uint16 * red, Uint16 * green, Uint16 * blue) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); /* Lazily allocate the gamma table */ if (!SDL_CurrentWindow.gamma) { SDL_CurrentWindow.gamma = - SDL_malloc (3 * 256 * sizeof (*SDL_CurrentWindow.gamma)); + SDL_malloc(3 * 256 * sizeof(*SDL_CurrentWindow.gamma)); if (!SDL_CurrentWindow.gamma) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return -1; } if (_this->GetGammaRamp) { /* Get the real hardware gamma */ - _this->GetGammaRamp (_this, SDL_CurrentWindow.gamma); + _this->GetGammaRamp(_this, SDL_CurrentWindow.gamma); } else { /* Assume an identity gamma */ int i; @@ -216,16 +216,16 @@ /* Just copy from our internal table */ if (red) { - SDL_memcpy (red, &SDL_CurrentWindow.gamma[0 * 256], - 256 * sizeof (*red)); + SDL_memcpy(red, &SDL_CurrentWindow.gamma[0 * 256], + 256 * sizeof(*red)); } if (green) { - SDL_memcpy (green, &SDL_CurrentWindow.gamma[1 * 256], - 256 * sizeof (*green)); + SDL_memcpy(green, &SDL_CurrentWindow.gamma[1 * 256], + 256 * sizeof(*green)); } if (blue) { - SDL_memcpy (blue, &SDL_CurrentWindow.gamma[2 * 256], - 256 * sizeof (*blue)); + SDL_memcpy(blue, &SDL_CurrentWindow.gamma[2 * 256], + 256 * sizeof(*blue)); } return 0; }