summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-02-10 16:49:41 -0800
committerJason Ekstrand <[email protected]>2016-02-10 17:09:56 -0800
commit7ef3e47c27fb9b11b113bb699019785960d6bf9a (patch)
tree3c67c175bed89db662b6bd0db9dbea3d0b6f529f /src/mesa/main
parentd2623a324713134b4da6e08775aed868300e96cb (diff)
parent85f5c18fef1ff2f19d698f150e23a02acd6f59b9 (diff)
Merge commit '85f5c18fef1ff2f19d698f150e23a02acd6f59b9' into vulkan
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/image.c22
-rw-r--r--src/mesa/main/readpix.c69
2 files changed, 50 insertions, 41 deletions
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index e79e3e68eac..99f253cd373 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -670,7 +670,7 @@ _mesa_clip_drawpixels(const struct gl_context *ctx,
* so that the image region is entirely within the window bounds.
* Note: this is different from _mesa_clip_drawpixels() in that the
* scissor box is ignored, and we use the bounds of the current readbuffer
- * surface.
+ * surface or the attached image.
*
* \return GL_TRUE if region to read is in bounds
* GL_FALSE if region is completely out of bounds (nothing to read)
@@ -682,6 +682,18 @@ _mesa_clip_readpixels(const struct gl_context *ctx,
struct gl_pixelstore_attrib *pack)
{
const struct gl_framebuffer *buffer = ctx->ReadBuffer;
+ struct gl_renderbuffer *rb = buffer->_ColorReadBuffer;
+ GLsizei clip_width;
+ GLsizei clip_height;
+
+ if (rb) {
+ clip_width = rb->Width;
+ clip_height = rb->Height;
+ } else {
+ clip_width = buffer->Width;
+ clip_height = buffer->Height;
+ }
+
if (pack->RowLength == 0) {
pack->RowLength = *width;
@@ -694,8 +706,8 @@ _mesa_clip_readpixels(const struct gl_context *ctx,
*srcX = 0;
}
/* right clipping */
- if (*srcX + *width > (GLsizei) buffer->Width)
- *width -= (*srcX + *width - buffer->Width);
+ if (*srcX + *width > clip_width)
+ *width -= (*srcX + *width - clip_width);
if (*width <= 0)
return GL_FALSE;
@@ -707,8 +719,8 @@ _mesa_clip_readpixels(const struct gl_context *ctx,
*srcY = 0;
}
/* top clipping */
- if (*srcY + *height > (GLsizei) buffer->Height)
- *height -= (*srcY + *height - buffer->Height);
+ if (*srcY + *height > clip_height)
+ *height -= (*srcY + *height - clip_height);
if (*height <= 0)
return GL_FALSE;
diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index 8cdc9fe1cb2..470182ab23d 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -858,46 +858,40 @@ _mesa_readpixels(struct gl_context *ctx,
const struct gl_pixelstore_attrib *packing,
GLvoid *pixels)
{
- struct gl_pixelstore_attrib clippedPacking = *packing;
-
if (ctx->NewState)
_mesa_update_state(ctx);
- /* Do all needed clipping here, so that we can forget about it later */
- if (_mesa_clip_readpixels(ctx, &x, &y, &width, &height, &clippedPacking)) {
-
- pixels = _mesa_map_pbo_dest(ctx, &clippedPacking, pixels);
+ pixels = _mesa_map_pbo_dest(ctx, packing, pixels);
- if (pixels) {
- /* Try memcpy first. */
- if (readpixels_memcpy(ctx, x, y, width, height, format, type,
- pixels, packing)) {
- _mesa_unmap_pbo_dest(ctx, &clippedPacking);
- return;
- }
-
- /* Otherwise take the slow path. */
- switch (format) {
- case GL_STENCIL_INDEX:
- read_stencil_pixels(ctx, x, y, width, height, type, pixels,
- &clippedPacking);
- break;
- case GL_DEPTH_COMPONENT:
- read_depth_pixels(ctx, x, y, width, height, type, pixels,
- &clippedPacking);
- break;
- case GL_DEPTH_STENCIL_EXT:
- read_depth_stencil_pixels(ctx, x, y, width, height, type, pixels,
- &clippedPacking);
- break;
- default:
- /* all other formats should be color formats */
- read_rgba_pixels(ctx, x, y, width, height, format, type, pixels,
- &clippedPacking);
- }
+ if (pixels) {
+ /* Try memcpy first. */
+ if (readpixels_memcpy(ctx, x, y, width, height, format, type,
+ pixels, packing)) {
+ _mesa_unmap_pbo_dest(ctx, packing);
+ return;
+ }
- _mesa_unmap_pbo_dest(ctx, &clippedPacking);
+ /* Otherwise take the slow path. */
+ switch (format) {
+ case GL_STENCIL_INDEX:
+ read_stencil_pixels(ctx, x, y, width, height, type, pixels,
+ packing);
+ break;
+ case GL_DEPTH_COMPONENT:
+ read_depth_pixels(ctx, x, y, width, height, type, pixels,
+ packing);
+ break;
+ case GL_DEPTH_STENCIL_EXT:
+ read_depth_stencil_pixels(ctx, x, y, width, height, type, pixels,
+ packing);
+ break;
+ default:
+ /* all other formats should be color formats */
+ read_rgba_pixels(ctx, x, y, width, height, format, type, pixels,
+ packing);
}
+
+ _mesa_unmap_pbo_dest(ctx, packing);
}
}
@@ -993,6 +987,7 @@ _mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height,
{
GLenum err = GL_NO_ERROR;
struct gl_renderbuffer *rb;
+ struct gl_pixelstore_attrib clippedPacking;
GET_CURRENT_CONTEXT(ctx);
@@ -1094,7 +1089,9 @@ _mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height,
}
}
- if (width == 0 || height == 0)
+ /* Do all needed clipping here, so that we can forget about it later */
+ clippedPacking = ctx->Pack;
+ if (!_mesa_clip_readpixels(ctx, &x, &y, &width, &height, &clippedPacking))
return; /* nothing to do */
if (!_mesa_validate_pbo_access(2, &ctx->Pack, width, height, 1,
@@ -1118,7 +1115,7 @@ _mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height,
}
ctx->Driver.ReadPixels(ctx, x, y, width, height,
- format, type, &ctx->Pack, pixels);
+ format, type, &clippedPacking, pixels);
}
void GLAPIENTRY