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.
This commit is contained in:
Robert Bragg 2011-01-12 22:06:58 +00:00
parent e150f474b3
commit 142b229c5c
10 changed files with 31 additions and 1 deletions

View File

@ -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

View File

@ -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)
{

View File

@ -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 ());
}

View File

@ -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__

View File

@ -573,6 +573,7 @@ _clutter_stage_egl_redraw (ClutterStageEGL *stage_egl,
CLUTTER_TIMER_START (_clutter_uprof_context, swapbuffers_timer);
eglSwapBuffers (backend_egl->edpy, egl_surface);
CLUTTER_TIMER_STOP (_clutter_uprof_context, swapbuffers_timer);
_cogl_swap_buffers_notify ();
}
/* reset the redraw clipping for the next paint... */

View File

@ -77,6 +77,7 @@ clutter_backend_egl_redraw (ClutterBackend *backend,
cogl_flush ();
eglWaitGL();
eglSwapBuffers (backend_egl->edpy, stage_egl->egl_surface);
_cogl_swap_buffers_notify ();
}
static ClutterActor *

View File

@ -737,6 +737,7 @@ _clutter_stage_glx_redraw (ClutterStageGLX *stage_glx,
CLUTTER_TIMER_START (_clutter_uprof_context, swapbuffers_timer);
glXSwapBuffers (backend_x11->xdpy, drawable);
CLUTTER_TIMER_STOP (_clutter_uprof_context, swapbuffers_timer);
_cogl_swap_buffers_notify ();
}
backend_glx->last_video_sync_count = video_sync_count;

View File

@ -152,6 +152,7 @@ clutter_stage_osx_get_wrapper (ClutterStageWindow *stage_window);
_clutter_stage_do_paint (CLUTTER_STAGE (self->stage_osx->wrapper), NULL);
cogl_flush ();
[[self openGLContext] flushBuffer];
_cogl_swap_buffers_notify ();
}
/* In order to receive key events */

View File

@ -372,6 +372,8 @@ wayland_swap_buffers (ClutterStageWayland *stage_wayland)
wl_display_frame_callback (backend_wayland->wayland_display,
wayland_frame_callback,
stage_wayland);
_cogl_swap_buffers_notify ();
}
static void

View File

@ -498,7 +498,10 @@ clutter_backend_win32_redraw (ClutterBackend *backend,
cogl_flush ();
if (stage_win32->client_dc)
SwapBuffers (stage_win32->client_dc);
{
SwapBuffers (stage_win32->client_dc);
_cogl_swap_buffers_notify ();
}
}
static ClutterStageWindow *