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.
9 <title>Testing resolution of texture uploads
</title>
14 display: -webkit-flex;
16 -webkit-flex-direction: row;
20 .description, .element, .render, .log {
21 border:
1px solid black;
43 <script src=
"../js/webgl-test-utils.js"> </script>
46 var outOfPageSVG
= new Image();
47 outOfPageSVG
.src
= "sample.svg";
50 var wtu
= WebGLTestUtils
;
51 var results
= document
.querySelectorAll(".result");
52 for (var i
= 0; i
< results
.length
; i
++) {
53 var result
= results
[i
];
54 var img
= result
.querySelector("img");
55 if (result
.classList
.contains("out-of-page")) {
58 if (result
.classList
.contains("set-dimensions")) {
62 var out
= result
.querySelector(".output");
63 out
.innerHTML
= "img.width = " + img
.width
+ "<br>img.height = " + img
.height
+ "<br>img.naturalWidth = " + img
.naturalWidth
+ "<br>img.naturalHeight = " + img
.naturalHeight
;
65 var canvas
= document
.createElement("canvas");
66 canvas
.width
= 200 * window
.devicePixelRatio
;
67 canvas
.height
= 200 * window
.devicePixelRatio
;
68 result
.querySelector(".render").appendChild(canvas
);
69 var gl
= wtu
.create3DContext(canvas
);
71 gl
.disable(gl
.DEPTH_TEST
);
73 var program
= wtu
.setupSimpleTextureProgram(gl
, 0, 1);
74 var buffers
= wtu
.setupUnitQuad(gl
, 0, 1);
75 var tex
= gl
.createTexture();
76 gl
.bindTexture(gl
.TEXTURE_2D
, tex
);
77 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MIN_FILTER
, gl
.LINEAR
);
78 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_WRAP_S
, gl
.CLAMP_TO_EDGE
);
79 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_WRAP_T
, gl
.CLAMP_TO_EDGE
);
80 gl
.texImage2D(gl
.TEXTURE_2D
, 0, gl
.RGBA
, gl
.RGBA
, gl
.UNSIGNED_BYTE
, img
);
81 var loc
= gl
.getUniformLocation(program
, "tex");
84 wtu
.clearAndDrawUnitQuad(gl
, [0, 255, 0, 255]);
88 window
.addEventListener("load", function () {
95 <div class=
"description">
96 <p>IMG to SVG with
200x200 attributes
</p>
99 <img src=
"sample.svg" width=
"200" height=
"200">
104 <p class=
"output"></p>
108 <div class=
"description">
109 <p>IMG to
100x100 PNG with
200x200 attributes
</p>
111 <div class=
"element">
112 <img src=
"sample-100.png" width=
"200" height=
"200">
117 <p class=
"output"></p>
121 <div class=
"description">
122 <p>IMG to
200x200 PNG with
200x200 attributes
</p>
124 <div class=
"element">
125 <img src=
"sample-200.png" width=
"200" height=
"200">
130 <p class=
"output"></p>
134 <div class=
"description">
135 <p>IMG to
400x400 PNG with
200x200 attributes
</p>
137 <div class=
"element">
138 <img src=
"sample-400.png" width=
"200" height=
"200">
143 <p class=
"output"></p>
147 <div class=
"description">
148 <p>IMG SRCSET to multiple PNGs with
200x200 attributes
</p>
150 <div class=
"element">
151 <img src=
"sample-100.png" srcset=
"sample-200.png 1x, sample-400.png 2x" width=
"200" height=
"200">
156 <p class=
"output"></p>
160 <div class=
"description">
161 <p>IMG to SVG with no attributes -
200x200 sizing via CSS
</p>
163 <div class=
"element">
164 <img src=
"sample.svg" class=
"viacss">
169 <p class=
"output"></p>
173 <div class=
"description">
174 <p>IMG to
400x400 PNG with no attributes -
200x200 sizing via CSS
</p>
176 <div class=
"element">
177 <img src=
"sample-400.png" class=
"viacss">
182 <p class=
"output"></p>
186 <div class=
"description">
188 IMG to SVG with no attributes and no sizing via CSS
<br>
189 (although the width and height of the container set a size)
192 <div class=
"element">
193 <img src=
"sample.svg">
198 <p class=
"output"></p>
201 <div class=
"result out-of-page">
202 <div class=
"description">
203 <p>Out of page SVG with no dimensions
</p>
205 <div class=
"element">
206 Not a child of document
211 <p class=
"output"></p>
214 <div class=
"result out-of-page set-dimensions">
215 <div class=
"description">
216 <p>Out of page SVG with
200x200 specified
</p>
218 <div class=
"element">
219 Not a child of document
224 <p class=
"output"></p>