Mesa (master): mesa: added _mesa_pack_ubyte_rgba_rect()

Brian Paul brianp at kemper.freedesktop.org
Mon Jan 30 12:04:20 PST 2012


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

Author: Brian Paul <brianp at vmware.com>
Date:   Sun Jan 29 19:47:37 2012 -0700

mesa: added _mesa_pack_ubyte_rgba_rect()

Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/mesa/main/format_pack.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 src/mesa/main/format_pack.h |    4 ++++
 2 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/format_pack.c b/src/mesa/main/format_pack.c
index 85b2c69..ea1d95e 100644
--- a/src/mesa/main/format_pack.c
+++ b/src/mesa/main/format_pack.c
@@ -2050,6 +2050,48 @@ _mesa_pack_ubyte_rgba_row(gl_format format, GLuint n,
 
 
 /**
+ * Pack a 2D image of ubyte RGBA pixels in the given format.
+ * \param srcRowStride  source image row stride in bytes
+ * \param dstRowStride  destination image row stride in bytes
+ */
+void
+_mesa_pack_ubyte_rgba_rect(gl_format format, GLuint width, GLuint height,
+                           const GLubyte *src, GLint srcRowStride,
+                           void *dst, GLint dstRowStride)
+{
+   pack_ubyte_rgba_row_func packrow = get_pack_ubyte_rgba_row_function(format);
+   GLubyte *dstUB = (GLubyte *) dst;
+   GLuint i;
+
+   if (packrow) {
+      if (srcRowStride == width * 4 * sizeof(GLubyte) &&
+          dstRowStride == _mesa_format_row_stride(format, width)) {
+         /* do whole image at once */
+         packrow(width * height, (const GLubyte (*)[4]) src, dst);
+      }
+      else {
+         /* row by row */
+         for (i = 0; i < height; i++) {
+            packrow(width, (const GLubyte (*)[4]) src, dstUB);
+            src += srcRowStride;
+            dstUB += dstRowStride;
+         }
+      }
+   }
+   else {
+      /* slower fallback */
+      for (i = 0; i < height; i++) {
+         _mesa_pack_ubyte_rgba_row(format, width,
+                                   (const GLubyte (*)[4]) src, dstUB);
+         src += srcRowStride;
+         dstUB += dstRowStride;
+      }
+   }
+}
+
+
+
+/**
  ** Pack float Z pixels
  **/
 
diff --git a/src/mesa/main/format_pack.h b/src/mesa/main/format_pack.h
index f1b4805..20b2ad8 100644
--- a/src/mesa/main/format_pack.h
+++ b/src/mesa/main/format_pack.h
@@ -77,6 +77,10 @@ _mesa_pack_ubyte_rgba_row(gl_format format, GLuint n,
                           const GLubyte src[][4], void *dst);
 
 
+extern void
+_mesa_pack_ubyte_rgba_rect(gl_format format, GLuint width, GLuint height,
+                           const GLubyte *src, GLint srcRowStride,
+                           void *dst, GLint dstRowStride);
 
 extern void
 _mesa_pack_float_z_row(gl_format format, GLuint n,



More information about the mesa-commit mailing list