[cairo] [PATCH 2/3] gl/msaa: Support for texture sources
Henry (Yu) Song - SISA
hsong at sisa.samsung.com
Mon Oct 17 07:59:16 PDT 2011
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
cairo at cairographics.org<mailto:cairo at cairographics.org>
http://lists.cairographics.org/mailman/listinfo/cairo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20111017/ced46e6b/attachment-0001.htm>
More information about the cairo
mailing list