Chromium Code Reviews| Index: runtime/embedders/openglui/common/gl.dart |
| =================================================================== |
| --- runtime/embedders/openglui/common/gl.dart (revision 19440) |
| +++ runtime/embedders/openglui/common/gl.dart (working copy) |
| @@ -13,6 +13,42 @@ |
| BodyElement() : _nodes = new List(); |
| } |
| +// The OpenGLUI "equivalent" of Window. |
| + |
| +typedef void RequestAnimationFrameCallback(num highResTime); |
| + |
| +class Window { |
| + static int _nextId = 0; |
| + Map<int, Function> _callbacks; |
|
vsm
2013/03/07 23:53:04
Might as well s/Function/RequestAnimationFrameCall
gram
2013/03/08 00:26:42
Done.
|
| + |
| + Window._internal() : _callbacks = new Map(); |
|
vsm
2013/03/07 23:53:04
nit: new lines between methods.
gram
2013/03/08 00:26:42
Done.
|
| + 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 +58,10 @@ |
| Document document = new Document._internal(); |
| +update_() { |
|
vsm
2013/03/07 23:53:04
TODO to make private? I assume this is only calle
gram
2013/03/08 00:26:42
Done.
|
| + window._dispatch(); |
| +} |
| + |
| // Event handling. This is very kludgy for now, especially the |
| // bare-bones Stream stuff! |