Mercurial > sdl-ios-xcode
diff src/video/nanox/SDL_nximage.c @ 471:26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
From: "Greg Haerr"
Subject: Announce: sdl-nanox-patch
Sam,
I've created an update patch for enhanced Nano-X support
with SDL. I've created the patch against SDL-1.2.4. I'd appreciate
it if you would apply it to the next SDL version.
Enhancements include:
1. Small bugfixes to compile without errors
2. Support for direct client-side framebuffer access with configure option
3. Add dynamic pixel type support for hardware framebuffer; eliminating the
need for compile-time configuration option.
I've updated the README.NanoX file with the details.
This version has been tested with Microwindows v0.89pre9 CVS
and SMPEG 0.4.4. I've added multi-threading support to
Microwindows to support the multi-threaded SMPEG, and
all works fine. To turn on thread safety in Microwindows,
use THREADSAFE=Y in the Microwindows config file.
Thanks!
Regards,
Greg
Founder, The Microwindows Project
http://microwindows.org
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 25 Aug 2002 06:21:49 +0000 |
parents | f6ffac90895c |
children | 31d9be995d5c |
line wrap: on
line diff
--- a/src/video/nanox/SDL_nximage.c Sun Aug 25 02:05:24 2002 +0000 +++ b/src/video/nanox/SDL_nximage.c Sun Aug 25 06:21:49 2002 +0000 @@ -2,6 +2,7 @@ SDL - Simple DirectMedia Layer Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga Copyright (C) 2001 Hsieh-Fu Tsai + Copyright (C) 2002 Greg Haerr <greg@censoft.com> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -32,12 +33,13 @@ void NX_NormalUpdate (_THIS, int numrects, SDL_Rect * rects) { - int i, j, xinc, yinc, destinc ; + int i, j, xinc, yinc, destinc, rowinc ; int x, y, w, h ; unsigned char * src = NULL, * dest = NULL ; - + Dprintf ("enter NX_NormalUpdate\n") ; - + + /* These are the values for the incoming image */ xinc = this -> screen -> format -> BytesPerPixel ; yinc = this -> screen -> pitch ; @@ -45,28 +47,36 @@ x = rects [i].x, y = rects [i].y ; w = rects [i].w, h = rects [i].h ; src = SDL_Image + y * yinc + x * xinc ; - dest = Image_buff ; - destinc = w * xinc ; +#ifdef ENABLE_NANOX_DIRECT_FB + if (Clientfb) { + if (currently_fullscreen) + dest = fbinfo.winpixels + (((y+OffsetY) * fbinfo.pitch) + + ((x+OffsetX) * fbinfo.bytespp)); + else + dest = fbinfo.winpixels + ((y * fbinfo.pitch) + (x * fbinfo.bytespp)); + destinc = fbinfo.pitch; + } else { +#endif + dest = Image_buff ; + destinc = w * xinc ; +#ifdef ENABLE_NANOX_DIRECT_FB + } +#endif + rowinc = w * xinc; // apply GammaRamp table -#if (defined (NANOX_PIXEL_RGB) || defined (NANOX_PIXEL_0888) || \ - defined (NANOX_PIXEL_888)) - if (GammaRamp_R && GammaRamp_G && GammaRamp_B) { + if ((pixel_type == MWPF_TRUECOLOR0888 || pixel_type == MWPF_TRUECOLOR888) + && GammaRamp_R && GammaRamp_G && GammaRamp_B) { Uint8 * ptr ; int k ; for (j = h; j > 0; -- j, src += yinc) { ptr = src - 1 ; for (k = w; k > 0; -- k) { -#ifdef NANOX_PIXEL_RGB - ptr += 2 ; -#endif -#ifdef NANOX_PIXEL_0888 - ptr += 2 ; -#endif -#ifdef NANOX_PIXEL_888 - ++ ptr ; -#endif + if (pixel_type == MWPF_TRUECOLOR0888) + ptr += 2 ; + else + ++ ptr ; (* ptr) = GammaRamp_B [(* ptr)] ; ++ ptr ; (* ptr) = GammaRamp_G [(* ptr)] ; @@ -76,19 +86,19 @@ } src = SDL_Image + y * yinc + x * xinc ; } -#endif // apply Gamma table - for (j = h; j > 0; -- j, src += yinc, dest += destinc) { - memcpy (dest, src, destinc) ; - } - - if (currently_fullscreen) { - GrArea (FSwindow, SDL_GC, x + OffsetX, y + OffsetY, w, h, Image_buff, - pixel_type) ; - } else { - GrArea (SDL_Window, SDL_GC, x, y, w, h, Image_buff, pixel_type) ; - } + for (j = h; j > 0; -- j, src += yinc, dest += destinc) + memcpy (dest, src, rowinc) ; + if (!Clientfb) { + if (currently_fullscreen) { + GrArea (FSwindow, SDL_GC, x + OffsetX, y + OffsetY, w, h, Image_buff, + pixel_type) ; + } else { + GrArea (SDL_Window, SDL_GC, x, y, w, h, Image_buff, pixel_type) ; + } + } } + GrFlush(); Dprintf ("leave NX_NormalUpdate\n") ; } @@ -100,12 +110,15 @@ Dprintf ("enter NX_SetupImage\n") ; screen -> pixels = (void *) malloc (size) ; - Image_buff = (unsigned char *) malloc (size) ; - if (screen -> pixels == NULL || Image_buff == NULL) { - free (screen -> pixels) ; - free (Image_buff) ; - SDL_OutOfMemory () ; - return -1 ; + + if (!Clientfb) { + Image_buff = (unsigned char *) malloc (size) ; + if (screen -> pixels == NULL || Image_buff == NULL) { + free (screen -> pixels) ; + free (Image_buff) ; + SDL_OutOfMemory () ; + return -1 ; + } } SDL_Image = (unsigned char *) screen -> pixels ; @@ -140,7 +153,16 @@ GrGetScreenInfo (& si) ; OffsetX = (si.cols - screen -> w) / 2 ; OffsetY = (si.rows - screen -> h) / 2 ; - + +#ifdef ENABLE_NANOX_DIRECT_FB + if (Clientfb) { + /* Get current window position and fb pointer*/ + if (currently_fullscreen) + GrGetWindowFBInfo(FSwindow, &fbinfo); + else + GrGetWindowFBInfo(SDL_Window, &fbinfo); + } +#endif Dprintf ("leave NX_ResizeImage\n") ; return retval ; } @@ -154,13 +176,40 @@ return; } - if (currently_fullscreen) { - GrArea (FSwindow, SDL_GC, OffsetX, OffsetY, this -> screen -> w, - this -> screen -> h, SDL_Image, pixel_type) ; +#ifdef ENABLE_NANOX_DIRECT_FB + if (Clientfb) { + int j; + char *src, *dest = NULL; + int xinc, yinc, rowinc; + + GrGetWindowFBInfo(SDL_Window, &fbinfo); + + xinc = this -> screen -> format -> BytesPerPixel ; + yinc = this -> screen -> pitch ; + + src = SDL_Image; + if (currently_fullscreen) + dest = fbinfo.winpixels + ((OffsetY * fbinfo.pitch) + + (OffsetX * fbinfo.bytespp)); + else + dest = fbinfo.winpixels; + rowinc = xinc * this -> screen -> w; + + for (j = this -> screen -> h; j > 0; -- j, src += yinc, dest += fbinfo.pitch) + memcpy (dest, src, rowinc) ; } else { - GrArea (SDL_Window, SDL_GC, 0, 0, this -> screen -> w, - this -> screen -> h, SDL_Image, pixel_type) ; +#endif + if (currently_fullscreen) { + GrArea (FSwindow, SDL_GC, OffsetX, OffsetY, this -> screen -> w, + this -> screen -> h, SDL_Image, pixel_type) ; + } else { + GrArea (SDL_Window, SDL_GC, 0, 0, this -> screen -> w, + this -> screen -> h, SDL_Image, pixel_type) ; + } +#ifdef ENABLE_NANOX_DIRECT_FB } +#endif + GrFlush(); Dprintf ("leave NX_RefreshDisplay\n") ; }