mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
Don't take a reference to the last used onscreen framebuffer
Cogl keeps a pointer to the last used onscreen framebuffer from the context to implement the deprecated cogl_set_draw_buffer function which can take COGL_WINDOW_BUFFER as the target to use the last onscreen buffer. Previously this would also take a reference to that pointer. However that was causing a circular reference between the framebuffer and the context which makes it impossible to clean up resources properly when onscreen buffers are used. This patch instead changes it to just store the pointer and then clear the pointer during _cogl_onscreen_free as a kind of cheap weak reference. Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
parent
18b0ad652c
commit
39ca3e51df
@ -408,12 +408,6 @@ _cogl_context_free (CoglContext *context)
|
||||
|
||||
winsys->context_deinit (context);
|
||||
|
||||
if (context->window_buffer)
|
||||
{
|
||||
cogl_object_unref (context->window_buffer);
|
||||
context->window_buffer = NULL;
|
||||
}
|
||||
|
||||
_cogl_free_framebuffer_stack (context->framebuffer_stack);
|
||||
|
||||
if (context->current_path)
|
||||
|
@ -1141,18 +1141,16 @@ notify_buffers_changed (CoglFramebuffer *old_draw_buffer,
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX:
|
||||
* To support the deprecated cogl_set_draw_buffer API we keep track
|
||||
* of the last onscreen framebuffer that was set so that it can
|
||||
* be restored if the COGL_WINDOW_BUFFER enum is used. */
|
||||
/* XXX: To support the deprecated cogl_set_draw_buffer API we keep
|
||||
* track of the last onscreen framebuffer that was set so that it
|
||||
* can be restored if the COGL_WINDOW_BUFFER enum is used. A
|
||||
* reference isn't taken to the framebuffer because otherwise we
|
||||
* would have a circular reference between the context and the
|
||||
* framebuffer. Instead the pointer is set to NULL in
|
||||
* _cogl_onscreen_free as a kind of a cheap weak reference */
|
||||
if (new_draw_buffer &&
|
||||
new_draw_buffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN)
|
||||
{
|
||||
cogl_object_ref (new_draw_buffer);
|
||||
if (ctx->window_buffer)
|
||||
cogl_object_unref (ctx->window_buffer);
|
||||
ctx->window_buffer = new_draw_buffer;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the current framebuffer without checking if it's already the
|
||||
|
@ -112,6 +112,9 @@ _cogl_onscreen_free (CoglOnscreen *onscreen)
|
||||
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
||||
const CoglWinsysVtable *winsys = _cogl_framebuffer_get_winsys (framebuffer);
|
||||
|
||||
if (framebuffer->context->window_buffer == onscreen)
|
||||
framebuffer->context->window_buffer = NULL;
|
||||
|
||||
winsys->onscreen_deinit (onscreen);
|
||||
_COGL_RETURN_IF_FAIL (onscreen->winsys == NULL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user