From 2a8bd4e32943f8fd5bac87bf711150b31fb1a4bf Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 20 Mar 2006 02:23:26 +0000 Subject: [PATCH] Replace intel_clip_to_framebuffer(), intel_clip_to_drawable(), and intel_clip_to_region() with new _mesa_clip_to_region(). --- src/mesa/drivers/dri/i915/intel_pixel.c | 117 ++----------------- src/mesa/drivers/dri/i915/intel_pixel.h | 16 --- src/mesa/drivers/dri/i915/intel_pixel_copy.c | 7 +- src/mesa/drivers/dri/i915/intel_pixel_draw.c | 7 +- src/mesa/drivers/dri/i915/intel_tex_copy.c | 9 +- 5 files changed, 24 insertions(+), 132 deletions(-) diff --git a/src/mesa/drivers/dri/i915/intel_pixel.c b/src/mesa/drivers/dri/i915/intel_pixel.c index f8b8373133b..2c7ad23b747 100644 --- a/src/mesa/drivers/dri/i915/intel_pixel.c +++ b/src/mesa/drivers/dri/i915/intel_pixel.c @@ -34,6 +34,10 @@ #include "intel_regions.h" +/** + * Check if any fragment operations are in effect which might effect + * glDraw/CopyPixels. + */ GLboolean intel_check_blit_fragment_ops( GLcontext *ctx ) { if (ctx->NewState) @@ -75,6 +79,11 @@ GLboolean intel_check_meta_tex_fragment_ops( GLcontext *ctx ) * format of the pixels in the region. For now this code assumes that * the region is a display surface and hence is either ARGB8888 or * RGB565. + * XXX FBO: If we'd pass in the intel_renderbuffer instead of region, we'd + * know the buffer's pixel format. + * + * \param format as given to glDraw/ReadPixels + * \param type as given to glDraw/ReadPixels */ GLboolean intel_check_blit_format( struct intel_region *region, GLenum format, GLenum type ) @@ -101,114 +110,6 @@ GLboolean intel_check_blit_format( struct intel_region *region, } -GLboolean intel_clip_to_framebuffer( GLcontext *ctx, - const GLframebuffer *buffer, - GLint *x, GLint *y, - GLsizei *width, GLsizei *height ) -{ - /* left clipping */ - if (*x < buffer->_Xmin) { - *width -= (buffer->_Xmin - *x); - *x = buffer->_Xmin; - } - - /* right clipping */ - if (*x + *width > buffer->_Xmax) - *width -= (*x + *width - buffer->_Xmax - 1); - - if (*width <= 0) - return GL_FALSE; - - /* bottom clipping */ - if (*y < buffer->_Ymin) { - *height -= (buffer->_Ymin - *y); - *y = buffer->_Ymin; - } - - /* top clipping */ - if (*y + *height > buffer->_Ymax) - *height -= (*y + *height - buffer->_Ymax - 1); - - if (*height <= 0) - return GL_FALSE; - - return GL_TRUE; -} - - - -GLboolean intel_clip_to_drawable( GLcontext *ctx, - const __DRIdrawablePrivate *dPriv, - GLint *x, GLint *y, - GLsizei *width, GLsizei *height ) -{ - /* left clipping */ - if (*x < dPriv->x) { - *width -= (dPriv->x - *x); - *x = dPriv->x; - } - - /* right clipping */ - if (*x + *width > dPriv->x + dPriv->w) - *width -= (*x + *width) - (dPriv->x + dPriv->w); - - if (*width <= 0) - return GL_FALSE; - - /* bottom clipping */ - if (*y < dPriv->y) { - *height -= (dPriv->y - *y); - *y = dPriv->y; - } - - /* top clipping */ - if (*y + *height > dPriv->y + dPriv->h) - *height -= (*y + *height) - (dPriv->y + dPriv->w); - - if (*height <= 0) - return GL_FALSE; - - return GL_TRUE; -} - - -GLboolean intel_clip_to_region( GLcontext *ctx, - const struct intel_region *region, - GLint *x, GLint *y, - GLsizei *width, GLsizei *height ) -{ - /* left clipping */ - if (*x < 0) { - *width -= (0 - *x); - *x = 0; - } - - /* right clipping */ - if (*x + *width > region->pitch) - *width -= (*x + *width) - region->pitch; - - if (*width <= 0) - return GL_FALSE; - - /* bottom clipping */ - if (*y < 0) { - *height -= (0 - *y); - *y = 0; - } - - /* top clipping */ - if (*y + *height > region->height) - *height -= (*y + *height) - region->height; - - if (*height <= 0) - return GL_FALSE; - - return GL_TRUE; -} - - - - void intelInitPixelFuncs( struct dd_function_table *functions ) { functions->Accum = _swrast_Accum; diff --git a/src/mesa/drivers/dri/i915/intel_pixel.h b/src/mesa/drivers/dri/i915/intel_pixel.h index 35699bc3f2d..3654a91b595 100644 --- a/src/mesa/drivers/dri/i915/intel_pixel.h +++ b/src/mesa/drivers/dri/i915/intel_pixel.h @@ -40,22 +40,6 @@ GLboolean intel_check_blit_format( struct intel_region *region, GLenum format, GLenum type ); -GLboolean intel_clip_to_framebuffer( GLcontext *ctx, - const GLframebuffer *buffer, - GLint *x, GLint *y, - GLsizei *width, GLsizei *height ); - -GLboolean intel_clip_to_drawable( GLcontext *ctx, - const __DRIdrawablePrivate *dPriv, - GLint *x, GLint *y, - GLsizei *width, GLsizei *height ); - -GLboolean intel_clip_to_region( GLcontext *ctx, - const struct intel_region *region, - GLint *x, GLint *y, - GLsizei *width, GLsizei *height ); - - void intelReadPixels( GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, diff --git a/src/mesa/drivers/dri/i915/intel_pixel_copy.c b/src/mesa/drivers/dri/i915/intel_pixel_copy.c index 4b4ab5aa35f..48b24b6f249 100644 --- a/src/mesa/drivers/dri/i915/intel_pixel_copy.c +++ b/src/mesa/drivers/dri/i915/intel_pixel_copy.c @@ -27,6 +27,7 @@ #include "glheader.h" #include "enums.h" +#include "image.h" #include "mtypes.h" #include "macros.h" #include "swrast/swrast.h" @@ -180,7 +181,8 @@ static GLboolean do_texture_copypixels( GLcontext *ctx, GLint orig_x = srcx; GLint orig_y = srcy; - if (!intel_clip_to_region(ctx, src, &srcx, &srcy, &width, &height)) + if (!_mesa_clip_to_region(ctx, 0, 0, src->pitch, src->height, + &srcx, &srcy, &width, &height)) goto out; dstx += srcx - orig_x; @@ -273,7 +275,8 @@ static GLboolean do_blit_copypixels( GLcontext *ctx, delta_x = srcx - dstx; delta_y = srcy - dsty; - if (!intel_clip_to_region(ctx, src, &srcx, &srcy, &width, &height)) + if (!_mesa_clip_to_region(ctx, 0, 0, src->pitch, src->height, + &srcx, &srcy, &width, &height)) goto out; dstx = srcx - delta_x; diff --git a/src/mesa/drivers/dri/i915/intel_pixel_draw.c b/src/mesa/drivers/dri/i915/intel_pixel_draw.c index d6b961035cd..f28afafbd2a 100644 --- a/src/mesa/drivers/dri/i915/intel_pixel_draw.c +++ b/src/mesa/drivers/dri/i915/intel_pixel_draw.c @@ -150,10 +150,11 @@ static GLboolean do_texture_drawpixels( GLcontext *ctx, srcy = 0; if (0) { - GLint orig_x = dstx; - GLint orig_y = dsty; + const GLint orig_x = dstx; + const GLint orig_y = dsty; - if (!intel_clip_to_region(ctx, dst, &dstx, &dsty, &width, &height)) + if (!_mesa_clip_to_region(ctx, 0, 0, dst->pitch, dst->height, + &dstx, &dsty, &width, &height)) goto out; srcx += dstx - orig_x; diff --git a/src/mesa/drivers/dri/i915/intel_tex_copy.c b/src/mesa/drivers/dri/i915/intel_tex_copy.c index d0307aaaee5..9e9c5f7031b 100644 --- a/src/mesa/drivers/dri/i915/intel_tex_copy.c +++ b/src/mesa/drivers/dri/i915/intel_tex_copy.c @@ -27,6 +27,7 @@ #include "mtypes.h" #include "enums.h" +#include "image.h" #include "teximage.h" #include "swrast/swrast.h" @@ -94,11 +95,13 @@ static GLboolean do_copy_texsubimage( struct intel_context *intel, GLuint image_offset = intel_miptree_image_offset(intelImage->mt, intelImage->face, intelImage->level); - GLint orig_x = x; - GLint orig_y = y; + const GLint orig_x = x; + const GLint orig_y = y; GLuint window_y; + const struct gl_framebuffer *fb = ctx->DrawBuffer; - if (intel_clip_to_framebuffer(ctx, ctx->DrawBuffer, &x, &y, &width, &height)) { + if (_mesa_clip_to_region(ctx, fb->_Xmin, fb->_Ymin, fb->_Xmax, fb->_Ymax, + &x, &y, &width, &height)) { /* Update dst for clipped src. Need to also clip the source rect. */ dstx += x - orig_x;