mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 636002 - better messages about attrib index validation - r=jrmuizel, a=joe
This commit is contained in:
parent
16d3658b63
commit
84ea51cd32
@ -440,6 +440,7 @@ protected:
|
||||
PRBool ValidateTexFormatAndType(WebGLenum format, WebGLenum type,
|
||||
PRUint32 *texelSize, const char *info);
|
||||
PRBool ValidateDrawModeEnum(WebGLenum mode, const char *info);
|
||||
PRBool ValidateAttribIndex(WebGLuint index, const char *info);
|
||||
|
||||
void Invalidate();
|
||||
void DestroyResourcesAndContext();
|
||||
|
@ -183,6 +183,9 @@ WebGLContext::BindAttribLocation(nsIWebGLProgram *pobj, WebGLuint location, cons
|
||||
if (name.IsEmpty())
|
||||
return ErrorInvalidValue("BindAttribLocation: name can't be null or empty");
|
||||
|
||||
if (!ValidateAttribIndex(location, "bindAttribLocation"))
|
||||
return NS_OK;
|
||||
|
||||
MakeContextCurrent();
|
||||
|
||||
gl->fBindAttribLocation(progname, location, NS_LossyConvertUTF16toASCII(name).get());
|
||||
@ -1087,8 +1090,8 @@ WebGLContext::DepthRange(WebGLfloat zNear, WebGLfloat zFar)
|
||||
NS_IMETHODIMP
|
||||
WebGLContext::DisableVertexAttribArray(WebGLuint index)
|
||||
{
|
||||
if (index > mAttribBuffers.Length())
|
||||
return ErrorInvalidValue("DisableVertexAttribArray: index out of range");
|
||||
if (!ValidateAttribIndex(index, "disableVertexAttribArray"))
|
||||
return NS_OK;
|
||||
|
||||
MakeContextCurrent();
|
||||
|
||||
@ -1452,8 +1455,8 @@ NS_IMETHODIMP WebGLContext::Disable(WebGLenum cap)
|
||||
NS_IMETHODIMP
|
||||
WebGLContext::EnableVertexAttribArray(WebGLuint index)
|
||||
{
|
||||
if (index > mAttribBuffers.Length())
|
||||
return ErrorInvalidValue("EnableVertexAttribArray: index out of range");
|
||||
if (!ValidateAttribIndex(index, "enableVertexAttribArray"))
|
||||
return NS_OK;
|
||||
|
||||
MakeContextCurrent();
|
||||
|
||||
@ -2512,8 +2515,8 @@ WebGLContext::GetVertexAttrib(WebGLuint index, WebGLenum pname, nsIVariant **ret
|
||||
{
|
||||
*retval = nsnull;
|
||||
|
||||
if (index >= mAttribBuffers.Length())
|
||||
return ErrorInvalidValue("getVertexAttrib: invalid index");
|
||||
if (!ValidateAttribIndex(index, "getVertexAttrib"))
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIWritableVariant> wrval = do_CreateInstance("@mozilla.org/variant;1");
|
||||
NS_ENSURE_TRUE(wrval, NS_ERROR_FAILURE);
|
||||
@ -2579,8 +2582,8 @@ WebGLContext::GetVertexAttribOffset(WebGLuint index, WebGLenum pname, WebGLuint
|
||||
{
|
||||
*retval = 0;
|
||||
|
||||
if (index >= mAttribBuffers.Length())
|
||||
return ErrorInvalidValue("getVertexAttribOffset: invalid index");
|
||||
if (!ValidateAttribIndex(index, "getVertexAttribOffset"))
|
||||
return NS_OK;
|
||||
|
||||
if (pname != LOCAL_GL_VERTEX_ATTRIB_ARRAY_POINTER)
|
||||
return ErrorInvalidEnum("getVertexAttribOffset: bad parameter");
|
||||
@ -3873,8 +3876,8 @@ WebGLContext::VertexAttribPointer(WebGLuint index, WebGLint size, WebGLenum type
|
||||
// requiredAlignment should always be a power of two.
|
||||
WebGLsizei requiredAlignmentMask = requiredAlignment - 1;
|
||||
|
||||
if (index >= mAttribBuffers.Length())
|
||||
return ErrorInvalidValue("VertexAttribPointer: index out of range - %d >= %d", index, mAttribBuffers.Length());
|
||||
if (!ValidateAttribIndex(index, "vertexAttribPointer"))
|
||||
return NS_OK;
|
||||
|
||||
if (size < 1 || size > 4)
|
||||
return ErrorInvalidValue("VertexAttribPointer: invalid element size");
|
||||
|
@ -376,6 +376,22 @@ PRBool WebGLContext::ValidateTexFormatAndType(WebGLenum format, WebGLenum type,
|
||||
}
|
||||
}
|
||||
|
||||
PRBool WebGLContext::ValidateAttribIndex(WebGLuint index, const char *info)
|
||||
{
|
||||
if (index > mAttribBuffers.Length()) {
|
||||
if (index == WebGLuint(-1)) {
|
||||
ErrorInvalidValue("%s: index -1 is invalid. That probably comes from a getAttribLication() call, "
|
||||
"where this return value -1 means that the passed name didn't correspond to an active attribute in "
|
||||
"the specified program.", info);
|
||||
} else {
|
||||
ErrorInvalidValue("%s: index %d is out of range", info, index);
|
||||
}
|
||||
return PR_FALSE;
|
||||
} else {
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
WebGLContext::InitAndValidateGL()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user