Add internal _cogl_push_source to optionally disable legacy state
Some code in Cogl such as when flushing a stencil clip assumes that it can push a temporary simple pipeline to reset to a known state for internal drawing operations. However this breaks down if the application has set any legacy state because that is set globally so it will also get applied to the internal pipeline. _cogl_draw_attributes already had an internal flag to disable applying the legacy state but I think this is quite awkward to use because not all places that push a pipeline draw the attribute buffers directly so it is difficult to pass the flag down through the layers. Conceptually the legacy state is meant to be like a layer on top of the purely pipeline-based state API so I think ideally we should have an internal function to push the source without the applying the legacy state. The legacy state can't be applied as the pipeline is pushed because the global state can be modified even after it is pushed. This patch adds a _cogl_push_source() function which takes an extra boolean flag to mark whether to enable the legacy state. The value of this flag is stored alongside the pipeline in the pipeline stack. Another new internal function called _cogl_get_enable_legacy_state queries whether the top entry in the pipeline stack has legacy state enabled. cogl-primitives and the vertex array drawing code now use this to determine whether to apply the legacy state when drawing. The COGL_DRAW_SKIP_LEGACY_STATE flag is now removed. Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:

committed by
Robert Bragg

parent
acc7d25188
commit
2059ae3ac8
@ -43,6 +43,7 @@
|
||||
#ifdef HAVE_COGL_GLES2
|
||||
#include "cogl-pipeline-progend-glsl-private.h"
|
||||
#endif
|
||||
#include "cogl-private.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
@ -535,7 +536,7 @@ enable_gl_state (CoglDrawFlags flags,
|
||||
}
|
||||
|
||||
if (G_UNLIKELY (ctx->legacy_state_set) &&
|
||||
(flags & COGL_DRAW_SKIP_LEGACY_STATE) == 0)
|
||||
_cogl_get_enable_legacy_state ())
|
||||
{
|
||||
/* If we haven't already created a derived pipeline... */
|
||||
if (!copy)
|
||||
@ -1015,7 +1016,7 @@ draw_wireframe (CoglVerticesMode mode,
|
||||
0x00, 0xff, 0x00, 0xff);
|
||||
}
|
||||
|
||||
cogl_push_source (wire_pipeline);
|
||||
_cogl_push_source (wire_pipeline, FALSE);
|
||||
|
||||
/* temporarily disable the wireframe to avoid recursion! */
|
||||
COGL_DEBUG_CLEAR_FLAG (COGL_DEBUG_WIREFRAME);
|
||||
@ -1026,8 +1027,7 @@ draw_wireframe (CoglVerticesMode mode,
|
||||
1,
|
||||
COGL_DRAW_SKIP_JOURNAL_FLUSH |
|
||||
COGL_DRAW_SKIP_PIPELINE_VALIDATION |
|
||||
COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH |
|
||||
COGL_DRAW_SKIP_LEGACY_STATE);
|
||||
COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH);
|
||||
|
||||
COGL_DEBUG_SET_FLAG (COGL_DEBUG_WIREFRAME);
|
||||
|
||||
|
Reference in New Issue
Block a user