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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/webgl/webgl-large-texture.html

Issue 2447493002: Removed some duplicate layout tests under fast/canvas/webgl (Closed)
Patch Set: Created 4 years, 1 month 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
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>Loading a large texture using texImage2D</title>
6 <script src="../../../resources/js-test.js"></script>
7 <script src="resources/webgl-test.js"></script>
8 </head>
9
10 <body>
11 <canvas id="canvas" width="64" height="64"></canvas>
12 <div id="description"></div>
13 <div id="console"></div>
14
15 <script>
16 var successfullyParsed = false;
17
18 function init()
19 {
20 if (window.initNonKhronosFramework)
21 window.initNonKhronosFramework(true);
22
23 if (window.internals)
24 window.internals.settings.setWebGLErrorsToConsoleEnabled(false);
25
26 description('Test loading a large texture using texImage2D');
27
28 runTest();
29 }
30
31 function andPixels(pixels32) {
32 var pixelsAnd = 0xffffffff;
33 for (var i = 0; i < pixels32.length; ++i) {
34 pixelsAnd &= pixels32[i];
35 }
36 return pixelsAnd;
37 }
38
39 function runTest() {
40 var width = 3900;
41 var height = 3900;
42
43 var canvas = document.getElementById('canvas');
44 var gl = canvas.getContext('webgl');
45
46 gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE);
47
48 var texture = gl.createTexture();
49 gl.bindTexture(gl.TEXTURE_2D, texture);
50
51 var image = new Image();
52 image.onerror = function (e) {
53 testFailed('Image failed to load');
54 }
55 image.onload = function () {
56 debug('Image width and height: ' + image.width + ', ' + image.height);
57
58 if (image.width !== width || image.height !== height) {
59 testFailed('Image did not have expected dimensions.');
60 return;
61 }
62
63 var pixels = new ArrayBuffer(width * height * 4);
64 var pixels8 = new Uint8Array(pixels);
65 var pixels32 = new Uint32Array(pixels);
66
67 if (width > gl.getParameter(gl.MAX_TEXTURE_SIZE) ||
68 width > gl.getParameter(gl.MAX_RENDERBUFFER_SIZE)) {
69 // The image is allowed to be too big to be used as a texture.
70 finishJSTest();
71 return;
72 }
73
74 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
75 if (gl.getError() != gl.NO_ERROR) {
76 // Loading the texture is allowed to fail due to resource constraints.
77 finishJSTest();
78 return;
79 }
80 var fb = gl.createFramebuffer();
81 gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
82 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
83 gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, pixels8);
84
85 // The image is filled with white, ignore last bit of each subpixel to accou nt for decoding rounding differences.
86 if ((andPixels(pixels32) & 0xfefefefe) !== (0xfefefefe | 0)) {
87 testFailed('Texture was not loaded correctly.');
88 }
89
90 finishJSTest();
91 }
92 image.src = 'resources/white3900x3900.jpg';
93 }
94
95 init();
96 </script>
97 </body>
98 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698