diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-07-22 22:14:52 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-07-22 22:41:58 +0100 |
commit | 9402bdcc13f7e96dfe527ff4a3da8d13a7870a02 (patch) | |
tree | 88b9ddc32974cd989f604388781750ba35dce661 | |
parent | b315e0ebb75d8391ebef7ebe53741a5e33c968bb (diff) |
sna/glyphs: Also discard the glyph mask for bitmaps with an opaque source
Though I expect all such glyphs to be caught by the non-overlapping
checks...
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/sna_glyphs.c | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c index 46fbf8d5..918b51c7 100644 --- a/src/sna/sna_glyphs.c +++ b/src/sna/sna_glyphs.c @@ -1248,6 +1248,44 @@ out: return format; } +static bool can_discard_mask(uint8_t op, PicturePtr src, PictFormatPtr mask, + int nlist, GlyphListPtr list, GlyphPtr *glyphs) +{ + PictFormatPtr g; + uint32_t color; + + if (nlist == 1 && list->len == 1) + return true; + + if (!op_is_bounded(op)) + return false; + + /* No glyphs overlap and we are not performing a mask conversion. */ + g = glyphs_format(nlist, list, glyphs); + if (mask == g) + return true; + + /* Otherwise if the glyphs are all bitmaps and we have an + * opaque source we can also render directly to the dst. + */ + if (g == NULL) { + while (nlist--) { + if (list->format->depth != 1) + return false; + + list++; + } + } else { + if (g->depth != 1) + return false; + } + + if (!sna_picture_is_solid(src, &color)) + return false; + + return color >> 24 == 0xff; +} + #if HAS_PIXMAN_GLYPHS static void glyphs_fallback(CARD8 op, @@ -1309,8 +1347,7 @@ glyphs_fallback(CARD8 op, RegionTranslate(®ion, -dst->pDrawable->x, -dst->pDrawable->y); if (mask_format && - (op_is_bounded(op) || (nlist == 1 && list->len == 1)) && - mask_format == glyphs_format(nlist, list, glyphs)) + can_discard_mask(op, src, mask_format, nlist, list, glyphs)) mask_format = NULL; cache = sna->render.glyph_cache; @@ -1674,8 +1711,7 @@ sna_glyphs(CARD8 op, /* Try to discard the mask for non-overlapping glyphs */ if (mask && dst->pCompositeClip->data == NULL && - (op_is_bounded(op) || (nlist == 1 && list->len == 1)) && - mask == glyphs_format(nlist, list, glyphs)) { + can_discard_mask(op, src, mask, nlist, list, glyphs)) { DBG(("%s: discarding mask\n", __FUNCTION__)); if (glyphs_to_dst(sna, op, src, dst, |