Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From f6ca7f0e4293481f6cbe3334bda53a5e2fd48d79 Mon Sep 17 00:00:00 2001
- From: Robert Bragg <robert@linux.intel.com>
- Date: Mon, 1 Nov 2010 20:27:32 +0000
- Subject: [PATCH] cogl: add separate material for blended source_colors
- When using cogl_set_source_color4ub there is a notable difference
- between colors that require blending and those that dont. When trying to
- modify the color of pipeline referenced by the journal we don't force a
- flush of the journal unless the color change will also change the
- blending state. By using two separate pipeline objects for handing
- opaque or transparent colors we can avoid ever flushing the journal when
- repeatedly using cogl_set_source_color and jumping between opaque and
- transparent colors.
- ---
- clutter/cogl/cogl/cogl-context.c | 13 ++++++++-----
- clutter/cogl/cogl/cogl-context.h | 5 +++--
- clutter/cogl/cogl/cogl.c | 19 ++++++++++++++-----
- 3 files changed, 25 insertions(+), 12 deletions(-)
- diff --git a/clutter/cogl/cogl/cogl-context.c b/clutter/cogl/cogl/cogl-context.c
- index 7395b76..1e762db 100644
- --- a/clutter/cogl/cogl/cogl-context.c
- +++ b/clutter/cogl/cogl/cogl-context.c
- @@ -129,7 +129,8 @@ cogl_create_context (void)
- _context->legacy_fog_state.enabled = FALSE;
- - _context->simple_pipeline = cogl_pipeline_new ();
- + _context->opaque_color_pipeline = cogl_pipeline_new ();
- + _context->blended_color_pipeline = cogl_pipeline_new ();
- _context->texture_pipeline = cogl_pipeline_new ();
- _context->arbfp_source_buffer = g_string_new ("");
- _context->source_stack = NULL;
- @@ -235,8 +236,8 @@ cogl_create_context (void)
- 0, /* auto calc row stride */
- default_texture_data);
- - cogl_push_source (_context->simple_pipeline);
- - _cogl_pipeline_flush_gl_state (_context->simple_pipeline, FALSE);
- + cogl_push_source (_context->opaque_color_pipeline);
- + _cogl_pipeline_flush_gl_state (_context->opaque_color_pipeline, FALSE);
- _cogl_enable (enable_flags);
- _cogl_flush_face_winding ();
- @@ -275,8 +276,10 @@ _cogl_destroy_context (void)
- if (_context->default_gl_texture_rect_tex)
- cogl_handle_unref (_context->default_gl_texture_rect_tex);
- - if (_context->simple_pipeline)
- - cogl_handle_unref (_context->simple_pipeline);
- + if (_context->opaque_color_pipeline)
- + cogl_handle_unref (_context->opaque_color_pipeline);
- + if (_context->blended_color_pipeline)
- + cogl_handle_unref (_context->blended_color_pipeline);
- if (_context->texture_pipeline)
- cogl_handle_unref (_context->texture_pipeline);
- diff --git a/clutter/cogl/cogl/cogl-context.h b/clutter/cogl/cogl/cogl-context.h
- index 96157cb..fd8db15 100644
- --- a/clutter/cogl/cogl/cogl-context.h
- +++ b/clutter/cogl/cogl/cogl-context.h
- @@ -82,8 +82,9 @@ typedef struct
- CoglPipelineFogState legacy_fog_state;
- - /* Materials */
- - CoglPipeline *simple_pipeline; /* used for set_source_color */
- + /* Pipelines */
- + CoglPipeline *opaque_color_pipeline; /* used for set_source_color */
- + CoglPipeline *blended_color_pipeline; /* used for set_source_color */
- CoglPipeline *texture_pipeline; /* used for set_source_texture */
- GString *arbfp_source_buffer;
- GList *source_stack;
- diff --git a/clutter/cogl/cogl/cogl.c b/clutter/cogl/cogl/cogl.c
- index af3a3d5..8271c68 100644
- --- a/clutter/cogl/cogl/cogl.c
- +++ b/clutter/cogl/cogl/cogl.c
- @@ -369,15 +369,24 @@ _cogl_flush_face_winding (void)
- void
- cogl_set_source_color (const CoglColor *color)
- {
- - CoglColor premultiplied;
- + CoglPipeline *pipeline;
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
- - premultiplied = *color;
- - cogl_color_premultiply (&premultiplied);
- - cogl_pipeline_set_color (ctx->simple_pipeline, &premultiplied);
- + if (cogl_color_get_alpha_byte (color) == 0xff)
- + {
- + cogl_pipeline_set_color (ctx->opaque_color_pipeline, color);
- + pipeline = ctx->opaque_color_pipeline;
- + }
- + else
- + {
- + CoglColor premultiplied = *color;
- + cogl_color_premultiply (&premultiplied);
- + cogl_pipeline_set_color (ctx->blended_color_pipeline, &premultiplied);
- + pipeline = ctx->blended_color_pipeline;
- + }
- - cogl_set_source (ctx->simple_pipeline);
- + cogl_set_source (pipeline);
- }
- void
- --
- 1.7.0.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement