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

Unified Diff: native_client_sdk/src/examples/demo/life_simd/example.js

Issue 451883002: Update SIMD version of life demo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove commented out js Created 6 years, 4 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
Index: native_client_sdk/src/examples/demo/life_simd/example.js
diff --git a/native_client_sdk/src/examples/demo/life_simd/example.js b/native_client_sdk/src/examples/demo/life_simd/example.js
new file mode 100644
index 0000000000000000000000000000000000000000..cdbd83493c4eac503cb3b38cf84461bd3341c3a6
--- /dev/null
+++ b/native_client_sdk/src/examples/demo/life_simd/example.js
@@ -0,0 +1,51 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function moduleDidLoad() {
+}
+
+
+// Add event listeners after the NaCl module has loaded. These listeners will
+// forward messages to the NaCl module via postMessage()
+function attachListeners() {
+ document.getElementById('benchmark').addEventListener('click',
+ function() {
+ common.naclModule.postMessage({'message' : 'run_benchmark'});
+ common.updateStatus('BENCHMARKING... (please wait)');
+ });
+ document.getElementById('simd').addEventListener('click',
+ function() {
+ var simd = document.getElementById('simd');
+ common.naclModule.postMessage({'message' : 'set_simd',
+ 'value' : simd.checked});
+ });
+ document.getElementById('multithread').addEventListener('click',
+ function() {
+ var multithread = document.getElementById('multithread');
+ common.naclModule.postMessage({'message' : 'set_threading',
+ 'value' : multithread.checked});
+ });
+ document.getElementById('large').addEventListener('click',
+ function() {
+ var large = document.getElementById('large');
+ var nacl = document.getElementById('nacl_module');
+ nacl.setAttribute('width', large.checked ? 1280 : 640);
+ nacl.setAttribute('height', large.checked ? 1024 : 640);
+ });
+}
+
+
+// Handle a message coming from the NaCl module.
+function handleMessage(message_event) {
+ if (message_event.data.message == 'benchmark_result') {
+ // benchmark result
+ var result = message_event.data.value;
+ console.log('Benchmark result:' + result);
+ result = (Math.round(result * 1000) / 1000).toFixed(3);
+ document.getElementById('result').textContent =
+ 'Result: ' + result + ' seconds';
+ common.updateStatus('SUCCESS');
+ }
+}
+
« no previous file with comments | « native_client_sdk/src/examples/demo/life_simd/example.dsc ('k') | native_client_sdk/src/examples/demo/life_simd/index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698