Пример #1
0
void
renderer_copy(struct xa_context *r,
	      int dx,
	      int dy,
	      int sx,
	      int sy,
	      int width, int height, float src_width, float src_height)
{
    float s0, t0, s1, t1;
    float x0, y0, x1, y1;

    /* XXX: could put the texcoord scaling calculation into the vertex
     * shader.
     */
    s0 = sx / src_width;
    s1 = (sx + width) / src_width;
    t0 = sy / src_height;
    t1 = (sy + height) / src_height;

    x0 = dx;
    x1 = dx + width;
    y0 = dy;
    y1 = dy + height;

    /* draw quad */
    renderer_draw_conditional(r, 4 * 8);
    add_vertex_1tex(r, x0, y0, s0, t0);
    add_vertex_1tex(r, x1, y0, s1, t0);
    add_vertex_1tex(r, x1, y1, s1, t1);
    add_vertex_1tex(r, x0, y1, s0, t1);
}
Пример #2
0
static void
setup_vertex_data_yuv(struct xa_context *r,
		      float srcX,
		      float srcY,
		      float srcW,
		      float srcH,
		      float dstX,
		      float dstY,
		      float dstW, float dstH, struct xa_surface *srf[])
{
    float s0, t0, s1, t1;
    float spt0[2], spt1[2];
    struct pipe_resource *tex;

    spt0[0] = srcX;
    spt0[1] = srcY;
    spt1[0] = srcX + srcW;
    spt1[1] = srcY + srcH;

    tex = srf[0]->tex;
    s0 = spt0[0] / tex->width0;
    t0 = spt0[1] / tex->height0;
    s1 = spt1[0] / tex->width0;
    t1 = spt1[1] / tex->height0;

    /* 1st vertex */
    add_vertex_1tex(r, dstX, dstY, s0, t0);
    /* 2nd vertex */
    add_vertex_1tex(r, dstX + dstW, dstY, s1, t0);
    /* 3rd vertex */
    add_vertex_1tex(r, dstX + dstW, dstY + dstH, s1, t1);
    /* 4th vertex */
    add_vertex_1tex(r, dstX, dstY + dstH, s0, t1);
}
Пример #3
0
static struct pipe_buffer *
setup_vertex_data_yuv(struct xorg_renderer *r,
                      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;
   float spt0[2], spt1[2];

   spt0[0] = srcX;
   spt0[1] = srcY;
   spt1[0] = srcX + srcW;
   spt1[1] = srcY + srcH;

   s0 = spt0[0] / tex[0]->width[0];
   t0 = spt0[1] / tex[0]->height[0];
   s1 = spt1[0] / tex[0]->width[0];
   t1 = spt1[1] / tex[0]->height[0];

   /* 1st vertex */
   add_vertex_1tex(r, dstX, dstY, s0, t0);
   /* 2nd vertex */
   add_vertex_1tex(r, dstX + dstW, dstY,
                   s1, t0);
   /* 3rd vertex */
   add_vertex_1tex(r, dstX + dstW, dstY + dstH,
                   s1, t1);
   /* 4th vertex */
   add_vertex_1tex(r, dstX, dstY + dstH,
                   s0, t1);

   return renderer_buffer_create(r);
}
Пример #4
0
static void
add_vertex_data1(struct xa_context *r,
                 float srcX, float srcY,  float dstX, float dstY,
                 float width, float height,
                 struct pipe_resource *src, const float *src_matrix)
{
    float s0, t0, s1, t1, s2, t2, s3, t3;
    float pt0[2], pt1[2], pt2[2], pt3[2];

    pt0[0] = srcX;
    pt0[1] = srcY;
    pt1[0] = (srcX + width);
    pt1[1] = srcY;
    pt2[0] = (srcX + width);
    pt2[1] = (srcY + height);
    pt3[0] = srcX;
    pt3[1] = (srcY + height);

    if (src_matrix) {
	map_point((float *)src_matrix, pt0[0], pt0[1], &pt0[0], &pt0[1]);
	map_point((float *)src_matrix, pt1[0], pt1[1], &pt1[0], &pt1[1]);
	map_point((float *)src_matrix, pt2[0], pt2[1], &pt2[0], &pt2[1]);
	map_point((float *)src_matrix, pt3[0], pt3[1], &pt3[0], &pt3[1]);
    }

    s0 =  pt0[0] / src->width0;
    s1 =  pt1[0] / src->width0;
    s2 =  pt2[0] / src->width0;
    s3 =  pt3[0] / src->width0;
    t0 =  pt0[1] / src->height0;
    t1 =  pt1[1] / src->height0;
    t2 =  pt2[1] / src->height0;
    t3 =  pt3[1] / src->height0;

    /* 1st vertex */
    add_vertex_1tex(r, dstX, dstY, s0, t0);
    /* 2nd vertex */
    add_vertex_1tex(r, dstX + width, dstY, s1, t1);
    /* 3rd vertex */
    add_vertex_1tex(r, dstX + width, dstY + height, s2, t2);
    /* 4th vertex */
    add_vertex_1tex(r, dstX, dstY + height, s3, t3);
}