Context: Remove mutable gl::State getter.
This will preserve layering - the API layer doesn't mutate the state
directly, it passes the API call through to the Context. Is also
removes the possiblity of any shenanigans of the Validation layer
changing the GL state.
Also, this CL refactors a few validation entry points to take
ValidationContext instead of Context. ValidationContext will be the
correct way to interact with the gl::Context in the Validation code.
Finally, additional refactorings make ContextState a proper class with
private data. This allows the ContextState itself to keep a mutable
pointer to the gl::State, so ValidationContext can modify it if
necessary (and it will be necessary for Framebuffer completeness
caching).
BUG=angleproject:1388
Change-Id: I86ab3561573caa9535c8d1b8aad4ab3d0e7cd470
Reviewed-on: https://chromium-review.googlesource.com/348954
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/validationES2.cpp b/src/libANGLE/validationES2.cpp
index 2ddda21..4472249 100644
--- a/src/libANGLE/validationES2.cpp
+++ b/src/libANGLE/validationES2.cpp
@@ -47,9 +47,9 @@
return true;
}
- if (context->getState().isScissorTestEnabled())
+ if (context->getGLState().isScissorTestEnabled())
{
- const Rectangle &scissor = context->getState().getScissor();
+ const Rectangle &scissor = context->getGLState().getScissor();
return scissor.x > 0 || scissor.y > 0 || scissor.width < writeSize.width ||
scissor.height < writeSize.height;
}
@@ -495,7 +495,7 @@
return false;
}
- const gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
+ const gl::Framebuffer *framebuffer = context->getGLState().getReadFramebuffer();
GLenum colorbufferFormat = framebuffer->getReadColorbuffer()->getInternalFormat();
const auto &internalFormatInfo = gl::GetInternalFormatInfo(textureInternalFormat);
GLenum textureFormat = internalFormatInfo.format;
@@ -963,7 +963,7 @@
}
// check for combinations of format and type that are valid for ReadPixels
-bool ValidES2ReadFormatType(Context *context, GLenum format, GLenum type)
+bool ValidES2ReadFormatType(ValidationContext *context, GLenum format, GLenum type)
{
switch (format)
{
@@ -1022,8 +1022,9 @@
switch (target)
{
case GL_FRAMEBUFFER:
- defaultFramebuffer = (context->getState().getTargetFramebuffer(GL_FRAMEBUFFER)->id() == 0);
- break;
+ defaultFramebuffer =
+ (context->getGLState().getTargetFramebuffer(GL_FRAMEBUFFER)->id() == 0);
+ break;
default:
context->handleError(Error(GL_INVALID_ENUM, "Invalid framebuffer target"));
return false;
@@ -1230,7 +1231,7 @@
return false;
}
- if (!context->getState().getDebug().isOutputEnabled())
+ if (!context->getGLState().getDebug().isOutputEnabled())
{
// If the DEBUG_OUTPUT state is disabled calls to DebugMessageInsert are discarded and do
// not generate an error.
@@ -1331,7 +1332,7 @@
return false;
}
- size_t currentStackSize = context->getState().getDebug().getGroupStackDepth();
+ size_t currentStackSize = context->getGLState().getDebug().getGroupStackDepth();
if (currentStackSize >= context->getExtensions().maxDebugGroupStackDepth)
{
context->handleError(
@@ -1351,7 +1352,7 @@
return false;
}
- size_t currentStackSize = context->getState().getDebug().getGroupStackDepth();
+ size_t currentStackSize = context->getGLState().getDebug().getGroupStackDepth();
if (currentStackSize <= 1)
{
context->handleError(Error(GL_STACK_UNDERFLOW, "Cannot pop the default debug group."));
@@ -1631,8 +1632,8 @@
return false;
}
- const Framebuffer *readFramebuffer = context->getState().getReadFramebuffer();
- const Framebuffer *drawFramebuffer = context->getState().getDrawFramebuffer();
+ const Framebuffer *readFramebuffer = context->getGLState().getReadFramebuffer();
+ const Framebuffer *drawFramebuffer = context->getGLState().getDrawFramebuffer();
if (mask & GL_COLOR_BUFFER_BIT)
{
@@ -1675,7 +1676,7 @@
}
}
- int readSamples = readFramebuffer->getSamples(context->getData());
+ int readSamples = readFramebuffer->getSamples(context->getContextState());
if (readSamples != 0 &&
IsPartialBlit(context, readColorAttachment, drawColorAttachment, srcX0, srcY0,
@@ -1726,10 +1727,10 @@
bool ValidateClear(ValidationContext *context, GLbitfield mask)
{
- const Framebuffer *framebufferObject = context->getState().getDrawFramebuffer();
+ const Framebuffer *framebufferObject = context->getGLState().getDrawFramebuffer();
ASSERT(framebufferObject);
- if (framebufferObject->checkStatus(context->getData()) != GL_FRAMEBUFFER_COMPLETE)
+ if (framebufferObject->checkStatus(context->getContextState()) != GL_FRAMEBUFFER_COMPLETE)
{
context->handleError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
return false;
@@ -1920,7 +1921,7 @@
return false;
}
- Buffer *buffer = context->getState().getTargetBuffer(target);
+ Buffer *buffer = context->getGLState().getTargetBuffer(target);
if (buffer == nullptr)
{