From 60fd6ab708927f37d29ed58262ed812288c9e72a Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Wed, 12 Jan 2011 22:06:58 +0000 Subject: [PATCH] cogl: Adds _cogl_swap_buffers_notify for clutter backends This adds a stop-gap mechanism for Cogl to know when the window system is requested to present the current backbuffer to the frontbuffer by adding a _cogl_swap_buffers_notify function that backends are now expected to call right after issuing the equivalent request to OpenGL vie the platforms OpenGL binding layer. This (blindly) updates all the backends to call this new function. For now Cogl doesn't do anything with the notification but the intention is to use it as part of a planned read-pixel optimization which will need to reset some state at the start of each new frame. --- cogl/cogl-framebuffer-private.h | 3 +++ cogl/cogl-framebuffer.c | 5 +++++ cogl/cogl.c | 10 ++++++++++ cogl/cogl.h | 3 +++ 4 files changed, 21 insertions(+) diff --git a/cogl/cogl-framebuffer-private.h b/cogl/cogl-framebuffer-private.h index 0bfc64e61..3d9cba364 100644 --- a/cogl/cogl-framebuffer-private.h +++ b/cogl/cogl-framebuffer-private.h @@ -193,6 +193,9 @@ _cogl_framebuffer_flush_journal (CoglFramebuffer *framebuffer); void _cogl_framebuffer_flush_dependency_journals (CoglFramebuffer *framebuffer); +void +_cogl_framebuffer_swap_notify (CoglFramebuffer *framebuffer); + typedef enum _CoglFramebufferFlushFlags { /* XXX: When using this, that imples you are going to manually load the diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c index ede491e37..a0c5b944d 100644 --- a/cogl/cogl-framebuffer.c +++ b/cogl/cogl-framebuffer.c @@ -313,6 +313,11 @@ _cogl_framebuffer_clear (CoglFramebuffer *framebuffer, cogl_color_get_alpha_float (color)); } +void +_cogl_framebuffer_swap_notify (CoglFramebuffer *framebuffer) +{ +} + int _cogl_framebuffer_get_width (CoglFramebuffer *framebuffer) { diff --git a/cogl/cogl.c b/cogl/cogl.c index c2cee24ae..b6c3fa535 100644 --- a/cogl/cogl.c +++ b/cogl/cogl.c @@ -1097,3 +1097,13 @@ _cogl_error_quark (void) return g_quark_from_static_string ("cogl-error-quark"); } +/* Until Cogl becomes responsible for handling swap-buffer requests + * this API is used by Clutter to notify us when it issues a + * swap-buffer on our behalf. */ +void +_cogl_swap_buffers_notify (void) +{ + _COGL_GET_CONTEXT (ctx, NO_RETVAL); + + _cogl_framebuffer_swap_notify (_cogl_get_framebuffer ()); +} diff --git a/cogl/cogl.h b/cogl/cogl.h index d6170fe16..0e8d1ad08 100644 --- a/cogl/cogl.h +++ b/cogl/cogl.h @@ -1293,6 +1293,9 @@ _cogl_driver_error_quark (void); void _cogl_onscreen_clutter_backend_set_size (int width, int height); +void +_cogl_swap_buffers_notify (void); + G_END_DECLS #undef __COGL_H_INSIDE__