summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-01-03 21:20:09 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2012-01-03 21:35:03 +0000
commit4652a20de5fee0d5d1a8baadc4a93b6a93525564 (patch)
treef2804b7cd3f029d41c4d29c47230a221a0274670
parent777fcc9b11e8cbfe942aa6bf898749f552acb3cf (diff)
sna/gen3: Check for a non-NULL bo before incrementing its ref in reuse_source()
For gen3, we may reduce a source into a constant operator and so dispense with keeping a bo. When duplicated into the mask channel, we then need to be careful not to dereference the NULL pointer. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/gen3_render.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c
index 61742575..a4701dfb 100644
--- a/src/sna/gen3_render.c
+++ b/src/sna/gen3_render.c
@@ -2399,14 +2399,21 @@ 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)
{
- if (src->pDrawable == NULL || mask->pDrawable != src->pDrawable)
+ if (src_x != msk_x || src_y != msk_y)
return FALSE;
- DBG(("%s: mask reuses source drawable\n", __FUNCTION__));
+ if (mask == src) {
+ *mc = *sc;
+ if (mc->bo)
+ kgem_bo_reference(mc->bo);
+ return TRUE;
+ }
- if (src_x != msk_x || src_y != msk_y)
+ if ((src->pDrawable == NULL || mask->pDrawable != src->pDrawable))
return FALSE;
+ DBG(("%s: mask reuses source drawable\n", __FUNCTION__));
+
if (!sna_transform_equal(src->transform, mask->transform))
return FALSE;
@@ -2427,7 +2434,8 @@ reuse_source(struct sna *sna,
mc->filter = gen3_filter(mask->filter);
mc->pict_format = mask->format;
gen3_composite_channel_set_format(mc, mask->format);
- mc->bo = kgem_bo_reference(mc->bo);
+ if (mc->bo)
+ kgem_bo_reference(mc->bo);
return TRUE;
}