[Cogl] [PATCH 7/7] avoid redundant idle if using FRAME_SYNC to throttle

Robert Bragg robert at sixbynine.org
Fri Feb 15 08:57:09 PST 2013


From: Robert Bragg <robert at linux.intel.com>

This updates the examples and test-journal which now use the _FRAME_SYNC
events to throttle rendering so that they don't install a redundant idle
handler to paint when they get a FRAME_SYNC event and instead they now
directly paint when the event is received.
---
 examples/cogl-gles2-context.c   | 4 ++--
 examples/cogl-gles2-gears.c     | 4 ++--
 examples/cogl-hello.c           | 2 +-
 tests/micro-perf/test-journal.c | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/examples/cogl-gles2-context.c b/examples/cogl-gles2-context.c
index c102a0c..68e7503 100644
--- a/examples/cogl-gles2-context.c
+++ b/examples/cogl-gles2-context.c
@@ -59,8 +59,8 @@ frame_event_cb (CoglOnscreen *onscreen,
                 CoglFrameInfo *info,
                 void *user_data)
 {
-  if (event == COGL_FRAME_EVENT_SYNC)
-    g_idle_add (paint_cb, user_data);
+    if (event == COGL_FRAME_EVENT_SYNC)
+        paint_cb (user_data);
 }
 
 int
diff --git a/examples/cogl-gles2-gears.c b/examples/cogl-gles2-gears.c
index ad795b0..d7dd271 100644
--- a/examples/cogl-gles2-gears.c
+++ b/examples/cogl-gles2-gears.c
@@ -604,8 +604,8 @@ frame_event_cb (CoglOnscreen *onscreen,
                 CoglFrameInfo *info,
                 void *user_data)
 {
-  if (event == COGL_FRAME_EVENT_SYNC)
-    g_idle_add (paint_cb, user_data);
+    if (event == COGL_FRAME_EVENT_SYNC)
+        paint_cb (user_data);
 }
 
 /**
diff --git a/examples/cogl-hello.c b/examples/cogl-hello.c
index 8d86a97..5bda9bf 100644
--- a/examples/cogl-hello.c
+++ b/examples/cogl-hello.c
@@ -29,7 +29,7 @@ frame_event_cb (CoglOnscreen *onscreen,
                 void *user_data)
 {
     if (event == COGL_FRAME_EVENT_SYNC)
-        g_idle_add (paint_cb, user_data);
+        paint_cb (user_data);
 }
 
 int
diff --git a/tests/micro-perf/test-journal.c b/tests/micro-perf/test-journal.c
index dec485b..84d3c06 100644
--- a/tests/micro-perf/test-journal.c
+++ b/tests/micro-perf/test-journal.c
@@ -130,7 +130,7 @@ frame_event_cb (CoglOnscreen *onscreen,
                 void *user_data)
 {
   if (event == COGL_FRAME_EVENT_SYNC)
-    g_idle_add (paint_cb, user_data);
+    paint_cb (user_data);
 }
 
 int
-- 
1.8.1.1



More information about the Cogl mailing list