Mercurial > sdl-ios-xcode
comparison src/video/photon/SDL_ph_image.c @ 663:8bedd6d61642
Date: Sat, 2 Aug 2003 16:22:51 +0300
From: "Mike Gorchak"
Subject: New patches for QNX6
Here my patches for the SDL/QNX:
QNXSDL.diff - diff to non-QNX related sources:
- updated BUGS file, I think QNX6 is now will be officially supported
- configure.in - added shared library support for QNX, and removed dependency between the ALSA and QNX6.
- SDL_audio.c - added QNX NTO sound bootstrap insted of ALSA's.
- SDL_sysaudio.h - the same.
- SDL_nto_audio.c - the same.
- SDL_video.c - right now, QNX doesn't offer any method to obtain pointers to the OpenGL functions by function name, so they must be hardcoded in library, otherwise OpenGL will not be supported.
- testsprite.c - fixed: do not draw vertical red line if we are in non-double-buffered mode.
sdlqnxph.tar.gz - archive of the ./src/video/photon/* . Too many changes in code to make diffs :) :
+ Added stub for support hide/unhide window event
+ Added full YUV overlays support.
+ Added window maximize support.
+ Added mouse wheel events.
+ Added support for some specific key codes in Unicode mode (like ESC).
+ Added more checks to the all memory allocation code.
+ Added SDL_DOUBLEBUF support in all fullscreen modes.
+ Added fallback to window mode, if desired fullscreen mode is not supported.
+ Added stub support for the GL_LoadLibrary and GL_GetProcAddress functions.
+ Added resizable window support without caption.
! Fixed bug in the Ph_EV_EXPOSE event handler, when rectangles to update is 0 and when width or height of the rectangle is 0.
! Fixed bug in the event handler code. Events has not been passed to the window widget handler.
! Fixed codes for Win keys (Super/Hyper/Menu).
! Fixed memory leak, when deallocation palette.
! Fixed palette emulation code bugs.
! Fixed fullscreen and hwsurface handling.
! Fixed CLOSE button bug. First event was passed to the handler, but second terminated the application. Now all events passed to the application correctly.
- Removed all printfs in code, now SDL_SetError used instead of them.
- Disabled ToggleFullScreen function.
README.QNX - updated README.QNX file. Added much more issues.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 04 Aug 2003 00:52:42 +0000 |
parents | 8e3ce997621c |
children | 04dd6c6d7c30 |
comparison
equal
deleted
inserted
replaced
662:66c02f83f5bf | 663:8bedd6d61642 |
---|---|
33 #include "SDL_error.h" | 33 #include "SDL_error.h" |
34 #include "SDL_endian.h" | 34 #include "SDL_endian.h" |
35 #include "SDL_video.h" | 35 #include "SDL_video.h" |
36 #include "SDL_pixels_c.h" | 36 #include "SDL_pixels_c.h" |
37 #include "SDL_ph_image_c.h" | 37 #include "SDL_ph_image_c.h" |
38 | 38 #include "SDL_ph_modes_c.h" |
39 /* Mask values for SDL_ReallocFormat() */ | |
40 struct ColourMasks | |
41 { | |
42 Uint32 red; | |
43 Uint32 green; | |
44 Uint32 blue; | |
45 Uint32 alpha; | |
46 Uint32 bpp; | |
47 }; | |
48 | |
49 static const struct ColourMasks *ph_GetColourMasks( int format ) | |
50 { | |
51 /* The alpha mask doesn't appear to be needed */ | |
52 static const struct ColourMasks phColorMasks[5] = { | |
53 /* 8 bit */ {0, 0, 0, 0, 8}, | |
54 /* 15 bit ARGB */ {0x7C00, 0x03E0, 0x001F, 0x8000, 16}, | |
55 /* 16 bit RGB */ {0xF800, 0x07E0, 0x001F, 0x0000, 16}, | |
56 /* 24 bit RGB */ {0xFF0000, 0x00FF00, 0x0000FF, 0x000000, 24}, | |
57 /* 32 bit ARGB */ {0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000, 32}, | |
58 }; | |
59 | |
60 switch( format ) | |
61 { | |
62 case Pg_IMAGE_PALETTE_BYTE: | |
63 return &phColorMasks[0]; | |
64 break; | |
65 case Pg_IMAGE_DIRECT_1555: | |
66 case Pg_IMAGE_DIRECT_555: | |
67 return &phColorMasks[1]; | |
68 break; | |
69 case Pg_IMAGE_DIRECT_565: | |
70 return &phColorMasks[2]; | |
71 break; | |
72 case Pg_IMAGE_DIRECT_888: | |
73 return &phColorMasks[3]; | |
74 break; | |
75 case Pg_IMAGE_DIRECT_8888: | |
76 return &phColorMasks[4]; | |
77 break; | |
78 } | |
79 return NULL; | |
80 } | |
81 | 39 |
82 int ph_SetupImage(_THIS, SDL_Surface *screen) | 40 int ph_SetupImage(_THIS, SDL_Surface *screen) |
83 { | 41 { |
84 PgColor_t* palette=NULL; | 42 PgColor_t* palette=NULL; |
85 const struct ColourMasks* mask; | |
86 int type=0; | 43 int type=0; |
87 int bpp; | 44 int bpp; |
88 | 45 |
89 bpp=screen->format->BitsPerPixel; | 46 bpp=screen->format->BitsPerPixel; |
90 | 47 |
110 case 32:{ | 67 case 32:{ |
111 type = Pg_IMAGE_DIRECT_8888; | 68 type = Pg_IMAGE_DIRECT_8888; |
112 } | 69 } |
113 break; | 70 break; |
114 default:{ | 71 default:{ |
115 fprintf(stderr,"ph_SetupImage(): unsupported bpp=%d !\n", bpp); | 72 SDL_SetError("ph_SetupImage(): unsupported bpp=%d !\n", bpp); |
116 return -1; | 73 return -1; |
117 } | 74 } |
118 break; | 75 break; |
119 } | 76 } |
120 | 77 |
121 /* palette emulation code */ | 78 /* palette emulation code */ |
122 if ((bpp==8) && (desktoppal==SDLPH_PAL_EMULATE)) | 79 if ((bpp==8) && (desktoppal==SDLPH_PAL_EMULATE)) |
123 { | 80 { |
124 /* creating image palette */ | 81 /* creating image palette */ |
125 palette=malloc(_Pg_MAX_PALETTE*sizeof(PgColor_t)); | 82 palette=malloc(_Pg_MAX_PALETTE*sizeof(PgColor_t)); |
83 if (palette==NULL) | |
84 { | |
85 SDL_SetError("ph_SetupImage(): can't allocate memory for palette !\n"); | |
86 return -1; | |
87 } | |
126 PgGetPalette(palette); | 88 PgGetPalette(palette); |
127 | 89 |
128 /* using shared memory for speed (set last param to 1) */ | 90 /* using shared memory for speed (set last param to 1) */ |
129 if ((SDL_Image = PhCreateImage(NULL, screen->w, screen->h, type, palette, _Pg_MAX_PALETTE, 1)) == NULL) | 91 if ((SDL_Image = PhCreateImage(NULL, screen->w, screen->h, type, palette, _Pg_MAX_PALETTE, 1)) == NULL) |
130 { | 92 { |
131 fprintf(stderr,"ph_SetupImage(): PhCreateImage failed for bpp=8 !\n"); | 93 SDL_SetError("ph_SetupImage(): PhCreateImage() failed for bpp=8 !\n"); |
94 free(palette); | |
132 return -1; | 95 return -1; |
133 } | 96 } |
134 } | 97 } |
135 else | 98 else |
136 { | 99 { |
137 /* using shared memory for speed (set last param to 1) */ | 100 /* using shared memory for speed (set last param to 1) */ |
138 if ((SDL_Image = PhCreateImage(NULL, screen->w, screen->h, type, NULL, 0, 1)) == NULL) | 101 if ((SDL_Image = PhCreateImage(NULL, screen->w, screen->h, type, NULL, 0, 1)) == NULL) |
139 { | 102 { |
140 fprintf(stderr,"ph_SetupImage: PhCreateImage failed !\n"); | 103 SDL_SetError("ph_SetupImage(): PhCreateImage() failed for bpp=%d !\n", bpp); |
141 return -1; | 104 return -1; |
142 } | 105 } |
143 } | 106 } |
144 | 107 |
145 screen->pixels = SDL_Image->image; | 108 screen->pixels = SDL_Image->image; |
146 screen->pitch = SDL_Image->bpl; /* Recalculated pitch, created by PhCreateImage */ | 109 screen->pitch = SDL_Image->bpl; |
147 | |
148 mask = ph_GetColourMasks(type); | |
149 if (mask != NULL) | |
150 { | |
151 SDL_ReallocFormat(screen, mask->bpp, mask->red, mask->green, mask->blue, 0); | |
152 } | |
153 | 110 |
154 this->UpdateRects = ph_NormalUpdate; | 111 this->UpdateRects = ph_NormalUpdate; |
155 | 112 |
156 return 0; | 113 return 0; |
157 } | 114 } |
158 | 115 |
159 int ph_SetupOCImage(_THIS, SDL_Surface *screen) | 116 int ph_SetupOCImage(_THIS, SDL_Surface *screen) |
160 { | 117 { |
161 const struct ColourMasks *mask; | |
162 int type = 0; | 118 int type = 0; |
163 int bpp; | 119 int bpp; |
164 | 120 |
165 screen->flags &= ~SDL_DOUBLEBUF; | |
166 OCImage.flags = screen->flags; | 121 OCImage.flags = screen->flags; |
167 | 122 |
168 bpp=screen->format->BitsPerPixel; | 123 bpp=screen->format->BitsPerPixel; |
169 | 124 |
170 /* Determine image type */ | 125 /* Determine image type */ |
189 case 32:{ | 144 case 32:{ |
190 type = Pg_IMAGE_DIRECT_8888; | 145 type = Pg_IMAGE_DIRECT_8888; |
191 } | 146 } |
192 break; | 147 break; |
193 default:{ | 148 default:{ |
194 fprintf(stderr,"ph_SetupOCImage(): unsupported bpp=%d !\n", bpp); | 149 SDL_SetError("ph_SetupOCImage(): unsupported bpp=%d !\n", bpp); |
195 return -1; | 150 return -1; |
196 } | 151 } |
197 break; | 152 break; |
198 } | 153 } |
199 | 154 |
201 * display can be created. */ | 156 * display can be created. */ |
202 OCImage.offscreen_context = PdCreateOffscreenContext(0, screen->w, screen->h, Pg_OSC_MEM_PAGE_ALIGN); | 157 OCImage.offscreen_context = PdCreateOffscreenContext(0, screen->w, screen->h, Pg_OSC_MEM_PAGE_ALIGN); |
203 | 158 |
204 if (OCImage.offscreen_context == NULL) | 159 if (OCImage.offscreen_context == NULL) |
205 { | 160 { |
206 fprintf(stderr, "ph_SetupOCImage(): PdCreateOffscreenContext failed !\n"); | 161 SDL_SetError("ph_SetupOCImage(): PdCreateOffscreenContext() function failed !\n"); |
207 return -1; | 162 return -1; |
208 } | 163 } |
209 | 164 |
210 /* If the bit depth of the context is different than was requested, | 165 screen->pitch = OCImage.offscreen_context->pitch; |
211 * these values need to be updated accordingly. SDL will | 166 |
212 * allocate a shadow surface if it needs to. */ | 167 OCImage.dc_ptr = (unsigned char *) PdGetOffscreenContextPtr(OCImage.offscreen_context); |
213 mask = ph_GetColourMasks(OCImage.offscreen_context->format); | 168 |
214 if (mask != NULL) | 169 if (OCImage.dc_ptr == NULL) |
215 { | 170 { |
216 SDL_ReallocFormat(screen, mask->bpp, mask->red, mask->green, mask->blue, 0); | 171 SDL_SetError("ph_SetupOCImage(): PdGetOffscreenContextPtr function failed !\n"); |
217 | 172 PhDCRelease(OCImage.offscreen_context); |
218 if (mask->bpp > 8) | |
219 { | |
220 screen->flags &= ~SDL_HWPALETTE; | |
221 } | |
222 } | |
223 | |
224 screen->pitch = OCImage.offscreen_context->pitch; /* Recalculated pitch */ | |
225 | |
226 OCImage.dc_ptr.ptr8 = (unsigned char *) PdGetOffscreenContextPtr(OCImage.offscreen_context); | |
227 | |
228 if (OCImage.dc_ptr.ptr8 == NULL) | |
229 { | |
230 fprintf(stderr, "ph_SetupOCImage(): PdGetOffscreenContextPtr failed !\n"); | |
231 return -1; | 173 return -1; |
232 } | 174 } |
233 | 175 |
234 OCImage.FrameData0 = OCImage.dc_ptr.ptr8; | 176 OCImage.FrameData0 = OCImage.dc_ptr; |
235 OCImage.CurrentFrameData = OCImage.FrameData0; | 177 OCImage.CurrentFrameData = OCImage.FrameData0; |
236 OCImage.current = 0; | 178 OCImage.current = 0; |
237 | 179 |
238 PhDCSetCurrent(OCImage.offscreen_context); | 180 PhDCSetCurrent(OCImage.offscreen_context); |
239 | 181 |
251 return 0; | 193 return 0; |
252 } | 194 } |
253 | 195 |
254 int ph_SetupFullScreenImage(_THIS, SDL_Surface* screen) | 196 int ph_SetupFullScreenImage(_THIS, SDL_Surface* screen) |
255 { | 197 { |
256 const struct ColourMasks *mask; | |
257 screen->flags &= ~SDL_DOUBLEBUF; | |
258 OCImage.flags = screen->flags; | 198 OCImage.flags = screen->flags; |
259 | 199 |
200 /* Begin direct mode */ | |
201 if (!ph_EnterFullScreen(this, screen)) | |
202 { | |
203 return -1; | |
204 } | |
205 | |
206 /* store palette for fullscreen */ | |
207 if ((screen->format->BitsPerPixel==8) && (desktopbpp!=8)) | |
208 { | |
209 PgGetPalette(savedpal); | |
210 PgGetPalette(syspalph); | |
211 } | |
212 | |
260 OCImage.offscreen_context = PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY); | 213 OCImage.offscreen_context = PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY); |
261 | |
262 if (OCImage.offscreen_context == NULL) | 214 if (OCImage.offscreen_context == NULL) |
263 { | 215 { |
264 fprintf(stderr, "ph_SetupFullScreenImage(): PdCreateOffscreenContext failed !\n"); | 216 SDL_SetError("ph_SetupFullScreenImage(): PdCreateOffscreenContext() function failed !\n"); |
265 return -1; | 217 return -1; |
266 } | 218 } |
267 | 219 |
268 /* If the bit depth of the context is different than was requested, | 220 if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) |
269 * these values need to be updated accordingly. SDL will | 221 { |
270 * allocate a shadow surface if it needs to. */ | 222 OCImage.offscreen_backcontext = PdDupOffscreenContext(OCImage.offscreen_context, Pg_OSC_CRTC_SAFE); |
271 mask = ph_GetColourMasks(OCImage.offscreen_context->format); | 223 if (OCImage.offscreen_backcontext == NULL) |
272 if (mask != NULL) | 224 { |
273 { | 225 SDL_SetError("ph_SetupFullScreenImage(): PdCreateOffscreenContext(back) function failed !\n"); |
274 SDL_ReallocFormat(screen, mask->bpp, mask->red, mask->green, mask->blue, 0); | 226 return -1; |
275 | 227 } |
276 if (mask->bpp > 8) | 228 } |
277 { | 229 |
278 screen->flags &= ~SDL_HWPALETTE; | 230 OCImage.FrameData0 = (unsigned char *)PdGetOffscreenContextPtr(OCImage.offscreen_context); |
279 } | 231 if (OCImage.FrameData0 == NULL) |
280 } | 232 { |
281 | 233 SDL_SetError("ph_SetupFullScreenImage(): PdGetOffscreenContextPtr() function failed !\n"); |
282 screen->pitch = OCImage.offscreen_context->pitch; /* Recalculated pitch */ | 234 ph_DestroyImage(this, screen); |
283 | |
284 OCImage.dc_ptr.ptr8 = (unsigned char *)PdGetOffscreenContextPtr(OCImage.offscreen_context); | |
285 | |
286 if (OCImage.dc_ptr.ptr8 == NULL) | |
287 { | |
288 fprintf(stderr, "ph_SetupOCImage(): PdGetOffscreenContextPtr failed !\n"); | |
289 return -1; | 235 return -1; |
290 } | 236 } |
291 | 237 |
292 /* wait for hw */ | 238 if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) |
239 { | |
240 OCImage.FrameData1 = (unsigned char *)PdGetOffscreenContextPtr(OCImage.offscreen_backcontext); | |
241 if (OCImage.FrameData1 == NULL) | |
242 { | |
243 SDL_SetError("ph_SetupFullScreenImage(back): PdGetOffscreenContextPtr() function failed !\n"); | |
244 ph_DestroyImage(this, screen); | |
245 return -1; | |
246 } | |
247 } | |
248 | |
249 /* wait for the hardware */ | |
293 PgWaitHWIdle(); | 250 PgWaitHWIdle(); |
294 | 251 |
295 OCImage.FrameData0 = OCImage.dc_ptr.ptr8; | 252 if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) |
296 OCImage.CurrentFrameData = OCImage.FrameData0; | 253 { |
297 OCImage.current = 0; | 254 OCImage.current = 1; |
298 | 255 PhDCSetCurrent(OCImage.offscreen_backcontext); |
299 PhDCSetCurrent(OCImage.offscreen_context); | 256 screen->pitch = OCImage.offscreen_backcontext->pitch; |
300 | 257 screen->pixels = OCImage.FrameData1; |
301 screen->pixels = OCImage.CurrentFrameData; | 258 PgSwapDisplay(OCImage.offscreen_context, 0); |
302 | 259 } |
303 this->UpdateRects = ph_OCUpdate; | 260 else |
261 { | |
262 OCImage.current = 0; | |
263 PhDCSetCurrent(OCImage.offscreen_context); | |
264 screen->pitch = OCImage.offscreen_context->pitch; | |
265 screen->pixels = OCImage.FrameData0; | |
266 } | |
267 | |
268 this->UpdateRects = ph_OCDCUpdate; | |
304 | 269 |
305 return 0; | 270 return 0; |
306 } | 271 } |
307 | 272 |
308 void ph_DestroyImage(_THIS, SDL_Surface *screen) | 273 void ph_DestroyImage(_THIS, SDL_Surface *screen) |
309 { | 274 { |
275 if (currently_fullscreen) | |
276 { | |
277 /* if we right now in 8bpp fullscreen we must release palette */ | |
278 if ((screen->format->BitsPerPixel==8) && (desktopbpp!=8)) | |
279 { | |
280 PgSetPalette(syspalph, 0, -1, 0, 0, 0); | |
281 PgSetPalette(savedpal, 0, 0, _Pg_MAX_PALETTE, Pg_PALSET_GLOBAL | Pg_PALSET_FORCE_EXPOSE, 0); | |
282 PgFlush(); | |
283 } | |
284 ph_LeaveFullScreen(this); | |
285 } | |
286 | |
310 if (OCImage.offscreen_context != NULL) | 287 if (OCImage.offscreen_context != NULL) |
311 { | 288 { |
312 PhDCRelease(OCImage.offscreen_context); | 289 PhDCRelease(OCImage.offscreen_context); |
313 OCImage.offscreen_context = NULL; | 290 OCImage.offscreen_context = NULL; |
314 OCImage.FrameData0 = NULL; | 291 OCImage.FrameData0 = NULL; |
292 } | |
293 if (OCImage.offscreen_backcontext != NULL) | |
294 { | |
295 PhDCRelease(OCImage.offscreen_backcontext); | |
296 OCImage.offscreen_backcontext = NULL; | |
315 OCImage.FrameData1 = NULL; | 297 OCImage.FrameData1 = NULL; |
316 } | 298 } |
299 OCImage.CurrentFrameData = NULL; | |
317 | 300 |
318 if (SDL_Image) | 301 if (SDL_Image) |
319 { | 302 { |
320 /* if palette allocated, free it */ | 303 /* if palette allocated, free it */ |
321 if (SDL_Image->palette) | 304 if (SDL_Image->palette) |
352 return ph_SetupOpenGLImage(this, screen); | 335 return ph_SetupOpenGLImage(this, screen); |
353 } | 336 } |
354 | 337 |
355 return ph_SetupImage(this, screen); | 338 return ph_SetupImage(this, screen); |
356 } | 339 } |
340 | |
357 int ph_AllocHWSurface(_THIS, SDL_Surface *surface) | 341 int ph_AllocHWSurface(_THIS, SDL_Surface *surface) |
358 { | 342 { |
359 return(-1); | 343 return(-1); |
360 } | 344 } |
361 | 345 |
362 void ph_FreeHWSurface(_THIS, SDL_Surface *surface) | 346 void ph_FreeHWSurface(_THIS, SDL_Surface *surface) |
363 { | 347 { |
364 return; | 348 return; |
365 } | 349 } |
366 | 350 |
367 int ph_FlipHWSurface(_THIS, SDL_Surface *surface) | 351 int ph_FlipHWSurface(_THIS, SDL_Surface *screen) |
368 { | 352 { |
369 return(0); | 353 PhArea_t area; |
354 | |
355 area.pos.x=0; | |
356 area.pos.y=0; | |
357 area.size.w=screen->w; | |
358 area.size.h=screen->h; | |
359 | |
360 if ((screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) | |
361 { | |
362 if (OCImage.current==0) | |
363 { | |
364 PgSwapDisplay(OCImage.offscreen_context, 0); | |
365 OCImage.current=1; | |
366 screen->pitch = OCImage.offscreen_backcontext->pitch; | |
367 screen->pixels = OCImage.FrameData1; | |
368 // memcpy(OCImage.FrameData1, OCImage.FrameData0, OCImage.offscreen_context->shared_size); | |
369 PgContextBlitArea(OCImage.offscreen_context, &area, OCImage.offscreen_backcontext, &area); | |
370 PhDCSetCurrent(OCImage.offscreen_backcontext); | |
371 PgFlush(); | |
372 } | |
373 else | |
374 { | |
375 PgSwapDisplay(OCImage.offscreen_backcontext, 0); | |
376 OCImage.current=0; | |
377 screen->pitch = OCImage.offscreen_context->pitch; | |
378 screen->pixels = OCImage.FrameData0; | |
379 // memcpy(OCImage.FrameData0, OCImage.FrameData1, OCImage.offscreen_context->shared_size); | |
380 PgContextBlitArea(OCImage.offscreen_backcontext, &area, OCImage.offscreen_context, &area); | |
381 PhDCSetCurrent(OCImage.offscreen_context); | |
382 PgFlush(); | |
383 } | |
384 } | |
385 return 0; | |
370 } | 386 } |
371 | 387 |
372 int ph_LockHWSurface(_THIS, SDL_Surface *surface) | 388 int ph_LockHWSurface(_THIS, SDL_Surface *surface) |
373 { | 389 { |
374 return(0); | 390 return(0); |
393 int i; | 409 int i; |
394 | 410 |
395 for (i=0; i<numrects; ++i) | 411 for (i=0; i<numrects; ++i) |
396 { | 412 { |
397 if (rects[i].w==0) /* Clipped? */ | 413 if (rects[i].w==0) /* Clipped? */ |
414 { | |
415 continue; | |
416 } | |
417 | |
418 if (rects[i].h==0) /* Clipped? */ | |
398 { | 419 { |
399 continue; | 420 continue; |
400 } | 421 } |
401 | 422 |
402 ph_pos.x = rects[i].x; | 423 ph_pos.x = rects[i].x; |
406 ph_rect.lr.x = rects[i].x + rects[i].w; | 427 ph_rect.lr.x = rects[i].x + rects[i].w; |
407 ph_rect.lr.y = rects[i].y + rects[i].h; | 428 ph_rect.lr.y = rects[i].y + rects[i].h; |
408 | 429 |
409 if (PgDrawPhImageRectmx(&ph_pos, SDL_Image, &ph_rect, 0) < 0) | 430 if (PgDrawPhImageRectmx(&ph_pos, SDL_Image, &ph_rect, 0) < 0) |
410 { | 431 { |
411 fprintf(stderr,"ph_NormalUpdate(): PgDrawPhImageRectmx failed !\n"); | 432 SDL_SetError("ph_NormalUpdate(): PgDrawPhImageRectmx failed !\n"); |
412 } | 433 } |
413 } | 434 } |
414 | 435 |
415 if (PgFlush() < 0) | 436 if (PgFlush() < 0) |
416 { | 437 { |
417 fprintf(stderr,"ph_NormalUpdate(): PgFlush failed.\n"); | 438 SDL_SetError("ph_NormalUpdate(): PgFlush failed.\n"); |
418 } | 439 } |
419 } | 440 } |
420 | 441 |
421 void ph_OCUpdate(_THIS, int numrects, SDL_Rect *rects) | 442 void ph_OCUpdate(_THIS, int numrects, SDL_Rect *rects) |
422 { | 443 { |
431 PgWaitHWIdle(); | 452 PgWaitHWIdle(); |
432 | 453 |
433 for (i=0; i<numrects; ++i) | 454 for (i=0; i<numrects; ++i) |
434 { | 455 { |
435 if (rects[i].w == 0) /* Clipped? */ | 456 if (rects[i].w == 0) /* Clipped? */ |
457 { | |
458 continue; | |
459 } | |
460 | |
461 if (rects[i].h == 0) /* Clipped? */ | |
436 { | 462 { |
437 continue; | 463 continue; |
438 } | 464 } |
439 | 465 |
440 src_rect.pos.x=rects[i].x; | 466 src_rect.pos.x=rects[i].x; |
455 PgContextBlitArea(OCImage.offscreen_context, &src_rect, NULL, &dest_rect); | 481 PgContextBlitArea(OCImage.offscreen_context, &src_rect, NULL, &dest_rect); |
456 } | 482 } |
457 | 483 |
458 if (PgFlush() < 0) | 484 if (PgFlush() < 0) |
459 { | 485 { |
460 fprintf(stderr,"ph_OCUpdate(): PgFlush failed.\n"); | 486 SDL_SetError("ph_OCUpdate(): PgFlush failed.\n"); |
461 } | 487 } |
462 | 488 } |
463 /* later used to toggling double buffer */ | 489 |
464 if (OCImage.current == 0) | 490 void ph_OCDCUpdate(_THIS, int numrects, SDL_Rect *rects) |
465 { | 491 { |
466 OCImage.CurrentFrameData = OCImage.FrameData0; | 492 PgWaitHWIdle(); |
467 } | 493 |
468 else | 494 if (PgFlush() < 0) |
469 { | 495 { |
470 OCImage.CurrentFrameData = OCImage.FrameData1; | 496 SDL_SetError("ph_OCDCUpdate(): PgFlush failed.\n"); |
471 } | 497 } |
472 } | 498 } |