summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-03-14 22:02:09 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2013-03-14 22:03:58 +0000
commit94cb10c3f2b9bbb6ae3c76faebe9fc88691224a9 (patch)
treeb56ca1d35a2cb6b25ee355a6d367635a356e6869
parentdad50881d545da665191c6681f2acd0ebc3ddbfc (diff)
sna/gen5+: Add missing float casts in computation of scaled src offsets
Without the casts, the division ends up as 0 rather than the fractional offset into the texture. The casts were missed in the claimed fix: commit 89038ddb96aabc4bc1f04402b2aca0ce546e8bf3 Author: Chris Wilson <chris@chris-wilson.co.uk> Date: Thu Feb 28 14:35:54 2013 +0000 sna/video: Correct scaling of source offsets Reported-by: Roman Elshin <roman.elshin@gmail.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=62343 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/gen4_render.c4
-rw-r--r--src/sna/gen5_render.c4
-rw-r--r--src/sna/gen6_render.c4
-rw-r--r--src/sna/gen7_render.c26
4 files changed, 30 insertions, 8 deletions
diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c
index 67f7b64e..e40a1b7b 100644
--- a/src/sna/gen4_render.c
+++ b/src/sna/gen4_render.c
@@ -1379,10 +1379,10 @@ gen4_render_video(struct sna *sna,
#endif
src_scale_x = (float)src_width / dst_width / frame->width;
- src_offset_x = frame->src.x1 / frame->width - dstRegion->extents.x1 * src_scale_x;
+ src_offset_x = (float)frame->src.x1 / frame->width - dstRegion->extents.x1 * src_scale_x;
src_scale_y = (float)src_height / dst_height / frame->height;
- src_offset_y = frame->src.y1 / frame->height - dstRegion->extents.y1 * src_scale_y;
+ src_offset_y = (float)frame->src.y1 / frame->height - dstRegion->extents.y1 * src_scale_y;
box = REGION_RECTS(dstRegion);
nbox = REGION_NUM_RECTS(dstRegion);
diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c
index 8c8a996f..8b50d22e 100644
--- a/src/sna/gen5_render.c
+++ b/src/sna/gen5_render.c
@@ -1363,10 +1363,10 @@ gen5_render_video(struct sna *sna,
#endif
src_scale_x = (float)src_width / dst_width / frame->width;
- src_offset_x = frame->src.x1 / frame->width - dstRegion->extents.x1 * src_scale_x;
+ src_offset_x = (float)frame->src.x1 / frame->width - dstRegion->extents.x1 * src_scale_x;
src_scale_y = (float)src_height / dst_height / frame->height;
- src_offset_y = frame->src.y1 / frame->height - dstRegion->extents.y1 * src_scale_y;
+ src_offset_y = (float)frame->src.y1 / frame->height - dstRegion->extents.y1 * src_scale_y;
box = REGION_RECTS(dstRegion);
nbox = REGION_NUM_RECTS(dstRegion);
diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c
index 8d15bd80..64eccc51 100644
--- a/src/sna/gen6_render.c
+++ b/src/sna/gen6_render.c
@@ -1651,10 +1651,10 @@ gen6_render_video(struct sna *sna,
#endif
src_scale_x = (float)src_width / dst_width / frame->width;
- src_offset_x = frame->src.x1 / frame->width - dstRegion->extents.x1 * src_scale_x;
+ src_offset_x = (float)frame->src.x1 / frame->width - dstRegion->extents.x1 * src_scale_x;
src_scale_y = (float)src_height / dst_height / frame->height;
- src_offset_y = frame->src.y1 / frame->height - dstRegion->extents.y1 * src_scale_y;
+ src_offset_y = (float)frame->src.y1 / frame->height - dstRegion->extents.y1 * src_scale_y;
box = REGION_RECTS(dstRegion);
nbox = REGION_NUM_RECTS(dstRegion);
diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c
index 4453797f..80fa872e 100644
--- a/src/sna/gen7_render.c
+++ b/src/sna/gen7_render.c
@@ -1792,17 +1792,39 @@ gen7_render_video(struct sna *sna,
pix_yoff = 0;
#endif
+ DBG(("%s: src=(%d, %d)x(%d, %d); frame=(%dx%d), dst=(%dx%d)\n",
+ __FUNCTION__,
+ frame->src.x1, frame->src.y1,
+ src_width, src_height,
+ dst_width, dst_height,
+ frame->width, frame->height));
+
src_scale_x = (float)src_width / dst_width / frame->width;
- src_offset_x = frame->src.x1 / frame->width - dstRegion->extents.x1 * src_scale_x;
+ src_offset_x = (float)frame->src.x1 / frame->width - dstRegion->extents.x1 * src_scale_x;
src_scale_y = (float)src_height / dst_height / frame->height;
- src_offset_y = frame->src.y1 / frame->height - dstRegion->extents.y1 * src_scale_y;
+ src_offset_y = (float)frame->src.y1 / frame->height - dstRegion->extents.y1 * src_scale_y;
+
+ DBG(("%s: scale=(%f, %f), offset=(%f, %f)\n",
+ __FUNCTION__,
+ src_scale_x, src_scale_y,
+ src_offset_x, src_offset_y));
box = REGION_RECTS(dstRegion);
nbox = REGION_NUM_RECTS(dstRegion);
while (nbox--) {
BoxRec r;
+ DBG(("%s: dst=(%d, %d), (%d, %d) + (%d, %d); src=(%f, %f), (%f, %f)\n",
+ __FUNCTION__,
+ box->x1, box->y1,
+ box->x2, box->y2,
+ pix_xoff, pix_yoff,
+ box->x1 * src_scale_x + src_offset_x,
+ box->y1 * src_scale_y + src_offset_y,
+ box->x2 * src_scale_x + src_offset_x,
+ box->y2 * src_scale_y + src_offset_y));
+
r.x1 = box->x1 + pix_xoff;
r.x2 = box->x2 + pix_xoff;
r.y1 = box->y1 + pix_yoff;