Chromium Code Reviews| Index: third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp |
| diff --git a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp |
| index 7770ea6409f2d0356bcfc5d663b7569261ffab92..caec41f6db17c987a9c418179df67ac541cd29c2 100644 |
| --- a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp |
| +++ b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp |
| @@ -237,7 +237,8 @@ WebGL2RenderingContextBase::WebGL2RenderingContextBase( |
| m_boundTransformFeedbackBuffer(this, nullptr), |
| m_boundUniformBuffer(this, nullptr), |
| m_currentBooleanOcclusionQuery(this, nullptr), |
| - m_currentTransformFeedbackPrimitivesWrittenQuery(this, nullptr) { |
| + m_currentTransformFeedbackPrimitivesWrittenQuery(this, nullptr), |
| + m_currentElapsedQuery(this, nullptr) { |
| m_supportedInternalFormatsStorage.insert( |
| kSupportedInternalFormatsStorage, |
| kSupportedInternalFormatsStorage + |
| @@ -256,6 +257,7 @@ WebGL2RenderingContextBase::~WebGL2RenderingContextBase() { |
| m_currentBooleanOcclusionQuery = nullptr; |
| m_currentTransformFeedbackPrimitivesWrittenQuery = nullptr; |
| + m_currentElapsedQuery = nullptr; |
| } |
| void WebGL2RenderingContextBase::destroyContext() { |
| @@ -282,6 +284,7 @@ void WebGL2RenderingContextBase::initializeNewContext() { |
| m_currentBooleanOcclusionQuery = nullptr; |
| m_currentTransformFeedbackPrimitivesWrittenQuery = nullptr; |
| + m_currentElapsedQuery = nullptr; |
| GLint numCombinedTextureImageUnits = 0; |
| contextGL()->GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, |
| @@ -2641,6 +2644,11 @@ void WebGL2RenderingContextBase::deleteQuery(WebGLQuery* query) { |
| m_currentTransformFeedbackPrimitivesWrittenQuery = nullptr; |
| } |
| + if (m_currentElapsedQuery == query) { |
| + contextGL()->EndQueryEXT(m_currentElapsedQuery->getTarget()); |
| + m_currentElapsedQuery = nullptr; |
| + } |
| + |
| deleteObject(query); |
| } |
| @@ -2691,6 +2699,18 @@ void WebGL2RenderingContextBase::beginQuery(GLenum target, WebGLQuery* query) { |
| } |
| m_currentTransformFeedbackPrimitivesWrittenQuery = query; |
| } break; |
| + case GL_TIME_ELAPSED_EXT: { |
| + if (!extensionEnabled(EXTDisjointTimerQueryWebGL2Name)) { |
| + synthesizeGLError(GL_INVALID_ENUM, "beginQuery", "invalid target"); |
| + return; |
| + } |
| + if (m_currentElapsedQuery) { |
| + synthesizeGLError(GL_INVALID_OPERATION, "beginQuery", |
| + "a query is already active for target"); |
| + return; |
| + } |
| + m_currentElapsedQuery = query; |
| + } break; |
| default: |
| synthesizeGLError(GL_INVALID_ENUM, "beginQuery", "invalid target"); |
| return; |
| @@ -2729,6 +2749,20 @@ void WebGL2RenderingContextBase::endQuery(GLenum target) { |
| return; |
| } |
| } break; |
| + case GL_TIME_ELAPSED_EXT: { |
| + if (!extensionEnabled(EXTDisjointTimerQueryWebGL2Name)) { |
| + synthesizeGLError(GL_INVALID_ENUM, "endQuery", "invalid target"); |
| + return; |
| + } |
| + if (m_currentElapsedQuery) { |
| + m_currentElapsedQuery->resetCachedResult(); |
| + m_currentElapsedQuery = nullptr; |
| + } else { |
| + synthesizeGLError(GL_INVALID_OPERATION, "endQuery", |
| + "target query is not active"); |
| + return; |
| + } |
| + } break; |
| default: |
| synthesizeGLError(GL_INVALID_ENUM, "endQuery", "invalid target"); |
| return; |
| @@ -2737,13 +2771,32 @@ void WebGL2RenderingContextBase::endQuery(GLenum target) { |
| contextGL()->EndQueryEXT(target); |
| } |
| -WebGLQuery* WebGL2RenderingContextBase::getQuery(GLenum target, GLenum pname) { |
| +ScriptValue WebGL2RenderingContextBase::getQuery(ScriptState* scriptState, |
| + GLenum target, |
| + GLenum pname) { |
| if (isContextLost()) |
| - return nullptr; |
| + return ScriptValue::createNull(scriptState); |
| + |
| + if (extensionEnabled(EXTDisjointTimerQueryWebGL2Name)) { |
| + switch (target) { |
| + case GL_TIME_ELAPSED_EXT: |
| + if (pname == GL_CURRENT_QUERY && m_currentElapsedQuery.get()) { |
| + return WebGLAny(scriptState, m_currentElapsedQuery.get()); |
| + } |
| + return ScriptValue::createNull(scriptState); |
| + case GL_TIMESTAMP_EXT: |
| + if (pname == GL_QUERY_COUNTER_BITS_EXT) { |
| + GLint value = 0; |
| + contextGL()->GetQueryivEXT(target, pname, &value); |
| + return WebGLAny(scriptState, value); |
| + } |
| + return ScriptValue::createNull(scriptState); |
| + } |
| + } |
| if (pname != GL_CURRENT_QUERY) { |
| synthesizeGLError(GL_INVALID_ENUM, "getQuery", "invalid parameter name"); |
| - return nullptr; |
| + return ScriptValue::createNull(scriptState); |
| } |
| switch (target) { |
| @@ -2751,15 +2804,16 @@ WebGLQuery* WebGL2RenderingContextBase::getQuery(GLenum target, GLenum pname) { |
| case GL_ANY_SAMPLES_PASSED_CONSERVATIVE: |
| if (m_currentBooleanOcclusionQuery && |
| m_currentBooleanOcclusionQuery->getTarget() == target) |
| - return m_currentBooleanOcclusionQuery; |
| + return WebGLAny(scriptState, m_currentBooleanOcclusionQuery); |
| break; |
| case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: |
| - return m_currentTransformFeedbackPrimitivesWrittenQuery; |
| + return WebGLAny(scriptState, |
| + m_currentTransformFeedbackPrimitivesWrittenQuery); |
| default: |
| synthesizeGLError(GL_INVALID_ENUM, "getQuery", "invalid target"); |
| - return nullptr; |
| + return ScriptValue::createNull(scriptState); |
| } |
| - return nullptr; |
| + return ScriptValue::createNull(scriptState); |
| } |
| ScriptValue WebGL2RenderingContextBase::getQueryParameter( |
| @@ -2788,7 +2842,8 @@ ScriptValue WebGL2RenderingContextBase::getQueryParameter( |
| return ScriptValue::createNull(scriptState); |
| } |
| if (query == m_currentBooleanOcclusionQuery || |
| - query == m_currentTransformFeedbackPrimitivesWrittenQuery) { |
| + query == m_currentTransformFeedbackPrimitivesWrittenQuery || |
| + query == m_currentElapsedQuery) { |
| synthesizeGLError(GL_INVALID_OPERATION, "getQueryParameter", |
| "query is currently active"); |
| return ScriptValue::createNull(scriptState); |
| @@ -3839,6 +3894,22 @@ ScriptValue WebGL2RenderingContextBase::getParameter(ScriptState* scriptState, |
| return getIntParameter(scriptState, pname); |
| case GL_UNPACK_SKIP_ROWS: |
| return getIntParameter(scriptState, pname); |
| + case GL_TIMESTAMP_EXT: |
| + if (extensionEnabled(EXTDisjointTimerQueryWebGL2Name)) { |
| + return WebGLAny(scriptState, 0); |
| + } |
| + synthesizeGLError(GL_INVALID_ENUM, "getParameter", |
| + "invalid parameter name, " |
| + "EXT_disjoint_timer_query_webgl2 not enabled"); |
| + return ScriptValue::createNull(scriptState); |
|
Ken Russell (switch to Gerrit)
2016/10/21 00:18:13
I'm not sure this is the same thing as returning t
Kai Ninomiya
2016/10/21 17:58:10
This is the case where the given pname (GL_TIMESTA
Ken Russell (switch to Gerrit)
2016/10/21 20:53:14
OK, I see. Thanks. I have a related concern which
|
| + case GL_GPU_DISJOINT_EXT: |
| + if (extensionEnabled(EXTDisjointTimerQueryWebGL2Name)) { |
| + return getBooleanParameter(scriptState, GL_GPU_DISJOINT_EXT); |
| + } |
| + synthesizeGLError(GL_INVALID_ENUM, "getParameter", |
| + "invalid parameter name, " |
| + "EXT_disjoint_timer_query_webgl2 not enabled"); |
| + return ScriptValue::createNull(scriptState); |
|
Ken Russell (switch to Gerrit)
2016/10/21 00:18:13
Same here -- this needs to explicitly return a boo
Kai Ninomiya
2016/10/21 17:58:10
See above.
|
| default: |
| return WebGLRenderingContextBase::getParameter(scriptState, pname); |
| @@ -4414,6 +4485,7 @@ DEFINE_TRACE(WebGL2RenderingContextBase) { |
| visitor->trace(m_boundIndexedUniformBuffers); |
| visitor->trace(m_currentBooleanOcclusionQuery); |
| visitor->trace(m_currentTransformFeedbackPrimitivesWrittenQuery); |
| + visitor->trace(m_currentElapsedQuery); |
| visitor->trace(m_samplerUnits); |
| visitor->trace(m_getBufferSubDataAsyncCallbacks); |
| WebGLRenderingContextBase::trace(visitor); |
| @@ -4440,6 +4512,7 @@ DEFINE_TRACE_WRAPPERS(WebGL2RenderingContextBase) { |
| } |
| visitor->traceWrappers(m_currentBooleanOcclusionQuery); |
| visitor->traceWrappers(m_currentTransformFeedbackPrimitivesWrittenQuery); |
| + visitor->traceWrappers(m_currentElapsedQuery); |
| for (auto& unit : m_samplerUnits) { |
| visitor->traceWrappers(unit); |
| } |
| @@ -4692,6 +4765,8 @@ void WebGL2RenderingContextBase::visitChildDOMWrappers( |
| wrapper, m_currentBooleanOcclusionQuery, isolate); |
| DOMWrapperWorld::setWrapperReferencesInAllWorlds( |
| wrapper, m_currentTransformFeedbackPrimitivesWrittenQuery, isolate); |
| + DOMWrapperWorld::setWrapperReferencesInAllWorlds( |
| + wrapper, m_currentElapsedQuery, isolate); |
| for (auto& unit : m_samplerUnits) { |
| DOMWrapperWorld::setWrapperReferencesInAllWorlds(wrapper, unit, isolate); |