[cairo] [PATCH]: gl: Setup operands when the vertex size changes
Martin Robinson
mrobinson at igalia.com
Wed Feb 27 16:04:57 PST 2013
>From 8140b8b06e50595abbad87f6fa82daf4bf4b76ce Mon Sep 17 00:00:00 2001
From: Martin Robinson <mrobinson at igalia.com>
Date: Wed, 27 Feb 2013 15:40:16 -0800
Subject: [PATCH] gl: Setup operands when the vertex size changes
Previously _cairo_gl_composite_setup_vbo was overwriting the old context
vertex_size, while _cairo_gl_context_setup_operand was relying on it to
determine if the vertex size changed. Instead of a fragile ordering of
statements, pass whether the vertex size changed as an argument to enforce
the calling order via method parameters.
---
src/cairo-gl-composite.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
index c250e72..10597e1 100644
--- a/src/cairo-gl-composite.c
+++ b/src/cairo-gl-composite.c
@@ -209,15 +209,15 @@ static void
_cairo_gl_context_setup_operand (cairo_gl_context_t *ctx,
cairo_gl_tex_t tex_unit,
cairo_gl_operand_t *operand,
- unsigned int vertex_size,
- unsigned int vertex_offset)
+ unsigned int vertex_offset,
+ cairo_bool_t vertex_size_changed)
{
cairo_gl_dispatch_t *dispatch = &ctx->dispatch;
cairo_bool_t needs_setup;
/* XXX: we need to do setup when switching from shaders
* to no shaders (or back) */
- needs_setup = ctx->vertex_size != vertex_size;
+ needs_setup = vertex_size_changed;
needs_setup |= _cairo_gl_operand_needs_setup (&ctx->operands[tex_unit],
operand,
vertex_offset);
@@ -252,7 +252,7 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx,
if (! operand->texture.texgen) {
dispatch->VertexAttribPointer (CAIRO_GL_TEXCOORD0_ATTRIB_INDEX + tex_unit, 2,
- GL_FLOAT, GL_FALSE, vertex_size,
+ GL_FLOAT, GL_FALSE, ctx->vertex_size,
ctx->vb + vertex_offset);
dispatch->EnableVertexAttribArray (CAIRO_GL_TEXCOORD0_ATTRIB_INDEX + tex_unit);
}
@@ -268,7 +268,7 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx,
if (! operand->gradient.texgen) {
dispatch->VertexAttribPointer (CAIRO_GL_TEXCOORD0_ATTRIB_INDEX + tex_unit, 2,
- GL_FLOAT, GL_FALSE, vertex_size,
+ GL_FLOAT, GL_FALSE, ctx->vertex_size,
ctx->vb + vertex_offset);
dispatch->EnableVertexAttribArray (CAIRO_GL_TEXCOORD0_ATTRIB_INDEX + tex_unit);
}
@@ -523,12 +523,15 @@ _scissor_to_box (cairo_gl_surface_t *surface,
_scissor_to_doubles (surface, x1, y1, x2, y2);
}
-static void
+static cairo_bool_t
_cairo_gl_composite_setup_vbo (cairo_gl_context_t *ctx,
unsigned int size_per_vertex)
{
- if (ctx->vertex_size != size_per_vertex)
- _cairo_gl_composite_flush (ctx);
+ cairo_bool_t vertex_size_changed = ctx->vertex_size != size_per_vertex;
+ if (vertex_size_changed) {
+ ctx->vertex_size = size_per_vertex;
+ _cairo_gl_composite_flush (ctx);
+ }
if (_cairo_gl_context_is_flushed (ctx)) {
ctx->dispatch.VertexAttribPointer (CAIRO_GL_VERTEX_ATTRIB_INDEX, 2,
@@ -536,7 +539,8 @@ _cairo_gl_composite_setup_vbo (cairo_gl_context_t *ctx,
ctx->vb);
ctx->dispatch.EnableVertexAttribArray (CAIRO_GL_VERTEX_ATTRIB_INDEX);
}
- ctx->vertex_size = size_per_vertex;
+
+ return vertex_size_changed;
}
static void
@@ -669,6 +673,7 @@ _cairo_gl_set_operands_and_operator (cairo_gl_composite_t *setup,
cairo_status_t status;
cairo_gl_shader_t *shader;
cairo_bool_t component_alpha;
+ cairo_bool_t vertex_size_changed;
component_alpha =
setup->mask.type == CAIRO_GL_OPERAND_TEXTURE &&
--
1.7.10.4
More information about the cairo
mailing list