diff --git a/cogl/cogl-journal.c b/cogl/cogl-journal.c index 117707786..9e6ea22eb 100644 --- a/cogl/cogl-journal.c +++ b/cogl/cogl-journal.c @@ -233,9 +233,9 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start, { CoglJournalFlushState *state = data; CoglVertexAttribute **attributes; - static const CoglDrawFlags draw_flags = (COGL_DRAW_SKIP_JOURNAL_FLUSH | - COGL_DRAW_SKIP_PIPELINE_VALIDATION | - COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH); + CoglDrawFlags draw_flags = (COGL_DRAW_SKIP_JOURNAL_FLUSH | + COGL_DRAW_SKIP_PIPELINE_VALIDATION | + COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH); COGL_STATIC_TIMER (time_flush_modelview_and_entries, "flush: pipeline+entries", /* parent */ @@ -261,6 +261,9 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start, attributes = (CoglVertexAttribute **)state->attributes->data; cogl_push_source (state->source); + if (!_cogl_pipeline_get_real_blend_enabled (state->source)) + draw_flags |= COGL_DRAW_COLOR_ATTRIBUTE_IS_OPAQUE; + #ifdef HAVE_COGL_GL /* XXX: it's rather evil that we sneak in the GL_QUADS enum here... */ diff --git a/cogl/cogl-vertex-attribute-private.h b/cogl/cogl-vertex-attribute-private.h index ad2777f34..b3a0e081e 100644 --- a/cogl/cogl-vertex-attribute-private.h +++ b/cogl/cogl-vertex-attribute-private.h @@ -61,7 +61,14 @@ typedef enum { COGL_DRAW_SKIP_JOURNAL_FLUSH = 1 << 0, COGL_DRAW_SKIP_PIPELINE_VALIDATION = 1 << 1, - COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH = 1 << 2 + COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH = 1 << 2, + /* By default the vertex attribute drawing code will assume that if + there is a color attribute array enabled then we can't determine + if the colors will be opaque so we need to enabling + blending. However when drawing from the journal we know what the + contents of the color array is so we can override this by passing + this flag. */ + COGL_DRAW_COLOR_ATTRIBUTE_IS_OPAQUE = 1 << 3 } CoglDrawFlags; CoglVertexAttribute * diff --git a/cogl/cogl-vertex-attribute.c b/cogl/cogl-vertex-attribute.c index 73df66ba5..eb1451613 100644 --- a/cogl/cogl-vertex-attribute.c +++ b/cogl/cogl-vertex-attribute.c @@ -474,7 +474,8 @@ set_enabled_arrays (CoglBitmask *value_cache, } static CoglHandle -enable_gl_state (CoglVertexAttribute **attributes, +enable_gl_state (CoglDrawFlags flags, + CoglVertexAttribute **attributes, ValidateLayerState *state) { int i; @@ -498,7 +499,8 @@ enable_gl_state (CoglVertexAttribute **attributes, switch (attributes[i]->name_id) { case COGL_VERTEX_ATTRIBUTE_NAME_ID_COLOR_ARRAY: - if (!_cogl_pipeline_get_real_blend_enabled (source)) + if ((flags & COGL_DRAW_COLOR_ATTRIBUTE_IS_OPAQUE) == 0 && + !_cogl_pipeline_get_real_blend_enabled (source)) { CoglPipelineBlendEnable blend_enable = COGL_PIPELINE_BLEND_ENABLE_ENABLED; @@ -1082,7 +1084,7 @@ _cogl_draw_vertex_attributes_array (CoglVerticesMode mode, flush_state (flags, &state); - source = enable_gl_state (attributes, &state); + source = enable_gl_state (flags, attributes, &state); GE (glDrawArrays ((GLenum)mode, first_vertex, n_vertices)); @@ -1171,7 +1173,7 @@ _cogl_draw_indexed_vertex_attributes_array (CoglVerticesMode mode, flush_state (flags, &state); - source = enable_gl_state (attributes, &state); + source = enable_gl_state (flags, attributes, &state); buffer = COGL_BUFFER (cogl_indices_get_array (indices)); base = _cogl_buffer_bind (buffer, COGL_BUFFER_BIND_TARGET_INDEX_ARRAY);