diff src/video/photon/SDL_photon_render.c @ 3469:8c5fb2a3b11d

RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
author Mike Gorchak <lestat@i.com.ua>
date Sat, 21 Nov 2009 06:17:50 +0000
parents 6265b67848e0
children 4b594623401b
line wrap: on
line diff
--- a/src/video/photon/SDL_photon_render.c	Sat Nov 21 05:29:31 2009 +0000
+++ b/src/video/photon/SDL_photon_render.c	Sat Nov 21 06:17:50 2009 +0000
@@ -1594,17 +1594,32 @@
     uint8_t* spixels=NULL;
     unsigned int spitch=0;
 
+    /* Flush all undrawn graphics data to surface */
     switch (rdata->surfaces_type)
     {
         case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-             sformat=photon_image_to_sdl_pixelformat(rdata->osurfaces[rdata->surface_visible_idx]->format);
-             spixels=(uint8_t*)PdGetOffscreenContextPtr(rdata->osurfaces[rdata->surface_visible_idx]);
-             spitch=rdata->osurfaces[rdata->surface_visible_idx]->pitch;
+             PgFlushCx(rdata->osurfaces[rdata->surface_render_idx]);
+             PgWaitHWIdle();
              break;
         case SDL_PHOTON_SURFTYPE_PHIMAGE:
-             sformat=photon_image_to_sdl_pixelformat(rdata->psurfaces[rdata->surface_visible_idx]->type);
-             spixels=(uint8_t*)rdata->psurfaces[rdata->surface_visible_idx]->image;
-             spitch=rdata->psurfaces[rdata->surface_visible_idx]->bpl;
+             PmMemFlush(rdata->pcontexts[rdata->surface_render_idx], rdata->psurfaces[rdata->surface_render_idx]);
+             break;
+        case SDL_PHOTON_SURFTYPE_UNKNOWN:
+        default:
+             return;
+    }
+
+    switch (rdata->surfaces_type)
+    {
+        case SDL_PHOTON_SURFTYPE_OFFSCREEN:
+             sformat=photon_image_to_sdl_pixelformat(rdata->osurfaces[rdata->surface_render_idx]->format);
+             spixels=(uint8_t*)PdGetOffscreenContextPtr(rdata->osurfaces[rdata->surface_render_idx]);
+             spitch=rdata->osurfaces[rdata->surface_render_idx]->pitch;
+             break;
+        case SDL_PHOTON_SURFTYPE_PHIMAGE:
+             sformat=photon_image_to_sdl_pixelformat(rdata->psurfaces[rdata->surface_render_idx]->type);
+             spixels=(uint8_t*)rdata->psurfaces[rdata->surface_render_idx]->image;
+             spitch=rdata->psurfaces[rdata->surface_render_idx]->bpl;
              break;
         case SDL_PHOTON_SURFTYPE_UNKNOWN:
         default:
@@ -1631,17 +1646,32 @@
     uint8_t* spixels=NULL;
     unsigned int spitch=0;
 
+    /* Flush all undrawn graphics data to surface */
     switch (rdata->surfaces_type)
     {
         case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-             sformat=photon_image_to_sdl_pixelformat(rdata->osurfaces[rdata->surface_visible_idx]->format);
-             spixels=(uint8_t*)PdGetOffscreenContextPtr(rdata->osurfaces[rdata->surface_visible_idx]);
-             spitch=rdata->osurfaces[rdata->surface_visible_idx]->pitch;
+             PgFlushCx(rdata->osurfaces[rdata->surface_render_idx]);
+             PgWaitHWIdle();
              break;
         case SDL_PHOTON_SURFTYPE_PHIMAGE:
-             sformat=photon_image_to_sdl_pixelformat(rdata->psurfaces[rdata->surface_visible_idx]->type);
-             spixels=(uint8_t*)rdata->psurfaces[rdata->surface_visible_idx]->image;
-             spitch=rdata->psurfaces[rdata->surface_visible_idx]->bpl;
+             PmMemFlush(rdata->pcontexts[rdata->surface_render_idx], rdata->psurfaces[rdata->surface_render_idx]);
+             break;
+        case SDL_PHOTON_SURFTYPE_UNKNOWN:
+        default:
+             return;
+    }
+
+    switch (rdata->surfaces_type)
+    {
+        case SDL_PHOTON_SURFTYPE_OFFSCREEN:
+             sformat=photon_image_to_sdl_pixelformat(rdata->osurfaces[rdata->surface_render_idx]->format);
+             spixels=(uint8_t*)PdGetOffscreenContextPtr(rdata->osurfaces[rdata->surface_render_idx]);
+             spitch=rdata->osurfaces[rdata->surface_render_idx]->pitch;
+             break;
+        case SDL_PHOTON_SURFTYPE_PHIMAGE:
+             sformat=photon_image_to_sdl_pixelformat(rdata->psurfaces[rdata->surface_render_idx]->type);
+             spixels=(uint8_t*)rdata->psurfaces[rdata->surface_render_idx]->image;
+             spitch=rdata->psurfaces[rdata->surface_render_idx]->bpl;
              break;
         case SDL_PHOTON_SURFTYPE_UNKNOWN:
         default: