mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 20:32:16 +00:00
cogl-gles2-context: use new _add_frame_callback api
This updates cogl-gles2-context to use the new cogl_onscreen_add_frame_callback() api to use _SYNC events for throttling. (cherry picked from commit 2063306645e32ceb3252ebcd2eebd33c879d7fbe)
This commit is contained in:
parent
4347f33917
commit
adfb561258
@ -50,19 +50,16 @@ paint_cb (void *user_data)
|
|||||||
|
|
||||||
cogl_onscreen_swap_buffers (COGL_ONSCREEN (data->fb));
|
cogl_onscreen_swap_buffers (COGL_ONSCREEN (data->fb));
|
||||||
|
|
||||||
/* If the driver can deliver swap complete events then we can remove
|
return FALSE; /* remove the callback */
|
||||||
* the idle paint callback until we next get a swap complete event
|
|
||||||
* otherwise we keep the idle paint callback installed and simply
|
|
||||||
* paint as fast as the driver will allow... */
|
|
||||||
if (cogl_has_feature (data->ctx, COGL_FEATURE_ID_SWAP_BUFFERS_EVENT))
|
|
||||||
return FALSE; /* remove the callback */
|
|
||||||
else
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
swap_complete_cb (CoglFramebuffer *framebuffer, void *user_data)
|
frame_event_cb (CoglOnscreen *onscreen,
|
||||||
|
CoglFrameEvent event,
|
||||||
|
CoglFrameInfo *info,
|
||||||
|
void *user_data)
|
||||||
{
|
{
|
||||||
|
if (event == COGL_FRAME_EVENT_SYNC)
|
||||||
g_idle_add (paint_cb, user_data);
|
g_idle_add (paint_cb, user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,9 +125,10 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
g_source_attach (cogl_source, NULL);
|
g_source_attach (cogl_source, NULL);
|
||||||
|
|
||||||
if (cogl_has_feature (data.ctx, COGL_FEATURE_ID_SWAP_BUFFERS_EVENT))
|
cogl_onscreen_add_frame_callback (COGL_ONSCREEN (data.fb),
|
||||||
cogl_onscreen_add_swap_buffers_callback (COGL_ONSCREEN (data.fb),
|
frame_event_cb,
|
||||||
swap_complete_cb, &data);
|
&data,
|
||||||
|
NULL); /* destroy notify */
|
||||||
|
|
||||||
g_idle_add (paint_cb, &data);
|
g_idle_add (paint_cb, &data);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user