mirror of
https://github.com/brl/mutter.git
synced 2025-02-03 15:22:15 +00:00
cogl-crate: use new _add_frame_callback api
This updates cogl-crate to use the new cogl_onscreen_add_frame_callback() api to use _SYNC events for throttling. Reviewed-by: Neil Roberts <neil@linux.intel.com> (cherry picked from commit 47ea52774025b620258e00a32cb873674d0fc721)
This commit is contained in:
parent
51c1b3fbff
commit
d12f39d0e6
@ -130,12 +130,15 @@ paint (Data *data)
|
||||
}
|
||||
|
||||
static void
|
||||
swap_notify_cb (CoglFramebuffer *framebuffer,
|
||||
frame_event_cb (CoglOnscreen *onscreen,
|
||||
CoglFrameEvent event,
|
||||
CoglFrameInfo *info,
|
||||
void *user_data)
|
||||
{
|
||||
Data *data = user_data;
|
||||
|
||||
data->swap_ready = TRUE;
|
||||
if (event == COGL_FRAME_EVENT_SYNC)
|
||||
data->swap_ready = TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
@ -149,7 +152,6 @@ main (int argc, char **argv)
|
||||
PangoRectangle hello_label_size;
|
||||
float fovy, aspect, z_near, z_2d, z_far;
|
||||
CoglDepthState depth_state;
|
||||
CoglBool has_swap_notify;
|
||||
|
||||
ctx = cogl_context_new (NULL, &error);
|
||||
if (!ctx) {
|
||||
@ -267,13 +269,10 @@ main (int argc, char **argv)
|
||||
|
||||
data.swap_ready = TRUE;
|
||||
|
||||
has_swap_notify =
|
||||
cogl_has_feature (ctx, COGL_FEATURE_ID_SWAP_BUFFERS_EVENT);
|
||||
|
||||
if (has_swap_notify)
|
||||
cogl_onscreen_add_swap_buffers_callback (COGL_ONSCREEN (fb),
|
||||
swap_notify_cb,
|
||||
&data);
|
||||
cogl_onscreen_add_frame_callback (COGL_ONSCREEN (fb),
|
||||
frame_event_cb,
|
||||
&data,
|
||||
NULL); /* destroy notify */
|
||||
|
||||
while (1)
|
||||
{
|
||||
@ -289,14 +288,6 @@ main (int argc, char **argv)
|
||||
|
||||
cogl_poll_get_info (ctx, &poll_fds, &n_poll_fds, &timeout);
|
||||
|
||||
if (!has_swap_notify)
|
||||
{
|
||||
/* If the winsys doesn't support swap event notification
|
||||
then we'll just redraw constantly */
|
||||
data.swap_ready = TRUE;
|
||||
timeout = 0;
|
||||
}
|
||||
|
||||
g_poll ((GPollFD *) poll_fds, n_poll_fds,
|
||||
timeout == -1 ? -1 : timeout / 1000);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user