src/video/nanox/SDL_nximage.c
changeset 3274 08574b033f37
parent 3273 e0dfba770eb7
child 3275 a4a34a511ba0
     1.1 --- a/src/video/nanox/SDL_nximage.c	Sat Sep 19 07:22:07 2009 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,243 +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_nximage_c.h"
    1.33 -
    1.34 -void
    1.35 -NX_NormalUpdate(_THIS, int numrects, SDL_Rect * rects)
    1.36 -{
    1.37 -    int i, j, xinc, yinc, destinc, rowinc;
    1.38 -    int x, y, w, h;
    1.39 -    unsigned char *src = NULL, *dest = NULL;
    1.40 -
    1.41 -    Dprintf("enter NX_NormalUpdate\n");
    1.42 -
    1.43 -    /* These are the values for the incoming image */
    1.44 -    xinc = this->screen->format->BytesPerPixel;
    1.45 -    yinc = this->screen->pitch;
    1.46 -
    1.47 -    for (i = 0; i < numrects; ++i) {
    1.48 -        x = rects[i].x, y = rects[i].y;
    1.49 -        w = rects[i].w, h = rects[i].h;
    1.50 -        src = SDL_Image + y * yinc + x * xinc;
    1.51 -#ifdef ENABLE_NANOX_DIRECT_FB
    1.52 -        if (Clientfb) {
    1.53 -            if (currently_fullscreen)
    1.54 -                dest =
    1.55 -                    fbinfo.winpixels + (((y + OffsetY) * fbinfo.pitch) +
    1.56 -                                        ((x + OffsetX) * fbinfo.bytespp));
    1.57 -            else
    1.58 -                dest =
    1.59 -                    fbinfo.winpixels + ((y * fbinfo.pitch) +
    1.60 -                                        (x * fbinfo.bytespp));
    1.61 -            destinc = fbinfo.pitch;
    1.62 -        } else
    1.63 -#endif
    1.64 -        {
    1.65 -            dest = Image_buff;
    1.66 -            destinc = w * xinc;
    1.67 -        }
    1.68 -        rowinc = w * xinc;
    1.69 -
    1.70 -        // apply GammaRamp table
    1.71 -        if ((pixel_type == MWPF_TRUECOLOR0888
    1.72 -             || pixel_type == MWPF_TRUECOLOR888) && GammaRamp_R
    1.73 -            && GammaRamp_G && GammaRamp_B) {
    1.74 -            Uint8 *ptrsrc;
    1.75 -            Uint8 *ptrdst;
    1.76 -            int k;
    1.77 -
    1.78 -            for (j = h; j > 0; --j, src += yinc, dest += destinc) {
    1.79 -                ptrsrc = src;
    1.80 -                ptrdst = dest;
    1.81 -                for (k = w; k > 0; --k) {
    1.82 -                    *ptrdst++ = GammaRamp_B[*ptrsrc++] >> 8;
    1.83 -                    *ptrdst++ = GammaRamp_G[*ptrsrc++] >> 8;
    1.84 -                    *ptrdst++ = GammaRamp_R[*ptrsrc++] >> 8;
    1.85 -                    *ptrdst++ = 0;
    1.86 -                    ++ptrsrc;
    1.87 -                }
    1.88 -            }
    1.89 -        }
    1.90 -#if 1                           /* This is needed for microwindows 0.90 or older */
    1.91 -        else if (pixel_type == MWPF_TRUECOLOR0888
    1.92 -                 || pixel_type == MWPF_TRUECOLOR888) {
    1.93 -            Uint8 *ptrsrc;
    1.94 -            Uint8 *ptrdst;
    1.95 -            int k;
    1.96 -
    1.97 -            for (j = h; j > 0; --j, src += yinc, dest += destinc) {
    1.98 -                ptrsrc = src;
    1.99 -                ptrdst = dest;
   1.100 -                for (k = w; k > 0; --k) {
   1.101 -                    *ptrdst++ = *ptrsrc++;
   1.102 -                    *ptrdst++ = *ptrsrc++;
   1.103 -                    *ptrdst++ = *ptrsrc++;
   1.104 -                    *ptrdst++ = 0;
   1.105 -                    ++ptrsrc;
   1.106 -                }
   1.107 -            }
   1.108 -        }
   1.109 -#endif
   1.110 -        else {
   1.111 -            for (j = h; j > 0; --j, src += yinc, dest += destinc)
   1.112 -                SDL_memcpy(dest, src, rowinc);
   1.113 -        }
   1.114 -        if (!Clientfb) {
   1.115 -            if (currently_fullscreen) {
   1.116 -                GrArea(FSwindow, SDL_GC, x + OffsetX, y + OffsetY, w,
   1.117 -                       h, Image_buff, pixel_type);
   1.118 -            } else {
   1.119 -                GrArea(SDL_Window, SDL_GC, x, y, w, h, Image_buff,
   1.120 -                       pixel_type);
   1.121 -            }
   1.122 -        }
   1.123 -    }
   1.124 -    GrFlush();
   1.125 -
   1.126 -    Dprintf("leave NX_NormalUpdate\n");
   1.127 -}
   1.128 -
   1.129 -int
   1.130 -NX_SetupImage(_THIS, SDL_Surface * screen)
   1.131 -{
   1.132 -    int size = screen->h * screen->pitch;
   1.133 -
   1.134 -    Dprintf("enter NX_SetupImage\n");
   1.135 -
   1.136 -    screen->pixels = (void *) SDL_malloc(size);
   1.137 -
   1.138 -    if (!Clientfb) {
   1.139 -        Image_buff = (unsigned char *) SDL_malloc(size);
   1.140 -        if (screen->pixels == NULL || Image_buff == NULL) {
   1.141 -            SDL_free(screen->pixels);
   1.142 -            SDL_free(Image_buff);
   1.143 -            SDL_OutOfMemory();
   1.144 -            return -1;
   1.145 -        }
   1.146 -    }
   1.147 -
   1.148 -    SDL_Image = (unsigned char *) screen->pixels;
   1.149 -
   1.150 -    this->UpdateRects = NX_NormalUpdate;
   1.151 -
   1.152 -    Dprintf("leave NX_SetupImage\n");
   1.153 -    return 0;
   1.154 -}
   1.155 -
   1.156 -void
   1.157 -NX_DestroyImage(_THIS, SDL_Surface * screen)
   1.158 -{
   1.159 -    Dprintf("enter NX_DestroyImage\n");
   1.160 -
   1.161 -    if (SDL_Image)
   1.162 -        SDL_free(SDL_Image);
   1.163 -    if (Image_buff)
   1.164 -        SDL_free(Image_buff);
   1.165 -    if (screen)
   1.166 -        screen->pixels = NULL;
   1.167 -
   1.168 -    Dprintf("leave NX_DestroyImage\n");
   1.169 -}
   1.170 -
   1.171 -int
   1.172 -NX_ResizeImage(_THIS, SDL_Surface * screen, Uint32 flags)
   1.173 -{
   1.174 -    int retval;
   1.175 -    GR_SCREEN_INFO si;
   1.176 -
   1.177 -    Dprintf("enter NX_ResizeImage\n");
   1.178 -
   1.179 -    NX_DestroyImage(this, screen);
   1.180 -    retval = NX_SetupImage(this, screen);
   1.181 -
   1.182 -    GrGetScreenInfo(&si);
   1.183 -    OffsetX = (si.cols - screen->w) / 2;
   1.184 -    OffsetY = (si.rows - screen->h) / 2;
   1.185 -
   1.186 -#ifdef ENABLE_NANOX_DIRECT_FB
   1.187 -    if (Clientfb) {
   1.188 -        /* Get current window position and fb pointer */
   1.189 -        if (currently_fullscreen)
   1.190 -            GrGetWindowFBInfo(FSwindow, &fbinfo);
   1.191 -        else
   1.192 -            GrGetWindowFBInfo(SDL_Window, &fbinfo);
   1.193 -    }
   1.194 -#endif
   1.195 -    Dprintf("leave NX_ResizeImage\n");
   1.196 -    return retval;
   1.197 -}
   1.198 -
   1.199 -void
   1.200 -NX_RefreshDisplay(_THIS)
   1.201 -{
   1.202 -    Dprintf("enter NX_RefreshDisplay\n");
   1.203 -
   1.204 -    // Don't refresh a display that doesn't have an image (like GL)
   1.205 -    if (!SDL_Image) {
   1.206 -        return;
   1.207 -    }
   1.208 -#ifdef ENABLE_NANOX_DIRECT_FB
   1.209 -    if (Clientfb) {
   1.210 -        int j;
   1.211 -        char *src, *dest = NULL;
   1.212 -        int xinc, yinc, rowinc;
   1.213 -
   1.214 -        GrGetWindowFBInfo(SDL_Window, &fbinfo);
   1.215 -
   1.216 -        xinc = this->screen->format->BytesPerPixel;
   1.217 -        yinc = this->screen->pitch;
   1.218 -
   1.219 -        src = SDL_Image;
   1.220 -        if (currently_fullscreen)
   1.221 -            dest = fbinfo.winpixels + ((OffsetY * fbinfo.pitch) +
   1.222 -                                       (OffsetX * fbinfo.bytespp));
   1.223 -        else
   1.224 -            dest = fbinfo.winpixels;
   1.225 -        rowinc = xinc * this->screen->w;
   1.226 -
   1.227 -        for (j = this->screen->h; j > 0;
   1.228 -             --j, src += yinc, dest += fbinfo.pitch)
   1.229 -            SDL_memcpy(dest, src, rowinc);
   1.230 -    } else
   1.231 -#endif
   1.232 -    {
   1.233 -        if (currently_fullscreen) {
   1.234 -            GrArea(FSwindow, SDL_GC, OffsetX, OffsetY, this->screen->w,
   1.235 -                   this->screen->h, SDL_Image, pixel_type);
   1.236 -        } else {
   1.237 -            GrArea(SDL_Window, SDL_GC, 0, 0, this->screen->w,
   1.238 -                   this->screen->h, SDL_Image, pixel_type);
   1.239 -        }
   1.240 -    }
   1.241 -    GrFlush();
   1.242 -
   1.243 -    Dprintf("leave NX_RefreshDisplay\n");
   1.244 -}
   1.245 -
   1.246 -/* vi: set ts=4 sw=4 expandtab: */