summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2010-05-28 20:45:52 +0200
committerBenjamin Otte <otte@redhat.com>2010-06-07 13:37:48 +0200
commit0fc6f08981604ffdd0109362dcbbd9773501cd9a (patch)
treed2417fbe77dc517caa3bd6b60cb140276bff7927
parent2971ca049881298cd171cf27cd3beb49d2c0572f (diff)
gl: Make _shader_by_type() a getter
And refactor code to do the current_shader assigning itself.
-rw-r--r--src/cairo-gl-composite.c16
-rw-r--r--src/cairo-gl-private.h5
-rw-r--r--src/cairo-gl-shaders.c13
3 files changed, 22 insertions, 12 deletions
diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
index edab8b3b..d364e57b 100644
--- a/src/cairo-gl-composite.c
+++ b/src/cairo-gl-composite.c
@@ -938,16 +938,19 @@ _cairo_gl_composite_begin_component_alpha (cairo_gl_context_t *ctx,
* lets two values come out of the shader and into the blend unit.
*/
if (setup->op == CAIRO_OPERATOR_OVER) {
+ cairo_gl_shader_t *pre_shader;
setup->op = CAIRO_OPERATOR_ADD;
- status = _cairo_gl_set_shader_by_type (ctx,
+ status = _cairo_gl_get_shader_by_type (ctx,
setup->src.type,
setup->mask.type,
- CAIRO_GL_SHADER_IN_CA_SOURCE_ALPHA);
+ CAIRO_GL_SHADER_IN_CA_SOURCE_ALPHA,
+ &pre_shader);
if (unlikely (status))
return status;
+ _cairo_gl_set_shader (ctx, pre_shader);
_cairo_gl_composite_bind_to_shader (ctx, setup);
- ctx->pre_shader = ctx->current_shader;
+ ctx->pre_shader = pre_shader;
}
return CAIRO_STATUS_SUCCESS;
@@ -961,6 +964,7 @@ _cairo_gl_composite_begin (cairo_gl_composite_t *setup,
cairo_gl_context_t *ctx;
cairo_status_t status;
cairo_bool_t component_alpha;
+ cairo_gl_shader_t *shader;
assert (setup->dst);
@@ -981,11 +985,12 @@ _cairo_gl_composite_begin (cairo_gl_composite_t *setup,
goto FAIL;
}
- status = _cairo_gl_set_shader_by_type (ctx,
+ status = _cairo_gl_get_shader_by_type (ctx,
setup->src.type,
setup->mask.type,
component_alpha ? CAIRO_GL_SHADER_IN_CA_SOURCE
- : CAIRO_GL_SHADER_IN_NORMAL);
+ : CAIRO_GL_SHADER_IN_NORMAL,
+ &shader);
if (unlikely (status)) {
ctx->pre_shader = NULL;
goto FAIL;
@@ -1004,6 +1009,7 @@ _cairo_gl_composite_begin (cairo_gl_composite_t *setup,
setup->op,
component_alpha);
+ _cairo_gl_set_shader (ctx, shader);
_cairo_gl_composite_bind_to_shader (ctx, setup);
glBindBufferARB (GL_ARRAY_BUFFER_ARB, ctx->vbo);
diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
index f82a45cc..511f6545 100644
--- a/src/cairo-gl-private.h
+++ b/src/cairo-gl-private.h
@@ -399,10 +399,11 @@ cairo_private void
_cairo_gl_context_fini_shaders (cairo_gl_context_t *ctx);
cairo_private cairo_status_t
-_cairo_gl_set_shader_by_type (cairo_gl_context_t *ctx,
+_cairo_gl_get_shader_by_type (cairo_gl_context_t *ctx,
cairo_gl_operand_type_t source,
cairo_gl_operand_type_t mask,
- cairo_gl_shader_in_t in);
+ cairo_gl_shader_in_t in,
+ cairo_gl_shader_t **shader);
cairo_private void
_cairo_gl_shader_bind_float (cairo_gl_context_t *ctx,
diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c
index c61f73fb..b39c5000 100644
--- a/src/cairo-gl-shaders.c
+++ b/src/cairo-gl-shaders.c
@@ -924,17 +924,20 @@ _cairo_gl_set_shader (cairo_gl_context_t *ctx,
}
cairo_status_t
-_cairo_gl_set_shader_by_type (cairo_gl_context_t *ctx,
+_cairo_gl_get_shader_by_type (cairo_gl_context_t *ctx,
cairo_gl_operand_type_t source,
cairo_gl_operand_type_t mask,
- cairo_gl_shader_in_t in)
+ cairo_gl_shader_in_t in,
+ cairo_gl_shader_t **shader)
{
cairo_shader_cache_entry_t lookup, *entry;
char *fs_source;
cairo_status_t status;
- if (ctx->shader_impl == NULL)
+ if (ctx->shader_impl == NULL) {
+ *shader = NULL;
return CAIRO_STATUS_SUCCESS;
+ }
lookup.src = source;
lookup.mask = mask;
@@ -946,7 +949,7 @@ _cairo_gl_set_shader_by_type (cairo_gl_context_t *ctx,
entry = _cairo_cache_lookup (&ctx->shaders, &lookup.base);
if (entry) {
assert (entry->shader.program);
- _cairo_gl_set_shader (ctx, &entry->shader);
+ *shader = &entry->shader;
return CAIRO_STATUS_SUCCESS;
}
@@ -988,7 +991,7 @@ _cairo_gl_set_shader_by_type (cairo_gl_context_t *ctx,
return status;
}
- _cairo_gl_set_shader (ctx, &entry->shader);
+ *shader = &entry->shader;
return CAIRO_STATUS_SUCCESS;
}