summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-03-07 15:45:21 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2012-03-07 18:47:58 +0000
commit72a7538d4e7bcf0bd7455d9e67d8751e17739e6c (patch)
treeb07a0a3d6aa71353fb950b990cdfe31898c72ed5
parent34fe3cbb316c36c7022735cf9b03d8b655e04434 (diff)
sna: Convolution filter fixes
A couple of typos made the convolution filter explode rather than convolve. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/gen4_render.c5
-rw-r--r--src/sna/sna_render.c21
2 files changed, 18 insertions, 8 deletions
diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c
index 404e12b0..c3a82a33 100644
--- a/src/sna/gen4_render.c
+++ b/src/sna/gen4_render.c
@@ -681,7 +681,10 @@ static uint32_t gen4_check_filter(PicturePtr picture)
case PictFilterBilinear:
return TRUE;
default:
- DBG(("%s: unknown filter: %d\n", __FUNCTION__, picture->filter));
+ DBG(("%s: unknown filter: %s [%d]\n",
+ __FUNCTION__,
+ PictureGetFilterName(picture->filter),
+ picture->filter));
return FALSE;
}
}
diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c
index a3459629..74c04afd 100644
--- a/src/sna/sna_render.c
+++ b/src/sna/sna_render.c
@@ -1234,15 +1234,18 @@ sna_render_picture_convolve(struct sna *sna,
PixmapPtr pixmap;
PicturePtr tmp;
pixman_fixed_t *params = picture->filter_params;
- int x_off = (params[0] - pixman_fixed_1) >> 1;
- int y_off = (params[1] - pixman_fixed_1) >> 1;
+ int x_off = -pixman_fixed_to_int((params[0] - pixman_fixed_1) >> 1);
+ int y_off = -pixman_fixed_to_int((params[1] - pixman_fixed_1) >> 1);
int cw = pixman_fixed_to_int(params[0]);
int ch = pixman_fixed_to_int(params[1]);
int i, j, error, depth;
+ struct kgem_bo *bo;
/* Lame multi-pass accumulation implementation of a general convolution
* that works everywhere.
*/
+ DBG(("%s: origin=(%d,%d) kernel=%dx%d, size=%dx%d\n",
+ __FUNCTION__, x_off, y_off, cw, ch, w, h));
assert(picture->pDrawable);
assert(picture->filter == PictFilterConvolution);
@@ -1267,8 +1270,10 @@ sna_render_picture_convolve(struct sna *sna,
if (tmp == NULL)
return 0;
- if (!sna->render.fill_one(sna, pixmap, sna_pixmap_get_bo(pixmap), 0,
- 0, 0, w, h, GXclear)) {
+ ValidatePicture(tmp);
+
+ bo = sna_pixmap_get_bo(pixmap);
+ if (!sna->render.clear(sna, pixmap, bo)) {
FreePicture(tmp, 0);
return 0;
}
@@ -1282,6 +1287,8 @@ sna_render_picture_convolve(struct sna *sna,
color.alpha = *params++;
color.red = color.green = color.blue = 0;
+ DBG(("%s: (%d, %d), alpha=%x\n",
+ __FUNCTION__, i,j, color.alpha));
if (color.alpha <= 0x00ff)
continue;
@@ -1291,7 +1298,7 @@ sna_render_picture_convolve(struct sna *sna,
sna_composite(PictOpAdd, picture, alpha, tmp,
x, y,
0, 0,
- x_off-i, y_off-j,
+ x_off+i, y_off+j,
w, h);
FreePicture(alpha, 0);
}
@@ -1309,7 +1316,7 @@ sna_render_picture_convolve(struct sna *sna,
channel->scale[1] = 1.f / h;
channel->offset[0] = -dst_x;
channel->offset[1] = -dst_y;
- channel->bo = kgem_bo_reference(sna_pixmap_get_bo(pixmap));
+ channel->bo = kgem_bo_reference(bo); /* transfer ownership */
FreePicture(tmp, 0);
return 1;
@@ -1423,7 +1430,7 @@ sna_render_picture_fixup(struct sna *sna,
DBG(("%s: convolution\n", __FUNCTION__));
if (picture->pDrawable && is_gpu(picture->pDrawable)) {
return sna_render_picture_convolve(sna, picture, channel,
- x, y, w, y, dst_x, dst_y);
+ x, y, w, h, dst_x, dst_y);
}
goto do_fixup;