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.
authorMike Gorchak <lestat@i.com.ua>
Sat, 21 Nov 2009 06:17:50 +0000
changeset 3469 8c5fb2a3b11d
parent 3468 789b97008d8a
child 3470 419f459f2f38
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.
src/video/photon/SDL_photon_render.c
--- 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: