gnome-shell r156 - trunk/js/ui



Author: otaylor
Date: Tue Jan 20 18:32:25 2009
New Revision: 156
URL: http://svn.gnome.org/viewvc/gnome-shell?rev=156&view=rev

Log:
Adapt to new Tweener frame ticker API

Now that getTime() has been added to the frame ticker interface
we can implement frame dropping in a more straightforward way
than adjusting the FRAME_RATE member variable to fool Tweener
into doing the right thing.

Modified:
   trunk/js/ui/main.js

Modified: trunk/js/ui/main.js
==============================================================================
--- trunk/js/ui/main.js	(original)
+++ trunk/js/ui/main.js	Tue Jan 20 18:32:25 2009
@@ -37,13 +37,14 @@
 }
 
 ClutterFrameTicker.prototype = {
-    TARGET_FRAME_RATE : 60,
+    FRAME_RATE : 60,
 
     _init : function() {
         // We don't have a finite duration; tweener will tell us to stop
         // when we need to stop, so use 1000 seconds as "infinity"
-        this._timeline = new Clutter.Timeline({ fps: this.TARGET_FRAME_RATE,
+        this._timeline = new Clutter.Timeline({ fps: this.FRAME_RATE,
                                                 duration: 1000*1000 });
+        this._currentTime = 0;
         this._frame = 0;
 
         let me = this;
@@ -76,13 +77,18 @@
             delta = frame - this._frame;
 
         if (delta == 0) // protect against divide-by-0 if we get a frame twice
-            this.FRAME_RATE = this.TARGET_FRAME_RATE;
-        else
-            this.FRAME_RATE = this.TARGET_FRAME_RATE / delta;
+            delta = 1;
+
+        // currentTime is in milliseconds
+        this._currentTime += (1000 * delta) / this.FRAME_RATE;
         this._frame = frame;
         this.emit('prepare-frame');
     },
 
+    getTime : function() {
+        return this._currentTime;
+    },
+
     start : function() {
         this._timeline.start();
     },
@@ -90,6 +96,7 @@
     stop : function() {
         this._timeline.stop();
         this._frame = 0;
+        this._currentTime = 0;
     }
 };
 



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