Changeset 119014 in webkit
- Timestamp:
- May 30, 2012, 6:31:46 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r119013 r119014 1 2012-05-30 Zhenyao Mo <zmo@google.com> 2 3 WebKit incorrectly clears the alpha channel on readPixels, even for Framebuffers 4 https://bugs.webkit.org/show_bug.cgi?id=87310 5 6 Reviewed by Kenneth Russell. 7 8 * fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias-expected.txt: 9 * fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias.html: synced with khronos 10 1 11 2012-05-30 Sheriff Bot <webkit.review.bot@gmail.com> 2 12 -
trunk/LayoutTests/fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias-expected.txt
r115870 r119014 4 4 5 5 Testing alpha = true 6 PASS webGL = getWebGL(1, 1, { alpha: true, depth: false, stencil: false, antialias: false }, [ 0, 0, 0, 0 ], 1, 0) is non-null. 7 PASS contextAttribs = webGL.getContextAttributes() is non-null. 6 PASS getError was expected value: NO_ERROR : should be no errors 7 PASS gl = getWebGL(1, 1, { alpha: true, depth: false, stencil: false, antialias: false }, [ 0, 0, 0, 0 ], 1, 0) is non-null. 8 PASS gl.getParameter(gl.ALPHA_BITS) >= 8 is true 9 PASS gl.getParameter(gl.RED_BITS) >= 8 is true 10 PASS gl.getParameter(gl.GREEN_BITS) >= 8 is true 11 PASS gl.getParameter(gl.BLUE_BITS) >= 8 is true 12 PASS gl.getParameter(gl.DEPTH_BITS) == 0 is true 13 PASS gl.getParameter(gl.STENCIL_BITS) == 0 is true 14 PASS contextAttribs = gl.getContextAttributes() is non-null. 8 15 PASS contextAttribs.alpha == true is true 9 16 PASS pixel is correctColor 17 PASS Math.abs(pixel[0] - 127) <= 1 && Math.abs(pixel[1] - 127) <= 1 && Math.abs(pixel[2] - 127) <= 1 && Math.abs(pixel[3] - 127) <= 1 is true 10 18 Testing alpha = false 11 PASS webGL = getWebGL(1, 1, { alpha: false, depth: false, stencil: false, antialias: false }, [ 0, 0, 0, 0 ], 1, 0) is non-null. 12 PASS contextAttribs = webGL.getContextAttributes() is non-null. 19 PASS getError was expected value: NO_ERROR : should be no errors 20 PASS gl = getWebGL(1, 1, { alpha: false, depth: false, stencil: false, antialias: false }, [ 0, 0, 0, 0 ], 1, 0) is non-null. 21 PASS gl.getParameter(gl.ALPHA_BITS) == 0 is true 22 PASS gl.getParameter(gl.RED_BITS) >= 8 is true 23 PASS gl.getParameter(gl.GREEN_BITS) >= 8 is true 24 PASS gl.getParameter(gl.BLUE_BITS) >= 8 is true 25 PASS gl.getParameter(gl.DEPTH_BITS) == 0 is true 26 PASS gl.getParameter(gl.STENCIL_BITS) == 0 is true 27 PASS contextAttribs = gl.getContextAttributes() is non-null. 13 28 PASS contextAttribs.alpha == false is true 14 29 PASS pixel is correctColor 30 PASS Math.abs(pixel[0] - 127) <= 1 && Math.abs(pixel[1] - 127) <= 1 && Math.abs(pixel[2] - 127) <= 1 && Math.abs(pixel[3] - 127) <= 1 is true 15 31 Testing depth = true 16 PASS webGL = getWebGL(1, 1, { stencil: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0) is non-null. 17 PASS contextAttribs = webGL.getContextAttributes() is non-null. 32 PASS getError was expected value: NO_ERROR : should be no errors 33 PASS gl = getWebGL(1, 1, { stencil: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0) is non-null. 34 PASS gl.getParameter(gl.DEPTH_BITS) >= 16 is true 35 PASS gl.getParameter(gl.RED_BITS) >= 8 is true 36 PASS gl.getParameter(gl.GREEN_BITS) >= 8 is true 37 PASS gl.getParameter(gl.BLUE_BITS) >= 8 is true 38 PASS gl.getParameter(gl.ALPHA_BITS) >= 8 is true 39 PASS contextAttribs = gl.getContextAttributes() is non-null. 18 40 PASS pixel is correctColor 41 PASS pixel is [0, 0, 0, 255] 19 42 Testing depth = false 20 PASS webGL = getWebGL(1, 1, { depth: false, stencil: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0) is non-null. 21 PASS contextAttribs = webGL.getContextAttributes() is non-null. 43 PASS getError was expected value: NO_ERROR : should be no errors 44 PASS gl = getWebGL(1, 1, { depth: false, stencil: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0) is non-null. 45 PASS gl.getParameter(gl.DEPTH_BITS) == 0 is true 46 PASS gl.getParameter(gl.RED_BITS) >= 8 is true 47 PASS gl.getParameter(gl.GREEN_BITS) >= 8 is true 48 PASS gl.getParameter(gl.BLUE_BITS) >= 8 is true 49 PASS gl.getParameter(gl.ALPHA_BITS) >= 8 is true 50 PASS contextAttribs = gl.getContextAttributes() is non-null. 22 51 PASS pixel is correctColor 52 PASS pixel is [0, 0, 0, 255] 23 53 Testing stencil = true, depth = false 24 PASS webGL = getWebGL(1, 1, { depth: false, stencil: true, antialias: false }, [ 0, 0, 0, 1 ], 1, 0) is non-null. 25 PASS contextAttribs = webGL.getContextAttributes() is non-null. 54 PASS getError was expected value: NO_ERROR : should be no errors 55 PASS gl = getWebGL(1, 1, { depth: false, stencil: true, antialias: false }, [ 0, 0, 0, 1 ], 1, 0) is non-null. 56 PASS gl.getParameter(gl.RED_BITS) >= 8 is true 57 PASS gl.getParameter(gl.GREEN_BITS) >= 8 is true 58 PASS gl.getParameter(gl.BLUE_BITS) >= 8 is true 59 PASS gl.getParameter(gl.ALPHA_BITS) >= 8 is true 60 PASS gl.getParameter(gl.DEPTH_BITS) == 0 is true 61 PASS gl.getParameter(gl.STENCIL_BITS) >= 8 is true 62 PASS contextAttribs = gl.getContextAttributes() is non-null. 26 63 PASS pixel is correctColor 64 PASS pixel is [0, 0, 0, 255] 27 65 Testing stencil = false, depth = false 28 PASS webGL = getWebGL(1, 1, { depth: false, stencil: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0) is non-null. 29 PASS contextAttribs = webGL.getContextAttributes() is non-null. 66 PASS getError was expected value: NO_ERROR : should be no errors 67 PASS gl = getWebGL(1, 1, { depth: false, stencil: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0) is non-null. 68 PASS gl.getParameter(gl.RED_BITS) >= 8 is true 69 PASS gl.getParameter(gl.GREEN_BITS) >= 8 is true 70 PASS gl.getParameter(gl.BLUE_BITS) >= 8 is true 71 PASS gl.getParameter(gl.ALPHA_BITS) >= 8 is true 72 PASS gl.getParameter(gl.DEPTH_BITS) == 0 is true 73 PASS gl.getParameter(gl.STENCIL_BITS) == 0 is true 74 PASS contextAttribs = gl.getContextAttributes() is non-null. 30 75 PASS pixel is correctColor 76 PASS pixel is [0, 0, 0, 255] 31 77 Testing stencil = true, depth = true 32 PASS webGL = getWebGL(1, 1, { depth: true, stencil: true, antialias: false }, [ 0, 0, 0, 1 ], 1, 0) is non-null. 33 PASS contextAttribs = webGL.getContextAttributes() is non-null. 78 PASS getError was expected value: NO_ERROR : should be no errors 79 PASS gl = getWebGL(1, 1, { depth: true, stencil: true, antialias: false }, [ 0, 0, 0, 1 ], 1, 0) is non-null. 80 PASS gl.getParameter(gl.RED_BITS) >= 8 is true 81 PASS gl.getParameter(gl.GREEN_BITS) >= 8 is true 82 PASS gl.getParameter(gl.BLUE_BITS) >= 8 is true 83 PASS gl.getParameter(gl.ALPHA_BITS) >= 8 is true 84 PASS gl.getParameter(gl.DEPTH_BITS) >= 16 is true 85 PASS gl.getParameter(gl.STENCIL_BITS) >= 8 is true 86 PASS contextAttribs = gl.getContextAttributes() is non-null. 34 87 PASS pixel is correctColor 88 PASS pixel is [0, 0, 0, 255] 35 89 Testing stencil = false, depth = true 36 PASS webGL = getWebGL(1, 1, { depth: true, stencil: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0) is non-null. 37 PASS contextAttribs = webGL.getContextAttributes() is non-null. 90 PASS getError was expected value: NO_ERROR : should be no errors 91 PASS gl = getWebGL(1, 1, { depth: true, stencil: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0) is non-null. 92 PASS gl.getParameter(gl.RED_BITS) >= 8 is true 93 PASS gl.getParameter(gl.GREEN_BITS) >= 8 is true 94 PASS gl.getParameter(gl.BLUE_BITS) >= 8 is true 95 PASS gl.getParameter(gl.ALPHA_BITS) >= 8 is true 96 PASS gl.getParameter(gl.DEPTH_BITS) >= 16 is true 97 PASS gl.getParameter(gl.STENCIL_BITS) == 0 is true 98 PASS contextAttribs = gl.getContextAttributes() is non-null. 38 99 PASS pixel is correctColor 100 PASS pixel is [0, 0, 0, 255] 39 101 Testing antialias = true 40 PASS webGL = getWebGL(2, 2, { depth: false, stencil: false, alpha: false, antialias: true }, [ 0, 0, 0, 1 ], 1, 0) is non-null. 41 PASS contextAttribs = webGL.getContextAttributes() is non-null. 102 PASS getError was expected value: NO_ERROR : should be no errors 103 PASS gl = getWebGL(2, 2, { depth: false, stencil: false, alpha: false, antialias: true }, [ 0, 0, 0, 1 ], 1, 0) is non-null. 104 PASS contextAttribs = gl.getContextAttributes() is non-null. 42 105 PASS pixel[0] != 255 && pixel[0] != 0 is contextAttribs.antialias 43 106 Testing antialias = false 44 PASS webGL = getWebGL(2, 2, { depth: false, stencil: false, alpha: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0) is non-null. 45 PASS contextAttribs = webGL.getContextAttributes() is non-null. 107 PASS getError was expected value: NO_ERROR : should be no errors 108 PASS gl = getWebGL(2, 2, { depth: false, stencil: false, alpha: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0) is non-null. 109 PASS contextAttribs = gl.getContextAttributes() is non-null. 46 110 PASS pixel[0] != 255 && pixel[0] != 0 is contextAttribs.antialias 47 111 PASS successfullyParsed is true -
trunk/LayoutTests/fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias.html
r115870 r119014 1 2 <!DOCTYPE html> 1 3 <html> 2 4 <head> 5 <meta charset="utf-8"> 6 <link rel="stylesheet" href="../../js/resources/js-test-style.css"/> 3 7 <script src="../../js/resources/js-test-pre.js"></script> 4 8 <script src="resources/webgl-test.js"></script> … … 27 31 28 32 <script> 33 var successfullyParsed = false; 29 34 30 35 // These four declarations need to be global for "shouldBe" to see them 31 var webGL = null;36 var gl; 32 37 var contextAttribs = null; 33 38 var pixel = [0, 0, 0, 1]; 34 39 var correctColor = null; 40 var framebuffer; 41 var fbHasColor; 42 var fbHasDepth; 43 var fbHasStencil; 35 44 36 45 function init() … … 53 62 canvas.height = canvasHeight; 54 63 55 var context= create3DContext(canvas, contextAttribs);56 if (! context)64 gl = create3DContext(canvas, contextAttribs); 65 if (!gl) 57 66 return null; 58 67 59 context.program = createProgram(context, "vshader", "fshader", ["pos", "colorIn"]);60 if (! context.program)68 var program = createProgram(gl, "vshader", "fshader", ["pos", "colorIn"]); 69 if (!program) 61 70 return null; 62 71 63 context.useProgram(context.program); 64 65 context.enable(context.DEPTH_TEST); 66 context.enable(context.STENCIL_TEST); 67 context.disable(context.BLEND); 68 69 context.clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); 70 context.clearDepth(clearDepth); 71 context.clearStencil(clearStencil); 72 context.clear(context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT | context.STENCIL_BUFFER_BIT); 73 74 return context; 72 gl.useProgram(program); 73 74 gl.enable(gl.DEPTH_TEST); 75 gl.enable(gl.STENCIL_TEST); 76 gl.disable(gl.BLEND); 77 78 gl.clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); 79 gl.clearDepth(clearDepth); 80 gl.clearStencil(clearStencil); 81 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT); 82 83 framebuffer = gl.createFramebuffer(); 84 gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); 85 var texture = gl.createTexture(); 86 gl.bindTexture(gl.TEXTURE_2D, texture); 87 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.canvas.width, gl.canvas.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 88 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0); 89 fbHasStencil = false; 90 fbHasDepth = false; 91 fbHasColor = gl.checkFramebufferStatus(gl.FRAMEBUFFER) == gl.FRAMEBUFFER_COMPLETE; 92 if (fbHasColor) { 93 var depthStencil = gl.createRenderbuffer(); 94 gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencil); 95 gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, gl.canvas.width, gl.canvas.height); 96 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencil); 97 fbHasDepth = gl.checkFramebufferStatus(gl.FRAMEBUFFER) == gl.FRAMEBUFFER_COMPLETE; 98 if (!fbHasDepth) { 99 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, null); 100 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE'); 101 } else { 102 fbHasStencil = true; 103 } 104 } 105 gl.bindFramebuffer(gl.FRAMEBUFFER, null); 106 glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors"); 107 108 return gl; 75 109 } 76 110 … … 100 134 { 101 135 debug("Testing alpha = " + alpha); 102 if (alpha) 103 shouldBeNonNull("webGL = getWebGL(1, 1, { alpha: true, depth: false, stencil: false, antialias: false }, [ 0, 0, 0, 0 ], 1, 0)"); 104 else 105 shouldBeNonNull("webGL = getWebGL(1, 1, { alpha: false, depth: false, stencil: false, antialias: false }, [ 0, 0, 0, 0 ], 1, 0)"); 106 shouldBeNonNull("contextAttribs = webGL.getContextAttributes()"); 136 if (alpha) { 137 shouldBeNonNull("gl = getWebGL(1, 1, { alpha: true, depth: false, stencil: false, antialias: false }, [ 0, 0, 0, 0 ], 1, 0)"); 138 shouldBeTrue("gl.getParameter(gl.ALPHA_BITS) >= 8"); 139 } else { 140 shouldBeNonNull("gl = getWebGL(1, 1, { alpha: false, depth: false, stencil: false, antialias: false }, [ 0, 0, 0, 0 ], 1, 0)"); 141 shouldBeTrue("gl.getParameter(gl.ALPHA_BITS) == 0"); 142 } 143 shouldBeTrue("gl.getParameter(gl.RED_BITS) >= 8"); 144 shouldBeTrue("gl.getParameter(gl.GREEN_BITS) >= 8"); 145 shouldBeTrue("gl.getParameter(gl.BLUE_BITS) >= 8"); 146 shouldBeTrue("gl.getParameter(gl.DEPTH_BITS) == 0"); 147 shouldBeTrue("gl.getParameter(gl.STENCIL_BITS) == 0"); 148 149 shouldBeNonNull("contextAttribs = gl.getContextAttributes()"); 107 150 shouldBeTrue("contextAttribs.alpha == " + alpha); 108 151 109 152 var buf = new Uint8Array(1 * 1 * 4); 110 webGL.readPixels(0, 0, 1, 1, webGL.RGBA, webGL.UNSIGNED_BYTE, buf);153 gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf); 111 154 pixel[0] = buf[0]; 112 155 pixel[1] = buf[1]; … … 115 158 correctColor = (contextAttribs.alpha ? [0, 0, 0, 0] : [0, 0, 0, 255]); 116 159 shouldBe("pixel", "correctColor"); 160 161 if (fbHasColor) { 162 gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); 163 gl.clearColor(0.5, 0.5, 0.5, 0.5); 164 gl.clear(gl.COLOR_BUFFER_BIT); 165 gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf); 166 pixel[0] = buf[0]; 167 pixel[1] = buf[1]; 168 pixel[2] = buf[2]; 169 pixel[3] = buf[3]; 170 shouldBeTrue("Math.abs(pixel[0] - 127) <= 1 && Math.abs(pixel[1] - 127) <= 1 && Math.abs(pixel[2] - 127) <= 1 && Math.abs(pixel[3] - 127) <= 1"); 171 gl.bindFramebuffer(gl.FRAMEBUFFER, null); 172 } 117 173 } 118 174 … … 120 176 { 121 177 debug("Testing depth = " + depth); 122 if (depth) 123 shouldBeNonNull("webGL = getWebGL(1, 1, { stencil: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0)"); 124 else 125 shouldBeNonNull("webGL = getWebGL(1, 1, { depth: false, stencil: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0)"); 126 shouldBeNonNull("contextAttribs = webGL.getContextAttributes()"); 127 128 webGL.depthFunc(webGL.NEVER); 178 if (depth) { 179 shouldBeNonNull("gl = getWebGL(1, 1, { stencil: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0)"); 180 shouldBeTrue("gl.getParameter(gl.DEPTH_BITS) >= 16"); 181 } else { 182 shouldBeNonNull("gl = getWebGL(1, 1, { depth: false, stencil: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0)"); 183 shouldBeTrue("gl.getParameter(gl.DEPTH_BITS) == 0"); 184 } 185 shouldBeTrue("gl.getParameter(gl.RED_BITS) >= 8"); 186 shouldBeTrue("gl.getParameter(gl.GREEN_BITS) >= 8"); 187 shouldBeTrue("gl.getParameter(gl.BLUE_BITS) >= 8"); 188 shouldBeTrue("gl.getParameter(gl.ALPHA_BITS) >= 8"); 189 190 shouldBeNonNull("contextAttribs = gl.getContextAttributes()"); 191 192 gl.depthFunc(gl.NEVER); 129 193 130 194 var vertices = new Float32Array([ … … 143 207 255, 0, 0, 255]); 144 208 145 var buf = drawAndReadPixel( webGL, vertices, colors, 0, 0);209 var buf = drawAndReadPixel(gl, vertices, colors, 0, 0); 146 210 pixel[0] = buf[0]; 147 211 pixel[1] = buf[1]; … … 150 214 correctColor = (contextAttribs.depth ? [0, 0, 0, 255] : [255, 0, 0, 255]); 151 215 shouldBe("pixel", "correctColor"); 216 217 if (fbHasDepth) { 218 gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); 219 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); 220 var buf = drawAndReadPixel(gl, vertices, colors, 0, 0); 221 pixel[0] = buf[0]; 222 pixel[1] = buf[1]; 223 pixel[2] = buf[2]; 224 pixel[3] = buf[3]; 225 shouldBe("pixel", "[0, 0, 0, 255]"); 226 gl.bindFramebuffer(gl.FRAMEBUFFER, null); 227 } 152 228 } 153 229 … … 156 232 debug("Testing stencil = " + stencil + ", depth = " + depth); 157 233 var creationString = 158 " webGL= getWebGL(1, 1, { depth: " + depth + ", stencil: " + stencil + ", antialias: false }, [ 0, 0, 0, 1 ], 1, 0)";234 "gl = getWebGL(1, 1, { depth: " + depth + ", stencil: " + stencil + ", antialias: false }, [ 0, 0, 0, 1 ], 1, 0)"; 159 235 shouldBeNonNull(creationString); 160 shouldBeNonNull("contextAttribs = webGL.getContextAttributes()"); 236 237 shouldBeTrue("gl.getParameter(gl.RED_BITS) >= 8"); 238 shouldBeTrue("gl.getParameter(gl.GREEN_BITS) >= 8"); 239 shouldBeTrue("gl.getParameter(gl.BLUE_BITS) >= 8"); 240 shouldBeTrue("gl.getParameter(gl.ALPHA_BITS) >= 8"); 241 if (depth) 242 shouldBeTrue("gl.getParameter(gl.DEPTH_BITS) >= 16"); 243 else 244 shouldBeTrue("gl.getParameter(gl.DEPTH_BITS) == 0"); 245 246 if (stencil) 247 shouldBeTrue("gl.getParameter(gl.STENCIL_BITS) >= 8"); 248 else 249 shouldBeTrue("gl.getParameter(gl.STENCIL_BITS) == 0"); 250 251 shouldBeNonNull("contextAttribs = gl.getContextAttributes()"); 252 if (!depth && contextAttribs.depth) { 253 testFailed("WebGL implementation provided a depth buffer when it should not have"); 254 } 255 if (!contextAttribs.depth) 256 depth = false; 161 257 if (!stencil && contextAttribs.stencil) { 162 258 testFailed("WebGL implementation provided a stencil buffer when it should not have"); … … 165 261 stencil = false; 166 262 167 webGL.depthFunc(webGL.ALWAYS);168 169 webGL.stencilFunc(webGL.NEVER, 1, 1);170 webGL.stencilOp(webGL.KEEP, webGL.KEEP, webGL.KEEP);263 gl.depthFunc(gl.ALWAYS); 264 265 gl.stencilFunc(gl.NEVER, 1, 1); 266 gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); 171 267 172 268 var vertices = new Float32Array([ … … 185 281 255, 0, 0, 255]); 186 282 187 var buf = drawAndReadPixel( webGL, vertices, colors, 0, 0);283 var buf = drawAndReadPixel(gl, vertices, colors, 0, 0); 188 284 pixel[0] = buf[0]; 189 285 pixel[1] = buf[1]; … … 192 288 correctColor = (stencil ? [0, 0, 0, 255] : [255, 0, 0, 255]); 193 289 shouldBe("pixel", "correctColor"); 290 291 if (fbHasStencil) { 292 gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); 293 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); 294 var buf = drawAndReadPixel(gl, vertices, colors, 0, 0); 295 pixel[0] = buf[0]; 296 pixel[1] = buf[1]; 297 pixel[2] = buf[2]; 298 pixel[3] = buf[3]; 299 shouldBe("pixel", "[0, 0, 0, 255]"); 300 gl.bindFramebuffer(gl.FRAMEBUFFER, null); 301 } 194 302 } 195 303 … … 198 306 debug("Testing antialias = " + antialias); 199 307 if (antialias) 200 shouldBeNonNull(" webGL= getWebGL(2, 2, { depth: false, stencil: false, alpha: false, antialias: true }, [ 0, 0, 0, 1 ], 1, 0)");308 shouldBeNonNull("gl = getWebGL(2, 2, { depth: false, stencil: false, alpha: false, antialias: true }, [ 0, 0, 0, 1 ], 1, 0)"); 201 309 else 202 shouldBeNonNull(" webGL= getWebGL(2, 2, { depth: false, stencil: false, alpha: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0)");203 shouldBeNonNull("contextAttribs = webGL.getContextAttributes()");310 shouldBeNonNull("gl = getWebGL(2, 2, { depth: false, stencil: false, alpha: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0)"); 311 shouldBeNonNull("contextAttribs = gl.getContextAttributes()"); 204 312 205 313 var vertices = new Float32Array([ … … 211 319 255, 0, 0, 255, 212 320 255, 0, 0, 255]); 213 var buf = drawAndReadPixel( webGL, vertices, colors, 0, 0);321 var buf = drawAndReadPixel(gl, vertices, colors, 0, 0); 214 322 pixel[0] = buf[0]; 215 323 shouldBe("pixel[0] != 255 && pixel[0] != 0", "contextAttribs.antialias"); -
trunk/Source/WebCore/ChangeLog
r119013 r119014 1 2012-05-30 Zhenyao Mo <zmo@google.com> 2 3 WebKit incorrectly clears the alpha channel on readPixels, even for Framebuffers 4 https://bugs.webkit.org/show_bug.cgi?id=87310 5 6 Reviewed by Kenneth Russell. 7 8 * html/canvas/WebGLRenderingContext.cpp: 9 (WebCore): 10 (WebCore::WebGLRenderingContext::getParameter): set DEPTH_BITS/STENCIL_BITS to 0 if related channels are not requested. 11 (WebCore::WebGLRenderingContext::readPixels): don't do the alpha value fix if the current bound is not the internal drawing buffer. 12 1 13 2012-05-30 Sheriff Bot <webkit.review.bot@gmail.com> 2 14 -
trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp
r117918 r119014 2402 2402 if (isContextLost()) 2403 2403 return WebGLGetInfo(); 2404 const int intZero = 0; 2404 2405 WebGLStateRestorer(this, false); 2405 2406 switch (pname) { … … 2445 2446 return WebGLGetInfo(PassRefPtr<WebGLProgram>(m_currentProgram)); 2446 2447 case GraphicsContext3D::DEPTH_BITS: 2448 if (!m_attributes.depth) 2449 return WebGLGetInfo(intZero); 2447 2450 return getIntParameter(pname); 2448 2451 case GraphicsContext3D::DEPTH_CLEAR_VALUE: … … 2538 2541 return getUnsignedIntParameter(pname); 2539 2542 case GraphicsContext3D::STENCIL_BITS: 2543 if (!m_attributes.stencil) 2544 return WebGLGetInfo(intZero); 2540 2545 return getIntParameter(pname); 2541 2546 case GraphicsContext3D::STENCIL_CLEAR_VALUE: … … 3292 3297 // FIXME: remove this section when GL driver bug on Mac is fixed, i.e., 3293 3298 // when alpha is off, readPixels should set alpha to 255 instead of 0. 3294 if (!m_ context->getContextAttributes().alpha) {3299 if (!m_framebufferBinding && !m_context->getContextAttributes().alpha) { 3295 3300 unsigned char* pixels = reinterpret_cast<unsigned char*>(data); 3296 3301 for (GC3Dsizei iy = 0; iy < height; ++iy) {
Note:
See TracChangeset
for help on using the changeset viewer.