summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/readpix.c
diff options
context:
space:
mode:
authorBartosz Tomczyk <[email protected]>2017-04-10 12:31:00 -0600
committerBrian Paul <[email protected]>2017-04-10 14:42:17 -0600
commita4019a81ab5857bb19dc6251bab6bf386947f6fc (patch)
treed224ee4be47995d643506560bcfc1235f5bdf7cf /src/mesa/main/readpix.c
parentda2ac1951110674f58245c0738f05610e80bc2cd (diff)
mesa: use single memcpy when strides match in glReadPixels, texstore code
v2: fix indentation Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/main/readpix.c')
-rw-r--r--src/mesa/main/readpix.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index 25823230d62..606d1e58e5a 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -220,7 +220,7 @@ readpixels_memcpy(struct gl_context *ctx,
struct gl_renderbuffer *rb =
_mesa_get_read_renderbuffer_for_format(ctx, format);
GLubyte *dst, *map;
- int dstStride, stride, j, texelBytes;
+ int dstStride, stride, j, texelBytes, bytesPerRow;
/* Fail if memcpy cannot be used. */
if (!readpixels_can_use_memcpy(ctx, format, type, packing)) {
@@ -239,12 +239,17 @@ readpixels_memcpy(struct gl_context *ctx,
}
texelBytes = _mesa_get_format_bytes(rb->Format);
+ bytesPerRow = texelBytes * width;
/* memcpy*/
- for (j = 0; j < height; j++) {
- memcpy(dst, map, width * texelBytes);
- dst += dstStride;
- map += stride;
+ if (dstStride == stride && dstStride == bytesPerRow) {
+ memcpy(dst, map, bytesPerRow * height);
+ } else {
+ for (j = 0; j < height; j++) {
+ memcpy(dst, map, bytesPerRow);
+ dst += dstStride;
+ map += stride;
+ }
}
ctx->Driver.UnmapRenderbuffer(ctx, rb);