diff options
author | Junyan He <junyan.he@linux.intel.com> | 2012-06-04 03:18:40 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@linux.intel.com> | 2012-06-12 17:14:07 +0800 |
commit | 445ee22ac67976d8226f2ba743a3a6897781c404 (patch) | |
tree | cb37da779ae38312a4cb5b1aac1c747113b14afe | |
parent | 2f6aa7a8d3fcae266b174fd629131616ef09686a (diff) |
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>
-rw-r--r-- | src/glamor_gradient.c | 47 | ||||
-rw-r--r-- | src/glamor_trapezoid.c | 31 | ||||
-rw-r--r-- | src/glamor_utils.h | 57 |
3 files changed, 81 insertions, 54 deletions
diff --git a/src/glamor_gradient.c b/src/glamor_gradient.c index 09e33d7..e02c12c 100644 --- a/src/glamor_gradient.c +++ b/src/glamor_gradient.c @@ -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, diff --git a/src/glamor_trapezoid.c b/src/glamor_trapezoid.c index d9682ba..e65f7e3 100644 --- a/src/glamor_trapezoid.c +++ b/src/glamor_trapezoid.c @@ -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], diff --git a/src/glamor_utils.h b/src/glamor_utils.h index 18f7f3b..dfe8e56 100644 --- a/src/glamor_utils.h +++ b/src/glamor_utils.h @@ -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 { \ |