mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 07:18:17 +02:00
Replace intel_clip_to_framebuffer(), intel_clip_to_drawable(), and
intel_clip_to_region() with new _mesa_clip_to_region().
This commit is contained in:
parent
c247268499
commit
2a8bd4e329
5 changed files with 24 additions and 132 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue