Commit 45c785d3 by Jamie Madill

Move validation of EndQuery out of gl::Context.

BUG=angle:571 Change-Id: I8913eb1b565a4282d9d84d06933e8b854453f17d Reviewed-on: https://chromium-review.googlesource.com/199349Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent db2f14c0
......@@ -782,13 +782,18 @@ bool Context::isQueryActive() const
return false;
}
GLuint Context::getActiveQuery(GLenum target) const
const Query *Context::getActiveQuery(GLenum target) const
{
// All query types should already exist in the activeQueries map
ASSERT(mState.activeQueries.find(target) != mState.activeQueries.end());
const Query *queryObject = mState.activeQueries.at(target).get();
return queryObject ? queryObject->id() : 0;
return mState.activeQueries.at(target).get();
}
GLuint Context::getActiveQueryId(GLenum target) const
{
const Query *query = getActiveQuery(target);
return (query ? query->id() : 0u);
}
void Context::setEnableVertexAttribArray(unsigned int attribNum, bool enabled)
......@@ -1383,11 +1388,7 @@ void Context::beginQuery(GLenum target, GLuint query)
void Context::endQuery(GLenum target)
{
Query *queryObject = mState.activeQueries[target].get();
if (queryObject == NULL)
{
return gl::error(GL_INVALID_OPERATION);
}
ASSERT(queryObject);
queryObject->end();
......
......@@ -228,7 +228,8 @@ class Context
GLuint getArrayBufferHandle() const;
bool isQueryActive() const;
GLuint getActiveQuery(GLenum target) const;
const Query *getActiveQuery(GLenum target) const;
GLuint getActiveQueryId(GLenum target) const;
void setEnableVertexAttribArray(unsigned int attribNum, bool enabled);
const VertexAttribute &getVertexAttribState(unsigned int attribNum) const;
......
......@@ -49,4 +49,9 @@ GLenum Query::getType() const
return mQuery->getType();
}
bool Query::isStarted() const
{
return mQuery->isStarted();
}
}
......@@ -38,6 +38,7 @@ class Query : public RefCountObject
GLboolean isResultAvailable();
GLenum getType() const;
bool isStarted() const;
private:
DISALLOW_COPY_AND_ASSIGN(Query);
......
......@@ -1823,9 +1823,9 @@ void __stdcall glEndQueryEXT(GLenum target)
if (context)
{
if (!ValidQueryType(context, target))
if (!ValidateEndQuery(context, target))
{
return gl::error(GL_INVALID_ENUM);
return;
}
context->endQuery(target);
......@@ -3118,7 +3118,7 @@ void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
switch (pname)
{
case GL_CURRENT_QUERY_EXT:
params[0] = context->getActiveQuery(target);
params[0] = context->getActiveQueryId(target);
break;
default:
......@@ -3149,7 +3149,7 @@ void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
return gl::error(GL_INVALID_OPERATION);
}
if (context->getActiveQuery(queryObject->getType()) == id)
if (context->getActiveQueryId(queryObject->getType()) == id)
{
return gl::error(GL_INVALID_OPERATION);
}
......@@ -6554,7 +6554,6 @@ void __stdcall glBeginQuery(GLenum target, GLuint id)
{
return;
}
context->beginQuery(target, id);
}
}
......@@ -6579,9 +6578,9 @@ void __stdcall glEndQuery(GLenum target)
return gl::error(GL_INVALID_OPERATION);
}
if (!ValidQueryType(context, target))
if (!ValidateEndQuery(context, target))
{
return gl::error(GL_INVALID_ENUM);
return;
}
context->endQuery(target);
......@@ -6616,7 +6615,7 @@ void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params)
switch (pname)
{
case GL_CURRENT_QUERY:
params[0] = context->getActiveQuery(target);
params[0] = static_cast<GLint>(context->getActiveQueryId(target));
break;
default:
......@@ -6652,7 +6651,7 @@ void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
return gl::error(GL_INVALID_OPERATION);
}
if (context->getActiveQuery(queryObject->getType()) == id)
if (context->getActiveQueryId(queryObject->getType()) == id)
{
return gl::error(GL_INVALID_OPERATION);
}
......
......@@ -24,6 +24,7 @@ class QueryImpl
virtual void end() = 0;
virtual GLuint getResult() = 0;
virtual GLboolean isResultAvailable() = 0;
virtual bool isStarted() const = 0;
GLenum getType() const { return mType; }
......
......@@ -59,11 +59,7 @@ void Query11::begin()
void Query11::end()
{
if (mQuery == NULL)
{
return gl::error(GL_INVALID_OPERATION);
}
ASSERT(mQuery);
mRenderer->getDeviceContext()->End(mQuery);
mStatus = GL_FALSE;
......@@ -151,4 +147,9 @@ GLboolean Query11::testQuery()
return GL_TRUE; // prevent blocking when query is null
}
bool Query11::isStarted() const
{
return (mQuery != NULL);
}
}
......@@ -21,10 +21,11 @@ class Query11 : public QueryImpl
Query11(rx::Renderer11 *renderer, GLenum type);
virtual ~Query11();
void begin();
void end();
GLuint getResult();
GLboolean isResultAvailable();
virtual void begin();
virtual void end();
virtual GLuint getResult();
virtual GLboolean isResultAvailable();
virtual bool isStarted() const;
private:
DISALLOW_COPY_AND_ASSIGN(Query11);
......
......@@ -43,10 +43,7 @@ void Query9::begin()
void Query9::end()
{
if (mQuery == NULL)
{
return gl::error(GL_INVALID_OPERATION);
}
ASSERT(mQuery);
HRESULT result = mQuery->Issue(D3DISSUE_END);
ASSERT(SUCCEEDED(result));
......@@ -118,4 +115,9 @@ GLboolean Query9::testQuery()
return GL_TRUE; // prevent blocking when query is null
}
bool Query9::isStarted() const
{
return (mQuery != NULL);
}
}
......@@ -21,10 +21,11 @@ class Query9 : public QueryImpl
Query9(rx::Renderer9 *renderer, GLenum type);
virtual ~Query9();
void begin();
void end();
GLuint getResult();
GLboolean isResultAvailable();
virtual void begin();
virtual void end();
virtual GLuint getResult();
virtual GLboolean isResultAvailable();
virtual bool isStarted() const;
private:
DISALLOW_COPY_AND_ASSIGN(Query9);
......
......@@ -924,4 +924,26 @@ bool ValidateBeginQuery(gl::Context *context, GLenum target, GLuint id)
return true;
}
bool ValidateEndQuery(gl::Context *context, GLenum target)
{
if (!ValidQueryType(context, target))
{
return gl::error(GL_INVALID_ENUM, false);
}
const Query *queryObject = context->getActiveQuery(target);
if (queryObject == NULL)
{
return gl::error(GL_INVALID_OPERATION, false);
}
if (!queryObject->isStarted())
{
return gl::error(GL_INVALID_OPERATION, false);
}
return true;
}
}
......@@ -46,6 +46,7 @@ bool ValidateReadPixelsParameters(gl::Context *context, GLint x, GLint y, GLsize
GLenum format, GLenum type, GLsizei *bufSize, GLvoid *pixels);
bool ValidateBeginQuery(gl::Context *context, GLenum target, GLuint id);
bool ValidateEndQuery(gl::Context *context, GLenum target);
}
......
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