From 455754ca8d2762c6294e6db6b405da7959ab8a0f Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 26 Sep 2013 15:41:36 +0100 Subject: [PATCH] sna: Make sure the transformed CRTC box is clipped correctly. Signed-off-by: Chris Wilson --- src/sna/sna_display.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index c7806cea..032c7769 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -3827,6 +3827,25 @@ void sna_mode_reset(struct sna *sna) } } +static void transformed_box(BoxRec *box, xf86CrtcPtr crtc) +{ + box->x1 -= crtc->filter_width >> 1; + box->x2 += crtc->filter_width >> 1; + box->y1 -= crtc->filter_height >> 1; + box->y2 += crtc->filter_height >> 1; + + pixman_f_transform_bounds(&crtc->f_framebuffer_to_crtc, box); + + if (box->x1 < 0) + box->x1 = 0; + if (box->y1 < 0) + box->y1 = 0; + if (box->x2 > crtc->mode.HDisplay) + box->x2 = crtc->mode.HDisplay; + if (box->y2 > crtc->mode.VDisplay) + box->y2 = crtc->mode.VDisplay; +} + static void sna_crtc_redisplay__fallback(xf86CrtcPtr crtc, RegionPtr region) { @@ -3894,11 +3913,7 @@ sna_crtc_redisplay__fallback(xf86CrtcPtr crtc, RegionPtr region) BoxRec box; box = *b++; - box.x1 -= crtc->filter_width >> 1; - box.x2 += crtc->filter_width >> 1; - box.y1 -= crtc->filter_height >> 1; - box.y2 += crtc->filter_height >> 1; - pixman_f_transform_bounds(&crtc->f_framebuffer_to_crtc, & box); + transformed_box(&box, crtc); DBG(("%s: (%d, %d)x(%d, %d) -> (%d, %d), (%d, %d)\n", __FUNCTION__, @@ -3993,11 +4008,7 @@ sna_crtc_redisplay__composite(xf86CrtcPtr crtc, RegionPtr region) BoxRec box; box = *b++; - box.x1 -= crtc->filter_width >> 1; - box.x2 += crtc->filter_width >> 1; - box.y1 -= crtc->filter_height >> 1; - box.y2 += crtc->filter_height >> 1; - pixman_f_transform_bounds(&crtc->f_framebuffer_to_crtc, & box); + transformed_box(&box, crtc); DBG(("%s: (%d, %d)x(%d, %d) -> (%d, %d), (%d, %d)\n", __FUNCTION__,