Changeset 65089 in webkit
- Timestamp:
- Aug 10, 2010 1:44:54 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r65082 r65089 1 2010-08-06 Zhenyao Mo <zmo@google.com> 2 3 Reviewed by Dimitri Glazkov. 4 5 texture functions should gen INVALID_OPERATION if no texture is bound 6 https://bugs.webkit.org/show_bug.cgi?id=42907 7 8 * fast/canvas/webgl/gl-enum-tests-expected.txt: Need to bind a texture before testing tex-functions. 9 * fast/canvas/webgl/gl-enum-tests.html: Ditto. 10 * fast/canvas/webgl/null-object-behaviour-expected.txt: Test tex-functions when no texture is bound. 11 * fast/canvas/webgl/null-object-behaviour.html: Ditto. 12 1 13 2010-08-10 Johnny Ding <jnd@chromium.org> 2 14 -
trunk/LayoutTests/fast/canvas/webgl/gl-enum-tests-expected.txt
r63444 r65089 20 20 PASS gl.disable(desktopGL['POINT_SPRITE']) should return INVALID_ENUM. 21 21 PASS gl.getBufferParameter(gl.ARRAY_BUFFER, desktopGL['PIXEL_PACK_BUFFER']) should return INVALID_ENUM. 22 PASS gl.getTexParameter(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP']) should return INVALID_ENUM.23 PASS gl.getTexParameter(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP']) should return INVALID_ENUM.24 22 PASS gl.hint(desktopGL['PERSPECTIVE_CORRECTION_HINT'], gl.FASTEST) should return INVALID_ENUM. 25 23 PASS gl.isEnabled(desktopGL['CLIP_PLANE0']) should return INVALID_ENUM. … … 27 25 PASS gl.pixelStorei(desktopGL['PACK_SWAP_BYTES'], 1) should return INVALID_ENUM. 28 26 PASS gl.readPixels(0, 0, 1, 1, gl.ALPHA, gl.SHORT, buf) should return INVALID_ENUM. 27 PASS gl.getError() is gl.NO_ERROR 28 PASS gl.getTexParameter(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP']) should return INVALID_ENUM. 29 29 PASS gl.texParameteri(desktopGL['TEXTURE_3D'], gl.TEXTURE_MAG_FILTER, gl.NEAREST) should return INVALID_ENUM. 30 30 PASS gl.texParameteri(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP'], 1) should return INVALID_ENUM. -
trunk/LayoutTests/fast/canvas/webgl/gl-enum-tests.html
r63444 r65089 34 34 gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer()); 35 35 shouldBe("gl.getError()", "gl.NO_ERROR"); 36 36 37 var tests = [ 37 38 "gl.bindTexture(desktopGL['TEXTURE_3D'], tex)", … … 46 47 "gl.disable(desktopGL['POINT_SPRITE'])", 47 48 "gl.getBufferParameter(gl.ARRAY_BUFFER, desktopGL['PIXEL_PACK_BUFFER'])", 48 "gl.getTexParameter(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP'])",49 "gl.getTexParameter(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP'])",50 49 "gl.hint(desktopGL['PERSPECTIVE_CORRECTION_HINT'], gl.FASTEST)", 51 50 "gl.isEnabled(desktopGL['CLIP_PLANE0'])", … … 53 52 "gl.pixelStorei(desktopGL['PACK_SWAP_BYTES'], 1)", 54 53 "gl.readPixels(0, 0, 1, 1, gl.ALPHA, gl.SHORT, buf)", 54 ]; 55 for (var ii = 0; ii < tests.length; ++ii) { 56 eval(tests[ii]); 57 assertMsg(gl.getError() == gl.INVALID_ENUM, 58 tests[ii] + " should return INVALID_ENUM."); 59 } 60 61 gl.bindTexture(gl.TEXTURE_2D, tex); 62 shouldBe("gl.getError()", "gl.NO_ERROR"); 63 64 tests = [ 65 "gl.getTexParameter(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP'])", 55 66 "gl.texParameteri(desktopGL['TEXTURE_3D'], gl.TEXTURE_MAG_FILTER, gl.NEAREST)", 56 67 "gl.texParameteri(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP'], 1)" 57 58 59 60 61 62 68 ]; 69 for (var ii = 0; ii < tests.length; ++ii) { 70 eval(tests[ii]); 71 assertMsg(gl.getError() == gl.INVALID_ENUM, 72 tests[ii] + " should return INVALID_ENUM."); 73 } 63 74 } 64 75 -
trunk/LayoutTests/fast/canvas/webgl/null-object-behaviour-expected.txt
r63444 r65089 19 19 PASS context.bindRenderbuffer(context.RENDERBUFFER, 0) was expected value: NO_ERROR. 20 20 PASS context.bindTexture(context.TEXTURE_2D, 0) was expected value: NO_ERROR. 21 PASS context.bindBuffer(context.ARRAY_BUFFER, null) was expected value: NO_ERROR. 22 PASS context.bindFramebuffer(context.FRAMEBUFFER, null) was expected value: NO_ERROR. 23 PASS context.bindRenderbuffer(context.RENDERBUFFER, null) was expected value: NO_ERROR. 24 PASS context.bindTexture(context.TEXTURE_2D, null) was expected value: NO_ERROR. 25 PASS context.bindBuffer(context.ARRAY_BUFFER, undefined) was expected value: NO_ERROR. 26 PASS context.bindFramebuffer(context.FRAMEBUFFER, undefined) was expected value: NO_ERROR. 27 PASS context.bindRenderbuffer(context.RENDERBUFFER, undefined) was expected value: NO_ERROR. 28 PASS context.bindTexture(context.TEXTURE_2D, undefined) was expected value: NO_ERROR. 21 29 PASS context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, 0) was expected value: INVALID_OPERATION. 22 30 PASS context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, 0, 0) was expected value: INVALID_OPERATION. … … 28 36 PASS context.getUniform(undefined, 0) was expected value: INVALID_VALUE. 29 37 PASS context.getUniformLocation(undefined, 'foo') was expected value: INVALID_VALUE. 38 39 check with bindings 40 PASS context.bufferData(context.ARRAY_BUFFER, 1, context.STATIC_DRAW) was expected value: NO_ERROR. 41 PASS context.getBufferParameter(context.ARRAY_BUFFER, context.BUFFER_SIZE) was expected value: NO_ERROR. 42 PASS context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 1, 1, 0, context.RGBA, context.UNSIGNED_BYTE, new Uint8Array([0,0,0,0])) was expected value: NO_ERROR. 43 PASS context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST) was expected value: NO_ERROR. 44 PASS context.getTexParameter(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER) was expected value: NO_ERROR. 45 46 check without bindings 47 PASS context.bufferData(context.ARRAY_BUFFER, 1, context.STATIC_DRAW) was expected value: INVALID_OPERATION. 48 PASS context.getBufferParameter(context.ARRAY_BUFFER, context.BUFFER_SIZE) was expected value: INVALID_OPERATION. 49 PASS context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 1, 1, 0, context.RGBA, context.UNSIGNED_BYTE, new Uint8Array([0,0,0,0])) was expected value: INVALID_OPERATION. 50 PASS context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST) was expected value: INVALID_OPERATION. 51 PASS context.getTexParameter(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER) was expected value: INVALID_OPERATION. 30 52 PASS successfullyParsed is true 31 53 -
trunk/LayoutTests/fast/canvas/webgl/null-object-behaviour.html
r63444 r65089 35 35 shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(context.RENDERBUFFER, 0)"); 36 36 shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TEXTURE_2D, 0)"); 37 shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARRAY_BUFFER, null)"); 38 shouldGenerateGLError(context, context.NO_ERROR, "context.bindFramebuffer(context.FRAMEBUFFER, null)"); 39 shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(context.RENDERBUFFER, null)"); 40 shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TEXTURE_2D, null)"); 41 shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARRAY_BUFFER, undefined)"); 42 shouldGenerateGLError(context, context.NO_ERROR, "context.bindFramebuffer(context.FRAMEBUFFER, undefined)"); 43 shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(context.RENDERBUFFER, undefined)"); 44 shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TEXTURE_2D, undefined)"); 37 45 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, 0)"); 38 46 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, 0, 0)"); … … 45 53 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniformLocation(undefined, 'foo')"); 46 54 55 debug(""); 56 debug("check with bindings"); 57 context.bindBuffer(context.ARRAY_BUFFER, context.createBuffer()); 58 context.bindTexture(context.TEXTURE_2D, context.createTexture()); 59 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ARRAY_BUFFER, 1, context.STATIC_DRAW)"); 60 shouldGenerateGLError(context, context.NO_ERROR, "context.getBufferParameter(context.ARRAY_BUFFER, context.BUFFER_SIZE)"); 61 shouldGenerateGLError(context, context.NO_ERROR, "context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 1, 1, 0, context.RGBA, context.UNSIGNED_BYTE, new Uint8Array([0,0,0,0]))"); 62 shouldGenerateGLError(context, context.NO_ERROR, "context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST)"); 63 shouldGenerateGLError(context, context.NO_ERROR, "context.getTexParameter(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER)"); 64 65 debug(""); 66 debug("check without bindings"); 67 context.bindBuffer(context.ARRAY_BUFFER, 0); 68 context.bindTexture(context.TEXTURE_2D, 0); 69 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.bufferData(context.ARRAY_BUFFER, 1, context.STATIC_DRAW)"); 70 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.getBufferParameter(context.ARRAY_BUFFER, context.BUFFER_SIZE)"); 71 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 1, 1, 0, context.RGBA, context.UNSIGNED_BYTE, new Uint8Array([0,0,0,0]))"); 72 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST)"); 73 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.getTexParameter(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER)"); 74 75 47 76 successfullyParsed = true; 48 77 </script> -
trunk/WebCore/ChangeLog
r65087 r65089 1 2010-08-06 Zhenyao Mo <zmo@google.com> 2 3 Reviewed by Dimitri Glazkov. 4 5 texture functions should gen INVALID_OPERATION if no texture is bound 6 https://bugs.webkit.org/show_bug.cgi?id=42907 7 8 * html/canvas/WebGLRenderingContext.cpp: 9 (WebCore::WebGLRenderingContext::copyTexImage2D): Check if a texture is bound to target. 10 (WebCore::WebGLRenderingContext::copyTexSubImage2D): Ditto. 11 (WebCore::WebGLRenderingContext::generateMipmap): Ditto. 12 (WebCore::WebGLRenderingContext::getTexParameter): Ditto. 13 (WebCore::WebGLRenderingContext::texImage2DBase): Ditto. 14 (WebCore::WebGLRenderingContext::texParameter): Ditto. 15 (WebCore::WebGLRenderingContext::texSubImage2DBase): Ditto. 16 (WebCore::WebGLRenderingContext::validateTextureBinding): Check if target is valid and if a texture is bound to it. 17 * html/canvas/WebGLRenderingContext.h: Declare validateTextureBinding(). 18 1 19 2010-08-10 Patrick Gansterer <paroga@paroga.com> 2 20 -
trunk/WebCore/html/canvas/WebGLRenderingContext.cpp
r64998 r65089 522 522 if (!validateTexFuncParameters(target, level, internalformat, width, height, border, internalformat, GraphicsContext3D::UNSIGNED_BYTE)) 523 523 return; 524 WebGLTexture* tex = validateTextureBinding(target, true); 525 if (!tex) 526 return; 524 527 if (!isGLES2Compliant()) { 525 528 if (m_framebufferBinding && m_framebufferBinding->object() … … 536 539 m_context->copyTexImage2D(target, level, internalformat, x, y, width, height, border); 537 540 // FIXME: if the framebuffer is not complete, none of the below should be executed. 538 WebGLTexture* tex = getTextureBinding(target); 541 if (!isGLES2Compliant()) 542 tex->setLevelInfo(target, level, internalformat, width, height, GraphicsContext3D::UNSIGNED_BYTE); 543 if (m_framebufferBinding) 544 m_framebufferBinding->onAttachedObjectChange(tex); 545 cleanupAfterGraphicsCall(false); 546 } 547 548 void WebGLRenderingContext::copyTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, long x, long y, unsigned long width, unsigned long height) 549 { 550 WebGLTexture* tex = validateTextureBinding(target, true); 551 if (!tex) 552 return; 539 553 if (!isGLES2Compliant()) { 540 if (tex) 541 tex->setLevelInfo(target, level, internalformat, width, height, GraphicsContext3D::UNSIGNED_BYTE); 542 } 543 if (m_framebufferBinding && tex) 544 m_framebufferBinding->onAttachedObjectChange(tex); 545 cleanupAfterGraphicsCall(false); 546 } 547 548 void WebGLRenderingContext::copyTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, long x, long y, unsigned long width, unsigned long height) 549 { 550 if (!isGLES2Compliant()) { 551 WebGLTexture* tex = getTextureBinding(target); 552 if (m_framebufferBinding && m_framebufferBinding->object() && tex 554 if (m_framebufferBinding && m_framebufferBinding->object() 553 555 && !isTexInternalFormatColorBufferCombinationValid(tex->getInternalFormat(), 554 556 m_framebufferBinding->getColorBufferFormat())) { … … 1111 1113 void WebGLRenderingContext::generateMipmap(unsigned long target) 1112 1114 { 1113 RefPtr<WebGLTexture> tex; 1115 WebGLTexture* tex = validateTextureBinding(target, false); 1116 if (!tex) 1117 return; 1114 1118 if (!isGLES2Compliant()) { 1115 if (target == GraphicsContext3D::TEXTURE_2D) 1116 tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding; 1117 else if (target == GraphicsContext3D::TEXTURE_CUBE_MAP) 1118 tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding; 1119 if (tex && !tex->canGenerateMipmaps()) { 1119 if (!tex->canGenerateMipmaps()) { 1120 1120 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION); 1121 1121 return; … … 1123 1123 } 1124 1124 m_context->generateMipmap(target); 1125 if (!isGLES2Compliant()) { 1126 if (tex) 1127 tex->generateMipmapLevelInfo(); 1128 } 1125 if (!isGLES2Compliant()) 1126 tex->generateMipmapLevelInfo(); 1129 1127 cleanupAfterGraphicsCall(false); 1130 1128 } … … 1575 1573 { 1576 1574 UNUSED_PARAM(ec); 1577 if (target != GraphicsContext3D::TEXTURE_2D 1578 && target != GraphicsContext3D::TEXTURE_CUBE_MAP) { 1579 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); 1575 WebGLTexture* tex = validateTextureBinding(target, false); 1576 if (!tex) 1580 1577 return WebGLGetInfo(); 1581 }1582 1578 WebGLStateRestorer(this, false); 1583 1579 int value = 0; … … 2101 2097 if (!validateTexFuncParameters(target, level, internalformat, width, height, border, format, type)) 2102 2098 return; 2099 WebGLTexture* tex = validateTextureBinding(target, true); 2100 if (!tex) 2101 return; 2103 2102 if (!isGLES2Compliant()) { 2104 2103 if (level && WebGLTexture::isNPOT(width, height)) { … … 2109 2108 m_context->texImage2D(target, level, internalformat, width, height, 2110 2109 border, format, type, pixels); 2111 WebGLTexture* tex = getTextureBinding(target); 2112 if (!isGLES2Compliant()) { 2113 if (tex) 2114 tex->setLevelInfo(target, level, internalformat, width, height, type); 2115 } 2116 if (m_framebufferBinding && tex) 2110 if (!isGLES2Compliant()) 2111 tex->setLevelInfo(target, level, internalformat, width, height, type); 2112 if (m_framebufferBinding) 2117 2113 m_framebufferBinding->onAttachedObjectChange(tex); 2118 2114 cleanupAfterGraphicsCall(false); … … 2331 2327 void WebGLRenderingContext::texParameter(unsigned long target, unsigned long pname, float paramf, int parami, bool isFloat) 2332 2328 { 2329 WebGLTexture* tex = validateTextureBinding(target, false); 2330 if (!tex) 2331 return; 2333 2332 if (!isGLES2Compliant()) { 2334 RefPtr<WebGLTexture> tex = 0;2335 switch (target) {2336 case GraphicsContext3D::TEXTURE_2D:2337 tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding;2338 break;2339 case GraphicsContext3D::TEXTURE_CUBE_MAP:2340 tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding;2341 break;2342 default:2343 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);2344 return;2345 }2346 2333 switch (pname) { 2347 2334 case GraphicsContext3D::TEXTURE_MIN_FILTER: … … 2360 2347 return; 2361 2348 } 2362 if (tex) { 2363 if (isFloat) 2364 tex->setParameterf(pname, paramf); 2365 else 2366 tex->setParameteri(pname, parami); 2367 } 2349 if (isFloat) 2350 tex->setParameterf(pname, paramf); 2351 else 2352 tex->setParameteri(pname, parami); 2368 2353 } 2369 2354 if (isFloat) … … 2392 2377 if (!validateTexFuncFormatAndType(format, type)) 2393 2378 return; 2394 2379 if (!validateTextureBinding(target, true)) 2380 return; 2395 2381 m_context->texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); 2396 2382 cleanupAfterGraphicsCall(false); … … 3310 3296 } 3311 3297 3312 WebGLTexture* WebGLRenderingContext:: getTextureBinding(unsigned long target)3313 { 3314 RefPtr<WebGLTexture>tex = 0;3298 WebGLTexture* WebGLRenderingContext::validateTextureBinding(unsigned long target, bool useSixEnumsForCubeMap) 3299 { 3300 WebGLTexture* tex = 0; 3315 3301 switch (target) { 3316 3302 case GraphicsContext3D::TEXTURE_2D: 3317 tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding ;3303 tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get(); 3318 3304 break; 3319 3305 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X: … … 3323 3309 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z: 3324 3310 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z: 3325 tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding; 3311 if (!useSixEnumsForCubeMap) { 3312 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); 3313 return 0; 3314 } 3315 tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding.get(); 3326 3316 break; 3327 } 3328 if (tex && tex->object()) 3329 return tex.get(); 3330 return 0; 3317 case GraphicsContext3D::TEXTURE_CUBE_MAP: 3318 if (useSixEnumsForCubeMap) { 3319 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); 3320 return 0; 3321 } 3322 tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding.get(); 3323 break; 3324 default: 3325 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); 3326 return 0; 3327 } 3328 if (!tex) 3329 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION); 3330 return tex; 3331 3331 } 3332 3332 -
trunk/WebCore/html/canvas/WebGLRenderingContext.h
r64998 r65089 461 461 unsigned long colorBufferFormat); 462 462 463 // Helper function to get the current bound texture. 464 WebGLTexture* getTextureBinding(unsigned long target); 463 // Helper function to check target and texture bound to the target. 464 // Generate GL errors and return 0 if target is invalid or texture bound is 465 // null. Otherwise, return the texture bound to the target. 466 WebGLTexture* validateTextureBinding(unsigned long target, bool useSixEnumsForCubeMap); 465 467 466 468 // Helper function to check input format/type for functions {copy}Tex{Sub}Image.
Note: See TracChangeset
for help on using the changeset viewer.