diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-09-10 12:54:14 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-09-10 12:54:14 -0700 |
commit | 07befe65843ff236b8abc3e34203c3dd93528734 (patch) | |
tree | d8fc0f39fa5b4cdcdcd371ec7444dd8812a81a49 /src/library_browser.js | |
parent | 1a66b2dffdb1e2c84a738ed29047d6e907703efb (diff) |
add hooks for main loop instead of hackish PROFILE_MAIN_LOOP
Diffstat (limited to 'src/library_browser.js')
-rw-r--r-- | src/library_browser.js | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/library_browser.js b/src/library_browser.js index bf235493..43732e5b 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -379,12 +379,6 @@ mergeInto(LibraryManager.library, { emscripten_set_main_loop: function(func, fps) { Module['noExitRuntime'] = true; -#if PROFILE_MAIN_LOOP - Module['totalTime'] = 0; - Module['iterations'] = 0; - Module['maxTime'] = 0; -#endif - var jsFunc = FUNCTION_TABLE[func]; Browser.mainLoop.runner = function() { if (Browser.mainLoop.queue.length > 0) { @@ -414,18 +408,15 @@ mergeInto(LibraryManager.library, { return; } -#if PROFILE_MAIN_LOOP - var start = performance.now(); -#endif + if (Module['preMainLoop']) { + Module['preMainLoop'](); + } jsFunc(); -#if PROFILE_MAIN_LOOP - var time = performance.now() - start; - Module['totalTime'] += time; - Module['iterations']++; - Module['maxTime'] = Math.max(Module['maxTime'], time); -#endif + if (Module['postMainLoop']) { + Module['postMainLoop'](); + } if (Browser.mainLoop.shouldPause) { // catch pauses from the main loop itself |