void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
- return;
-
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ if (!validateUniformParameters(location, v, 1))
return;
- }
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
m_context->uniform1fv(location->location(), v->data(), v->length());
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
- return;
-
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ if (!validateUniformParameters(location, v, size, 1))
return;
- }
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
m_context->uniform1fv(location->location(), v, size);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
+ if (!validateUniformParameters(location, v, 1))
return;
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
- return;
- }
-
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
m_context->uniform1iv(location->location(), v->data(), v->length());
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
- return;
-
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ if (!validateUniformParameters(location, v, size, 1))
return;
- }
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
m_context->uniform1iv(location->location(), v, size);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
+ if (!validateUniformParameters(location, v, 2))
return;
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
- return;
- }
-
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 2
m_context->uniform2fv(location->location(), v->data(), v->length() / 2);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
- return;
-
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ if (!validateUniformParameters(location, v, size, 2))
return;
- }
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 2
m_context->uniform2fv(location->location(), v, size / 2);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
- return;
-
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ if (!validateUniformParameters(location, v, 2))
return;
- }
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 2
m_context->uniform2iv(location->location(), v->data(), v->length() / 2);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
+ if (!validateUniformParameters(location, v, size, 2))
return;
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
- return;
- }
-
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 2
m_context->uniform2iv(location->location(), v, size / 2);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
+ if (!validateUniformParameters(location, v, 3))
return;
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
- return;
- }
-
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 3
m_context->uniform3fv(location->location(), v->data(), v->length() / 3);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
+ if (!validateUniformParameters(location, v, size, 3))
return;
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
- return;
- }
-
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 3
m_context->uniform3fv(location->location(), v, size / 3);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
- return;
-
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ if (!validateUniformParameters(location, v, 3))
return;
- }
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 3
m_context->uniform3iv(location->location(), v->data(), v->length() / 3);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
- return;
-
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ if (!validateUniformParameters(location, v, size, 3))
return;
- }
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 3
m_context->uniform3iv(location->location(), v, size / 3);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
- return;
-
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ if (!validateUniformParameters(location, v, 4))
return;
- }
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 4
m_context->uniform4fv(location->location(), v->data(), v->length() / 4);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
- return;
-
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ if (!validateUniformParameters(location, v, size, 4))
return;
- }
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 4
m_context->uniform4fv(location->location(), v, size / 4);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
+ if (!validateUniformParameters(location, v, 4))
return;
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
- return;
- }
-
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 4
m_context->uniform4iv(location->location(), v->data(), v->length() / 4);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
+ if (!validateUniformParameters(location, v, size, 4))
return;
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
- return;
- }
-
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 4
m_context->uniform4iv(location->location(), v, size / 4);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!validateUniformMatrixParameters(location, transpose, v))
+ if (!validateUniformMatrixParameters(location, transpose, v, 4))
return;
- // FIXME: length needs to be a multiple of 4
m_context->uniformMatrix2fv(location->location(), transpose, v->data(), v->length() / 4);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!validateUniformMatrixParameters(location, transpose, v))
+ if (!validateUniformMatrixParameters(location, transpose, v, size, 4))
return;
- // FIXME: length needs to be a multiple of 4
m_context->uniformMatrix2fv(location->location(), transpose, v, size / 4);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!validateUniformMatrixParameters(location, transpose, v))
+ if (!validateUniformMatrixParameters(location, transpose, v, 9))
return;
- // FIXME: length needs to be a multiple of 9
m_context->uniformMatrix3fv(location->location(), transpose, v->data(), v->length() / 9);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!validateUniformMatrixParameters(location, transpose, v))
+ if (!validateUniformMatrixParameters(location, transpose, v, size, 9))
return;
- // FIXME: length needs to be a multiple of 9
m_context->uniformMatrix3fv(location->location(), transpose, v, size / 9);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!validateUniformMatrixParameters(location, transpose, v))
+ if (!validateUniformMatrixParameters(location, transpose, v, 16))
return;
- // FIXME: length needs to be a multiple of 16
m_context->uniformMatrix4fv(location->location(), transpose, v->data(), v->length() / 16);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!validateUniformMatrixParameters(location, transpose, v))
+ if (!validateUniformMatrixParameters(location, transpose, v, size, 16))
return;
- // FIXME: length needs to be a multiple of 16
m_context->uniformMatrix4fv(location->location(), transpose, v, size / 16);
cleanupAfterGraphicsCall(false);
}
}
}
-bool WebGLRenderingContext::validateUniformMatrixParameters(const WebGLUniformLocation* location, bool transpose, void* v)
+bool WebGLRenderingContext::validateUniformParameters(const WebGLUniformLocation* location, Float32Array* v, int requiredMinSize)
+{
+ if (!v) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return false;
+ }
+ return validateUniformMatrixParameters(location, false, v->data(), v->length(), requiredMinSize);
+}
+
+bool WebGLRenderingContext::validateUniformParameters(const WebGLUniformLocation* location, Int32Array* v, int requiredMinSize)
+{
+ if (!v) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return false;
+ }
+ return validateUniformMatrixParameters(location, false, v->data(), v->length(), requiredMinSize);
+}
+
+bool WebGLRenderingContext::validateUniformParameters(const WebGLUniformLocation* location, void* v, int size, int requiredMinSize)
+{
+ return validateUniformMatrixParameters(location, false, v, size, requiredMinSize);
+}
+
+bool WebGLRenderingContext::validateUniformMatrixParameters(const WebGLUniformLocation* location, bool transpose, Float32Array* v, int requiredMinSize)
+{
+ if (!v) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return false;
+ }
+ return validateUniformMatrixParameters(location, transpose, v->data(), v->length(), requiredMinSize);
+}
+
+bool WebGLRenderingContext::validateUniformMatrixParameters(const WebGLUniformLocation* location, bool transpose, void* v, int size, int requiredMinSize)
{
if (!location)
return false;
m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
return false;
}
+ if (size < requiredMinSize) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return false;
+ }
return true;
}