forked from 12to11/12to11
Speed up compositing
* subcompositor.c (IntersectBoxes): New function. (SubcompositorUpdate): Intersect boxes instead of regions when updating from global update region.
This commit is contained in:
parent
459de34ca7
commit
86216a1164
1 changed files with 51 additions and 20 deletions
|
@ -1727,6 +1727,29 @@ StorePreviousDamage (Subcompositor *subcompositor,
|
||||||
update_region);
|
update_region);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Bool
|
||||||
|
IntersectBoxes (pixman_box32_t *in, pixman_box32_t *other,
|
||||||
|
pixman_box32_t *out)
|
||||||
|
{
|
||||||
|
pixman_box32_t a, b;
|
||||||
|
|
||||||
|
/* Take copies of all the boxes, since one of them might be out. */
|
||||||
|
a = *in;
|
||||||
|
b = *other;
|
||||||
|
|
||||||
|
out->x1 = MAX (a.x1, b.x1);
|
||||||
|
out->y1 = MAX (a.y1, b.y1);
|
||||||
|
|
||||||
|
out->x2 = MIN (a.x2, b.x2);
|
||||||
|
out->y2 = MIN (a.y2, b.y2);
|
||||||
|
|
||||||
|
/* If the intersection is empty, return False. */
|
||||||
|
if (out->x2 - out->x1 <= 0 || out->y2 - out->y1 <= 0)
|
||||||
|
return False;
|
||||||
|
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SubcompositorUpdate (Subcompositor *subcompositor)
|
SubcompositorUpdate (Subcompositor *subcompositor)
|
||||||
{
|
{
|
||||||
|
@ -2156,28 +2179,36 @@ SubcompositorUpdate (Subcompositor *subcompositor)
|
||||||
|
|
||||||
if (!IsGarbaged (subcompositor) && (age >= 0 && age < 3))
|
if (!IsGarbaged (subcompositor) && (age >= 0 && age < 3))
|
||||||
{
|
{
|
||||||
/* First, obtain a new region that is the intersection of
|
/* Next, composite every rectangle in the update region
|
||||||
the view with the global update region. */
|
intersecting with the target. */
|
||||||
pixman_region32_intersect_rect (&temp, &update_region,
|
boxes = pixman_region32_rectangles (&update_region, &nboxes);
|
||||||
view->abs_x, view->abs_y,
|
|
||||||
ViewWidth (view),
|
|
||||||
ViewHeight (view));
|
|
||||||
|
|
||||||
/* Next, composite every rectangle in that region. */
|
|
||||||
boxes = pixman_region32_rectangles (&temp, &nboxes);
|
|
||||||
|
|
||||||
for (i = 0; i < nboxes; ++i)
|
for (i = 0; i < nboxes; ++i)
|
||||||
RenderComposite (buffer, subcompositor->target, op,
|
{
|
||||||
/* src-x. */
|
/* Check if the rectangle is completely inside the
|
||||||
BoxStartX (boxes[i]) - view->abs_x,
|
region. We used to take the intersection of the
|
||||||
/* src-y. */
|
region, but that proved to be too slow. */
|
||||||
BoxStartY (boxes[i]) - view->abs_y,
|
|
||||||
/* dst-x. */
|
temp_boxes.x1 = view->abs_x;
|
||||||
BoxStartX (boxes[i]) - min_x + tx,
|
temp_boxes.y1 = view->abs_y;
|
||||||
/* dst-y. */
|
temp_boxes.x2 = view->abs_x + ViewWidth (view);
|
||||||
BoxStartY (boxes[i]) - min_y + ty,
|
temp_boxes.y2 = view->abs_y + ViewHeight (view);
|
||||||
/* width, height. */
|
|
||||||
BoxWidth (boxes[i]), BoxHeight (boxes[i]));
|
if (IntersectBoxes (&boxes[i], &temp_boxes, &temp_boxes))
|
||||||
|
RenderComposite (buffer, subcompositor->target, op,
|
||||||
|
/* src-x. */
|
||||||
|
BoxStartX (temp_boxes) - view->abs_x,
|
||||||
|
/* src-y. */
|
||||||
|
BoxStartY (temp_boxes) - view->abs_y,
|
||||||
|
/* dst-x. */
|
||||||
|
BoxStartX (temp_boxes) - min_x + tx,
|
||||||
|
/* dst-y. */
|
||||||
|
BoxStartY (temp_boxes) - min_y + ty,
|
||||||
|
/* width. */
|
||||||
|
BoxWidth (temp_boxes),
|
||||||
|
/* height. */
|
||||||
|
BoxHeight (temp_boxes));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue