Mercurial > sdl-ios-xcode
comparison 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 |
comparison
equal
deleted
inserted
replaced
470:877b992f2d0c | 471:26dafefeebb2 |
---|---|
1 /* | 1 /* |
2 SDL - Simple DirectMedia Layer | 2 SDL - Simple DirectMedia Layer |
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga | 3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga |
4 Copyright (C) 2001 Hsieh-Fu Tsai | 4 Copyright (C) 2001 Hsieh-Fu Tsai |
5 Copyright (C) 2002 Greg Haerr <greg@censoft.com> | |
5 | 6 |
6 This library is free software; you can redistribute it and/or | 7 This library is free software; you can redistribute it and/or |
7 modify it under the terms of the GNU Library General Public | 8 modify it under the terms of the GNU Library General Public |
8 License as published by the Free Software Foundation; either | 9 License as published by the Free Software Foundation; either |
9 version 2 of the License, or (at your option) any later version. | 10 version 2 of the License, or (at your option) any later version. |
30 | 31 |
31 #include "SDL_nximage_c.h" | 32 #include "SDL_nximage_c.h" |
32 | 33 |
33 void NX_NormalUpdate (_THIS, int numrects, SDL_Rect * rects) | 34 void NX_NormalUpdate (_THIS, int numrects, SDL_Rect * rects) |
34 { | 35 { |
35 int i, j, xinc, yinc, destinc ; | 36 int i, j, xinc, yinc, destinc, rowinc ; |
36 int x, y, w, h ; | 37 int x, y, w, h ; |
37 unsigned char * src = NULL, * dest = NULL ; | 38 unsigned char * src = NULL, * dest = NULL ; |
38 | 39 |
39 Dprintf ("enter NX_NormalUpdate\n") ; | 40 Dprintf ("enter NX_NormalUpdate\n") ; |
40 | 41 |
42 /* These are the values for the incoming image */ | |
41 xinc = this -> screen -> format -> BytesPerPixel ; | 43 xinc = this -> screen -> format -> BytesPerPixel ; |
42 yinc = this -> screen -> pitch ; | 44 yinc = this -> screen -> pitch ; |
43 | 45 |
44 for (i = 0; i < numrects; ++ i) { | 46 for (i = 0; i < numrects; ++ i) { |
45 x = rects [i].x, y = rects [i].y ; | 47 x = rects [i].x, y = rects [i].y ; |
46 w = rects [i].w, h = rects [i].h ; | 48 w = rects [i].w, h = rects [i].h ; |
47 src = SDL_Image + y * yinc + x * xinc ; | 49 src = SDL_Image + y * yinc + x * xinc ; |
48 dest = Image_buff ; | 50 #ifdef ENABLE_NANOX_DIRECT_FB |
49 destinc = w * xinc ; | 51 if (Clientfb) { |
52 if (currently_fullscreen) | |
53 dest = fbinfo.winpixels + (((y+OffsetY) * fbinfo.pitch) + | |
54 ((x+OffsetX) * fbinfo.bytespp)); | |
55 else | |
56 dest = fbinfo.winpixels + ((y * fbinfo.pitch) + (x * fbinfo.bytespp)); | |
57 destinc = fbinfo.pitch; | |
58 } else { | |
59 #endif | |
60 dest = Image_buff ; | |
61 destinc = w * xinc ; | |
62 #ifdef ENABLE_NANOX_DIRECT_FB | |
63 } | |
64 #endif | |
65 rowinc = w * xinc; | |
50 | 66 |
51 // apply GammaRamp table | 67 // apply GammaRamp table |
52 #if (defined (NANOX_PIXEL_RGB) || defined (NANOX_PIXEL_0888) || \ | 68 if ((pixel_type == MWPF_TRUECOLOR0888 || pixel_type == MWPF_TRUECOLOR888) |
53 defined (NANOX_PIXEL_888)) | 69 && GammaRamp_R && GammaRamp_G && GammaRamp_B) { |
54 if (GammaRamp_R && GammaRamp_G && GammaRamp_B) { | |
55 Uint8 * ptr ; | 70 Uint8 * ptr ; |
56 int k ; | 71 int k ; |
57 | 72 |
58 for (j = h; j > 0; -- j, src += yinc) { | 73 for (j = h; j > 0; -- j, src += yinc) { |
59 ptr = src - 1 ; | 74 ptr = src - 1 ; |
60 for (k = w; k > 0; -- k) { | 75 for (k = w; k > 0; -- k) { |
61 #ifdef NANOX_PIXEL_RGB | 76 if (pixel_type == MWPF_TRUECOLOR0888) |
62 ptr += 2 ; | 77 ptr += 2 ; |
63 #endif | 78 else |
64 #ifdef NANOX_PIXEL_0888 | 79 ++ ptr ; |
65 ptr += 2 ; | |
66 #endif | |
67 #ifdef NANOX_PIXEL_888 | |
68 ++ ptr ; | |
69 #endif | |
70 (* ptr) = GammaRamp_B [(* ptr)] ; | 80 (* ptr) = GammaRamp_B [(* ptr)] ; |
71 ++ ptr ; | 81 ++ ptr ; |
72 (* ptr) = GammaRamp_G [(* ptr)] ; | 82 (* ptr) = GammaRamp_G [(* ptr)] ; |
73 ++ ptr ; | 83 ++ ptr ; |
74 (* ptr) = GammaRamp_R [(* ptr)] ; | 84 (* ptr) = GammaRamp_R [(* ptr)] ; |
75 } | 85 } |
76 } | 86 } |
77 src = SDL_Image + y * yinc + x * xinc ; | 87 src = SDL_Image + y * yinc + x * xinc ; |
78 } | 88 } |
79 #endif // apply Gamma table | 89 |
80 | 90 for (j = h; j > 0; -- j, src += yinc, dest += destinc) |
81 for (j = h; j > 0; -- j, src += yinc, dest += destinc) { | 91 memcpy (dest, src, rowinc) ; |
82 memcpy (dest, src, destinc) ; | 92 if (!Clientfb) { |
93 if (currently_fullscreen) { | |
94 GrArea (FSwindow, SDL_GC, x + OffsetX, y + OffsetY, w, h, Image_buff, | |
95 pixel_type) ; | |
96 } else { | |
97 GrArea (SDL_Window, SDL_GC, x, y, w, h, Image_buff, pixel_type) ; | |
98 } | |
99 } | |
100 } | |
101 GrFlush(); | |
102 | |
103 Dprintf ("leave NX_NormalUpdate\n") ; | |
104 } | |
105 | |
106 int NX_SetupImage (_THIS, SDL_Surface * screen) | |
107 { | |
108 int size = screen -> h * screen -> pitch ; | |
109 | |
110 Dprintf ("enter NX_SetupImage\n") ; | |
111 | |
112 screen -> pixels = (void *) malloc (size) ; | |
113 | |
114 if (!Clientfb) { | |
115 Image_buff = (unsigned char *) malloc (size) ; | |
116 if (screen -> pixels == NULL || Image_buff == NULL) { | |
117 free (screen -> pixels) ; | |
118 free (Image_buff) ; | |
119 SDL_OutOfMemory () ; | |
120 return -1 ; | |
83 } | 121 } |
84 | |
85 if (currently_fullscreen) { | |
86 GrArea (FSwindow, SDL_GC, x + OffsetX, y + OffsetY, w, h, Image_buff, | |
87 pixel_type) ; | |
88 } else { | |
89 GrArea (SDL_Window, SDL_GC, x, y, w, h, Image_buff, pixel_type) ; | |
90 } | |
91 } | |
92 | |
93 Dprintf ("leave NX_NormalUpdate\n") ; | |
94 } | |
95 | |
96 int NX_SetupImage (_THIS, SDL_Surface * screen) | |
97 { | |
98 int size = screen -> h * screen -> pitch ; | |
99 | |
100 Dprintf ("enter NX_SetupImage\n") ; | |
101 | |
102 screen -> pixels = (void *) malloc (size) ; | |
103 Image_buff = (unsigned char *) malloc (size) ; | |
104 if (screen -> pixels == NULL || Image_buff == NULL) { | |
105 free (screen -> pixels) ; | |
106 free (Image_buff) ; | |
107 SDL_OutOfMemory () ; | |
108 return -1 ; | |
109 } | 122 } |
110 | 123 |
111 SDL_Image = (unsigned char *) screen -> pixels ; | 124 SDL_Image = (unsigned char *) screen -> pixels ; |
112 | 125 |
113 this -> UpdateRects = NX_NormalUpdate ; | 126 this -> UpdateRects = NX_NormalUpdate ; |
138 retval = NX_SetupImage (this, screen) ; | 151 retval = NX_SetupImage (this, screen) ; |
139 | 152 |
140 GrGetScreenInfo (& si) ; | 153 GrGetScreenInfo (& si) ; |
141 OffsetX = (si.cols - screen -> w) / 2 ; | 154 OffsetX = (si.cols - screen -> w) / 2 ; |
142 OffsetY = (si.rows - screen -> h) / 2 ; | 155 OffsetY = (si.rows - screen -> h) / 2 ; |
143 | 156 |
157 #ifdef ENABLE_NANOX_DIRECT_FB | |
158 if (Clientfb) { | |
159 /* Get current window position and fb pointer*/ | |
160 if (currently_fullscreen) | |
161 GrGetWindowFBInfo(FSwindow, &fbinfo); | |
162 else | |
163 GrGetWindowFBInfo(SDL_Window, &fbinfo); | |
164 } | |
165 #endif | |
144 Dprintf ("leave NX_ResizeImage\n") ; | 166 Dprintf ("leave NX_ResizeImage\n") ; |
145 return retval ; | 167 return retval ; |
146 } | 168 } |
147 | 169 |
148 void NX_RefreshDisplay (_THIS) | 170 void NX_RefreshDisplay (_THIS) |
152 // Don't refresh a display that doesn't have an image (like GL) | 174 // Don't refresh a display that doesn't have an image (like GL) |
153 if (! SDL_Image) { | 175 if (! SDL_Image) { |
154 return; | 176 return; |
155 } | 177 } |
156 | 178 |
157 if (currently_fullscreen) { | 179 #ifdef ENABLE_NANOX_DIRECT_FB |
158 GrArea (FSwindow, SDL_GC, OffsetX, OffsetY, this -> screen -> w, | 180 if (Clientfb) { |
159 this -> screen -> h, SDL_Image, pixel_type) ; | 181 int j; |
182 char *src, *dest = NULL; | |
183 int xinc, yinc, rowinc; | |
184 | |
185 GrGetWindowFBInfo(SDL_Window, &fbinfo); | |
186 | |
187 xinc = this -> screen -> format -> BytesPerPixel ; | |
188 yinc = this -> screen -> pitch ; | |
189 | |
190 src = SDL_Image; | |
191 if (currently_fullscreen) | |
192 dest = fbinfo.winpixels + ((OffsetY * fbinfo.pitch) + | |
193 (OffsetX * fbinfo.bytespp)); | |
194 else | |
195 dest = fbinfo.winpixels; | |
196 rowinc = xinc * this -> screen -> w; | |
197 | |
198 for (j = this -> screen -> h; j > 0; -- j, src += yinc, dest += fbinfo.pitch) | |
199 memcpy (dest, src, rowinc) ; | |
160 } else { | 200 } else { |
161 GrArea (SDL_Window, SDL_GC, 0, 0, this -> screen -> w, | 201 #endif |
162 this -> screen -> h, SDL_Image, pixel_type) ; | 202 if (currently_fullscreen) { |
163 } | 203 GrArea (FSwindow, SDL_GC, OffsetX, OffsetY, this -> screen -> w, |
204 this -> screen -> h, SDL_Image, pixel_type) ; | |
205 } else { | |
206 GrArea (SDL_Window, SDL_GC, 0, 0, this -> screen -> w, | |
207 this -> screen -> h, SDL_Image, pixel_type) ; | |
208 } | |
209 #ifdef ENABLE_NANOX_DIRECT_FB | |
210 } | |
211 #endif | |
212 GrFlush(); | |
164 | 213 |
165 Dprintf ("leave NX_RefreshDisplay\n") ; | 214 Dprintf ("leave NX_RefreshDisplay\n") ; |
166 } | 215 } |