Module: Mesa
Branch: master
Commit: 2b079485f6092051ebb7fec0e6210d6743926064
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2b079485f6092051ebb7fec0e6210d6743926064

Author: Thomas Hellstrom <thellst...@vmware.com>
Date:   Thu Feb 24 13:03:07 2011 +0100

st/egl: Add a helper to perform a copy swap on a resource surface

The copy swap can be used when we need to preserve the contents of
the back buffer or when there is no way to do native page-flipping.

Signed-off-by: Thomas Hellstrom <thellst...@vmware.com>

---

 .../state_trackers/egl/common/native_helper.c      |   41 ++++++++++++++++++++
 .../state_trackers/egl/common/native_helper.h      |    4 ++
 2 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/src/gallium/state_trackers/egl/common/native_helper.c 
b/src/gallium/state_trackers/egl/common/native_helper.c
index a9d8f32..0f00c4d 100644
--- a/src/gallium/state_trackers/egl/common/native_helper.c
+++ b/src/gallium/state_trackers/egl/common/native_helper.c
@@ -225,3 +225,44 @@ resource_surface_present(struct resource_surface *rsurf,
 
    return TRUE;
 }
+
+/**
+ * Schedule a copy swap from the back to the front buffer using the
+ * native display's copy context.
+ */
+boolean
+resource_surface_copy_swap(struct resource_surface *rsurf,
+                          struct native_display *ndpy)
+{
+   struct pipe_resource *ftex;
+   struct pipe_resource *btex;
+   struct pipe_context *pipe;
+   struct pipe_box src_box;
+   boolean ret = FALSE;
+
+   pipe = ndpy_get_copy_context(ndpy);
+   if (!pipe)
+      return FALSE;
+
+   ftex = resource_surface_get_single_resource(rsurf,
+                                              NATIVE_ATTACHMENT_FRONT_LEFT);
+   if (!ftex)
+      goto out_no_ftex;
+   btex = resource_surface_get_single_resource(rsurf,
+                                              NATIVE_ATTACHMENT_BACK_LEFT);
+   if (!btex)
+      goto out_no_btex;
+
+   u_box_origin_2d(ftex->width0, ftex->height0, &src_box);
+   pipe->resource_copy_region(pipe, ftex, 0, 0, 0, 0,
+                             btex, 0, &src_box);
+   pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
+   ret = TRUE;
+
+ out_no_ftex:
+   pipe_resource_reference(&btex, NULL);
+ out_no_btex:
+   pipe_resource_reference(&ftex, NULL);
+
+   return ret;
+}
diff --git a/src/gallium/state_trackers/egl/common/native_helper.h 
b/src/gallium/state_trackers/egl/common/native_helper.h
index 03995de..ad68273 100644
--- a/src/gallium/state_trackers/egl/common/native_helper.h
+++ b/src/gallium/state_trackers/egl/common/native_helper.h
@@ -74,3 +74,7 @@ boolean
 resource_surface_present(struct resource_surface *rsurf,
                          enum native_attachment which,
                          void *winsys_drawable_handle);
+
+boolean
+resource_surface_copy_swap(struct resource_surface *rsurf,
+                          struct native_display *ndpy);

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to