summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2006-06-30 17:21:32 +0000
committerBrian Paul <[email protected]>2006-06-30 17:21:32 +0000
commit0cdf2d7413838ab5aea2edb6a2792edeb8c659e5 (patch)
treeaddba75233422e40acd6e10790be009c01606989 /src/mesa/drivers
parentf63623779a44c677d8731cbd706a02a615e03b0f (diff)
clipping fixes (Martijn van Oosterhout)
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/r128/r128_state.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/mesa/drivers/dri/r128/r128_state.c b/src/mesa/drivers/dri/r128/r128_state.c
index 1b2c2a5284e..3a1d71d2154 100644
--- a/src/mesa/drivers/dri/r128/r128_state.c
+++ b/src/mesa/drivers/dri/r128/r128_state.c
@@ -599,8 +599,18 @@ static void r128UpdateClipping( GLcontext *ctx )
x2 += drawable->x;
y2 += drawable->y;
- rmesa->setup.sc_top_left_c = ((y1 << 16) | x1);
- rmesa->setup.sc_bottom_right_c = ((y2 << 16) | x2);
+ /* Clamp values to screen to avoid wrapping problems */
+ if ( x1 < 0 )
+ x1 = 0;
+ else if ( x1 >= rmesa->driScreen->fbWidth )
+ x1 = rmesa->driScreen->fbWidth - 1;
+ if ( y1 < 0 )
+ y1 = 0;
+ else if ( y1 >= rmesa->driScreen->fbHeight )
+ y1 = rmesa->driScreen->fbHeight - 1;
+
+ rmesa->setup.sc_top_left_c = (((y1 & 0x3FFF) << 16) | (x1 & 0x3FFF));
+ rmesa->setup.sc_bottom_right_c = (((y2 & 0x3FFF) << 16) | (x2 & 0x3FFF));
rmesa->dirty |= R128_UPLOAD_CONTEXT;
}
@@ -798,8 +808,8 @@ static void r128UpdateWindow( GLcontext *ctx )
struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
driRenderbuffer *drb = (driRenderbuffer *) rb;
- rmesa->setup.window_xy_offset = ((y << R128_WINDOW_Y_SHIFT) |
- (x << R128_WINDOW_X_SHIFT));
+ rmesa->setup.window_xy_offset = (((y & 0xFFF) << R128_WINDOW_Y_SHIFT) |
+ ((x & 0xFFF) << R128_WINDOW_X_SHIFT));
rmesa->setup.dst_pitch_offset_c = (((drb->flippedPitch/8) << 21) |
(drb->flippedOffset >> 5));