Changeset 106421 in webkit
- Timestamp:
- Jan 31, 2012 7:17:06 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r106420 r106421 1 2012-01-31 Gregg Tavares <gman@google.com> 2 3 Make WebGL put synthesized errors in the JS console 4 https://bugs.webkit.org/show_bug.cgi?id=77267 5 6 Reviewed by Kenneth Russell. 7 8 No new functionality so no new tests. 9 10 * html/canvas/WebGLCompressedTextures.cpp: 11 (WebCore::WebGLCompressedTextures::validateCompressedTexFuncData): 12 (WebCore::WebGLCompressedTextures::compressedTexImage2D): 13 (WebCore::WebGLCompressedTextures::compressedTexSubImage2D): 14 * html/canvas/WebGLCompressedTextures.h: 15 (WebGLCompressedTextures): 16 * html/canvas/WebGLDebugShaders.cpp: 17 (WebCore::WebGLDebugShaders::getTranslatedShaderSource): 18 * html/canvas/WebGLRenderingContext.cpp: 19 (WebCore::WebGLRenderingContext::activeTexture): 20 (WebCore::WebGLRenderingContext::attachShader): 21 (WebCore::WebGLRenderingContext::bindAttribLocation): 22 (WebCore::WebGLRenderingContext::checkObjectToBeBound): 23 (WebCore::WebGLRenderingContext::bindBuffer): 24 (WebCore::WebGLRenderingContext::bindFramebuffer): 25 (WebCore::WebGLRenderingContext::bindRenderbuffer): 26 (WebCore::WebGLRenderingContext::bindTexture): 27 (WebCore::WebGLRenderingContext::blendEquation): 28 (WebCore::WebGLRenderingContext::blendEquationSeparate): 29 (WebCore::WebGLRenderingContext::blendFunc): 30 (WebCore::WebGLRenderingContext::blendFuncSeparate): 31 (WebCore::WebGLRenderingContext::bufferData): 32 (WebCore::WebGLRenderingContext::bufferSubData): 33 (WebCore::WebGLRenderingContext::checkFramebufferStatus): 34 (WebCore::WebGLRenderingContext::clear): 35 (WebCore::WebGLRenderingContext::compileShader): 36 (WebCore::WebGLRenderingContext::compressedTexImage2D): 37 (WebCore::WebGLRenderingContext::compressedTexSubImage2D): 38 (WebCore::WebGLRenderingContext::copyTexImage2D): 39 (WebCore::WebGLRenderingContext::copyTexSubImage2D): 40 (WebCore::WebGLRenderingContext::createShader): 41 (WebCore::WebGLRenderingContext::deleteObject): 42 (WebCore::WebGLRenderingContext::depthRange): 43 (WebCore::WebGLRenderingContext::detachShader): 44 (WebCore::WebGLRenderingContext::disable): 45 (WebCore::WebGLRenderingContext::disableVertexAttribArray): 46 (WebCore::WebGLRenderingContext::validateWebGLObject): 47 (WebCore::WebGLRenderingContext::drawArrays): 48 (WebCore::WebGLRenderingContext::drawElements): 49 (WebCore::WebGLRenderingContext::enable): 50 (WebCore::WebGLRenderingContext::enableVertexAttribArray): 51 (WebCore::WebGLRenderingContext::framebufferRenderbuffer): 52 (WebCore::WebGLRenderingContext::framebufferTexture2D): 53 (WebCore::WebGLRenderingContext::generateMipmap): 54 (WebCore::WebGLRenderingContext::getActiveAttrib): 55 (WebCore::WebGLRenderingContext::getActiveUniform): 56 (WebCore::WebGLRenderingContext::getAttachedShaders): 57 (WebCore::WebGLRenderingContext::getAttribLocation): 58 (WebCore::WebGLRenderingContext::getBufferParameter): 59 (WebCore::WebGLRenderingContext::getFramebufferAttachmentParameter): 60 (WebCore::WebGLRenderingContext::getParameter): 61 (WebCore::WebGLRenderingContext::getProgramParameter): 62 (WebCore::WebGLRenderingContext::getProgramInfoLog): 63 (WebCore::WebGLRenderingContext::getRenderbufferParameter): 64 (WebCore::WebGLRenderingContext::getShaderParameter): 65 (WebCore::WebGLRenderingContext::getShaderInfoLog): 66 (WebCore::WebGLRenderingContext::getShaderSource): 67 (WebCore::WebGLRenderingContext::getTexParameter): 68 (WebCore::WebGLRenderingContext::getUniform): 69 (WebCore::WebGLRenderingContext::getUniformLocation): 70 (WebCore::WebGLRenderingContext::getVertexAttrib): 71 (WebCore::WebGLRenderingContext::hint): 72 (WebCore::WebGLRenderingContext::isEnabled): 73 (WebCore::WebGLRenderingContext::linkProgram): 74 (WebCore::WebGLRenderingContext::pixelStorei): 75 (WebCore::WebGLRenderingContext::readPixels): 76 (WebCore::WebGLRenderingContext::renderbufferStorage): 77 (WebCore::WebGLRenderingContext::scissor): 78 (WebCore::WebGLRenderingContext::shaderSource): 79 (WebCore::WebGLRenderingContext::stencilFunc): 80 (WebCore::WebGLRenderingContext::stencilFuncSeparate): 81 (WebCore::WebGLRenderingContext::stencilMaskSeparate): 82 (WebCore::WebGLRenderingContext::texImage2DBase): 83 (WebCore::WebGLRenderingContext::texImage2DImpl): 84 (WebCore::WebGLRenderingContext::texImage2D): 85 (WebCore::WebGLRenderingContext::videoFrameToImage): 86 (WebCore::WebGLRenderingContext::texParameter): 87 (WebCore::WebGLRenderingContext::texSubImage2DBase): 88 (WebCore::WebGLRenderingContext::texSubImage2DImpl): 89 (WebCore::WebGLRenderingContext::texSubImage2D): 90 (WebCore::WebGLRenderingContext::uniform1f): 91 (WebCore::WebGLRenderingContext::uniform1fv): 92 (WebCore::WebGLRenderingContext::uniform1i): 93 (WebCore::WebGLRenderingContext::uniform1iv): 94 (WebCore::WebGLRenderingContext::uniform2f): 95 (WebCore::WebGLRenderingContext::uniform2fv): 96 (WebCore::WebGLRenderingContext::uniform2i): 97 (WebCore::WebGLRenderingContext::uniform2iv): 98 (WebCore::WebGLRenderingContext::uniform3f): 99 (WebCore::WebGLRenderingContext::uniform3fv): 100 (WebCore::WebGLRenderingContext::uniform3i): 101 (WebCore::WebGLRenderingContext::uniform3iv): 102 (WebCore::WebGLRenderingContext::uniform4f): 103 (WebCore::WebGLRenderingContext::uniform4fv): 104 (WebCore::WebGLRenderingContext::uniform4i): 105 (WebCore::WebGLRenderingContext::uniform4iv): 106 (WebCore::WebGLRenderingContext::uniformMatrix2fv): 107 (WebCore::WebGLRenderingContext::uniformMatrix3fv): 108 (WebCore::WebGLRenderingContext::uniformMatrix4fv): 109 (WebCore::WebGLRenderingContext::useProgram): 110 (WebCore::WebGLRenderingContext::validateProgram): 111 (WebCore::WebGLRenderingContext::vertexAttrib1f): 112 (WebCore::WebGLRenderingContext::vertexAttrib1fv): 113 (WebCore::WebGLRenderingContext::vertexAttrib2f): 114 (WebCore::WebGLRenderingContext::vertexAttrib2fv): 115 (WebCore::WebGLRenderingContext::vertexAttrib3f): 116 (WebCore::WebGLRenderingContext::vertexAttrib3fv): 117 (WebCore::WebGLRenderingContext::vertexAttrib4f): 118 (WebCore::WebGLRenderingContext::vertexAttrib4fv): 119 (WebCore::WebGLRenderingContext::vertexAttribPointer): 120 (WebCore::WebGLRenderingContext::viewport): 121 (WebCore::WebGLRenderingContext::forceLostContext): 122 (WebCore::WebGLRenderingContext::loseContextImpl): 123 (WebCore::WebGLRenderingContext::forceRestoreContext): 124 (WebCore::WebGLRenderingContext::validateTextureBinding): 125 (WebCore::WebGLRenderingContext::validateLocationLength): 126 (WebCore::WebGLRenderingContext::validateSize): 127 (WebCore::WebGLRenderingContext::validateString): 128 (WebCore::WebGLRenderingContext::validateTexFuncFormatAndType): 129 (WebCore::WebGLRenderingContext::validateTexFuncLevel): 130 (WebCore::WebGLRenderingContext::validateTexFuncParameters): 131 (WebCore::WebGLRenderingContext::validateTexFuncData): 132 (WebCore::WebGLRenderingContext::validateDrawMode): 133 (WebCore::WebGLRenderingContext::validateStencilSettings): 134 (WebCore::WebGLRenderingContext::validateStencilFunc): 135 (WebCore::WebGLRenderingContext::validateFramebufferFuncParameters): 136 (WebCore::WebGLRenderingContext::validateBlendEquation): 137 (WebCore::WebGLRenderingContext::validateBlendFuncFactors): 138 (WebCore::WebGLRenderingContext::validateCapability): 139 (WebCore::WebGLRenderingContext::validateUniformParameters): 140 (WebCore::WebGLRenderingContext::validateUniformMatrixParameters): 141 (WebCore::WebGLRenderingContext::validateBufferDataParameters): 142 (WebCore::WebGLRenderingContext::validateHTMLImageElement): 143 (WebCore::WebGLRenderingContext::vertexAttribfImpl): 144 (WebCore::WebGLRenderingContext::vertexAttribfvImpl): 145 (WebCore::WebGLRenderingContext::maybeRestoreContext): 146 (WebCore): 147 (WebCore::WebGLRenderingContext::synthesizeGLError): 148 * html/canvas/WebGLRenderingContext.h: 149 (WebGLRenderingContext): 150 1 151 2012-01-31 Raymond Liu <raymond.liu@intel.com> 2 152 -
trunk/Source/WebCore/html/canvas/WebGLCompressedTextures.cpp
r101578 r106421 126 126 } 127 127 128 bool WebGLCompressedTextures::validateCompressedTexFuncData( GC3Dsizei width, GC3Dsizei height,129 GC3Denum format, ArrayBufferView* pixels)130 { 131 GraphicsContext3D* context = m_context->graphicsContext3D(); 128 bool WebGLCompressedTextures::validateCompressedTexFuncData(const char* functionName, 129 GC3Dsizei width, GC3Dsizei height, 130 GC3Denum format, ArrayBufferView* pixels) 131 { 132 132 if (!pixels) { 133 context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);133 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no pixels"); 134 134 return false; 135 135 } 136 136 if (width < 0 || height < 0) { 137 context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);137 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "width or height < 0"); 138 138 return false; 139 139 } … … 173 173 break; 174 174 default: 175 context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);175 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid format"); 176 176 return false; 177 177 } 178 178 179 179 if (pixels->byteLength() != bytesRequired) { 180 context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);180 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "length of ArrayBufferView is not correct for dimensions"); 181 181 return false; 182 182 } … … 230 230 GC3Dsizei height, GC3Dint border, ArrayBufferView* data) 231 231 { 232 GraphicsContext3D* context = m_context->graphicsContext3D();233 232 if (m_context->isContextLost()) 234 233 return; 235 234 if (!validateCompressedTexFormat(internalformat)) { 236 context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);235 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexImage2D", "invalid internalformat"); 237 236 return; 238 237 } 239 238 if (border) { 240 context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);241 return; 242 } 243 if (!validateCompressedTexFuncData( width, height, internalformat, data))244 return; 245 WebGLTexture* tex = m_context->validateTextureBinding( target, true);239 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexImage2D", "border not 0"); 240 return; 241 } 242 if (!validateCompressedTexFuncData("compressedTexImage2D", width, height, internalformat, data)) 243 return; 244 WebGLTexture* tex = m_context->validateTextureBinding("compressedTexImage2D", target, true); 246 245 if (!tex) 247 246 return; 248 247 if (!m_context->isGLES2NPOTStrict()) { 249 248 if (level && WebGLTexture::isNPOT(width, height)) { 250 context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);249 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexImage2D", "level > 0 not power of 2"); 251 250 return; 252 251 } 253 252 } 254 context->compressedTexImage2D(target, level, internalformat, width, height,255 border, data->byteLength(), data->baseAddress());253 m_context->graphicsContext3D()->compressedTexImage2D(target, level, internalformat, width, height, 254 border, data->byteLength(), data->baseAddress()); 256 255 tex->setLevelInfo(target, level, internalformat, width, height, GraphicsContext3D::UNSIGNED_BYTE); 257 256 m_context->cleanupAfterGraphicsCall(false); … … 261 260 GC3Dsizei width, GC3Dsizei height, GC3Denum format, ArrayBufferView* data) 262 261 { 263 GraphicsContext3D* context = m_context->graphicsContext3D();264 262 if (m_context->isContextLost()) 265 263 return; 266 264 if (!validateCompressedTexFormat(format)) { 267 context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);268 return; 269 } 270 if (!validateCompressedTexFuncData( width, height, format, data))271 return; 272 273 WebGLTexture* tex = m_context->validateTextureBinding( target, true);265 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexSubImage2D", "invalid format"); 266 return; 267 } 268 if (!validateCompressedTexFuncData("compressedTexSubImage2D", width, height, format, data)) 269 return; 270 271 WebGLTexture* tex = m_context->validateTextureBinding("compressedTexSubImage2D", target, true); 274 272 if (!tex) 275 273 return; 276 274 277 275 if (format != tex->getInternalFormat(target, level)) { 278 context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);276 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexSubImage2D", "format does not match texture format"); 279 277 return; 280 278 } 281 279 282 280 if (!validateCompressedTexSubDimensions(target, level, xoffset, yoffset, width, height, format, tex)) { 283 context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);284 return; 285 } 286 287 context->compressedTexSubImage2D(target, level, xoffset, yoffset,288 width, height, format, data->byteLength(), data->baseAddress());281 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "compressedTexSubImage2D", "dimensions invalid for format"); 282 return; 283 } 284 285 m_context->graphicsContext3D()->compressedTexSubImage2D(target, level, xoffset, yoffset, 286 width, height, format, data->byteLength(), data->baseAddress()); 289 287 m_context->cleanupAfterGraphicsCall(false); 290 288 } -
trunk/Source/WebCore/html/canvas/WebGLCompressedTextures.h
r101578 r106421 55 55 WebGLCompressedTextures(WebGLRenderingContext*); 56 56 57 bool validateCompressedTexFuncData(GC3Dsizei width, GC3Dsizei height, 57 bool validateCompressedTexFuncData(const char* functionName, 58 GC3Dsizei width, GC3Dsizei height, 58 59 GC3Denum format, ArrayBufferView* pixels); 59 60 -
trunk/Source/WebCore/html/canvas/WebGLDebugShaders.cpp
r97896 r106421 62 62 if (m_context->isContextLost()) 63 63 return String(); 64 if (!m_context->validateWebGLObject( shader))64 if (!m_context->validateWebGLObject("getTranslatedShaderSource", shader)) 65 65 return ""; 66 66 return m_context->graphicsContext3D()->getExtensions()->getTranslatedShaderSourceANGLE(shader->object()); -
trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp
r106320 r106421 425 425 , m_contextLostMode(SyntheticLostContext) 426 426 , m_attributes(attributes) 427 , m_synthesizedErrorsToConsole(false) 427 428 { 428 429 ASSERT(m_context); … … 787 788 return; 788 789 if (texture - GraphicsContext3D::TEXTURE0 >= m_textureUnits.size()) { 789 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);790 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "activeTexture", "texture unit out of range"); 790 791 return; 791 792 } … … 802 803 { 803 804 UNUSED_PARAM(ec); 804 if (isContextLost() || !validateWebGLObject( program) || !validateWebGLObject(shader))805 if (isContextLost() || !validateWebGLObject("attachShader", program) || !validateWebGLObject("attachShader", shader)) 805 806 return; 806 807 if (!program->attachShader(shader)) { 807 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);808 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "attachShader", "shader attachment already has shader"); 808 809 return; 809 810 } … … 816 817 { 817 818 UNUSED_PARAM(ec); 818 if (isContextLost() || !validateWebGLObject( program))819 return; 820 if (!validateLocationLength( name))821 return; 822 if (!validateString( name))819 if (isContextLost() || !validateWebGLObject("bindAttribLocation", program)) 820 return; 821 if (!validateLocationLength("bindAttribLocation", name)) 822 return; 823 if (!validateString("bindAttribLocation", name)) 823 824 return; 824 825 m_context->bindAttribLocation(objectOrZero(program), index, name); … … 826 827 } 827 828 828 bool WebGLRenderingContext::checkObjectToBeBound( WebGLObject* object, bool& deleted)829 bool WebGLRenderingContext::checkObjectToBeBound(const char* functionName, WebGLObject* object, bool& deleted) 829 830 { 830 831 deleted = false; … … 833 834 if (object) { 834 835 if (!object->validate(contextGroup(), this)) { 835 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);836 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "object not from this context"); 836 837 return false; 837 838 } … … 845 846 UNUSED_PARAM(ec); 846 847 bool deleted; 847 if (!checkObjectToBeBound( buffer, deleted))848 if (!checkObjectToBeBound("bindBuffer", buffer, deleted)) 848 849 return; 849 850 if (deleted) 850 851 buffer = 0; 851 852 if (buffer && buffer->getTarget() && buffer->getTarget() != target) { 852 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);853 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindBuffer", "buffers can not be used with multiple targets"); 853 854 return; 854 855 } … … 858 859 m_boundVertexArrayObject->setElementArrayBuffer(buffer); 859 860 else { 860 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);861 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindBuffer", "invalid target"); 861 862 return; 862 863 } … … 872 873 UNUSED_PARAM(ec); 873 874 bool deleted; 874 if (!checkObjectToBeBound( buffer, deleted))875 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) 875 876 return; 876 877 if (deleted) 877 878 buffer = 0; 878 879 if (target != GraphicsContext3D::FRAMEBUFFER) { 879 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);880 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindFramebuffer", "invalid target"); 880 881 return; 881 882 } … … 895 896 UNUSED_PARAM(ec); 896 897 bool deleted; 897 if (!checkObjectToBeBound( renderBuffer, deleted))898 if (!checkObjectToBeBound("bindRenderbuffer", renderBuffer, deleted)) 898 899 return; 899 900 if (deleted) 900 901 renderBuffer = 0; 901 902 if (target != GraphicsContext3D::RENDERBUFFER) { 902 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);903 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindRenderbuffer", "invalid target"); 903 904 return; 904 905 } … … 914 915 UNUSED_PARAM(ec); 915 916 bool deleted; 916 if (!checkObjectToBeBound( texture, deleted))917 if (!checkObjectToBeBound("bindTexture", texture, deleted)) 917 918 return; 918 919 if (deleted) 919 920 texture = 0; 920 921 if (texture && texture->getTarget() && texture->getTarget() != target) { 921 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);922 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindTexture", "textures can not be used with multiple targets"); 922 923 return; 923 924 } … … 934 935 maxLevel = m_maxCubeMapTextureLevel; 935 936 } else { 936 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);937 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindTexture", "invalid target"); 937 938 return; 938 939 } … … 963 964 void WebGLRenderingContext::blendEquation(GC3Denum mode) 964 965 { 965 if (isContextLost() || !validateBlendEquation( mode))966 if (isContextLost() || !validateBlendEquation("blendEquation", mode)) 966 967 return; 967 968 m_context->blendEquation(mode); … … 971 972 void WebGLRenderingContext::blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha) 972 973 { 973 if (isContextLost() || !validateBlendEquation( modeRGB) || !validateBlendEquation(modeAlpha))974 if (isContextLost() || !validateBlendEquation("blendEquation", modeRGB) || !validateBlendEquation("blendEquation", modeAlpha)) 974 975 return; 975 976 m_context->blendEquationSeparate(modeRGB, modeAlpha); … … 980 981 void WebGLRenderingContext::blendFunc(GC3Denum sfactor, GC3Denum dfactor) 981 982 { 982 if (isContextLost() || !validateBlendFuncFactors( sfactor, dfactor))983 if (isContextLost() || !validateBlendFuncFactors("blendFunc", sfactor, dfactor)) 983 984 return; 984 985 m_context->blendFunc(sfactor, dfactor); … … 988 989 void WebGLRenderingContext::blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha) 989 990 { 990 if (isContextLost() || !validateBlendFuncFactors(srcRGB, dstRGB)) 991 // Note: Alpha does not have the same restrictions as RGB. 992 if (isContextLost() || !validateBlendFuncFactors("blendFunc", srcRGB, dstRGB)) 991 993 return; 992 994 m_context->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); … … 999 1001 if (isContextLost()) 1000 1002 return; 1001 WebGLBuffer* buffer = validateBufferDataParameters( target, usage);1003 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usage); 1002 1004 if (!buffer) 1003 1005 return; 1004 1006 if (size < 0) { 1005 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);1007 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "size < 0"); 1006 1008 return; 1007 1009 } 1008 1010 if (!isErrorGeneratedOnOutOfBoundsAccesses()) { 1009 1011 if (!buffer->associateBufferData(size)) { 1010 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);1012 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "invalid buffer"); 1011 1013 return; 1012 1014 } … … 1022 1024 if (isContextLost()) 1023 1025 return; 1024 WebGLBuffer* buffer = validateBufferDataParameters( target, usage);1026 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usage); 1025 1027 if (!buffer) 1026 1028 return; 1027 1029 if (!data) { 1028 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);1030 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "no data"); 1029 1031 return; 1030 1032 } 1031 1033 if (!isErrorGeneratedOnOutOfBoundsAccesses()) { 1032 1034 if (!buffer->associateBufferData(data)) { 1033 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);1035 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "invalid buffer"); 1034 1036 return; 1035 1037 } … … 1045 1047 if (isContextLost()) 1046 1048 return; 1047 WebGLBuffer* buffer = validateBufferDataParameters( target, usage);1049 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usage); 1048 1050 if (!buffer) 1049 1051 return; 1050 1052 if (!data) { 1051 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);1053 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "no data"); 1052 1054 return; 1053 1055 } 1054 1056 if (!isErrorGeneratedOnOutOfBoundsAccesses()) { 1055 1057 if (!buffer->associateBufferData(data)) { 1056 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);1058 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "invalid buffer"); 1057 1059 return; 1058 1060 } … … 1068 1070 if (isContextLost()) 1069 1071 return; 1070 WebGLBuffer* buffer = validateBufferDataParameters( target, GraphicsContext3D::STATIC_DRAW);1072 WebGLBuffer* buffer = validateBufferDataParameters("bufferSubData", target, GraphicsContext3D::STATIC_DRAW); 1071 1073 if (!buffer) 1072 1074 return; 1073 1075 if (offset < 0) { 1074 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);1076 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferSubData", "offset < 0"); 1075 1077 return; 1076 1078 } … … 1079 1081 if (!isErrorGeneratedOnOutOfBoundsAccesses()) { 1080 1082 if (!buffer->associateBufferSubData(offset, data)) { 1081 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);1083 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferSubData", "offset out of range"); 1082 1084 return; 1083 1085 } … … 1093 1095 if (isContextLost()) 1094 1096 return; 1095 WebGLBuffer* buffer = validateBufferDataParameters( target, GraphicsContext3D::STATIC_DRAW);1097 WebGLBuffer* buffer = validateBufferDataParameters("bufferSubData", target, GraphicsContext3D::STATIC_DRAW); 1096 1098 if (!buffer) 1097 1099 return; 1098 1100 if (offset < 0) { 1099 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);1101 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferSubData", "offset < 0"); 1100 1102 return; 1101 1103 } … … 1104 1106 if (!isErrorGeneratedOnOutOfBoundsAccesses()) { 1105 1107 if (!buffer->associateBufferSubData(offset, data)) { 1106 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);1108 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferSubData", "offset out of range"); 1107 1109 return; 1108 1110 } … … 1118 1120 return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED; 1119 1121 if (target != GraphicsContext3D::FRAMEBUFFER) { 1120 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);1122 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "checkFramebufferStatus", "invalid target"); 1121 1123 return 0; 1122 1124 } … … 1136 1138 return; 1137 1139 if (mask & ~(GraphicsContext3D::COLOR_BUFFER_BIT | GraphicsContext3D::DEPTH_BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT)) { 1138 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);1140 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "clear", "invalid mask"); 1139 1141 return; 1140 1142 } 1141 1143 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3D(), !isResourceSafe())) { 1142 m_context->synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION);1144 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "clear", "can not render to framebuffer"); 1143 1145 return; 1144 1146 } … … 1201 1203 { 1202 1204 UNUSED_PARAM(ec); 1203 if (isContextLost() || !validateWebGLObject( shader))1205 if (isContextLost() || !validateWebGLObject("compileShader", shader)) 1204 1206 return; 1205 1207 m_context->compileShader(objectOrZero(shader)); … … 1214 1216 1215 1217 // FIXME: implement this. 1216 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);1218 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexImage2D", "invalid internalformat"); 1217 1219 } 1218 1220 … … 1224 1226 1225 1227 // FIXME: implement this. 1226 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);1228 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexSubImage2D", "invalid format"); 1227 1229 } 1228 1230 … … 1231 1233 if (isContextLost()) 1232 1234 return; 1233 if (!validateTexFuncParameters( target, level, internalformat, width, height, border, internalformat, GraphicsContext3D::UNSIGNED_BYTE))1234 return; 1235 WebGLTexture* tex = validateTextureBinding( target, true);1235 if (!validateTexFuncParameters("copyTexImage2D", target, level, internalformat, width, height, border, internalformat, GraphicsContext3D::UNSIGNED_BYTE)) 1236 return; 1237 WebGLTexture* tex = validateTextureBinding("copyTexImage2D", target, true); 1236 1238 if (!tex) 1237 1239 return; 1238 1240 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, getBoundFramebufferColorFormat())) { 1239 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);1241 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "copyTexImage2D", "framebuffer is incompatible format"); 1240 1242 return; 1241 1243 } 1242 1244 if (!isGLES2NPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { 1243 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);1245 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexImage2D", "level > 0 not power of 2"); 1244 1246 return; 1245 1247 } 1246 1248 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3D(), !isResourceSafe())) { 1247 m_context->synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION);1249 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "copyTexImage2D", "framebuffer not readable"); 1248 1250 return; 1249 1251 } … … 1275 1277 if (isContextLost()) 1276 1278 return; 1277 if (!validateTexFuncLevel( target, level))1278 return; 1279 WebGLTexture* tex = validateTextureBinding( target, true);1279 if (!validateTexFuncLevel("copyTexSubImage2D", target, level)) 1280 return; 1281 WebGLTexture* tex = validateTextureBinding("copyTexSubImage2D", target, true); 1280 1282 if (!tex) 1281 1283 return; 1282 if (!validateSize( xoffset, yoffset) || !validateSize(width, height))1284 if (!validateSize("copyTexSubImage2D", xoffset, yoffset) || !validateSize("copyTexSubImage2D", width, height)) 1283 1285 return; 1284 1286 if (xoffset + width > tex->getWidth(target, level) || yoffset + height > tex->getHeight(target, level)) { 1285 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);1287 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexSubImage2D", "rectangle out of range"); 1286 1288 return; 1287 1289 } 1288 1290 if (!isTexInternalFormatColorBufferCombinationValid(tex->getInternalFormat(target, level), getBoundFramebufferColorFormat())) { 1289 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);1291 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "copyTexSubImage2D", "framebuffer is incompatible format"); 1290 1292 return; 1291 1293 } 1292 1294 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3D(), !isResourceSafe())) { 1293 m_context->synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION);1295 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "copyTexSubImage2D", "framebuffer not readable"); 1294 1296 return; 1295 1297 } … … 1309 1311 GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, height, m_unpackAlignment, &size, 0); 1310 1312 if (error != GraphicsContext3D::NO_ERROR) { 1311 m_context->synthesizeGLError(error);1313 synthesizeGLError(error, "copyTexSubImage2D", "bad dimensions"); 1312 1314 return; 1313 1315 } 1314 1316 zero = adoptArrayPtr(new unsigned char[size]); 1315 1317 if (!zero) { 1316 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);1318 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexSubImage2D", "out of memory"); 1317 1319 return; 1318 1320 } … … 1384 1386 return 0; 1385 1387 if (type != GraphicsContext3D::VERTEX_SHADER && type != GraphicsContext3D::FRAGMENT_SHADER) { 1386 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);1388 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "createShader", "invalid shader type"); 1387 1389 return 0; 1388 1390 } … … 1406 1408 return false; 1407 1409 if (!object->validate(contextGroup(), this)) { 1408 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);1410 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "delete", "object does not belong to this context"); 1409 1411 return false; 1410 1412 } … … 1512 1514 return; 1513 1515 if (zNear > zFar) { 1514 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);1516 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "depthRange", "zNear > zFar"); 1515 1517 return; 1516 1518 } … … 1522 1524 { 1523 1525 UNUSED_PARAM(ec); 1524 if (isContextLost() || !validateWebGLObject( program) || !validateWebGLObject(shader))1526 if (isContextLost() || !validateWebGLObject("detachShader", program) || !validateWebGLObject("detachShader", shader)) 1525 1527 return; 1526 1528 if (!program->detachShader(shader)) { 1527 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);1529 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "detachShader", "shader not attached"); 1528 1530 return; 1529 1531 } … … 1535 1537 void WebGLRenderingContext::disable(GC3Denum cap) 1536 1538 { 1537 if (isContextLost() || !validateCapability( cap))1539 if (isContextLost() || !validateCapability("disable", cap)) 1538 1540 return; 1539 1541 if (cap == GraphicsContext3D::SCISSOR_TEST) { … … 1552 1554 return; 1553 1555 if (index >= m_maxVertexAttribs) { 1554 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);1556 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "disableVertexAttribArray", "index out of range"); 1555 1557 return; 1556 1558 } … … 1735 1737 } 1736 1738 1737 bool WebGLRenderingContext::validateWebGLObject( WebGLObject* object)1739 bool WebGLRenderingContext::validateWebGLObject(const char* functionName, WebGLObject* object) 1738 1740 { 1739 1741 if (!object || !object->object()) { 1740 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);1742 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no object or object deleted"); 1741 1743 return false; 1742 1744 } 1743 1745 if (!object->validate(contextGroup(), this)) { 1744 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);1746 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "object does not belong to this context"); 1745 1747 return false; 1746 1748 } … … 1752 1754 UNUSED_PARAM(ec); 1753 1755 1754 if (isContextLost() || !validateDrawMode( mode))1755 return; 1756 1757 if (!validateStencilSettings( ))1756 if (isContextLost() || !validateDrawMode("drawArrays", mode)) 1757 return; 1758 1759 if (!validateStencilSettings("drawArrays")) 1758 1760 return; 1759 1761 1760 1762 if (first < 0 || count < 0) { 1761 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);1763 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "drawArrays", "first or count < 0"); 1762 1764 return; 1763 1765 } … … 1772 1774 CheckedInt<GC3Dint> checkedSum = checkedFirst + checkedCount; 1773 1775 if (!checkedSum.valid() || !validateRenderingState(checkedSum.value())) { 1774 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);1776 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "drawArrays", "attempt to access out of bounds arrays"); 1775 1777 return; 1776 1778 } 1777 1779 } else { 1778 1780 if (!validateRenderingState(0)) { 1779 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);1781 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "drawArrays", "attribs not setup correctly"); 1780 1782 return; 1781 1783 } … … 1783 1785 1784 1786 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3D(), !isResourceSafe())) { 1785 m_context->synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION);1787 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "drawArrays", "framebuffer can not be rendered to"); 1786 1788 return; 1787 1789 } … … 1806 1808 UNUSED_PARAM(ec); 1807 1809 1808 if (isContextLost() || !validateDrawMode( mode))1809 return; 1810 1811 if (!validateStencilSettings( ))1810 if (isContextLost() || !validateDrawMode("drawElements", mode)) 1811 return; 1812 1813 if (!validateStencilSettings("drawElements")) 1812 1814 return; 1813 1815 … … 1817 1819 break; 1818 1820 default: 1819 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);1821 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "drawElements", "invalid type"); 1820 1822 return; 1821 1823 } 1822 1824 1823 1825 if (count < 0 || offset < 0) { 1824 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);1826 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "drawElements", "count or offset < 0"); 1825 1827 return; 1826 1828 } … … 1830 1832 1831 1833 if (!m_boundVertexArrayObject->getElementArrayBuffer()) { 1832 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);1834 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "drawElements", "no ELEMENT_ARRAY_BUFFER bound"); 1833 1835 return; 1834 1836 } … … 1838 1840 // Ensure we have a valid rendering state 1839 1841 if (!validateElementArraySize(count, type, offset)) { 1840 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);1842 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "drawElements", "request out of bounds for current ELEMENT_ARRAY_BUFFER"); 1841 1843 return; 1842 1844 } … … 1845 1847 if (!validateIndexArrayConservative(type, numElements) || !validateRenderingState(numElements)) { 1846 1848 if (!validateIndexArrayPrecise(count, type, offset, numElements) || !validateRenderingState(numElements)) { 1847 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);1849 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "drawElements", "attempt to access out of bounds arrays"); 1848 1850 return; 1849 1851 } … … 1851 1853 } else { 1852 1854 if (!validateRenderingState(0)) { 1853 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);1855 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "drawElements", "attribs not setup correctly"); 1854 1856 return; 1855 1857 } … … 1857 1859 1858 1860 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3D(), !isResourceSafe())) { 1859 m_context->synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION);1861 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "drawElements", "framebuffer can not be rendered to"); 1860 1862 return; 1861 1863 } … … 1880 1882 void WebGLRenderingContext::enable(GC3Denum cap) 1881 1883 { 1882 if (isContextLost() || !validateCapability( cap))1884 if (isContextLost() || !validateCapability("enable", cap)) 1883 1885 return; 1884 1886 if (cap == GraphicsContext3D::SCISSOR_TEST) { … … 1897 1899 return; 1898 1900 if (index >= m_maxVertexAttribs) { 1899 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);1901 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "enableVertexAttribArray", "index out of range"); 1900 1902 return; 1901 1903 } … … 1927 1929 { 1928 1930 UNUSED_PARAM(ec); 1929 if (isContextLost() || !validateFramebufferFuncParameters( target, attachment))1931 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRenderbuffer", target, attachment)) 1930 1932 return; 1931 1933 if (renderbuffertarget != GraphicsContext3D::RENDERBUFFER) { 1932 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);1934 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "framebufferRenderbuffer", "invalid target"); 1933 1935 return; 1934 1936 } 1935 1937 if (buffer && !buffer->validate(contextGroup(), this)) { 1936 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);1938 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferRenderbuffer", "no buffer or buffer not from this context"); 1937 1939 return; 1938 1940 } … … 1941 1943 // FBO. 1942 1944 if (!m_framebufferBinding || !m_framebufferBinding->object()) { 1943 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);1945 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferRenderbuffer", "no framebuffer bound"); 1944 1946 return; 1945 1947 } … … 1998 2000 { 1999 2001 UNUSED_PARAM(ec); 2000 if (isContextLost() || !validateFramebufferFuncParameters( target, attachment))2002 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTexture2D", target, attachment)) 2001 2003 return; 2002 2004 if (level) { 2003 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);2005 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "framebufferTexture2D", "level not 0"); 2004 2006 return; 2005 2007 } 2006 2008 if (texture && !texture->validate(contextGroup(), this)) { 2007 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);2009 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferTexture2D", "no texture or texture not from this context"); 2008 2010 return; 2009 2011 } … … 2012 2014 // FBO. 2013 2015 if (!m_framebufferBinding || !m_framebufferBinding->object()) { 2014 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);2016 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferTexture2D", "no framebuffer bound"); 2015 2017 return; 2016 2018 } … … 2032 2034 if (isContextLost()) 2033 2035 return; 2034 WebGLTexture* tex = validateTextureBinding( target, false);2036 WebGLTexture* tex = validateTextureBinding("generateMipmap", target, false); 2035 2037 if (!tex) 2036 2038 return; 2037 2039 if (!tex->canGenerateMipmaps()) { 2038 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);2040 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "generateMipmap", "level 0 not power of 2 or not all the same size"); 2039 2041 return; 2040 2042 } … … 2060 2062 { 2061 2063 UNUSED_PARAM(ec); 2062 if (isContextLost() || !validateWebGLObject( program))2064 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) 2063 2065 return 0; 2064 2066 ActiveInfo info; … … 2071 2073 { 2072 2074 UNUSED_PARAM(ec); 2073 if (isContextLost() || !validateWebGLObject( program))2075 if (isContextLost() || !validateWebGLObject("getActiveUniform", program)) 2074 2076 return 0; 2075 2077 ActiveInfo info; … … 2086 2088 UNUSED_PARAM(ec); 2087 2089 shaderObjects.clear(); 2088 if (isContextLost() || !validateWebGLObject( program))2090 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program)) 2089 2091 return false; 2090 2092 … … 2105 2107 if (isContextLost()) 2106 2108 return -1; 2107 if (!validateLocationLength( name))2109 if (!validateLocationLength("getAttribLocation", name)) 2108 2110 return -1; 2109 if (!validateString( name))2111 if (!validateString("getAttribLocation", name)) 2110 2112 return -1; 2111 2113 return m_context->getAttribLocation(objectOrZero(program), name); … … 2118 2120 return WebGLGetInfo(); 2119 2121 if (target != GraphicsContext3D::ARRAY_BUFFER && target != GraphicsContext3D::ELEMENT_ARRAY_BUFFER) { 2120 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);2122 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getBufferParameter", "invalid target"); 2121 2123 return WebGLGetInfo(); 2122 2124 } 2123 2125 2124 2126 if (pname != GraphicsContext3D::BUFFER_SIZE && pname != GraphicsContext3D::BUFFER_USAGE) { 2125 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);2127 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getBufferParameter", "invalid parameter name"); 2126 2128 return WebGLGetInfo(); 2127 2129 } … … 2212 2214 { 2213 2215 UNUSED_PARAM(ec); 2214 if (isContextLost() || !validateFramebufferFuncParameters( target, attachment))2216 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAttachmentParameter", target, attachment)) 2215 2217 return WebGLGetInfo(); 2216 2218 2217 2219 if (!m_framebufferBinding || !m_framebufferBinding->object()) { 2218 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);2220 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getFramebufferAttachmentParameter", "no framebuffer bound"); 2219 2221 return WebGLGetInfo(); 2220 2222 } … … 2226 2228 // OpenGL ES 2.0 specifies INVALID_ENUM in this case, while desktop GL 2227 2229 // specifies INVALID_OPERATION. 2228 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);2230 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getFramebufferAttachmentParameter", "invalid parameter name"); 2229 2231 return WebGLGetInfo(); 2230 2232 } … … 2246 2248 } 2247 2249 default: 2248 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);2250 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getFramebufferAttachmentParameter", "invalid parameter name for texture attachment"); 2249 2251 return WebGLGetInfo(); 2250 2252 } … … 2256 2258 return WebGLGetInfo(PassRefPtr<WebGLRenderbuffer>(reinterpret_cast<WebGLRenderbuffer*>(object))); 2257 2259 default: 2258 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);2260 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getFramebufferAttachmentParameter", "invalid parameter name for renderbuffer attachment"); 2259 2261 return WebGLGetInfo(); 2260 2262 } … … 2451 2453 if (m_oesStandardDerivatives) 2452 2454 return getUnsignedIntParameter(Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES); 2453 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);2455 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "invalid parameter name, OES_standard_derivatives not enabled"); 2454 2456 return WebGLGetInfo(); 2455 2457 case WebGLDebugRendererInfo::UNMASKED_RENDERER_WEBGL: 2456 2458 if (m_webglDebugRendererInfo) 2457 2459 return WebGLGetInfo(m_context->getString(GraphicsContext3D::RENDERER)); 2458 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);2460 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "invalid parameter name, WEBGL_debug_renderer_info not enabled"); 2459 2461 return WebGLGetInfo(); 2460 2462 case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL: 2461 2463 if (m_webglDebugRendererInfo) 2462 2464 return WebGLGetInfo(m_context->getString(GraphicsContext3D::VENDOR)); 2463 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);2465 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "invalid parameter name, WEBGL_debug_renderer_info not enabled"); 2464 2466 return WebGLGetInfo(); 2465 2467 case Extensions3D::VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object … … 2469 2471 return WebGLGetInfo(); 2470 2472 } 2471 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);2473 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "invalid parameter name, OES_vertex_array_object not enabled"); 2472 2474 return WebGLGetInfo(); 2473 2475 default: 2474 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);2476 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "invalid parameter name"); 2475 2477 return WebGLGetInfo(); 2476 2478 } … … 2480 2482 { 2481 2483 UNUSED_PARAM(ec); 2482 if (isContextLost() || !validateWebGLObject( program))2484 if (isContextLost() || !validateWebGLObject("getProgramParameter", program)) 2483 2485 return WebGLGetInfo(); 2484 2486 … … 2499 2501 return WebGLGetInfo(value); 2500 2502 default: 2501 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);2503 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getProgramParameter", "invalid parameter name"); 2502 2504 return WebGLGetInfo(); 2503 2505 } … … 2509 2511 if (isContextLost()) 2510 2512 return String(); 2511 if (!validateWebGLObject( program))2513 if (!validateWebGLObject("getProgramInfoLog", program)) 2512 2514 return ""; 2513 2515 WebGLStateRestorer(this, false); … … 2521 2523 return WebGLGetInfo(); 2522 2524 if (target != GraphicsContext3D::RENDERBUFFER) { 2523 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);2525 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParameter", "invalid target"); 2524 2526 return WebGLGetInfo(); 2525 2527 } 2526 2528 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { 2527 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);2529 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getRenderbufferParameter", "no renderbuffer bound"); 2528 2530 return WebGLGetInfo(); 2529 2531 } … … 2555 2557 return WebGLGetInfo(m_renderbufferBinding->getInternalFormat()); 2556 2558 default: 2557 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);2559 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParameter", "invalid parameter name"); 2558 2560 return WebGLGetInfo(); 2559 2561 } … … 2577 2579 return WebGLGetInfo(m_renderbufferBinding->getInternalFormat()); 2578 2580 default: 2579 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);2581 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParameter", "invalid parameter name"); 2580 2582 return WebGLGetInfo(); 2581 2583 } … … 2585 2587 { 2586 2588 UNUSED_PARAM(ec); 2587 if (isContextLost() || !validateWebGLObject( shader))2589 if (isContextLost() || !validateWebGLObject("getShaderParameter", shader)) 2588 2590 return WebGLGetInfo(); 2589 2591 WebGLStateRestorer(this, false); … … 2599 2601 return WebGLGetInfo(static_cast<unsigned int>(value)); 2600 2602 default: 2601 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);2603 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderParameter", "invalid parameter name"); 2602 2604 return WebGLGetInfo(); 2603 2605 } … … 2609 2611 if (isContextLost()) 2610 2612 return String(); 2611 if (!validateWebGLObject( shader))2613 if (!validateWebGLObject("getShaderInfoLog", shader)) 2612 2614 return ""; 2613 2615 WebGLStateRestorer(this, false); … … 2620 2622 if (isContextLost()) 2621 2623 return String(); 2622 if (!validateWebGLObject( shader))2624 if (!validateWebGLObject("getShaderSource", shader)) 2623 2625 return ""; 2624 2626 return shader->getSource(); … … 2652 2654 if (isContextLost()) 2653 2655 return WebGLGetInfo(); 2654 WebGLTexture* tex = validateTextureBinding( target, false);2656 WebGLTexture* tex = validateTextureBinding("getTexParameter", target, false); 2655 2657 if (!tex) 2656 2658 return WebGLGetInfo(); … … 2665 2667 return WebGLGetInfo(static_cast<unsigned int>(value)); 2666 2668 default: 2667 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);2669 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getTexParameter", "invalid parameter name"); 2668 2670 return WebGLGetInfo(); 2669 2671 } … … 2673 2675 { 2674 2676 UNUSED_PARAM(ec); 2675 if (isContextLost() || !validateWebGLObject( program))2677 if (isContextLost() || !validateWebGLObject("getUniform", program)) 2676 2678 return WebGLGetInfo(); 2677 2679 if (!uniformLocation || uniformLocation->program() != program) { 2678 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);2680 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getUniform", "no uniformlocation or not valid for this program"); 2679 2681 return WebGLGetInfo(); 2680 2682 } … … 2774 2776 default: 2775 2777 // Can't handle this type 2776 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);2778 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "getUniform", "unhandled type"); 2777 2779 return WebGLGetInfo(); 2778 2780 } … … 2810 2812 } 2811 2813 // If we get here, something went wrong in our unfortunately complex logic above 2812 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);2814 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "getUniform", "unknown error"); 2813 2815 return WebGLGetInfo(); 2814 2816 } … … 2817 2819 { 2818 2820 UNUSED_PARAM(ec); 2819 if (isContextLost() || !validateWebGLObject( program))2821 if (isContextLost() || !validateWebGLObject("getUniformLocation", program)) 2820 2822 return 0; 2821 if (!validateLocationLength( name))2823 if (!validateLocationLength("getUniformLocation", name)) 2822 2824 return 0; 2823 if (!validateString( name))2825 if (!validateString("getUniformLocation", name)) 2824 2826 return 0; 2825 2827 WebGLStateRestorer(this, false); … … 2837 2839 WebGLStateRestorer(this, false); 2838 2840 if (index >= m_maxVertexAttribs) { 2839 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);2841 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "getVertexAttrib", "index out of range"); 2840 2842 return WebGLGetInfo(); 2841 2843 } … … 2861 2863 return WebGLGetInfo(Float32Array::create(m_vertexAttribValue[index].value, 4)); 2862 2864 default: 2863 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);2865 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getVertexAttrib", "invalid parameter name"); 2864 2866 return WebGLGetInfo(); 2865 2867 } … … 2890 2892 } 2891 2893 if (!isValid) { 2892 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);2894 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "hint", "invalid target"); 2893 2895 return; 2894 2896 } … … 2915 2917 GC3Dboolean WebGLRenderingContext::isEnabled(GC3Denum cap) 2916 2918 { 2917 if ( !validateCapability(cap) || isContextLost())2919 if (isContextLost() || !validateCapability("isEnabled", cap)) 2918 2920 return 0; 2919 2921 return m_context->isEnabled(cap); … … 2980 2982 { 2981 2983 UNUSED_PARAM(ec); 2982 if (isContextLost() || !validateWebGLObject( program))2984 if (isContextLost() || !validateWebGLObject("linkProgram", program)) 2983 2985 return; 2984 2986 if (!isGLES2Compliant()) { … … 3015 3017 m_unpackColorspaceConversion = static_cast<GC3Denum>(param); 3016 3018 else { 3017 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);3019 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "pixelStorei", "invalid parameter for UNPACK_COLORSPACE_CONVERSION_WEBGL"); 3018 3020 return; 3019 3021 } … … 3029 3031 cleanupAfterGraphicsCall(false); 3030 3032 } else { 3031 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);3033 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "pixelStorei", "invalid parameter for alignment"); 3032 3034 return; 3033 3035 } 3034 3036 break; 3035 3037 default: 3036 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);3038 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "pixelStorei", "invalid parameter name"); 3037 3039 return; 3038 3040 } … … 3056 3058 // Validate input parameters. 3057 3059 if (!pixels) { 3058 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);3060 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "readPixels", "no destination ArrayBufferView"); 3059 3061 return; 3060 3062 } … … 3065 3067 break; 3066 3068 default: 3067 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);3069 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "readPixels", "invalid format"); 3068 3070 return; 3069 3071 } … … 3075 3077 break; 3076 3078 default: 3077 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);3079 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "readPixels", "invalid type"); 3078 3080 return; 3079 3081 } 3080 3082 if (format != GraphicsContext3D::RGBA || type != GraphicsContext3D::UNSIGNED_BYTE) { 3081 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);3083 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "format not RGBA or type not UNSIGNED_BYTE"); 3082 3084 return; 3083 3085 } 3084 3086 // Validate array type against pixel type. 3085 3087 if (!pixels->isUnsignedByteArray()) { 3086 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);3088 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "ArrayBufferView not Uint8Array"); 3087 3089 return; 3088 3090 } 3089 3091 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3D(), !isResourceSafe())) { 3090 m_context->synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION);3092 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "readPixels", "framebuffer not readable"); 3091 3093 return; 3092 3094 } … … 3096 3098 GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, height, m_packAlignment, &totalBytesRequired, &padding); 3097 3099 if (error != GraphicsContext3D::NO_ERROR) { 3098 m_context->synthesizeGLError(error);3100 synthesizeGLError(error, "readPixels", "invalid dimensions"); 3099 3101 return; 3100 3102 } 3101 3103 if (pixels->byteLength() < totalBytesRequired) { 3102 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);3104 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "ArrayBufferView not large enough for dimensions"); 3103 3105 return; 3104 3106 } … … 3141 3143 return; 3142 3144 if (target != GraphicsContext3D::RENDERBUFFER) { 3143 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);3145 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "renderbufferStorage", "invalid target"); 3144 3146 return; 3145 3147 } 3146 3148 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { 3147 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);3148 return; 3149 } 3150 if (!validateSize( width, height))3149 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "renderbufferStorage", "no bound renderbuffer"); 3150 return; 3151 } 3152 if (!validateSize("renderbufferStorage", width, height)) 3151 3153 return; 3152 3154 switch (internalformat) { … … 3172 3174 break; 3173 3175 default: 3174 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);3176 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "renderbufferStorage", "invalid internalformat"); 3175 3177 } 3176 3178 } … … 3188 3190 if (isContextLost()) 3189 3191 return; 3190 if (!validateSize( width, height))3192 if (!validateSize("scissor", width, height)) 3191 3193 return; 3192 3194 m_context->scissor(x, y, width, height); … … 3197 3199 { 3198 3200 UNUSED_PARAM(ec); 3199 if (isContextLost() || !validateWebGLObject( shader))3201 if (isContextLost() || !validateWebGLObject("shaderSource", shader)) 3200 3202 return; 3201 3203 String stringWithoutComments = StripComments(string).result(); 3202 if (!validateString( stringWithoutComments))3204 if (!validateString("shaderSource", stringWithoutComments)) 3203 3205 return; 3204 3206 shader->setSource(string); … … 3211 3213 if (isContextLost()) 3212 3214 return; 3213 if (!validateStencilFunc( func))3215 if (!validateStencilFunc("stencilFunc", func)) 3214 3216 return; 3215 3217 m_stencilFuncRef = ref; … … 3225 3227 if (isContextLost()) 3226 3228 return; 3227 if (!validateStencilFunc( func))3229 if (!validateStencilFunc("stencilFuncSeparate", func)) 3228 3230 return; 3229 3231 switch (face) { … … 3243 3245 break; 3244 3246 default: 3245 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);3247 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "stencilFuncSeparate", "invalid face"); 3246 3248 return; 3247 3249 } … … 3276 3278 break; 3277 3279 default: 3278 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);3280 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "stencilMaskSeparate", "invalid face"); 3279 3281 return; 3280 3282 } … … 3305 3307 // FIXME: For now we ignore any errors returned 3306 3308 ec = 0; 3307 if (!validateTexFuncParameters( target, level, internalformat, width, height, border, format, type))3308 return; 3309 WebGLTexture* tex = validateTextureBinding( target, true);3309 if (!validateTexFuncParameters("texImage2D", target, level, internalformat, width, height, border, format, type)) 3310 return; 3311 WebGLTexture* tex = validateTextureBinding("texImage2D", target, true); 3310 3312 if (!tex) 3311 3313 return; 3312 3314 if (!isGLES2NPOTStrict()) { 3313 3315 if (level && WebGLTexture::isNPOT(width, height)) { 3314 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);3316 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "level > 0 not power of 2"); 3315 3317 return; 3316 3318 } … … 3336 3338 Vector<uint8_t> data; 3337 3339 if (!m_context->extractImageData(image, format, type, flipY, premultiplyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE, data)) { 3338 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);3340 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "bad image data"); 3339 3341 return; 3340 3342 } … … 3351 3353 GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionCode& ec) 3352 3354 { 3353 if (isContextLost() || !validateTexFuncData( width, height, format, type, pixels))3355 if (isContextLost() || !validateTexFuncData("texImage2D", width, height, format, type, pixels)) 3354 3356 return; 3355 3357 void* data = pixels ? pixels->baseAddress() : 0; … … 3382 3384 Vector<uint8_t> data; 3383 3385 if (!m_context->extractImageData(pixels, format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) { 3384 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);3386 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "bad image data"); 3385 3387 return; 3386 3388 } … … 3399 3401 if (isContextLost()) 3400 3402 return; 3401 if (!validateHTMLImageElement( image))3403 if (!validateHTMLImageElement("texImage2D", image)) 3402 3404 return; 3403 3405 if (wouldTaintOrigin(image)) { … … 3417 3419 return; 3418 3420 if (!canvas || !canvas->buffer()) { 3419 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);3421 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "no canvas"); 3420 3422 return; 3421 3423 } … … 3436 3438 { 3437 3439 if (!video || !video->videoWidth() || !video->videoHeight()) { 3438 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);3440 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "no video"); 3439 3441 return 0; 3440 3442 } … … 3442 3444 ImageBuffer* buf = m_videoCache.imageBuffer(size); 3443 3445 if (!buf) { 3444 m_context->synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY);3446 synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY, "texImage2D", "out of memory"); 3445 3447 return 0; 3446 3448 } … … 3472 3474 if (isContextLost()) 3473 3475 return; 3474 WebGLTexture* tex = validateTextureBinding( target, false);3476 WebGLTexture* tex = validateTextureBinding("texParameter", target, false); 3475 3477 if (!tex) 3476 3478 return; … … 3483 3485 if ((isFloat && paramf != GraphicsContext3D::CLAMP_TO_EDGE && paramf != GraphicsContext3D::MIRRORED_REPEAT && paramf != GraphicsContext3D::REPEAT) 3484 3486 || (!isFloat && parami != GraphicsContext3D::CLAMP_TO_EDGE && parami != GraphicsContext3D::MIRRORED_REPEAT && parami != GraphicsContext3D::REPEAT)) { 3485 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);3487 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "texParameter", "invalid parameter"); 3486 3488 return; 3487 3489 } 3488 3490 break; 3489 3491 default: 3490 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);3492 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "texParameter", "invalid parameter name"); 3491 3493 return; 3492 3494 } … … 3519 3521 if (isContextLost()) 3520 3522 return; 3521 if (!validateTexFuncParameters( target, level, format, width, height, 0, format, type))3522 return; 3523 if (!validateSize( xoffset, yoffset))3524 return; 3525 WebGLTexture* tex = validateTextureBinding( target, true);3523 if (!validateTexFuncParameters("texSubImage2D", target, level, format, width, height, 0, format, type)) 3524 return; 3525 if (!validateSize("texSubImage2D", xoffset, yoffset)) 3526 return; 3527 WebGLTexture* tex = validateTextureBinding("texSubImage2D", target, true); 3526 3528 if (!tex) 3527 3529 return; 3528 3530 if (xoffset + width > tex->getWidth(target, level) || yoffset + height > tex->getHeight(target, level)) { 3529 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);3531 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "dimensions out of range"); 3530 3532 return; 3531 3533 } 3532 3534 if (tex->getInternalFormat(target, level) != format || tex->getType(target, level) != type) { 3533 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);3535 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "texSubImage2D", "type and format do not match texture"); 3534 3536 return; 3535 3537 } … … 3547 3549 Vector<uint8_t> data; 3548 3550 if (!m_context->extractImageData(image, format, type, flipY, premultiplyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE, data)) { 3549 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);3551 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "bad image"); 3550 3552 return; 3551 3553 } … … 3558 3560 GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionCode& ec) 3559 3561 { 3560 if (isContextLost() || !validateTexFuncData( width, height, format, type, pixels))3562 if (isContextLost() || !validateTexFuncData("texSubImage2D", width, height, format, type, pixels)) 3561 3563 return; 3562 3564 void* data = pixels ? pixels->baseAddress() : 0; … … 3588 3590 Vector<uint8_t> data; 3589 3591 if (!m_context->extractImageData(pixels, format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) { 3590 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);3592 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "bad image data"); 3591 3593 return; 3592 3594 } … … 3601 3603 if (isContextLost()) 3602 3604 return; 3603 if (!validateHTMLImageElement( image))3605 if (!validateHTMLImageElement("texSubImage2D", image)) 3604 3606 return; 3605 3607 if (wouldTaintOrigin(image)) { … … 3618 3620 return; 3619 3621 if (!canvas || !canvas->buffer()) { 3620 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);3622 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "no canvas"); 3621 3623 return; 3622 3624 } … … 3654 3656 3655 3657 if (location->program() != m_currentProgram) { 3656 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);3658 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform1f", "location not for current program"); 3657 3659 return; 3658 3660 } … … 3665 3667 { 3666 3668 UNUSED_PARAM(ec); 3667 if (isContextLost() || !validateUniformParameters( location, v, 1))3669 if (isContextLost() || !validateUniformParameters("uniform1fv", location, v, 1)) 3668 3670 return; 3669 3671 … … 3675 3677 { 3676 3678 UNUSED_PARAM(ec); 3677 if (isContextLost() || !validateUniformParameters( location, v, size, 1))3679 if (isContextLost() || !validateUniformParameters("uniform1fv", location, v, size, 1)) 3678 3680 return; 3679 3681 … … 3689 3691 3690 3692 if (location->program() != m_currentProgram) { 3691 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);3693 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform1i", "location not for current program"); 3692 3694 return; 3693 3695 } … … 3700 3702 { 3701 3703 UNUSED_PARAM(ec); 3702 if (isContextLost() || !validateUniformParameters( location, v, 1))3704 if (isContextLost() || !validateUniformParameters("uniform1iv", location, v, 1)) 3703 3705 return; 3704 3706 … … 3710 3712 { 3711 3713 UNUSED_PARAM(ec); 3712 if (isContextLost() || !validateUniformParameters( location, v, size, 1))3714 if (isContextLost() || !validateUniformParameters("uniform1iv", location, v, size, 1)) 3713 3715 return; 3714 3716 … … 3724 3726 3725 3727 if (location->program() != m_currentProgram) { 3726 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);3728 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform2f", "location not for current program"); 3727 3729 return; 3728 3730 } … … 3735 3737 { 3736 3738 UNUSED_PARAM(ec); 3737 if (isContextLost() || !validateUniformParameters( location, v, 2))3739 if (isContextLost() || !validateUniformParameters("uniform2fv", location, v, 2)) 3738 3740 return; 3739 3741 … … 3745 3747 { 3746 3748 UNUSED_PARAM(ec); 3747 if (isContextLost() || !validateUniformParameters( location, v, size, 2))3749 if (isContextLost() || !validateUniformParameters("uniform2fv", location, v, size, 2)) 3748 3750 return; 3749 3751 … … 3759 3761 3760 3762 if (location->program() != m_currentProgram) { 3761 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);3763 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform2i", "location not for current program"); 3762 3764 return; 3763 3765 } … … 3770 3772 { 3771 3773 UNUSED_PARAM(ec); 3772 if (isContextLost() || !validateUniformParameters( location, v, 2))3774 if (isContextLost() || !validateUniformParameters("uniform2iv", location, v, 2)) 3773 3775 return; 3774 3776 … … 3780 3782 { 3781 3783 UNUSED_PARAM(ec); 3782 if (isContextLost() || !validateUniformParameters( location, v, size, 2))3784 if (isContextLost() || !validateUniformParameters("uniform2iv", location, v, size, 2)) 3783 3785 return; 3784 3786 … … 3794 3796 3795 3797 if (location->program() != m_currentProgram) { 3796 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);3798 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform3f", "location not for current program"); 3797 3799 return; 3798 3800 } … … 3805 3807 { 3806 3808 UNUSED_PARAM(ec); 3807 if (isContextLost() || !validateUniformParameters( location, v, 3))3809 if (isContextLost() || !validateUniformParameters("uniform3fv", location, v, 3)) 3808 3810 return; 3809 3811 … … 3815 3817 { 3816 3818 UNUSED_PARAM(ec); 3817 if (isContextLost() || !validateUniformParameters( location, v, size, 3))3819 if (isContextLost() || !validateUniformParameters("uniform3fv", location, v, size, 3)) 3818 3820 return; 3819 3821 … … 3829 3831 3830 3832 if (location->program() != m_currentProgram) { 3831 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);3833 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform3i", "location not for current program"); 3832 3834 return; 3833 3835 } … … 3840 3842 { 3841 3843 UNUSED_PARAM(ec); 3842 if (isContextLost() || !validateUniformParameters( location, v, 3))3844 if (isContextLost() || !validateUniformParameters("uniform3iv", location, v, 3)) 3843 3845 return; 3844 3846 … … 3850 3852 { 3851 3853 UNUSED_PARAM(ec); 3852 if (isContextLost() || !validateUniformParameters( location, v, size, 3))3854 if (isContextLost() || !validateUniformParameters("uniform3iv", location, v, size, 3)) 3853 3855 return; 3854 3856 … … 3864 3866 3865 3867 if (location->program() != m_currentProgram) { 3866 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);3868 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform4f", "location not for current program"); 3867 3869 return; 3868 3870 } … … 3875 3877 { 3876 3878 UNUSED_PARAM(ec); 3877 if (isContextLost() || !validateUniformParameters( location, v, 4))3879 if (isContextLost() || !validateUniformParameters("uniform4fv", location, v, 4)) 3878 3880 return; 3879 3881 … … 3885 3887 { 3886 3888 UNUSED_PARAM(ec); 3887 if (isContextLost() || !validateUniformParameters( location, v, size, 4))3889 if (isContextLost() || !validateUniformParameters("uniform4fv", location, v, size, 4)) 3888 3890 return; 3889 3891 … … 3899 3901 3900 3902 if (location->program() != m_currentProgram) { 3901 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);3903 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform4i", "location not for current program"); 3902 3904 return; 3903 3905 } … … 3910 3912 { 3911 3913 UNUSED_PARAM(ec); 3912 if (isContextLost() || !validateUniformParameters( location, v, 4))3914 if (isContextLost() || !validateUniformParameters("uniform4iv", location, v, 4)) 3913 3915 return; 3914 3916 … … 3920 3922 { 3921 3923 UNUSED_PARAM(ec); 3922 if (isContextLost() || !validateUniformParameters( location, v, size, 4))3924 if (isContextLost() || !validateUniformParameters("uniform4iv", location, v, size, 4)) 3923 3925 return; 3924 3926 … … 3930 3932 { 3931 3933 UNUSED_PARAM(ec); 3932 if (isContextLost() || !validateUniformMatrixParameters( location, transpose, v, 4))3934 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, v, 4)) 3933 3935 return; 3934 3936 m_context->uniformMatrix2fv(location->location(), transpose, v->data(), v->length() / 4); … … 3939 3941 { 3940 3942 UNUSED_PARAM(ec); 3941 if (isContextLost() || !validateUniformMatrixParameters( location, transpose, v, size, 4))3943 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, v, size, 4)) 3942 3944 return; 3943 3945 m_context->uniformMatrix2fv(location->location(), transpose, v, size / 4); … … 3948 3950 { 3949 3951 UNUSED_PARAM(ec); 3950 if (isContextLost() || !validateUniformMatrixParameters( location, transpose, v, 9))3952 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, v, 9)) 3951 3953 return; 3952 3954 m_context->uniformMatrix3fv(location->location(), transpose, v->data(), v->length() / 9); … … 3957 3959 { 3958 3960 UNUSED_PARAM(ec); 3959 if (isContextLost() || !validateUniformMatrixParameters( location, transpose, v, size, 9))3961 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, v, size, 9)) 3960 3962 return; 3961 3963 m_context->uniformMatrix3fv(location->location(), transpose, v, size / 9); … … 3966 3968 { 3967 3969 UNUSED_PARAM(ec); 3968 if (isContextLost() || !validateUniformMatrixParameters( location, transpose, v, 16))3970 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, v, 16)) 3969 3971 return; 3970 3972 m_context->uniformMatrix4fv(location->location(), transpose, v->data(), v->length() / 16); … … 3975 3977 { 3976 3978 UNUSED_PARAM(ec); 3977 if (isContextLost() || !validateUniformMatrixParameters( location, transpose, v, size, 16))3979 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, v, size, 16)) 3978 3980 return; 3979 3981 m_context->uniformMatrix4fv(location->location(), transpose, v, size / 16); … … 3985 3987 UNUSED_PARAM(ec); 3986 3988 bool deleted; 3987 if (!checkObjectToBeBound( program, deleted))3989 if (!checkObjectToBeBound("useProgram", program, deleted)) 3988 3990 return; 3989 3991 if (deleted) 3990 3992 program = 0; 3991 3993 if (program && !program->getLinkStatus()) { 3992 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);3994 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "useProgram", "program not valid"); 3993 3995 cleanupAfterGraphicsCall(false); 3994 3996 return; … … 4008 4010 { 4009 4011 UNUSED_PARAM(ec); 4010 if (isContextLost() || !validateWebGLObject( program))4012 if (isContextLost() || !validateWebGLObject("validateProgram", program)) 4011 4013 return; 4012 4014 m_context->validateProgram(objectOrZero(program)); … … 4016 4018 void WebGLRenderingContext::vertexAttrib1f(GC3Duint index, GC3Dfloat v0) 4017 4019 { 4018 vertexAttribfImpl( index, 1, v0, 0.0f, 0.0f, 1.0f);4020 vertexAttribfImpl("vertexAttrib1f", index, 1, v0, 0.0f, 0.0f, 1.0f); 4019 4021 } 4020 4022 4021 4023 void WebGLRenderingContext::vertexAttrib1fv(GC3Duint index, Float32Array* v) 4022 4024 { 4023 vertexAttribfvImpl( index, v, 1);4025 vertexAttribfvImpl("vertexAttrib1fv", index, v, 1); 4024 4026 } 4025 4027 4026 4028 void WebGLRenderingContext::vertexAttrib1fv(GC3Duint index, GC3Dfloat* v, GC3Dsizei size) 4027 4029 { 4028 vertexAttribfvImpl( index, v, size, 1);4030 vertexAttribfvImpl("vertexAttrib1fv", index, v, size, 1); 4029 4031 } 4030 4032 4031 4033 void WebGLRenderingContext::vertexAttrib2f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1) 4032 4034 { 4033 vertexAttribfImpl( index, 2, v0, v1, 0.0f, 1.0f);4035 vertexAttribfImpl("vertexAttrib2f", index, 2, v0, v1, 0.0f, 1.0f); 4034 4036 } 4035 4037 4036 4038 void WebGLRenderingContext::vertexAttrib2fv(GC3Duint index, Float32Array* v) 4037 4039 { 4038 vertexAttribfvImpl( index, v, 2);4040 vertexAttribfvImpl("vertexAttrib2fv", index, v, 2); 4039 4041 } 4040 4042 4041 4043 void WebGLRenderingContext::vertexAttrib2fv(GC3Duint index, GC3Dfloat* v, GC3Dsizei size) 4042 4044 { 4043 vertexAttribfvImpl( index, v, size, 2);4045 vertexAttribfvImpl("vertexAttrib2fv", index, v, size, 2); 4044 4046 } 4045 4047 4046 4048 void WebGLRenderingContext::vertexAttrib3f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2) 4047 4049 { 4048 vertexAttribfImpl( index, 3, v0, v1, v2, 1.0f);4050 vertexAttribfImpl("vertexAttrib3f", index, 3, v0, v1, v2, 1.0f); 4049 4051 } 4050 4052 4051 4053 void WebGLRenderingContext::vertexAttrib3fv(GC3Duint index, Float32Array* v) 4052 4054 { 4053 vertexAttribfvImpl( index, v, 3);4055 vertexAttribfvImpl("vertexAttrib3fv", index, v, 3); 4054 4056 } 4055 4057 4056 4058 void WebGLRenderingContext::vertexAttrib3fv(GC3Duint index, GC3Dfloat* v, GC3Dsizei size) 4057 4059 { 4058 vertexAttribfvImpl( index, v, size, 3);4060 vertexAttribfvImpl("vertexAttrib3fv", index, v, size, 3); 4059 4061 } 4060 4062 4061 4063 void WebGLRenderingContext::vertexAttrib4f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfloat v3) 4062 4064 { 4063 vertexAttribfImpl( index, 4, v0, v1, v2, v3);4065 vertexAttribfImpl("vertexAttrib4f", index, 4, v0, v1, v2, v3); 4064 4066 } 4065 4067 4066 4068 void WebGLRenderingContext::vertexAttrib4fv(GC3Duint index, Float32Array* v) 4067 4069 { 4068 vertexAttribfvImpl( index, v, 4);4070 vertexAttribfvImpl("vertexAttrib4fv", index, v, 4); 4069 4071 } 4070 4072 4071 4073 void WebGLRenderingContext::vertexAttrib4fv(GC3Duint index, GC3Dfloat* v, GC3Dsizei size) 4072 4074 { 4073 vertexAttribfvImpl( index, v, size, 4);4075 vertexAttribfvImpl("vertexAttrib4fv", index, v, size, 4); 4074 4076 } 4075 4077 … … 4087 4089 break; 4088 4090 default: 4089 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);4091 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "vertexAttribPointer", "invalid type"); 4090 4092 return; 4091 4093 } 4092 4094 if (index >= m_maxVertexAttribs) { 4093 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4095 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "vertexAttribPointer", "index out of range"); 4094 4096 return; 4095 4097 } 4096 4098 if (size < 1 || size > 4 || stride < 0 || stride > 255 || offset < 0) { 4097 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4099 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "vertexAttribPointer", "bad size, stride or offset"); 4098 4100 return; 4099 4101 } 4100 4102 if (!m_boundArrayBuffer) { 4101 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);4103 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "vertexAttribPointer", "no bound ARRAY_BUFFER"); 4102 4104 return; 4103 4105 } … … 4105 4107 unsigned int typeSize = sizeInBytes(type); 4106 4108 if (!typeSize) { 4107 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);4109 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "vertexAttribPointer", "invalid type"); 4108 4110 return; 4109 4111 } 4110 4112 if ((stride % typeSize) || (offset % typeSize)) { 4111 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);4113 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "vertexAttribPointer", "stride or offset not valid for type"); 4112 4114 return; 4113 4115 } … … 4133 4135 if (isContextLost()) 4134 4136 return; 4135 if (!validateSize( width, height))4137 if (!validateSize("viewport", width, height)) 4136 4138 return; 4137 4139 m_context->viewport(x, y, width, height); … … 4142 4144 { 4143 4145 if (isContextLost()) { 4144 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);4146 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "loseContext", "context already lost"); 4145 4147 return; 4146 4148 } … … 4167 4169 break; 4168 4170 } 4169 m_context->synthesizeGLError(GraphicsContext3D::CONTEXT_LOST_WEBGL);4171 synthesizeGLError(GraphicsContext3D::CONTEXT_LOST_WEBGL, "loseContext", "context lost"); 4170 4172 4171 4173 // Don't allow restoration unless the context lost event has both been … … 4181 4183 { 4182 4184 if (!isContextLost()) { 4183 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);4185 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "restoreContext", "context not lost"); 4184 4186 return; 4185 4187 } … … 4187 4189 if (!m_restoreAllowed) { 4188 4190 if (m_contextLostMode == SyntheticLostContext) 4189 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);4191 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "restoreContext", "context restoration not allowed"); 4190 4192 return; 4191 4193 } … … 4418 4420 } 4419 4421 4420 WebGLTexture* WebGLRenderingContext::validateTextureBinding( GC3Denum target, bool useSixEnumsForCubeMap)4422 WebGLTexture* WebGLRenderingContext::validateTextureBinding(const char* functionName, GC3Denum target, bool useSixEnumsForCubeMap) 4421 4423 { 4422 4424 WebGLTexture* tex = 0; … … 4432 4434 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z: 4433 4435 if (!useSixEnumsForCubeMap) { 4434 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);4436 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid texture target"); 4435 4437 return 0; 4436 4438 } … … 4439 4441 case GraphicsContext3D::TEXTURE_CUBE_MAP: 4440 4442 if (useSixEnumsForCubeMap) { 4441 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);4443 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid texture target"); 4442 4444 return 0; 4443 4445 } … … 4445 4447 break; 4446 4448 default: 4447 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);4449 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid texture target"); 4448 4450 return 0; 4449 4451 } 4450 4452 if (!tex) 4451 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);4453 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "no texture"); 4452 4454 return tex; 4453 4455 } 4454 4456 4455 bool WebGLRenderingContext::validateLocationLength(const String& string)4457 bool WebGLRenderingContext::validateLocationLength(const char* functionName, const String& string) 4456 4458 { 4457 4459 const unsigned maxWebGLLocationLength = 256; 4458 4460 if (string.length() > maxWebGLLocationLength) { 4459 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4461 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "location length > 256"); 4460 4462 return false; 4461 4463 } … … 4463 4465 } 4464 4466 4465 bool WebGLRenderingContext::validateSize( GC3Dint x, GC3Dint y)4467 bool WebGLRenderingContext::validateSize(const char* functionName, GC3Dint x, GC3Dint y) 4466 4468 { 4467 4469 if (x < 0 || y < 0) { 4468 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4470 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "size < 0"); 4469 4471 return false; 4470 4472 } … … 4472 4474 } 4473 4475 4474 bool WebGLRenderingContext::validateString(const String& string)4476 bool WebGLRenderingContext::validateString(const char* functionName, const String& string) 4475 4477 { 4476 4478 for (size_t i = 0; i < string.length(); ++i) { 4477 4479 if (!validateCharacter(string[i])) { 4478 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4480 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "string not ASCII"); 4479 4481 return false; 4480 4482 } … … 4483 4485 } 4484 4486 4485 bool WebGLRenderingContext::validateTexFuncFormatAndType( GC3Denum format, GC3Denum type)4487 bool WebGLRenderingContext::validateTexFuncFormatAndType(const char* functionName, GC3Denum format, GC3Denum type) 4486 4488 { 4487 4489 switch (format) { … … 4493 4495 break; 4494 4496 default: 4495 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);4497 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid texture format"); 4496 4498 return false; 4497 4499 } … … 4506 4508 if (m_oesTextureFloat) 4507 4509 break; 4508 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);4510 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid texture type"); 4509 4511 return false; 4510 4512 default: 4511 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);4513 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid texture type"); 4512 4514 return false; 4513 4515 } … … 4520 4522 if (type != GraphicsContext3D::UNSIGNED_BYTE 4521 4523 && type != GraphicsContext3D::FLOAT) { 4522 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);4524 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "invalid type for format"); 4523 4525 return false; 4524 4526 } … … 4528 4530 && type != GraphicsContext3D::UNSIGNED_SHORT_5_6_5 4529 4531 && type != GraphicsContext3D::FLOAT) { 4530 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);4532 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "invalid type for RGB format"); 4531 4533 return false; 4532 4534 } … … 4537 4539 && type != GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1 4538 4540 && type != GraphicsContext3D::FLOAT) { 4539 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);4541 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "invalid type for RGBA format"); 4540 4542 return false; 4541 4543 } … … 4548 4550 } 4549 4551 4550 bool WebGLRenderingContext::validateTexFuncLevel( GC3Denum target, GC3Dint level)4552 bool WebGLRenderingContext::validateTexFuncLevel(const char* functionName, GC3Denum target, GC3Dint level) 4551 4553 { 4552 4554 if (level < 0) { 4553 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4555 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "level < 0"); 4554 4556 return false; 4555 4557 } … … 4557 4559 case GraphicsContext3D::TEXTURE_2D: 4558 4560 if (level > m_maxTextureLevel) { 4559 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4561 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "level out of range"); 4560 4562 return false; 4561 4563 } … … 4568 4570 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z: 4569 4571 if (level > m_maxCubeMapTextureLevel) { 4570 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4572 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "level out of range"); 4571 4573 return false; 4572 4574 } … … 4578 4580 } 4579 4581 4580 bool WebGLRenderingContext::validateTexFuncParameters(GC3Denum target, GC3Dint level, 4582 bool WebGLRenderingContext::validateTexFuncParameters(const char* functionName, 4583 GC3Denum target, GC3Dint level, 4581 4584 GC3Denum internalformat, 4582 4585 GC3Dsizei width, GC3Dsizei height, GC3Dint border, … … 4586 4589 // The texImage2D entry points taking HTMLImage, etc. will produce 4587 4590 // temporary data based on this combination, so it must be legal. 4588 if (!validateTexFuncFormatAndType(f ormat, type) || !validateTexFuncLevel(target, level))4591 if (!validateTexFuncFormatAndType(functionName, format, type) || !validateTexFuncLevel(functionName, target, level)) 4589 4592 return false; 4590 4593 4591 4594 if (width < 0 || height < 0) { 4592 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4595 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "width or height < 0"); 4593 4596 return false; 4594 4597 } … … 4597 4600 case GraphicsContext3D::TEXTURE_2D: 4598 4601 if (width > m_maxTextureSize || height > m_maxTextureSize) { 4599 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4602 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "width or height out of range"); 4600 4603 return false; 4601 4604 } … … 4608 4611 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z: 4609 4612 if (width != height || width > m_maxCubeMapTextureSize) { 4610 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4613 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "width != height or width or height out of range for cube map"); 4611 4614 return false; 4612 4615 } 4613 4616 break; 4614 4617 default: 4615 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);4618 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid target"); 4616 4619 return false; 4617 4620 } 4618 4621 4619 4622 if (format != internalformat) { 4620 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);4623 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "format != internalformat"); 4621 4624 return false; 4622 4625 } 4623 4626 4624 4627 if (border) { 4625 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4628 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "border != 0"); 4626 4629 return false; 4627 4630 } … … 4630 4633 } 4631 4634 4632 bool WebGLRenderingContext::validateTexFuncData(GC3Dsizei width, GC3Dsizei height, 4635 bool WebGLRenderingContext::validateTexFuncData(const char* functionName, 4636 GC3Dsizei width, GC3Dsizei height, 4633 4637 GC3Denum format, GC3Denum type, 4634 4638 ArrayBufferView* pixels) … … 4637 4641 return true; 4638 4642 4639 if (!validateTexFuncFormatAndType(f ormat, type))4643 if (!validateTexFuncFormatAndType(functionName, format, type)) 4640 4644 return false; 4641 4645 … … 4643 4647 case GraphicsContext3D::UNSIGNED_BYTE: 4644 4648 if (!pixels->isUnsignedByteArray()) { 4645 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);4649 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "type UNSIGNED_BYTE but ArrayBufferView not Uint8Array"); 4646 4650 return false; 4647 4651 } … … 4651 4655 case GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1: 4652 4656 if (!pixels->isUnsignedShortArray()) { 4653 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);4657 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "type UNSIGNED_SHORT but ArrayBufferView not Uint16Array"); 4654 4658 return false; 4655 4659 } … … 4657 4661 case GraphicsContext3D::FLOAT: // OES_texture_float 4658 4662 if (!pixels->isFloatArray()) { 4659 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);4663 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "type FLOAT but ArrayBufferView not Float32Array"); 4660 4664 return false; 4661 4665 } … … 4668 4672 GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, height, m_unpackAlignment, &totalBytesRequired, 0); 4669 4673 if (error != GraphicsContext3D::NO_ERROR) { 4670 m_context->synthesizeGLError(error);4674 synthesizeGLError(error, functionName, "invalid texture dimensions"); 4671 4675 return false; 4672 4676 } 4673 4677 if (pixels->byteLength() < totalBytesRequired) { 4674 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);4678 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "ArrayBufferView not big enough for request"); 4675 4679 return false; 4676 4680 } … … 4678 4682 } 4679 4683 4680 bool WebGLRenderingContext::validateDrawMode( GC3Denum mode)4684 bool WebGLRenderingContext::validateDrawMode(const char* functionName, GC3Denum mode) 4681 4685 { 4682 4686 switch (mode) { … … 4690 4694 return true; 4691 4695 default: 4692 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);4696 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid draw mode"); 4693 4697 return false; 4694 4698 } 4695 4699 } 4696 4700 4697 bool WebGLRenderingContext::validateStencilSettings( )4701 bool WebGLRenderingContext::validateStencilSettings(const char* functionName) 4698 4702 { 4699 4703 if (m_stencilMask != m_stencilMaskBack || m_stencilFuncRef != m_stencilFuncRefBack || m_stencilFuncMask != m_stencilFuncMaskBack) { 4700 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);4704 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "front and back stencils settings do not match"); 4701 4705 return false; 4702 4706 } … … 4704 4708 } 4705 4709 4706 bool WebGLRenderingContext::validateStencilFunc( GC3Denum func)4710 bool WebGLRenderingContext::validateStencilFunc(const char* functionName, GC3Denum func) 4707 4711 { 4708 4712 switch (func) { … … 4717 4721 return true; 4718 4722 default: 4719 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);4723 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid function"); 4720 4724 return false; 4721 4725 } … … 4727 4731 } 4728 4732 4729 bool WebGLRenderingContext::validateFramebufferFuncParameters( GC3Denum target, GC3Denum attachment)4733 bool WebGLRenderingContext::validateFramebufferFuncParameters(const char* functionName, GC3Denum target, GC3Denum attachment) 4730 4734 { 4731 4735 if (target != GraphicsContext3D::FRAMEBUFFER) { 4732 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);4736 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid target"); 4733 4737 return false; 4734 4738 } … … 4740 4744 break; 4741 4745 default: 4742 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);4746 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid attachment"); 4743 4747 return false; 4744 4748 } … … 4746 4750 } 4747 4751 4748 bool WebGLRenderingContext::validateBlendEquation( GC3Denum mode)4752 bool WebGLRenderingContext::validateBlendEquation(const char* functionName, GC3Denum mode) 4749 4753 { 4750 4754 switch (mode) { … … 4754 4758 return true; 4755 4759 default: 4756 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);4760 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid mode"); 4757 4761 return false; 4758 4762 } 4759 4763 } 4760 4764 4761 bool WebGLRenderingContext::validateBlendFuncFactors( GC3Denum src, GC3Denum dst)4765 bool WebGLRenderingContext::validateBlendFuncFactors(const char* functionName, GC3Denum src, GC3Denum dst) 4762 4766 { 4763 4767 if (((src == GraphicsContext3D::CONSTANT_COLOR || src == GraphicsContext3D::ONE_MINUS_CONSTANT_COLOR) … … 4765 4769 || ((dst == GraphicsContext3D::CONSTANT_COLOR || dst == GraphicsContext3D::ONE_MINUS_CONSTANT_COLOR) 4766 4770 && (src == GraphicsContext3D::CONSTANT_ALPHA || src == GraphicsContext3D::ONE_MINUS_CONSTANT_ALPHA))) { 4767 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);4771 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "incompatible src and dst"); 4768 4772 return false; 4769 4773 } … … 4771 4775 } 4772 4776 4773 bool WebGLRenderingContext::validateCapability( GC3Denum cap)4777 bool WebGLRenderingContext::validateCapability(const char* functionName, GC3Denum cap) 4774 4778 { 4775 4779 switch (cap) { … … 4785 4789 return true; 4786 4790 default: 4787 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);4791 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid capability"); 4788 4792 return false; 4789 4793 } 4790 4794 } 4791 4795 4792 bool WebGLRenderingContext::validateUniformParameters(const WebGLUniformLocation* location, Float32Array* v, GC3Dsizei requiredMinSize)4796 bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, Float32Array* v, GC3Dsizei requiredMinSize) 4793 4797 { 4794 4798 if (!v) { 4795 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4799 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no array"); 4796 4800 return false; 4797 4801 } 4798 return validateUniformMatrixParameters( location, false, v->data(), v->length(), requiredMinSize);4799 } 4800 4801 bool WebGLRenderingContext::validateUniformParameters(const WebGLUniformLocation* location, Int32Array* v, GC3Dsizei requiredMinSize)4802 return validateUniformMatrixParameters(functionName, location, false, v->data(), v->length(), requiredMinSize); 4803 } 4804 4805 bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, Int32Array* v, GC3Dsizei requiredMinSize) 4802 4806 { 4803 4807 if (!v) { 4804 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4808 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no array"); 4805 4809 return false; 4806 4810 } 4807 return validateUniformMatrixParameters( location, false, v->data(), v->length(), requiredMinSize);4808 } 4809 4810 bool WebGLRenderingContext::validateUniformParameters(const WebGLUniformLocation* location, void* v, GC3Dsizei size, GC3Dsizei requiredMinSize)4811 { 4812 return validateUniformMatrixParameters( location, false, v, size, requiredMinSize);4813 } 4814 4815 bool WebGLRenderingContext::validateUniformMatrixParameters(const WebGLUniformLocation* location, GC3Dboolean transpose, Float32Array* v, GC3Dsizei requiredMinSize)4811 return validateUniformMatrixParameters(functionName, location, false, v->data(), v->length(), requiredMinSize); 4812 } 4813 4814 bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, void* v, GC3Dsizei size, GC3Dsizei requiredMinSize) 4815 { 4816 return validateUniformMatrixParameters(functionName, location, false, v, size, requiredMinSize); 4817 } 4818 4819 bool WebGLRenderingContext::validateUniformMatrixParameters(const char* functionName, const WebGLUniformLocation* location, GC3Dboolean transpose, Float32Array* v, GC3Dsizei requiredMinSize) 4816 4820 { 4817 4821 if (!v) { 4818 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4822 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no array"); 4819 4823 return false; 4820 4824 } 4821 return validateUniformMatrixParameters( location, transpose, v->data(), v->length(), requiredMinSize);4822 } 4823 4824 bool WebGLRenderingContext::validateUniformMatrixParameters(const WebGLUniformLocation* location, GC3Dboolean transpose, void* v, GC3Dsizei size, GC3Dsizei requiredMinSize)4825 return validateUniformMatrixParameters(functionName, location, transpose, v->data(), v->length(), requiredMinSize); 4826 } 4827 4828 bool WebGLRenderingContext::validateUniformMatrixParameters(const char* functionName, const WebGLUniformLocation* location, GC3Dboolean transpose, void* v, GC3Dsizei size, GC3Dsizei requiredMinSize) 4825 4829 { 4826 4830 if (!location) 4827 4831 return false; 4828 4832 if (location->program() != m_currentProgram) { 4829 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);4833 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "location is not from current program"); 4830 4834 return false; 4831 4835 } 4832 4836 if (!v) { 4833 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4837 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no array"); 4834 4838 return false; 4835 4839 } 4836 4840 if (transpose) { 4837 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4841 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "transpose not FALSE"); 4838 4842 return false; 4839 4843 } 4840 4844 if (size < requiredMinSize || (size % requiredMinSize)) { 4841 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4845 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "invalid size"); 4842 4846 return false; 4843 4847 } … … 4845 4849 } 4846 4850 4847 WebGLBuffer* WebGLRenderingContext::validateBufferDataParameters( GC3Denum target, GC3Denum usage)4851 WebGLBuffer* WebGLRenderingContext::validateBufferDataParameters(const char* functionName, GC3Denum target, GC3Denum usage) 4848 4852 { 4849 4853 WebGLBuffer* buffer = 0; … … 4856 4860 break; 4857 4861 default: 4858 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);4862 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid target"); 4859 4863 return 0; 4860 4864 } 4861 4865 if (!buffer) { 4862 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);4866 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "no buffer"); 4863 4867 return 0; 4864 4868 } … … 4869 4873 return buffer; 4870 4874 } 4871 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);4875 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid usage"); 4872 4876 return 0; 4873 4877 } 4874 4878 4875 bool WebGLRenderingContext::validateHTMLImageElement( HTMLImageElement* image)4879 bool WebGLRenderingContext::validateHTMLImageElement(const char* functionName, HTMLImageElement* image) 4876 4880 { 4877 4881 if (!image || !image->cachedImage()) { 4878 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4882 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no image"); 4879 4883 return false; 4880 4884 } 4881 4885 const KURL& url = image->cachedImage()->response().url(); 4882 4886 if (url.isNull() || url.isEmpty() || !url.isValid()) { 4883 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4887 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "invalid image"); 4884 4888 return false; 4885 4889 } … … 4887 4891 } 4888 4892 4889 void WebGLRenderingContext::vertexAttribfImpl( GC3Duint index, GC3Dsizei expectedSize, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfloat v3)4893 void WebGLRenderingContext::vertexAttribfImpl(const char* functionName, GC3Duint index, GC3Dsizei expectedSize, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfloat v3) 4890 4894 { 4891 4895 if (isContextLost()) 4892 4896 return; 4893 4897 if (index >= m_maxVertexAttribs) { 4894 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4898 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "index out of range"); 4895 4899 return; 4896 4900 } … … 4920 4924 } 4921 4925 4922 void WebGLRenderingContext::vertexAttribfvImpl( GC3Duint index, Float32Array* v, GC3Dsizei expectedSize)4926 void WebGLRenderingContext::vertexAttribfvImpl(const char* functionName, GC3Duint index, Float32Array* v, GC3Dsizei expectedSize) 4923 4927 { 4924 4928 if (isContextLost()) 4925 4929 return; 4926 4930 if (!v) { 4927 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4928 return; 4929 } 4930 vertexAttribfvImpl( index, v->data(), v->length(), expectedSize);4931 } 4932 4933 void WebGLRenderingContext::vertexAttribfvImpl( GC3Duint index, GC3Dfloat* v, GC3Dsizei size, GC3Dsizei expectedSize)4931 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no array"); 4932 return; 4933 } 4934 vertexAttribfvImpl(functionName, index, v->data(), v->length(), expectedSize); 4935 } 4936 4937 void WebGLRenderingContext::vertexAttribfvImpl(const char* functionName, GC3Duint index, GC3Dfloat* v, GC3Dsizei size, GC3Dsizei expectedSize) 4934 4938 { 4935 4939 if (isContextLost()) 4936 4940 return; 4937 4941 if (!v) { 4938 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4942 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no array"); 4939 4943 return; 4940 4944 } 4941 4945 if (size < expectedSize) { 4942 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4946 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "invalid size"); 4943 4947 return; 4944 4948 } 4945 4949 if (index >= m_maxVertexAttribs) { 4946 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);4950 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "index out of range"); 4947 4951 return; 4948 4952 } … … 5103 5107 else 5104 5108 // This likely shouldn't happen but is the best way to report it to the WebGL app. 5105 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);5109 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "", "error restoring context"); 5106 5110 return; 5107 5111 } … … 5156 5160 } 5157 5161 5162 namespace { 5163 5164 String GetErrorString(GC3Denum error) 5165 { 5166 switch (error) { 5167 case GraphicsContext3D::INVALID_ENUM: 5168 return "INVALID_ENUM"; 5169 case GraphicsContext3D::INVALID_VALUE: 5170 return "INVALID_VALUE"; 5171 case GraphicsContext3D::INVALID_OPERATION: 5172 return "INVALID_OPERATION"; 5173 case GraphicsContext3D::OUT_OF_MEMORY: 5174 return "OUT_OF_MEMORY"; 5175 case GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION: 5176 return "INVALID_FRAMEBUFFER_OPERATION"; 5177 case GraphicsContext3D::CONTEXT_LOST_WEBGL: 5178 return "CONTEXT_LOST_WEBGL"; 5179 default: 5180 return String::format("WebGL ERROR(%04x)", error); 5181 } 5182 } 5183 5184 } // namespace anonymous 5185 5186 void WebGLRenderingContext::synthesizeGLError(GC3Denum error, const char* functionName, const char* description) 5187 { 5188 if (m_synthesizedErrorsToConsole) { 5189 String str = String("WebGL: ") + GetErrorString(error) + ": " + String(functionName) + ": " + String(description); 5190 printWarningToConsole(str); 5191 } 5192 m_context->synthesizeGLError(error); 5193 } 5194 5195 5158 5196 } // namespace WebCore 5159 5197 -
trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h
r106320 r106421 366 366 bool validateRenderingState(int numElements); 367 367 368 bool validateWebGLObject( WebGLObject*);368 bool validateWebGLObject(const char*, WebGLObject*); 369 369 370 370 #if ENABLE(VIDEO) … … 492 492 bool m_isDepthStencilSupported; 493 493 494 bool m_synthesizedErrorsToConsole; 495 494 496 // Enabled extension objects. 495 497 OwnPtr<OESTextureFloat> m_oesTextureFloat; … … 548 550 549 551 // Helper function to verify limits on the length of uniform and attribute locations. 550 bool validateLocationLength(const String&);552 bool validateLocationLength(const char* functionName, const String&); 551 553 552 554 // Helper function to check if size is non-negative. 553 555 // Generate GL error and return false for negative inputs; otherwise, return true. 554 bool validateSize( GC3Dint x, GC3Dint y);556 bool validateSize(const char* functionName, GC3Dint x, GC3Dint y); 555 557 556 558 // Helper function to check if all characters in the string belong to the 557 559 // ASCII subset as defined in GLSL ES 1.0 spec section 3.1. 558 bool validateString(const String&);560 bool validateString(const char* functionName, const String&); 559 561 560 562 // Helper function to check target and texture bound to the target. 561 563 // Generate GL errors and return 0 if target is invalid or texture bound is 562 564 // null. Otherwise, return the texture bound to the target. 563 WebGLTexture* validateTextureBinding( GC3Denum target, bool useSixEnumsForCubeMap);565 WebGLTexture* validateTextureBinding(const char* functionName, GC3Denum target, bool useSixEnumsForCubeMap); 564 566 565 567 // Helper function to check input format/type for functions {copy}Tex{Sub}Image. 566 568 // Generates GL error and returns false if parameters are invalid. 567 bool validateTexFuncFormatAndType( GC3Denum format, GC3Denum type);569 bool validateTexFuncFormatAndType(const char* functionName, GC3Denum format, GC3Denum type); 568 570 569 571 // Helper function to check input level for functions {copy}Tex{Sub}Image. 570 572 // Generates GL error and returns false if level is invalid. 571 bool validateTexFuncLevel( GC3Denum target, GC3Dint level);573 bool validateTexFuncLevel(const char* functionName, GC3Denum target, GC3Dint level); 572 574 573 575 // Helper function to check input parameters for functions {copy}Tex{Sub}Image. 574 576 // Generates GL error and returns false if parameters are invalid. 575 bool validateTexFuncParameters(GC3Denum target, GC3Dint level, 577 bool validateTexFuncParameters(const char* functionName, 578 GC3Denum target, GC3Dint level, 576 579 GC3Denum internalformat, 577 580 GC3Dsizei width, GC3Dsizei height, GC3Dint border, … … 581 584 // is of the correct type and contains enough data for the texImage call. 582 585 // Generates GL error and returns false if parameters are invalid. 583 bool validateTexFuncData(GC3Dsizei width, GC3Dsizei height, 586 bool validateTexFuncData(const char* functionName, 587 GC3Dsizei width, GC3Dsizei height, 584 588 GC3Denum format, GC3Denum type, 585 589 ArrayBufferView* pixels); 586 590 587 591 // Helper function to validate mode for draw{Arrays/Elements}. 588 bool validateDrawMode( GC3Denum);592 bool validateDrawMode(const char* functionName, GC3Denum); 589 593 590 594 // Helper function to validate if front/back stencilMask and stencilFunc settings are the same. 591 bool validateStencilSettings( );595 bool validateStencilSettings(const char* functionName); 592 596 593 597 // Helper function to validate stencil func. 594 bool validateStencilFunc( GC3Denum);598 bool validateStencilFunc(const char* functionName, GC3Denum); 595 599 596 600 // Helper function for texParameterf and texParameteri. … … 603 607 // Helper function to validate input parameters for framebuffer functions. 604 608 // Generate GL error if parameters are illegal. 605 bool validateFramebufferFuncParameters( GC3Denum target, GC3Denum attachment);609 bool validateFramebufferFuncParameters(const char* functionName, GC3Denum target, GC3Denum attachment); 606 610 607 611 // Helper function to validate blend equation mode. 608 bool validateBlendEquation( GC3Denum);612 bool validateBlendEquation(const char* functionName, GC3Denum); 609 613 610 614 // Helper function to validate blend func factors. 611 bool validateBlendFuncFactors( GC3Denum src, GC3Denum dst);615 bool validateBlendFuncFactors(const char* functionName, GC3Denum src, GC3Denum dst); 612 616 613 617 // Helper function to validate a GL capability. 614 bool validateCapability( GC3Denum);618 bool validateCapability(const char* functionName, GC3Denum); 615 619 616 620 // Helper function to validate input parameters for uniform functions. 617 bool validateUniformParameters(const WebGLUniformLocation*, Float32Array*, GC3Dsizei mod);618 bool validateUniformParameters(const WebGLUniformLocation*, Int32Array*, GC3Dsizei mod);619 bool validateUniformParameters(const WebGLUniformLocation*, void*, GC3Dsizei size, GC3Dsizei mod);620 bool validateUniformMatrixParameters(const WebGLUniformLocation*, GC3Dboolean transpose, Float32Array*, GC3Dsizei mod);621 bool validateUniformMatrixParameters(const WebGLUniformLocation*, GC3Dboolean transpose, void*, GC3Dsizei size, GC3Dsizei mod);621 bool validateUniformParameters(const char* functionName, const WebGLUniformLocation*, Float32Array*, GC3Dsizei mod); 622 bool validateUniformParameters(const char* functionName, const WebGLUniformLocation*, Int32Array*, GC3Dsizei mod); 623 bool validateUniformParameters(const char* functionName, const WebGLUniformLocation*, void*, GC3Dsizei, GC3Dsizei mod); 624 bool validateUniformMatrixParameters(const char* functionName, const WebGLUniformLocation*, GC3Dboolean transpose, Float32Array*, GC3Dsizei mod); 625 bool validateUniformMatrixParameters(const char* functionName, const WebGLUniformLocation*, GC3Dboolean transpose, void*, GC3Dsizei, GC3Dsizei mod); 622 626 623 627 // Helper function to validate parameters for bufferData. 624 628 // Return the current bound buffer to target, or 0 if parameters are invalid. 625 WebGLBuffer* validateBufferDataParameters( GC3Denum target, GC3Denum usage);629 WebGLBuffer* validateBufferDataParameters(const char* functionName, GC3Denum target, GC3Denum usage); 626 630 627 631 // Helper function for tex{Sub}Image2D to make sure image is ready. 628 bool validateHTMLImageElement( HTMLImageElement*);632 bool validateHTMLImageElement(const char* functionName, HTMLImageElement*); 629 633 630 634 // Helper functions for vertexAttribNf{v}. 631 void vertexAttribfImpl( GC3Duint index, GC3Dsizei expectedSize, GC3Dfloat, GC3Dfloat, GC3Dfloat, GC3Dfloat);632 void vertexAttribfvImpl( GC3Duint index, Float32Array*, GC3Dsizei expectedSize);633 void vertexAttribfvImpl( GC3Duint index, GC3Dfloat*, GC3Dsizei size, GC3Dsizei expectedSize);635 void vertexAttribfImpl(const char* functionName, GC3Duint index, GC3Dsizei expectedSize, GC3Dfloat, GC3Dfloat, GC3Dfloat, GC3Dfloat); 636 void vertexAttribfvImpl(const char* functionName, GC3Duint index, Float32Array*, GC3Dsizei expectedSize); 637 void vertexAttribfvImpl(const char* functionName, GC3Duint index, GC3Dfloat*, GC3Dsizei, GC3Dsizei expectedSize); 634 638 635 639 // Helper function for delete* (deleteBuffer, deleteProgram, etc) functions. … … 640 644 // If the object has already been deleted, set deleted to true upon return. 641 645 // Return false if caller should return without further processing. 642 bool checkObjectToBeBound( WebGLObject*, bool& deleted);646 bool checkObjectToBeBound(const char* functionName, WebGLObject*, bool& deleted); 643 647 644 648 // Helpers for simulating vertexAttrib0 … … 655 659 bool allowPrivilegedExtensions() const; 656 660 661 // Wrapper for GraphicsContext3D::synthesizeGLError that sends a message 662 // to the JavaScript console. 663 void synthesizeGLError(GC3Denum, const char* functionName, const char* description); 664 657 665 friend class WebGLStateRestorer; 658 666 };
Note: See TracChangeset
for help on using the changeset viewer.