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)) {
}
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);
if (dstMap) {
/* copy rows of blocks */
- for (i = 0; i < store.CopyRowsPerSlice; i++) {
- memcpy(dstMap, src, store.CopyBytesPerRow);
- dstMap += dstRowStride;
- src += store.TotalBytesPerRow;
+ if (dstRowStride == store.TotalBytesPerRow &&
+ dstRowStride == store.CopyBytesPerRow) {
+ memcpy(dstMap, src, store.CopyBytesPerRow * store.CopyRowsPerSlice);
+ src += store.CopyBytesPerRow * store.CopyRowsPerSlice;
+ }
+ else {
+ for (i = 0; i < store.CopyRowsPerSlice; i++) {
+ memcpy(dstMap, src, store.CopyBytesPerRow);
+ dstMap += dstRowStride;
+ src += store.TotalBytesPerRow;
+ }
}
ctx->Driver.UnmapTextureImage(ctx, texImage, slice + zoffset);