summaryrefslogtreecommitdiff
path: root/src/sna/sna_video.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/sna/sna_video.h')
-rw-r--r--src/sna/sna_video.h22
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 */