Mesa (master): st/mesa: add support for GL_RGBA + GL_UNSIGNED_INT_8_8_8_8 in st_fast_readpixels
Brian Paul
brianp at kemper.freedesktop.org
Thu Apr 14 13:55:51 UTC 2011
Module: Mesa
Branch: master
Commit: 78e90bf2474b89dcc7cc199ddb360745e93720c6
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=78e90bf2474b89dcc7cc199ddb360745e93720c6
Author: pepp <pelloux at gmail.com>
Date: Wed Apr 13 13:03:31 2011 +0200
st/mesa: add support for GL_RGBA + GL_UNSIGNED_INT_8_8_8_8 in st_fast_readpixels
Signed-off-by: Brian Paul <brianp at vmware.com>
---
src/mesa/state_tracker/st_cb_readpixels.c | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index 03f58bf..fdb7770 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -201,7 +201,8 @@ st_fast_readpixels(struct gl_context *ctx, struct st_renderbuffer *strb,
enum combination {
A8R8G8B8_UNORM_TO_RGBA_UBYTE,
A8R8G8B8_UNORM_TO_RGB_UBYTE,
- A8R8G8B8_UNORM_TO_BGRA_UINT
+ A8R8G8B8_UNORM_TO_BGRA_UINT,
+ A8R8G8B8_UNORM_TO_RGBA_UINT
} combo;
if (ctx->_ImageTransferState)
@@ -219,6 +220,10 @@ st_fast_readpixels(struct gl_context *ctx, struct st_renderbuffer *strb,
format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV) {
combo = A8R8G8B8_UNORM_TO_BGRA_UINT;
}
+ else if (strb->format == PIPE_FORMAT_B8G8R8A8_UNORM &&
+ format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8) {
+ combo = A8R8G8B8_UNORM_TO_RGBA_UINT;
+ }
else {
return GL_FALSE;
}
@@ -305,6 +310,20 @@ st_fast_readpixels(struct gl_context *ctx, struct st_renderbuffer *strb,
y += dy;
}
break;
+ case A8R8G8B8_UNORM_TO_RGBA_UINT:
+ for (row = 0; row < height; row++) {
+ const GLubyte *src = map + y * trans->stride;
+ for (col = 0; col < width; col++) {
+ GLuint pixel = ((GLuint *) src)[col];
+ dst[col*4+0] = (pixel >> 24) & 0xff;
+ dst[col*4+1] = (pixel >> 0) & 0xff;
+ dst[col*4+2] = (pixel >> 8) & 0xff;
+ dst[col*4+3] = (pixel >> 16) & 0xff;
+ }
+ dst += dstStride;
+ y += dy;
+ }
+ break;
default:
; /* nothing */
}
More information about the mesa-commit
mailing list