summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-01-14 23:21:29 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2012-01-15 09:48:52 +0000
commitd9871f01d8c4584c1f39eb09b51d5461863934e9 (patch)
treed2a747637a2151a95d519303a0e0f0263ced3780
parent1d6030322e2c3bae87a0173a32fb8d341dea560c (diff)
sna/gen6: Check reused source for validity
Be sure the mask picture has a valid format even though it points to the same pixels as the valid source. And also be wary if the source was converted to a solid, but the mask is not. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/gen6_render.c49
1 files changed, 42 insertions, 7 deletions
diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c
index d25ece16..b155e864 100644
--- a/src/sna/gen6_render.c
+++ b/src/sna/gen6_render.c
@@ -311,6 +311,29 @@ static Bool gen6_check_dst_format(PictFormat format)
return FALSE;
}
+static bool gen6_check_format(PicturePtr p)
+{
+ switch (p->format) {
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+ case PICT_a8b8g8r8:
+ case PICT_x8b8g8r8:
+ case PICT_a2r10g10b10:
+ case PICT_x2r10g10b10:
+ case PICT_r8g8b8:
+ case PICT_r5g6b5:
+ case PICT_x1r5g5b5:
+ case PICT_a1r5g5b5:
+ case PICT_a8:
+ case PICT_a4r4g4b4:
+ case PICT_x4r4g4b4:
+ return true;
+ default:
+ DBG(("%s: unhandled format: %x\n", __FUNCTION__, p->format));
+ return false;
+ }
+}
+
static uint32_t gen6_get_dest_format_for_depth(int depth)
{
switch (depth) {
@@ -2064,6 +2087,10 @@ gen6_composite_picture(struct sna *sna,
return sna_render_picture_fixup(sna, picture, channel,
x, y, w, h, dst_x, dst_y);
+ if (!gen6_check_format(picture))
+ return sna_render_picture_fixup(sna, picture, channel,
+ x, y, w, h, dst_x, dst_y);
+
channel->repeat = picture->repeat ? picture->repeatType : RepeatNone;
channel->filter = picture->filter;
@@ -2085,9 +2112,6 @@ gen6_composite_picture(struct sna *sna,
channel->transform = picture->transform;
channel->card_format = gen6_get_card_format(picture->format);
- if (channel->card_format == (unsigned)-1)
- return sna_render_picture_convert(sna, picture, channel, pixmap,
- x, y, w, h, dst_x, dst_y);
if (too_large(pixmap->drawable.width, pixmap->drawable.height)) {
DBG(("%s: extracting from pixmap %dx%d\n", __FUNCTION__,
@@ -2231,7 +2255,7 @@ has_alphamap(PicturePtr p)
static bool
source_fallback(PicturePtr p)
{
- return has_alphamap(p) || is_gradient(p) || !gen6_check_filter(p) || !gen6_check_repeat(p);
+ return has_alphamap(p) || is_gradient(p) || !gen6_check_filter(p) || !gen6_check_repeat(p) || !gen6_check_format(p);
}
static bool
@@ -2319,16 +2343,24 @@ reuse_source(struct sna *sna,
PicturePtr src, struct sna_composite_channel *sc, int src_x, int src_y,
PicturePtr mask, struct sna_composite_channel *mc, int msk_x, int msk_y)
{
+ uint32_t color;
+
if (src_x != msk_x || src_y != msk_y)
return FALSE;
- if (mask == src) {
- DBG(("%s: mask is source picture\n", __FUNCTION__));
+ if (src == mask) {
+ DBG(("%s: mask is source\n", __FUNCTION__));
*mc = *sc;
- kgem_bo_reference(mc->bo);
+ mc->bo = kgem_bo_reference(mc->bo);
return TRUE;
}
+ if (sna_picture_is_solid(mask, &color))
+ return gen6_composite_solid_init(sna, mc, color);
+
+ if (sc->is_solid)
+ return FALSE;
+
if (src->pDrawable == NULL || mask->pDrawable != src->pDrawable)
return FALSE;
@@ -2346,6 +2378,9 @@ reuse_source(struct sna *sna,
if (!gen6_check_filter(mask))
return FALSE;
+ if (!gen6_check_format(mask))
+ return FALSE;
+
DBG(("%s: reusing source channel for mask with a twist\n",
__FUNCTION__));