summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2010-06-02 18:11:04 +0200
committerBenjamin Otte <otte@redhat.com>2010-06-07 13:37:48 +0200
commit1f249064cc5c19a39ffe0faaa8825c8f8b6a2175 (patch)
tree928e87e0ee922ff74d0dfe2ab65adaa62a9a1a37
parentf66500d8b052251ea3ce06f06d2fa4c8dec2ff3b (diff)
gl: rework _cairo_gl_set_operator()
1) store the current operator. This will be useful later to check if the operator changed. 2) pass the context instead of the destination as first argument. The destination is known to be the current target.
-rw-r--r--src/cairo-gl-composite.c16
-rw-r--r--src/cairo-gl-device.c3
-rw-r--r--src/cairo-gl-private.h1
3 files changed, 13 insertions, 7 deletions
diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
index ef0c2ac5..04701576 100644
--- a/src/cairo-gl-composite.c
+++ b/src/cairo-gl-composite.c
@@ -830,8 +830,9 @@ _cairo_gl_set_src_alpha (cairo_gl_context_t *ctx,
}
static void
-_cairo_gl_set_operator (cairo_gl_surface_t *dst, cairo_operator_t op,
- cairo_bool_t component_alpha)
+_cairo_gl_set_operator (cairo_gl_context_t *ctx,
+ cairo_operator_t op,
+ cairo_bool_t component_alpha)
{
struct {
GLenum src;
@@ -856,6 +857,7 @@ _cairo_gl_set_operator (cairo_gl_surface_t *dst, cairo_operator_t op,
GLenum src_factor, dst_factor;
assert (op < ARRAY_LENGTH (blend_factors));
+ ctx->current_operator = op;
src_factor = blend_factors[op].src;
dst_factor = blend_factors[op].dst;
@@ -864,7 +866,7 @@ _cairo_gl_set_operator (cairo_gl_surface_t *dst, cairo_operator_t op,
* due to texture filtering of GL_CLAMP_TO_BORDER. So fix those
* bits in that case.
*/
- if (dst->base.content == CAIRO_CONTENT_COLOR) {
+ if (ctx->current_target->base.content == CAIRO_CONTENT_COLOR) {
if (src_factor == GL_ONE_MINUS_DST_ALPHA)
src_factor = GL_ZERO;
if (src_factor == GL_DST_ALPHA)
@@ -878,7 +880,7 @@ _cairo_gl_set_operator (cairo_gl_surface_t *dst, cairo_operator_t op,
dst_factor = GL_SRC_COLOR;
}
- if (dst->base.content == CAIRO_CONTENT_ALPHA) {
+ if (ctx->current_target->base.content == CAIRO_CONTENT_ALPHA) {
glBlendFuncSeparate (GL_ZERO, GL_ZERO, src_factor, dst_factor);
} else {
glBlendFunc (src_factor, dst_factor);
@@ -1063,7 +1065,7 @@ _cairo_gl_composite_begin (cairo_gl_composite_t *setup,
}
_cairo_gl_context_set_destination (ctx, setup->dst);
- _cairo_gl_set_operator (setup->dst,
+ _cairo_gl_set_operator (ctx,
setup->op,
component_alpha);
@@ -1110,13 +1112,13 @@ _cairo_gl_composite_draw (cairo_gl_context_t *ctx,
cairo_gl_shader_t *prev_shader = ctx->current_shader;
_cairo_gl_set_shader (ctx, ctx->pre_shader);
- _cairo_gl_set_operator (ctx->current_target, CAIRO_OPERATOR_DEST_OUT, TRUE);
+ _cairo_gl_set_operator (ctx, CAIRO_OPERATOR_DEST_OUT, TRUE);
_cairo_gl_set_src_alpha (ctx, TRUE);
glDrawArrays (GL_TRIANGLES, 0, count);
_cairo_gl_set_src_alpha (ctx, FALSE);
_cairo_gl_set_shader (ctx, prev_shader);
- _cairo_gl_set_operator (ctx->current_target, CAIRO_OPERATOR_ADD, TRUE);
+ _cairo_gl_set_operator (ctx, CAIRO_OPERATOR_ADD, TRUE);
glDrawArrays (GL_TRIANGLES, 0, count);
}
}
diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c
index ff64ae6f..54a2fde8 100644
--- a/src/cairo-gl-device.c
+++ b/src/cairo-gl-device.c
@@ -80,6 +80,7 @@ _gl_flush (void *device)
}
ctx->current_target = NULL;
+ ctx->current_operator = -1;
ctx->vertex_size = 0;
ctx->pre_shader = NULL;
_cairo_gl_set_shader (ctx, NULL);
@@ -196,6 +197,8 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx)
else
ctx->tex_target = GL_TEXTURE_2D;
+ ctx->current_operator = -1;
+
status = _cairo_gl_context_init_shaders (ctx);
if (unlikely (status))
return status;
diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
index 41016516..07333042 100644
--- a/src/cairo-gl-private.h
+++ b/src/cairo-gl-private.h
@@ -182,6 +182,7 @@ typedef struct _cairo_gl_context {
cairo_list_t fonts;
cairo_gl_surface_t *current_target;
+ cairo_operator_t current_operator;
cairo_gl_shader_t *pre_shader; /* for component alpha */
cairo_gl_shader_t *current_shader;