Commit c20ab279 by Jamie Madill Committed by Commit Bot

Refactor more GL entrypoints.

In the next CL, the Context is going to remove the mutable getter for the gl::State. This means we can only mutate the state inside Context. So, we need to move all the state mutating GL command implementations to gl::Context. BUG=angleproject:747 BUG=angleproject:1388 Change-Id: I9ed351d08611934bf708781c6af3948396921593 Reviewed-on: https://chromium-review.googlesource.com/351171Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 5034c971
......@@ -188,6 +188,82 @@ class Context final : public ValidationContext
bool getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams);
bool getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams);
void activeTexture(GLenum texture);
void blendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
void blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
void clearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void clearDepthf(GLclampf depth);
void clearStencil(GLint s);
void colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
void cullFace(GLenum mode);
void depthFunc(GLenum func);
void depthMask(GLboolean flag);
void depthRangef(GLclampf zNear, GLclampf zFar);
void disable(GLenum cap);
void disableVertexAttribArray(GLuint index);
void enable(GLenum cap);
void enableVertexAttribArray(GLuint index);
void frontFace(GLenum mode);
void hint(GLenum target, GLenum mode);
void lineWidth(GLfloat width);
void pixelStorei(GLenum pname, GLint param);
void polygonOffset(GLfloat factor, GLfloat units);
void sampleCoverage(GLclampf value, GLboolean invert);
void scissor(GLint x, GLint y, GLsizei width, GLsizei height);
void stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
void stencilMaskSeparate(GLenum face, GLuint mask);
void stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
void vertexAttrib1f(GLuint index, GLfloat x);
void vertexAttrib1fv(GLuint index, const GLfloat *values);
void vertexAttrib2f(GLuint index, GLfloat x, GLfloat y);
void vertexAttrib2fv(GLuint index, const GLfloat *values);
void vertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z);
void vertexAttrib3fv(GLuint index, const GLfloat *values);
void vertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void vertexAttrib4fv(GLuint index, const GLfloat *values);
void vertexAttribPointer(GLuint index,
GLint size,
GLenum type,
GLboolean normalized,
GLsizei stride,
const GLvoid *ptr);
void viewport(GLint x, GLint y, GLsizei width, GLsizei height);
void vertexAttribIPointer(GLuint index,
GLint size,
GLenum type,
GLsizei stride,
const GLvoid *pointer);
void vertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w);
void vertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
void vertexAttribI4iv(GLuint index, const GLint *v);
void vertexAttribI4uiv(GLuint index, const GLuint *v);
void debugMessageControl(GLenum source,
GLenum type,
GLenum severity,
GLsizei count,
const GLuint *ids,
GLboolean enabled);
void debugMessageInsert(GLenum source,
GLenum type,
GLuint id,
GLenum severity,
GLsizei length,
const GLchar *buf);
void debugMessageCallback(GLDEBUGPROCKHR callback, const void *userParam);
GLuint getDebugMessageLog(GLuint count,
GLsizei bufSize,
GLenum *sources,
GLenum *types,
GLuint *ids,
GLenum *severities,
GLsizei *lengths,
GLchar *messageLog);
void pushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar *message);
void popDebugGroup();
void clear(GLbitfield mask);
void clearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *values);
void clearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *values);
......
......@@ -1139,9 +1139,7 @@ void GL_APIENTRY DebugMessageControlKHR(GLenum source,
return;
}
std::vector<GLuint> idVector(ids, ids + count);
context->getState().getDebug().setMessageControl(
source, type, severity, std::move(idVector), (enabled != GL_FALSE));
context->debugMessageControl(source, type, severity, count, ids, enabled);
}
}
......@@ -1165,8 +1163,7 @@ void GL_APIENTRY DebugMessageInsertKHR(GLenum source,
return;
}
std::string msg(buf, (length > 0) ? static_cast<size_t>(length) : strlen(buf));
context->getState().getDebug().insertMessage(source, type, id, severity, std::move(msg));
context->debugMessageInsert(source, type, id, severity, length, buf);
}
}
......@@ -1183,7 +1180,7 @@ void GL_APIENTRY DebugMessageCallbackKHR(GLDEBUGPROCKHR callback, const void *us
return;
}
context->getState().getDebug().setCallback(callback, userParam);
context->debugMessageCallback(callback, userParam);
}
}
......@@ -1211,8 +1208,8 @@ GLuint GL_APIENTRY GetDebugMessageLogKHR(GLuint count,
return 0;
}
return static_cast<GLuint>(context->getState().getDebug().getMessages(
count, bufSize, sources, types, ids, severities, lengths, messageLog));
return context->getDebugMessageLog(count, bufSize, sources, types, ids, severities, lengths,
messageLog);
}
return 0;
......@@ -1234,7 +1231,7 @@ void GL_APIENTRY PushDebugGroupKHR(GLenum source, GLuint id, GLsizei length, con
}
std::string msg(message, (length > 0) ? static_cast<size_t>(length) : strlen(message));
context->getState().getDebug().pushGroup(source, id, std::move(msg));
context->pushDebugGroup(source, id, length, message);
}
}
......@@ -1250,7 +1247,7 @@ void GL_APIENTRY PopDebugGroupKHR(void)
return;
}
context->getState().getDebug().popGroup();
context->popDebugGroup();
}
}
......
......@@ -836,7 +836,8 @@ void GL_APIENTRY BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLi
}
// Cannot bind a transform feedback buffer if the current transform feedback is active (3.0.4 pg 91 section 2.15.2)
TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
TransformFeedback *curTransformFeedback =
context->getState().getCurrentTransformFeedback();
if (curTransformFeedback && curTransformFeedback->isActive())
{
context->handleError(Error(GL_INVALID_OPERATION));
......@@ -910,7 +911,8 @@ void GL_APIENTRY BindBufferBase(GLenum target, GLuint index, GLuint buffer)
case GL_TRANSFORM_FEEDBACK_BUFFER:
{
// Cannot bind a transform feedback buffer if the current transform feedback is active (3.0.4 pg 91 section 2.15.2)
TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
TransformFeedback *curTransformFeedback =
context->getState().getCurrentTransformFeedback();
if (curTransformFeedback && curTransformFeedback->isActive())
{
context->handleError(Error(GL_INVALID_OPERATION));
......@@ -1075,14 +1077,14 @@ void GL_APIENTRY VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLs
// An INVALID_OPERATION error is generated when a non-zero vertex array object
// is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
// and the pointer argument is not NULL.
if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && pointer != NULL)
if (context->getState().getVertexArray()->id() != 0 &&
context->getState().getArrayBufferId() == 0 && pointer != NULL)
{
context->handleError(Error(GL_INVALID_OPERATION));
return;
}
context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type, false, true,
stride, pointer);
context->vertexAttribIPointer(index, size, type, stride, pointer);
}
}
......@@ -1113,7 +1115,8 @@ void GL_APIENTRY GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
if (pname == GL_CURRENT_VERTEX_ATTRIB)
{
const VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
const VertexAttribCurrentValueData &currentValueData =
context->getState().getVertexAttribCurrentValue(index);
for (int i = 0; i < 4; ++i)
{
params[i] = currentValueData.IntValues[i];
......@@ -1121,7 +1124,8 @@ void GL_APIENTRY GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
}
else
{
const VertexAttribute &attribState = context->getState().getVertexArray()->getVertexAttribute(index);
const VertexAttribute &attribState =
context->getState().getVertexArray()->getVertexAttribute(index);
*params = QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
}
}
......@@ -1154,7 +1158,8 @@ void GL_APIENTRY GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
if (pname == GL_CURRENT_VERTEX_ATTRIB)
{
const VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
const VertexAttribCurrentValueData &currentValueData =
context->getState().getVertexAttribCurrentValue(index);
for (int i = 0; i < 4; ++i)
{
params[i] = currentValueData.UnsignedIntValues[i];
......@@ -1162,7 +1167,8 @@ void GL_APIENTRY GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
}
else
{
const VertexAttribute &attribState = context->getState().getVertexArray()->getVertexAttribute(index);
const VertexAttribute &attribState =
context->getState().getVertexArray()->getVertexAttribute(index);
*params = QuerySingleVertexAttributeParameter<GLuint>(attribState, pname);
}
}
......@@ -1188,8 +1194,7 @@ void GL_APIENTRY VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint
return;
}
GLint vals[4] = { x, y, z, w };
context->getState().setVertexAttribi(index, vals);
context->vertexAttribI4i(index, x, y, z, w);
}
}
......@@ -1213,8 +1218,7 @@ void GL_APIENTRY VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GL
return;
}
GLuint vals[4] = { x, y, z, w };
context->getState().setVertexAttribu(index, vals);
context->vertexAttribI4ui(index, x, y, z, w);
}
}
......@@ -1237,7 +1241,7 @@ void GL_APIENTRY VertexAttribI4iv(GLuint index, const GLint* v)
return;
}
context->getState().setVertexAttribi(index, v);
context->vertexAttribI4iv(index, v);
}
}
......@@ -1260,7 +1264,7 @@ void GL_APIENTRY VertexAttribI4uiv(GLuint index, const GLuint* v)
return;
}
context->getState().setVertexAttribu(index, v);
context->vertexAttribI4uiv(index, v);
}
}
......@@ -2507,7 +2511,8 @@ void GL_APIENTRY BindTransformFeedback(GLenum target, GLuint id)
case GL_TRANSFORM_FEEDBACK:
{
// Cannot bind a transform feedback object if the current one is started and not paused (3.0.2 pg 85 section 2.14.1)
TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
TransformFeedback *curTransformFeedback =
context->getState().getCurrentTransformFeedback();
if (curTransformFeedback && curTransformFeedback->isActive() && !curTransformFeedback->isPaused())
{
context->handleError(Error(GL_INVALID_OPERATION));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment