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

Side by Side Diff: native_client_sdk/src/examples/demo/voronoi/example.js

Issue 289023002: Initial SIMD demos life and earth for PNaCl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: title Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « native_client_sdk/src/examples/demo/life_simd/life.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 function moduleDidLoad() { 5 function moduleDidLoad() {
6 } 6 }
7 7
8 function postThreadFunc(numThreads) { 8 function postThreadFunc(numThreads) {
9 return function () { 9 return function () {
10 common.naclModule.postMessage({'message' : 'set_threads', 10 common.naclModule.postMessage({'message' : 'set_threads',
(...skipping 19 matching lines...) Expand all
30 function() { 30 function() {
31 var checked = document.getElementById('drawInteriors').checked; 31 var checked = document.getElementById('drawInteriors').checked;
32 common.naclModule.postMessage({'message' : 'draw_interiors', 32 common.naclModule.postMessage({'message' : 'draw_interiors',
33 'value' : checked}); 33 'value' : checked});
34 }); 34 });
35 var threads = [0, 1, 2, 4, 6, 8, 12, 16, 24, 32]; 35 var threads = [0, 1, 2, 4, 6, 8, 12, 16, 24, 32];
36 for (var i = 0; i < threads.length; i++) { 36 for (var i = 0; i < threads.length; i++) {
37 document.getElementById('radio' + i).addEventListener('click', 37 document.getElementById('radio' + i).addEventListener('click',
38 postThreadFunc(threads[i])); 38 postThreadFunc(threads[i]));
39 } 39 }
40 document.getElementById('pointRange').addEventListener('change', 40 document.getElementById('pointRange').addEventListener('input',
41 function() { 41 function() {
42 var value = parseFloat(document.getElementById('pointRange').value); 42 var value = parseFloat(document.getElementById('pointRange').value);
43 common.naclModule.postMessage({'message' : 'set_points', 43 common.naclModule.postMessage({'message' : 'set_points',
44 'value' : value}); 44 'value' : value});
45 document.getElementById('pointCount').textContent = value + ' points'; 45 document.getElementById('pointCount').textContent = value + ' points';
46 }); 46 });
47 } 47 }
48 48
49 // Handle a message coming from the NaCl module. 49 // Handle a message coming from the NaCl module.
50 // In the Voronoi example, the only message will be the benchmark result. 50 // In the Voronoi example, the only message will be the benchmark result.
51 function handleMessage(message_event) { 51 function handleMessage(message_event) {
52 if (message_event.data['message'] == 'benchmark_result') { 52 if (message_event.data['message'] == 'benchmark_result') {
53 var x = (Math.round(message_event.data['value'] * 1000) / 1000).toFixed(3); 53 var x = (Math.round(message_event.data['value'] * 1000) / 1000).toFixed(3);
54 document.getElementById('result').textContent = 54 document.getElementById('result').textContent =
55 'Result: ' + x + ' seconds'; 55 'Result: ' + x + ' seconds';
56 common.updateStatus('SUCCESS') 56 common.updateStatus('SUCCESS')
57 } 57 }
58 } 58 }
59 59
OLDNEW
« no previous file with comments | « native_client_sdk/src/examples/demo/life_simd/life.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698