mirror of
https://github.com/brl/mutter.git
synced 2024-11-09 23:46:33 -05: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
598939cee1
commit
2d94b3f46f
21
cogl.h.in
21
cogl.h.in
@ -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