[gtk+/wip/chergert/quartz-frame-clock: 218/228] quartz: pause/unpause display link



commit fca1822d5b35f18b036f660eea421b3344597589
Author: Christian Hergert <christian hergert me>
Date:   Fri Sep 11 15:02:30 2015 -0700

    quartz: pause/unpause display link
    
    Blah

 gdk/quartz/gdkdisplaylinksource.c |   11 +++++++----
 gdk/quartz/gdkdisplaylinksource.h |    2 +-
 2 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/gdk/quartz/gdkdisplaylinksource.c b/gdk/quartz/gdkdisplaylinksource.c
index 6b0a470..f4418e0 100644
--- a/gdk/quartz/gdkdisplaylinksource.c
+++ b/gdk/quartz/gdkdisplaylinksource.c
@@ -91,13 +91,13 @@ static GSourceFuncs gdk_display_link_source_funcs = {
 void
 gdk_display_link_source_pause (GdkDisplayLinkSource *source)
 {
-  //CVDisplayLinkStop (source->display_link);
+  CVDisplayLinkStop (source->display_link);
 }
 
 void
 gdk_display_link_source_unpause (GdkDisplayLinkSource *source)
 {
-  //CVDisplayLinkStart (source->display_link);
+  CVDisplayLinkStart (source->display_link);
 }
 
 static CVReturn
@@ -111,6 +111,9 @@ gdk_display_link_source_frame_cb (CVDisplayLinkRef   display_link,
   GdkDisplayLinkSource *impl = user_data;
   GMainContext *context;
   gint64 presentation_time;
+  gboolean needs_wakeup;
+
+  needs_wakeup = !g_atomic_int_get (&impl->needs_dispatch);
 
   presentation_time = host_to_frame_clock_time (inOutputTime->hostTime);
 
@@ -118,7 +121,7 @@ gdk_display_link_source_frame_cb (CVDisplayLinkRef   display_link,
   impl->needs_dispatch = TRUE;
 
   context = g_source_get_context ((GSource *)impl);
-  if (context != NULL)
+  if ((context != NULL) && needs_wakeup)
     g_main_context_wakeup (context);
 
   return kCVReturnSuccess;
@@ -179,7 +182,7 @@ gdk_display_link_source_new (void)
 
   g_source_set_name (source, "[gdk] quartz frame timer");
 
-#if 1
+#if 0
   CVDisplayLinkStart (impl->display_link);
 #endif
 
diff --git a/gdk/quartz/gdkdisplaylinksource.h b/gdk/quartz/gdkdisplaylinksource.h
index 805a9e0..7493b0c 100644
--- a/gdk/quartz/gdkdisplaylinksource.h
+++ b/gdk/quartz/gdkdisplaylinksource.h
@@ -36,7 +36,7 @@ typedef struct
   gint64           refresh_interval;
 
   volatile gint64  presentation_time;
-  volatile guint   needs_dispatch : 1;
+  volatile guint   needs_dispatch;
 } GdkDisplayLinkSource;
 
 GSource *gdk_display_link_source_new     (void);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]