aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/swrast/s_copypix.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-01-25 08:32:49 +0100
committermarha <marha@users.sourceforge.net>2012-01-25 08:32:49 +0100
commit0c1cee47049afdcf74d87a23f4f4fd57867f6798 (patch)
tree14c117114d1b996e5b04e6546b1580ea53bc26f2 /mesalib/src/mesa/swrast/s_copypix.c
parent5be921907008288d6465962063bc10fd7a5b1906 (diff)
parente6432710d8a586386b3c7025e845cf4f80830da3 (diff)
downloadvcxsrv-0c1cee47049afdcf74d87a23f4f4fd57867f6798.tar.gz
vcxsrv-0c1cee47049afdcf74d87a23f4f4fd57867f6798.tar.bz2
vcxsrv-0c1cee47049afdcf74d87a23f4f4fd57867f6798.zip
Merge remote-tracking branch 'origin/released'
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;
+ }
}