Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / canvas / webgl / webgl-large-texture.html
blobc79b9a1aa0364729749bb8ea094c41d769c198ff
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>
10 <body>
11 <canvas id="canvas" width="64" height="64"></canvas>
12 <div id="description"></div>
13 <div id="console"></div>
15 <script>
16 var successfullyParsed = false;
18 function init()
20 if (window.initNonKhronosFramework)
21 window.initNonKhronosFramework(true);
23 if (window.internals)
24 window.internals.settings.setWebGLErrorsToConsoleEnabled(false);
26 description('Test loading a large texture using texImage2D');
28 runTest();
31 function andPixels(pixels32) {
32 var pixelsAnd = 0xffffffff;
33 for (var i = 0; i < pixels32.length; ++i) {
34 pixelsAnd &= pixels32[i];
36 return pixelsAnd;
39 function runTest() {
40 var width = 3900;
41 var height = 3900;
43 var canvas = document.getElementById('canvas');
44 var gl = canvas.getContext('webgl');
46 gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE);
48 var texture = gl.createTexture();
49 gl.bindTexture(gl.TEXTURE_2D, texture);
51 var image = new Image();
52 image.onerror = function (e) {
53 testFailed('Image failed to load');
55 image.onload = function () {
56 debug('Image width and height: ' + image.width + ', ' + image.height);
58 if (image.width !== width || image.height !== height) {
59 testFailed('Image did not have expected dimensions.');
60 return;
63 var pixels = new ArrayBuffer(width * height * 4);
64 var pixels8 = new Uint8Array(pixels);
65 var pixels32 = new Uint32Array(pixels);
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;
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;
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);
85 // The image is filled with white, ignore last bit of each subpixel to account for decoding rounding differences.
86 if ((andPixels(pixels32) & 0xfefefefe) !== (0xfefefefe | 0)) {
87 testFailed('Texture was not loaded correctly.');
90 finishJSTest();
92 image.src = 'resources/white3900x3900.jpg';
95 init();
96 </script>
97 </body>
98 </html>