static INLINE void
-setup_vertex0(float vertex[2][4], float x, float y,
+setup_vertex0(float *vertex, float x, float y,
float color[4])
{
- vertex[0][0] = x;
- vertex[0][1] = y;
- vertex[0][2] = 0.f; /*z*/
- vertex[0][3] = 1.f; /*w*/
-
- vertex[1][0] = color[0]; /*r*/
- vertex[1][1] = color[1]; /*g*/
- vertex[1][2] = color[2]; /*b*/
- vertex[1][3] = color[3]; /*a*/
+ vertex[0] = x;
+ vertex[1] = y;
+ vertex[2] = 0.f; /*z*/
+ vertex[3] = 1.f; /*w*/
+
+ vertex[4] = color[0]; /*r*/
+ vertex[5] = color[1]; /*g*/
+ vertex[6] = color[2]; /*b*/
+ vertex[7] = color[3]; /*a*/
}
static INLINE void
-setup_vertex1(float vertex[2][4], float x, float y, float s, float t)
+setup_vertex1(float *vertex, float x, float y, float s, float t)
{
- vertex[0][0] = x;
- vertex[0][1] = y;
- vertex[0][2] = 0.f; /*z*/
- vertex[0][3] = 1.f; /*w*/
-
- vertex[1][0] = s; /*s*/
- vertex[1][1] = t; /*t*/
- vertex[1][2] = 0.f; /*r*/
- vertex[1][3] = 1.f; /*q*/
+ vertex[0] = x;
+ vertex[1] = y;
+ vertex[2] = 0.f; /*z*/
+ vertex[3] = 1.f; /*w*/
+
+ vertex[4] = s; /*s*/
+ vertex[5] = t; /*t*/
+ vertex[6] = 0.f; /*r*/
+ vertex[7] = 1.f; /*q*/
}
static struct pipe_buffer *
t1 = pt1[1] / src->height[0];
/* 1st vertex */
- setup_vertex1(r->vertices2[0], dstX, dstY, s0, t0);
+ setup_vertex1(r->vertices, dstX, dstY, s0, t0);
/* 2nd vertex */
- setup_vertex1(r->vertices2[1], dstX + width, dstY, s1, t0);
+ setup_vertex1(r->vertices + 2*4, dstX + width, dstY, s1, t0);
/* 3rd vertex */
- setup_vertex1(r->vertices2[2], dstX + width, dstY + height, s1, t1);
+ setup_vertex1(r->vertices + 4*4, dstX + width, dstY + height, s1, t1);
/* 4th vertex */
- setup_vertex1(r->vertices2[3], dstX, dstY + height, s0, t1);
+ setup_vertex1(r->vertices + 6*4, dstX, dstY + height, s0, t1);
return pipe_user_buffer_create(r->pipe->screen,
- r->vertices2,
- sizeof(r->vertices2));
+ r->vertices,
+ sizeof(float)*8*4);
}
static struct pipe_buffer *
float z)
{
/* 1st vertex */
- setup_vertex1(r->vertices2[0], x0, y0, s0, t0);
+ setup_vertex1(r->vertices, x0, y0, s0, t0);
/* 2nd vertex */
- setup_vertex1(r->vertices2[1], x1, y0, s1, t0);
+ setup_vertex1(r->vertices + 2*4, x1, y0, s1, t0);
/* 3rd vertex */
- setup_vertex1(r->vertices2[2], x1, y1, s1, t1);
+ setup_vertex1(r->vertices + 4*4, x1, y1, s1, t1);
/* 4th vertex */
- setup_vertex1(r->vertices2[3], x0, y1, s0, t1);
+ setup_vertex1(r->vertices + 6*4, x0, y1, s0, t1);
return pipe_user_buffer_create(r->pipe->screen,
- r->vertices2,
- sizeof(r->vertices2));
+ r->vertices,
+ sizeof(float)*8*4);
}
static INLINE void
-setup_vertex2(float vertex[3][4], float x, float y,
+setup_vertex2(float *vertex, float x, float y,
float s0, float t0, float s1, float t1)
{
- vertex[0][0] = x;
- vertex[0][1] = y;
- vertex[0][2] = 0.f; /*z*/
- vertex[0][3] = 1.f; /*w*/
-
- vertex[1][0] = s0; /*s*/
- vertex[1][1] = t0; /*t*/
- vertex[1][2] = 0.f; /*r*/
- vertex[1][3] = 1.f; /*q*/
-
- vertex[2][0] = s1; /*s*/
- vertex[2][1] = t1; /*t*/
- vertex[2][2] = 0.f; /*r*/
- vertex[2][3] = 1.f; /*q*/
+ vertex[0] = x;
+ vertex[1] = y;
+ vertex[2] = 0.f; /*z*/
+ vertex[3] = 1.f; /*w*/
+
+ vertex[4] = s0; /*s*/
+ vertex[5] = t0; /*t*/
+ vertex[6] = 0.f; /*r*/
+ vertex[7] = 1.f; /*q*/
+
+ vertex[8] = s1; /*s*/
+ vertex[9] = t1; /*t*/
+ vertex[10] = 0.f; /*r*/
+ vertex[11] = 1.f; /*q*/
}
static struct pipe_buffer *
mask_t1 = mpt1[1] / mask->height[0];
/* 1st vertex */
- setup_vertex2(r->vertices3[0], dstX, dstY,
+ setup_vertex2(r->vertices, dstX, dstY,
src_s0, src_t0, mask_s0, mask_t0);
/* 2nd vertex */
- setup_vertex2(r->vertices3[1], dstX + width, dstY,
+ setup_vertex2(r->vertices + 3*4, dstX + width, dstY,
src_s1, src_t0, mask_s1, mask_t0);
/* 3rd vertex */
- setup_vertex2(r->vertices3[2], dstX + width, dstY + height,
+ setup_vertex2(r->vertices + 6*4, dstX + width, dstY + height,
src_s1, src_t1, mask_s1, mask_t1);
/* 4th vertex */
- setup_vertex2(r->vertices3[3], dstX, dstY + height,
+ setup_vertex2(r->vertices + 9*4, dstX, dstY + height,
src_s0, src_t1, mask_s0, mask_t1);
return pipe_user_buffer_create(r->pipe->screen,
- r->vertices3,
- sizeof(r->vertices3));
+ r->vertices,
+ sizeof(float)*12*4);
}
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];
t1 = spt1[1] / tex[0]->height[0];
/* 1st vertex */
- setup_vertex1(r->vertices2[0], dstX, dstY, s0, t0);
+ setup_vertex1(r->vertices, dstX, dstY, s0, t0);
/* 2nd vertex */
- setup_vertex1(r->vertices2[1], dstX + width, dstY,
+ setup_vertex1(r->vertices + 2*4, dstX + dstW, dstY,
s1, t0);
/* 3rd vertex */
- setup_vertex1(r->vertices2[2], dstX + width, dstY + height,
+ setup_vertex1(r->vertices + 4*4, dstX + dstW, dstY + dstH,
s1, t1);
/* 4th vertex */
- setup_vertex1(r->vertices2[3], dstX, dstY + height,
+ setup_vertex1(r->vertices + 6*4, dstX, dstY + dstH,
s0, t1);
return pipe_user_buffer_create(r->pipe->screen,
- r->vertices2,
- sizeof(r->vertices2));
+ r->vertices,
+ sizeof(float)*8*4);
}
debug_printf("solid rect[(%d, %d), (%d, %d)], rgba[%f, %f, %f, %f]\n",
x0, y0, x1, y1, color[0], color[1], color[2], color[3]);*/
/* 1st vertex */
- setup_vertex0(r->vertices2[0], x0, y0, color);
+ setup_vertex0(r->vertices, x0, y0, color);
/* 2nd vertex */
- setup_vertex0(r->vertices2[1], x1, y0, color);
+ setup_vertex0(r->vertices + 2*4, x1, y0, color);
/* 3rd vertex */
- setup_vertex0(r->vertices2[2], x1, y1, color);
+ setup_vertex0(r->vertices + 4*4, x1, y1, color);
/* 4th vertex */
- setup_vertex0(r->vertices2[3], x0, y1, color);
+ setup_vertex0(r->vertices + 6*4, x0, y1, color);
buf = pipe_user_buffer_create(pipe->screen,
- r->vertices2,
- sizeof(r->vertices2));
+ r->vertices,
+ sizeof(float)*8*4);
if (buf) {
src_matrix, mask_matrix);
break;
case 3:
- buf = setup_vertex_data_yuv(r,
- pos[0], pos[1],
- pos[2], pos[3],
- width, height,
- textures);
- 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);
+ }
+}