sna: Apply drawable offset to glyph bbox prior to checking for clipping
authorChris Wilson <chris@chris-wilson.co.uk>
Tue, 12 Nov 2013 00:05:11 +0000 (00:05 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Tue, 12 Nov 2013 08:41:49 +0000 (08:41 +0000)
This is a correction to

commit ec0866e86d365ae3fd9790b1b263d49fc4981220
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Wed Oct 16 22:39:54 2013 +0100

    sna/glyphs: Fix computation of extents for long strings

in order for us to correctly detect when we need to clip.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=71191
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
src/sna/sna_glyphs.c

index f2c1788..759e415 100644 (file)
@@ -517,18 +517,36 @@ static void apply_damage_clipped_to_dst(struct sna_composite_op *op,
        sna_damage_add_box(op->damage, &box);
 }
 
+static inline bool region_matches_pixmap(const RegionRec *r, PixmapPtr pixmap)
+{
+       return (r->extents.x2 - r->extents.x1 >= pixmap->drawable.width &&
+               r->extents.y2 - r->extents.y1 >= pixmap->drawable.height);
+}
+
 static inline bool clipped_glyphs(PicturePtr dst, int nlist, GlyphListPtr list, GlyphPtr *glyphs)
 {
        BoxRec box;
 
+       if (dst->pCompositeClip->data == NULL &&
+           region_matches_pixmap(dst->pCompositeClip,
+                                 get_drawable_pixmap(dst->pDrawable))) {
+               DBG(("%s: no, region matches drawable\n", __FUNCTION__));
+               return false;
+       }
+
        glyph_extents(nlist, list, glyphs, &box);
+
+       box.x1 += dst->pDrawable->x;
+       box.x2 += dst->pDrawable->x;
+       box.y1 += dst->pDrawable->y;
+       box.y2 += dst->pDrawable->y;
+
        DBG(("%s? glyph extents (%d, %d), (%d, %d), region (%d, %d), (%d, %d): %s\n",
             __FUNCTION__, box.x1, box.y1, box.x2, box.y2,
-            dst->pCompositeClip->extents.x1, dst->pCompositeClip->extents.y1, dst->pCompositeClip->extents.x2, dst->pCompositeClip->extents.y2,
-            (box.x1 < dst->pCompositeClip->extents.x1 ||
-             box.y1 < dst->pCompositeClip->extents.y1 ||
-             box.x2 > dst->pCompositeClip->extents.x2 ||
-             box.y2 > dst->pCompositeClip->extents.y2) ? "yes" : "no"));
+            dst->pCompositeClip->extents.x1, dst->pCompositeClip->extents.y1,
+            dst->pCompositeClip->extents.x2, dst->pCompositeClip->extents.y2,
+            pixman_region_contains_rectangle(dst->pCompositeClip,
+                                             &box) != PIXMAN_REGION_IN ?  "yes" : "no"));
 
        return pixman_region_contains_rectangle(dst->pCompositeClip,
                                                &box) != PIXMAN_REGION_IN;