aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/swrast/s_copypix.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-01-25 08:24:51 +0100
committermarha <marha@users.sourceforge.net>2012-01-25 08:24:51 +0100
commite6432710d8a586386b3c7025e845cf4f80830da3 (patch)
treea403fa86779a287c97f5605f9b4d455d662ece66 /mesalib/src/mesa/swrast/s_copypix.c
parentd3f0fe49b8cb29295f3e529cc699a2abde1515a1 (diff)
downloadvcxsrv-e6432710d8a586386b3c7025e845cf4f80830da3.tar.gz
vcxsrv-e6432710d8a586386b3c7025e845cf4f80830da3.tar.bz2
vcxsrv-e6432710d8a586386b3c7025e845cf4f80830da3.zip
mesa git update 25 jan 2012
Diffstat (limited to 'mesalib/src/mesa/swrast/s_copypix.c')
-rw-r--r--mesalib/src/mesa/swrast/s_copypix.c55
1 files changed, 53 insertions, 2 deletions
diff --git a/mesalib/src/mesa/swrast/s_copypix.c b/mesalib/src/mesa/swrast/s_copypix.c
index 1e0f9fe7d..592d35a98 100644
--- a/mesalib/src/mesa/swrast/s_copypix.c
+++ b/mesalib/src/mesa/swrast/s_copypix.c
@@ -148,7 +148,7 @@ copy_rgba_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
p = tmpImage;
for (row = 0; row < height; row++) {
_swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
- width, srcx, sy + row, GL_FLOAT, p );
+ width, srcx, sy + row, p );
p += width * 4;
}
p = tmpImage;
@@ -172,7 +172,7 @@ copy_rgba_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
else {
/* get from framebuffer */
_swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
- width, srcx, sy, GL_FLOAT, rgba );
+ width, srcx, sy, rgba );
}
if (transferOps) {
@@ -558,6 +558,49 @@ swrast_fast_copy_pixels(struct gl_context *ctx,
/**
+ * Find/map the renderbuffer that we'll be reading from.
+ * The swrast_render_start() function only maps the drawing buffers,
+ * not the read buffer.
+ */
+static struct gl_renderbuffer *
+map_readbuffer(struct gl_context *ctx, GLenum type)
+{
+ struct gl_framebuffer *fb = ctx->ReadBuffer;
+ struct gl_renderbuffer *rb;
+ struct swrast_renderbuffer *srb;
+
+ switch (type) {
+ case GL_COLOR:
+ rb = fb->Attachment[fb->_ColorReadBufferIndex].Renderbuffer;
+ break;
+ case GL_DEPTH:
+ case GL_DEPTH_STENCIL:
+ rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer;
+ break;
+ case GL_STENCIL:
+ rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer;
+ break;
+ default:
+ return NULL;
+ }
+
+ srb = swrast_renderbuffer(rb);
+
+ if (!srb || srb->Map) {
+ /* no buffer, or buffer is mapped already, we're done */
+ return NULL;
+ }
+
+ ctx->Driver.MapRenderbuffer(ctx, rb,
+ 0, 0, rb->Width, rb->Height,
+ GL_MAP_READ_BIT,
+ &srb->Map, &srb->RowStride);
+
+ return rb;
+}
+
+
+/**
* Do software-based glCopyPixels.
* By time we get here, all parameters will have been error-checked.
*/
@@ -567,6 +610,7 @@ _swrast_CopyPixels( struct gl_context *ctx,
GLint destx, GLint desty, GLenum type )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_renderbuffer *rb;
if (!_mesa_check_conditional_render(ctx))
return; /* don't copy */
@@ -585,6 +629,7 @@ _swrast_CopyPixels( struct gl_context *ctx,
}
swrast_render_start(ctx);
+ rb = map_readbuffer(ctx, type);
switch (type) {
case GL_COLOR:
@@ -606,4 +651,10 @@ _swrast_CopyPixels( struct gl_context *ctx,
}
swrast_render_finish(ctx);
+
+ if (rb) {
+ struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
+ ctx->Driver.UnmapRenderbuffer(ctx, rb);
+ srb->Map = NULL;
+ }
}