Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Unified Diff: runtime/embedders/openglui/common/gl.dart

Issue 12506004: Added window.requestAnimationFrame. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/embedders/openglui/common/vm_glue.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/embedders/openglui/common/gl.dart
===================================================================
--- runtime/embedders/openglui/common/gl.dart (revision 19664)
+++ runtime/embedders/openglui/common/gl.dart (working copy)
@@ -13,6 +13,43 @@
BodyElement() : _nodes = new List();
}
+// The OpenGLUI "equivalent" of Window.
+
+typedef void RequestAnimationFrameCallback(num highResTime);
+
+class Window {
+ static int _nextId = 0;
+ Map<int, RequestAnimationFrameCallback> _callbacks;
+
+ Window._internal() : _callbacks = new Map();
+
+ int requestAnimationFrame(RequestAnimationFrameCallback callback) {
+ _callbacks[_nextId++] = callback;
+ }
+ void cancelAnimationFrame(id) {
+ if (_callbacks.containsKey(id)) {
+ _callbacks.remove(id);
+ }
+ }
+ get animationFrame {
+ // TODO(gram)
+ return null;
+ }
+
+ void _dispatch() {
+ var when = (new DateTime.now()).millisecondsSinceEpoch;
+ // We clear out the callbacks map before calling any callbacks,
+ // as they may schedule new callbacks.
+ var oldcallbacks = _callbacks;
+ _callbacks = new Map();
+ for (var c in oldcallbacks.values) {
+ c(when);
+ }
+ }
+}
+
+Window window = new Window._internal();
+
// The OpenGLUI "equivalent" of HtmlDocument.
class Document {
BodyElement _body;
@@ -22,6 +59,11 @@
Document document = new Document._internal();
+// TODO(gram): make private and call from within library context.
+update_() {
+ window._dispatch();
+}
+
// Event handling. This is very kludgy for now, especially the
// bare-bones Stream stuff!
« no previous file with comments | « no previous file | runtime/embedders/openglui/common/vm_glue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698