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 /src/sna/sna_video.h | |
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>
Diffstat (limited to 'src/sna/sna_video.h')
-rw-r--r-- | src/sna/sna_video.h | 22 |
1 files changed, 22 insertions, 0 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 */ |