Refactor UniformMatrix validation.
Move the shared validation logic to validationES.cpp.
BUG=angle:571
Change-Id: I2fb06a012703c647de2176914238b48665145c6f
Reviewed-on: https://chromium-review.googlesource.com/200073
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libGLESv2/libGLESv2.cpp b/src/libGLESv2/libGLESv2.cpp
index 0256df6..99a99d0 100644
--- a/src/libGLESv2/libGLESv2.cpp
+++ b/src/libGLESv2/libGLESv2.cpp
@@ -5580,31 +5580,16 @@
try
{
- if (count < 0)
- {
- return gl::error(GL_INVALID_VALUE);
- }
-
- if (location == -1)
- {
- return;
- }
-
gl::Context *context = gl::getNonLostContext();
if (context)
{
- if (transpose != GL_FALSE && context->getClientVersion() < 3)
+ if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2, location, count, transpose))
{
- return gl::error(GL_INVALID_VALUE);
+ return;
}
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
- if (!programBinary)
- {
- return gl::error(GL_INVALID_OPERATION);
- }
-
if (!programBinary->setUniformMatrix2fv(location, count, transpose, value))
{
return gl::error(GL_INVALID_OPERATION);
@@ -5624,31 +5609,16 @@
try
{
- if (count < 0)
- {
- return gl::error(GL_INVALID_VALUE);
- }
-
- if (location == -1)
- {
- return;
- }
-
gl::Context *context = gl::getNonLostContext();
if (context)
{
- if (transpose != GL_FALSE && context->getClientVersion() < 3)
+ if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3, location, count, transpose))
{
- return gl::error(GL_INVALID_VALUE);
+ return;
}
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
- if (!programBinary)
- {
- return gl::error(GL_INVALID_OPERATION);
- }
-
if (!programBinary->setUniformMatrix3fv(location, count, transpose, value))
{
return gl::error(GL_INVALID_OPERATION);
@@ -5668,31 +5638,16 @@
try
{
- if (count < 0)
- {
- return gl::error(GL_INVALID_VALUE);
- }
-
- if (location == -1)
- {
- return;
- }
-
gl::Context *context = gl::getNonLostContext();
if (context)
{
- if (transpose != GL_FALSE && context->getClientVersion() < 3)
+ if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4, location, count, transpose))
{
- return gl::error(GL_INVALID_VALUE);
+ return;
}
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
- if (!programBinary)
- {
- return gl::error(GL_INVALID_OPERATION);
- }
-
if (!programBinary->setUniformMatrix4fv(location, count, transpose, value))
{
return gl::error(GL_INVALID_OPERATION);
@@ -6754,31 +6709,16 @@
try
{
- if (count < 0)
- {
- return gl::error(GL_INVALID_VALUE);
- }
-
- if (location == -1)
- {
- return;
- }
-
gl::Context *context = gl::getNonLostContext();
if (context)
{
- if (context->getClientVersion() < 3)
+ if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x3, location, count, transpose))
{
- return gl::error(GL_INVALID_OPERATION);
+ return;
}
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
- if (!programBinary)
- {
- return gl::error(GL_INVALID_OPERATION);
- }
-
if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value))
{
return gl::error(GL_INVALID_OPERATION);
@@ -6798,31 +6738,16 @@
try
{
- if (count < 0)
- {
- return gl::error(GL_INVALID_VALUE);
- }
-
- if (location == -1)
- {
- return;
- }
-
gl::Context *context = gl::getNonLostContext();
if (context)
{
- if (context->getClientVersion() < 3)
+ if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x2, location, count, transpose))
{
- return gl::error(GL_INVALID_OPERATION);
+ return;
}
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
- if (!programBinary)
- {
- return gl::error(GL_INVALID_OPERATION);
- }
-
if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value))
{
return gl::error(GL_INVALID_OPERATION);
@@ -6842,31 +6767,16 @@
try
{
- if (count < 0)
- {
- return gl::error(GL_INVALID_VALUE);
- }
-
- if (location == -1)
- {
- return;
- }
-
gl::Context *context = gl::getNonLostContext();
if (context)
{
- if (context->getClientVersion() < 3)
+ if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x4, location, count, transpose))
{
- return gl::error(GL_INVALID_OPERATION);
+ return;
}
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
- if (!programBinary)
- {
- return gl::error(GL_INVALID_OPERATION);
- }
-
if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value))
{
return gl::error(GL_INVALID_OPERATION);
@@ -6886,31 +6796,16 @@
try
{
- if (count < 0)
- {
- return gl::error(GL_INVALID_VALUE);
- }
-
- if (location == -1)
- {
- return;
- }
-
gl::Context *context = gl::getNonLostContext();
if (context)
{
- if (context->getClientVersion() < 3)
+ if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x2, location, count, transpose))
{
- return gl::error(GL_INVALID_OPERATION);
+ return;
}
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
- if (!programBinary)
- {
- return gl::error(GL_INVALID_OPERATION);
- }
-
if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value))
{
return gl::error(GL_INVALID_OPERATION);
@@ -6930,31 +6825,16 @@
try
{
- if (count < 0)
- {
- return gl::error(GL_INVALID_VALUE);
- }
-
- if (location == -1)
- {
- return;
- }
-
gl::Context *context = gl::getNonLostContext();
if (context)
{
- if (context->getClientVersion() < 3)
+ if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x4, location, count, transpose))
{
- return gl::error(GL_INVALID_OPERATION);
+ return;
}
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
- if (!programBinary)
- {
- return gl::error(GL_INVALID_OPERATION);
- }
-
if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value))
{
return gl::error(GL_INVALID_OPERATION);
@@ -6974,31 +6854,16 @@
try
{
- if (count < 0)
- {
- return gl::error(GL_INVALID_VALUE);
- }
-
- if (location == -1)
- {
- return;
- }
-
gl::Context *context = gl::getNonLostContext();
if (context)
{
- if (context->getClientVersion() < 3)
+ if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x3, location, count, transpose))
{
- return gl::error(GL_INVALID_OPERATION);
+ return;
}
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
- if (!programBinary)
- {
- return gl::error(GL_INVALID_OPERATION);
- }
-
if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value))
{
return gl::error(GL_INVALID_OPERATION);