diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2015-02-04 10:41:11 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2015-02-04 10:44:33 +0000 |
commit | d7bcb7bcbf96eae6f4cf131ac2bc166cd820b43e (patch) | |
tree | 2fea18175f30eceeb722189e64493a47737b116b /src/sna/sna_trapezoids_imprecise.c | |
parent | db629a38342883176d58357fa014176c9e45115d (diff) |
sna/trapezoids: Amalgamate adjacent lines
If we have two scanlines with identical extents and coverage, we can
amalgamate them into a set of multi-row boxes. For simplicity, we only
compare with the last box (assuming that the majority of such cases are
"rounded-rectangles" where we have a large vertical area with no
variation and can coalesce into a single box). This operates as a second
pass to the scanline converter itself coalescing pure-vertical regions.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/sna_trapezoids_imprecise.c')
-rw-r--r-- | src/sna/sna_trapezoids_imprecise.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/sna/sna_trapezoids_imprecise.c b/src/sna/sna_trapezoids_imprecise.c index 92db92d4..fc631f22 100644 --- a/src/sna/sna_trapezoids_imprecise.c +++ b/src/sna/sna_trapezoids_imprecise.c @@ -1722,7 +1722,21 @@ span_thread_box(struct sna *sna, const BoxRec *box, int coverage) { + struct span_thread_boxes *b = (struct span_thread_boxes *)op; + __DBG(("%s: %d -> %d @ %d\n", __FUNCTION__, box->x1, box->x2, coverage)); + if (b->num_boxes) { + struct sna_opacity_box *bb = &b->boxes[b->num_boxes-1]; + if (bb->box.x1 == box->x1 && + bb->box.x2 == box->x2 && + bb->box.y2 == box->y1 && + bb->alpha == AREA_TO_ALPHA(coverage)) { + bb->box.y2 = box->y2; + __DBG(("%s: contracted double row: %d -> %d\n", __func__, bb->box.y1, bb->box.y2)); + return; + } + } + span_thread_add_boxes(sna, op, box, 1, AREA_TO_ALPHA(coverage)); } @@ -1741,11 +1755,26 @@ span_thread_clipped_box(struct sna *sna, pixman_region_init_rects(®ion, box, 1); RegionIntersect(®ion, ®ion, clip); if (region_num_rects(®ion)) { + struct span_thread_boxes *b = (struct span_thread_boxes *)op; + + if (region.data == NULL && b->num_boxes) { + struct sna_opacity_box *bb = &b->boxes[b->num_boxes-1]; + if (bb->box.x1 == region.extents.x1 && + bb->box.x2 == region.extents.x2 && + bb->box.y2 == region.extents.y1 && + bb->alpha == AREA_TO_ALPHA(coverage)) { + bb->box.y2 = region.extents.y2; + __DBG(("%s: contracted double row: %d -> %d\n", __func__, bb->box.y1, bb->box.y2)); + goto out; + } + } + span_thread_add_boxes(sna, op, region_rects(®ion), region_num_rects(®ion), AREA_TO_ALPHA(coverage)); } +out: pixman_region_fini(®ion); } |