diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-12-17 09:41:47 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-12-17 12:02:41 +0000 |
commit | 7a4d1136bd09bfd4d2657c0b1b64d553eeb6ed4f (patch) | |
tree | 1ff14694e334e5088d05a706208f06441e50af96 /src/sna | |
parent | dfe9d18f9f97a77ceeb410307010424c789c8bd1 (diff) |
sna/video: Pass along the video source offset
Fortunately nobody had yet noticed that all videos were assumed to play
with a matching src/dst origin.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna')
-rw-r--r-- | src/sna/gen3_render.c | 5 | ||||
-rw-r--r-- | src/sna/gen4_render.c | 5 | ||||
-rw-r--r-- | src/sna/gen5_render.c | 6 | ||||
-rw-r--r-- | src/sna/gen6_render.c | 5 | ||||
-rw-r--r-- | src/sna/gen7_render.c | 5 | ||||
-rw-r--r-- | src/sna/sna_render.h | 1 | ||||
-rw-r--r-- | src/sna/sna_video.c | 48 | ||||
-rw-r--r-- | src/sna/sna_video.h | 4 | ||||
-rw-r--r-- | src/sna/sna_video_textured.c | 11 |
9 files changed, 53 insertions, 37 deletions
diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index b9a1e01d..3ad8a8ad 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -3869,13 +3869,14 @@ gen3_render_video(struct sna *sna, RegionPtr dstRegion, short src_w, short src_h, short drw_w, short drw_h, + short dx, short dy, PixmapPtr pixmap) { struct sna_pixmap *priv = sna_pixmap(pixmap); BoxPtr pbox = REGION_RECTS(dstRegion); int nbox = REGION_NUM_RECTS(dstRegion); - int dxo = dstRegion->extents.x1; - int dyo = dstRegion->extents.y1; + int dxo = dstRegion->extents.x1 + dx; + int dyo = dstRegion->extents.y1 + dy; int width = dstRegion->extents.x2 - dxo; int height = dstRegion->extents.y2 - dyo; float src_scale_x, src_scale_y; diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c index 27cf9757..b05361de 100644 --- a/src/sna/gen4_render.c +++ b/src/sna/gen4_render.c @@ -1667,6 +1667,7 @@ gen4_render_video(struct sna *sna, RegionPtr dstRegion, short src_w, short src_h, short drw_w, short drw_h, + short dx, short dy, PixmapPtr pixmap) { struct sna_composite_op tmp; @@ -1724,8 +1725,8 @@ gen4_render_video(struct sna *sna, pix_yoff = 0; #endif - dxo = dstRegion->extents.x1; - dyo = dstRegion->extents.y1; + 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; diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c index 9b779b67..9b388786 100644 --- a/src/sna/gen5_render.c +++ b/src/sna/gen5_render.c @@ -1604,7 +1604,6 @@ static void gen5_video_bind_surfaces(struct sna *sna, int n_src, n; uint16_t offset; - src_surf_base[0] = 0; src_surf_base[1] = 0; src_surf_base[2] = frame->VBufOffset; @@ -1665,6 +1664,7 @@ gen5_render_video(struct sna *sna, RegionPtr dstRegion, short src_w, short src_h, short drw_w, short drw_h, + short dx, short dy, PixmapPtr pixmap) { struct sna_composite_op tmp; @@ -1722,8 +1722,8 @@ gen5_render_video(struct sna *sna, pix_yoff = 0; #endif - dxo = dstRegion->extents.x1; - dyo = dstRegion->extents.y1; + 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; diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index 970e9430..bb3bbbad 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -1976,6 +1976,7 @@ gen6_render_video(struct sna *sna, RegionPtr dstRegion, short src_w, short src_h, short drw_w, short drw_h, + short dx, short dy, PixmapPtr pixmap) { struct sna_composite_op tmp; @@ -2047,8 +2048,8 @@ gen6_render_video(struct sna *sna, pix_yoff = 0; #endif - dxo = dstRegion->extents.x1; - dyo = dstRegion->extents.y1; + 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; diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c index 65989ee9..06bef75e 100644 --- a/src/sna/gen7_render.c +++ b/src/sna/gen7_render.c @@ -2088,6 +2088,7 @@ gen7_render_video(struct sna *sna, RegionPtr dstRegion, short src_w, short src_h, short drw_w, short drw_h, + short dx, short dy, PixmapPtr pixmap) { struct sna_composite_op tmp; @@ -2159,8 +2160,8 @@ gen7_render_video(struct sna *sna, pix_yoff = 0; #endif - dxo = dstRegion->extents.x1; - dyo = dstRegion->extents.y1; + 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; diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h index a2281f47..ea1d781b 100644 --- a/src/sna/sna_render.h +++ b/src/sna/sna_render.h @@ -215,6 +215,7 @@ struct sna_render { RegionPtr dstRegion, short src_w, short src_h, short drw_w, short drw_h, + short dx, short dy, PixmapPtr pixmap); bool (*fill_boxes)(struct sna *sna, diff --git a/src/sna/sna_video.c b/src/sna/sna_video.c index 43454549..578a7597 100644 --- a/src/sna/sna_video.c +++ b/src/sna/sna_video.c @@ -166,14 +166,20 @@ sna_video_clip_helper(ScrnInfoPtr scrn, if (crtc_region != reg) RegionUninit(crtc_region); - frame->top = y1 >> 16; - frame->left = (x1 >> 16) & ~1; - frame->npixels = ALIGN(((x2 + 0xffff) >> 16), 2) - frame->left; + frame->src.x1 = x1 >> 16; + frame->src.y1 = y1 >> 16; + frame->src.x2 = (x2 + 0xffff) >> 16; + frame->src.y2 = (y2 + 0xffff) >> 16; + + frame->image.x1 = frame->src.x1 & ~1; + frame->image.x2 = ALIGN(frame->src.x1, 2); if (is_planar_fourcc(frame->id)) { - frame->top &= ~1; - frame->nlines = ALIGN(((y2 + 0xffff) >> 16), 2) - frame->top; - } else - frame->nlines = ((y2 + 0xffff) >> 16) - frame->top; + frame->image.y1 = frame->src.y1 & ~1; + frame->image.y2 = ALIGN(frame->src.y2, 2); + } else { + frame->image.y1 = frame->src.y1; + frame->image.y1 = frame->src.y2; + } return ret; } @@ -309,19 +315,19 @@ sna_copy_planar_data(struct sna_video *video, const uint8_t *src, uint8_t *dst) { uint8_t *d; - int w = frame->npixels; - int h = frame->nlines; + int w = frame->image.x2 - frame->image.x1; + int h = frame->image.y2 - frame->image.y1; int pitch; pitch = ALIGN(frame->width, 4); - sna_memcpy_plane(dst, src + frame->top * pitch + frame->left, + sna_memcpy_plane(dst, src + frame->image.y1 * pitch + frame->image.x1, h, w, frame->pitch[1], pitch, video->rotation); src += frame->height * pitch; /* move over Luma plane */ /* align to beginning of chroma planes */ pitch = ALIGN((frame->width >> 1), 0x4); - src += (frame->top >> 1) * pitch + (frame->left >> 1); + src += (frame->image.y1 >> 1) * pitch + (frame->image.x1 >> 1); w >>= 1; h >>= 1; @@ -349,11 +355,11 @@ sna_copy_packed_data(struct sna_video *video, { int pitch = frame->width << 1; const uint8_t *src, *s; - int w = frame->npixels; - int h = frame->nlines; + int w = frame->image.x2 - frame->image.x1; + int h = frame->image.y2 - frame->image.y1; int i, j; - src = buf + (frame->top * pitch) + (frame->left << 1); + src = buf + (frame->image.y1 * pitch) + (frame->image.x1 << 1); switch (video->rotation) { case RR_Rotate_0: @@ -376,7 +382,7 @@ sna_copy_packed_data(struct sna_video *video, src += pitch; } h >>= 1; - src = buf + (frame->top * pitch) + (frame->left << 1); + src = buf + (frame->image.y1 * pitch) + (frame->image.x1 << 1); for (i = 0; i < h; i += 2) { for (j = 0; j < w; j += 2) { /* Copy U */ @@ -412,7 +418,7 @@ sna_copy_packed_data(struct sna_video *video, src += pitch; } h >>= 1; - src = buf + (frame->top * pitch) + (frame->left << 1); + src = buf + (frame->image.y1 * pitch) + (frame->image.x1 << 1); for (i = 0; i < h; i += 2) { for (j = 0; j < w; j += 2) { /* Copy U */ @@ -449,7 +455,7 @@ sna_video_copy_data(struct sna *sna, }; if (pitch[0] == frame->pitch[0] && pitch[1] == frame->pitch[1] && - frame->top == 0 && frame->left == 0) { + (frame->image.y1 | frame->image.x1) == 0) { uint32_t len = (uint32_t)pitch[1]*frame->height + (uint32_t)pitch[0]*frame->height; @@ -477,8 +483,8 @@ sna_video_copy_data(struct sna *sna, if (frame->width*2 == frame->pitch[0]) { if (frame->bo) { kgem_bo_write(&sna->kgem, frame->bo, - buf + (2U*frame->top * frame->width) + (frame->left << 1), - 2U*frame->nlines*frame->width); + buf + (2U*frame->image.y1 * frame->width) + (frame->image.x1 << 1), + 2U*(frame->image.y2-frame->image.y1)*frame->width); } else { frame->bo = kgem_create_buffer(&sna->kgem, frame->size, KGEM_BUFFER_WRITE | KGEM_BUFFER_WRITE_INPLACE, @@ -487,8 +493,8 @@ sna_video_copy_data(struct sna *sna, return false; memcpy(dst, - buf + (frame->top * frame->width*2) + (frame->left << 1), - 2U*frame->nlines*frame->width); + buf + (frame->image.y1 * frame->width*2) + (frame->image.x1 << 1), + 2U*(frame->image.y2-frame->image.y1)*frame->width); } return true; } diff --git a/src/sna/sna_video.h b/src/sna/sna_video.h index 3ce72c00..774ddb8d 100644 --- a/src/sna/sna_video.h +++ b/src/sna/sna_video.h @@ -75,8 +75,8 @@ struct sna_video_frame { uint16_t pitch[2]; /* extents */ - uint16_t top, left; - uint16_t npixels, nlines; + BoxRec image; + BoxRec src; }; void sna_video_init(struct sna *sna, ScreenPtr screen); diff --git a/src/sna/sna_video_textured.c b/src/sna/sna_video_textured.c index 8db8b6fc..92073d97 100644 --- a/src/sna/sna_video_textured.c +++ b/src/sna/sna_video_textured.c @@ -267,6 +267,10 @@ sna_video_textured_put_image(ScrnInfoPtr scrn, } assert(kgem_bo_size(frame.bo) >= frame.size); + frame.image.x1 = 0; + frame.image.y1 = 0; + frame.image.x2 = frame.width; + frame.image.y2 = frame.height; } else { if (!sna_video_copy_data(sna, video, &frame, buf)) { DBG(("%s: failed to copy frame\n", __FUNCTION__)); @@ -284,9 +288,10 @@ 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, - pixmap)) { + 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; } else |