diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-01-09 21:58:03 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-01-09 23:24:18 +0000 |
commit | d65b7f9cf46a48e3bfb37c0b75df55aa1e7bff41 (patch) | |
tree | 2bb19fadd87fdb6505f1dac35c845dbb792bde4e | |
parent | 09e54c553680cbc2f3b4319cdab0f3d1af1574a8 (diff) |
sna/blt: Rearrange to reduce a out-of-bounds copy to a clear
If we asked to use the BLT, try to avoid trigging a context switch for
a trivial case where we sample outside of a NONE source and so can
reduce the operation to a clear.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/sna_blt.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index dfc4b434..64fcd061 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -1595,6 +1595,24 @@ sna_blt_composite(struct sna *sna, return FALSE; } + if (!sna_transform_is_integer_translation(src->transform, &tx, &ty)) { + DBG(("%s: source transform is not an integer translation\n", + __FUNCTION__)); + return FALSE; + } + x += tx; + y += ty; + + if ((x > src->pDrawable->width || + y > src->pDrawable->height || + x + width < 0 || + y + height < 0) && + (!src->repeat || src->repeatType == RepeatNone)) { + DBG(("%s: source is outside of valid area, converting to clear\n", + __FUNCTION__)); + return prepare_blt_clear(sna, tmp); + } + alpha_fixup = 0; if (!(dst->format == src_format || dst->format == alphaless(src_format) || @@ -1607,14 +1625,6 @@ sna_blt_composite(struct sna *sna, return FALSE; } - if (!sna_transform_is_integer_translation(src->transform, &tx, &ty)) { - DBG(("%s: source transform is not an integer translation\n", - __FUNCTION__)); - return FALSE; - } - x += tx; - y += ty; - /* XXX tiling? */ if (x < 0 || y < 0 || x + width > src->pDrawable->width || |