mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 06:35:42 +00:00
back out 1b09c80c46c3 (bug 680722, WebGL shader validation) because of regression, see bug 684312 and 683710
This commit is contained in:
parent
5532b6853e
commit
3e9465294d
@ -502,9 +502,7 @@ protected:
|
||||
PRBool ValidateAttribIndex(WebGLuint index, const char *info);
|
||||
PRBool ValidateStencilParamsForDrawCall();
|
||||
|
||||
bool ValidateGLSLVariableName(const nsAString& name, const char *info);
|
||||
bool ValidateGLSLCharacter(PRUnichar c);
|
||||
bool ValidateGLSLString(const nsAString& string, const char *info);
|
||||
bool ValidateGLSLIdentifier(const nsAString& name, const char *info);
|
||||
|
||||
static PRUint32 GetTexelSize(WebGLenum format, WebGLenum type);
|
||||
|
||||
|
@ -62,7 +62,6 @@
|
||||
#endif
|
||||
|
||||
#include "WebGLTexelConversions.h"
|
||||
#include "WebGLValidateStrings.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -183,8 +182,8 @@ WebGLContext::BindAttribLocation(nsIWebGLProgram *pobj, WebGLuint location, cons
|
||||
if (!GetGLName<WebGLProgram>("bindAttribLocation: program", pobj, &progname))
|
||||
return NS_OK;
|
||||
|
||||
if (!ValidateGLSLVariableName(name, "bindAttribLocation"))
|
||||
return NS_OK;
|
||||
if (name.IsEmpty())
|
||||
return ErrorInvalidValue("BindAttribLocation: name can't be null or empty");
|
||||
|
||||
if (!ValidateAttribIndex(location, "bindAttribLocation"))
|
||||
return NS_OK;
|
||||
@ -1857,7 +1856,7 @@ WebGLContext::GetAttribLocation(nsIWebGLProgram *pobj,
|
||||
if (!GetGLName<WebGLProgram>("getAttribLocation: program", pobj, &progname))
|
||||
return NS_OK;
|
||||
|
||||
if (!ValidateGLSLVariableName(name, "getAttribLocation"))
|
||||
if (!ValidateGLSLIdentifier(name, "getAttribLocation"))
|
||||
return NS_OK;
|
||||
|
||||
MakeContextCurrent();
|
||||
@ -2672,7 +2671,7 @@ WebGLContext::GetUniformLocation(nsIWebGLProgram *pobj, const nsAString& name, n
|
||||
if (!GetConcreteObjectAndGLName("getUniformLocation: program", pobj, &prog, &progname))
|
||||
return NS_OK;
|
||||
|
||||
if (!ValidateGLSLVariableName(name, "getUniformLocation"))
|
||||
if (!ValidateGLSLIdentifier(name, "getUniformLocation"))
|
||||
return NS_OK;
|
||||
|
||||
MakeContextCurrent();
|
||||
@ -4138,10 +4137,7 @@ WebGLContext::ShaderSource(nsIWebGLShader *sobj, const nsAString& source)
|
||||
WebGLuint shadername;
|
||||
if (!GetConcreteObjectAndGLName("shaderSource: shader", sobj, &shader, &shadername))
|
||||
return NS_OK;
|
||||
|
||||
if (!ValidateGLSLString(source, "shaderSource"))
|
||||
return NS_OK;
|
||||
|
||||
|
||||
const nsPromiseFlatString& flatSource = PromiseFlatString(source);
|
||||
|
||||
if (!NS_IsAscii(flatSource.get()))
|
||||
|
@ -328,31 +328,14 @@ PRBool WebGLContext::ValidateDrawModeEnum(WebGLenum mode, const char *info)
|
||||
}
|
||||
}
|
||||
|
||||
bool WebGLContext::ValidateGLSLVariableName(const nsAString& name, const char *info)
|
||||
bool WebGLContext::ValidateGLSLIdentifier(const nsAString& name, const char *info)
|
||||
{
|
||||
const PRUint32 maxSize = 255;
|
||||
const PRUint32 maxSize = 4095;
|
||||
if (name.Length() > maxSize) {
|
||||
ErrorInvalidValue("%s: identifier is %d characters long, exceeds the maximum allowed length of %d characters",
|
||||
info, name.Length(), maxSize);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ValidateGLSLString(name, info)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebGLContext::ValidateGLSLString(const nsAString& string, const char *info)
|
||||
{
|
||||
for (PRUint32 i = 0; i < string.Length(); ++i) {
|
||||
if (!ValidateGLSLCharacter(string.CharAt(i))) {
|
||||
ErrorInvalidValue("%s: string contains the illegal character '%d'", info, string.CharAt(i));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Apple Inc. All rights reserved.
|
||||
* Copyright (C) 2011 Mozilla Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef WEBGLVALIDATESTRINGS_H_
|
||||
#define WEBGLVALIDATESTRINGS_H_
|
||||
|
||||
#include "WebGLContext.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
// The following function was taken from the WebKit WebGL implementation,
|
||||
// which can be found here:
|
||||
// http://trac.webkit.org/browser/trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp#L123
|
||||
/****** BEGIN CODE TAKEN FROM WEBKIT ******/
|
||||
bool WebGLContext::ValidateGLSLCharacter(PRUnichar c)
|
||||
{
|
||||
// Printing characters are valid except " $ ` @ \ ' DEL.
|
||||
if (c >= 32 && c <= 126 &&
|
||||
c != '"' && c != '$' && c != '`' && c != '@' && c != '\\' && c != '\'')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Horizontal tab, line feed, vertical tab, form feed, carriage return are also valid.
|
||||
if (c >= 9 && c <= 13) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/****** END CODE TAKEN FROM WEBKIT ******/
|
||||
|
||||
} // end namespace mozilla
|
||||
|
||||
#endif // WEBGLVALIDATESTRINGS_H_
|
@ -12,6 +12,7 @@ conformance/gl-getshadersource.html
|
||||
conformance/gl-uniform-bool.html
|
||||
conformance/glsl-conformance.html
|
||||
conformance/glsl-long-variable-names.html
|
||||
conformance/invalid-passed-params.html
|
||||
conformance/premultiplyalpha-test.html
|
||||
conformance/read-pixels-test.html
|
||||
conformance/uninitialized-test.html
|
||||
|
@ -6,6 +6,7 @@ conformance/gl-getshadersource.html
|
||||
conformance/gl-object-get-calls.html
|
||||
conformance/glsl-conformance.html
|
||||
conformance/glsl-long-variable-names.html
|
||||
conformance/invalid-passed-params.html
|
||||
conformance/premultiplyalpha-test.html
|
||||
conformance/program-test.html
|
||||
conformance/read-pixels-test.html
|
||||
|
@ -4,6 +4,7 @@ conformance/framebuffer-object-attachment.html
|
||||
conformance/gl-getshadersource.html
|
||||
conformance/glsl-conformance.html
|
||||
conformance/glsl-long-variable-names.html
|
||||
conformance/invalid-passed-params.html
|
||||
conformance/premultiplyalpha-test.html
|
||||
conformance/read-pixels-test.html
|
||||
conformance/more/conformance/quickCheckAPI.html
|
||||
|
Loading…
Reference in New Issue
Block a user