summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast/s_span.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2006-10-12 23:17:02 +0000
committerBrian Paul <[email protected]>2006-10-12 23:17:02 +0000
commit76e778dce59aa6f290db50242df945943fc47b05 (patch)
tree07ad7bf3d7a54f49e86ff650fc7a9d4ce5d40338 /src/mesa/swrast/s_span.c
parent4bb9f4115c4b1930a140da78feff953e80f8a4f5 (diff)
Lots of changes to support runtime renderbuffer depths.
_swrast_read_rgba_span() now takes a datatype parameter. New optimization for glReadPixels(format=GL_RGB). New glCopyPixels optimization for the simple, common cases.
Diffstat (limited to 'src/mesa/swrast/s_span.c')
-rw-r--r--src/mesa/swrast/s_span.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 4d0ccf5f1d0..59a5361632b 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1560,14 +1560,16 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
}
-
/**
* Read RGBA pixels from frame buffer. Clipping will be done to prevent
* reading ouside the buffer's boundaries.
+ * \param type datatype for returned colors
+ * \param rgba the returned colors
*/
void
_swrast_read_rgba_span( GLcontext *ctx, struct gl_renderbuffer *rb,
- GLuint n, GLint x, GLint y, GLchan rgba[][4] )
+ GLuint n, GLint x, GLint y, GLenum dstType,
+ GLvoid *rgba)
{
const GLint bufWidth = (GLint) rb->Width;
const GLint bufHeight = (GLint) rb->Height;
@@ -1609,8 +1611,18 @@ _swrast_read_rgba_span( GLcontext *ctx, struct gl_renderbuffer *rb,
ASSERT(rb);
ASSERT(rb->GetRow);
ASSERT(rb->_BaseFormat == GL_RGB || rb->_BaseFormat == GL_RGBA);
- ASSERT(rb->DataType == CHAN_TYPE);
- rb->GetRow(ctx, rb, length, x + skip, y, rgba + skip);
+
+ if (rb->DataType == dstType) {
+ rb->GetRow(ctx, rb, length, x + skip, y,
+ (GLubyte *) rgba + skip * RGBA_PIXEL_SIZE(rb->DataType));
+ }
+ else {
+ GLuint temp[MAX_WIDTH * 4];
+ rb->GetRow(ctx, rb, length, x + skip, y, temp);
+ _mesa_convert_colors(rb->DataType, temp,
+ dstType, (GLubyte *) rgba + skip * RGBA_PIXEL_SIZE(dstType),
+ length, NULL);
+ }
}
}
@@ -1801,7 +1813,7 @@ void *
_swrast_get_dest_rgba(GLcontext *ctx, struct gl_renderbuffer *rb,
SWspan *span)
{
- GLuint pixelSize;
+ const GLuint pixelSize = RGBA_PIXEL_SIZE(span->array->ChanType);
void *rbPixels;
/*
@@ -1809,15 +1821,12 @@ _swrast_get_dest_rgba(GLcontext *ctx, struct gl_renderbuffer *rb,
* Point rbPixels to a temporary space (use specular color arrays).
*/
if (span->array->ChanType == GL_UNSIGNED_BYTE) {
- pixelSize = 4 * sizeof(GLubyte);
rbPixels = span->array->color.sz1.spec;
}
else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
- pixelSize = 4 * sizeof(GLushort);
rbPixels = span->array->color.sz2.spec;
}
else {
- pixelSize = 4 * sizeof(GLfloat);
rbPixels = span->array->color.sz4.spec;
}