[PATCH 2/3] gl/msaa: Support for texture sources

"Henry (Yu) Song - SISA" <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <3955FA337689574EB32F94B12A7E6E9E0B18D85E@ex10mail>
Add support for texture sources, by unforking _cairo_gl_composite_begin.
_cairo_gl_composite_begin_tristrip is now just a small wrapper. Also
properly emit the source texture coordinates when emitting tristrip
vertices.
---
src/cairo-gl-composite.c |   53 +++++++--------------------------------------
1 files changed, 9 insertions(+), 44 deletions(-)

diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
index 2f9697a..d3a7588 100644
--- a/src/cairo-gl-composite.c
+++ b/src/cairo-gl-composite.c
@@ -792,9 +792,12 @@ _cairo_gl_composite_emit_tristrip_vertex (cairo_gl_context_t   *ctx,
                               const cairo_point_t   *point)
{
     GLfloat *vb = (GLfloat *) (void *) &ctx->vb[ctx->vb_offset];
+    GLfloat x = _cairo_fixed_to_double (point->x);
+    GLfloat y = _cairo_fixed_to_double (point->y);
-    *vb++ = _cairo_fixed_to_double (point->x);
-    *vb++ = _cairo_fixed_to_double (point->y);
+    *vb++ = x;
+    *vb++ = y;
+    _cairo_gl_operand_emit (&ctx->operands[CAIRO_GL_TEX_SOURCE], &vb, x, y);
     ctx->vb_offset += ctx->vertex_size;
}
@@ -874,56 +877,18 @@ cairo_status_t
_cairo_gl_composite_begin_tristrip (cairo_gl_composite_t   *setup,
                           cairo_gl_context_t        **ctx_out)
{
-    cairo_gl_context_t *ctx;
     cairo_status_t status;
-    cairo_gl_shader_t *shader;
-    int src_size, dst_size;
-
-    cairo_gl_operand_t default_mask;
-    memset (&default_mask, 0, sizeof (cairo_gl_operand_t));
-
-    assert (setup->dst);
+    cairo_gl_context_t *ctx;
+    /* FIXME: Ideally we should only have to acquire the context once, but
+       this avoids a deeper integration with _cairo_gl_composite_begin. */
     status = _cairo_gl_context_acquire (setup->dst->base.device, &ctx);
     if (unlikely (status))
     return status;
-    *ctx_out = ctx;
     /* Finish any pending operations from other GL compositors. */
     if (! _cairo_gl_context_is_flushed (ctx))
     _cairo_gl_composite_flush (ctx);
-    glEnable (GL_BLEND);
-
-    status = _cairo_gl_get_shader_by_type (ctx,
-                                &setup->src,
-                                &default_mask,
-                                setup->spans,
-                                CAIRO_GL_SHADER_IN_NORMAL,
-                                           &shader);
-    if (unlikely (status)) {
-     status = _cairo_gl_context_release (ctx, status);
-     return status;
-    }
-
-    _cairo_gl_context_set_destination (ctx, setup->dst);
-
-    _cairo_gl_set_operator (ctx, setup->op, FALSE);
-    _cairo_gl_set_shader (ctx, shader);
-    _cairo_gl_composite_bind_to_shader (ctx, setup);
-
-    dst_size  = 2 * sizeof (GLfloat);
-    src_size  = _cairo_gl_operand_get_vertex_size (setup->src.type);
-
-    ctx->vertex_size = dst_size + src_size;
-
-    ctx->dispatch.BindBuffer (GL_ARRAY_BUFFER, ctx->vbo);
-    ctx->dispatch.VertexAttribPointer (CAIRO_GL_VERTEX_ATTRIB_INDEX, 2,
-                              GL_FLOAT, GL_FALSE, ctx->vertex_size, NULL);
-    ctx->dispatch.EnableVertexAttribArray (CAIRO_GL_VERTEX_ATTRIB_INDEX);
-
-    _cairo_gl_context_setup_operand (ctx, CAIRO_GL_TEX_SOURCE, &setup->src,
-                            ctx->vertex_size, dst_size);
-
-    return status;
+    return _cairo_gl_composite_begin (setup, ctx_out);
}
--
1.7.4.1


--

cairo mailing list

[email protected]<mailto:[email protected]>

http://lists.cairographics.org/mailman/listinfo/cairo

--
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.