comparison src/video/nanox/SDL_nximage.c @ 699:d3b2e93629eb

Fixed some bugs in the Nano-X video driver
author Sam Lantinga <slouken@libsdl.org>
date Sat, 30 Aug 2003 09:06:37 +0000
parents 31d9be995d5c
children c35edafc84d1
comparison
equal deleted inserted replaced
698:31d9be995d5c 699:d3b2e93629eb
47 for (i = 0; i < numrects; ++ i) { 47 for (i = 0; i < numrects; ++ i) {
48 x = rects [i].x, y = rects [i].y ; 48 x = rects [i].x, y = rects [i].y ;
49 w = rects [i].w, h = rects [i].h ; 49 w = rects [i].w, h = rects [i].h ;
50 src = SDL_Image + y * yinc + x * xinc ; 50 src = SDL_Image + y * yinc + x * xinc ;
51 #ifdef ENABLE_NANOX_DIRECT_FB 51 #ifdef ENABLE_NANOX_DIRECT_FB
52 if (Clientfb) { 52 if (Clientfb) {
53 if (currently_fullscreen) 53 if (currently_fullscreen)
54 dest = fbinfo.winpixels + (((y+OffsetY) * fbinfo.pitch) + 54 dest = fbinfo.winpixels + (((y+OffsetY) * fbinfo.pitch) +
55 ((x+OffsetX) * fbinfo.bytespp)); 55 ((x+OffsetX) * fbinfo.bytespp));
56 else 56 else
57 dest = fbinfo.winpixels + ((y * fbinfo.pitch) + (x * fbinfo.bytespp)); 57 dest = fbinfo.winpixels + ((y * fbinfo.pitch) + (x * fbinfo.bytespp));
58 destinc = fbinfo.pitch; 58 destinc = fbinfo.pitch;
59 } else { 59 }
60 #endif 60 else
61 #endif
62 {
61 dest = Image_buff ; 63 dest = Image_buff ;
62 destinc = w * xinc ; 64 destinc = w * xinc ;
63 #ifdef ENABLE_NANOX_DIRECT_FB 65 }
64 } 66 rowinc = w * xinc;
65 #endif
66 rowinc = w * xinc;
67 67
68 // apply GammaRamp table 68 // apply GammaRamp table
69 if ((pixel_type == MWPF_TRUECOLOR0888 || pixel_type == MWPF_TRUECOLOR888) 69 if ((pixel_type == MWPF_TRUECOLOR0888 || pixel_type == MWPF_TRUECOLOR888)
70 && GammaRamp_R && GammaRamp_G && GammaRamp_B) { 70 && GammaRamp_R && GammaRamp_G && GammaRamp_B) {
71 Uint8 * ptr ; 71 Uint8 * ptrsrc ;
72 Uint8 * ptrdst ;
72 int k ; 73 int k ;
73 74
74 for (j = h; j > 0; -- j, src += yinc) { 75 for (j = h; j > 0; -- j, src += yinc, dest += destinc) {
75 ptr = src - 1 ; 76 ptrsrc = src ;
77 ptrdst = dest ;
76 for (k = w; k > 0; -- k) { 78 for (k = w; k > 0; -- k) {
77 if (pixel_type == MWPF_TRUECOLOR0888) 79 *ptrdst++ = GammaRamp_B [*ptrsrc++] >> 8;
78 ptr += 2 ; 80 *ptrdst++ = GammaRamp_G [*ptrsrc++] >> 8;
79 else 81 *ptrdst++ = GammaRamp_R [*ptrsrc++] >> 8;
80 ++ ptr ; 82 *ptrdst++ = 0;
81 (* ptr) = GammaRamp_B [(* ptr)] ; 83 ++ptrsrc;
82 ++ ptr ;
83 (* ptr) = GammaRamp_G [(* ptr)] ;
84 ++ ptr ;
85 (* ptr) = GammaRamp_R [(* ptr)] ;
86 } 84 }
87 } 85 }
88 src = SDL_Image + y * yinc + x * xinc ; 86 }
89 } 87 #if 0 /* This is needed for microwindows 0.90 or older */
90 88 else if (pixel_type == MWPF_TRUECOLOR0888 || pixel_type == MWPF_TRUECOLOR888) {
91 for (j = h; j > 0; -- j, src += yinc, dest += destinc) 89 Uint8 * ptrsrc ;
92 memcpy (dest, src, rowinc) ; 90 Uint8 * ptrdst ;
93 if (!Clientfb) { 91 int k ;
92
93 for (j = h; j > 0; -- j, src += yinc, dest += destinc) {
94 ptrsrc = src ;
95 ptrdst = dest ;
96 for (k = w; k > 0; -- k) {
97 *ptrdst++ = *ptrsrc++;
98 *ptrdst++ = *ptrsrc++;
99 *ptrdst++ = *ptrsrc++;
100 *ptrdst++ = 0;
101 ++ptrsrc;
102 }
103 }
104 }
105 #endif
106 else
107 {
108 for (j = h; j > 0; -- j, src += yinc, dest += destinc)
109 memcpy (dest, src, rowinc) ;
110 }
111 if (!Clientfb) {
94 if (currently_fullscreen) { 112 if (currently_fullscreen) {
95 GrArea (FSwindow, SDL_GC, x + OffsetX, y + OffsetY, w, h, Image_buff, 113 GrArea (FSwindow, SDL_GC, x + OffsetX, y + OffsetY, w, h, Image_buff,
96 pixel_type) ; 114 pixel_type) ;
97 } else { 115 } else {
98 GrArea (SDL_Window, SDL_GC, x, y, w, h, Image_buff, pixel_type) ; 116 GrArea (SDL_Window, SDL_GC, x, y, w, h, Image_buff, pixel_type) ;
99 } 117 }
100 } 118 }
101 } 119 }
102 GrFlush(); 120 GrFlush();
103 121
104 Dprintf ("leave NX_NormalUpdate\n") ; 122 Dprintf ("leave NX_NormalUpdate\n") ;
105 } 123 }
181 if (Clientfb) { 199 if (Clientfb) {
182 int j; 200 int j;
183 char *src, *dest = NULL; 201 char *src, *dest = NULL;
184 int xinc, yinc, rowinc; 202 int xinc, yinc, rowinc;
185 203
186 GrGetWindowFBInfo(SDL_Window, &fbinfo); 204 GrGetWindowFBInfo(SDL_Window, &fbinfo);
187 205
188 xinc = this -> screen -> format -> BytesPerPixel ; 206 xinc = this -> screen -> format -> BytesPerPixel ;
189 yinc = this -> screen -> pitch ; 207 yinc = this -> screen -> pitch ;
190 208
191 src = SDL_Image; 209 src = SDL_Image;
192 if (currently_fullscreen) 210 if (currently_fullscreen)
193 dest = fbinfo.winpixels + ((OffsetY * fbinfo.pitch) + 211 dest = fbinfo.winpixels + ((OffsetY * fbinfo.pitch) +
194 (OffsetX * fbinfo.bytespp)); 212 (OffsetX * fbinfo.bytespp));
195 else 213 else
196 dest = fbinfo.winpixels; 214 dest = fbinfo.winpixels;
197 rowinc = xinc * this -> screen -> w; 215 rowinc = xinc * this -> screen -> w;
198 216
199 for (j = this -> screen -> h; j > 0; -- j, src += yinc, dest += fbinfo.pitch) 217 for (j = this -> screen -> h; j > 0; -- j, src += yinc, dest += fbinfo.pitch)
200 memcpy (dest, src, rowinc) ; 218 memcpy (dest, src, rowinc) ;
201 } else { 219 }
202 #endif 220 else
221 #endif
222 {
203 if (currently_fullscreen) { 223 if (currently_fullscreen) {
204 GrArea (FSwindow, SDL_GC, OffsetX, OffsetY, this -> screen -> w, 224 GrArea (FSwindow, SDL_GC, OffsetX, OffsetY, this -> screen -> w,
205 this -> screen -> h, SDL_Image, pixel_type) ; 225 this -> screen -> h, SDL_Image, pixel_type) ;
206 } else { 226 } else {
207 GrArea (SDL_Window, SDL_GC, 0, 0, this -> screen -> w, 227 GrArea (SDL_Window, SDL_GC, 0, 0, this -> screen -> w,
208 this -> screen -> h, SDL_Image, pixel_type) ; 228 this -> screen -> h, SDL_Image, pixel_type) ;
209 } 229 }
210 #ifdef ENABLE_NANOX_DIRECT_FB 230 }
211 }
212 #endif
213 GrFlush(); 231 GrFlush();
214 232
215 Dprintf ("leave NX_RefreshDisplay\n") ; 233 Dprintf ("leave NX_RefreshDisplay\n") ;
216 } 234 }