[Glamor] [PATCH 3/7] Modify the logic of gradient pixmap gl draw.
junyan.he at linux.intel.com
junyan.he at linux.intel.com
Mon May 7 17:44:43 PDT 2012
From: Junyan He <junyan.he at linux.intel.com>
Modify the logic of gradient pixmap gl draw. Use the
logic like composite before, but the gradient always
just have one rect to render, so no need to set the VB
and EB, replace it with just call glDrawArrays.
Signed-off-by: Junyan He <junyan.he at linux.intel.com>
---
src/glamor_gradient.c | 66 ++++++++++++++++++++++++------------------------
1 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/src/glamor_gradient.c b/src/glamor_gradient.c
index 234aa9e..a519b34 100644
--- a/src/glamor_gradient.c
+++ b/src/glamor_gradient.c
@@ -795,6 +795,8 @@ _glamor_gradient_set_pixmap_destination(ScreenPtr screen,
{
glamor_pixmap_private *pixmap_priv;
PixmapPtr pixmap = NULL;
+ glamor_gl_dispatch *dispatch = NULL;
+ float tmp;
pixmap = glamor_get_drawable_pixmap(dst_picture->pDrawable);
pixmap_priv = glamor_get_pixmap_private(pixmap);
@@ -803,13 +805,14 @@ _glamor_gradient_set_pixmap_destination(ScreenPtr screen,
return 0;
}
+ dispatch = glamor_get_dispatch(glamor_priv);
+
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
pixmap_priv_get_scale(pixmap_priv, xscale, yscale);
glamor_priv->has_source_coords = 1;
glamor_priv->has_mask_coords = 0;
- glamor_setup_composite_vbo(screen, 4*2);
DEBUGF("xscale = %f, yscale = %f,"
" x_source = %d, y_source = %d, width = %d, height = %d\n",
@@ -844,6 +847,31 @@ _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->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
+ GL_FALSE, 2 * sizeof(float), vertices);
+ dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
+ GL_FALSE, 2 * sizeof(float), tex_vertices);
+
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+
+ glamor_put_dispatch(glamor_priv);
+
return 1;
}
@@ -1208,22 +1236,8 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
DEBUGF("C1:(%f, %f) R1:%f\nC2:(%f, %f) R2:%f\nA = %f\n",
c1x, c1y, r1, c2x, c2y, r2, A_value);
- glamor_emit_composite_rect(screen, tex_vertices, NULL, vertices);
-
- if (glamor_priv->render_nr_verts) {
- if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
- dispatch->glUnmapBuffer(GL_ARRAY_BUFFER);
- else {
-
- dispatch->glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
- dispatch->glBufferData(GL_ARRAY_BUFFER,
- glamor_priv->vbo_offset,
- glamor_priv->vb, GL_DYNAMIC_DRAW);
- }
-
- dispatch->glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, NULL);
- }
-
+ /* Now rendering. */
+ dispatch->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
/* Do the clear logic.*/
if (stops_count > RADIAL_SMALL_STOPS) {
@@ -1576,22 +1590,8 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
dispatch->glUniform1f(pt_distance_uniform_location, pt_distance);
}
- /* set the transform matrix. */ /* Now rendering. */
- glamor_emit_composite_rect(screen, tex_vertices, NULL, vertices);
-
- if (glamor_priv->render_nr_verts) {
- if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
- dispatch->glUnmapBuffer(GL_ARRAY_BUFFER);
- else {
-
- dispatch->glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
- dispatch->glBufferData(GL_ARRAY_BUFFER,
- glamor_priv->vbo_offset,
- glamor_priv->vb, GL_DYNAMIC_DRAW);
- }
-
- dispatch->glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, NULL);
- }
+ /* Now rendering. */
+ dispatch->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
/* Do the clear logic.*/
if (stops_count > LINEAR_SMALL_STOPS) {
--
1.7.7.6
More information about the Glamor
mailing list