diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-12-18 15:14:00 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-12-18 15:14:00 +0000 |
commit | 551b400377ddc5eb1e89b8b5827a42e810c8d23d (patch) | |
tree | 4e407fb65a39987482cb1a159945662de0981fcb /src | |
parent | d96a226cc59c641c10153ae3a086a5138c852423 (diff) |
sna/video: Amalgamate the computation of source vs dest offsets
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/sna/gen3_render.c | 26 | ||||
-rw-r--r-- | src/sna/gen4_render.c | 17 | ||||
-rw-r--r-- | src/sna/gen5_render.c | 17 | ||||
-rw-r--r-- | src/sna/gen6_render.c | 17 | ||||
-rw-r--r-- | src/sna/gen7_render.c | 17 | ||||
-rw-r--r-- | src/sna/sna_video_textured.c | 6 |
6 files changed, 42 insertions, 58 deletions
diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index 3ad8a8ad..34dcd042 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -3875,10 +3875,8 @@ gen3_render_video(struct sna *sna, struct sna_pixmap *priv = sna_pixmap(pixmap); BoxPtr pbox = REGION_RECTS(dstRegion); int nbox = REGION_NUM_RECTS(dstRegion); - int dxo = dstRegion->extents.x1 + dx; - int dyo = dstRegion->extents.y1 + dy; - int width = dstRegion->extents.x2 - dxo; - int height = dstRegion->extents.y2 - dyo; + int width = dstRegion->extents.x2 - dstRegion->extents.x1; + int height = dstRegion->extents.y2 - dstRegion->extents.y1; float src_scale_x, src_scale_y; int pix_xoff, pix_yoff; struct kgem_bo *dst_bo; @@ -3904,8 +3902,8 @@ gen3_render_video(struct sna *sna, if (!dst_bo) return false; - pix_xoff = -dxo; - pix_yoff = -dyo; + pix_xoff = -dstRegion->extents.x1; + pix_yoff = -dstRegion->extents.y1; copy = 1; } else { width = pixmap->drawable.width; @@ -3930,7 +3928,7 @@ gen3_render_video(struct sna *sna, DBG(("%s: src offset=(%d, %d), scale=(%f, %f), dst offset=(%d, %d)\n", __FUNCTION__, - dxo, dyo, src_scale_x, src_scale_y, pix_xoff, pix_yoff)); + dx, dy, src_scale_x, src_scale_y, pix_xoff, pix_yoff)); gen3_video_get_batch(sna, dst_bo); gen3_emit_video_state(sna, video, frame, pixmap, @@ -3960,20 +3958,20 @@ gen3_render_video(struct sna *sna, /* bottom right */ OUT_BATCH_F(box_x2 + pix_xoff); OUT_BATCH_F(box_y2 + pix_yoff); - OUT_BATCH_F((box_x2 - dxo) * src_scale_x); - OUT_BATCH_F((box_y2 - dyo) * src_scale_y); + OUT_BATCH_F((box_x2 - dx) * src_scale_x); + OUT_BATCH_F((box_y2 - dy) * src_scale_y); /* bottom left */ OUT_BATCH_F(box_x1 + pix_xoff); OUT_BATCH_F(box_y2 + pix_yoff); - OUT_BATCH_F((box_x1 - dxo) * src_scale_x); - OUT_BATCH_F((box_y2 - dyo) * src_scale_y); + OUT_BATCH_F((box_x1 - dx) * src_scale_x); + OUT_BATCH_F((box_y2 - dy) * src_scale_y); /* top left */ OUT_BATCH_F(box_x1 + pix_xoff); OUT_BATCH_F(box_y1 + pix_yoff); - OUT_BATCH_F((box_x1 - dxo) * src_scale_x); - OUT_BATCH_F((box_y1 - dyo) * src_scale_y); + OUT_BATCH_F((box_x1 - dx) * src_scale_x); + OUT_BATCH_F((box_y1 - dy) * src_scale_y); } } while (nbox); @@ -3986,7 +3984,7 @@ gen3_render_video(struct sna *sna, pix_yoff = 0; #endif sna_blt_copy_boxes(sna, GXcopy, - dst_bo, -dxo, -dyo, + dst_bo, -dstRegion->extents.x1, -dstRegion->extents.y1, priv->gpu_bo, pix_xoff, pix_yoff, pixmap->drawable.bitsPerPixel, REGION_RECTS(dstRegion), diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c index b05361de..ee373789 100644 --- a/src/sna/gen4_render.c +++ b/src/sna/gen4_render.c @@ -1671,7 +1671,7 @@ gen4_render_video(struct sna *sna, PixmapPtr pixmap) { struct sna_composite_op tmp; - int nbox, dxo, dyo, pix_xoff, pix_yoff; + int nbox, pix_xoff, pix_yoff; float src_scale_x, src_scale_y; struct sna_pixmap *priv; BoxPtr box; @@ -1725,9 +1725,6 @@ gen4_render_video(struct sna *sna, pix_yoff = 0; #endif - dxo = dstRegion->extents.x1 + dx; - dyo = dstRegion->extents.y1 + dy; - /* Use normalized texture coordinates */ src_scale_x = ((float)src_w / frame->width) / (float)drw_w; src_scale_y = ((float)src_h / frame->height) / (float)drw_h; @@ -1745,16 +1742,16 @@ gen4_render_video(struct sna *sna, gen4_get_rectangles(sna, &tmp, 1, gen4_video_bind_surfaces); OUT_VERTEX(r.x2, r.y2); - OUT_VERTEX_F((box->x2 - dxo) * src_scale_x); - OUT_VERTEX_F((box->y2 - dyo) * src_scale_y); + OUT_VERTEX_F((box->x2 - dx) * src_scale_x); + OUT_VERTEX_F((box->y2 - dy) * src_scale_y); OUT_VERTEX(r.x1, r.y2); - OUT_VERTEX_F((box->x1 - dxo) * src_scale_x); - OUT_VERTEX_F((box->y2 - dyo) * src_scale_y); + OUT_VERTEX_F((box->x1 - dx) * src_scale_x); + OUT_VERTEX_F((box->y2 - dy) * src_scale_y); OUT_VERTEX(r.x1, r.y1); - OUT_VERTEX_F((box->x1 - dxo) * src_scale_x); - OUT_VERTEX_F((box->y1 - dyo) * src_scale_y); + OUT_VERTEX_F((box->x1 - dx) * src_scale_x); + OUT_VERTEX_F((box->y1 - dy) * src_scale_y); if (!DAMAGE_IS_ALL(priv->gpu_damage)) { sna_damage_add_box(&priv->gpu_damage, &r); diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c index 7f0e8fb5..3a9fd8c1 100644 --- a/src/sna/gen5_render.c +++ b/src/sna/gen5_render.c @@ -1668,7 +1668,7 @@ gen5_render_video(struct sna *sna, PixmapPtr pixmap) { struct sna_composite_op tmp; - int nbox, dxo, dyo, pix_xoff, pix_yoff; + int nbox, pix_xoff, pix_yoff; float src_scale_x, src_scale_y; struct sna_pixmap *priv; BoxPtr box; @@ -1722,9 +1722,6 @@ gen5_render_video(struct sna *sna, pix_yoff = 0; #endif - dxo = dstRegion->extents.x1 + dx; - dyo = dstRegion->extents.y1 + dy; - /* Use normalized texture coordinates */ src_scale_x = ((float)src_w / frame->width) / (float)drw_w; src_scale_y = ((float)src_h / frame->height) / (float)drw_h; @@ -1742,16 +1739,16 @@ gen5_render_video(struct sna *sna, gen5_get_rectangles(sna, &tmp, 1, gen5_video_bind_surfaces); OUT_VERTEX(r.x2, r.y2); - OUT_VERTEX_F((box->x2 - dxo) * src_scale_x); - OUT_VERTEX_F((box->y2 - dyo) * src_scale_y); + OUT_VERTEX_F((box->x2 - dx) * src_scale_x); + OUT_VERTEX_F((box->y2 - dy) * src_scale_y); OUT_VERTEX(r.x1, r.y2); - OUT_VERTEX_F((box->x1 - dxo) * src_scale_x); - OUT_VERTEX_F((box->y2 - dyo) * src_scale_y); + OUT_VERTEX_F((box->x1 - dx) * src_scale_x); + OUT_VERTEX_F((box->y2 - dy) * src_scale_y); OUT_VERTEX(r.x1, r.y1); - OUT_VERTEX_F((box->x1 - dxo) * src_scale_x); - OUT_VERTEX_F((box->y1 - dyo) * src_scale_y); + OUT_VERTEX_F((box->x1 - dx) * src_scale_x); + OUT_VERTEX_F((box->y1 - dy) * src_scale_y); if (!DAMAGE_IS_ALL(priv->gpu_damage)) { sna_damage_add_box(&priv->gpu_damage, &r); diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index 7f17c717..c6143631 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -1980,7 +1980,7 @@ gen6_render_video(struct sna *sna, PixmapPtr pixmap) { struct sna_composite_op tmp; - int nbox, dxo, dyo, pix_xoff, pix_yoff; + int nbox, pix_xoff, pix_yoff; float src_scale_x, src_scale_y; struct sna_pixmap *priv; unsigned filter; @@ -2048,9 +2048,6 @@ gen6_render_video(struct sna *sna, pix_yoff = 0; #endif - dxo = dstRegion->extents.x1 + dx; - dyo = dstRegion->extents.y1 + dy; - /* Use normalized texture coordinates */ src_scale_x = ((float)src_w / frame->width) / (float)drw_w; src_scale_y = ((float)src_h / frame->height) / (float)drw_h; @@ -2068,16 +2065,16 @@ gen6_render_video(struct sna *sna, gen6_get_rectangles(sna, &tmp, 1, gen6_emit_video_state); OUT_VERTEX(r.x2, r.y2); - OUT_VERTEX_F((box->x2 - dxo) * src_scale_x); - OUT_VERTEX_F((box->y2 - dyo) * src_scale_y); + OUT_VERTEX_F((box->x2 - dx) * src_scale_x); + OUT_VERTEX_F((box->y2 - dy) * src_scale_y); OUT_VERTEX(r.x1, r.y2); - OUT_VERTEX_F((box->x1 - dxo) * src_scale_x); - OUT_VERTEX_F((box->y2 - dyo) * src_scale_y); + OUT_VERTEX_F((box->x1 - dx) * src_scale_x); + OUT_VERTEX_F((box->y2 - dy) * src_scale_y); OUT_VERTEX(r.x1, r.y1); - OUT_VERTEX_F((box->x1 - dxo) * src_scale_x); - OUT_VERTEX_F((box->y1 - dyo) * src_scale_y); + OUT_VERTEX_F((box->x1 - dx) * src_scale_x); + OUT_VERTEX_F((box->y1 - dy) * src_scale_y); if (!DAMAGE_IS_ALL(priv->gpu_damage)) { sna_damage_add_box(&priv->gpu_damage, &r); diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c index aeace74c..4c67340f 100644 --- a/src/sna/gen7_render.c +++ b/src/sna/gen7_render.c @@ -2092,7 +2092,7 @@ gen7_render_video(struct sna *sna, PixmapPtr pixmap) { struct sna_composite_op tmp; - int nbox, dxo, dyo, pix_xoff, pix_yoff; + int nbox, pix_xoff, pix_yoff; float src_scale_x, src_scale_y; struct sna_pixmap *priv; unsigned filter; @@ -2160,9 +2160,6 @@ gen7_render_video(struct sna *sna, pix_yoff = 0; #endif - dxo = dstRegion->extents.x1 + dx; - dyo = dstRegion->extents.y1 + dy; - /* Use normalized texture coordinates */ src_scale_x = ((float)src_w / frame->width) / (float)drw_w; src_scale_y = ((float)src_h / frame->height) / (float)drw_h; @@ -2180,16 +2177,16 @@ gen7_render_video(struct sna *sna, gen7_get_rectangles(sna, &tmp, 1, gen7_emit_video_state); OUT_VERTEX(r.x2, r.y2); - OUT_VERTEX_F((box->x2 - dxo) * src_scale_x); - OUT_VERTEX_F((box->y2 - dyo) * src_scale_y); + OUT_VERTEX_F((box->x2 - dx) * src_scale_x); + OUT_VERTEX_F((box->y2 - dy) * src_scale_y); OUT_VERTEX(r.x1, r.y2); - OUT_VERTEX_F((box->x1 - dxo) * src_scale_x); - OUT_VERTEX_F((box->y2 - dyo) * src_scale_y); + OUT_VERTEX_F((box->x1 - dx) * src_scale_x); + OUT_VERTEX_F((box->y2 - dy) * src_scale_y); OUT_VERTEX(r.x1, r.y1); - OUT_VERTEX_F((box->x1 - dxo) * src_scale_x); - OUT_VERTEX_F((box->y1 - dyo) * src_scale_y); + OUT_VERTEX_F((box->x1 - dx) * src_scale_x); + OUT_VERTEX_F((box->y1 - dy) * src_scale_y); if (!DAMAGE_IS_ALL(priv->gpu_damage)) { sna_damage_add_box(&priv->gpu_damage, &r); diff --git a/src/sna/sna_video_textured.c b/src/sna/sna_video_textured.c index 70ea9319..cc35c57c 100644 --- a/src/sna/sna_video_textured.c +++ b/src/sna/sna_video_textured.c @@ -288,10 +288,8 @@ sna_video_textured_put_image(ScrnInfoPtr scrn, ret = Success; if (!sna->render.video(sna, video, &frame, clip, - src_w, src_h, - drw_w, drw_h, - drw_x - clip->extents.x1 - src_x, - drw_y - clip->extents.y1 - src_y, + src_w, src_h, drw_w, drw_h, + drw_x - src_x, drw_y - src_y, pixmap)) { DBG(("%s: failed to render video\n", __FUNCTION__)); ret = BadAlloc; |