src/video/nanox/SDL_nxvideo.c
changeset 3274 08574b033f37
parent 3273 e0dfba770eb7
child 3275 a4a34a511ba0
     1.1 --- a/src/video/nanox/SDL_nxvideo.c	Sat Sep 19 07:22:07 2009 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,572 +0,0 @@
     1.4 -/*
     1.5 -    SDL - Simple DirectMedia Layer
     1.6 -    Copyright (C) 1997-2009 Sam Lantinga
     1.7 -    Copyright (C) 2001  Hsieh-Fu Tsai
     1.8 -    Copyright (C) 2002  Greg Haerr <greg@censoft.com>
     1.9 -
    1.10 -    This library is free software; you can redistribute it and/or
    1.11 -    modify it under the terms of the GNU Library General Public
    1.12 -    License as published by the Free Software Foundation; either
    1.13 -    version 2 of the License, or (at your option) any later version.
    1.14 -
    1.15 -    This library is distributed in the hope that it will be useful,
    1.16 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.17 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.18 -    Library General Public License for more details.
    1.19 -
    1.20 -    You should have received a copy of the GNU Library General Public
    1.21 -    License along with this library; if not, write to the Free
    1.22 -    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.23 -
    1.24 -    Sam Lantinga
    1.25 -    slouken@libsdl.org
    1.26 -    
    1.27 -    Hsieh-Fu Tsai
    1.28 -    clare@setabox.com
    1.29 -*/
    1.30 -#include "SDL_config.h"
    1.31 -
    1.32 -#include "SDL_thread.h"
    1.33 -#include "SDL_video.h"
    1.34 -#include "../SDL_pixels_c.h"
    1.35 -#include "../../events/SDL_events_c.h"
    1.36 -
    1.37 -#define MWINCLUDECOLORS
    1.38 -#include "SDL_nxvideo.h"
    1.39 -#include "SDL_nxmodes_c.h"
    1.40 -#include "SDL_nxwm_c.h"
    1.41 -#include "SDL_nxmouse_c.h"
    1.42 -#include "SDL_nximage_c.h"
    1.43 -#include "SDL_nxevents_c.h"
    1.44 -
    1.45 -// Initialization/Query functions
    1.46 -static int NX_VideoInit(_THIS, SDL_PixelFormat * vformat);
    1.47 -static SDL_Surface *NX_SetVideoMode(_THIS, SDL_Surface * current, int width,
    1.48 -                                    int height, int bpp, Uint32 flags);
    1.49 -static int NX_SetColors(_THIS, int firstcolor, int ncolors,
    1.50 -                        SDL_Color * colors);
    1.51 -static void NX_VideoQuit(_THIS);
    1.52 -static void NX_DestroyWindow(_THIS, SDL_Surface * screen);
    1.53 -static int NX_ToggleFullScreen(_THIS, int on);
    1.54 -static void NX_UpdateMouse(_THIS);
    1.55 -static int NX_SetGammaRamp(_THIS, Uint16 * ramp);
    1.56 -static int NX_GetGammaRamp(_THIS, Uint16 * ramp);
    1.57 -
    1.58 -// Microwin driver bootstrap functions
    1.59 -static int
    1.60 -NX_Available()
    1.61 -{
    1.62 -    Dprintf("enter NX_Available\n");
    1.63 -
    1.64 -    if (GrOpen() < 0)
    1.65 -        return 0;
    1.66 -    GrClose();
    1.67 -
    1.68 -    Dprintf("leave NX_Available\n");
    1.69 -    return 1;
    1.70 -}
    1.71 -
    1.72 -static void
    1.73 -NX_DeleteDevice(SDL_VideoDevice * device)
    1.74 -{
    1.75 -    Dprintf("enter NX_DeleteDevice\n");
    1.76 -
    1.77 -    if (device) {
    1.78 -        if (device->hidden)
    1.79 -            SDL_free(device->hidden);
    1.80 -        if (device->gl_data)
    1.81 -            SDL_free(device->gl_data);
    1.82 -        SDL_free(device);
    1.83 -    }
    1.84 -
    1.85 -    Dprintf("leave NX_DeleteDevice\n");
    1.86 -}
    1.87 -
    1.88 -static SDL_VideoDevice *
    1.89 -NX_CreateDevice(int devindex)
    1.90 -{
    1.91 -    SDL_VideoDevice *device;
    1.92 -
    1.93 -    Dprintf("enter NX_CreateDevice\n");
    1.94 -
    1.95 -    // Initialize all variables that we clean on shutdown
    1.96 -    device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
    1.97 -    if (device) {
    1.98 -        SDL_memset(device, 0, (sizeof *device));
    1.99 -        device->hidden = (struct SDL_PrivateVideoData *)
   1.100 -            SDL_malloc((sizeof *device->hidden));
   1.101 -        device->gl_data = NULL;
   1.102 -    }
   1.103 -    if ((device == NULL) || (device->hidden == NULL)) {
   1.104 -        SDL_OutOfMemory();
   1.105 -        NX_DeleteDevice(device);
   1.106 -        return 0;
   1.107 -    }
   1.108 -    SDL_memset(device->hidden, 0, (sizeof *device->hidden));
   1.109 -
   1.110 -    // Set the function pointers
   1.111 -    device->VideoInit = NX_VideoInit;
   1.112 -    device->ListModes = NX_ListModes;
   1.113 -    device->SetVideoMode = NX_SetVideoMode;
   1.114 -    device->ToggleFullScreen = NX_ToggleFullScreen;
   1.115 -    device->UpdateMouse = NX_UpdateMouse;
   1.116 -    device->CreateYUVOverlay = NULL;
   1.117 -    device->SetColors = NX_SetColors;
   1.118 -    device->UpdateRects = NULL;
   1.119 -    device->VideoQuit = NX_VideoQuit;
   1.120 -    device->AllocHWSurface = NULL;
   1.121 -    device->CheckHWBlit = NULL;
   1.122 -    device->FillHWRect = NULL;
   1.123 -    device->SetHWColorKey = NULL;
   1.124 -    device->SetHWAlpha = NULL;
   1.125 -    device->LockHWSurface = NULL;
   1.126 -    device->UnlockHWSurface = NULL;
   1.127 -    device->FlipHWSurface = NULL;
   1.128 -    device->FreeHWSurface = NULL;
   1.129 -    device->SetGamma = NULL;
   1.130 -    device->GetGamma = NULL;
   1.131 -    device->SetGammaRamp = NX_SetGammaRamp;
   1.132 -    device->GetGammaRamp = NX_GetGammaRamp;
   1.133 -
   1.134 -#if SDL_VIDEO_OPENGL
   1.135 -    device->GL_LoadLibrary = NULL;
   1.136 -    device->GL_GetProcAddress = NULL;
   1.137 -    device->GL_GetAttribute = NULL;
   1.138 -    device->GL_MakeCurrent = NULL;
   1.139 -    device->GL_SwapBuffers = NULL;
   1.140 -#endif
   1.141 -
   1.142 -    device->SetIcon = NULL;
   1.143 -    device->SetCaption = NX_SetCaption;
   1.144 -    device->IconifyWindow = NULL;
   1.145 -    device->GrabInput = NULL;
   1.146 -    device->GetWMInfo = NX_GetWMInfo;
   1.147 -    device->FreeWMCursor = NX_FreeWMCursor;
   1.148 -    device->CreateWMCursor = NX_CreateWMCursor;
   1.149 -    device->ShowWMCursor = NX_ShowWMCursor;
   1.150 -    device->WarpWMCursor = NX_WarpWMCursor;
   1.151 -    device->CheckMouseMode = NULL;
   1.152 -    device->InitOSKeymap = NX_InitOSKeymap;
   1.153 -    device->PumpEvents = NX_PumpEvents;
   1.154 -
   1.155 -    device->free = NX_DeleteDevice;
   1.156 -
   1.157 -    Dprintf("leave NX_CreateDevice\n");
   1.158 -    return device;
   1.159 -}
   1.160 -
   1.161 -VideoBootStrap NX_bootstrap = {
   1.162 -    "nanox", "nanox", NX_Available, NX_CreateDevice
   1.163 -};
   1.164 -
   1.165 -static void
   1.166 -create_aux_windows(_THIS)
   1.167 -{
   1.168 -    GR_WM_PROPERTIES props;
   1.169 -
   1.170 -    Dprintf("enter create_aux_windows\n");
   1.171 -
   1.172 -    // Don't create any extra windows if we are being managed
   1.173 -    if (SDL_windowid) {
   1.174 -        FSwindow = 0;
   1.175 -        return;
   1.176 -    }
   1.177 -
   1.178 -    if (FSwindow && FSwindow != GR_ROOT_WINDOW_ID) {
   1.179 -        GrDestroyWindow(FSwindow);
   1.180 -    }
   1.181 -
   1.182 -    FSwindow = GrNewWindow(GR_ROOT_WINDOW_ID, 0, 0, 1, 1, 0, BLACK, BLACK);
   1.183 -    props.flags = GR_WM_FLAGS_PROPS;
   1.184 -    props.props = GR_WM_PROPS_NODECORATE;
   1.185 -    GrSetWMProperties(FSwindow, &props);
   1.186 -
   1.187 -    GrSelectEvents(FSwindow, (GR_EVENT_MASK_EXPOSURE |
   1.188 -                              GR_EVENT_MASK_BUTTON_DOWN |
   1.189 -                              GR_EVENT_MASK_BUTTON_UP |
   1.190 -                              GR_EVENT_MASK_FOCUS_IN |
   1.191 -                              GR_EVENT_MASK_FOCUS_OUT |
   1.192 -                              GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP |
   1.193 -                              GR_EVENT_MASK_MOUSE_ENTER |
   1.194 -                              GR_EVENT_MASK_MOUSE_EXIT |
   1.195 -                              GR_EVENT_MASK_MOUSE_MOTION |
   1.196 -                              GR_EVENT_MASK_UPDATE |
   1.197 -                              GR_EVENT_MASK_CLOSE_REQ));
   1.198 -
   1.199 -    Dprintf("leave create_aux_windows\n");
   1.200 -}
   1.201 -
   1.202 -int
   1.203 -NX_VideoInit(_THIS, SDL_PixelFormat * vformat)
   1.204 -{
   1.205 -    GR_SCREEN_INFO si;
   1.206 -
   1.207 -    Dprintf("enter NX_VideoInit\n");
   1.208 -
   1.209 -    if (GrOpen() < 0) {
   1.210 -        SDL_SetError("GrOpen() fail");
   1.211 -        return -1;
   1.212 -    }
   1.213 -    // use share memory to speed up
   1.214 -#ifdef NANOX_SHARE_MEMORY
   1.215 -    GrReqShmCmds(0xFFFF);
   1.216 -#endif
   1.217 -
   1.218 -    SDL_Window = 0;
   1.219 -    FSwindow = 0;
   1.220 -
   1.221 -    GammaRamp_R = NULL;
   1.222 -    GammaRamp_G = NULL;
   1.223 -    GammaRamp_B = NULL;
   1.224 -
   1.225 -    GrGetScreenInfo(&si);
   1.226 -    SDL_Visual.bpp = si.bpp;
   1.227 -
   1.228 -    /* Determine the current screen size */
   1.229 -    this->info.current_w = si.cols;
   1.230 -    this->info.current_h = si.rows;
   1.231 -
   1.232 -    // GetVideoMode
   1.233 -    SDL_modelist = (SDL_Rect **) SDL_malloc(sizeof(SDL_Rect *) * 2);
   1.234 -    if (SDL_modelist) {
   1.235 -        SDL_modelist[0] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect));
   1.236 -        if (SDL_modelist[0]) {
   1.237 -            SDL_modelist[0]->x = 0;
   1.238 -            SDL_modelist[0]->y = 0;
   1.239 -            SDL_modelist[0]->w = si.cols;
   1.240 -            SDL_modelist[0]->h = si.rows;
   1.241 -        }
   1.242 -        SDL_modelist[1] = NULL;
   1.243 -    }
   1.244 -
   1.245 -    pixel_type = si.pixtype;
   1.246 -    SDL_Visual.red_mask = si.rmask;
   1.247 -    SDL_Visual.green_mask = si.gmask;
   1.248 -    SDL_Visual.blue_mask = si.bmask;
   1.249 -
   1.250 -    vformat->BitsPerPixel = SDL_Visual.bpp;
   1.251 -    if (vformat->BitsPerPixel > 8) {
   1.252 -        vformat->Rmask = SDL_Visual.red_mask;
   1.253 -        vformat->Gmask = SDL_Visual.green_mask;
   1.254 -        vformat->Bmask = SDL_Visual.blue_mask;
   1.255 -    }
   1.256 -    // See if we have been passed a window to use
   1.257 -    SDL_windowid = getenv("SDL_WINDOWID");
   1.258 -
   1.259 -    // Create the fullscreen (and managed windows : no implement)
   1.260 -    create_aux_windows(this);
   1.261 -
   1.262 -    Dprintf("leave NX_VideoInit\n");
   1.263 -    return 0;
   1.264 -}
   1.265 -
   1.266 -void
   1.267 -NX_VideoQuit(_THIS)
   1.268 -{
   1.269 -    Dprintf("enter NX_VideoQuit\n");
   1.270 -
   1.271 -    // Start shutting down the windows
   1.272 -    NX_DestroyImage(this, this->screen);
   1.273 -    NX_DestroyWindow(this, this->screen);
   1.274 -    if (FSwindow && FSwindow != GR_ROOT_WINDOW_ID) {
   1.275 -        GrDestroyWindow(FSwindow);
   1.276 -    }
   1.277 -    NX_FreeVideoModes(this);
   1.278 -    SDL_free(GammaRamp_R);
   1.279 -    SDL_free(GammaRamp_G);
   1.280 -    SDL_free(GammaRamp_B);
   1.281 -
   1.282 -#ifdef ENABLE_NANOX_DIRECT_FB
   1.283 -    if (Clientfb)
   1.284 -        GrCloseClientFramebuffer();
   1.285 -#endif
   1.286 -    GrClose();
   1.287 -
   1.288 -    Dprintf("leave NX_VideoQuit\n");
   1.289 -}
   1.290 -
   1.291 -static void
   1.292 -NX_DestroyWindow(_THIS, SDL_Surface * screen)
   1.293 -{
   1.294 -    Dprintf("enter NX_DestroyWindow\n");
   1.295 -
   1.296 -    if (!SDL_windowid) {
   1.297 -        if (screen && (screen->flags & SDL_FULLSCREEN)) {
   1.298 -            screen->flags &= ~SDL_FULLSCREEN;
   1.299 -            NX_LeaveFullScreen(this);
   1.300 -        }
   1.301 -        // Destroy the output window
   1.302 -        if (SDL_Window && SDL_Window != GR_ROOT_WINDOW_ID) {
   1.303 -            GrDestroyWindow(SDL_Window);
   1.304 -        }
   1.305 -    }
   1.306 -    // Free the graphics context
   1.307 -    if (!SDL_GC) {
   1.308 -        GrDestroyGC(SDL_GC);
   1.309 -        SDL_GC = 0;
   1.310 -    }
   1.311 -
   1.312 -    Dprintf("leave NX_DestroyWindow\n");
   1.313 -}
   1.314 -
   1.315 -static int
   1.316 -NX_CreateWindow(_THIS, SDL_Surface * screen,
   1.317 -                int w, int h, int bpp, Uint32 flags)
   1.318 -{
   1.319 -    Dprintf("enter NX_CreateWindow\n");
   1.320 -
   1.321 -    // If a window is already present, destroy it and start fresh
   1.322 -    if (SDL_Window && SDL_Window != GR_ROOT_WINDOW_ID) {
   1.323 -        NX_DestroyWindow(this, screen);
   1.324 -    }
   1.325 -    // See if we have been given a window id
   1.326 -    if (SDL_windowid) {
   1.327 -        SDL_Window = SDL_strtol(SDL_windowid, NULL, 0);
   1.328 -    } else {
   1.329 -        SDL_Window = 0;
   1.330 -    }
   1.331 -
   1.332 -    if (!SDL_ReallocFormat(screen, bpp, SDL_Visual.red_mask,
   1.333 -                           SDL_Visual.green_mask, SDL_Visual.blue_mask, 0))
   1.334 -        return -1;
   1.335 -
   1.336 -    // Create (or use) the nanox display window
   1.337 -    if (!SDL_windowid) {
   1.338 -
   1.339 -        SDL_Window =
   1.340 -            GrNewWindow(GR_ROOT_WINDOW_ID, 0, 0, w, h, 0, BLACK, WHITE);
   1.341 -
   1.342 -        GrSelectEvents(SDL_Window, (GR_EVENT_MASK_EXPOSURE |
   1.343 -                                    GR_EVENT_MASK_BUTTON_DOWN |
   1.344 -                                    GR_EVENT_MASK_BUTTON_UP |
   1.345 -                                    GR_EVENT_MASK_FOCUS_IN |
   1.346 -                                    GR_EVENT_MASK_FOCUS_OUT |
   1.347 -                                    GR_EVENT_MASK_KEY_DOWN |
   1.348 -                                    GR_EVENT_MASK_KEY_UP |
   1.349 -                                    GR_EVENT_MASK_MOUSE_ENTER |
   1.350 -                                    GR_EVENT_MASK_MOUSE_EXIT |
   1.351 -                                    GR_EVENT_MASK_MOUSE_MOTION |
   1.352 -                                    GR_EVENT_MASK_UPDATE |
   1.353 -                                    GR_EVENT_MASK_CLOSE_REQ));
   1.354 -    }
   1.355 -
   1.356 -    /* Create the graphics context here, once we have a window */
   1.357 -    SDL_GC = GrNewGC();
   1.358 -    if (SDL_GC == 0) {
   1.359 -        SDL_SetError("Couldn't create graphics context");
   1.360 -        return (-1);
   1.361 -    }
   1.362 -    // Map them both and go fullscreen, if requested
   1.363 -    if (!SDL_windowid) {
   1.364 -        GrMapWindow(SDL_Window);
   1.365 -        if (flags & SDL_FULLSCREEN) {
   1.366 -            screen->flags |= SDL_FULLSCREEN;
   1.367 -            NX_EnterFullScreen(this);
   1.368 -        } else {
   1.369 -            screen->flags &= ~SDL_FULLSCREEN;
   1.370 -        }
   1.371 -    }
   1.372 -#ifdef ENABLE_NANOX_DIRECT_FB
   1.373 -    /* attempt allocating the client side framebuffer */
   1.374 -    Clientfb = GrOpenClientFramebuffer();
   1.375 -    /* NULL return will default to using GrArea() */
   1.376 -#endif
   1.377 -
   1.378 -    Dprintf("leave NX_CreateWindow\n");
   1.379 -    return 0;
   1.380 -}
   1.381 -
   1.382 -SDL_Surface *
   1.383 -NX_SetVideoMode(_THIS, SDL_Surface * current,
   1.384 -                int width, int height, int bpp, Uint32 flags)
   1.385 -{
   1.386 -    Dprintf("enter NX_SetVideoMode\n");
   1.387 -
   1.388 -    // Lock the event thread, in multi-threading environments
   1.389 -    SDL_Lock_EventThread();
   1.390 -
   1.391 -    bpp = SDL_Visual.bpp;
   1.392 -    if (NX_CreateWindow(this, current, width, height, bpp, flags) < 0) {
   1.393 -        current = NULL;
   1.394 -        goto done;
   1.395 -    }
   1.396 -
   1.397 -    if (current->w != width || current->h != height) {
   1.398 -        current->w = width;
   1.399 -        current->h = height;
   1.400 -        current->pitch = SDL_CalculatePitch(current);
   1.401 -        NX_ResizeImage(this, current, flags);
   1.402 -    }
   1.403 -    current->flags |= (flags & (SDL_RESIZABLE | SDL_NOFRAME));
   1.404 -
   1.405 -  done:
   1.406 -    SDL_Unlock_EventThread();
   1.407 -
   1.408 -    Dprintf("leave NX_SetVideoMode\n");
   1.409 -
   1.410 -    // We're done!
   1.411 -    return current;
   1.412 -}
   1.413 -
   1.414 -// ncolors <= 256
   1.415 -int
   1.416 -NX_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
   1.417 -{
   1.418 -    int i;
   1.419 -    GR_PALETTE pal;
   1.420 -
   1.421 -    Dprintf("enter NX_SetColors\n");
   1.422 -
   1.423 -    if (ncolors > 256)
   1.424 -        return 0;
   1.425 -
   1.426 -    pal.count = ncolors;
   1.427 -    for (i = 0; i < ncolors; ++i) {
   1.428 -        pal.palette[i].r = colors[i].r;
   1.429 -        pal.palette[i].g = colors[i].g;
   1.430 -        pal.palette[i].b = colors[i].b;
   1.431 -    }
   1.432 -    GrSetSystemPalette(firstcolor, &pal);
   1.433 -
   1.434 -    Dprintf("leave NX_SetColors\n");
   1.435 -    return 1;
   1.436 -}
   1.437 -
   1.438 -static int
   1.439 -NX_ToggleFullScreen(_THIS, int on)
   1.440 -{
   1.441 -    SDL_Rect rect;
   1.442 -    Uint32 event_thread;
   1.443 -
   1.444 -    Dprintf("enter NX_ToggleFullScreen\n");
   1.445 -
   1.446 -    // Don't switch if we don't own the window
   1.447 -    if (SDL_windowid)
   1.448 -        return 0;
   1.449 -
   1.450 -    // Don't lock if we are the event thread
   1.451 -    event_thread = SDL_EventThreadID();
   1.452 -    if (event_thread && (SDL_ThreadID() == event_thread)) {
   1.453 -        event_thread = 0;
   1.454 -    }
   1.455 -    if (event_thread) {
   1.456 -        SDL_Lock_EventThread();
   1.457 -    }
   1.458 -
   1.459 -    if (on) {
   1.460 -        NX_EnterFullScreen(this);
   1.461 -    } else {
   1.462 -        this->screen->flags &= ~SDL_FULLSCREEN;
   1.463 -        NX_LeaveFullScreen(this);
   1.464 -    }
   1.465 -
   1.466 -    rect.x = rect.y = 0;
   1.467 -    rect.w = this->screen->w, rect.h = this->screen->h;
   1.468 -    NX_NormalUpdate(this, 1, &rect);
   1.469 -
   1.470 -    if (event_thread) {
   1.471 -        SDL_Unlock_EventThread();
   1.472 -    }
   1.473 -
   1.474 -    Dprintf("leave NX_ToggleFullScreen\n");
   1.475 -    return 1;
   1.476 -}
   1.477 -
   1.478 -// Update the current mouse state and position
   1.479 -static void
   1.480 -NX_UpdateMouse(_THIS)
   1.481 -{
   1.482 -    int x, y;
   1.483 -    GR_WINDOW_INFO info;
   1.484 -    GR_SCREEN_INFO si;
   1.485 -
   1.486 -
   1.487 -    Dprintf("enter NX_UpdateMouse\n");
   1.488 -
   1.489 -    // Lock the event thread, in multi-threading environments
   1.490 -    SDL_Lock_EventThread();
   1.491 -
   1.492 -    GrGetScreenInfo(&si);
   1.493 -    GrGetWindowInfo(SDL_Window, &info);
   1.494 -    x = si.xpos - info.x;
   1.495 -    y = si.ypos - info.y;
   1.496 -    if (x >= 0 && x <= info.width && y >= 0 && y <= info.height) {
   1.497 -        SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
   1.498 -        SDL_PrivateMouseMotion(0, 0, x, y);
   1.499 -    } else {
   1.500 -        SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
   1.501 -    }
   1.502 -
   1.503 -    SDL_Unlock_EventThread();
   1.504 -    Dprintf("leave NX_UpdateMouse\n");
   1.505 -}
   1.506 -
   1.507 -static int
   1.508 -NX_SetGammaRamp(_THIS, Uint16 * ramp)
   1.509 -{
   1.510 -    int i;
   1.511 -    Uint16 *red, *green, *blue;
   1.512 -
   1.513 -    Dprintf("enter NX_SetGammaRamp\n");
   1.514 -
   1.515 -    if (SDL_Visual.bpp != 32 && SDL_Visual.bpp != 24)
   1.516 -        return -1;
   1.517 -
   1.518 -    if (!GammaRamp_R)
   1.519 -        GammaRamp_R = (Uint16 *) SDL_malloc(sizeof(Uint16) * CI_SIZE);
   1.520 -    if (!GammaRamp_G)
   1.521 -        GammaRamp_G = (Uint16 *) SDL_malloc(sizeof(Uint16) * CI_SIZE);
   1.522 -    if (!GammaRamp_B)
   1.523 -        GammaRamp_B = (Uint16 *) SDL_malloc(sizeof(Uint16) * CI_SIZE);
   1.524 -    if ((!GammaRamp_R) || (!GammaRamp_G) || (!GammaRamp_B)) {
   1.525 -        SDL_OutOfMemory();
   1.526 -        return -1;
   1.527 -    }
   1.528 -
   1.529 -    for (i = 0; i < CI_SIZE; ++i)
   1.530 -        GammaRamp_R[i] = GammaRamp_G[i] = GammaRamp_B[i] = i;
   1.531 -
   1.532 -    red = ramp;
   1.533 -    green = ramp + CI_SIZE;
   1.534 -    blue = green + CI_SIZE;
   1.535 -
   1.536 -    for (i = 0; i < CI_SIZE; ++i) {
   1.537 -        GammaRamp_R[i] = red[i];
   1.538 -        GammaRamp_G[i] = green[i];
   1.539 -        GammaRamp_B[i] = blue[i];
   1.540 -    }
   1.541 -    SDL_UpdateRect(this->screen, 0, 0, 0, 0);
   1.542 -
   1.543 -    Dprintf("leave NX_SetGammaRamp\n");
   1.544 -    return 0;
   1.545 -}
   1.546 -
   1.547 -static int
   1.548 -NX_GetGammaRamp(_THIS, Uint16 * ramp)
   1.549 -{
   1.550 -    int i;
   1.551 -    Uint16 *red, *green, *blue;
   1.552 -
   1.553 -    Dprintf("enter NX_GetGammaRamp\n");
   1.554 -
   1.555 -    if (SDL_Visual.bpp != 32 && SDL_Visual.bpp != 24)
   1.556 -        return -1;
   1.557 -    red = ramp;
   1.558 -    green = ramp + CI_SIZE;
   1.559 -    blue = green + CI_SIZE;
   1.560 -    if (GammaRamp_R && GammaRamp_G && GammaRamp_B) {
   1.561 -        for (i = 0; i < CI_SIZE; ++i) {
   1.562 -            red[i] = GammaRamp_R[i];
   1.563 -            green[i] = GammaRamp_G[i];
   1.564 -            blue[i] = GammaRamp_B[i];
   1.565 -        }
   1.566 -    } else {
   1.567 -        for (i = 0; i < CI_SIZE; ++i)
   1.568 -            red[i] = green[i] = blue[i] = i;
   1.569 -    }
   1.570 -
   1.571 -    Dprintf("leave NX_GetGammaRamp\n");
   1.572 -    return 0;
   1.573 -}
   1.574 -
   1.575 -/* vi: set ts=4 sw=4 expandtab: */