From 75226501cfc272eb54dba29d98937461cd502b63 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Sat, 25 Feb 2012 15:10:02 +0000 Subject: [PATCH] Don't use cogl_get_draw_framebuffer when flushing pipeline state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some of the state when flushing a pipeline depends on the current framebuffer being used. These are: • The matrix stack, so that it can flip vertically or not depending on whether the framebuffer is offscreen. • The colormask. This is combined with the framebuffer's color mask. • The cull face mode. If the framebuffer is offscreen then backface culling is translated to frontface culling and vice-versa. These states were not working if the new framebuffer draw_primitive API was used because in that case the framebuffer is not pushed to the framebuffer stack so it would use the wrong one. This patch changes it to use ctx->current_draw_buffer which is a pointer to the framebuffer whose state was last flushed. https://bugzilla.gnome.org/show_bug.cgi?id=670793 Reviewed-by: Robert Bragg --- cogl/cogl-matrix-stack.c | 2 +- cogl/cogl-pipeline-opengl.c | 8 +++----- cogl/cogl-pipeline-progend-glsl.c | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/cogl/cogl-matrix-stack.c b/cogl/cogl-matrix-stack.c index fd1bed06d..40d090344 100644 --- a/cogl/cogl-matrix-stack.c +++ b/cogl/cogl-matrix-stack.c @@ -430,7 +430,7 @@ _cogl_matrix_stack_flush_to_gl_builtins (CoglContext *ctx, if (disable_flip) needs_flip = FALSE; else - needs_flip = cogl_is_offscreen (cogl_get_draw_framebuffer ()); + needs_flip = cogl_is_offscreen (ctx->current_draw_buffer); cache = &ctx->builtin_flushed_projection; } diff --git a/cogl/cogl-pipeline-opengl.c b/cogl/cogl-pipeline-opengl.c index 3237dc4be..a76324027 100644 --- a/cogl/cogl-pipeline-opengl.c +++ b/cogl/cogl-pipeline-opengl.c @@ -593,10 +593,9 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state ( _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LOGIC_OPS); CoglPipelineLogicOpsState *logic_ops_state = &authority->big_state->logic_ops_state; CoglColorMask color_mask = logic_ops_state->color_mask; - CoglFramebuffer *draw_framebuffer = cogl_get_draw_framebuffer (); - if (draw_framebuffer) - color_mask &= draw_framebuffer->color_mask; + if (ctx->current_draw_buffer) + color_mask &= ctx->current_draw_buffer->color_mask; GE (ctx, glColorMask (!!(color_mask & COGL_COLOR_MASK_RED), !!(color_mask & COGL_COLOR_MASK_GREEN), @@ -616,7 +615,6 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state ( GE( ctx, glDisable (GL_CULL_FACE) ); else { - CoglFramebuffer *draw_framebuffer = cogl_get_draw_framebuffer (); gboolean invert_winding; GE( ctx, glEnable (GL_CULL_FACE) ); @@ -642,7 +640,7 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state ( /* If we are painting to an offscreen framebuffer then we need to invert the winding of the front face because everything is painted upside down */ - invert_winding = cogl_is_offscreen (draw_framebuffer); + invert_winding = cogl_is_offscreen (ctx->current_draw_buffer); switch (cull_face_state->front_winding) { diff --git a/cogl/cogl-pipeline-progend-glsl.c b/cogl/cogl-pipeline-progend-glsl.c index 5d65d709a..3bb6f797a 100644 --- a/cogl/cogl-pipeline-progend-glsl.c +++ b/cogl/cogl-pipeline-progend-glsl.c @@ -951,7 +951,7 @@ _cogl_pipeline_progend_glsl_pre_paint (CoglPipeline *pipeline) if (modelview_stack == NULL || projection_stack == NULL) return; - needs_flip = cogl_is_offscreen (cogl_get_draw_framebuffer ()); + needs_flip = cogl_is_offscreen (ctx->current_draw_buffer); #ifdef HAVE_COGL_GLES2 if (ctx->driver == COGL_DRIVER_GLES2)