<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 9, 2014 at 4:07 AM, Iago Toral Quiroga <span dir="ltr"><<a href="mailto:itoral@igalia.com" target="_blank">itoral@igalia.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This is the only place that uses _mesa_unpack_color_span_float so after<br>
this we should be able to remove that function.<br>
---<br>
 src/mesa/swrast/s_drawpix.c | 39 +++++++++++++++++++++++++++++++++++----<br>
 1 file changed, 35 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c<br>
index 227faa2..dcf5581 100644<br>
--- a/src/mesa/swrast/s_drawpix.c<br>
+++ b/src/mesa/swrast/s_drawpix.c<br>
@@ -29,6 +29,8 @@<br>
 #include "main/condrender.h"<br>
 #include "main/context.h"<br>
 #include "main/format_pack.h"<br>
+#include "main/format_utils.h"<br>
+#include "main/glformats.h"<br>
 #include "main/image.h"<br>
 #include "main/imports.h"<br>
 #include "main/macros.h"<br>
@@ -451,6 +453,28 @@ draw_rgba_pixels( struct gl_context *ctx, GLint x, GLint y,<br>
       GLint skipPixels = 0;<br>
       /* use span array for temp color storage */<br>
       GLfloat *rgba = (GLfloat *) span.array->attribs[VARYING_SLOT_COL0];<br>
+      void *tempImage = NULL;<br>
+<br>
+      if (unpack->SwapBytes) {<br>
+         /* We have to handle byte-swapping scenarios before calling<br>
+          * _mesa_format_convert<br>
+          */<br>
+         GLint swapSize = _mesa_sizeof_packed_type(type);<br>
+         if (swapSize == 2 || swapSize == 4) {<br>
+            int components = _mesa_components_in_format(format);<br>
+            int elementCount = width * height * components;<br>
+            tempImage = malloc(elementCount * swapSize);<br>
+            if (!tempImage) {<br>
+               _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels");<br>
+               return;<br>
+            }<br>
+            if (swapSize == 2)<br>
+               _mesa_swap2_copy(tempImage, (GLushort *) pixels, elementCount);<br>
+            else<br>
+               _mesa_swap4_copy(tempImage, (GLuint *) pixels, elementCount);<br>
+            pixels = tempImage;<br>
+         }<br>
+      }<br>
<br>
       /* if the span is wider than SWRAST_MAX_WIDTH we have to do it in chunks */<br>
       while (skipPixels < width) {<br>
@@ -461,11 +485,15 @@ draw_rgba_pixels( struct gl_context *ctx, GLint x, GLint y,<br>
                                                       type, 0, skipPixels);<br>
          GLint row;<br>
<br>
+         /* get image row as float/RGBA */<br>
+         uint32_t srcMesaFormat = _mesa_format_from_format_and_type(format, type);<br>
          for (row = 0; row < height; row++) {<br>
-            /* get image row as float/RGBA */<br>
-            _mesa_unpack_color_span_float(ctx, spanWidth, GL_RGBA, rgba,<br>
-                                     format, type, source, unpack,<br>
-                                     transferOps);<br>
+            int dstRowStride = 4 * width * sizeof(float);<br>
+            _mesa_format_convert(rgba, RGBA8888_FLOAT, dstRowStride,<br>
+                                 (void*)source, srcMesaFormat, srcStride,<br>
+                                 spanWidth, 1, NULL);<br>
+            if (transferOps)<br>
+               _mesa_apply_rgba_transfer_ops(ctx, transferOps, spanWidth, (GLfloat (*)[4])rgba);<br>
            /* Set these for each row since the _swrast_write_* functions<br>
             * may change them while clipping/rendering.<br>
             */<br>
@@ -490,6 +518,9 @@ draw_rgba_pixels( struct gl_context *ctx, GLint x, GLint y,<br>
<br>
       /* XXX this is ugly/temporary, to undo above change */<br>
       span.array->ChanType = CHAN_TYPE;<br>
+<br>
+      if (tempImage)<br>
+         free(tempImage);<br></blockquote><div><br></div><div>You don't need the if.  Otherwise, It looks fine.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    }<br>
<br>
    swrast_render_finish(ctx);<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.9.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div></div></div>