Commit 153a88e1 authored by Mike Gorchak's avatar Mike Gorchak

RenderReadPixels and RenderWritePixels functions work with back buffer now and...

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.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404210
parent 335b4597
...@@ -1594,17 +1594,32 @@ photon_renderreadpixels(SDL_Renderer * renderer, const SDL_Rect * rect, ...@@ -1594,17 +1594,32 @@ photon_renderreadpixels(SDL_Renderer * renderer, const SDL_Rect * rect,
uint8_t* spixels=NULL; uint8_t* spixels=NULL;
unsigned int spitch=0; unsigned int spitch=0;
/* Flush all undrawn graphics data to surface */
switch (rdata->surfaces_type) switch (rdata->surfaces_type)
{ {
case SDL_PHOTON_SURFTYPE_OFFSCREEN: case SDL_PHOTON_SURFTYPE_OFFSCREEN:
sformat=photon_image_to_sdl_pixelformat(rdata->osurfaces[rdata->surface_visible_idx]->format); PgFlushCx(rdata->osurfaces[rdata->surface_render_idx]);
spixels=(uint8_t*)PdGetOffscreenContextPtr(rdata->osurfaces[rdata->surface_visible_idx]); PgWaitHWIdle();
spitch=rdata->osurfaces[rdata->surface_visible_idx]->pitch;
break; break;
case SDL_PHOTON_SURFTYPE_PHIMAGE: case SDL_PHOTON_SURFTYPE_PHIMAGE:
sformat=photon_image_to_sdl_pixelformat(rdata->psurfaces[rdata->surface_visible_idx]->type); PmMemFlush(rdata->pcontexts[rdata->surface_render_idx], rdata->psurfaces[rdata->surface_render_idx]);
spixels=(uint8_t*)rdata->psurfaces[rdata->surface_visible_idx]->image; break;
spitch=rdata->psurfaces[rdata->surface_visible_idx]->bpl; 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; break;
case SDL_PHOTON_SURFTYPE_UNKNOWN: case SDL_PHOTON_SURFTYPE_UNKNOWN:
default: default:
...@@ -1631,17 +1646,32 @@ photon_renderwritepixels(SDL_Renderer * renderer, const SDL_Rect * rect, ...@@ -1631,17 +1646,32 @@ photon_renderwritepixels(SDL_Renderer * renderer, const SDL_Rect * rect,
uint8_t* spixels=NULL; uint8_t* spixels=NULL;
unsigned int spitch=0; unsigned int spitch=0;
/* Flush all undrawn graphics data to surface */
switch (rdata->surfaces_type)
{
case SDL_PHOTON_SURFTYPE_OFFSCREEN:
PgFlushCx(rdata->osurfaces[rdata->surface_render_idx]);
PgWaitHWIdle();
break;
case SDL_PHOTON_SURFTYPE_PHIMAGE:
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) switch (rdata->surfaces_type)
{ {
case SDL_PHOTON_SURFTYPE_OFFSCREEN: case SDL_PHOTON_SURFTYPE_OFFSCREEN:
sformat=photon_image_to_sdl_pixelformat(rdata->osurfaces[rdata->surface_visible_idx]->format); sformat=photon_image_to_sdl_pixelformat(rdata->osurfaces[rdata->surface_render_idx]->format);
spixels=(uint8_t*)PdGetOffscreenContextPtr(rdata->osurfaces[rdata->surface_visible_idx]); spixels=(uint8_t*)PdGetOffscreenContextPtr(rdata->osurfaces[rdata->surface_render_idx]);
spitch=rdata->osurfaces[rdata->surface_visible_idx]->pitch; spitch=rdata->osurfaces[rdata->surface_render_idx]->pitch;
break; break;
case SDL_PHOTON_SURFTYPE_PHIMAGE: case SDL_PHOTON_SURFTYPE_PHIMAGE:
sformat=photon_image_to_sdl_pixelformat(rdata->psurfaces[rdata->surface_visible_idx]->type); sformat=photon_image_to_sdl_pixelformat(rdata->psurfaces[rdata->surface_render_idx]->type);
spixels=(uint8_t*)rdata->psurfaces[rdata->surface_visible_idx]->image; spixels=(uint8_t*)rdata->psurfaces[rdata->surface_render_idx]->image;
spitch=rdata->psurfaces[rdata->surface_visible_idx]->bpl; spitch=rdata->psurfaces[rdata->surface_render_idx]->bpl;
break; break;
case SDL_PHOTON_SURFTYPE_UNKNOWN: case SDL_PHOTON_SURFTYPE_UNKNOWN:
default: default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment