Changeset 106421 in webkit


Ignore:
Timestamp:
Jan 31, 2012 7:17:06 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Make WebGL put synthesized errors in the JS console
https://bugs.webkit.org/show_bug.cgi?id=77267

Patch by Gregg Tavares <gman@google.com> on 2012-01-31
Reviewed by Kenneth Russell.

No new functionality so no new tests.

  • html/canvas/WebGLCompressedTextures.cpp:

(WebCore::WebGLCompressedTextures::validateCompressedTexFuncData):
(WebCore::WebGLCompressedTextures::compressedTexImage2D):
(WebCore::WebGLCompressedTextures::compressedTexSubImage2D):

  • html/canvas/WebGLCompressedTextures.h:

(WebGLCompressedTextures):

  • html/canvas/WebGLDebugShaders.cpp:

(WebCore::WebGLDebugShaders::getTranslatedShaderSource):

  • html/canvas/WebGLRenderingContext.cpp:

(WebCore::WebGLRenderingContext::activeTexture):
(WebCore::WebGLRenderingContext::attachShader):
(WebCore::WebGLRenderingContext::bindAttribLocation):
(WebCore::WebGLRenderingContext::checkObjectToBeBound):
(WebCore::WebGLRenderingContext::bindBuffer):
(WebCore::WebGLRenderingContext::bindFramebuffer):
(WebCore::WebGLRenderingContext::bindRenderbuffer):
(WebCore::WebGLRenderingContext::bindTexture):
(WebCore::WebGLRenderingContext::blendEquation):
(WebCore::WebGLRenderingContext::blendEquationSeparate):
(WebCore::WebGLRenderingContext::blendFunc):
(WebCore::WebGLRenderingContext::blendFuncSeparate):
(WebCore::WebGLRenderingContext::bufferData):
(WebCore::WebGLRenderingContext::bufferSubData):
(WebCore::WebGLRenderingContext::checkFramebufferStatus):
(WebCore::WebGLRenderingContext::clear):
(WebCore::WebGLRenderingContext::compileShader):
(WebCore::WebGLRenderingContext::compressedTexImage2D):
(WebCore::WebGLRenderingContext::compressedTexSubImage2D):
(WebCore::WebGLRenderingContext::copyTexImage2D):
(WebCore::WebGLRenderingContext::copyTexSubImage2D):
(WebCore::WebGLRenderingContext::createShader):
(WebCore::WebGLRenderingContext::deleteObject):
(WebCore::WebGLRenderingContext::depthRange):
(WebCore::WebGLRenderingContext::detachShader):
(WebCore::WebGLRenderingContext::disable):
(WebCore::WebGLRenderingContext::disableVertexAttribArray):
(WebCore::WebGLRenderingContext::validateWebGLObject):
(WebCore::WebGLRenderingContext::drawArrays):
(WebCore::WebGLRenderingContext::drawElements):
(WebCore::WebGLRenderingContext::enable):
(WebCore::WebGLRenderingContext::enableVertexAttribArray):
(WebCore::WebGLRenderingContext::framebufferRenderbuffer):
(WebCore::WebGLRenderingContext::framebufferTexture2D):
(WebCore::WebGLRenderingContext::generateMipmap):
(WebCore::WebGLRenderingContext::getActiveAttrib):
(WebCore::WebGLRenderingContext::getActiveUniform):
(WebCore::WebGLRenderingContext::getAttachedShaders):
(WebCore::WebGLRenderingContext::getAttribLocation):
(WebCore::WebGLRenderingContext::getBufferParameter):
(WebCore::WebGLRenderingContext::getFramebufferAttachmentParameter):
(WebCore::WebGLRenderingContext::getParameter):
(WebCore::WebGLRenderingContext::getProgramParameter):
(WebCore::WebGLRenderingContext::getProgramInfoLog):
(WebCore::WebGLRenderingContext::getRenderbufferParameter):
(WebCore::WebGLRenderingContext::getShaderParameter):
(WebCore::WebGLRenderingContext::getShaderInfoLog):
(WebCore::WebGLRenderingContext::getShaderSource):
(WebCore::WebGLRenderingContext::getTexParameter):
(WebCore::WebGLRenderingContext::getUniform):
(WebCore::WebGLRenderingContext::getUniformLocation):
(WebCore::WebGLRenderingContext::getVertexAttrib):
(WebCore::WebGLRenderingContext::hint):
(WebCore::WebGLRenderingContext::isEnabled):
(WebCore::WebGLRenderingContext::linkProgram):
(WebCore::WebGLRenderingContext::pixelStorei):
(WebCore::WebGLRenderingContext::readPixels):
(WebCore::WebGLRenderingContext::renderbufferStorage):
(WebCore::WebGLRenderingContext::scissor):
(WebCore::WebGLRenderingContext::shaderSource):
(WebCore::WebGLRenderingContext::stencilFunc):
(WebCore::WebGLRenderingContext::stencilFuncSeparate):
(WebCore::WebGLRenderingContext::stencilMaskSeparate):
(WebCore::WebGLRenderingContext::texImage2DBase):
(WebCore::WebGLRenderingContext::texImage2DImpl):
(WebCore::WebGLRenderingContext::texImage2D):
(WebCore::WebGLRenderingContext::videoFrameToImage):
(WebCore::WebGLRenderingContext::texParameter):
(WebCore::WebGLRenderingContext::texSubImage2DBase):
(WebCore::WebGLRenderingContext::texSubImage2DImpl):
(WebCore::WebGLRenderingContext::texSubImage2D):
(WebCore::WebGLRenderingContext::uniform1f):
(WebCore::WebGLRenderingContext::uniform1fv):
(WebCore::WebGLRenderingContext::uniform1i):
(WebCore::WebGLRenderingContext::uniform1iv):
(WebCore::WebGLRenderingContext::uniform2f):
(WebCore::WebGLRenderingContext::uniform2fv):
(WebCore::WebGLRenderingContext::uniform2i):
(WebCore::WebGLRenderingContext::uniform2iv):
(WebCore::WebGLRenderingContext::uniform3f):
(WebCore::WebGLRenderingContext::uniform3fv):
(WebCore::WebGLRenderingContext::uniform3i):
(WebCore::WebGLRenderingContext::uniform3iv):
(WebCore::WebGLRenderingContext::uniform4f):
(WebCore::WebGLRenderingContext::uniform4fv):
(WebCore::WebGLRenderingContext::uniform4i):
(WebCore::WebGLRenderingContext::uniform4iv):
(WebCore::WebGLRenderingContext::uniformMatrix2fv):
(WebCore::WebGLRenderingContext::uniformMatrix3fv):
(WebCore::WebGLRenderingContext::uniformMatrix4fv):
(WebCore::WebGLRenderingContext::useProgram):
(WebCore::WebGLRenderingContext::validateProgram):
(WebCore::WebGLRenderingContext::vertexAttrib1f):
(WebCore::WebGLRenderingContext::vertexAttrib1fv):
(WebCore::WebGLRenderingContext::vertexAttrib2f):
(WebCore::WebGLRenderingContext::vertexAttrib2fv):
(WebCore::WebGLRenderingContext::vertexAttrib3f):
(WebCore::WebGLRenderingContext::vertexAttrib3fv):
(WebCore::WebGLRenderingContext::vertexAttrib4f):
(WebCore::WebGLRenderingContext::vertexAttrib4fv):
(WebCore::WebGLRenderingContext::vertexAttribPointer):
(WebCore::WebGLRenderingContext::viewport):
(WebCore::WebGLRenderingContext::forceLostContext):
(WebCore::WebGLRenderingContext::loseContextImpl):
(WebCore::WebGLRenderingContext::forceRestoreContext):
(WebCore::WebGLRenderingContext::validateTextureBinding):
(WebCore::WebGLRenderingContext::validateLocationLength):
(WebCore::WebGLRenderingContext::validateSize):
(WebCore::WebGLRenderingContext::validateString):
(WebCore::WebGLRenderingContext::validateTexFuncFormatAndType):
(WebCore::WebGLRenderingContext::validateTexFuncLevel):
(WebCore::WebGLRenderingContext::validateTexFuncParameters):
(WebCore::WebGLRenderingContext::validateTexFuncData):
(WebCore::WebGLRenderingContext::validateDrawMode):
(WebCore::WebGLRenderingContext::validateStencilSettings):
(WebCore::WebGLRenderingContext::validateStencilFunc):
(WebCore::WebGLRenderingContext::validateFramebufferFuncParameters):
(WebCore::WebGLRenderingContext::validateBlendEquation):
(WebCore::WebGLRenderingContext::validateBlendFuncFactors):
(WebCore::WebGLRenderingContext::validateCapability):
(WebCore::WebGLRenderingContext::validateUniformParameters):
(WebCore::WebGLRenderingContext::validateUniformMatrixParameters):
(WebCore::WebGLRenderingContext::validateBufferDataParameters):
(WebCore::WebGLRenderingContext::validateHTMLImageElement):
(WebCore::WebGLRenderingContext::vertexAttribfImpl):
(WebCore::WebGLRenderingContext::vertexAttribfvImpl):
(WebCore::WebGLRenderingContext::maybeRestoreContext):
(WebCore):
(WebCore::WebGLRenderingContext::synthesizeGLError):

  • html/canvas/WebGLRenderingContext.h:

(WebGLRenderingContext):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r106420 r106421  
     12012-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
    11512012-01-31  Raymond Liu  <raymond.liu@intel.com>
    2152
  • trunk/Source/WebCore/html/canvas/WebGLCompressedTextures.cpp

    r101578 r106421  
    126126}
    127127
    128 bool WebGLCompressedTextures::validateCompressedTexFuncData(GC3Dsizei width, GC3Dsizei height,
    129                                                                         GC3Denum format, ArrayBufferView* pixels)
    130 {
    131     GraphicsContext3D* context = m_context->graphicsContext3D();
     128bool WebGLCompressedTextures::validateCompressedTexFuncData(const char* functionName,
     129                                                            GC3Dsizei width, GC3Dsizei height,
     130                                                            GC3Denum format, ArrayBufferView* pixels)
     131{
    132132    if (!pixels) {
    133         context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     133        m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no pixels");
    134134        return false;
    135135    }
    136136    if (width < 0 || height < 0) {
    137         context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     137        m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "width or height < 0");
    138138        return false;
    139139    }
     
    173173        break;
    174174    default:
    175         context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     175        m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid format");
    176176        return false;
    177177    }
    178178
    179179    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");
    181181        return false;
    182182    }
     
    230230                                                               GC3Dsizei height, GC3Dint border, ArrayBufferView* data)
    231231{
    232     GraphicsContext3D* context = m_context->graphicsContext3D();
    233232    if (m_context->isContextLost())
    234233        return;
    235234    if (!validateCompressedTexFormat(internalformat)) {
    236         context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     235        m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexImage2D", "invalid internalformat");
    237236        return;
    238237    }
    239238    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);
    246245    if (!tex)
    247246        return;
    248247    if (!m_context->isGLES2NPOTStrict()) {
    249248        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");
    251250            return;
    252251        }
    253252    }
    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());
    256255    tex->setLevelInfo(target, level, internalformat, width, height, GraphicsContext3D::UNSIGNED_BYTE);
    257256    m_context->cleanupAfterGraphicsCall(false);
     
    261260                                                                  GC3Dsizei width, GC3Dsizei height, GC3Denum format, ArrayBufferView* data)
    262261{
    263     GraphicsContext3D* context = m_context->graphicsContext3D();
    264262    if (m_context->isContextLost())
    265263        return;
    266264    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);
    274272    if (!tex)
    275273        return;
    276274
    277275    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");
    279277        return;
    280278    }
    281279
    282280    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());
    289287    m_context->cleanupAfterGraphicsCall(false);
    290288}
  • trunk/Source/WebCore/html/canvas/WebGLCompressedTextures.h

    r101578 r106421  
    5555    WebGLCompressedTextures(WebGLRenderingContext*);
    5656
    57     bool validateCompressedTexFuncData(GC3Dsizei width, GC3Dsizei height,
     57    bool validateCompressedTexFuncData(const char* functionName,
     58                                       GC3Dsizei width, GC3Dsizei height,
    5859                                       GC3Denum format, ArrayBufferView* pixels);
    5960
  • trunk/Source/WebCore/html/canvas/WebGLDebugShaders.cpp

    r97896 r106421  
    6262    if (m_context->isContextLost())
    6363        return String();
    64     if (!m_context->validateWebGLObject(shader))
     64    if (!m_context->validateWebGLObject("getTranslatedShaderSource", shader))
    6565        return "";
    6666    return m_context->graphicsContext3D()->getExtensions()->getTranslatedShaderSourceANGLE(shader->object());
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp

    r106320 r106421  
    425425    , m_contextLostMode(SyntheticLostContext)
    426426    , m_attributes(attributes)
     427    , m_synthesizedErrorsToConsole(false)
    427428{
    428429    ASSERT(m_context);
     
    787788        return;
    788789    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");
    790791        return;
    791792    }
     
    802803{
    803804    UNUSED_PARAM(ec);
    804     if (isContextLost() || !validateWebGLObject(program) || !validateWebGLObject(shader))
     805    if (isContextLost() || !validateWebGLObject("attachShader", program) || !validateWebGLObject("attachShader", shader))
    805806        return;
    806807    if (!program->attachShader(shader)) {
    807         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     808        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "attachShader", "shader attachment already has shader");
    808809        return;
    809810    }
     
    816817{
    817818    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))
    823824        return;
    824825    m_context->bindAttribLocation(objectOrZero(program), index, name);
     
    826827}
    827828
    828 bool WebGLRenderingContext::checkObjectToBeBound(WebGLObject* object, bool& deleted)
     829bool WebGLRenderingContext::checkObjectToBeBound(const char* functionName, WebGLObject* object, bool& deleted)
    829830{
    830831    deleted = false;
     
    833834    if (object) {
    834835        if (!object->validate(contextGroup(), this)) {
    835             m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     836            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "object not from this context");
    836837            return false;
    837838        }
     
    845846    UNUSED_PARAM(ec);
    846847    bool deleted;
    847     if (!checkObjectToBeBound(buffer, deleted))
     848    if (!checkObjectToBeBound("bindBuffer", buffer, deleted))
    848849        return;
    849850    if (deleted)
    850851        buffer = 0;
    851852    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");
    853854        return;
    854855    }
     
    858859        m_boundVertexArrayObject->setElementArrayBuffer(buffer);
    859860    else {
    860         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     861        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindBuffer", "invalid target");
    861862        return;
    862863    }
     
    872873    UNUSED_PARAM(ec);
    873874    bool deleted;
    874     if (!checkObjectToBeBound(buffer, deleted))
     875    if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted))
    875876        return;
    876877    if (deleted)
    877878        buffer = 0;
    878879    if (target != GraphicsContext3D::FRAMEBUFFER) {
    879         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     880        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindFramebuffer", "invalid target");
    880881        return;
    881882    }
     
    895896    UNUSED_PARAM(ec);
    896897    bool deleted;
    897     if (!checkObjectToBeBound(renderBuffer, deleted))
     898    if (!checkObjectToBeBound("bindRenderbuffer", renderBuffer, deleted))
    898899        return;
    899900    if (deleted)
    900901        renderBuffer = 0;
    901902    if (target != GraphicsContext3D::RENDERBUFFER) {
    902         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     903        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindRenderbuffer", "invalid target");
    903904        return;
    904905    }
     
    914915    UNUSED_PARAM(ec);
    915916    bool deleted;
    916     if (!checkObjectToBeBound(texture, deleted))
     917    if (!checkObjectToBeBound("bindTexture", texture, deleted))
    917918        return;
    918919    if (deleted)
    919920        texture = 0;
    920921    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");
    922923        return;
    923924    }
     
    934935        maxLevel = m_maxCubeMapTextureLevel;
    935936    } else {
    936         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     937        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindTexture", "invalid target");
    937938        return;
    938939    }
     
    963964void WebGLRenderingContext::blendEquation(GC3Denum mode)
    964965{
    965     if (isContextLost() || !validateBlendEquation(mode))
     966    if (isContextLost() || !validateBlendEquation("blendEquation", mode))
    966967        return;
    967968    m_context->blendEquation(mode);
     
    971972void WebGLRenderingContext::blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha)
    972973{
    973     if (isContextLost() || !validateBlendEquation(modeRGB) || !validateBlendEquation(modeAlpha))
     974    if (isContextLost() || !validateBlendEquation("blendEquation", modeRGB) || !validateBlendEquation("blendEquation", modeAlpha))
    974975        return;
    975976    m_context->blendEquationSeparate(modeRGB, modeAlpha);
     
    980981void WebGLRenderingContext::blendFunc(GC3Denum sfactor, GC3Denum dfactor)
    981982{
    982     if (isContextLost() || !validateBlendFuncFactors(sfactor, dfactor))
     983    if (isContextLost() || !validateBlendFuncFactors("blendFunc", sfactor, dfactor))
    983984        return;
    984985    m_context->blendFunc(sfactor, dfactor);
     
    988989void WebGLRenderingContext::blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha)
    989990{
    990     if (isContextLost() || !validateBlendFuncFactors(srcRGB, dstRGB))
     991    // Note: Alpha does not have the same restrictions as RGB.
     992    if (isContextLost() || !validateBlendFuncFactors("blendFunc", srcRGB, dstRGB))
    991993        return;
    992994    m_context->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
     
    9991001    if (isContextLost())
    10001002        return;
    1001     WebGLBuffer* buffer = validateBufferDataParameters(target, usage);
     1003    WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usage);
    10021004    if (!buffer)
    10031005        return;
    10041006    if (size < 0) {
    1005         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     1007        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "size < 0");
    10061008        return;
    10071009    }
    10081010    if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
    10091011        if (!buffer->associateBufferData(size)) {
    1010             m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     1012            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "invalid buffer");
    10111013            return;
    10121014        }
     
    10221024    if (isContextLost())
    10231025        return;
    1024     WebGLBuffer* buffer = validateBufferDataParameters(target, usage);
     1026    WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usage);
    10251027    if (!buffer)
    10261028        return;
    10271029    if (!data) {
    1028         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     1030        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "no data");
    10291031        return;
    10301032    }
    10311033    if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
    10321034        if (!buffer->associateBufferData(data)) {
    1033             m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     1035            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "invalid buffer");
    10341036            return;
    10351037        }
     
    10451047    if (isContextLost())
    10461048        return;
    1047     WebGLBuffer* buffer = validateBufferDataParameters(target, usage);
     1049    WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usage);
    10481050    if (!buffer)
    10491051        return;
    10501052    if (!data) {
    1051         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     1053        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "no data");
    10521054        return;
    10531055    }
    10541056    if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
    10551057        if (!buffer->associateBufferData(data)) {
    1056             m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     1058            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "invalid buffer");
    10571059            return;
    10581060        }
     
    10681070    if (isContextLost())
    10691071        return;
    1070     WebGLBuffer* buffer = validateBufferDataParameters(target, GraphicsContext3D::STATIC_DRAW);
     1072    WebGLBuffer* buffer = validateBufferDataParameters("bufferSubData", target, GraphicsContext3D::STATIC_DRAW);
    10711073    if (!buffer)
    10721074        return;
    10731075    if (offset < 0) {
    1074         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     1076        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferSubData", "offset < 0");
    10751077        return;
    10761078    }
     
    10791081    if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
    10801082        if (!buffer->associateBufferSubData(offset, data)) {
    1081             m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     1083            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferSubData", "offset out of range");
    10821084            return;
    10831085        }
     
    10931095    if (isContextLost())
    10941096        return;
    1095     WebGLBuffer* buffer = validateBufferDataParameters(target, GraphicsContext3D::STATIC_DRAW);
     1097    WebGLBuffer* buffer = validateBufferDataParameters("bufferSubData", target, GraphicsContext3D::STATIC_DRAW);
    10961098    if (!buffer)
    10971099        return;
    10981100    if (offset < 0) {
    1099         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     1101        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferSubData", "offset < 0");
    11001102        return;
    11011103    }
     
    11041106    if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
    11051107        if (!buffer->associateBufferSubData(offset, data)) {
    1106             m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     1108            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferSubData", "offset out of range");
    11071109            return;
    11081110        }
     
    11181120        return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED;
    11191121    if (target != GraphicsContext3D::FRAMEBUFFER) {
    1120         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     1122        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "checkFramebufferStatus", "invalid target");
    11211123        return 0;
    11221124    }
     
    11361138        return;
    11371139    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");
    11391141        return;
    11401142    }
    11411143    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");
    11431145        return;
    11441146    }
     
    12011203{
    12021204    UNUSED_PARAM(ec);
    1203     if (isContextLost() || !validateWebGLObject(shader))
     1205    if (isContextLost() || !validateWebGLObject("compileShader", shader))
    12041206        return;
    12051207    m_context->compileShader(objectOrZero(shader));
     
    12141216
    12151217    // FIXME: implement this.
    1216     m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     1218    synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexImage2D", "invalid internalformat");
    12171219}
    12181220
     
    12241226
    12251227    // FIXME: implement this.
    1226     m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     1228    synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexSubImage2D", "invalid format");
    12271229}
    12281230
     
    12311233    if (isContextLost())
    12321234        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);
    12361238    if (!tex)
    12371239        return;
    12381240    if (!isTexInternalFormatColorBufferCombinationValid(internalformat, getBoundFramebufferColorFormat())) {
    1239         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     1241        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "copyTexImage2D", "framebuffer is incompatible format");
    12401242        return;
    12411243    }
    12421244    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");
    12441246        return;
    12451247    }
    12461248    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");
    12481250        return;
    12491251    }
     
    12751277    if (isContextLost())
    12761278        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);
    12801282    if (!tex)
    12811283        return;
    1282     if (!validateSize(xoffset, yoffset) || !validateSize(width, height))
     1284    if (!validateSize("copyTexSubImage2D", xoffset, yoffset) || !validateSize("copyTexSubImage2D", width, height))
    12831285        return;
    12841286    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");
    12861288        return;
    12871289    }
    12881290    if (!isTexInternalFormatColorBufferCombinationValid(tex->getInternalFormat(target, level), getBoundFramebufferColorFormat())) {
    1289         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     1291        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "copyTexSubImage2D", "framebuffer is incompatible format");
    12901292        return;
    12911293    }
    12921294    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");
    12941296        return;
    12951297    }
     
    13091311                GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, height, m_unpackAlignment, &size, 0);
    13101312                if (error != GraphicsContext3D::NO_ERROR) {
    1311                     m_context->synthesizeGLError(error);
     1313                    synthesizeGLError(error, "copyTexSubImage2D", "bad dimensions");
    13121314                    return;
    13131315                }
    13141316                zero = adoptArrayPtr(new unsigned char[size]);
    13151317                if (!zero) {
    1316                     m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     1318                    synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexSubImage2D", "out of memory");
    13171319                    return;
    13181320                }
     
    13841386        return 0;
    13851387    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");
    13871389        return 0;
    13881390    }
     
    14061408        return false;
    14071409    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");
    14091411        return false;
    14101412    }
     
    15121514        return;
    15131515    if (zNear > zFar) {
    1514         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     1516        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "depthRange", "zNear > zFar");
    15151517        return;
    15161518    }
     
    15221524{
    15231525    UNUSED_PARAM(ec);
    1524     if (isContextLost() || !validateWebGLObject(program) || !validateWebGLObject(shader))
     1526    if (isContextLost() || !validateWebGLObject("detachShader", program) || !validateWebGLObject("detachShader", shader))
    15251527        return;
    15261528    if (!program->detachShader(shader)) {
    1527         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     1529        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "detachShader", "shader not attached");
    15281530        return;
    15291531    }
     
    15351537void WebGLRenderingContext::disable(GC3Denum cap)
    15361538{
    1537     if (isContextLost() || !validateCapability(cap))
     1539    if (isContextLost() || !validateCapability("disable", cap))
    15381540        return;
    15391541    if (cap == GraphicsContext3D::SCISSOR_TEST) {
     
    15521554        return;
    15531555    if (index >= m_maxVertexAttribs) {
    1554         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     1556        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "disableVertexAttribArray", "index out of range");
    15551557        return;
    15561558    }
     
    17351737}
    17361738
    1737 bool WebGLRenderingContext::validateWebGLObject(WebGLObject* object)
     1739bool WebGLRenderingContext::validateWebGLObject(const char* functionName, WebGLObject* object)
    17381740{
    17391741    if (!object || !object->object()) {
    1740         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     1742        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no object or object deleted");
    17411743        return false;
    17421744    }
    17431745    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");
    17451747        return false;
    17461748    }
     
    17521754    UNUSED_PARAM(ec);
    17531755
    1754     if (isContextLost() || !validateDrawMode(mode))
    1755         return;
    1756 
    1757     if (!validateStencilSettings())
     1756    if (isContextLost() || !validateDrawMode("drawArrays", mode))
     1757        return;
     1758
     1759    if (!validateStencilSettings("drawArrays"))
    17581760        return;
    17591761
    17601762    if (first < 0 || count < 0) {
    1761         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     1763        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "drawArrays", "first or count < 0");
    17621764        return;
    17631765    }
     
    17721774        CheckedInt<GC3Dint> checkedSum = checkedFirst + checkedCount;
    17731775        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");
    17751777            return;
    17761778        }
    17771779    } else {
    17781780        if (!validateRenderingState(0)) {
    1779             m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     1781            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "drawArrays", "attribs not setup correctly");
    17801782            return;
    17811783        }
     
    17831785
    17841786    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");
    17861788        return;
    17871789    }
     
    18061808    UNUSED_PARAM(ec);
    18071809
    1808     if (isContextLost() || !validateDrawMode(mode))
    1809         return;
    1810 
    1811     if (!validateStencilSettings())
     1810    if (isContextLost() || !validateDrawMode("drawElements", mode))
     1811        return;
     1812
     1813    if (!validateStencilSettings("drawElements"))
    18121814        return;
    18131815
     
    18171819        break;
    18181820    default:
    1819         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     1821        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "drawElements", "invalid type");
    18201822        return;
    18211823    }
    18221824
    18231825    if (count < 0 || offset < 0) {
    1824         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     1826        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "drawElements", "count or offset < 0");
    18251827        return;
    18261828    }
     
    18301832
    18311833    if (!m_boundVertexArrayObject->getElementArrayBuffer()) {
    1832         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     1834        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "drawElements", "no ELEMENT_ARRAY_BUFFER bound");
    18331835        return;
    18341836    }
     
    18381840        // Ensure we have a valid rendering state
    18391841        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");
    18411843            return;
    18421844        }
     
    18451847        if (!validateIndexArrayConservative(type, numElements) || !validateRenderingState(numElements)) {
    18461848            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");
    18481850                return;
    18491851            }
     
    18511853    } else {
    18521854        if (!validateRenderingState(0)) {
    1853             m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     1855            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "drawElements", "attribs not setup correctly");
    18541856            return;
    18551857        }
     
    18571859
    18581860    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");
    18601862        return;
    18611863    }
     
    18801882void WebGLRenderingContext::enable(GC3Denum cap)
    18811883{
    1882     if (isContextLost() || !validateCapability(cap))
     1884    if (isContextLost() || !validateCapability("enable", cap))
    18831885        return;
    18841886    if (cap == GraphicsContext3D::SCISSOR_TEST) {
     
    18971899        return;
    18981900    if (index >= m_maxVertexAttribs) {
    1899         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     1901        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "enableVertexAttribArray", "index out of range");
    19001902        return;
    19011903    }
     
    19271929{
    19281930    UNUSED_PARAM(ec);
    1929     if (isContextLost() || !validateFramebufferFuncParameters(target, attachment))
     1931    if (isContextLost() || !validateFramebufferFuncParameters("framebufferRenderbuffer", target, attachment))
    19301932        return;
    19311933    if (renderbuffertarget != GraphicsContext3D::RENDERBUFFER) {
    1932         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     1934        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "framebufferRenderbuffer", "invalid target");
    19331935        return;
    19341936    }
    19351937    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");
    19371939        return;
    19381940    }
     
    19411943    // FBO.
    19421944    if (!m_framebufferBinding || !m_framebufferBinding->object()) {
    1943         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     1945        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferRenderbuffer", "no framebuffer bound");
    19441946        return;
    19451947    }
     
    19982000{
    19992001    UNUSED_PARAM(ec);
    2000     if (isContextLost() || !validateFramebufferFuncParameters(target, attachment))
     2002    if (isContextLost() || !validateFramebufferFuncParameters("framebufferTexture2D", target, attachment))
    20012003        return;
    20022004    if (level) {
    2003         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     2005        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "framebufferTexture2D", "level not 0");
    20042006        return;
    20052007    }
    20062008    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");
    20082010        return;
    20092011    }
     
    20122014    // FBO.
    20132015    if (!m_framebufferBinding || !m_framebufferBinding->object()) {
    2014         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     2016        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferTexture2D", "no framebuffer bound");
    20152017        return;
    20162018    }
     
    20322034    if (isContextLost())
    20332035        return;
    2034     WebGLTexture* tex = validateTextureBinding(target, false);
     2036    WebGLTexture* tex = validateTextureBinding("generateMipmap", target, false);
    20352037    if (!tex)
    20362038        return;
    20372039    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");
    20392041        return;
    20402042    }
     
    20602062{
    20612063    UNUSED_PARAM(ec);
    2062     if (isContextLost() || !validateWebGLObject(program))
     2064    if (isContextLost() || !validateWebGLObject("getActiveAttrib", program))
    20632065        return 0;
    20642066    ActiveInfo info;
     
    20712073{
    20722074    UNUSED_PARAM(ec);
    2073     if (isContextLost() || !validateWebGLObject(program))
     2075    if (isContextLost() || !validateWebGLObject("getActiveUniform", program))
    20742076        return 0;
    20752077    ActiveInfo info;
     
    20862088    UNUSED_PARAM(ec);
    20872089    shaderObjects.clear();
    2088     if (isContextLost() || !validateWebGLObject(program))
     2090    if (isContextLost() || !validateWebGLObject("getAttachedShaders", program))
    20892091        return false;
    20902092
     
    21052107    if (isContextLost())
    21062108        return -1;
    2107     if (!validateLocationLength(name))
     2109    if (!validateLocationLength("getAttribLocation", name))
    21082110        return -1;
    2109     if (!validateString(name))
     2111    if (!validateString("getAttribLocation", name))
    21102112        return -1;
    21112113    return m_context->getAttribLocation(objectOrZero(program), name);
     
    21182120        return WebGLGetInfo();
    21192121    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");
    21212123        return WebGLGetInfo();
    21222124    }
    21232125
    21242126    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");
    21262128        return WebGLGetInfo();
    21272129    }
     
    22122214{
    22132215    UNUSED_PARAM(ec);
    2214     if (isContextLost() || !validateFramebufferFuncParameters(target, attachment))
     2216    if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAttachmentParameter", target, attachment))
    22152217        return WebGLGetInfo();
    22162218
    22172219    if (!m_framebufferBinding || !m_framebufferBinding->object()) {
    2218         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     2220        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getFramebufferAttachmentParameter", "no framebuffer bound");
    22192221        return WebGLGetInfo();
    22202222    }
     
    22262228        // OpenGL ES 2.0 specifies INVALID_ENUM in this case, while desktop GL
    22272229        // specifies INVALID_OPERATION.
    2228         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     2230        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getFramebufferAttachmentParameter", "invalid parameter name");
    22292231        return WebGLGetInfo();
    22302232    }
     
    22462248            }
    22472249        default:
    2248             m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     2250            synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getFramebufferAttachmentParameter", "invalid parameter name for texture attachment");
    22492251            return WebGLGetInfo();
    22502252        }
     
    22562258            return WebGLGetInfo(PassRefPtr<WebGLRenderbuffer>(reinterpret_cast<WebGLRenderbuffer*>(object)));
    22572259        default:
    2258             m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     2260            synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getFramebufferAttachmentParameter", "invalid parameter name for renderbuffer attachment");
    22592261            return WebGLGetInfo();
    22602262        }
     
    24512453        if (m_oesStandardDerivatives)
    24522454            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");
    24542456        return WebGLGetInfo();
    24552457    case WebGLDebugRendererInfo::UNMASKED_RENDERER_WEBGL:
    24562458        if (m_webglDebugRendererInfo)
    24572459            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");
    24592461        return WebGLGetInfo();
    24602462    case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL:
    24612463        if (m_webglDebugRendererInfo)
    24622464            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");
    24642466        return WebGLGetInfo();
    24652467    case Extensions3D::VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object
     
    24692471            return WebGLGetInfo();
    24702472        }
    2471         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     2473        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "invalid parameter name, OES_vertex_array_object not enabled");
    24722474        return WebGLGetInfo();
    24732475    default:
    2474         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     2476        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "invalid parameter name");
    24752477        return WebGLGetInfo();
    24762478    }
     
    24802482{
    24812483    UNUSED_PARAM(ec);
    2482     if (isContextLost() || !validateWebGLObject(program))
     2484    if (isContextLost() || !validateWebGLObject("getProgramParameter", program))
    24832485        return WebGLGetInfo();
    24842486
     
    24992501        return WebGLGetInfo(value);
    25002502    default:
    2501         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     2503        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getProgramParameter", "invalid parameter name");
    25022504        return WebGLGetInfo();
    25032505    }
     
    25092511    if (isContextLost())
    25102512        return String();
    2511     if (!validateWebGLObject(program))
     2513    if (!validateWebGLObject("getProgramInfoLog", program))
    25122514        return "";
    25132515    WebGLStateRestorer(this, false);
     
    25212523        return WebGLGetInfo();
    25222524    if (target != GraphicsContext3D::RENDERBUFFER) {
    2523         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     2525        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParameter", "invalid target");
    25242526        return WebGLGetInfo();
    25252527    }
    25262528    if (!m_renderbufferBinding || !m_renderbufferBinding->object()) {
    2527         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     2529        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getRenderbufferParameter", "no renderbuffer bound");
    25282530        return WebGLGetInfo();
    25292531    }
     
    25552557            return WebGLGetInfo(m_renderbufferBinding->getInternalFormat());
    25562558        default:
    2557             m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     2559            synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParameter", "invalid parameter name");
    25582560            return WebGLGetInfo();
    25592561        }
     
    25772579        return WebGLGetInfo(m_renderbufferBinding->getInternalFormat());
    25782580    default:
    2579         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     2581        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParameter", "invalid parameter name");
    25802582        return WebGLGetInfo();
    25812583    }
     
    25852587{
    25862588    UNUSED_PARAM(ec);
    2587     if (isContextLost() || !validateWebGLObject(shader))
     2589    if (isContextLost() || !validateWebGLObject("getShaderParameter", shader))
    25882590        return WebGLGetInfo();
    25892591    WebGLStateRestorer(this, false);
     
    25992601        return WebGLGetInfo(static_cast<unsigned int>(value));
    26002602    default:
    2601         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     2603        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderParameter", "invalid parameter name");
    26022604        return WebGLGetInfo();
    26032605    }
     
    26092611    if (isContextLost())
    26102612        return String();
    2611     if (!validateWebGLObject(shader))
     2613    if (!validateWebGLObject("getShaderInfoLog", shader))
    26122614        return "";
    26132615    WebGLStateRestorer(this, false);
     
    26202622    if (isContextLost())
    26212623        return String();
    2622     if (!validateWebGLObject(shader))
     2624    if (!validateWebGLObject("getShaderSource", shader))
    26232625        return "";
    26242626    return shader->getSource();
     
    26522654    if (isContextLost())
    26532655        return WebGLGetInfo();
    2654     WebGLTexture* tex = validateTextureBinding(target, false);
     2656    WebGLTexture* tex = validateTextureBinding("getTexParameter", target, false);
    26552657    if (!tex)
    26562658        return WebGLGetInfo();
     
    26652667        return WebGLGetInfo(static_cast<unsigned int>(value));
    26662668    default:
    2667         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     2669        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getTexParameter", "invalid parameter name");
    26682670        return WebGLGetInfo();
    26692671    }
     
    26732675{
    26742676    UNUSED_PARAM(ec);
    2675     if (isContextLost() || !validateWebGLObject(program))
     2677    if (isContextLost() || !validateWebGLObject("getUniform", program))
    26762678        return WebGLGetInfo();
    26772679    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");
    26792681        return WebGLGetInfo();
    26802682    }
     
    27742776                default:
    27752777                    // Can't handle this type
    2776                     m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     2778                    synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "getUniform", "unhandled type");
    27772779                    return WebGLGetInfo();
    27782780                }
     
    28102812    }
    28112813    // 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");
    28132815    return WebGLGetInfo();
    28142816}
     
    28172819{
    28182820    UNUSED_PARAM(ec);
    2819     if (isContextLost() || !validateWebGLObject(program))
     2821    if (isContextLost() || !validateWebGLObject("getUniformLocation", program))
    28202822        return 0;
    2821     if (!validateLocationLength(name))
     2823    if (!validateLocationLength("getUniformLocation", name))
    28222824        return 0;
    2823     if (!validateString(name))
     2825    if (!validateString("getUniformLocation", name))
    28242826        return 0;
    28252827    WebGLStateRestorer(this, false);
     
    28372839    WebGLStateRestorer(this, false);
    28382840    if (index >= m_maxVertexAttribs) {
    2839         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     2841        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "getVertexAttrib", "index out of range");
    28402842        return WebGLGetInfo();
    28412843    }
     
    28612863        return WebGLGetInfo(Float32Array::create(m_vertexAttribValue[index].value, 4));
    28622864    default:
    2863         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     2865        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getVertexAttrib", "invalid parameter name");
    28642866        return WebGLGetInfo();
    28652867    }
     
    28902892    }
    28912893    if (!isValid) {
    2892         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     2894        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "hint", "invalid target");
    28932895        return;
    28942896    }
     
    29152917GC3Dboolean WebGLRenderingContext::isEnabled(GC3Denum cap)
    29162918{
    2917     if (!validateCapability(cap) || isContextLost())
     2919    if (isContextLost() || !validateCapability("isEnabled", cap))
    29182920        return 0;
    29192921    return m_context->isEnabled(cap);
     
    29802982{
    29812983    UNUSED_PARAM(ec);
    2982     if (isContextLost() || !validateWebGLObject(program))
     2984    if (isContextLost() || !validateWebGLObject("linkProgram", program))
    29832985        return;
    29842986    if (!isGLES2Compliant()) {
     
    30153017            m_unpackColorspaceConversion = static_cast<GC3Denum>(param);
    30163018        else {
    3017             m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     3019            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "pixelStorei", "invalid parameter for UNPACK_COLORSPACE_CONVERSION_WEBGL");
    30183020            return;
    30193021        }
     
    30293031            cleanupAfterGraphicsCall(false);
    30303032        } else {
    3031             m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     3033            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "pixelStorei", "invalid parameter for alignment");
    30323034            return;
    30333035        }
    30343036        break;
    30353037    default:
    3036         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     3038        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "pixelStorei", "invalid parameter name");
    30373039        return;
    30383040    }
     
    30563058    // Validate input parameters.
    30573059    if (!pixels) {
    3058         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     3060        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "readPixels", "no destination ArrayBufferView");
    30593061        return;
    30603062    }
     
    30653067        break;
    30663068    default:
    3067         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     3069        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "readPixels", "invalid format");
    30683070        return;
    30693071    }
     
    30753077        break;
    30763078    default:
    3077         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     3079        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "readPixels", "invalid type");
    30783080        return;
    30793081    }
    30803082    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");
    30823084        return;
    30833085    }
    30843086    // Validate array type against pixel type.
    30853087    if (!pixels->isUnsignedByteArray()) {
    3086         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     3088        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "ArrayBufferView not Uint8Array");
    30873089        return;
    30883090    }
    30893091    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");
    30913093        return;
    30923094    }
     
    30963098    GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, height, m_packAlignment, &totalBytesRequired, &padding);
    30973099    if (error != GraphicsContext3D::NO_ERROR) {
    3098         m_context->synthesizeGLError(error);
     3100        synthesizeGLError(error, "readPixels", "invalid dimensions");
    30993101        return;
    31003102    }
    31013103    if (pixels->byteLength() < totalBytesRequired) {
    3102         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     3104        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "ArrayBufferView not large enough for dimensions");
    31033105        return;
    31043106    }
     
    31413143        return;
    31423144    if (target != GraphicsContext3D::RENDERBUFFER) {
    3143         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     3145        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "renderbufferStorage", "invalid target");
    31443146        return;
    31453147    }
    31463148    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))
    31513153        return;
    31523154    switch (internalformat) {
     
    31723174        break;
    31733175    default:
    3174         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     3176        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "renderbufferStorage", "invalid internalformat");
    31753177    }
    31763178}
     
    31883190    if (isContextLost())
    31893191        return;
    3190     if (!validateSize(width, height))
     3192    if (!validateSize("scissor", width, height))
    31913193        return;
    31923194    m_context->scissor(x, y, width, height);
     
    31973199{
    31983200    UNUSED_PARAM(ec);
    3199     if (isContextLost() || !validateWebGLObject(shader))
     3201    if (isContextLost() || !validateWebGLObject("shaderSource", shader))
    32003202        return;
    32013203    String stringWithoutComments = StripComments(string).result();
    3202     if (!validateString(stringWithoutComments))
     3204    if (!validateString("shaderSource", stringWithoutComments))
    32033205        return;
    32043206    shader->setSource(string);
     
    32113213    if (isContextLost())
    32123214        return;
    3213     if (!validateStencilFunc(func))
     3215    if (!validateStencilFunc("stencilFunc", func))
    32143216        return;
    32153217    m_stencilFuncRef = ref;
     
    32253227    if (isContextLost())
    32263228        return;
    3227     if (!validateStencilFunc(func))
     3229    if (!validateStencilFunc("stencilFuncSeparate", func))
    32283230        return;
    32293231    switch (face) {
     
    32433245        break;
    32443246    default:
    3245         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     3247        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "stencilFuncSeparate", "invalid face");
    32463248        return;
    32473249    }
     
    32763278        break;
    32773279    default:
    3278         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     3280        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "stencilMaskSeparate", "invalid face");
    32793281        return;
    32803282    }
     
    33053307    // FIXME: For now we ignore any errors returned
    33063308    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);
    33103312    if (!tex)
    33113313        return;
    33123314    if (!isGLES2NPOTStrict()) {
    33133315        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");
    33153317            return;
    33163318        }
     
    33363338    Vector<uint8_t> data;
    33373339    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");
    33393341        return;
    33403342    }
     
    33513353                                       GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionCode& ec)
    33523354{
    3353     if (isContextLost() || !validateTexFuncData(width, height, format, type, pixels))
     3355    if (isContextLost() || !validateTexFuncData("texImage2D", width, height, format, type, pixels))
    33543356        return;
    33553357    void* data = pixels ? pixels->baseAddress() : 0;
     
    33823384    Vector<uint8_t> data;
    33833385    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");
    33853387        return;
    33863388    }
     
    33993401    if (isContextLost())
    34003402        return;
    3401     if (!validateHTMLImageElement(image))
     3403    if (!validateHTMLImageElement("texImage2D", image))
    34023404        return;
    34033405    if (wouldTaintOrigin(image)) {
     
    34173419        return;
    34183420    if (!canvas || !canvas->buffer()) {
    3419         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     3421        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "no canvas");
    34203422        return;
    34213423    }
     
    34363438{
    34373439    if (!video || !video->videoWidth() || !video->videoHeight()) {
    3438         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     3440        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "no video");
    34393441        return 0;
    34403442    }
     
    34423444    ImageBuffer* buf = m_videoCache.imageBuffer(size);
    34433445    if (!buf) {
    3444         m_context->synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY);
     3446        synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY, "texImage2D", "out of memory");
    34453447        return 0;
    34463448    }
     
    34723474    if (isContextLost())
    34733475        return;
    3474     WebGLTexture* tex = validateTextureBinding(target, false);
     3476    WebGLTexture* tex = validateTextureBinding("texParameter", target, false);
    34753477    if (!tex)
    34763478        return;
     
    34833485        if ((isFloat && paramf != GraphicsContext3D::CLAMP_TO_EDGE && paramf != GraphicsContext3D::MIRRORED_REPEAT && paramf != GraphicsContext3D::REPEAT)
    34843486            || (!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");
    34863488            return;
    34873489        }
    34883490        break;
    34893491    default:
    3490         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     3492        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "texParameter", "invalid parameter name");
    34913493        return;
    34923494    }
     
    35193521    if (isContextLost())
    35203522        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);
    35263528    if (!tex)
    35273529        return;
    35283530    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");
    35303532        return;
    35313533    }
    35323534    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");
    35343536        return;
    35353537    }
     
    35473549    Vector<uint8_t> data;
    35483550    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");
    35503552        return;
    35513553    }
     
    35583560                                          GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionCode& ec)
    35593561{
    3560     if (isContextLost() || !validateTexFuncData(width, height, format, type, pixels))
     3562    if (isContextLost() || !validateTexFuncData("texSubImage2D", width, height, format, type, pixels))
    35613563        return;
    35623564    void* data = pixels ? pixels->baseAddress() : 0;
     
    35883590    Vector<uint8_t> data;
    35893591    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");
    35913593        return;
    35923594    }
     
    36013603    if (isContextLost())
    36023604        return;
    3603     if (!validateHTMLImageElement(image))
     3605    if (!validateHTMLImageElement("texSubImage2D", image))
    36043606        return;
    36053607    if (wouldTaintOrigin(image)) {
     
    36183620        return;
    36193621    if (!canvas || !canvas->buffer()) {
    3620         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     3622        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "no canvas");
    36213623        return;
    36223624    }
     
    36543656
    36553657    if (location->program() != m_currentProgram) {
    3656         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     3658        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform1f", "location not for current program");
    36573659        return;
    36583660    }
     
    36653667{
    36663668    UNUSED_PARAM(ec);
    3667     if (isContextLost() || !validateUniformParameters(location, v, 1))
     3669    if (isContextLost() || !validateUniformParameters("uniform1fv", location, v, 1))
    36683670        return;
    36693671
     
    36753677{
    36763678    UNUSED_PARAM(ec);
    3677     if (isContextLost() || !validateUniformParameters(location, v, size, 1))
     3679    if (isContextLost() || !validateUniformParameters("uniform1fv", location, v, size, 1))
    36783680        return;
    36793681
     
    36893691
    36903692    if (location->program() != m_currentProgram) {
    3691         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     3693        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform1i", "location not for current program");
    36923694        return;
    36933695    }
     
    37003702{
    37013703    UNUSED_PARAM(ec);
    3702     if (isContextLost() || !validateUniformParameters(location, v, 1))
     3704    if (isContextLost() || !validateUniformParameters("uniform1iv", location, v, 1))
    37033705        return;
    37043706
     
    37103712{
    37113713    UNUSED_PARAM(ec);
    3712     if (isContextLost() || !validateUniformParameters(location, v, size, 1))
     3714    if (isContextLost() || !validateUniformParameters("uniform1iv", location, v, size, 1))
    37133715        return;
    37143716
     
    37243726
    37253727    if (location->program() != m_currentProgram) {
    3726         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     3728        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform2f", "location not for current program");
    37273729        return;
    37283730    }
     
    37353737{
    37363738    UNUSED_PARAM(ec);
    3737     if (isContextLost() || !validateUniformParameters(location, v, 2))
     3739    if (isContextLost() || !validateUniformParameters("uniform2fv", location, v, 2))
    37383740        return;
    37393741
     
    37453747{
    37463748    UNUSED_PARAM(ec);
    3747     if (isContextLost() || !validateUniformParameters(location, v, size, 2))
     3749    if (isContextLost() || !validateUniformParameters("uniform2fv", location, v, size, 2))
    37483750        return;
    37493751
     
    37593761
    37603762    if (location->program() != m_currentProgram) {
    3761         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     3763        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform2i", "location not for current program");
    37623764        return;
    37633765    }
     
    37703772{
    37713773    UNUSED_PARAM(ec);
    3772     if (isContextLost() || !validateUniformParameters(location, v, 2))
     3774    if (isContextLost() || !validateUniformParameters("uniform2iv", location, v, 2))
    37733775        return;
    37743776
     
    37803782{
    37813783    UNUSED_PARAM(ec);
    3782     if (isContextLost() || !validateUniformParameters(location, v, size, 2))
     3784    if (isContextLost() || !validateUniformParameters("uniform2iv", location, v, size, 2))
    37833785        return;
    37843786
     
    37943796
    37953797    if (location->program() != m_currentProgram) {
    3796         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     3798        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform3f", "location not for current program");
    37973799        return;
    37983800    }
     
    38053807{
    38063808    UNUSED_PARAM(ec);
    3807     if (isContextLost() || !validateUniformParameters(location, v, 3))
     3809    if (isContextLost() || !validateUniformParameters("uniform3fv", location, v, 3))
    38083810        return;
    38093811
     
    38153817{
    38163818    UNUSED_PARAM(ec);
    3817     if (isContextLost() || !validateUniformParameters(location, v, size, 3))
     3819    if (isContextLost() || !validateUniformParameters("uniform3fv", location, v, size, 3))
    38183820        return;
    38193821
     
    38293831
    38303832    if (location->program() != m_currentProgram) {
    3831         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     3833        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform3i", "location not for current program");
    38323834        return;
    38333835    }
     
    38403842{
    38413843    UNUSED_PARAM(ec);
    3842     if (isContextLost() || !validateUniformParameters(location, v, 3))
     3844    if (isContextLost() || !validateUniformParameters("uniform3iv", location, v, 3))
    38433845        return;
    38443846
     
    38503852{
    38513853    UNUSED_PARAM(ec);
    3852     if (isContextLost() || !validateUniformParameters(location, v, size, 3))
     3854    if (isContextLost() || !validateUniformParameters("uniform3iv", location, v, size, 3))
    38533855        return;
    38543856
     
    38643866
    38653867    if (location->program() != m_currentProgram) {
    3866         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     3868        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform4f", "location not for current program");
    38673869        return;
    38683870    }
     
    38753877{
    38763878    UNUSED_PARAM(ec);
    3877     if (isContextLost() || !validateUniformParameters(location, v, 4))
     3879    if (isContextLost() || !validateUniformParameters("uniform4fv", location, v, 4))
    38783880        return;
    38793881
     
    38853887{
    38863888    UNUSED_PARAM(ec);
    3887     if (isContextLost() || !validateUniformParameters(location, v, size, 4))
     3889    if (isContextLost() || !validateUniformParameters("uniform4fv", location, v, size, 4))
    38883890        return;
    38893891
     
    38993901
    39003902    if (location->program() != m_currentProgram) {
    3901         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     3903        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform4i", "location not for current program");
    39023904        return;
    39033905    }
     
    39103912{
    39113913    UNUSED_PARAM(ec);
    3912     if (isContextLost() || !validateUniformParameters(location, v, 4))
     3914    if (isContextLost() || !validateUniformParameters("uniform4iv", location, v, 4))
    39133915        return;
    39143916
     
    39203922{
    39213923    UNUSED_PARAM(ec);
    3922     if (isContextLost() || !validateUniformParameters(location, v, size, 4))
     3924    if (isContextLost() || !validateUniformParameters("uniform4iv", location, v, size, 4))
    39233925        return;
    39243926
     
    39303932{
    39313933    UNUSED_PARAM(ec);
    3932     if (isContextLost() || !validateUniformMatrixParameters(location, transpose, v, 4))
     3934    if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, v, 4))
    39333935        return;
    39343936    m_context->uniformMatrix2fv(location->location(), transpose, v->data(), v->length() / 4);
     
    39393941{
    39403942    UNUSED_PARAM(ec);
    3941     if (isContextLost() || !validateUniformMatrixParameters(location, transpose, v, size, 4))
     3943    if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, v, size, 4))
    39423944        return;
    39433945    m_context->uniformMatrix2fv(location->location(), transpose, v, size / 4);
     
    39483950{
    39493951    UNUSED_PARAM(ec);
    3950     if (isContextLost() || !validateUniformMatrixParameters(location, transpose, v, 9))
     3952    if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, v, 9))
    39513953        return;
    39523954    m_context->uniformMatrix3fv(location->location(), transpose, v->data(), v->length() / 9);
     
    39573959{
    39583960    UNUSED_PARAM(ec);
    3959     if (isContextLost() || !validateUniformMatrixParameters(location, transpose, v, size, 9))
     3961    if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, v, size, 9))
    39603962        return;
    39613963    m_context->uniformMatrix3fv(location->location(), transpose, v, size / 9);
     
    39663968{
    39673969    UNUSED_PARAM(ec);
    3968     if (isContextLost() || !validateUniformMatrixParameters(location, transpose, v, 16))
     3970    if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, v, 16))
    39693971        return;
    39703972    m_context->uniformMatrix4fv(location->location(), transpose, v->data(), v->length() / 16);
     
    39753977{
    39763978    UNUSED_PARAM(ec);
    3977     if (isContextLost() || !validateUniformMatrixParameters(location, transpose, v, size, 16))
     3979    if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, v, size, 16))
    39783980        return;
    39793981    m_context->uniformMatrix4fv(location->location(), transpose, v, size / 16);
     
    39853987    UNUSED_PARAM(ec);
    39863988    bool deleted;
    3987     if (!checkObjectToBeBound(program, deleted))
     3989    if (!checkObjectToBeBound("useProgram", program, deleted))
    39883990        return;
    39893991    if (deleted)
    39903992        program = 0;
    39913993    if (program && !program->getLinkStatus()) {
    3992         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     3994        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "useProgram", "program not valid");
    39933995        cleanupAfterGraphicsCall(false);
    39943996        return;
     
    40084010{
    40094011    UNUSED_PARAM(ec);
    4010     if (isContextLost() || !validateWebGLObject(program))
     4012    if (isContextLost() || !validateWebGLObject("validateProgram", program))
    40114013        return;
    40124014    m_context->validateProgram(objectOrZero(program));
     
    40164018void WebGLRenderingContext::vertexAttrib1f(GC3Duint index, GC3Dfloat v0)
    40174019{
    4018     vertexAttribfImpl(index, 1, v0, 0.0f, 0.0f, 1.0f);
     4020    vertexAttribfImpl("vertexAttrib1f", index, 1, v0, 0.0f, 0.0f, 1.0f);
    40194021}
    40204022
    40214023void WebGLRenderingContext::vertexAttrib1fv(GC3Duint index, Float32Array* v)
    40224024{
    4023     vertexAttribfvImpl(index, v, 1);
     4025    vertexAttribfvImpl("vertexAttrib1fv", index, v, 1);
    40244026}
    40254027
    40264028void WebGLRenderingContext::vertexAttrib1fv(GC3Duint index, GC3Dfloat* v, GC3Dsizei size)
    40274029{
    4028     vertexAttribfvImpl(index, v, size, 1);
     4030    vertexAttribfvImpl("vertexAttrib1fv", index, v, size, 1);
    40294031}
    40304032
    40314033void WebGLRenderingContext::vertexAttrib2f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1)
    40324034{
    4033     vertexAttribfImpl(index, 2, v0, v1, 0.0f, 1.0f);
     4035    vertexAttribfImpl("vertexAttrib2f", index, 2, v0, v1, 0.0f, 1.0f);
    40344036}
    40354037
    40364038void WebGLRenderingContext::vertexAttrib2fv(GC3Duint index, Float32Array* v)
    40374039{
    4038     vertexAttribfvImpl(index, v, 2);
     4040    vertexAttribfvImpl("vertexAttrib2fv", index, v, 2);
    40394041}
    40404042
    40414043void WebGLRenderingContext::vertexAttrib2fv(GC3Duint index, GC3Dfloat* v, GC3Dsizei size)
    40424044{
    4043     vertexAttribfvImpl(index, v, size, 2);
     4045    vertexAttribfvImpl("vertexAttrib2fv", index, v, size, 2);
    40444046}
    40454047
    40464048void WebGLRenderingContext::vertexAttrib3f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2)
    40474049{
    4048     vertexAttribfImpl(index, 3, v0, v1, v2, 1.0f);
     4050    vertexAttribfImpl("vertexAttrib3f", index, 3, v0, v1, v2, 1.0f);
    40494051}
    40504052
    40514053void WebGLRenderingContext::vertexAttrib3fv(GC3Duint index, Float32Array* v)
    40524054{
    4053     vertexAttribfvImpl(index, v, 3);
     4055    vertexAttribfvImpl("vertexAttrib3fv", index, v, 3);
    40544056}
    40554057
    40564058void WebGLRenderingContext::vertexAttrib3fv(GC3Duint index, GC3Dfloat* v, GC3Dsizei size)
    40574059{
    4058     vertexAttribfvImpl(index, v, size, 3);
     4060    vertexAttribfvImpl("vertexAttrib3fv", index, v, size, 3);
    40594061}
    40604062
    40614063void WebGLRenderingContext::vertexAttrib4f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfloat v3)
    40624064{
    4063     vertexAttribfImpl(index, 4, v0, v1, v2, v3);
     4065    vertexAttribfImpl("vertexAttrib4f", index, 4, v0, v1, v2, v3);
    40644066}
    40654067
    40664068void WebGLRenderingContext::vertexAttrib4fv(GC3Duint index, Float32Array* v)
    40674069{
    4068     vertexAttribfvImpl(index, v, 4);
     4070    vertexAttribfvImpl("vertexAttrib4fv", index, v, 4);
    40694071}
    40704072
    40714073void WebGLRenderingContext::vertexAttrib4fv(GC3Duint index, GC3Dfloat* v, GC3Dsizei size)
    40724074{
    4073     vertexAttribfvImpl(index, v, size, 4);
     4075    vertexAttribfvImpl("vertexAttrib4fv", index, v, size, 4);
    40744076}
    40754077
     
    40874089        break;
    40884090    default:
    4089         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     4091        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "vertexAttribPointer", "invalid type");
    40904092        return;
    40914093    }
    40924094    if (index >= m_maxVertexAttribs) {
    4093         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4095        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "vertexAttribPointer", "index out of range");
    40944096        return;
    40954097    }
    40964098    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");
    40984100        return;
    40994101    }
    41004102    if (!m_boundArrayBuffer) {
    4101         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     4103        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "vertexAttribPointer", "no bound ARRAY_BUFFER");
    41024104        return;
    41034105    }
     
    41054107    unsigned int typeSize = sizeInBytes(type);
    41064108    if (!typeSize) {
    4107         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     4109        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "vertexAttribPointer", "invalid type");
    41084110        return;
    41094111    }
    41104112    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");
    41124114        return;
    41134115    }
     
    41334135    if (isContextLost())
    41344136        return;
    4135     if (!validateSize(width, height))
     4137    if (!validateSize("viewport", width, height))
    41364138        return;
    41374139    m_context->viewport(x, y, width, height);
     
    41424144{
    41434145    if (isContextLost()) {
    4144         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     4146        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "loseContext", "context already lost");
    41454147        return;
    41464148    }
     
    41674169            break;
    41684170    }
    4169     m_context->synthesizeGLError(GraphicsContext3D::CONTEXT_LOST_WEBGL);
     4171    synthesizeGLError(GraphicsContext3D::CONTEXT_LOST_WEBGL, "loseContext", "context lost");
    41704172
    41714173    // Don't allow restoration unless the context lost event has both been
     
    41814183{
    41824184    if (!isContextLost()) {
    4183         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     4185        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "restoreContext", "context not lost");
    41844186        return;
    41854187    }
     
    41874189    if (!m_restoreAllowed) {
    41884190        if (m_contextLostMode == SyntheticLostContext)
    4189             m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     4191            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "restoreContext", "context restoration not allowed");
    41904192        return;
    41914193    }
     
    44184420}
    44194421
    4420 WebGLTexture* WebGLRenderingContext::validateTextureBinding(GC3Denum target, bool useSixEnumsForCubeMap)
     4422WebGLTexture* WebGLRenderingContext::validateTextureBinding(const char* functionName, GC3Denum target, bool useSixEnumsForCubeMap)
    44214423{
    44224424    WebGLTexture* tex = 0;
     
    44324434    case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z:
    44334435        if (!useSixEnumsForCubeMap) {
    4434             m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     4436            synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid texture target");
    44354437            return 0;
    44364438        }
     
    44394441    case GraphicsContext3D::TEXTURE_CUBE_MAP:
    44404442        if (useSixEnumsForCubeMap) {
    4441             m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     4443            synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid texture target");
    44424444            return 0;
    44434445        }
     
    44454447        break;
    44464448    default:
    4447         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     4449        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid texture target");
    44484450        return 0;
    44494451    }
    44504452    if (!tex)
    4451         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     4453        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "no texture");
    44524454    return tex;
    44534455}
    44544456
    4455 bool WebGLRenderingContext::validateLocationLength(const String& string)
     4457bool WebGLRenderingContext::validateLocationLength(const char* functionName, const String& string)
    44564458{
    44574459    const unsigned maxWebGLLocationLength = 256;
    44584460    if (string.length() > maxWebGLLocationLength) {
    4459         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4461        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "location length > 256");
    44604462        return false;
    44614463    }
     
    44634465}
    44644466
    4465 bool WebGLRenderingContext::validateSize(GC3Dint x, GC3Dint y)
     4467bool WebGLRenderingContext::validateSize(const char* functionName, GC3Dint x, GC3Dint y)
    44664468{
    44674469    if (x < 0 || y < 0) {
    4468         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4470        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "size < 0");
    44694471        return false;
    44704472    }
     
    44724474}
    44734475
    4474 bool WebGLRenderingContext::validateString(const String& string)
     4476bool WebGLRenderingContext::validateString(const char* functionName, const String& string)
    44754477{
    44764478    for (size_t i = 0; i < string.length(); ++i) {
    44774479        if (!validateCharacter(string[i])) {
    4478             m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4480            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "string not ASCII");
    44794481            return false;
    44804482        }
     
    44834485}
    44844486
    4485 bool WebGLRenderingContext::validateTexFuncFormatAndType(GC3Denum format, GC3Denum type)
     4487bool WebGLRenderingContext::validateTexFuncFormatAndType(const char* functionName, GC3Denum format, GC3Denum type)
    44864488{
    44874489    switch (format) {
     
    44934495        break;
    44944496    default:
    4495         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     4497        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid texture format");
    44964498        return false;
    44974499    }
     
    45064508        if (m_oesTextureFloat)
    45074509            break;
    4508         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     4510        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid texture type");
    45094511        return false;
    45104512    default:
    4511         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     4513        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid texture type");
    45124514        return false;
    45134515    }
     
    45204522        if (type != GraphicsContext3D::UNSIGNED_BYTE
    45214523            && type != GraphicsContext3D::FLOAT) {
    4522             m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     4524            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "invalid type for format");
    45234525            return false;
    45244526        }
     
    45284530            && type != GraphicsContext3D::UNSIGNED_SHORT_5_6_5
    45294531            && type != GraphicsContext3D::FLOAT) {
    4530             m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     4532            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "invalid type for RGB format");
    45314533            return false;
    45324534        }
     
    45374539            && type != GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1
    45384540            && type != GraphicsContext3D::FLOAT) {
    4539             m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     4541            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "invalid type for RGBA format");
    45404542            return false;
    45414543        }
     
    45484550}
    45494551
    4550 bool WebGLRenderingContext::validateTexFuncLevel(GC3Denum target, GC3Dint level)
     4552bool WebGLRenderingContext::validateTexFuncLevel(const char* functionName, GC3Denum target, GC3Dint level)
    45514553{
    45524554    if (level < 0) {
    4553         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4555        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "level < 0");
    45544556        return false;
    45554557    }
     
    45574559    case GraphicsContext3D::TEXTURE_2D:
    45584560        if (level > m_maxTextureLevel) {
    4559             m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4561            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "level out of range");
    45604562            return false;
    45614563        }
     
    45684570    case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z:
    45694571        if (level > m_maxCubeMapTextureLevel) {
    4570             m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4572            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "level out of range");
    45714573            return false;
    45724574        }
     
    45784580}
    45794581
    4580 bool WebGLRenderingContext::validateTexFuncParameters(GC3Denum target, GC3Dint level,
     4582bool WebGLRenderingContext::validateTexFuncParameters(const char* functionName,
     4583                                                      GC3Denum target, GC3Dint level,
    45814584                                                      GC3Denum internalformat,
    45824585                                                      GC3Dsizei width, GC3Dsizei height, GC3Dint border,
     
    45864589    // The texImage2D entry points taking HTMLImage, etc. will produce
    45874590    // temporary data based on this combination, so it must be legal.
    4588     if (!validateTexFuncFormatAndType(format, type) || !validateTexFuncLevel(target, level))
     4591    if (!validateTexFuncFormatAndType(functionName, format, type) || !validateTexFuncLevel(functionName, target, level))
    45894592        return false;
    45904593
    45914594    if (width < 0 || height < 0) {
    4592         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4595        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "width or height < 0");
    45934596        return false;
    45944597    }
     
    45974600    case GraphicsContext3D::TEXTURE_2D:
    45984601        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");
    46004603            return false;
    46014604        }
     
    46084611    case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z:
    46094612        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");
    46114614            return false;
    46124615        }
    46134616        break;
    46144617    default:
    4615         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     4618        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid target");
    46164619        return false;
    46174620    }
    46184621
    46194622    if (format != internalformat) {
    4620         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     4623        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "format != internalformat");
    46214624        return false;
    46224625    }
    46234626
    46244627    if (border) {
    4625         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4628        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "border != 0");
    46264629        return false;
    46274630    }
     
    46304633}
    46314634
    4632 bool WebGLRenderingContext::validateTexFuncData(GC3Dsizei width, GC3Dsizei height,
     4635bool WebGLRenderingContext::validateTexFuncData(const char* functionName,
     4636                                                GC3Dsizei width, GC3Dsizei height,
    46334637                                                GC3Denum format, GC3Denum type,
    46344638                                                ArrayBufferView* pixels)
     
    46374641        return true;
    46384642
    4639     if (!validateTexFuncFormatAndType(format, type))
     4643    if (!validateTexFuncFormatAndType(functionName, format, type))
    46404644        return false;
    46414645
     
    46434647    case GraphicsContext3D::UNSIGNED_BYTE:
    46444648        if (!pixels->isUnsignedByteArray()) {
    4645             m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     4649            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "type UNSIGNED_BYTE but ArrayBufferView not Uint8Array");
    46464650            return false;
    46474651        }
     
    46514655    case GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1:
    46524656        if (!pixels->isUnsignedShortArray()) {
    4653             m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     4657            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "type UNSIGNED_SHORT but ArrayBufferView not Uint16Array");
    46544658            return false;
    46554659        }
     
    46574661    case GraphicsContext3D::FLOAT: // OES_texture_float
    46584662        if (!pixels->isFloatArray()) {
    4659             m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     4663            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "type FLOAT but ArrayBufferView not Float32Array");
    46604664            return false;
    46614665        }
     
    46684672    GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, height, m_unpackAlignment, &totalBytesRequired, 0);
    46694673    if (error != GraphicsContext3D::NO_ERROR) {
    4670         m_context->synthesizeGLError(error);
     4674        synthesizeGLError(error, functionName, "invalid texture dimensions");
    46714675        return false;
    46724676    }
    46734677    if (pixels->byteLength() < totalBytesRequired) {
    4674         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     4678        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "ArrayBufferView not big enough for request");
    46754679        return false;
    46764680    }
     
    46784682}
    46794683
    4680 bool WebGLRenderingContext::validateDrawMode(GC3Denum mode)
     4684bool WebGLRenderingContext::validateDrawMode(const char* functionName, GC3Denum mode)
    46814685{
    46824686    switch (mode) {
     
    46904694        return true;
    46914695    default:
    4692         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     4696        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid draw mode");
    46934697        return false;
    46944698    }
    46954699}
    46964700
    4697 bool WebGLRenderingContext::validateStencilSettings()
     4701bool WebGLRenderingContext::validateStencilSettings(const char* functionName)
    46984702{
    46994703    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");
    47014705        return false;
    47024706    }
     
    47044708}
    47054709
    4706 bool WebGLRenderingContext::validateStencilFunc(GC3Denum func)
     4710bool WebGLRenderingContext::validateStencilFunc(const char* functionName, GC3Denum func)
    47074711{
    47084712    switch (func) {
     
    47174721        return true;
    47184722    default:
    4719         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     4723        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid function");
    47204724        return false;
    47214725    }
     
    47274731}
    47284732
    4729 bool WebGLRenderingContext::validateFramebufferFuncParameters(GC3Denum target, GC3Denum attachment)
     4733bool WebGLRenderingContext::validateFramebufferFuncParameters(const char* functionName, GC3Denum target, GC3Denum attachment)
    47304734{
    47314735    if (target != GraphicsContext3D::FRAMEBUFFER) {
    4732         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     4736        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid target");
    47334737        return false;
    47344738    }
     
    47404744        break;
    47414745    default:
    4742         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     4746        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid attachment");
    47434747        return false;
    47444748    }
     
    47464750}
    47474751
    4748 bool WebGLRenderingContext::validateBlendEquation(GC3Denum mode)
     4752bool WebGLRenderingContext::validateBlendEquation(const char* functionName, GC3Denum mode)
    47494753{
    47504754    switch (mode) {
     
    47544758        return true;
    47554759    default:
    4756         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     4760        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid mode");
    47574761        return false;
    47584762    }
    47594763}
    47604764
    4761 bool WebGLRenderingContext::validateBlendFuncFactors(GC3Denum src, GC3Denum dst)
     4765bool WebGLRenderingContext::validateBlendFuncFactors(const char* functionName, GC3Denum src, GC3Denum dst)
    47624766{
    47634767    if (((src == GraphicsContext3D::CONSTANT_COLOR || src == GraphicsContext3D::ONE_MINUS_CONSTANT_COLOR)
     
    47654769        || ((dst == GraphicsContext3D::CONSTANT_COLOR || dst == GraphicsContext3D::ONE_MINUS_CONSTANT_COLOR)
    47664770            && (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");
    47684772        return false;
    47694773    }
     
    47714775}
    47724776
    4773 bool WebGLRenderingContext::validateCapability(GC3Denum cap)
     4777bool WebGLRenderingContext::validateCapability(const char* functionName, GC3Denum cap)
    47744778{
    47754779    switch (cap) {
     
    47854789        return true;
    47864790    default:
    4787         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     4791        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid capability");
    47884792        return false;
    47894793    }
    47904794}
    47914795
    4792 bool WebGLRenderingContext::validateUniformParameters(const WebGLUniformLocation* location, Float32Array* v, GC3Dsizei requiredMinSize)
     4796bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, Float32Array* v, GC3Dsizei requiredMinSize)
    47934797{
    47944798    if (!v) {
    4795         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4799        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no array");
    47964800        return false;
    47974801    }
    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
     4805bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, Int32Array* v, GC3Dsizei requiredMinSize)
    48024806{
    48034807    if (!v) {
    4804         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4808        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no array");
    48054809        return false;
    48064810    }
    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
     4814bool 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
     4819bool WebGLRenderingContext::validateUniformMatrixParameters(const char* functionName, const WebGLUniformLocation* location, GC3Dboolean transpose, Float32Array* v, GC3Dsizei requiredMinSize)
    48164820{
    48174821    if (!v) {
    4818         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4822        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no array");
    48194823        return false;
    48204824    }
    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
     4828bool WebGLRenderingContext::validateUniformMatrixParameters(const char* functionName, const WebGLUniformLocation* location, GC3Dboolean transpose, void* v, GC3Dsizei size, GC3Dsizei requiredMinSize)
    48254829{
    48264830    if (!location)
    48274831        return false;
    48284832    if (location->program() != m_currentProgram) {
    4829         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     4833        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "location is not from current program");
    48304834        return false;
    48314835    }
    48324836    if (!v) {
    4833         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4837        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no array");
    48344838        return false;
    48354839    }
    48364840    if (transpose) {
    4837         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4841        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "transpose not FALSE");
    48384842        return false;
    48394843    }
    48404844    if (size < requiredMinSize || (size % requiredMinSize)) {
    4841         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4845        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "invalid size");
    48424846        return false;
    48434847    }
     
    48454849}
    48464850
    4847 WebGLBuffer* WebGLRenderingContext::validateBufferDataParameters(GC3Denum target, GC3Denum usage)
     4851WebGLBuffer* WebGLRenderingContext::validateBufferDataParameters(const char* functionName, GC3Denum target, GC3Denum usage)
    48484852{
    48494853    WebGLBuffer* buffer = 0;
     
    48564860        break;
    48574861    default:
    4858         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     4862        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid target");
    48594863        return 0;
    48604864    }
    48614865    if (!buffer) {
    4862         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     4866        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "no buffer");
    48634867        return 0;
    48644868    }
     
    48694873        return buffer;
    48704874    }
    4871     m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     4875    synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid usage");
    48724876    return 0;
    48734877}
    48744878
    4875 bool WebGLRenderingContext::validateHTMLImageElement(HTMLImageElement* image)
     4879bool WebGLRenderingContext::validateHTMLImageElement(const char* functionName, HTMLImageElement* image)
    48764880{
    48774881    if (!image || !image->cachedImage()) {
    4878         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4882        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no image");
    48794883        return false;
    48804884    }
    48814885    const KURL& url = image->cachedImage()->response().url();
    48824886    if (url.isNull() || url.isEmpty() || !url.isValid()) {
    4883         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4887        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "invalid image");
    48844888        return false;
    48854889    }
     
    48874891}
    48884892
    4889 void WebGLRenderingContext::vertexAttribfImpl(GC3Duint index, GC3Dsizei expectedSize, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfloat v3)
     4893void WebGLRenderingContext::vertexAttribfImpl(const char* functionName, GC3Duint index, GC3Dsizei expectedSize, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfloat v3)
    48904894{
    48914895    if (isContextLost())
    48924896        return;
    48934897    if (index >= m_maxVertexAttribs) {
    4894         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4898        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "index out of range");
    48954899        return;
    48964900    }
     
    49204924}
    49214925
    4922 void WebGLRenderingContext::vertexAttribfvImpl(GC3Duint index, Float32Array* v, GC3Dsizei expectedSize)
     4926void WebGLRenderingContext::vertexAttribfvImpl(const char* functionName, GC3Duint index, Float32Array* v, GC3Dsizei expectedSize)
    49234927{
    49244928    if (isContextLost())
    49254929        return;
    49264930    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
     4937void WebGLRenderingContext::vertexAttribfvImpl(const char* functionName, GC3Duint index, GC3Dfloat* v, GC3Dsizei size, GC3Dsizei expectedSize)
    49344938{
    49354939    if (isContextLost())
    49364940        return;
    49374941    if (!v) {
    4938         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4942        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no array");
    49394943        return;
    49404944    }
    49414945    if (size < expectedSize) {
    4942         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4946        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "invalid size");
    49434947        return;
    49444948    }
    49454949    if (index >= m_maxVertexAttribs) {
    4946         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
     4950        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "index out of range");
    49474951        return;
    49484952    }
     
    51035107        else
    51045108            // 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");
    51065110        return;
    51075111    }
     
    51565160}
    51575161
     5162namespace {
     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
     5186void 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
    51585196} // namespace WebCore
    51595197
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h

    r106320 r106421  
    366366    bool validateRenderingState(int numElements);
    367367
    368     bool validateWebGLObject(WebGLObject*);
     368    bool validateWebGLObject(const char*, WebGLObject*);
    369369
    370370#if ENABLE(VIDEO)
     
    492492    bool m_isDepthStencilSupported;
    493493
     494    bool m_synthesizedErrorsToConsole;
     495
    494496    // Enabled extension objects.
    495497    OwnPtr<OESTextureFloat> m_oesTextureFloat;
     
    548550
    549551    // 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&);
    551553
    552554    // Helper function to check if size is non-negative.
    553555    // 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);
    555557
    556558    // Helper function to check if all characters in the string belong to the
    557559    // 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&);
    559561
    560562    // Helper function to check target and texture bound to the target.
    561563    // Generate GL errors and return 0 if target is invalid or texture bound is
    562564    // 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);
    564566
    565567    // Helper function to check input format/type for functions {copy}Tex{Sub}Image.
    566568    // 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);
    568570
    569571    // Helper function to check input level for functions {copy}Tex{Sub}Image.
    570572    // 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);
    572574
    573575    // Helper function to check input parameters for functions {copy}Tex{Sub}Image.
    574576    // 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,
    576579                                   GC3Denum internalformat,
    577580                                   GC3Dsizei width, GC3Dsizei height, GC3Dint border,
     
    581584    // is of the correct type and contains enough data for the texImage call.
    582585    // 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,
    584588                             GC3Denum format, GC3Denum type,
    585589                             ArrayBufferView* pixels);
    586590
    587591    // Helper function to validate mode for draw{Arrays/Elements}.
    588     bool validateDrawMode(GC3Denum);
     592    bool validateDrawMode(const char* functionName, GC3Denum);
    589593
    590594    // Helper function to validate if front/back stencilMask and stencilFunc settings are the same.
    591     bool validateStencilSettings();
     595    bool validateStencilSettings(const char* functionName);
    592596
    593597    // Helper function to validate stencil func.
    594     bool validateStencilFunc(GC3Denum);
     598    bool validateStencilFunc(const char* functionName, GC3Denum);
    595599
    596600    // Helper function for texParameterf and texParameteri.
     
    603607    // Helper function to validate input parameters for framebuffer functions.
    604608    // Generate GL error if parameters are illegal.
    605     bool validateFramebufferFuncParameters(GC3Denum target, GC3Denum attachment);
     609    bool validateFramebufferFuncParameters(const char* functionName, GC3Denum target, GC3Denum attachment);
    606610
    607611    // Helper function to validate blend equation mode.
    608     bool validateBlendEquation(GC3Denum);
     612    bool validateBlendEquation(const char* functionName, GC3Denum);
    609613
    610614    // Helper function to validate blend func factors.
    611     bool validateBlendFuncFactors(GC3Denum src, GC3Denum dst);
     615    bool validateBlendFuncFactors(const char* functionName, GC3Denum src, GC3Denum dst);
    612616
    613617    // Helper function to validate a GL capability.
    614     bool validateCapability(GC3Denum);
     618    bool validateCapability(const char* functionName, GC3Denum);
    615619
    616620    // 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);
    622626
    623627    // Helper function to validate parameters for bufferData.
    624628    // 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);
    626630
    627631    // Helper function for tex{Sub}Image2D to make sure image is ready.
    628     bool validateHTMLImageElement(HTMLImageElement*);
     632    bool validateHTMLImageElement(const char* functionName, HTMLImageElement*);
    629633
    630634    // 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);
    634638
    635639    // Helper function for delete* (deleteBuffer, deleteProgram, etc) functions.
     
    640644    // If the object has already been deleted, set deleted to true upon return.
    641645    // Return false if caller should return without further processing.
    642     bool checkObjectToBeBound(WebGLObject*, bool& deleted);
     646    bool checkObjectToBeBound(const char* functionName, WebGLObject*, bool& deleted);
    643647
    644648    // Helpers for simulating vertexAttrib0
     
    655659    bool allowPrivilegedExtensions() const;
    656660
     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
    657665    friend class WebGLStateRestorer;
    658666};
Note: See TracChangeset for help on using the changeset viewer.