From 479c5fd2c965b79ca19986150b2bb36f0e595e00 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Wed, 8 Feb 2012 23:46:16 +0000 Subject: [PATCH] onscreen: move swap_buffer apis to onscreen namespace This moves all the cogl_framebuffer_ apis relating to swap buffer requests into the cogl_onscreen_ namespace since on CoglOnscreen framebuffers have back buffers that can be swapped. Reviewed-by: Neil Roberts --- cogl/cogl-onscreen.c | 22 ++++++++-------- cogl/cogl-onscreen.h | 51 ++++++++++++++++++------------------- examples/cogl-crate.c | 8 +++--- examples/cogl-hello.c | 2 +- examples/cogl-msaa.c | 2 +- examples/cogl-sdl-hello.c | 2 +- examples/cogl-x11-foreign.c | 2 +- examples/cogl-x11-tfp.c | 2 +- examples/cogland.c | 2 +- 9 files changed, 46 insertions(+), 47 deletions(-) diff --git a/cogl/cogl-onscreen.c b/cogl/cogl-onscreen.c index 103baf950..4247de699 100644 --- a/cogl/cogl-onscreen.c +++ b/cogl/cogl-onscreen.c @@ -127,8 +127,9 @@ _cogl_onscreen_free (CoglOnscreen *onscreen) } void -cogl_framebuffer_swap_buffers (CoglFramebuffer *framebuffer) +cogl_onscreen_swap_buffers (CoglOnscreen *onscreen) { + CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen); const CoglWinsysVtable *winsys; _COGL_RETURN_IF_FAIL (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN); @@ -144,10 +145,11 @@ cogl_framebuffer_swap_buffers (CoglFramebuffer *framebuffer) } void -cogl_framebuffer_swap_region (CoglFramebuffer *framebuffer, - const int *rectangles, - int n_rectangles) +cogl_onscreen_swap_region (CoglOnscreen *onscreen, + const int *rectangles, + int n_rectangles) { + CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen); const CoglWinsysVtable *winsys; _COGL_RETURN_IF_FAIL (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN); @@ -254,11 +256,10 @@ cogl_win32_onscreen_get_window (CoglOnscreen *onscreen) #endif /* COGL_HAS_WIN32_SUPPORT */ unsigned int -cogl_framebuffer_add_swap_buffers_callback (CoglFramebuffer *framebuffer, - CoglSwapBuffersNotify callback, - void *user_data) +cogl_onscreen_add_swap_buffers_callback (CoglOnscreen *onscreen, + CoglSwapBuffersNotify callback, + void *user_data) { - CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer); CoglSwapBuffersNotifyEntry *entry = g_slice_new0 (CoglSwapBuffersNotifyEntry); static int next_swap_buffers_callback_id = 0; @@ -272,10 +273,9 @@ cogl_framebuffer_add_swap_buffers_callback (CoglFramebuffer *framebuffer, } void -cogl_framebuffer_remove_swap_buffers_callback (CoglFramebuffer *framebuffer, - unsigned int id) +cogl_onscreen_remove_swap_buffers_callback (CoglOnscreen *onscreen, + unsigned int id) { - CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer); CoglSwapBuffersNotifyEntry *entry; COGL_TAILQ_FOREACH (entry, &onscreen->swap_callbacks, list_node) diff --git a/cogl/cogl-onscreen.h b/cogl/cogl-onscreen.h index dbc4784ca..66206bacb 100644 --- a/cogl/cogl-onscreen.h +++ b/cogl/cogl-onscreen.h @@ -3,7 +3,7 @@ * * An object oriented GL/GLES Abstraction/Utility Layer * - * Copyright (C) 2011 Intel Corporation. + * Copyright (C) 2011,2012 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -289,10 +289,9 @@ cogl_onscreen_show (CoglOnscreen *onscreen); void cogl_onscreen_hide (CoglOnscreen *onscreen); -/* XXX: Actually should this be renamed too cogl_onscreen_swap_buffers()? */ /** - * cogl_framebuffer_swap_buffers: - * @framebuffer: A #CoglFramebuffer + * cogl_onscreen_swap_buffers: + * @onscreen: A #CoglOnscreen framebuffer * * Swaps the current back buffer being rendered too, to the front for display. * @@ -302,15 +301,15 @@ cogl_onscreen_hide (CoglOnscreen *onscreen); * start a new frame that incrementally builds on the contents of the previous * frame. * - * Since: 1.8 + * Since: 1.10 * Stability: unstable */ void -cogl_framebuffer_swap_buffers (CoglFramebuffer *framebuffer); +cogl_onscreen_swap_buffers (CoglOnscreen *onscreen); /** - * cogl_framebuffer_swap_region: - * @framebuffer: A #CoglFramebuffer + * cogl_onscreen_swap_region: + * @onscreen: A #CoglOnscreen framebuffer * @rectangles: An array of integer 4-tuples representing rectangles as * (x, y, width, height) tuples. * @n_rectangles: The number of 4-tuples to be read from @rectangles @@ -320,32 +319,32 @@ cogl_framebuffer_swap_buffers (CoglFramebuffer *framebuffer); * defined by 4 sequential (x, y, width, height) integers. * * This function also implicitly discards the contents of the color, depth and - * stencil buffers as if cogl_framebuffer_discard_buffers() were used. The + * stencil buffers as if cogl_onscreen_discard_buffers() were used. The * significance of the discard is that you should not expect to be able to * start a new frame that incrementally builds on the contents of the previous * frame. * - * Since: 1.8 + * Since: 1.10 * Stability: unstable */ void -cogl_framebuffer_swap_region (CoglFramebuffer *framebuffer, - const int *rectangles, - int n_rectangles); +cogl_onscreen_swap_region (CoglOnscreen *onscreen, + const int *rectangles, + int n_rectangles); typedef void (*CoglSwapBuffersNotify) (CoglFramebuffer *framebuffer, void *user_data); /** - * cogl_framebuffer_add_swap_buffers_callback: - * @framebuffer A #CoglFramebuffer + * cogl_onscreen_add_swap_buffers_callback: + * @onscreen: A #CoglOnscreen framebuffer * @callback: A callback function to call when a swap has completed * @user_data: A private pointer to be passed to @callback * * Installs a @callback function that should be called whenever a swap buffers - * request (made using cogl_framebuffer_swap_buffers()) for the given - * @framebuffer completes. + * request (made using cogl_onscreen_swap_buffers()) for the given + * @onscreen completes. * * Applications should check for the %COGL_FEATURE_ID_SWAP_BUFFERS_EVENT * feature before using this API. It's currently undefined when and if @@ -362,24 +361,24 @@ typedef void (*CoglSwapBuffersNotify) (CoglFramebuffer *framebuffer, * Stability: unstable */ unsigned int -cogl_framebuffer_add_swap_buffers_callback (CoglFramebuffer *framebuffer, - CoglSwapBuffersNotify callback, - void *user_data); +cogl_onscreen_add_swap_buffers_callback (CoglOnscreen *onscreen, + CoglSwapBuffersNotify callback, + void *user_data); /** - * cogl_framebuffer_remove_swap_buffers_callback: - * @framebuffer: - * @id: An identifier returned from cogl_framebuffer_add_swap_buffers_callback() + * cogl_onscreen_remove_swap_buffers_callback: + * @onscreen: A #CoglOnscreen framebuffer + * @id: An identifier returned from cogl_onscreen_add_swap_buffers_callback() * * Removes a callback that was previously registered - * using cogl_framebuffer_add_swap_buffers_callback(). + * using cogl_onscreen_add_swap_buffers_callback(). * * Since: 1.10 * Stability: unstable */ void -cogl_framebuffer_remove_swap_buffers_callback (CoglFramebuffer *framebuffer, - unsigned int id); +cogl_onscreen_remove_swap_buffers_callback (CoglOnscreen *onscreen, + unsigned int id); G_END_DECLS diff --git a/examples/cogl-crate.c b/examples/cogl-crate.c index cddd990dd..f0a7bbd2a 100644 --- a/examples/cogl-crate.c +++ b/examples/cogl-crate.c @@ -273,9 +273,9 @@ main (int argc, char **argv) cogl_has_feature (ctx, COGL_FEATURE_ID_SWAP_BUFFERS_EVENT); if (has_swap_notify) - cogl_framebuffer_add_swap_buffers_callback (fb, - swap_notify_cb, - &data); + cogl_onscreen_add_swap_buffers_callback (COGL_ONSCREEN (fb), + swap_notify_cb, + &data); while (1) { @@ -286,7 +286,7 @@ main (int argc, char **argv) if (data.swap_ready) { paint (&data); - cogl_framebuffer_swap_buffers (fb); + cogl_onscreen_swap_buffers (COGL_ONSCREEN (fb)); } cogl_poll_get_info (ctx, &poll_fds, &n_poll_fds, &timeout); diff --git a/examples/cogl-hello.c b/examples/cogl-hello.c index 2896f2439..4e3d5e243 100644 --- a/examples/cogl-hello.c +++ b/examples/cogl-hello.c @@ -41,7 +41,7 @@ main (int argc, char **argv) cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1); cogl_framebuffer_draw_primitive (fb, pipeline, triangle); - cogl_framebuffer_swap_buffers (fb); + cogl_onscreen_swap_buffers (onscreen); cogl_poll_get_info (ctx, &poll_fds, &n_poll_fds, &timeout); g_poll ((GPollFD *) poll_fds, n_poll_fds, 0); diff --git a/examples/cogl-msaa.c b/examples/cogl-msaa.c index 320dbc2d1..ba23b3833 100644 --- a/examples/cogl-msaa.c +++ b/examples/cogl-msaa.c @@ -102,7 +102,7 @@ main (int argc, char **argv) cogl_set_source_texture (tex); cogl_rectangle (0, 1, 1, -1); - cogl_framebuffer_swap_buffers (fb); + cogl_onscreen_swap_buffers (onscreen); cogl_poll_get_info (ctx, &poll_fds, &n_poll_fds, &timeout); g_poll ((GPollFD *) poll_fds, n_poll_fds, 0); diff --git a/examples/cogl-sdl-hello.c b/examples/cogl-sdl-hello.c index 057235c20..8643c38f6 100644 --- a/examples/cogl-sdl-hello.c +++ b/examples/cogl-sdl-hello.c @@ -28,7 +28,7 @@ redraw (Data *data) cogl_framebuffer_draw_primitive (fb, data->pipeline, data->triangle); cogl_framebuffer_pop_matrix (fb); - cogl_framebuffer_swap_buffers (fb); + cogl_onscreen_swap_buffers (COGL_ONSCREEN (fb)); } static void diff --git a/examples/cogl-x11-foreign.c b/examples/cogl-x11-foreign.c index 202b8d250..7329a3fbf 100644 --- a/examples/cogl-x11-foreign.c +++ b/examples/cogl-x11-foreign.c @@ -172,7 +172,7 @@ main (int argc, char **argv) } cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1); cogl_framebuffer_draw_primitive (fb, pipeline, triangle); - cogl_framebuffer_swap_buffers (fb); + cogl_onscreen_swap_buffers (onscreen); cogl_poll_get_info (ctx, &poll_fds, &n_poll_fds, &timeout); g_poll ((GPollFD *) poll_fds, n_poll_fds, 0); diff --git a/examples/cogl-x11-tfp.c b/examples/cogl-x11-tfp.c index 74ef45d45..78aafde0e 100644 --- a/examples/cogl-x11-tfp.c +++ b/examples/cogl-x11-tfp.c @@ -217,7 +217,7 @@ main (int argc, char **argv) cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1); cogl_set_source_texture (tfp); cogl_rectangle (-0.8, 0.8, 0.8, -0.8); - cogl_framebuffer_swap_buffers (fb); + cogl_onscreen_swap_buffers (onscreen); } return 0; diff --git a/examples/cogland.c b/examples/cogland.c index 36c2cb345..ffcbe479c 100644 --- a/examples/cogland.c +++ b/examples/cogland.c @@ -527,7 +527,7 @@ paint_cb (void *user_data) cogl_rectangle (-1, 1, 1, -1); } } - cogl_framebuffer_swap_buffers (fb); + cogl_onscreen_swap_buffers (COGL_ONSCREEN (fb)); cogl_pop_framebuffer (); }