[Cogl] [PATCH] framebuffer: remove framebuffer stack
Robert Bragg
robert at sixbynine.org
Mon Nov 19 08:54:04 PST 2012
From: Robert Bragg <robert at linux.intel.com>
The framebuffer stack is no longer used internally and all public apis
that require framebuffers takes explicit framebuffer pointers.
---
cogl/cogl-clutter.c | 15 --
cogl/cogl-clutter.h | 4 -
cogl/cogl-context-private.h | 2 -
cogl/cogl-context.c | 16 --
cogl/cogl-framebuffer-private.h | 9 --
cogl/cogl-framebuffer.c | 237 --------------------------------
cogl/cogl-onscreen.c | 3 -
cogl/cogl1-context.h | 129 -----------------
doc/reference/cogl2/cogl2-sections.txt | 6 -
examples/cogl-x11-tfp.c | 1 -
10 files changed, 0 insertions(+), 422 deletions(-)
diff --git a/cogl/cogl-clutter.c b/cogl/cogl-clutter.c
index b00e510..e9d4c7a 100644
--- a/cogl/cogl-clutter.c
+++ b/cogl/cogl-clutter.c
@@ -75,21 +75,6 @@ cogl_clutter_winsys_has_feature (CoglWinsysFeature feature)
return _cogl_winsys_has_feature (feature);
}
-void
-cogl_onscreen_clutter_backend_set_size (int width, int height)
-{
- CoglFramebuffer *framebuffer;
-
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
- if (_cogl_context_get_winsys (ctx) != _cogl_winsys_stub_get_vtable ())
- return;
-
- framebuffer = COGL_FRAMEBUFFER (ctx->window_buffer);
-
- _cogl_framebuffer_winsys_update_size (framebuffer, width, height);
-}
-
#ifdef COGL_HAS_XLIB_SUPPORT
XVisualInfo *
cogl_clutter_winsys_xlib_get_visual_info (void)
diff --git a/cogl/cogl-clutter.h b/cogl/cogl-clutter.h
index 2673888..8e0074e 100644
--- a/cogl/cogl-clutter.h
+++ b/cogl/cogl-clutter.h
@@ -38,10 +38,6 @@ cogl_clutter_check_extension (const char *name, const char *ext);
CoglBool
cogl_clutter_winsys_has_feature (CoglWinsysFeature feature);
-#define cogl_onscreen_clutter_backend_set_size cogl_onscreen_clutter_backend_set_size_CLUTTER
-void
-cogl_onscreen_clutter_backend_set_size (int width, int height);
-
G_END_DECLS
#endif /* __COGL_CLUTTER_H__ */
diff --git a/cogl/cogl-context-private.h b/cogl/cogl-context-private.h
index 37743c4..eb9acb9 100644
--- a/cogl/cogl-context-private.h
+++ b/cogl/cogl-context-private.h
@@ -169,8 +169,6 @@ struct _CoglContext
CoglBuffer *current_buffer[COGL_BUFFER_BIND_TARGET_COUNT];
/* Framebuffers */
- GSList *framebuffer_stack;
- CoglFramebuffer *window_buffer;
unsigned long current_draw_buffer_state_flushed;
unsigned long current_draw_buffer_changes;
CoglFramebuffer *current_draw_buffer;
diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c
index c70e020..6788da5 100644
--- a/cogl/cogl-context.c
+++ b/cogl/cogl-context.c
@@ -332,20 +332,6 @@ cogl_context_new (CoglDisplay *display,
for (i = 0; i < COGL_BUFFER_BIND_TARGET_COUNT; i++)
context->current_buffer[i] = NULL;
- context->window_buffer = NULL;
- context->framebuffer_stack = _cogl_create_framebuffer_stack ();
-
- /* XXX: In this case the Clutter backend is still responsible for
- * the OpenGL binding API and for creating onscreen framebuffers and
- * so we have to add a dummy framebuffer to represent the backend
- * owned window... */
- if (_cogl_context_get_winsys (context) == _cogl_winsys_stub_get_vtable ())
- {
- CoglOnscreen *window = _cogl_onscreen_new ();
- cogl_set_framebuffer (COGL_FRAMEBUFFER (window));
- cogl_object_unref (COGL_FRAMEBUFFER (window));
- }
-
context->stencil_pipeline = cogl_pipeline_new (context);
context->in_begin_gl_block = FALSE;
@@ -457,8 +443,6 @@ _cogl_context_free (CoglContext *context)
winsys->context_deinit (context);
- _cogl_free_framebuffer_stack (context->framebuffer_stack);
-
if (context->default_gl_texture_2d_tex)
cogl_object_unref (context->default_gl_texture_2d_tex);
if (context->default_gl_texture_3d_tex)
diff --git a/cogl/cogl-framebuffer-private.h b/cogl/cogl-framebuffer-private.h
index be7470e..81fbeef 100644
--- a/cogl/cogl-framebuffer-private.h
+++ b/cogl/cogl-framebuffer-private.h
@@ -281,15 +281,6 @@ _cogl_framebuffer_flush_state (CoglFramebuffer *draw_buffer,
CoglFramebuffer *read_buffer,
CoglFramebufferState state);
-CoglFramebuffer *
-_cogl_get_read_framebuffer (void);
-
-GSList *
-_cogl_create_framebuffer_stack (void);
-
-void
-_cogl_free_framebuffer_stack (GSList *stack);
-
/*
* _cogl_offscreen_new_to_texture_full:
* @texture: A #CoglTexture pointer
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index 8d57f59..b9a3b29 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -51,12 +51,6 @@
#include "cogl-path-private.h"
#include "cogl-error-private.h"
-typedef struct _CoglFramebufferStackEntry
-{
- CoglFramebuffer *draw_buffer;
- CoglFramebuffer *read_buffer;
-} CoglFramebufferStackEntry;
-
extern CoglObjectClass _cogl_onscreen_class;
#ifdef COGL_ENABLE_DEBUG
@@ -692,237 +686,6 @@ cogl_framebuffer_allocate (CoglFramebuffer *framebuffer,
return TRUE;
}
-static CoglFramebufferStackEntry *
-create_stack_entry (CoglFramebuffer *draw_buffer,
- CoglFramebuffer *read_buffer)
-{
- CoglFramebufferStackEntry *entry = g_slice_new (CoglFramebufferStackEntry);
-
- entry->draw_buffer = draw_buffer;
- entry->read_buffer = read_buffer;
-
- return entry;
-}
-
-GSList *
-_cogl_create_framebuffer_stack (void)
-{
- CoglFramebufferStackEntry *entry;
- GSList *stack = NULL;
-
- entry = create_stack_entry (NULL, NULL);
-
- return g_slist_prepend (stack, entry);
-}
-
-void
-_cogl_free_framebuffer_stack (GSList *stack)
-{
- GSList *l;
-
- for (l = stack; l != NULL; l = l->next)
- {
- CoglFramebufferStackEntry *entry = l->data;
-
- if (entry->draw_buffer)
- cogl_object_unref (entry->draw_buffer);
-
- if (entry->read_buffer)
- cogl_object_unref (entry->draw_buffer);
-
- g_slice_free (CoglFramebufferStackEntry, entry);
- }
- g_slist_free (stack);
-}
-
-static void
-notify_buffers_changed (CoglFramebuffer *old_draw_buffer,
- CoglFramebuffer *new_draw_buffer,
- CoglFramebuffer *old_read_buffer,
- CoglFramebuffer *new_read_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. 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)
- new_draw_buffer->context->window_buffer = new_draw_buffer;
-}
-
-/* Set the current framebuffer without checking if it's already the
- * current framebuffer. This is used by cogl_pop_framebuffer while
- * the top of the stack is currently not up to date. */
-static void
-_cogl_set_framebuffers_real (CoglFramebuffer *draw_buffer,
- CoglFramebuffer *read_buffer)
-{
- CoglFramebufferStackEntry *entry;
-
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
- _COGL_RETURN_IF_FAIL (ctx != NULL);
- _COGL_RETURN_IF_FAIL (draw_buffer && read_buffer ?
- draw_buffer->context == read_buffer->context : TRUE);
-
- entry = ctx->framebuffer_stack->data;
-
- notify_buffers_changed (entry->draw_buffer,
- draw_buffer,
- entry->read_buffer,
- read_buffer);
-
- if (draw_buffer)
- cogl_object_ref (draw_buffer);
- if (entry->draw_buffer)
- cogl_object_unref (entry->draw_buffer);
-
- if (read_buffer)
- cogl_object_ref (read_buffer);
- if (entry->read_buffer)
- cogl_object_unref (entry->read_buffer);
-
- entry->draw_buffer = draw_buffer;
- entry->read_buffer = read_buffer;
-}
-
-static void
-_cogl_set_framebuffers (CoglFramebuffer *draw_buffer,
- CoglFramebuffer *read_buffer)
-{
- CoglFramebuffer *current_draw_buffer;
- CoglFramebuffer *current_read_buffer;
-
- _COGL_RETURN_IF_FAIL (cogl_is_framebuffer (draw_buffer));
- _COGL_RETURN_IF_FAIL (cogl_is_framebuffer (read_buffer));
-
- current_draw_buffer = cogl_get_draw_framebuffer ();
- current_read_buffer = _cogl_get_read_framebuffer ();
-
- if (current_draw_buffer != draw_buffer ||
- current_read_buffer != read_buffer)
- _cogl_set_framebuffers_real (draw_buffer, read_buffer);
-}
-
-void
-cogl_set_framebuffer (CoglFramebuffer *framebuffer)
-{
- _cogl_set_framebuffers (framebuffer, framebuffer);
-}
-
-CoglFramebuffer *
-cogl_get_draw_framebuffer (void)
-{
- CoglFramebufferStackEntry *entry;
-
- _COGL_GET_CONTEXT (ctx, NULL);
-
- g_assert (ctx->framebuffer_stack);
-
- entry = ctx->framebuffer_stack->data;
-
- return entry->draw_buffer;
-}
-
-CoglFramebuffer *
-_cogl_get_read_framebuffer (void)
-{
- CoglFramebufferStackEntry *entry;
-
- _COGL_GET_CONTEXT (ctx, NULL);
-
- g_assert (ctx->framebuffer_stack);
-
- entry = ctx->framebuffer_stack->data;
-
- return entry->read_buffer;
-}
-
-void
-_cogl_push_framebuffers (CoglFramebuffer *draw_buffer,
- CoglFramebuffer *read_buffer)
-{
- CoglContext *ctx;
- CoglFramebuffer *old_draw_buffer, *old_read_buffer;
-
- _COGL_RETURN_IF_FAIL (cogl_is_framebuffer (draw_buffer));
- _COGL_RETURN_IF_FAIL (cogl_is_framebuffer (read_buffer));
-
- ctx = draw_buffer->context;
- _COGL_RETURN_IF_FAIL (ctx != NULL);
- _COGL_RETURN_IF_FAIL (draw_buffer->context == read_buffer->context);
-
- _COGL_RETURN_IF_FAIL (ctx->framebuffer_stack != NULL);
-
- /* Copy the top of the stack so that when we call cogl_set_framebuffer
- it will still know what the old framebuffer was */
- old_draw_buffer = cogl_get_draw_framebuffer ();
- if (old_draw_buffer)
- cogl_object_ref (old_draw_buffer);
- old_read_buffer = _cogl_get_read_framebuffer ();
- if (old_read_buffer)
- cogl_object_ref (old_read_buffer);
- ctx->framebuffer_stack =
- g_slist_prepend (ctx->framebuffer_stack,
- create_stack_entry (old_draw_buffer,
- old_read_buffer));
-
- _cogl_set_framebuffers (draw_buffer, read_buffer);
-}
-
-void
-cogl_push_framebuffer (CoglFramebuffer *buffer)
-{
- _cogl_push_framebuffers (buffer, buffer);
-}
-
-/* XXX: deprecated API */
-void
-cogl_push_draw_buffer (void)
-{
- cogl_push_framebuffer (cogl_get_draw_framebuffer ());
-}
-
-void
-cogl_pop_framebuffer (void)
-{
- CoglFramebufferStackEntry *to_pop;
- CoglFramebufferStackEntry *to_restore;
-
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
- g_assert (ctx->framebuffer_stack != NULL);
- g_assert (ctx->framebuffer_stack->next != NULL);
-
- to_pop = ctx->framebuffer_stack->data;
- to_restore = ctx->framebuffer_stack->next->data;
-
- if (to_pop->draw_buffer != to_restore->draw_buffer ||
- to_pop->read_buffer != to_restore->read_buffer)
- notify_buffers_changed (to_pop->draw_buffer,
- to_restore->draw_buffer,
- to_pop->read_buffer,
- to_restore->read_buffer);
-
- cogl_object_unref (to_pop->draw_buffer);
- cogl_object_unref (to_pop->read_buffer);
- g_slice_free (CoglFramebufferStackEntry, to_pop);
-
- ctx->framebuffer_stack =
- g_slist_delete_link (ctx->framebuffer_stack,
- ctx->framebuffer_stack);
-}
-
-/* XXX: deprecated API */
-void
-cogl_pop_draw_buffer (void)
-{
- cogl_pop_framebuffer ();
-}
-
static unsigned long
_cogl_framebuffer_compare_viewport_state (CoglFramebuffer *a,
CoglFramebuffer *b)
diff --git a/cogl/cogl-onscreen.c b/cogl/cogl-onscreen.c
index 4aaa5de..234f8bf 100644
--- a/cogl/cogl-onscreen.c
+++ b/cogl/cogl-onscreen.c
@@ -129,9 +129,6 @@ _cogl_onscreen_free (CoglOnscreen *onscreen)
g_slice_free (CoglSwapBuffersNotifyEntry, swap_entry);
}
- if (framebuffer->context->window_buffer == COGL_FRAMEBUFFER (onscreen))
- framebuffer->context->window_buffer = NULL;
-
winsys->onscreen_deinit (onscreen);
_COGL_RETURN_IF_FAIL (onscreen->winsys == NULL);
diff --git a/cogl/cogl1-context.h b/cogl/cogl1-context.h
index cdf21c2..f702ae6 100644
--- a/cogl/cogl1-context.h
+++ b/cogl/cogl1-context.h
@@ -40,135 +40,6 @@
G_BEGIN_DECLS
/**
- * cogl_set_framebuffer:
- * @buffer: A #CoglFramebuffer object, either onscreen or offscreen.
- *
- * This redirects all subsequent drawing to the specified framebuffer. This can
- * either be an offscreen buffer created with cogl_offscreen_new_to_texture ()
- * or in the future it may be an onscreen framebuffers too.
- *
- * Since: 1.2
- */
-void
-cogl_set_framebuffer (CoglFramebuffer *buffer);
-
-/**
- * cogl_push_framebuffer:
- * @buffer: A #CoglFramebuffer object, either onscreen or offscreen.
- *
- * Redirects all subsequent drawing to the specified framebuffer. This can
- * either be an offscreen buffer created with cogl_offscreen_new_to_texture ()
- * or in the future it may be an onscreen framebuffer too.
- *
- * You should understand that a framebuffer owns the following state:
- * <itemizedlist>
- * <listitem><simpara>The projection matrix</simpara></listitem>
- * <listitem><simpara>The modelview matrix stack</simpara></listitem>
- * <listitem><simpara>The viewport</simpara></listitem>
- * <listitem><simpara>The clip stack</simpara></listitem>
- * </itemizedlist>
- * So these items will automatically be saved and restored when you
- * push and pop between different framebuffers.
- *
- * Also remember a newly allocated framebuffer will have an identity matrix for
- * the projection and modelview matrices which gives you a coordinate space
- * like OpenGL with (-1, -1) corresponding to the top left of the viewport,
- * (1, 1) corresponding to the bottom right and +z coming out towards the
- * viewer.
- *
- * If you want to set up a coordinate space like Clutter does with (0, 0)
- * corresponding to the top left and (framebuffer_width, framebuffer_height)
- * corresponding to the bottom right you can do so like this:
- *
- * |[
- * static void
- * setup_viewport (unsigned int width,
- * unsigned int height,
- * float fovy,
- * float aspect,
- * float z_near,
- * float z_far)
- * {
- * float z_camera;
- * CoglMatrix projection_matrix;
- * CoglMatrix mv_matrix;
- *
- * cogl_set_viewport (0, 0, width, height);
- * cogl_perspective (fovy, aspect, z_near, z_far);
- *
- * cogl_get_projection_matrix (&projection_matrix);
- * z_camera = 0.5 * projection_matrix.xx;
- *
- * cogl_matrix_init_identity (&mv_matrix);
- * cogl_matrix_translate (&mv_matrix, -0.5f, -0.5f, -z_camera);
- * cogl_matrix_scale (&mv_matrix, 1.0f / width, -1.0f / height, 1.0f / width);
- * cogl_matrix_translate (&mv_matrix, 0.0f, -1.0 * height, 0.0f);
- * cogl_set_modelview_matrix (&mv_matrix);
- * }
- *
- * static void
- * my_init_framebuffer (ClutterStage *stage,
- * CoglFramebuffer *framebuffer,
- * unsigned int framebuffer_width,
- * unsigned int framebuffer_height)
- * {
- * ClutterPerspective perspective;
- *
- * clutter_stage_get_perspective (stage, &perspective);
- *
- * cogl_push_framebuffer (framebuffer);
- * setup_viewport (framebuffer_width,
- * framebuffer_height,
- * perspective.fovy,
- * perspective.aspect,
- * perspective.z_near,
- * perspective.z_far);
- * }
- * ]|
- *
- * The previous framebuffer can be restored by calling cogl_pop_framebuffer()
- *
- * Since: 1.2
- */
-void
-cogl_push_framebuffer (CoglFramebuffer *buffer);
-
-/**
- * cogl_pop_framebuffer:
- *
- * Restores the framebuffer that was previously at the top of the stack.
- * All subsequent drawing will be redirected to this framebuffer.
- *
- * Since: 1.2
- */
-void
-cogl_pop_framebuffer (void);
-
-#ifndef COGL_DISABLE_DEPRECATED
-
-/**
- * cogl_push_draw_buffer:
- *
- * Save cogl_set_draw_buffer() state.
- *
- * Deprecated: 1.2: The draw buffer API was replaced with a framebuffer API
- */
-void
-cogl_push_draw_buffer (void) G_GNUC_DEPRECATED;
-
-/**
- * cogl_pop_draw_buffer:
- *
- * Restore cogl_set_draw_buffer() state.
- *
- * Deprecated: 1.2: The draw buffer API was replaced with a framebuffer API
- */
-void
-cogl_pop_draw_buffer (void) G_GNUC_DEPRECATED;
-
-#endif /* COGL_DISABLE_DEPRECATED */
-
-/**
* cogl_flush:
*
* This function should only need to be called in exceptional circumstances.
diff --git a/doc/reference/cogl2/cogl2-sections.txt b/doc/reference/cogl2/cogl2-sections.txt
index 04757cd..c006b89 100644
--- a/doc/reference/cogl2/cogl2-sections.txt
+++ b/doc/reference/cogl2/cogl2-sections.txt
@@ -417,12 +417,6 @@ cogl_framebuffer_push_scissor_clip
cogl_framebuffer_push_rectangle_clip
cogl_framebuffer_push_primitive_clip
cogl_framebuffer_pop_clip
-
-<SUBSECTION>
-cogl_get_draw_framebuffer
-cogl_set_framebuffer
-cogl_push_framebuffer
-cogl_pop_framebuffer
</SECTION>
<SECTION>
diff --git a/examples/cogl-x11-tfp.c b/examples/cogl-x11-tfp.c
index b59327c..e7d7b0e 100644
--- a/examples/cogl-x11-tfp.c
+++ b/examples/cogl-x11-tfp.c
@@ -190,7 +190,6 @@ main (int argc, char **argv)
}
fb = COGL_FRAMEBUFFER (onscreen);
- cogl_push_framebuffer (fb);
for (;;)
{
--
1.7.7.6
More information about the Cogl
mailing list