From 2059ae3ac807e9078e9cb3f46a325fa13355bdb2 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Wed, 14 Sep 2011 12:17:09 +0100 Subject: 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 --- cogl/cogl-private.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'cogl/cogl-private.h') diff --git a/cogl/cogl-private.h b/cogl/cogl-private.h index eaa1d52f..32ca2b48 100644 --- a/cogl/cogl-private.h +++ b/cogl/cogl-private.h @@ -24,6 +24,8 @@ #ifndef __COGL_PRIVATE_H__ #define __COGL_PRIVATE_H__ +#include + G_BEGIN_DECLS gboolean @@ -53,6 +55,12 @@ _cogl_read_pixels_with_rowstride (int x, void _cogl_init (void); +void +_cogl_push_source (CoglPipeline *pipeline, gboolean enable_legacy); + +gboolean +_cogl_get_enable_legacy_state (void); + G_END_DECLS #endif /* __COGL_PRIVATE_H__ */ -- cgit v1.2.1