diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-01-26 12:50:13 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-01-26 12:50:13 +0000 |
commit | bb8dc3ef37580a221a40ba3dcbde755edc59bb62 (patch) | |
tree | 718070365befd8ac5dc8c551fb73f573a49e8655 | |
parent | 8ab71cd3293ad420b0cdf487e8d5c66170ddc13c (diff) |
sna/video: ValidateGC before use
We required the GC->pCompositeClip in order to apply the current Drawable's
clip to video region, this requires us to call ValidateGC first.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93874
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/sna_video.h | 22 | ||||
-rw-r--r-- | src/sna/sna_video_overlay.c | 10 | ||||
-rw-r--r-- | src/sna/sna_video_sprite.c | 10 | ||||
-rw-r--r-- | src/sna/sna_video_textured.c | 7 |
4 files changed, 32 insertions, 17 deletions
diff --git a/src/sna/sna_video.h b/src/sna/sna_video.h index dfb8c0c4..b2789913 100644 --- a/src/sna/sna_video.h +++ b/src/sna/sna_video.h @@ -213,4 +213,26 @@ sna_window_set_port(WindowPtr window, XvPortPtr port) ((void **)__get_private(window, sna_window_key))[2] = port; } +static inline int offset_and_clip(int x, int dx) +{ + x += dx; + if (x <= 0) + return 0; + if (x >= MAXSHORT) + return MAXSHORT; + return x; +} + +static inline void init_video_region(RegionRec *region, + DrawablePtr draw, + int drw_x, int drw_y, + int drw_w, int drw_h) +{ + region->extents.x1 = offset_and_clip(draw->x, drw_x); + region->extents.y1 = offset_and_clip(draw->y, drw_y); + region->extents.x2 = offset_and_clip(draw->x, drw_x + drw_w); + region->extents.y2 = offset_and_clip(draw->y, drw_y + drw_h); + region->data = NULL; +} + #endif /* SNA_VIDEO_H */ diff --git a/src/sna/sna_video_overlay.c b/src/sna/sna_video_overlay.c index d7821134..9bc5ce40 100644 --- a/src/sna/sna_video_overlay.c +++ b/src/sna/sna_video_overlay.c @@ -474,15 +474,13 @@ sna_video_overlay_put_image(ddPutImage_ARGS) if (src_h >= (drw_h * 8)) drw_h = src_h / 7; - clip.extents.x1 = draw->x + drw_x; - clip.extents.y1 = draw->y + drw_y; - clip.extents.x2 = clip.extents.x1 + drw_w; - clip.extents.y2 = clip.extents.y1 + drw_h; - clip.data = NULL; + init_video_region(&clip, draw, drw_x, drw_y, drw_w, drw_h); DBG(("%s: always_on_top=%d\n", __FUNCTION__, video->AlwaysOnTop)); - if (!video->AlwaysOnTop) + if (!video->AlwaysOnTop) { + ValidateGC(draw, gc); RegionIntersect(&clip, &clip, gc->pCompositeClip); + } if (box_empty(&clip.extents)) goto invisible; diff --git a/src/sna/sna_video_sprite.c b/src/sna/sna_video_sprite.c index 7c8a73f2..9e85049f 100644 --- a/src/sna/sna_video_sprite.c +++ b/src/sna/sna_video_sprite.c @@ -373,15 +373,13 @@ static int sna_video_sprite_put_image(ddPutImage_ARGS) RegionRec clip; int ret, i; - clip.extents.x1 = draw->x + drw_x; - clip.extents.y1 = draw->y + drw_y; - clip.extents.x2 = clip.extents.x1 + drw_w; - clip.extents.y2 = clip.extents.y1 + drw_h; - clip.data = NULL; + init_video_region(&clip, draw, drw_x, drw_y, drw_w, drw_h); DBG(("%s: always_on_top=%d\n", __FUNCTION__, video->AlwaysOnTop)); - if (!video->AlwaysOnTop) + if (!video->AlwaysOnTop) { + ValidateGC(draw, gc); RegionIntersect(&clip, &clip, gc->pCompositeClip); + } DBG(("%s: src=(%d, %d),(%d, %d), dst=(%d, %d),(%d, %d), id=%d, sizep=%dx%d, sync?=%d\n", __FUNCTION__, diff --git a/src/sna/sna_video_textured.c b/src/sna/sna_video_textured.c index 3f14a59c..f5b7e98d 100644 --- a/src/sna/sna_video_textured.c +++ b/src/sna/sna_video_textured.c @@ -156,12 +156,9 @@ sna_video_textured_put_image(ddPutImage_ARGS) if (wedged(sna)) return BadAlloc; - clip.extents.x1 = draw->x + drw_x; - clip.extents.y1 = draw->y + drw_y; - clip.extents.x2 = clip.extents.x1 + drw_w; - clip.extents.y2 = clip.extents.y1 + drw_h; - clip.data = NULL; + init_video_region(&clip, draw, drw_x, drw_y, drw_w, drw_h); + ValidateGC(draw, gc); RegionIntersect(&clip, &clip, gc->pCompositeClip); if (!RegionNotEmpty(&clip)) return Success; |