Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "modules/webgl/EXTDisjointTimerQuery.h" | 7 #include "modules/webgl/EXTDisjointTimerQuery.h" |
| 8 | 8 |
| 9 #include "bindings/modules/v8/WebGLAny.h" | 9 #include "bindings/modules/v8/WebGLAny.h" |
| 10 #include "modules/webgl/WebGLRenderingContextBase.h" | 10 #include "modules/webgl/WebGLRenderingContextBase.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 return; | 90 return; |
| 91 } | 91 } |
| 92 | 92 |
| 93 if (query->hasTarget() && query->target() != target) { | 93 if (query->hasTarget() && query->target() != target) { |
| 94 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); | 94 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); |
| 95 return; | 95 return; |
| 96 } | 96 } |
| 97 | 97 |
| 98 scoped.context()->webContext()->beginQueryEXT(target, query->object()); | 98 scoped.context()->webContext()->beginQueryEXT(target, query->object()); |
| 99 query->setTarget(target); | 99 query->setTarget(target); |
| 100 m_currentElapsedQuery = query; | 100 m_currentElapsedQuery = query; |
|
David Yen
2015/10/05 17:23:16
We also need to reset the cache results here so we
Ken Russell (switch to Gerrit)
2015/10/05 23:17:59
I'm not sure about that. The ES 3.0 spec says abou
David Yen
2015/10/05 23:36:30
I think you are right about when the query result
| |
| 101 } | 101 } |
| 102 | 102 |
| 103 void EXTDisjointTimerQuery::endQueryEXT(GLenum target) | 103 void EXTDisjointTimerQuery::endQueryEXT(GLenum target) |
| 104 { | 104 { |
| 105 WebGLExtensionScopedContext scoped(this); | 105 WebGLExtensionScopedContext scoped(this); |
| 106 if (scoped.isLost()) | 106 if (scoped.isLost()) |
| 107 return; | 107 return; |
| 108 | 108 |
| 109 if (target != GL_TIME_ELAPSED_EXT) { | 109 if (target != GL_TIME_ELAPSED_EXT) { |
| 110 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); | 110 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); |
| 111 return; | 111 return; |
| 112 } | 112 } |
| 113 | 113 |
| 114 if (!m_currentElapsedQuery) { | 114 if (!m_currentElapsedQuery) { |
| 115 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); | 115 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); |
| 116 return; | 116 return; |
| 117 } | 117 } |
| 118 | 118 |
| 119 scoped.context()->webContext()->endQueryEXT(target); | 119 scoped.context()->webContext()->endQueryEXT(target); |
| 120 m_currentElapsedQuery->resetCachedResult(); | |
| 120 m_currentElapsedQuery.clear(); | 121 m_currentElapsedQuery.clear(); |
| 121 } | 122 } |
| 122 | 123 |
| 123 void EXTDisjointTimerQuery::queryCounterEXT(WebGLTimerQueryEXT* query, GLenum ta rget) | 124 void EXTDisjointTimerQuery::queryCounterEXT(WebGLTimerQueryEXT* query, GLenum ta rget) |
| 124 { | 125 { |
| 125 WebGLExtensionScopedContext scoped(this); | 126 WebGLExtensionScopedContext scoped(this); |
| 126 if (scoped.isLost()) | 127 if (scoped.isLost()) |
| 127 return; | 128 return; |
| 128 | 129 |
| 129 if (!query || query->isDeleted() || !query->validate(0, scoped.context())) { | 130 if (!query || query->isDeleted() || !query->validate(0, scoped.context())) { |
| 130 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); | 131 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); |
| 131 return; | 132 return; |
| 132 } | 133 } |
| 133 | 134 |
| 134 if (target != GL_TIMESTAMP_EXT) { | 135 if (target != GL_TIMESTAMP_EXT) { |
| 135 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); | 136 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); |
| 136 return; | 137 return; |
| 137 } | 138 } |
| 138 | 139 |
| 139 if (query->hasTarget() && query->target() != target) { | 140 if (query->hasTarget() && query->target() != target) { |
| 140 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); | 141 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); |
| 141 return; | 142 return; |
| 142 } | 143 } |
| 143 | 144 |
| 144 scoped.context()->webContext()->queryCounterEXT(query->object(), target); | 145 scoped.context()->webContext()->queryCounterEXT(query->object(), target); |
| 145 query->setTarget(target); | 146 query->setTarget(target); |
| 147 query->resetCachedResult(); | |
| 146 } | 148 } |
| 147 | 149 |
| 148 ScriptValue EXTDisjointTimerQuery::getQueryEXT(ScriptState* scriptState, GLenum target, GLenum pname) | 150 ScriptValue EXTDisjointTimerQuery::getQueryEXT(ScriptState* scriptState, GLenum target, GLenum pname) |
| 149 { | 151 { |
| 150 WebGLExtensionScopedContext scoped(this); | 152 WebGLExtensionScopedContext scoped(this); |
| 151 if (scoped.isLost()) | 153 if (scoped.isLost()) |
| 152 return ScriptValue::createNull(scriptState); | 154 return ScriptValue::createNull(scriptState); |
| 153 | 155 |
| 154 if (target == GL_TIMESTAMP_EXT || target == GL_TIME_ELAPSED_EXT) { | 156 if (target == GL_TIMESTAMP_EXT || target == GL_TIME_ELAPSED_EXT) { |
| 155 switch (pname) { | 157 switch (pname) { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 170 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); | 172 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); |
| 171 return ScriptValue::createNull(scriptState); | 173 return ScriptValue::createNull(scriptState); |
| 172 } | 174 } |
| 173 | 175 |
| 174 ScriptValue EXTDisjointTimerQuery::getQueryObjectEXT(ScriptState* scriptState, W ebGLTimerQueryEXT* query, GLenum pname) | 176 ScriptValue EXTDisjointTimerQuery::getQueryObjectEXT(ScriptState* scriptState, W ebGLTimerQueryEXT* query, GLenum pname) |
| 175 { | 177 { |
| 176 WebGLExtensionScopedContext scoped(this); | 178 WebGLExtensionScopedContext scoped(this); |
| 177 if (scoped.isLost()) | 179 if (scoped.isLost()) |
| 178 return ScriptValue::createNull(scriptState); | 180 return ScriptValue::createNull(scriptState); |
| 179 | 181 |
| 180 if (!query || query->isDeleted() || !query->validate(0, scoped.context())) { | 182 if (!query || query->isDeleted() || !query->validate(0, scoped.context())) { |
|
David Yen
2015/10/05 23:36:30
It looks like we can just add the m_currentElapsed
Ken Russell (switch to Gerrit)
2015/10/06 00:08:17
Thanks. Fixed in the current patch set. Tested wit
| |
| 181 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); | 183 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); |
| 182 return ScriptValue::createNull(scriptState); | 184 return ScriptValue::createNull(scriptState); |
| 183 } | 185 } |
| 184 | 186 |
| 185 // TODO(kbr): Per the spec, figure out a way to only update this value once | |
| 186 // the current frame has completed rendering. | |
| 187 switch (pname) { | 187 switch (pname) { |
| 188 case GL_QUERY_RESULT_EXT: { | 188 case GL_QUERY_RESULT_EXT: { |
| 189 GLuint64 result = 0; | 189 query->updateCachedResult(scoped.context()->webContext()); |
| 190 scoped.context()->webContext()->getQueryObjectui64vEXT(query->object(), pname, &result); | 190 return WebGLAny(scriptState, query->getQueryResult()); |
| 191 return WebGLAny(scriptState, result); | |
| 192 } | 191 } |
| 193 case GL_QUERY_RESULT_AVAILABLE_EXT: { | 192 case GL_QUERY_RESULT_AVAILABLE_EXT: { |
| 194 GLuint available = 0; | 193 query->updateCachedResult(scoped.context()->webContext()); |
| 195 scoped.context()->webContext()->getQueryObjectuivEXT(query->object(), pn ame, &available); | 194 return WebGLAny(scriptState, query->isQueryResultAvailable()); |
| 196 return WebGLAny(scriptState, !!available); | |
| 197 } | 195 } |
| 198 default: | 196 default: |
| 199 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); | 197 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); |
| 200 break; | 198 break; |
| 201 } | 199 } |
| 202 | 200 |
| 203 return ScriptValue::createNull(scriptState); | 201 return ScriptValue::createNull(scriptState); |
| 204 } | 202 } |
| 205 | 203 |
| 206 DEFINE_TRACE(EXTDisjointTimerQuery) | 204 DEFINE_TRACE(EXTDisjointTimerQuery) |
| 207 { | 205 { |
| 208 visitor->trace(m_currentElapsedQuery); | 206 visitor->trace(m_currentElapsedQuery); |
| 209 WebGLExtension::trace(visitor); | 207 WebGLExtension::trace(visitor); |
| 210 } | 208 } |
| 211 | 209 |
| 212 EXTDisjointTimerQuery::EXTDisjointTimerQuery(WebGLRenderingContextBase* context) | 210 EXTDisjointTimerQuery::EXTDisjointTimerQuery(WebGLRenderingContextBase* context) |
| 213 : WebGLExtension(context) | 211 : WebGLExtension(context) |
| 214 { | 212 { |
| 215 context->extensionsUtil()->ensureExtensionEnabled("GL_EXT_disjoint_timer_que ry"); | 213 context->extensionsUtil()->ensureExtensionEnabled("GL_EXT_disjoint_timer_que ry"); |
| 216 } | 214 } |
| 217 | 215 |
| 218 } // namespace blink | 216 } // namespace blink |
| OLD | NEW |