2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
10 <meta charset=
"utf-8">
11 <title>WebGL
2 Resizing With PBO Bound Test
</title>
12 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
13 <script src=
"../../js/js-test-pre.js"></script>
14 <script src=
"../../js/webgl-test-utils.js"></script>
17 <div id=
"description"></div>
18 <canvas id=
"canvas1" style=
"width: 256px; height: 256px;"> </canvas>
19 <canvas id=
"canvas2" style=
"width: 256px; height: 256px;"> </canvas>
20 <div id=
"console"></div>
24 description("Verifies that resizing the canvas (recreating the backing framebuffer) works correctly while a PBO is bound.");
27 debug("Regression test for Chromium <a href='https://bugs.chromium.org/p/chromium/issues/detail?id=644572'>Issue 644572</a>");
30 var wtu
= WebGLTestUtils
;
43 currentSize
= largeSize
;
49 canvas
= document
.getElementById("canvas" + testNumber
);
50 canvas
.width
= currentSize
;
51 canvas
.height
= currentSize
;
52 var usePreserveDrawingBuffer
= (testNumber
== 1) ? true : false;
53 debug("Testing preserveDrawingBuffer = " + usePreserveDrawingBuffer
);
54 gl
= wtu
.create3DContext(canvas
, { preserveDrawingBuffer
: usePreserveDrawingBuffer
}, 2);
57 testFailed("context does not exist");
59 wtu
.requestAnimFrame(nextTest
);
61 testPassed("context exists");
63 gl
.clearColor(0, 1, 0, 1);
65 pbo
= gl
.createBuffer();
66 gl
.bindBuffer(gl
.PIXEL_UNPACK_BUFFER
, pbo
);
68 wtu
.requestAnimFrame(render
);
73 if (++numFrames
< 4) {
74 if (currentSize
== largeSize
) {
75 canvas
.height
= smallSize
;
76 currentSize
= smallSize
;
78 canvas
.height
= largeSize
;
79 currentSize
= largeSize
;
83 gl
.viewport(0, 0, largeSize
, currentSize
);
84 gl
.clear(gl
.COLOR_BUFFER_BIT
);
86 // Check the four corners
87 var green
= [ 0, 255, 0, 255 ];
89 wtu
.checkCanvasRect(gl
, inset
, inset
, 1, 1, green
, "lower left should be green", 1);
90 wtu
.checkCanvasRect(gl
, largeSize
- inset
, inset
, 1, 1, green
, "lower right should be green", 1);
91 wtu
.checkCanvasRect(gl
, inset
, currentSize
- inset
, 1, 1, green
, "upper left should be green", 1);
92 wtu
.checkCanvasRect(gl
, largeSize
- inset
, currentSize
- inset
, 1, 1, green
, "upper right should be green", 1);
94 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "No GL error");
95 if (gl
.getParameter(gl
.PIXEL_UNPACK_BUFFER_BINDING
) != pbo
) {
96 testFailed("Pixel unpack buffer binding was lost");
100 wtu
.requestAnimFrame(render
);
102 wtu
.requestAnimFrame(nextTest
);
106 wtu
.requestAnimFrame(nextTest
);