[PATCH xserver 1/3] glamor: Scissor rectangle drawing to the bounds of the rects.

Keith Packard keithp at keithp.com
Tue Aug 1 22:01:15 UTC 2017


Eric Anholt <eric at anholt.net> writes:

> Scissors provide a critical hint to tiled renderers as to what tiles
> need to be load/stored because they could be modified by the
> rendering.
>
> The bounds calculation here is limited to when we have a small number
> of rects (large enough to cover rounded window corners, but probably
> not xeyes) to avoid overhead on desktop GL.

Hrm. Often times, the rendering comes from a region which already has a
bounds computed. I wonder if it would be useful to somehow wrap
PaintWindow and capture the bounding rect from there?

+static inline void
+glamor_bounds_union_rect(BoxPtr bounds, xRectangle *rect)
+{
+    bounds->x1 = min(bounds->x1, rect->x);
+    bounds->y1 = min(bounds->y1, rect->y);
+    bounds->x2 = max(bounds->x2, rect->x + rect->width);
+    bounds->y2 = max(bounds->y2, rect->y + rect->height);
+}

You're in a world of pain here -- rect->width is an unsigned 16-bit
value, bounds->x2 and rect->x are signed 16-bit values.

Maybe something like:

    bounds->x2 = min(SHRT_MAX, max(bounds->x2, rect->x + rect->width));
    bounds->y2 = min(SHRT_MAX, max(bounds->y2, rect->y + rect->height));

?

-- 
-keith
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.x.org/archives/xorg-devel/attachments/20170801/78601818/attachment.sig>


More information about the xorg-devel mailing list