Add macro of vertex setting for triangle stripe
Add macro of vertex setting for triangle stripe draw, and make the code clear. Signed-off-by: Junyan He <junyan.he@linux.intel.com>
This commit is contained in:
parent
bd180be619
commit
0b0391765f
|
@ -806,25 +806,25 @@ _glamor_gradient_set_pixmap_destination(ScreenPtr screen,
|
|||
*xscale, *yscale, x_source, y_source,
|
||||
dst_picture->pDrawable->width, dst_picture->pDrawable->height);
|
||||
|
||||
glamor_set_normalize_vcoords(pixmap_priv, *xscale, *yscale,
|
||||
0, 0,
|
||||
(INT16)(dst_picture->pDrawable->width),
|
||||
(INT16)(dst_picture->pDrawable->height),
|
||||
glamor_priv->yInverted, vertices);
|
||||
glamor_set_normalize_vcoords_tri_strip(*xscale, *yscale,
|
||||
0, 0,
|
||||
(INT16)(dst_picture->pDrawable->width),
|
||||
(INT16)(dst_picture->pDrawable->height),
|
||||
glamor_priv->yInverted, vertices);
|
||||
|
||||
if (tex_normalize) {
|
||||
glamor_set_normalize_tcoords(pixmap_priv, *xscale, *yscale,
|
||||
x_source, y_source,
|
||||
(INT16)(dst_picture->pDrawable->width + x_source),
|
||||
(INT16)(dst_picture->pDrawable->height + y_source),
|
||||
glamor_priv->yInverted, tex_vertices);
|
||||
glamor_set_normalize_tcoords_tri_stripe(*xscale, *yscale,
|
||||
x_source, y_source,
|
||||
(INT16)(dst_picture->pDrawable->width + x_source),
|
||||
(INT16)(dst_picture->pDrawable->height + y_source),
|
||||
glamor_priv->yInverted, tex_vertices);
|
||||
} else {
|
||||
glamor_set_tcoords((INT16)(dst_picture->pDrawable->width),
|
||||
(INT16)(dst_picture->pDrawable->height),
|
||||
x_source, y_source,
|
||||
(INT16)(dst_picture->pDrawable->width) + x_source,
|
||||
(INT16)(dst_picture->pDrawable->height) + y_source,
|
||||
glamor_priv->yInverted, tex_vertices);
|
||||
glamor_set_tcoords_tri_strip((INT16)(dst_picture->pDrawable->width),
|
||||
(INT16)(dst_picture->pDrawable->height),
|
||||
x_source, y_source,
|
||||
(INT16)(dst_picture->pDrawable->width) + x_source,
|
||||
(INT16)(dst_picture->pDrawable->height) + y_source,
|
||||
glamor_priv->yInverted, tex_vertices);
|
||||
}
|
||||
|
||||
DEBUGF("vertices --> leftup : %f X %f, rightup: %f X %f,"
|
||||
|
@ -836,21 +836,6 @@ _glamor_gradient_set_pixmap_destination(ScreenPtr screen,
|
|||
tex_vertices[0], tex_vertices[1], tex_vertices[2], tex_vertices[3],
|
||||
tex_vertices[4], tex_vertices[5], tex_vertices[6], tex_vertices[7]);
|
||||
|
||||
/* Swap the vtx for triangle render. */
|
||||
tmp = vertices[4];
|
||||
vertices[4] = vertices[6];
|
||||
vertices[6] = tmp;
|
||||
tmp = vertices[5];
|
||||
vertices[5] = vertices[7];
|
||||
vertices[7] = tmp;
|
||||
|
||||
tmp = tex_vertices[4];
|
||||
tex_vertices[4] = tex_vertices[6];
|
||||
tex_vertices[6] = tmp;
|
||||
tmp = tex_vertices[5];
|
||||
tex_vertices[5] = tex_vertices[7];
|
||||
tex_vertices[7] = tmp;
|
||||
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
|
|
|
@ -490,39 +490,24 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
|
|||
xFixedToInt(ptrap->right.p2.y), ptrap->right.p2.y);
|
||||
|
||||
miTrapezoidBounds(1, ptrap, &one_trap_bound);
|
||||
glamor_set_tcoords((pixmap_priv->container->drawable.width),
|
||||
(pixmap_priv->container->drawable.height),
|
||||
(one_trap_bound.x1),
|
||||
(one_trap_bound.y1),
|
||||
(one_trap_bound.x2),
|
||||
(one_trap_bound.y2),
|
||||
glamor_priv->yInverted, tex_vertices);
|
||||
glamor_set_tcoords_tri_strip((pixmap_priv->container->drawable.width),
|
||||
(pixmap_priv->container->drawable.height),
|
||||
(one_trap_bound.x1),
|
||||
(one_trap_bound.y1),
|
||||
(one_trap_bound.x2),
|
||||
(one_trap_bound.y2),
|
||||
glamor_priv->yInverted, tex_vertices);
|
||||
|
||||
/* Need to rebase. */
|
||||
one_trap_bound.x1 -= bounds->x1;
|
||||
one_trap_bound.x2 -= bounds->x1;
|
||||
one_trap_bound.y1 -= bounds->y1;
|
||||
one_trap_bound.y2 -= bounds->y1;
|
||||
glamor_set_normalize_vcoords(xscale, yscale,
|
||||
glamor_set_normalize_vcoords_tri_strip(xscale, yscale,
|
||||
one_trap_bound.x1, one_trap_bound.y1,
|
||||
one_trap_bound.x2, one_trap_bound.y2,
|
||||
glamor_priv->yInverted, vertices);
|
||||
|
||||
/* Swap the vtx for triangle render. */
|
||||
tmp = vertices[4];
|
||||
vertices[4] = vertices[6];
|
||||
vertices[6] = tmp;
|
||||
tmp = vertices[5];
|
||||
vertices[5] = vertices[7];
|
||||
vertices[7] = tmp;
|
||||
|
||||
tmp = tex_vertices[4];
|
||||
tex_vertices[4] = tex_vertices[6];
|
||||
tex_vertices[6] = tmp;
|
||||
tmp = tex_vertices[5];
|
||||
tex_vertices[5] = tex_vertices[7];
|
||||
tex_vertices[7] = tmp;
|
||||
|
||||
DEBUGF("vertices --> leftup : %f X %f, rightup: %f X %f,"
|
||||
"rightbottom: %f X %f, leftbottom : %f X %f\n",
|
||||
vertices[0], vertices[1], vertices[2], vertices[3],
|
||||
|
|
|
@ -481,6 +481,25 @@
|
|||
tx2, ty2, yInverted, vertices); \
|
||||
} while(0)
|
||||
|
||||
#define glamor_set_normalize_tcoords_tri_stripe(xscale, yscale, \
|
||||
x1, y1, x2, y2, \
|
||||
yInverted, vertices) \
|
||||
do { \
|
||||
(vertices)[0] = t_from_x_coord_x(xscale, x1); \
|
||||
(vertices)[2] = t_from_x_coord_x(xscale, x2); \
|
||||
(vertices)[6] = (vertices)[2]; \
|
||||
(vertices)[4] = (vertices)[0]; \
|
||||
if (yInverted) { \
|
||||
(vertices)[1] = t_from_x_coord_y_inverted(yscale, y1); \
|
||||
(vertices)[7] = t_from_x_coord_y_inverted(yscale, y2); \
|
||||
} \
|
||||
else { \
|
||||
(vertices)[1] = t_from_x_coord_y(yscale, y1); \
|
||||
(vertices)[7] = t_from_x_coord_y(yscale, y2); \
|
||||
} \
|
||||
(vertices)[3] = (vertices)[1]; \
|
||||
(vertices)[5] = (vertices)[7]; \
|
||||
} while(0)
|
||||
|
||||
#define glamor_set_tcoords(width, height, x1, y1, x2, y2, \
|
||||
yInverted, vertices) \
|
||||
|
@ -501,6 +520,24 @@
|
|||
(vertices)[7] = (vertices)[5]; \
|
||||
} while(0)
|
||||
|
||||
#define glamor_set_tcoords_tri_strip(width, height, x1, y1, x2, y2, \
|
||||
yInverted, vertices) \
|
||||
do { \
|
||||
(vertices)[0] = (x1); \
|
||||
(vertices)[2] = (x2); \
|
||||
(vertices)[6] = (vertices)[2]; \
|
||||
(vertices)[4] = (vertices)[0]; \
|
||||
if (yInverted) { \
|
||||
(vertices)[1] = (y1); \
|
||||
(vertices)[7] = (y2); \
|
||||
} \
|
||||
else { \
|
||||
(vertices)[1] = height - (y2); \
|
||||
(vertices)[7] = height - (y1); \
|
||||
} \
|
||||
(vertices)[3] = (vertices)[1]; \
|
||||
(vertices)[5] = (vertices)[7]; \
|
||||
} while(0)
|
||||
|
||||
#define glamor_set_normalize_vcoords(priv, xscale, yscale, \
|
||||
x1, y1, x2, y2, \
|
||||
|
@ -524,6 +561,26 @@
|
|||
(vertices)[7] = (vertices)[5]; \
|
||||
} while(0)
|
||||
|
||||
#define glamor_set_normalize_vcoords_tri_strip(xscale, yscale, \
|
||||
x1, y1, x2, y2, \
|
||||
yInverted, vertices) \
|
||||
do { \
|
||||
(vertices)[0] = v_from_x_coord_x(xscale, x1); \
|
||||
(vertices)[2] = v_from_x_coord_x(xscale, x2); \
|
||||
(vertices)[6] = (vertices)[2]; \
|
||||
(vertices)[4] = (vertices)[0]; \
|
||||
if (yInverted) { \
|
||||
(vertices)[1] = v_from_x_coord_y_inverted(yscale, y1); \
|
||||
(vertices)[7] = v_from_x_coord_y_inverted(yscale, y2); \
|
||||
} \
|
||||
else { \
|
||||
(vertices)[1] = v_from_x_coord_y(yscale, y1); \
|
||||
(vertices)[7] = v_from_x_coord_y(yscale, y2); \
|
||||
} \
|
||||
(vertices)[3] = (vertices)[1]; \
|
||||
(vertices)[5] = (vertices)[7]; \
|
||||
} while(0)
|
||||
|
||||
#define glamor_set_normalize_pt(xscale, yscale, x, y, \
|
||||
yInverted, pt) \
|
||||
do { \
|
||||
|
|
Loading…
Reference in New Issue
Block a user