static struct pipe_buffer *
setup_vertex_data_yuv(struct xorg_renderer *r,
- float srcX, float srcY,
- float dstX, float dstY,
- float width, float height,
+ float srcX, float srcY, float srcW, float srcH,
+ float dstX, float dstY, float dstW, float dstH,
struct pipe_texture **tex)
{
float s0, t0, s1, t1;
spt0[0] = srcX;
spt0[1] = srcY;
- spt1[0] = srcX + width;
- spt1[1] = srcY + height;
+ spt1[0] = srcX + srcW;
+ spt1[1] = srcY + srcH;
s0 = spt0[0] / tex[0]->width[0];
t0 = spt0[1] / tex[0]->height[0];
/* 1st vertex */
setup_vertex1(r->vertices2[0], dstX, dstY, s0, t0);
/* 2nd vertex */
- setup_vertex1(r->vertices2[1], dstX + width, dstY,
+ setup_vertex1(r->vertices2[1], dstX + dstW, dstY,
s1, t0);
/* 3rd vertex */
- setup_vertex1(r->vertices2[2], dstX + width, dstY + height,
+ setup_vertex1(r->vertices2[2], dstX + dstW, dstY + dstH,
s1, t1);
/* 4th vertex */
- setup_vertex1(r->vertices2[3], dstX, dstY + height,
+ setup_vertex1(r->vertices2[3], dstX, dstY + dstH,
s0, t1);
src_matrix, mask_matrix);
break;
case 3:
- buf = setup_vertex_data_yuv(r,
- pos[0], pos[1],
- pos[2], pos[3],
- width, height,
- textures);
- num_textures = 1;
- break;
default:
debug_assert(!"Unsupported number of textures");
break;
pipe_buffer_reference(&buf, NULL);
}
}
+
+void renderer_draw_yuv(struct xorg_renderer *r,
+ int src_x, int src_y, int src_w, int src_h,
+ int dst_x, int dst_y, int dst_w, int dst_h,
+ struct pipe_texture **textures)
+{
+ struct pipe_context *pipe = r->pipe;
+ struct pipe_buffer *buf = 0;
+
+ buf = setup_vertex_data_yuv(r,
+ src_x, src_y, src_w, src_h,
+ dst_x, dst_y, dst_w, dst_h,
+ textures);
+
+ if (buf) {
+ const int num_attribs = 2; /*pos + tex coord*/
+
+ util_draw_vertex_buffer(pipe, buf, 0,
+ PIPE_PRIM_TRIANGLE_FAN,
+ 4, /* verts */
+ num_attribs); /* attribs/vert */
+
+ pipe_buffer_reference(&buf, NULL);
+ }
+}
}
static void
-draw_yuv(struct xorg_xv_port_priv *port, int src_x, int src_y,
- int dst_x, int dst_y,
- int w, int h)
+draw_yuv(struct xorg_xv_port_priv *port,
+ int src_x, int src_y, int src_w, int src_h,
+ int dst_x, int dst_y, int dst_w, int dst_h)
{
- int pos[4] = {src_x, src_y,
- dst_x, dst_y};
struct pipe_texture **textures = port->yuv[port->current_set];
- renderer_draw_textures(port->r,
- pos, w, h,
- textures,
- 3, /*bound samplers/textures */
- NULL, NULL /* no transformations */);
+ renderer_draw_yuv(port->r,
+ src_x, src_y, src_w, src_h,
+ dst_x, dst_y, dst_w, dst_h,
+ textures);
}
static void
display_video(ScrnInfoPtr pScrn, struct xorg_xv_port_priv *pPriv, int id,
RegionPtr dstRegion,
int src_x, int src_y, int src_w, int src_h,
- int dstX, int dstY,
- short width, short height,
+ int dstX, int dstY, int dst_w, int dst_h,
PixmapPtr pPixmap)
{
modesettingPtr ms = modesettingPTR(pScrn);
int box_y1 = pbox->y1;
int box_x2 = pbox->x2;
int box_y2 = pbox->y2;
+ float diff_x = (float)src_w / (float)dst_w;
+ float diff_y = (float)src_h / (float)dst_h;
+ int offset_x = box_x1 - dstX;
+ int offset_y = box_y1 - dstY;
+ int offset_w;
+ int offset_h;
x = box_x1;
y = box_y1;
w = box_x2 - box_x1;
h = box_y2 - box_y1;
- draw_yuv(pPriv, src_x, src_y, x, y, w, h);
+ offset_w = dst_w - w;
+ offset_h = dst_h - h;
+
+ draw_yuv(pPriv, src_x + offset_x*diff_x, src_y + offset_y*diff_y,
+ src_w - offset_w*diff_x, src_h - offset_h*diff_x,
+ x, y, w, h);
pbox++;
}