commit ae35db9

Michael Forney  ·  2013-06-14 11:31:20 +0000 UTC
parent 79b3408
Send frame callbacks
3 files changed,  +33, -1
+15, -0
 1@@ -163,10 +163,25 @@ static void handle_drm_event(struct wl_listener * listener, void * data)
 2         case SWC_DRM_PAGE_FLIP:
 3         {
 4             struct swc_output * output = event->data;
 5+            struct swc_surface * surface;
 6+            struct timeval timeval;
 7+            uint32_t time;
 8 
 9             output->repaint_scheduled = false;
10             output->front_buffer ^= 1;
11 
12+            gettimeofday(&timeval, NULL);
13+            time = timeval.tv_sec * 1000 + timeval.tv_usec / 1000;
14+
15+            /* Handle all frame callbacks for surfaces on this output. */
16+            wl_list_for_each(surface, &compositor->surfaces, link)
17+            {
18+                swc_surface_send_frame_callbacks(surface, time);
19+
20+                if (surface->state.buffer)
21+                    wl_buffer_send_release(&surface->state.buffer->resource);
22+            }
23+
24             break;
25         }
26     }
+15, -1
 1@@ -64,7 +64,8 @@ static void frame(struct wl_client * client, struct wl_resource * resource,
 2 
 3     callback_resource = wl_client_add_object(client, &wl_callback_interface,
 4                                              NULL, id, NULL);
 5-    wl_list_insert(surface->pending.state.frame_callbacks.prev, &resource->link);
 6+    wl_list_insert(surface->pending.state.frame_callbacks.prev,
 7+                   &callback_resource->link);
 8 }
 9 
10 static void set_opaque_region(struct wl_client * client,
11@@ -174,4 +175,17 @@ void swc_surface_finish(struct swc_surface * surface)
12 {
13 }
14 
15+void swc_surface_send_frame_callbacks(struct swc_surface * surface,
16+                                      uint32_t time)
17+{
18+    struct wl_resource * callback;
19+
20+    wl_list_for_each(callback, &surface->state.frame_callbacks, link)
21+    {
22+        wl_callback_send_done(callback, time);
23+        wl_resource_destroy(callback);
24+    }
25+
26+    wl_list_init(&surface->state.frame_callbacks);
27+}
28 
+3, -0
1@@ -67,5 +67,8 @@ bool swc_surface_initialize(struct swc_surface * surface,
2 
3 void swc_surface_finish(struct swc_surface * surface);
4 
5+void swc_surface_send_frame_callbacks(struct swc_surface * surface,
6+                                      uint32_t time);
7+
8 #endif
9