Removed gamma support since it wasn't widely used and not well supported.
authorSam Lantinga <slouken@libsdl.org>
Thu, 10 Feb 2011 11:39:08 -0800
changeset 52433a8a452b49f0
parent 5242 78ce7bfd0faf
child 5244 762e40fb8e28
Removed gamma support since it wasn't widely used and not well supported.
include/SDL_compat.h
include/SDL_video.h
src/SDL_compat.c
src/video/SDL_gamma.c
src/video/SDL_pixels.c
src/video/SDL_pixels_c.h
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/bwindow/SDL_sysvideo.cc
src/video/directfb/SDL_DirectFB_video.c
src/video/pandora/SDL_pandora.h
src/video/windows/SDL_windowsgamma.c
src/video/windows/SDL_windowsgamma.h
src/video/windows/SDL_windowsvideo.c
src/video/windows/SDL_windowsvideo.h
src/video/x11/SDL_x11gamma.c
src/video/x11/SDL_x11gamma.h
src/video/x11/SDL_x11modes.c
src/video/x11/SDL_x11opengl.c
src/video/x11/SDL_x11video.c
src/video/x11/SDL_x11video.h
src/video/x11/SDL_x11window.c
test/Makefile.in
test/testgamma.c
     1.1 --- a/include/SDL_compat.h	Thu Feb 10 10:37:35 2011 -0800
     1.2 +++ b/include/SDL_compat.h	Thu Feb 10 11:39:08 2011 -0800
     1.3 @@ -328,6 +328,12 @@
     1.4                                                    SDL_Rect * dstrect);
     1.5  extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay * overlay);
     1.6  extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
     1.7 +extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue);
     1.8 +extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 * red,
     1.9 +                                             const Uint16 * green,
    1.10 +                                             const Uint16 * blue);
    1.11 +extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 * red, Uint16 * green,
    1.12 +                                             Uint16 * blue);
    1.13  extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
    1.14  extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
    1.15  extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
     2.1 --- a/include/SDL_video.h	Thu Feb 10 10:37:35 2011 -0800
     2.2 +++ b/include/SDL_video.h	Thu Feb 10 11:39:08 2011 -0800
     2.3 @@ -361,55 +361,6 @@
     2.4  extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window);
     2.5  
     2.6  /**
     2.7 - *  \brief Set the gamma correction for each of the color channels on the 
     2.8 - *         currently selected display.
     2.9 - *  
    2.10 - *  \return 0 on success, or -1 if setting the gamma isn't supported.
    2.11 - *  
    2.12 - *  \sa SDL_SetGammaRamp()
    2.13 - */
    2.14 -extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue);
    2.15 -
    2.16 -/**
    2.17 - *  \brief Set the gamma ramp for the currently selected display.
    2.18 - *  
    2.19 - *  \param red The translation table for the red channel, or NULL.
    2.20 - *  \param green The translation table for the green channel, or NULL.
    2.21 - *  \param blue The translation table for the blue channel, or NULL.
    2.22 - *  
    2.23 - *  \return 0 on success, or -1 if gamma ramps are unsupported.
    2.24 - *  
    2.25 - *  Set the gamma translation table for the red, green, and blue channels
    2.26 - *  of the video hardware.  Each table is an array of 256 16-bit quantities,
    2.27 - *  representing a mapping between the input and output for that channel.
    2.28 - *  The input is the index into the array, and the output is the 16-bit
    2.29 - *  gamma value at that index, scaled to the output color precision.
    2.30 - *  
    2.31 - *  \sa SDL_GetGammaRamp()
    2.32 - */
    2.33 -extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 * red,
    2.34 -                                             const Uint16 * green,
    2.35 -                                             const Uint16 * blue);
    2.36 -
    2.37 -/**
    2.38 - *  \brief Get the gamma ramp for the currently selected display.
    2.39 - *  
    2.40 - *  \param red   A pointer to a 256 element array of 16-bit quantities to hold 
    2.41 - *               the translation table for the red channel, or NULL.
    2.42 - *  \param green A pointer to a 256 element array of 16-bit quantities to hold 
    2.43 - *               the translation table for the green channel, or NULL.
    2.44 - *  \param blue  A pointer to a 256 element array of 16-bit quantities to hold 
    2.45 - *               the translation table for the blue channel, or NULL.
    2.46 - *   
    2.47 - *  \return 0 on success, or -1 if gamma ramps are unsupported.
    2.48 - *  
    2.49 - *  \sa SDL_SetGammaRamp()
    2.50 - */
    2.51 -extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 * red, Uint16 * green,
    2.52 -                                             Uint16 * blue);
    2.53 -
    2.54 -
    2.55 -/**
    2.56   *  \brief Create a window with the specified position, dimensions, and flags.
    2.57   *  
    2.58   *  \param title The title of the window, in UTF-8 encoding.
     3.1 --- a/src/SDL_compat.c	Thu Feb 10 10:37:35 2011 -0800
     3.2 +++ b/src/SDL_compat.c	Thu Feb 10 11:39:08 2011 -0800
     3.3 @@ -1526,6 +1526,26 @@
     3.4      SDL_GL_SwapWindow(SDL_VideoWindow);
     3.5  }
     3.6  
     3.7 +int
     3.8 +SDL_SetGamma(float red, float green, float blue)
     3.9 +{
    3.10 +    SDL_Unsupported();
    3.11 +    return -1;
    3.12 +}
    3.13 +
    3.14 +int
    3.15 +SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green, const Uint16 * blue)
    3.16 +{
    3.17 +    SDL_Unsupported();
    3.18 +    return -1;
    3.19 +}
    3.20 +
    3.21 +int
    3.22 +SDL_GetGammaRamp(Uint16 * red, Uint16 * green, Uint16 * blue)
    3.23 +{
    3.24 +    SDL_Unsupported();
    3.25 +    return -1;
    3.26 +}
    3.27  
    3.28  int
    3.29  SDL_EnableKeyRepeat(int delay, int interval)
     4.1 --- a/src/video/SDL_gamma.c	Thu Feb 10 10:37:35 2011 -0800
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,236 +0,0 @@
     4.4 -/*
     4.5 -    SDL - Simple DirectMedia Layer
     4.6 -    Copyright (C) 1997-2010 Sam Lantinga
     4.7 -
     4.8 -    This library is free software; you can redistribute it and/or
     4.9 -    modify it under the terms of the GNU Lesser General Public
    4.10 -    License as published by the Free Software Foundation; either
    4.11 -    version 2.1 of the License, or (at your option) any later version.
    4.12 -
    4.13 -    This library is distributed in the hope that it will be useful,
    4.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.16 -    Lesser General Public License for more details.
    4.17 -
    4.18 -    You should have received a copy of the GNU Lesser General Public
    4.19 -    License along with this library; if not, write to the Free Software
    4.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    4.21 -
    4.22 -    Sam Lantinga
    4.23 -    slouken@libsdl.org
    4.24 -*/
    4.25 -#include "SDL_config.h"
    4.26 -
    4.27 -/* Gamma correction support */
    4.28 -
    4.29 -#include "SDL_sysvideo.h"
    4.30 -
    4.31 -
    4.32 -static void
    4.33 -CalculateGammaRamp(float gamma, Uint16 * ramp)
    4.34 -{
    4.35 -    int i;
    4.36 -
    4.37 -    /* 0.0 gamma is all black */
    4.38 -    if (gamma <= 0.0f) {
    4.39 -        for (i = 0; i < 256; ++i) {
    4.40 -            ramp[i] = 0;
    4.41 -        }
    4.42 -        return;
    4.43 -    } else
    4.44 -        /* 1.0 gamma is identity */
    4.45 -    if (gamma == 1.0f) {
    4.46 -        for (i = 0; i < 256; ++i) {
    4.47 -            ramp[i] = (i << 8) | i;
    4.48 -        }
    4.49 -        return;
    4.50 -    } else
    4.51 -        /* Calculate a real gamma ramp */
    4.52 -    {
    4.53 -        int value;
    4.54 -        gamma = 1.0f / gamma;
    4.55 -        for (i = 0; i < 256; ++i) {
    4.56 -            value =
    4.57 -                (int) (SDL_pow((double) i / 256.0, gamma) * 65535.0 + 0.5);
    4.58 -            if (value > 65535) {
    4.59 -                value = 65535;
    4.60 -            }
    4.61 -            ramp[i] = (Uint16) value;
    4.62 -        }
    4.63 -    }
    4.64 -}
    4.65 -
    4.66 -static void
    4.67 -CalculateGammaFromRamp(float *gamma, Uint16 * ramp)
    4.68 -{
    4.69 -    /* The following is adapted from a post by Garrett Bass on OpenGL
    4.70 -       Gamedev list, March 4, 2000.
    4.71 -     */
    4.72 -    float sum = 0.0f;
    4.73 -    int i, count = 0;
    4.74 -
    4.75 -    *gamma = 1.0;
    4.76 -    for (i = 1; i < 256; ++i) {
    4.77 -        if ((ramp[i] != 0) && (ramp[i] != 65535)) {
    4.78 -            double B = (double) i / 256.0;
    4.79 -            double A = ramp[i] / 65535.0;
    4.80 -            sum += (float) (SDL_log(A) / SDL_log(B));
    4.81 -            count++;
    4.82 -        }
    4.83 -    }
    4.84 -    if (count && sum > 0.0f) {
    4.85 -        *gamma = 1.0f / (sum / count);
    4.86 -    }
    4.87 -}
    4.88 -
    4.89 -int
    4.90 -SDL_SetGamma(float red, float green, float blue)
    4.91 -{
    4.92 -    Uint16 ramp[3][256];
    4.93 -
    4.94 -    CalculateGammaRamp(red, ramp[0]);
    4.95 -    CalculateGammaRamp(green, ramp[1]);
    4.96 -    CalculateGammaRamp(blue, ramp[2]);
    4.97 -
    4.98 -    return SDL_SetGammaRamp(ramp[0], ramp[1], ramp[2]);
    4.99 -}
   4.100 -
   4.101 -/* Calculating the gamma by integrating the gamma ramps isn't exact,
   4.102 -   so this function isn't officially supported.
   4.103 -*/
   4.104 -int
   4.105 -SDL_GetGamma(float *red, float *green, float *blue)
   4.106 -{
   4.107 -    int succeeded;
   4.108 -    Uint16 ramp[3][256];
   4.109 -
   4.110 -    succeeded = SDL_GetGammaRamp(ramp[0], ramp[1], ramp[2]);
   4.111 -    if (succeeded >= 0) {
   4.112 -        CalculateGammaFromRamp(red, ramp[0]);
   4.113 -        CalculateGammaFromRamp(green, ramp[1]);
   4.114 -        CalculateGammaFromRamp(blue, ramp[2]);
   4.115 -    }
   4.116 -    return succeeded;
   4.117 -}
   4.118 -
   4.119 -static void
   4.120 -SDL_UninitializedVideo()
   4.121 -{
   4.122 -    SDL_SetError("Video subsystem has not been initialized");
   4.123 -}
   4.124 -
   4.125 -int
   4.126 -SDL_SetGammaRampForDisplay(SDL_VideoDisplay * display, const Uint16 * red, const Uint16 * green, const Uint16 * blue)
   4.127 -{
   4.128 -    SDL_VideoDevice *_this = SDL_GetVideoDevice();
   4.129 -    int succeeded;
   4.130 -
   4.131 -    if (!_this) {
   4.132 -        SDL_UninitializedVideo();
   4.133 -        return -1;
   4.134 -    }
   4.135 -
   4.136 -    /* Lazily allocate the gamma tables */
   4.137 -    if (!display->gamma) {
   4.138 -        if (SDL_GetGammaRampForDisplay(display, NULL, NULL, NULL) < 0) {
   4.139 -            return -1;
   4.140 -        }
   4.141 -    }
   4.142 -
   4.143 -    /* Fill the gamma table with the new values */
   4.144 -    if (red) {
   4.145 -        SDL_memcpy(&display->gamma[0 * 256], red, 256 * sizeof(*display->gamma));
   4.146 -    }
   4.147 -    if (green) {
   4.148 -        SDL_memcpy(&display->gamma[1 * 256], green, 256 * sizeof(*display->gamma));
   4.149 -    }
   4.150 -    if (blue) {
   4.151 -        SDL_memcpy(&display->gamma[2 * 256], blue, 256 * sizeof(*display->gamma));
   4.152 -    }
   4.153 -
   4.154 -    /* Try to set the gamma ramp in the driver */
   4.155 -    succeeded = -1;
   4.156 -    if (_this && _this->SetDisplayGammaRamp) {
   4.157 -        if (SDL_GetFocusWindow()) {
   4.158 -            succeeded =
   4.159 -                _this->SetDisplayGammaRamp(_this, display, display->gamma);
   4.160 -        } else {
   4.161 -            succeeded = 0;
   4.162 -        }
   4.163 -    } else {
   4.164 -        SDL_SetError("Gamma ramp manipulation not supported");
   4.165 -    }
   4.166 -    return succeeded;
   4.167 -}
   4.168 -
   4.169 -int
   4.170 -SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green, const Uint16 * blue)
   4.171 -{
   4.172 -    SDL_VideoDevice *_this = SDL_GetVideoDevice();
   4.173 -    if (!_this) {
   4.174 -        SDL_UninitializedVideo();
   4.175 -        return -1;
   4.176 -    }
   4.177 -    return SDL_SetGammaRampForDisplay(SDL_CurrentDisplay, red, green, blue);
   4.178 -}
   4.179 -
   4.180 -int
   4.181 -SDL_GetGammaRampForDisplay(SDL_VideoDisplay * display, Uint16 * red, Uint16 * green, Uint16 * blue)
   4.182 -{
   4.183 -    SDL_VideoDevice *_this = SDL_GetVideoDevice();
   4.184 -
   4.185 -    if (!_this) {
   4.186 -        SDL_UninitializedVideo();
   4.187 -        return -1;
   4.188 -    }
   4.189 -
   4.190 -    /* Lazily allocate the gamma table */
   4.191 -    if (!display->gamma) {
   4.192 -        size_t rampsize = (3 * 256 * sizeof(*display->gamma));
   4.193 -
   4.194 -        display->gamma = SDL_malloc(rampsize * 2);
   4.195 -        if (!display->gamma) {
   4.196 -            SDL_OutOfMemory();
   4.197 -            return -1;
   4.198 -        }
   4.199 -        if (_this && _this->GetDisplayGammaRamp) {
   4.200 -            /* Get the real hardware gamma */
   4.201 -            _this->GetDisplayGammaRamp(_this, display, display->gamma);
   4.202 -        } else {
   4.203 -            /* Assume an identity gamma */
   4.204 -            int i;
   4.205 -            for (i = 0; i < 256; ++i) {
   4.206 -                display->gamma[0 * 256 + i] = (i << 8) | i;
   4.207 -                display->gamma[1 * 256 + i] = (i << 8) | i;
   4.208 -                display->gamma[2 * 256 + i] = (i << 8) | i;
   4.209 -            }
   4.210 -        }
   4.211 -        display->saved_gamma = display->gamma + (3 * 256);
   4.212 -        SDL_memcpy(display->saved_gamma, display->gamma, rampsize);
   4.213 -    }
   4.214 -
   4.215 -    /* Just copy from our internal table */
   4.216 -    if (red) {
   4.217 -        SDL_memcpy(red, &display->gamma[0 * 256], 256 * sizeof(*red));
   4.218 -    }
   4.219 -    if (green) {
   4.220 -        SDL_memcpy(green, &display->gamma[1 * 256], 256 * sizeof(*green));
   4.221 -    }
   4.222 -    if (blue) {
   4.223 -        SDL_memcpy(blue, &display->gamma[2 * 256], 256 * sizeof(*blue));
   4.224 -    }
   4.225 -    return 0;
   4.226 -}
   4.227 -
   4.228 -int
   4.229 -SDL_GetGammaRamp(Uint16 * red, Uint16 * green, Uint16 * blue)
   4.230 -{
   4.231 -    SDL_VideoDevice *_this = SDL_GetVideoDevice();
   4.232 -    if (!_this) {
   4.233 -        SDL_UninitializedVideo();
   4.234 -        return -1;
   4.235 -    }
   4.236 -    return SDL_GetGammaRampForDisplay(SDL_CurrentDisplay, red, green, blue);
   4.237 -}
   4.238 -
   4.239 -/* vi: set ts=4 sw=4 expandtab: */
     5.1 --- a/src/video/SDL_pixels.c	Thu Feb 10 10:37:35 2011 -0800
     5.2 +++ b/src/video/SDL_pixels.c	Thu Feb 10 11:39:08 2011 -0800
     5.3 @@ -764,20 +764,6 @@
     5.4      }
     5.5  }
     5.6  
     5.7 -/* Apply gamma to a set of colors - this is easy. :) */
     5.8 -void
     5.9 -SDL_ApplyGamma(Uint16 * gamma, SDL_Color * colors, SDL_Color * output,
    5.10 -               int ncolors)
    5.11 -{
    5.12 -    int i;
    5.13 -
    5.14 -    for (i = 0; i < ncolors; ++i) {
    5.15 -        output[i].r = gamma[0 * 256 + colors[i].r] >> 8;
    5.16 -        output[i].g = gamma[1 * 256 + colors[i].g] >> 8;
    5.17 -        output[i].b = gamma[2 * 256 + colors[i].b] >> 8;
    5.18 -    }
    5.19 -}
    5.20 -
    5.21  /* Map from Palette to Palette */
    5.22  static Uint8 *
    5.23  Map1to1(SDL_Palette * src, SDL_Palette * dst, int *identical)
     6.1 --- a/src/video/SDL_pixels_c.h	Thu Feb 10 10:37:35 2011 -0800
     6.2 +++ b/src/video/SDL_pixels_c.h	Thu Feb 10 11:39:08 2011 -0800
     6.3 @@ -45,7 +45,5 @@
     6.4  extern int SDL_CalculatePitch(SDL_Surface * surface);
     6.5  extern void SDL_DitherColors(SDL_Color * colors, int bpp);
     6.6  extern Uint8 SDL_FindColor(SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b);
     6.7 -extern void SDL_ApplyGamma(Uint16 * gamma, SDL_Color * colors,
     6.8 -                           SDL_Color * output, int ncolors);
     6.9  
    6.10  /* vi: set ts=4 sw=4 expandtab: */
     7.1 --- a/src/video/SDL_sysvideo.h	Thu Feb 10 10:37:35 2011 -0800
     7.2 +++ b/src/video/SDL_sysvideo.h	Thu Feb 10 11:39:08 2011 -0800
     7.3 @@ -110,9 +110,6 @@
     7.4      SDL_DisplayMode current_mode;
     7.5      SDL_bool updating_fullscreen;
     7.6  
     7.7 -    Uint16 *gamma;
     7.8 -    Uint16 *saved_gamma;        /* (just offset into gamma) */
     7.9 -
    7.10      SDL_Window *windows;
    7.11      SDL_Window *fullscreen_window;
    7.12  
    7.13 @@ -169,12 +166,6 @@
    7.14       */
    7.15      int (*SetDisplayMode) (_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
    7.16  
    7.17 -    /* Set the gamma ramp */
    7.18 -    int (*SetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
    7.19 -
    7.20 -    /* Get the gamma ramp */
    7.21 -    int (*GetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
    7.22 -
    7.23      /* * * */
    7.24      /*
    7.25       * Window functions
    7.26 @@ -343,8 +334,6 @@
    7.27  extern int SDL_GetCurrentDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode);
    7.28  extern SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode, SDL_DisplayMode * closest);
    7.29  extern int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode);
    7.30 -extern int SDL_SetGammaRampForDisplay(SDL_VideoDisplay * display, const Uint16 * red, const Uint16 * green, const Uint16 * blue);
    7.31 -extern int SDL_GetGammaRampForDisplay(SDL_VideoDisplay * display, Uint16 * red, Uint16 * green, Uint16 * blue);
    7.32  
    7.33  extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
    7.34  
     8.1 --- a/src/video/SDL_video.c	Thu Feb 10 10:37:35 2011 -0800
     8.2 +++ b/src/video/SDL_video.c	Thu Feb 10 11:39:08 2011 -0800
     8.3 @@ -1644,9 +1644,6 @@
     8.4  {
     8.5      SDL_VideoDisplay *display = window->display;
     8.6  
     8.7 -    if (display->gamma && _this->SetDisplayGammaRamp) {
     8.8 -        _this->SetDisplayGammaRamp(_this, display, display->gamma);
     8.9 -    }
    8.10      if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN))
    8.11          && _this->SetWindowGrab) {
    8.12          _this->SetWindowGrab(_this, window);
    8.13 @@ -1664,9 +1661,6 @@
    8.14          SDL_MinimizeWindow(window);
    8.15      }
    8.16  
    8.17 -    if (display->gamma && _this->SetDisplayGammaRamp) {
    8.18 -        _this->SetDisplayGammaRamp(_this, display, display->saved_gamma);
    8.19 -    }
    8.20      if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN))
    8.21          && _this->SetWindowGrab) {
    8.22          _this->SetWindowGrab(_this, window);
    8.23 @@ -1825,10 +1819,6 @@
    8.24              SDL_free(display->desktop_mode.driverdata);
    8.25              display->desktop_mode.driverdata = NULL;
    8.26          }
    8.27 -        if (display->gamma) {
    8.28 -            SDL_free(display->gamma);
    8.29 -            display->gamma = NULL;
    8.30 -        }
    8.31          if (display->driverdata) {
    8.32              SDL_free(display->driverdata);
    8.33              display->driverdata = NULL;
     9.1 --- a/src/video/bwindow/SDL_sysvideo.cc	Thu Feb 10 10:37:35 2011 -0800
     9.2 +++ b/src/video/bwindow/SDL_sysvideo.cc	Thu Feb 10 11:39:08 2011 -0800
     9.3 @@ -129,7 +129,6 @@
     9.4          device->UnlockHWSurface = BE_UnlockHWSurface;
     9.5          device->FlipHWSurface = NULL;
     9.6          device->FreeHWSurface = BE_FreeHWSurface;
     9.7 -        /* Gamma support */
     9.8  #if SDL_VIDEO_OPENGL
     9.9          /* OpenGL support */
    9.10          device->GL_LoadLibrary = BE_GL_LoadLibrary;
    10.1 --- a/src/video/directfb/SDL_DirectFB_video.c	Thu Feb 10 10:37:35 2011 -0800
    10.2 +++ b/src/video/directfb/SDL_DirectFB_video.c	Thu Feb 10 11:39:08 2011 -0800
    10.3 @@ -27,7 +27,6 @@
    10.4  
    10.5  #include "SDL_DirectFB_events.h"
    10.6  /*
    10.7 - * #include "SDL_DirectFB_gamma.h"
    10.8   * #include "SDL_DirectFB_keyboard.h"
    10.9   */
   10.10  #include "SDL_DirectFB_modes.h"
    11.1 --- a/src/video/pandora/SDL_pandora.h	Thu Feb 10 10:37:35 2011 -0800
    11.2 +++ b/src/video/pandora/SDL_pandora.h	Thu Feb 10 11:39:08 2011 -0800
    11.3 @@ -70,8 +70,6 @@
    11.4  void PND_videoquit(_THIS);
    11.5  void PND_getdisplaymodes(_THIS, SDL_VideoDisplay * display);
    11.6  int PND_setdisplaymode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
    11.7 -int PND_setdisplaygammaramp(_THIS, Uint16 * ramp);
    11.8 -int PND_getdisplaygammaramp(_THIS, Uint16 * ramp);
    11.9  int PND_createwindow(_THIS, SDL_Window * window);
   11.10  int PND_createwindowfrom(_THIS, SDL_Window * window, const void *data);
   11.11  void PND_setwindowtitle(_THIS, SDL_Window * window);
    12.1 --- a/src/video/windows/SDL_windowsgamma.c	Thu Feb 10 10:37:35 2011 -0800
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,71 +0,0 @@
    12.4 -/*
    12.5 -    SDL - Simple DirectMedia Layer
    12.6 -    Copyright (C) 1997-2010 Sam Lantinga
    12.7 -
    12.8 -    This library is free software; you can redistribute it and/or
    12.9 -    modify it under the terms of the GNU Lesser General Public
   12.10 -    License as published by the Free Software Foundation; either
   12.11 -    version 2.1 of the License, or (at your option) any later version.
   12.12 -
   12.13 -    This library is distributed in the hope that it will be useful,
   12.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   12.16 -    Lesser General Public License for more details.
   12.17 -
   12.18 -    You should have received a copy of the GNU Lesser General Public
   12.19 -    License along with this library; if not, write to the Free Software
   12.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   12.21 -
   12.22 -    Sam Lantinga
   12.23 -    slouken@libsdl.org
   12.24 -*/
   12.25 -#include "SDL_config.h"
   12.26 -
   12.27 -#include "SDL_windowsvideo.h"
   12.28 -
   12.29 -
   12.30 -int
   12.31 -WIN_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp)
   12.32 -{
   12.33 -#ifdef _WIN32_WCE
   12.34 -    return -1;
   12.35 -#else
   12.36 -    SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
   12.37 -    HDC hdc;
   12.38 -    BOOL succeeded = FALSE;
   12.39 -
   12.40 -    hdc = CreateDC(data->DeviceName, NULL, NULL, NULL);
   12.41 -    if (hdc) {
   12.42 -        succeeded = SetDeviceGammaRamp(hdc, ramp);
   12.43 -        if (!succeeded) {
   12.44 -            WIN_SetError("SetDeviceGammaRamp()");
   12.45 -        }
   12.46 -        DeleteDC(hdc);
   12.47 -    }
   12.48 -    return succeeded ? 0 : -1;
   12.49 -#endif
   12.50 -}
   12.51 -
   12.52 -int
   12.53 -WIN_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp)
   12.54 -{
   12.55 -#ifdef _WIN32_WCE
   12.56 -    return -1;
   12.57 -#else
   12.58 -    SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
   12.59 -    HDC hdc;
   12.60 -    BOOL succeeded = FALSE;
   12.61 -
   12.62 -    hdc = CreateDC(data->DeviceName, NULL, NULL, NULL);
   12.63 -    if (hdc) {
   12.64 -        succeeded = GetDeviceGammaRamp(hdc, ramp);
   12.65 -        if (!succeeded) {
   12.66 -            WIN_SetError("GetDeviceGammaRamp()");
   12.67 -        }
   12.68 -        DeleteDC(hdc);
   12.69 -    }
   12.70 -    return succeeded ? 0 : -1;
   12.71 -#endif
   12.72 -}
   12.73 -
   12.74 -/* vi: set ts=4 sw=4 expandtab: */
    13.1 --- a/src/video/windows/SDL_windowsgamma.h	Thu Feb 10 10:37:35 2011 -0800
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,32 +0,0 @@
    13.4 -/*
    13.5 -    SDL - Simple DirectMedia Layer
    13.6 -    Copyright (C) 1997-2010 Sam Lantinga
    13.7 -
    13.8 -    This library is free software; you can redistribute it and/or
    13.9 -    modify it under the terms of the GNU Lesser General Public
   13.10 -    License as published by the Free Software Foundation; either
   13.11 -    version 2.1 of the License, or (at your option) any later version.
   13.12 -
   13.13 -    This library is distributed in the hope that it will be useful,
   13.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   13.16 -    Lesser General Public License for more details.
   13.17 -
   13.18 -    You should have received a copy of the GNU Lesser General Public
   13.19 -    License along with this library; if not, write to the Free Software
   13.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   13.21 -
   13.22 -    Sam Lantinga
   13.23 -    slouken@libsdl.org
   13.24 -*/
   13.25 -#include "SDL_config.h"
   13.26 -
   13.27 -#ifndef _SDL_windowsgamma_h
   13.28 -#define _SDL_windowsgamma_h
   13.29 -
   13.30 -extern int WIN_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
   13.31 -extern int WIN_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
   13.32 -
   13.33 -#endif /* _SDL_windowsgamma_h */
   13.34 -
   13.35 -/* vi: set ts=4 sw=4 expandtab: */
    14.1 --- a/src/video/windows/SDL_windowsvideo.c	Thu Feb 10 10:37:35 2011 -0800
    14.2 +++ b/src/video/windows/SDL_windowsvideo.c	Thu Feb 10 11:39:08 2011 -0800
    14.3 @@ -109,8 +109,6 @@
    14.4      device->GetDisplayBounds = WIN_GetDisplayBounds;
    14.5      device->GetDisplayModes = WIN_GetDisplayModes;
    14.6      device->SetDisplayMode = WIN_SetDisplayMode;
    14.7 -    device->SetDisplayGammaRamp = WIN_SetDisplayGammaRamp;
    14.8 -    device->GetDisplayGammaRamp = WIN_GetDisplayGammaRamp;
    14.9      device->PumpEvents = WIN_PumpEvents;
   14.10  
   14.11  #undef CreateWindow
    15.1 --- a/src/video/windows/SDL_windowsvideo.h	Thu Feb 10 10:37:35 2011 -0800
    15.2 +++ b/src/video/windows/SDL_windowsvideo.h	Thu Feb 10 11:39:08 2011 -0800
    15.3 @@ -41,7 +41,6 @@
    15.4  
    15.5  #include "SDL_windowsclipboard.h"
    15.6  #include "SDL_windowsevents.h"
    15.7 -#include "SDL_windowsgamma.h"
    15.8  #include "SDL_windowskeyboard.h"
    15.9  #include "SDL_windowsmodes.h"
   15.10  #include "SDL_windowsmouse.h"
    16.1 --- a/src/video/x11/SDL_x11gamma.c	Thu Feb 10 10:37:35 2011 -0800
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,232 +0,0 @@
    16.4 -/*
    16.5 -    SDL - Simple DirectMedia Layer
    16.6 -    Copyright (C) 1997-2010 Sam Lantinga
    16.7 -
    16.8 -    This library is free software; you can redistribute it and/or
    16.9 -    modify it under the terms of the GNU Lesser General Public
   16.10 -    License as published by the Free Software Foundation; either
   16.11 -    version 2.1 of the License, or (at your option) any later version.
   16.12 -
   16.13 -    This library is distributed in the hope that it will be useful,
   16.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   16.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   16.16 -    Lesser General Public License for more details.
   16.17 -
   16.18 -    You should have received a copy of the GNU Lesser General Public
   16.19 -    License along with this library; if not, write to the Free Software
   16.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   16.21 -
   16.22 -    Sam Lantinga
   16.23 -    slouken@libsdl.org
   16.24 -*/
   16.25 -#include "SDL_config.h"
   16.26 -#include "../SDL_sysvideo.h"
   16.27 -#include "SDL_x11video.h"
   16.28 -
   16.29 -    /* The size of *all* SDL gamma ramps */
   16.30 -#define SDL_GammaRampSize (3 * 256 * sizeof(Uint16))
   16.31 -
   16.32 -static int numCmaps = 0;
   16.33 -
   16.34 -typedef struct
   16.35 -{
   16.36 -    Display *display;
   16.37 -    int scrNum;
   16.38 -    Colormap colormap;
   16.39 -    Visual visual;
   16.40 -    Uint16 *ramp;
   16.41 -} cmapTableEntry;
   16.42 -
   16.43 -cmapTableEntry *cmapTable = NULL;
   16.44 -
   16.45 -/* To reduce the overhead as much as possible lets do as little as
   16.46 -   possible. When we do have to create a colormap keep track of it and
   16.47 -   reuse it. We're going to do this for both DirectColor and
   16.48 -   PseudoColor colormaps. */
   16.49 -
   16.50 -Colormap
   16.51 -X11_LookupColormap(Display * display, int scrNum, VisualID vid)
   16.52 -{
   16.53 -    int i;
   16.54 -
   16.55 -    for (i = 0; i < numCmaps; i++) {
   16.56 -        if (cmapTable[i].display == display &&
   16.57 -            cmapTable[i].scrNum == scrNum &&
   16.58 -            cmapTable[i].visual.visualid == vid) {
   16.59 -            return cmapTable[i].colormap;
   16.60 -        }
   16.61 -    }
   16.62 -
   16.63 -    return 0;
   16.64 -}
   16.65 -
   16.66 -
   16.67 -void
   16.68 -X11_TrackColormap(Display * display, int scrNum, Colormap colormap,
   16.69 -                  Visual * visual, XColor * ramp)
   16.70 -{
   16.71 -    int i;
   16.72 -    Uint16 *newramp;
   16.73 -    int ncolors;
   16.74 -
   16.75 -    /* search the table to find out if we already have this one. We
   16.76 -       only want one entry for each display, screen number, visualid,
   16.77 -       and colormap combination */
   16.78 -    for (i = 0; i < numCmaps; i++) {
   16.79 -        if (cmapTable[i].display == display &&
   16.80 -            cmapTable[i].scrNum == scrNum &&
   16.81 -            cmapTable[i].visual.visualid == visual->visualid &&
   16.82 -            cmapTable[i].colormap == colormap) {
   16.83 -            return;
   16.84 -        }
   16.85 -    }
   16.86 -
   16.87 -    /* increase the table by one entry. If the table is NULL create the
   16.88 -       first entrty */
   16.89 -    cmapTable =
   16.90 -        SDL_realloc(cmapTable, (numCmaps + 1) * sizeof(cmapTableEntry));
   16.91 -    if (NULL == cmapTable) {
   16.92 -        SDL_SetError("Out of memory in X11_TrackColormap()");
   16.93 -        return;
   16.94 -    }
   16.95 -
   16.96 -    cmapTable[numCmaps].display = display;
   16.97 -    cmapTable[numCmaps].scrNum = scrNum;
   16.98 -    cmapTable[numCmaps].colormap = colormap;
   16.99 -    SDL_memcpy(&cmapTable[numCmaps].visual, visual, sizeof(Visual));
  16.100 -    cmapTable[numCmaps].ramp = NULL;
  16.101 -
  16.102 -    if (ramp != NULL) {
  16.103 -        newramp = SDL_malloc(SDL_GammaRampSize);
  16.104 -        if (NULL == newramp) {
  16.105 -            SDL_SetError("Out of memory in X11_TrackColormap()");
  16.106 -            return;
  16.107 -        }
  16.108 -        SDL_memset(newramp, 0, SDL_GammaRampSize);
  16.109 -        cmapTable[numCmaps].ramp = newramp;
  16.110 -
  16.111 -        ncolors = cmapTable[numCmaps].visual.map_entries;
  16.112 -
  16.113 -        for (i = 0; i < ncolors; i++) {
  16.114 -            newramp[(0 * 256) + i] = ramp[i].red;
  16.115 -            newramp[(1 * 256) + i] = ramp[i].green;
  16.116 -            newramp[(2 * 256) + i] = ramp[i].blue;
  16.117 -        }
  16.118 -    }
  16.119 -
  16.120 -    numCmaps++;
  16.121 -}
  16.122 -
  16.123 -/* The problem is that you have to have at least one DirectColor
  16.124 -   colormap before you can set the gamma ramps or read the gamma
  16.125 -   ramps. If the application has created a DirectColor window then the
  16.126 -   cmapTable will have at least one colormap in it and everything is
  16.127 -   cool. If not, then we just fail  */
  16.128 -
  16.129 -int
  16.130 -X11_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * sdl_display, Uint16 * ramp)
  16.131 -{
  16.132 -    Visual *visual;
  16.133 -    Display *display;
  16.134 -    Colormap colormap;
  16.135 -    XColor *colorcells;
  16.136 -    int ncolors;
  16.137 -    int rmask, gmask, bmask;
  16.138 -    int rshift, gshift, bshift;
  16.139 -    int i;
  16.140 -    int j;
  16.141 -
  16.142 -    for (j = 0; j < numCmaps; j++) {
  16.143 -        if (cmapTable[j].visual.class == DirectColor) {
  16.144 -            display = cmapTable[j].display;
  16.145 -            colormap = cmapTable[j].colormap;
  16.146 -            ncolors = cmapTable[j].visual.map_entries;
  16.147 -            visual = &cmapTable[j].visual;
  16.148 -
  16.149 -            colorcells = SDL_malloc(ncolors * sizeof(XColor));
  16.150 -            if (NULL == colorcells) {
  16.151 -                SDL_SetError("out of memory in X11_SetDisplayGammaRamp");
  16.152 -                return -1;
  16.153 -            }
  16.154 -            /* remember the new ramp */
  16.155 -            if (cmapTable[j].ramp == NULL) {
  16.156 -                Uint16 *newramp = SDL_malloc(SDL_GammaRampSize);
  16.157 -                if (NULL == newramp) {
  16.158 -                    SDL_SetError("Out of memory in X11_TrackColormap()");
  16.159 -                    return -1;
  16.160 -                }
  16.161 -                cmapTable[j].ramp = newramp;
  16.162 -            }
  16.163 -            SDL_memcpy(cmapTable[j].ramp, ramp, SDL_GammaRampSize);
  16.164 -
  16.165 -            rshift = 0;
  16.166 -            rmask = visual->red_mask;
  16.167 -            while (0 == (rmask & 1)) {
  16.168 -                rshift++;
  16.169 -                rmask >>= 1;
  16.170 -            }
  16.171 -
  16.172 -/*             printf("rmask = %4x rshift = %4d\n", rmask, rshift); */
  16.173 -
  16.174 -            gshift = 0;
  16.175 -            gmask = visual->green_mask;
  16.176 -            while (0 == (gmask & 1)) {
  16.177 -                gshift++;
  16.178 -                gmask >>= 1;
  16.179 -            }
  16.180 -
  16.181 -/*             printf("gmask = %4x gshift = %4d\n", gmask, gshift); */
  16.182 -
  16.183 -            bshift = 0;
  16.184 -            bmask = visual->blue_mask;
  16.185 -            while (0 == (bmask & 1)) {
  16.186 -                bshift++;
  16.187 -                bmask >>= 1;
  16.188 -            }
  16.189 -
  16.190 -/*             printf("bmask = %4x bshift = %4d\n", bmask, bshift); */
  16.191 -
  16.192 -            /* build the color table pixel values */
  16.193 -            for (i = 0; i < ncolors; i++) {
  16.194 -                Uint32 rbits = (rmask * i) / (ncolors - 1);
  16.195 -                Uint32 gbits = (gmask * i) / (ncolors - 1);
  16.196 -                Uint32 bbits = (bmask * i) / (ncolors - 1);
  16.197 -
  16.198 -                Uint32 pix =
  16.199 -                    (rbits << rshift) | (gbits << gshift) | (bbits << bshift);
  16.200 -
  16.201 -                colorcells[i].pixel = pix;
  16.202 -
  16.203 -                colorcells[i].flags = DoRed | DoGreen | DoBlue;
  16.204 -
  16.205 -                colorcells[i].red = ramp[(0 * 256) + i];
  16.206 -                colorcells[i].green = ramp[(1 * 256) + i];
  16.207 -                colorcells[i].blue = ramp[(2 * 256) + i];
  16.208 -            }
  16.209 -
  16.210 -            XStoreColors(display, colormap, colorcells, ncolors);
  16.211 -            XFlush(display);
  16.212 -            SDL_free(colorcells);
  16.213 -        }
  16.214 -    }
  16.215 -
  16.216 -    return 0;
  16.217 -}
  16.218 -
  16.219 -int
  16.220 -X11_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp)
  16.221 -{
  16.222 -    int i;
  16.223 -
  16.224 -    /* find the first DirectColor colormap and use it to get the gamma
  16.225 -       ramp */
  16.226 -
  16.227 -    for (i = 0; i < numCmaps; i++) {
  16.228 -        if (cmapTable[i].visual.class == DirectColor) {
  16.229 -            SDL_memcpy(ramp, cmapTable[i].ramp, SDL_GammaRampSize);
  16.230 -            return 0;
  16.231 -        }
  16.232 -    }
  16.233 -
  16.234 -    return -1;
  16.235 -}
    17.1 --- a/src/video/x11/SDL_x11gamma.h	Thu Feb 10 10:37:35 2011 -0800
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,36 +0,0 @@
    17.4 -/*
    17.5 -    SDL - Simple DirectMedia Layer
    17.6 -    Copyright (C) 1997-2010 Sam Lantinga
    17.7 -
    17.8 -    This library is free software; you can redistribute it and/or
    17.9 -    modify it under the terms of the GNU Lesser General Public
   17.10 -    License as published by the Free Software Foundation; either
   17.11 -    version 2.1 of the License, or (at your option) any later version.
   17.12 -
   17.13 -    This library is distributed in the hope that it will be useful,
   17.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   17.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   17.16 -    Lesser General Public License for more details.
   17.17 -
   17.18 -    You should have received a copy of the GNU Lesser General Public
   17.19 -    License along with this library; if not, write to the Free Software
   17.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   17.21 -
   17.22 -    Sam Lantinga
   17.23 -    slouken@libsdl.org
   17.24 -*/
   17.25 -#include "SDL_config.h"
   17.26 -
   17.27 -#ifndef _SDL_x11gamma_h
   17.28 -#define _SDL_x11gamma_h
   17.29 -
   17.30 -extern Colormap X11_LookupColormap(Display * display, int scrNum,
   17.31 -                                   VisualID vid);
   17.32 -extern void X11_TrackColormap(Display * display, int scrNum,
   17.33 -                              Colormap colormap,
   17.34 -                              Visual * visual, XColor * ramp);
   17.35 -
   17.36 -extern int X11_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
   17.37 -extern int X11_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
   17.38 -
   17.39 -#endif
    18.1 --- a/src/video/x11/SDL_x11modes.c	Thu Feb 10 10:37:35 2011 -0800
    18.2 +++ b/src/video/x11/SDL_x11modes.c	Thu Feb 10 11:39:08 2011 -0800
    18.3 @@ -47,9 +47,7 @@
    18.4      }
    18.5  
    18.6      depth = DefaultDepth(display, screen);
    18.7 -    if ((X11_UseDirectColorVisuals() &&
    18.8 -         XMatchVisualInfo(display, screen, depth, DirectColor, vinfo)) ||
    18.9 -        XMatchVisualInfo(display, screen, depth, TrueColor, vinfo) ||
   18.10 +    if (XMatchVisualInfo(display, screen, depth, TrueColor, vinfo) ||
   18.11          XMatchVisualInfo(display, screen, depth, PseudoColor, vinfo) ||
   18.12          XMatchVisualInfo(display, screen, depth, StaticColor, vinfo)) {
   18.13          return 0;
    19.1 --- a/src/video/x11/SDL_x11opengl.c	Thu Feb 10 10:37:35 2011 -0800
    19.2 +++ b/src/video/x11/SDL_x11opengl.c	Thu Feb 10 11:39:08 2011 -0800
    19.3 @@ -365,22 +365,9 @@
    19.4                                                        GLX_SLOW_VISUAL_EXT;
    19.5      }
    19.6  
    19.7 -#ifdef GLX_DIRECT_COLOR         /* Try for a DirectColor visual for gamma support */
    19.8 -    if (X11_UseDirectColorVisuals()) {
    19.9 -        attribs[i++] = GLX_X_VISUAL_TYPE;
   19.10 -        attribs[i++] = GLX_DIRECT_COLOR;
   19.11 -    }
   19.12 -#endif
   19.13 -
   19.14      attribs[i++] = None;
   19.15  
   19.16      vinfo = _this->gl_data->glXChooseVisual(display, screen, attribs);
   19.17 -#ifdef GLX_DIRECT_COLOR
   19.18 -    if (!vinfo && X11_UseDirectColorVisuals()) {        /* No DirectColor visual?  Try again.. */
   19.19 -        attribs[i - 3] = None;
   19.20 -        vinfo = _this->gl_data->glXChooseVisual(display, screen, attribs);
   19.21 -    }
   19.22 -#endif
   19.23      if (!vinfo) {
   19.24          SDL_SetError("Couldn't find matching GLX visual");
   19.25      }
    20.1 --- a/src/video/x11/SDL_x11video.c	Thu Feb 10 10:37:35 2011 -0800
    20.2 +++ b/src/video/x11/SDL_x11video.c	Thu Feb 10 11:39:08 2011 -0800
    20.3 @@ -186,8 +186,6 @@
    20.4      device->VideoQuit = X11_VideoQuit;
    20.5      device->GetDisplayModes = X11_GetDisplayModes;
    20.6      device->SetDisplayMode = X11_SetDisplayMode;
    20.7 -    device->SetDisplayGammaRamp = X11_SetDisplayGammaRamp;
    20.8 -    device->GetDisplayGammaRamp = X11_GetDisplayGammaRamp;
    20.9      device->SuspendScreenSaver = X11_SuspendScreenSaver;
   20.10      device->PumpEvents = X11_PumpEvents;
   20.11  
   20.12 @@ -384,13 +382,4 @@
   20.13      X11_QuitTouch(_this);
   20.14  }
   20.15  
   20.16 -SDL_bool
   20.17 -X11_UseDirectColorVisuals(void)
   20.18 -{
   20.19 -    /* Once we implement DirectColor colormaps and gamma ramp support...
   20.20 -       return SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ? SDL_FALSE : SDL_TRUE;
   20.21 -     */
   20.22 -    return SDL_FALSE;
   20.23 -}
   20.24 -
   20.25  /* vim: set ts=4 sw=4 expandtab: */
    21.1 --- a/src/video/x11/SDL_x11video.h	Thu Feb 10 10:37:35 2011 -0800
    21.2 +++ b/src/video/x11/SDL_x11video.h	Thu Feb 10 11:39:08 2011 -0800
    21.3 @@ -55,7 +55,6 @@
    21.4  
    21.5  #include "SDL_x11clipboard.h"
    21.6  #include "SDL_x11events.h"
    21.7 -#include "SDL_x11gamma.h"
    21.8  #include "SDL_x11keyboard.h"
    21.9  #include "SDL_x11modes.h"
   21.10  #include "SDL_x11mouse.h"
   21.11 @@ -93,8 +92,6 @@
   21.12      SDL_bool selection_waiting;
   21.13  } SDL_VideoData;
   21.14  
   21.15 -extern SDL_bool X11_UseDirectColorVisuals(void);
   21.16 -
   21.17  #endif /* _SDL_x11video_h */
   21.18  
   21.19  /* vi: set ts=4 sw=4 expandtab: */
    22.1 --- a/src/video/x11/SDL_x11window.c	Thu Feb 10 10:37:35 2011 -0800
    22.2 +++ b/src/video/x11/SDL_x11window.c	Thu Feb 10 11:39:08 2011 -0800
    22.3 @@ -28,7 +28,6 @@
    22.4  
    22.5  #include "SDL_x11video.h"
    22.6  #include "SDL_x11mouse.h"
    22.7 -#include "SDL_x11gamma.h"
    22.8  #include "SDL_x11shape.h"
    22.9  
   22.10  #ifdef SDL_VIDEO_DRIVER_PANDORA
   22.11 @@ -326,217 +325,7 @@
   22.12      }
   22.13      xattr.background_pixel = 0;
   22.14      xattr.border_pixel = 0;
   22.15 -
   22.16 -    if (visual->class == PseudoColor) {
   22.17 -        printf("asking for PseudoColor\n");
   22.18 -
   22.19 -/*      Status status; */
   22.20 -        XColor *colorcells;
   22.21 -        Colormap colormap;
   22.22 -        Sint32 pix;
   22.23 -        Sint32 ncolors;
   22.24 -        Sint32 nbits;
   22.25 -        Sint32 rmax, gmax, bmax;
   22.26 -        Sint32 rwidth, gwidth, bwidth;
   22.27 -        Sint32 rmask, gmask, bmask;
   22.28 -        Sint32 rshift, gshift, bshift;
   22.29 -        Sint32 r, g, b;
   22.30 -
   22.31 -        /* Is the colormap we need already registered in SDL? */
   22.32 -        if ((colormap =
   22.33 -            X11_LookupColormap(display, screen, visual->visualid))) {
   22.34 -            xattr.colormap = colormap;
   22.35 -/*             printf("found existing colormap\n"); */
   22.36 -        } else {
   22.37 -            /* The colormap is not known to SDL so we will create it */
   22.38 -            colormap = XCreateColormap(display, RootWindow(display, screen),
   22.39 -                                       visual, AllocAll);
   22.40 -/*             printf("colormap = %x\n", colormap); */
   22.41 -
   22.42 -            /* If we can't create a colormap, then we must die */
   22.43 -            if (!colormap) {
   22.44 -                SDL_SetError
   22.45 -                    ("Couldn't create window: Could not create writable colormap");
   22.46 -                return -1;
   22.47 -            }
   22.48 -
   22.49 -            /* OK, we got a colormap, now fill it in as best as we can */
   22.50 -
   22.51 -            colorcells = SDL_malloc(visual->map_entries * sizeof(XColor));
   22.52 -            if (NULL == colorcells) {
   22.53 -                SDL_SetError("out of memory in X11_CreateWindow");
   22.54 -                return -1;
   22.55 -            }
   22.56 -
   22.57 -            ncolors = visual->map_entries;
   22.58 -            nbits = visual->bits_per_rgb;
   22.59 -
   22.60 -/* 	    printf("ncolors = %d nbits = %d\n", ncolors, nbits); */
   22.61 -
   22.62 -            /* what if ncolors != (1 << nbits)? That can happen on a
   22.63 -               true PseudoColor display.  I'm assuming that we will
   22.64 -               always have ncolors == (1 << nbits) */
   22.65 -
   22.66 -            /* I'm making a lot of assumptions here. */
   22.67 -
   22.68 -            /* Compute the width of each field. If there is one extra
   22.69 -               bit, give it to green. If there are two extra bits give
   22.70 -               them to red and greed.  We can get extra bits when the
   22.71 -               number of bits per pixel is not a multiple of 3. For
   22.72 -               example when we have 16 bits per pixel and need a 5/6/5
   22.73 -               layout for the RGB fields */
   22.74 -
   22.75 -            rwidth = (nbits / 3) + (((nbits % 3) == 2) ? 1 : 0);
   22.76 -            gwidth = (nbits / 3) + (((nbits % 3) >= 1) ? 1 : 0);
   22.77 -            bwidth = (nbits / 3);
   22.78 -
   22.79 -            rshift = gwidth + bwidth;
   22.80 -            gshift = bwidth;
   22.81 -            bshift = 0;
   22.82 -
   22.83 -            rmax = 1 << rwidth;
   22.84 -            gmax = 1 << gwidth;
   22.85 -            bmax = 1 << bwidth;
   22.86 -
   22.87 -            rmask = rmax - 1;
   22.88 -            gmask = gmax - 1;
   22.89 -            bmask = bmax - 1;
   22.90 -
   22.91 -/*             printf("red   mask = %4x shift = %4d width = %d\n", rmask, rshift, rwidth); */
   22.92 -/*             printf("green mask = %4x shift = %4d width = %d\n", gmask, gshift, gwidth); */
   22.93 -/*             printf("blue  mask = %4x shift = %4d width = %d\n", bmask, bshift, bwidth); */
   22.94 -
   22.95 -            /* build the color table pixel values */
   22.96 -            pix = 0;
   22.97 -            for (r = 0; r < rmax; r++) {
   22.98 -                for (g = 0; g < gmax; g++) {
   22.99 -                    for (b = 0; b < bmax; b++) {
  22.100 -                        colorcells[pix].pixel =
  22.101 -                            (r << rshift) | (g << gshift) | (b << bshift);
  22.102 -                        colorcells[pix].red = (0xffff * r) / rmask;
  22.103 -                        colorcells[pix].green = (0xffff * g) / gmask;
  22.104 -                        colorcells[pix].blue = (0xffff * b) / bmask;
  22.105 -/* 		  printf("%4x:%4x [%4x %4x %4x]\n",  */
  22.106 -/* 			 pix,  */
  22.107 -/* 			 colorcells[pix].pixel, */
  22.108 -/* 			 colorcells[pix].red, */
  22.109 -/* 			 colorcells[pix].green, */
  22.110 -/* 			 colorcells[pix].blue); */
  22.111 -                        pix++;
  22.112 -                    }
  22.113 -                }
  22.114 -            }
  22.115 -
  22.116 -/*             status = */
  22.117 -/*                 XStoreColors(display, colormap, colorcells, ncolors); */
  22.118 -
  22.119 -            xattr.colormap = colormap;
  22.120 -            X11_TrackColormap(display, screen, colormap, visual, NULL);
  22.121 -
  22.122 -            SDL_free(colorcells);
  22.123 -        }
  22.124 -    } else if (visual->class == DirectColor) {
  22.125 -        Status status;
  22.126 -        XColor *colorcells;
  22.127 -        Colormap colormap;
  22.128 -        int i;
  22.129 -        int ncolors;
  22.130 -        int rmax, gmax, bmax;
  22.131 -        int rmask, gmask, bmask;
  22.132 -        int rshift, gshift, bshift;
  22.133 -
  22.134 -        /* Is the colormap we need already registered in SDL? */
  22.135 -        if ((colormap =
  22.136 -             X11_LookupColormap(display, screen, visual->visualid))) {
  22.137 -            xattr.colormap = colormap;
  22.138 -/*             printf("found existing colormap\n"); */
  22.139 -        } else {
  22.140 -            /* The colormap is not known to SDL so we will create it */
  22.141 -            colormap = XCreateColormap(display, RootWindow(display, screen),
  22.142 -                                       visual, AllocAll);
  22.143 -/*             printf("colormap = %x\n", colormap); */
  22.144 -
  22.145 -            /* If we can't create a colormap, then we must die */
  22.146 -            if (!colormap) {
  22.147 -                SDL_SetError
  22.148 -                    ("Couldn't create window: Could not create writable colormap");
  22.149 -                return -1;
  22.150 -            }
  22.151 -
  22.152 -            /* OK, we got a colormap, now fill it in as best as we can */
  22.153 -            colorcells = SDL_malloc(visual->map_entries * sizeof(XColor));
  22.154 -            if (NULL == colorcells) {
  22.155 -                SDL_SetError("out of memory in X11_CreateWindow");
  22.156 -                return -1;
  22.157 -            }
  22.158 -            ncolors = visual->map_entries;
  22.159 -            rmax = 0xffff;
  22.160 -            gmax = 0xffff;
  22.161 -            bmax = 0xffff;
  22.162 -
  22.163 -            rshift = 0;
  22.164 -            rmask = visual->red_mask;
  22.165 -            while (0 == (rmask & 1)) {
  22.166 -                rshift++;
  22.167 -                rmask >>= 1;
  22.168 -            }
  22.169 -
  22.170 -/*             printf("rmask = %4x rshift = %4d\n", rmask, rshift); */
  22.171 -
  22.172 -            gshift = 0;
  22.173 -            gmask = visual->green_mask;
  22.174 -            while (0 == (gmask & 1)) {
  22.175 -                gshift++;
  22.176 -                gmask >>= 1;
  22.177 -            }
  22.178 -
  22.179 -/*             printf("gmask = %4x gshift = %4d\n", gmask, gshift); */
  22.180 -
  22.181 -            bshift = 0;
  22.182 -            bmask = visual->blue_mask;
  22.183 -            while (0 == (bmask & 1)) {
  22.184 -                bshift++;
  22.185 -                bmask >>= 1;
  22.186 -            }
  22.187 -
  22.188 -/*             printf("bmask = %4x bshift = %4d\n", bmask, bshift); */
  22.189 -
  22.190 -            /* build the color table pixel values */
  22.191 -            for (i = 0; i < ncolors; i++) {
  22.192 -                Uint32 red = (rmax * i) / (ncolors - 1);
  22.193 -                Uint32 green = (gmax * i) / (ncolors - 1);
  22.194 -                Uint32 blue = (bmax * i) / (ncolors - 1);
  22.195 -
  22.196 -                Uint32 rbits = (rmask * i) / (ncolors - 1);
  22.197 -                Uint32 gbits = (gmask * i) / (ncolors - 1);
  22.198 -                Uint32 bbits = (bmask * i) / (ncolors - 1);
  22.199 -
  22.200 -                Uint32 pix =
  22.201 -                    (rbits << rshift) | (gbits << gshift) | (bbits << bshift);
  22.202 -
  22.203 -                colorcells[i].pixel = pix;
  22.204 -
  22.205 -                colorcells[i].red = red;
  22.206 -                colorcells[i].green = green;
  22.207 -                colorcells[i].blue = blue;
  22.208 -
  22.209 -                colorcells[i].flags = DoRed | DoGreen | DoBlue;
  22.210 -/* 		printf("%2d:%4x [%4x %4x %4x]\n", i, pix, red, green, blue); */
  22.211 -            }
  22.212 -
  22.213 -            status =
  22.214 -                XStoreColors(display, colormap, colorcells, ncolors);
  22.215 -
  22.216 -            xattr.colormap = colormap;
  22.217 -            X11_TrackColormap(display, screen, colormap, visual, colorcells);
  22.218 -
  22.219 -            SDL_free(colorcells);
  22.220 -        }
  22.221 -    } else {
  22.222 -        xattr.colormap =
  22.223 -            XCreateColormap(display, RootWindow(display, screen),
  22.224 -                            visual, AllocNone);
  22.225 -    }
  22.226 +    xattr.colormap = XCreateColormap(display, RootWindow(display, screen), visual, AllocNone);
  22.227  
  22.228      if (oldstyle_fullscreen
  22.229          || window->x == SDL_WINDOWPOS_CENTERED) {
    23.1 --- a/test/Makefile.in	Thu Feb 10 10:37:35 2011 -0800
    23.2 +++ b/test/Makefile.in	Thu Feb 10 11:39:08 2011 -0800
    23.3 @@ -23,7 +23,6 @@
    23.4  	testerror$(EXE) \
    23.5  	testfile$(EXE) \
    23.6  	testfill$(EXE) \
    23.7 -	testgamma$(EXE) \
    23.8  	testgesture$(EXE) \
    23.9  	testgl$(EXE) \
   23.10  	testgl2$(EXE) \
    24.1 --- a/test/testgamma.c	Thu Feb 10 10:37:35 2011 -0800
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,194 +0,0 @@
    24.4 -
    24.5 -/* Bring up a window and manipulate the gamma on it */
    24.6 -
    24.7 -#include <stdlib.h>
    24.8 -#include <stdio.h>
    24.9 -#include <string.h>
   24.10 -#include <math.h>
   24.11 -
   24.12 -#include "SDL.h"
   24.13 -
   24.14 -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
   24.15 -static void
   24.16 -quit(int rc)
   24.17 -{
   24.18 -    SDL_Quit();
   24.19 -    exit(rc);
   24.20 -}
   24.21 -
   24.22 -/* Turn a normal gamma value into an appropriate gamma ramp */
   24.23 -void
   24.24 -CalculateGamma(double gamma, Uint16 * ramp)
   24.25 -{
   24.26 -    int i, value;
   24.27 -
   24.28 -    gamma = 1.0 / gamma;
   24.29 -    for (i = 0; i < 256; ++i) {
   24.30 -        value = (int) (pow((double) i / 256.0, gamma) * 65535.0 + 0.5);
   24.31 -        if (value > 65535) {
   24.32 -            value = 65535;
   24.33 -        }
   24.34 -        ramp[i] = (Uint16) value;
   24.35 -    }
   24.36 -}
   24.37 -
   24.38 -/* This can be used as a general routine for all of the test programs */
   24.39 -int
   24.40 -get_video_args(char *argv[], int *w, int *h, int *bpp, Uint32 * flags)
   24.41 -{
   24.42 -    int i;
   24.43 -
   24.44 -    *w = 640;
   24.45 -    *h = 480;
   24.46 -    *bpp = 0;
   24.47 -    *flags = SDL_SWSURFACE;
   24.48 -
   24.49 -    for (i = 1; argv[i]; ++i) {
   24.50 -        if (strcmp(argv[i], "-width") == 0) {
   24.51 -            if (argv[i + 1]) {
   24.52 -                *w = atoi(argv[++i]);
   24.53 -            }
   24.54 -        } else if (strcmp(argv[i], "-height") == 0) {
   24.55 -            if (argv[i + 1]) {
   24.56 -                *h = atoi(argv[++i]);
   24.57 -            }
   24.58 -        } else if (strcmp(argv[i], "-bpp") == 0) {
   24.59 -            if (argv[i + 1]) {
   24.60 -                *bpp = atoi(argv[++i]);
   24.61 -            }
   24.62 -        } else if (strcmp(argv[i], "-fullscreen") == 0) {
   24.63 -            *flags |= SDL_FULLSCREEN;
   24.64 -        } else if (strcmp(argv[i], "-hw") == 0) {
   24.65 -            *flags |= SDL_HWSURFACE;
   24.66 -        } else if (strcmp(argv[i], "-hwpalette") == 0) {
   24.67 -            *flags |= SDL_HWPALETTE;
   24.68 -        } else
   24.69 -            break;
   24.70 -    }
   24.71 -    return i;
   24.72 -}
   24.73 -
   24.74 -int
   24.75 -main(int argc, char *argv[])
   24.76 -{
   24.77 -    SDL_Surface *screen;
   24.78 -    SDL_Surface *image;
   24.79 -    float gamma;
   24.80 -    int i;
   24.81 -    int w, h, bpp;
   24.82 -    Uint32 flags;
   24.83 -    Uint16 ramp[256];
   24.84 -    Uint16 red_ramp[256];
   24.85 -    Uint32 then, timeout;
   24.86 -
   24.87 -    /* Check command line arguments */
   24.88 -    argv += get_video_args(argv, &w, &h, &bpp, &flags);
   24.89 -
   24.90 -    /* Initialize SDL */
   24.91 -    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
   24.92 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   24.93 -        return (1);
   24.94 -    }
   24.95 -
   24.96 -    /* Initialize the display, always use hardware palette */
   24.97 -    screen = SDL_SetVideoMode(w, h, bpp, flags | SDL_HWPALETTE);
   24.98 -    if (screen == NULL) {
   24.99 -        fprintf(stderr, "Couldn't set %dx%d video mode: %s\n",
  24.100 -                w, h, SDL_GetError());
  24.101 -        quit(1);
  24.102 -    }
  24.103 -
  24.104 -    /* Set the window manager title bar */
  24.105 -    SDL_WM_SetCaption("SDL gamma test", "testgamma");
  24.106 -
  24.107 -    /* Set the desired gamma, if any */
  24.108 -    gamma = 1.0f;
  24.109 -    if (*argv) {
  24.110 -        gamma = (float) atof(*argv);
  24.111 -    }
  24.112 -    if (SDL_SetGamma(gamma, gamma, gamma) < 0) {
  24.113 -        fprintf(stderr, "Unable to set gamma: %s\n", SDL_GetError());
  24.114 -        quit(1);
  24.115 -    }
  24.116 -#if 0                           /* This isn't supported.  Integrating the gamma ramps isn't exact */
  24.117 -    /* See what gamma was actually set */
  24.118 -    float real[3];
  24.119 -    if (SDL_GetGamma(&real[0], &real[1], &real[2]) < 0) {
  24.120 -        printf("Couldn't get gamma: %s\n", SDL_GetError());
  24.121 -    } else {
  24.122 -        printf("Set gamma values: R=%2.2f, G=%2.2f, B=%2.2f\n",
  24.123 -               real[0], real[1], real[2]);
  24.124 -    }
  24.125 -#endif
  24.126 -
  24.127 -    /* Do all the drawing work */
  24.128 -    image = SDL_LoadBMP("sample.bmp");
  24.129 -    if (image) {
  24.130 -        SDL_Rect dst;
  24.131 -
  24.132 -        dst.x = (screen->w - image->w) / 2;
  24.133 -        dst.y = (screen->h - image->h) / 2;
  24.134 -        dst.w = image->w;
  24.135 -        dst.h = image->h;
  24.136 -        SDL_BlitSurface(image, NULL, screen, &dst);
  24.137 -        SDL_UpdateRects(screen, 1, &dst);
  24.138 -    }
  24.139 -
  24.140 -    /* Wait a bit, handling events */
  24.141 -    then = SDL_GetTicks();
  24.142 -    timeout = (5 * 1000);
  24.143 -    while ((SDL_GetTicks() - then) < timeout) {
  24.144 -        SDL_Event event;
  24.145 -
  24.146 -        while (SDL_PollEvent(&event)) {
  24.147 -            switch (event.type) {
  24.148 -            case SDL_QUIT:     /* Quit now */
  24.149 -                timeout = 0;
  24.150 -                break;
  24.151 -            case SDL_KEYDOWN:
  24.152 -                switch (event.key.keysym.sym) {
  24.153 -                case SDLK_SPACE:       /* Go longer.. */
  24.154 -                    timeout += (5 * 1000);
  24.155 -                    break;
  24.156 -                case SDLK_UP:
  24.157 -                    gamma += 0.2f;
  24.158 -                    SDL_SetGamma(gamma, gamma, gamma);
  24.159 -                    break;
  24.160 -                case SDLK_DOWN:
  24.161 -                    gamma -= 0.2f;
  24.162 -                    SDL_SetGamma(gamma, gamma, gamma);
  24.163 -                    break;
  24.164 -                case SDLK_ESCAPE:
  24.165 -                    timeout = 0;
  24.166 -                    break;
  24.167 -                default:
  24.168 -                    break;
  24.169 -                }
  24.170 -                break;
  24.171 -            }
  24.172 -        }
  24.173 -    }
  24.174 -
  24.175 -    /* Perform a gamma flash to red using color ramps */
  24.176 -    while (gamma < 10.0) {
  24.177 -        /* Increase the red gamma and decrease everything else... */
  24.178 -        gamma += 0.1f;
  24.179 -        CalculateGamma(gamma, red_ramp);
  24.180 -        CalculateGamma(1.0 / gamma, ramp);
  24.181 -        SDL_SetGammaRamp(red_ramp, ramp, ramp);
  24.182 -    }
  24.183 -    /* Finish completely red */
  24.184 -    memset(red_ramp, 255, sizeof(red_ramp));
  24.185 -    memset(ramp, 0, sizeof(ramp));
  24.186 -    SDL_SetGammaRamp(red_ramp, ramp, ramp);
  24.187 -
  24.188 -    /* Now fade out to black */
  24.189 -    for (i = (red_ramp[0] >> 8); i >= 0; --i) {
  24.190 -        memset(red_ramp, i, sizeof(red_ramp));
  24.191 -        SDL_SetGammaRamp(red_ramp, NULL, NULL);
  24.192 -    }
  24.193 -    SDL_Delay(1 * 1000);
  24.194 -
  24.195 -    SDL_Quit();
  24.196 -    return (0);
  24.197 -}