summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_drawpix.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
index 5393d50ea02..f05528d0d27 100644
--- a/src/mesa/swrast/s_drawpix.c
+++ b/src/mesa/swrast/s_drawpix.c
@@ -481,17 +481,17 @@ draw_rgba_pixels( struct gl_context *ctx, GLint x, GLint y,
*/
GLint swapSize = _mesa_sizeof_packed_type(type);
if (swapSize == 2 || swapSize == 4) {
- int components = _mesa_components_in_format(format);
- int elementCount = width * height * components;
- tempImage = malloc(elementCount * swapSize);
+ int imageStride = _mesa_image_image_stride(unpack, width, height, format, type);
+
+ tempImage = malloc(imageStride);
if (!tempImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels");
return;
}
- if (swapSize == 2)
- _mesa_swap2_copy(tempImage, (GLushort *) pixels, elementCount);
- else
- _mesa_swap4_copy(tempImage, (GLuint *) pixels, elementCount);
+
+ _mesa_swap_bytes_2d_image(format, type, unpack,
+ width, height, tempImage, pixels);
+
pixels = tempImage;
}
}