mirror of
https://github.com/brl/mutter.git
synced 2024-12-27 13:22:15 +00:00
[cogl] Adds a bitfield argument to cogl_clear for specifying which buffers to clear
Redundant clearing of depth and stencil buffers every render can be very expensive, so cogl now gives control over which auxiliary buffers are cleared. Note: For now clutter continues to clear the color, depth and stencil buffer each paint.
This commit is contained in:
parent
20cd885c3d
commit
741c4bb5e9
5
README
5
README
@ -295,8 +295,9 @@ Release Notes for Clutter 1.0
|
||||
* cogl_clip_set* and cogl_clip_unset have been renamed to cogl_clip_push and
|
||||
cogl_clip_pop respectively so they self document their stacking semantics.
|
||||
|
||||
* cogl_paint_init was renamed to cogl_clear and no longer disables lighting
|
||||
and fogging.
|
||||
* cogl_paint_init was renamed to cogl_clear and no longer disables lighting and
|
||||
fogging. cogl_clear also now takes a mask of the auxiliary buffers you want
|
||||
to clear so you can avoid redundant clears of buffers you aren't using.
|
||||
|
||||
* cogl_fog_set was renamed to cogl_set_fog and it now takes a mode argument
|
||||
giving control over the fogging blend factor equation, so that the
|
||||
|
@ -372,7 +372,10 @@ _clutter_do_pick (ClutterStage *stage,
|
||||
|
||||
cogl_color_set_from_4ub (&white, 255, 255, 255, 255);
|
||||
cogl_disable_fog ();
|
||||
cogl_clear (&white);
|
||||
cogl_clear (&white,
|
||||
COGL_BUFFER_BIT_COLOR |
|
||||
COGL_BUFFER_BIT_DEPTH |
|
||||
COGL_BUFFER_BIT_STENCIL);
|
||||
|
||||
/* Disable dithering (if any) when doing the painting in pick mode */
|
||||
dither_was_on = glIsEnabled (GL_DITHER);
|
||||
|
@ -222,7 +222,10 @@ clutter_stage_paint (ClutterActor *self)
|
||||
priv->color.green,
|
||||
priv->color.blue,
|
||||
priv->color.alpha);
|
||||
cogl_clear (&stage_color);
|
||||
cogl_clear (&stage_color,
|
||||
COGL_BUFFER_BIT_COLOR |
|
||||
COGL_BUFFER_BIT_DEPTH |
|
||||
COGL_BUFFER_BIT_STENCIL);
|
||||
|
||||
if (priv->use_fog)
|
||||
{
|
||||
|
@ -593,7 +593,10 @@ clutter_texture_paint (ClutterActor *self)
|
||||
|
||||
/* cogl_clear is called to clear the buffers */
|
||||
cogl_color_set_from_4ub (&transparent_col, 0, 0, 0, 0);
|
||||
cogl_clear (&transparent_col);
|
||||
cogl_clear (&transparent_col,
|
||||
COGL_BUFFER_BIT_COLOR |
|
||||
COGL_BUFFER_BIT_DEPTH |
|
||||
COGL_BUFFER_BIT_STENCIL);
|
||||
cogl_disable_fog ();
|
||||
|
||||
/* Clear the clipping stack so that if the FBO actor is being
|
||||
@ -1454,6 +1457,9 @@ clutter_texture_set_cogl_texture (ClutterTexture *texture,
|
||||
|
||||
g_object_notify (G_OBJECT (texture), "cogl-texture");
|
||||
|
||||
/* Re-assert the filter quality on the new cogl texture */
|
||||
clutter_texture_set_filter_quality (texture, CLUTTER_TEXTURE_QUALITY_MEDIUM);
|
||||
|
||||
/* If resized actor may need resizing but paint() will do this */
|
||||
if (CLUTTER_ACTOR_IS_VISIBLE (texture))
|
||||
clutter_actor_queue_redraw (CLUTTER_ACTOR (texture));
|
||||
|
@ -363,14 +363,29 @@ void cogl_set_fog (const CoglColor *fog_color,
|
||||
*/
|
||||
void cogl_disable_fog (void);
|
||||
|
||||
/**
|
||||
* CoglBufferBit:
|
||||
* @COGL_BUFFER_BIT_COLOR: Selects the primary color buffer
|
||||
* @COGL_BUFFER_BIT_DEPTH: Selects the depth buffer
|
||||
* @COGL_BUFFER_BIT_STENCIL: Selects the stencil buffer
|
||||
*/
|
||||
typedef enum _CoglBufferBit
|
||||
{
|
||||
COGL_BUFFER_BIT_COLOR = 1L<<0,
|
||||
COGL_BUFFER_BIT_DEPTH = 1L<<1,
|
||||
COGL_BUFFER_BIT_STENCIL = 1L<<2
|
||||
} CoglBufferBit;
|
||||
|
||||
/**
|
||||
* cogl_clear:
|
||||
* @color: Background color to clear to
|
||||
* @buffers: A mask of @CoglBufferBit<!-- -->'s identifying which auxiliary
|
||||
* buffers to clear
|
||||
*
|
||||
* Clears the color buffer to @color. The depth buffer and stencil
|
||||
* buffers are also cleared.
|
||||
* Clears all the auxiliary buffers identified in the @buffers mask, and if
|
||||
* that includes the color buffer then the specified @color is used.
|
||||
*/
|
||||
void cogl_clear (const CoglColor *color);
|
||||
void cogl_clear (const CoglColor *color, gulong buffers);
|
||||
|
||||
/**
|
||||
* cogl_set_source:
|
||||
|
@ -82,32 +82,36 @@ _cogl_error_string(GLenum errorCode)
|
||||
#endif
|
||||
|
||||
void
|
||||
cogl_clear (const CoglColor *color)
|
||||
cogl_clear (const CoglColor *color, gulong buffers)
|
||||
{
|
||||
GLbitfield gl_buffers = 0;
|
||||
|
||||
#if COGL_DEBUG
|
||||
fprintf(stderr, "\n ============== Paint Start ================ \n");
|
||||
#endif
|
||||
|
||||
GE( glClearColor (cogl_color_get_red_float (color),
|
||||
cogl_color_get_green_float (color),
|
||||
cogl_color_get_blue_float (color),
|
||||
0.0) );
|
||||
if (buffers & COGL_BUFFER_BIT_COLOR)
|
||||
{
|
||||
GE( glClearColor (cogl_color_get_red_float (color),
|
||||
cogl_color_get_green_float (color),
|
||||
cogl_color_get_blue_float (color),
|
||||
0.0) );
|
||||
gl_buffers |= GL_COLOR_BUFFER_BIT;
|
||||
}
|
||||
if (buffers & COGL_BUFFER_BIT_DEPTH)
|
||||
gl_buffers |= GL_DEPTH_BUFFER_BIT;
|
||||
if (buffers & COGL_BUFFER_BIT_STENCIL)
|
||||
gl_buffers |= GL_STENCIL_BUFFER_BIT;
|
||||
|
||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
if (!gl_buffers)
|
||||
{
|
||||
static gboolean shown = FALSE;
|
||||
if (!shown)
|
||||
g_warning ("You should specify at least one auxiliary buffer when calling cogl_clear");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Disable the depth test for now as has some strange side effects,
|
||||
* mainly on x/y axis rotation with multiple layers at same depth
|
||||
* (eg rotating text on a bg has very strange effect). Seems no clean
|
||||
* 100% effective way to fix without other odd issues.. So for now
|
||||
* move to application to handle and add cogl_enable_depth_test()
|
||||
* as for custom actors (i.e groups) to enable if need be.
|
||||
*
|
||||
* glEnable (GL_DEPTH_TEST);
|
||||
* glEnable (GL_ALPHA_TEST)
|
||||
* glDepthFunc (GL_LEQUAL);
|
||||
* glAlphaFunc (GL_GREATER, 0.1);
|
||||
*/
|
||||
glClear (gl_buffers);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
|
Loading…
Reference in New Issue
Block a user