framebuffer: lazily allocate framebuffers as needed
If the user doesn't explicitly allocate a CoglFramebuffer then Cogl should automatically allocate the framebuffer when the user starts to draw to the framebuffer. So this way calling cogl_framebuffer_allocate is only required if you are explicitly interested in checking for and gracefully handling failures to allocate a framebuffer. If automatic allocation fails then application behaviour becomes undefined. Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
parent
a3ad808f57
commit
8e8690a562
@ -301,8 +301,6 @@ cogl_framebuffer_clear4f (CoglFramebuffer *framebuffer,
|
|||||||
int scissor_x1;
|
int scissor_x1;
|
||||||
int scissor_y1;
|
int scissor_y1;
|
||||||
|
|
||||||
g_return_if_fail (framebuffer->allocated);
|
|
||||||
|
|
||||||
_cogl_clip_stack_get_bounds (clip_stack,
|
_cogl_clip_stack_get_bounds (clip_stack,
|
||||||
&scissor_x0, &scissor_y0,
|
&scissor_x0, &scissor_y0,
|
||||||
&scissor_x1, &scissor_y1);
|
&scissor_x1, &scissor_y1);
|
||||||
@ -452,8 +450,6 @@ cogl_framebuffer_clear (CoglFramebuffer *framebuffer,
|
|||||||
unsigned long buffers,
|
unsigned long buffers,
|
||||||
const CoglColor *color)
|
const CoglColor *color)
|
||||||
{
|
{
|
||||||
g_return_if_fail (framebuffer->allocated);
|
|
||||||
|
|
||||||
cogl_framebuffer_clear4f (framebuffer, buffers,
|
cogl_framebuffer_clear4f (framebuffer, buffers,
|
||||||
cogl_color_get_red_float (color),
|
cogl_color_get_red_float (color),
|
||||||
cogl_color_get_green_float (color),
|
cogl_color_get_green_float (color),
|
||||||
@ -618,6 +614,8 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
|
|||||||
{
|
{
|
||||||
CoglContext *ctx = framebuffer->context;
|
CoglContext *ctx = framebuffer->context;
|
||||||
|
|
||||||
|
cogl_framebuffer_allocate (framebuffer, NULL);
|
||||||
|
|
||||||
if (G_LIKELY (!framebuffer->dirty_bitmasks))
|
if (G_LIKELY (!framebuffer->dirty_bitmasks))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1383,6 +1381,10 @@ _cogl_framebuffer_flush_state (CoglFramebuffer *draw_buffer,
|
|||||||
{
|
{
|
||||||
CoglContext *ctx = draw_buffer->context;
|
CoglContext *ctx = draw_buffer->context;
|
||||||
|
|
||||||
|
/* Lazily ensure the framebuffer has been allocated */
|
||||||
|
cogl_framebuffer_allocate (draw_buffer, NULL);
|
||||||
|
cogl_framebuffer_allocate (read_buffer, NULL);
|
||||||
|
|
||||||
if (ctx->dirty_bound_framebuffer)
|
if (ctx->dirty_bound_framebuffer)
|
||||||
{
|
{
|
||||||
if (draw_buffer == read_buffer)
|
if (draw_buffer == read_buffer)
|
||||||
|
Loading…
Reference in New Issue
Block a user