mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
Merge branch 'wip/framebuffer-bits'
* wip/framebuffer-bits: Implement accessors for the color bits in a framebuffer
This commit is contained in:
commit
94c1614164
@ -100,6 +100,7 @@ cogl_create_context (void)
|
||||
_context->n_texcoord_arrays_enabled = 0;
|
||||
|
||||
_context->framebuffer_stack = _cogl_create_framebuffer_stack ();
|
||||
|
||||
window_buffer = _cogl_onscreen_new ();
|
||||
cogl_set_framebuffer (window_buffer);
|
||||
/* XXX: the deprecated _cogl_set_draw_buffer API expects to
|
||||
|
@ -48,6 +48,12 @@ typedef struct
|
||||
int viewport_height;
|
||||
|
||||
CoglClipState clip_state;
|
||||
|
||||
gboolean dirty_bitmasks;
|
||||
int red_bits;
|
||||
int blue_bits;
|
||||
int green_bits;
|
||||
int alpha_bits;
|
||||
} CoglFramebuffer;
|
||||
|
||||
#define COGL_FRAMEBUFFER(X) ((CoglFramebuffer *)(X))
|
||||
@ -71,12 +77,16 @@ typedef struct _CoglOnscreen
|
||||
|
||||
void
|
||||
_cogl_framebuffer_state_init (void);
|
||||
|
||||
int
|
||||
_cogl_framebuffer_get_width (CoglHandle handle);
|
||||
|
||||
int
|
||||
_cogl_framebuffer_get_height (CoglHandle handle);
|
||||
|
||||
CoglClipState *
|
||||
_cogl_framebuffer_get_clip_state (CoglHandle handle);
|
||||
|
||||
void
|
||||
_cogl_framebuffer_set_viewport (CoglHandle handle,
|
||||
int x,
|
||||
@ -85,16 +95,22 @@ _cogl_framebuffer_set_viewport (CoglHandle handle,
|
||||
int height);
|
||||
int
|
||||
_cogl_framebuffer_get_viewport_x (CoglHandle handle);
|
||||
|
||||
int
|
||||
_cogl_framebuffer_get_viewport_y (CoglHandle handle);
|
||||
|
||||
int
|
||||
_cogl_framebuffer_get_viewport_width (CoglHandle handle);
|
||||
|
||||
int
|
||||
_cogl_framebuffer_get_viewport_height (CoglHandle handle);
|
||||
|
||||
void
|
||||
_cogl_framebuffer_get_viewport4fv (CoglHandle handle, int *viewport);
|
||||
|
||||
CoglMatrixStack *
|
||||
_cogl_framebuffer_get_modelview_stack (CoglHandle handle);
|
||||
|
||||
CoglMatrixStack *
|
||||
_cogl_framebuffer_get_projection_stack (CoglHandle handle);
|
||||
|
||||
@ -116,8 +132,10 @@ _cogl_onscreen_new (void);
|
||||
|
||||
CoglHandle
|
||||
_cogl_get_framebuffer (void);
|
||||
|
||||
GSList *
|
||||
_cogl_create_framebuffer_stack (void);
|
||||
|
||||
void
|
||||
_cogl_free_framebuffer_stack (GSList *stack);
|
||||
|
||||
|
@ -130,6 +130,8 @@ _cogl_framebuffer_init (CoglFramebuffer *framebuffer,
|
||||
framebuffer->modelview_stack = _cogl_matrix_stack_new ();
|
||||
framebuffer->projection_stack = _cogl_matrix_stack_new ();
|
||||
|
||||
framebuffer->dirty_bitmasks = TRUE;
|
||||
|
||||
/* Initialise the clip stack */
|
||||
_cogl_clip_state_init (&framebuffer->clip_state);
|
||||
}
|
||||
@ -248,6 +250,20 @@ _cogl_framebuffer_get_projection_stack (CoglHandle handle)
|
||||
return framebuffer->projection_stack;
|
||||
}
|
||||
|
||||
static inline void
|
||||
_cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
|
||||
{
|
||||
if (G_LIKELY (!framebuffer->dirty_bitmasks))
|
||||
return;
|
||||
|
||||
GE( glGetIntegerv (GL_RED_BITS, &framebuffer->red_bits) );
|
||||
GE( glGetIntegerv (GL_GREEN_BITS, &framebuffer->green_bits) );
|
||||
GE( glGetIntegerv (GL_BLUE_BITS, &framebuffer->blue_bits) );
|
||||
GE( glGetIntegerv (GL_ALPHA_BITS, &framebuffer->alpha_bits) );
|
||||
|
||||
framebuffer->dirty_bitmasks = FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
try_creating_fbo (CoglOffscreen *offscreen,
|
||||
TryFBOFlags flags,
|
||||
@ -555,6 +571,8 @@ _cogl_set_framebuffer_real (CoglFramebuffer *framebuffer)
|
||||
_cogl_matrix_stack_dirty (framebuffer->modelview_stack);
|
||||
_cogl_matrix_stack_dirty (framebuffer->projection_stack);
|
||||
_cogl_clip_state_dirty (&framebuffer->clip_state);
|
||||
|
||||
_cogl_framebuffer_init_bits (framebuffer);
|
||||
}
|
||||
|
||||
void
|
||||
@ -710,3 +728,42 @@ _cogl_framebuffer_flush_state (CoglHandle handle,
|
||||
COGL_MATRIX_PROJECTION);
|
||||
}
|
||||
|
||||
int
|
||||
cogl_framebuffer_get_red_bits (CoglHandle framebuffer)
|
||||
{
|
||||
CoglFramebuffer *fb = COGL_FRAMEBUFFER (framebuffer);
|
||||
|
||||
_cogl_framebuffer_init_bits (fb);
|
||||
|
||||
return fb->red_bits;
|
||||
}
|
||||
|
||||
int
|
||||
cogl_framebuffer_get_green_bits (CoglHandle framebuffer)
|
||||
{
|
||||
CoglFramebuffer *fb = COGL_FRAMEBUFFER (framebuffer);
|
||||
|
||||
_cogl_framebuffer_init_bits (fb);
|
||||
|
||||
return fb->green_bits;
|
||||
}
|
||||
|
||||
int
|
||||
cogl_framebuffer_get_blue_bits (CoglHandle framebuffer)
|
||||
{
|
||||
CoglFramebuffer *fb = COGL_FRAMEBUFFER (framebuffer);
|
||||
|
||||
_cogl_framebuffer_init_bits (fb);
|
||||
|
||||
return fb->blue_bits;
|
||||
}
|
||||
|
||||
int
|
||||
cogl_framebuffer_get_alpha_bits (CoglHandle framebuffer)
|
||||
{
|
||||
CoglFramebuffer *fb = COGL_FRAMEBUFFER (framebuffer);
|
||||
|
||||
_cogl_framebuffer_init_bits (fb);
|
||||
|
||||
return fb->alpha_bits;
|
||||
}
|
||||
|
24
cogl/cogl.c
24
cogl/cogl.c
@ -533,31 +533,21 @@ cogl_get_bitmasks (int *red,
|
||||
int *blue,
|
||||
int *alpha)
|
||||
{
|
||||
GLint value;
|
||||
CoglHandle framebuffer;
|
||||
|
||||
framebuffer = _cogl_get_framebuffer ();
|
||||
|
||||
if (red)
|
||||
{
|
||||
GE( glGetIntegerv(GL_RED_BITS, &value) );
|
||||
*red = value;
|
||||
}
|
||||
*red = cogl_framebuffer_get_red_bits (framebuffer);
|
||||
|
||||
if (green)
|
||||
{
|
||||
GE( glGetIntegerv(GL_GREEN_BITS, &value) );
|
||||
*green = value;
|
||||
}
|
||||
*green = cogl_framebuffer_get_green_bits (framebuffer);
|
||||
|
||||
if (blue)
|
||||
{
|
||||
GE( glGetIntegerv(GL_BLUE_BITS, &value) );
|
||||
*blue = value;
|
||||
}
|
||||
*blue = cogl_framebuffer_get_blue_bits (framebuffer);
|
||||
|
||||
if (alpha)
|
||||
{
|
||||
GE( glGetIntegerv(GL_ALPHA_BITS, &value ) );
|
||||
*alpha = value;
|
||||
}
|
||||
*alpha = cogl_framebuffer_get_alpha_bits (framebuffer);
|
||||
}
|
||||
|
||||
void
|
||||
|
52
cogl/cogl.h
52
cogl/cogl.h
@ -161,6 +161,58 @@ cogl_get_bitmasks (int *red,
|
||||
int *blue,
|
||||
int *alpha);
|
||||
|
||||
/**
|
||||
* cogl_framebuffer_get_red_bits:
|
||||
* @framebuffer: a handle for a framebuffer
|
||||
*
|
||||
* Retrieves the number of red bits of @framebuffer
|
||||
*
|
||||
* Return value: the number of bits
|
||||
*
|
||||
* Since: 1.4
|
||||
*/
|
||||
int
|
||||
cogl_framebuffer_get_red_bits (CoglHandle framebuffer);
|
||||
|
||||
/**
|
||||
* cogl_framebuffer_get_green_bits:
|
||||
* @framebuffer: a handle for a framebuffer
|
||||
*
|
||||
* Retrieves the number of green bits of @framebuffer
|
||||
*
|
||||
* Return value: the number of bits
|
||||
*
|
||||
* Since: 1.4
|
||||
*/
|
||||
int
|
||||
cogl_framebuffer_get_green_bits (CoglHandle framebuffer);
|
||||
|
||||
/**
|
||||
* cogl_framebuffer_get_blue_bits:
|
||||
* @framebuffer: a handle for a framebuffer
|
||||
*
|
||||
* Retrieves the number of blue bits of @framebuffer
|
||||
*
|
||||
* Return value: the number of bits
|
||||
*
|
||||
* Since: 1.4
|
||||
*/
|
||||
int
|
||||
cogl_framebuffer_get_blue_bits (CoglHandle framebuffer);
|
||||
|
||||
/**
|
||||
* cogl_framebuffer_get_alpha_bits:
|
||||
* @framebuffer: a handle for a framebuffer
|
||||
*
|
||||
* Retrieves the number of alpha bits of @framebuffer
|
||||
*
|
||||
* Return value: the number of bits
|
||||
*
|
||||
* Since: 1.4
|
||||
*/
|
||||
int
|
||||
cogl_framebuffer_get_alpha_bits (CoglHandle framebuffer);
|
||||
|
||||
/**
|
||||
* cogl_perspective:
|
||||
* @fovy: Vertical of view angle in degrees.
|
||||
|
Loading…
Reference in New Issue
Block a user