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