OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 WebGLTestUtils = (function() { | 5 WebGLTestUtils = (function() { |
6 | 6 |
7 /** | 7 /** |
8 * Wrapped logging function. | 8 * Wrapped logging function. |
9 * @param {string} msg The message to log. | 9 * @param {string} msg The message to log. |
10 */ | 10 */ |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 }; | 446 }; |
447 | 447 |
448 /** | 448 /** |
449 * Creates a webgl context. | 449 * Creates a webgl context. |
450 * @param {!Canvas} opt_canvas The canvas tag to get context from. If one is not | 450 * @param {!Canvas} opt_canvas The canvas tag to get context from. If one is not |
451 * passed in one will be created. | 451 * passed in one will be created. |
452 * @return {!WebGLContext} The created context. | 452 * @return {!WebGLContext} The created context. |
453 */ | 453 */ |
454 var create3DContext = function(opt_canvas, opt_attributes) { | 454 var create3DContext = function(opt_canvas, opt_attributes) { |
455 opt_canvas = opt_canvas || document.createElement("canvas"); | 455 opt_canvas = opt_canvas || document.createElement("canvas"); |
| 456 if (typeof opt_canvas == 'string') { |
| 457 opt_canvas = document.getElementById(opt_canvas); |
| 458 } |
456 var context = null; | 459 var context = null; |
457 try { | 460 var names = ["webgl", "experimental-webgl"]; |
458 context = opt_canvas.getContext("webgl", opt_attributes); | 461 for (var i = 0; i < names.length; ++i) { |
459 } catch(e) {} | |
460 if (!context) { | |
461 try { | 462 try { |
462 context = opt_canvas.getContext("experimental-webgl", opt_attributes); | 463 context = opt_canvas.getContext(names[i], opt_attributes); |
463 } catch(e) {} | 464 } catch (e) { |
| 465 } |
| 466 if (context) { |
| 467 break; |
| 468 } |
464 } | 469 } |
465 if (!context) { | 470 if (!context) { |
466 testFailed("Unable to fetch WebGL rendering context for Canvas"); | 471 testFailed("Unable to fetch WebGL rendering context for Canvas"); |
467 } | 472 } |
468 return context; | 473 return context; |
469 } | 474 } |
470 | 475 |
471 /** | 476 /** |
472 * Gets a GLError value as a string. | 477 * Gets a GLError value as a string. |
473 * @param {!WebGLContext} gl The WebGLContext to use. | 478 * @param {!WebGLContext} gl The WebGLContext to use. |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 readFileList: readFileList, | 1213 readFileList: readFileList, |
1209 requestAnimFrame: requestAnimFrame, | 1214 requestAnimFrame: requestAnimFrame, |
1210 waitFrames: waitFrames, | 1215 waitFrames: waitFrames, |
1211 | 1216 |
1212 none: false | 1217 none: false |
1213 }; | 1218 }; |
1214 | 1219 |
1215 }()); | 1220 }()); |
1216 | 1221 |
1217 | 1222 |
OLD | NEW |