aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library_browser.js8
-rw-r--r--system/include/emscripten.h9
2 files changed, 17 insertions, 0 deletions
diff --git a/src/library_browser.js b/src/library_browser.js
index c42cef14..d49c4103 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -241,6 +241,14 @@ mergeInto(LibraryManager.library, {
}
}
styleSheet.insertRule('canvas.emscripten { border: 1px solid black; cursor: none; }', 0);
+ },
+
+ emscripten_get_now: function() {
+ if (window['performance'] && window['performance']['now']) {
+ return window['performance']['now']();
+ } else {
+ return Date.now();
+ }
}
});
diff --git a/system/include/emscripten.h b/system/include/emscripten.h
index a4f15868..d0e6cc46 100644
--- a/system/include/emscripten.h
+++ b/system/include/emscripten.h
@@ -65,6 +65,15 @@ void emscripten_async_call(void (*func)(), int millis) {
void emscripten_hide_mouse();
/*
+ * Returns the highest-precision representation of the
+ * current time that the browser provides. This uses either
+ * Date.now or performance.now. The result is *not* an
+ * absolute time, and is only meaningful in comparison to
+ * other calls to this function. The unit is ms.
+ */
+float emscripten_get_now();
+
+/*
* This macro-looking function will cause Emscripten to
* generate a comment in the generated code.
* XXX This is deprecated for now, because it requires us to