| 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 "modules/webgl/EXTDisjointTimerQuery.h" | 5 #include "modules/webgl/EXTDisjointTimerQuery.h" |
| 6 | 6 |
| 7 #include "bindings/modules/v8/WebGLAny.h" | 7 #include "bindings/modules/v8/WebGLAny.h" |
| 8 #include "gpu/command_buffer/client/gles2_interface.h" |
| 8 #include "modules/webgl/WebGLRenderingContextBase.h" | 9 #include "modules/webgl/WebGLRenderingContextBase.h" |
| 9 #include "modules/webgl/WebGLTimerQueryEXT.h" | 10 #include "modules/webgl/WebGLTimerQueryEXT.h" |
| 10 | 11 |
| 11 namespace blink { | 12 namespace blink { |
| 12 | 13 |
| 13 EXTDisjointTimerQuery::~EXTDisjointTimerQuery() | 14 EXTDisjointTimerQuery::~EXTDisjointTimerQuery() |
| 14 { | 15 { |
| 15 } | 16 } |
| 16 | 17 |
| 17 WebGLExtensionName EXTDisjointTimerQuery::name() const | 18 WebGLExtensionName EXTDisjointTimerQuery::name() const |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 m_currentElapsedQuery.clear(); | 58 m_currentElapsedQuery.clear(); |
| 58 } | 59 } |
| 59 | 60 |
| 60 GLboolean EXTDisjointTimerQuery::isQueryEXT(WebGLTimerQueryEXT* query) | 61 GLboolean EXTDisjointTimerQuery::isQueryEXT(WebGLTimerQueryEXT* query) |
| 61 { | 62 { |
| 62 WebGLExtensionScopedContext scoped(this); | 63 WebGLExtensionScopedContext scoped(this); |
| 63 if (!query || scoped.isLost() || query->isDeleted() || !query->validate(0, s
coped.context())) { | 64 if (!query || scoped.isLost() || query->isDeleted() || !query->validate(0, s
coped.context())) { |
| 64 return false; | 65 return false; |
| 65 } | 66 } |
| 66 | 67 |
| 67 return scoped.context()->webContext()->isQueryEXT(query->object()); | 68 return scoped.context()->contextGL()->IsQueryEXT(query->object()); |
| 68 } | 69 } |
| 69 | 70 |
| 70 void EXTDisjointTimerQuery::beginQueryEXT(GLenum target, WebGLTimerQueryEXT* que
ry) | 71 void EXTDisjointTimerQuery::beginQueryEXT(GLenum target, WebGLTimerQueryEXT* que
ry) |
| 71 { | 72 { |
| 72 WebGLExtensionScopedContext scoped(this); | 73 WebGLExtensionScopedContext scoped(this); |
| 73 if (scoped.isLost()) | 74 if (scoped.isLost()) |
| 74 return; | 75 return; |
| 75 | 76 |
| 76 if (!query || query->isDeleted() || !query->validate(0, scoped.context())) { | 77 if (!query || query->isDeleted() || !query->validate(0, scoped.context())) { |
| 77 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); | 78 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); |
| 78 return; | 79 return; |
| 79 } | 80 } |
| 80 | 81 |
| 81 if (target != GL_TIME_ELAPSED_EXT) { | 82 if (target != GL_TIME_ELAPSED_EXT) { |
| 82 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); | 83 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); |
| 83 return; | 84 return; |
| 84 } | 85 } |
| 85 | 86 |
| 86 if (m_currentElapsedQuery.get()) { | 87 if (m_currentElapsedQuery.get()) { |
| 87 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); | 88 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); |
| 88 return; | 89 return; |
| 89 } | 90 } |
| 90 | 91 |
| 91 if (query->hasTarget() && query->target() != target) { | 92 if (query->hasTarget() && query->target() != target) { |
| 92 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); | 93 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); |
| 93 return; | 94 return; |
| 94 } | 95 } |
| 95 | 96 |
| 96 scoped.context()->webContext()->beginQueryEXT(target, query->object()); | 97 scoped.context()->contextGL()->BeginQueryEXT(target, query->object()); |
| 97 query->setTarget(target); | 98 query->setTarget(target); |
| 98 m_currentElapsedQuery = query; | 99 m_currentElapsedQuery = query; |
| 99 } | 100 } |
| 100 | 101 |
| 101 void EXTDisjointTimerQuery::endQueryEXT(GLenum target) | 102 void EXTDisjointTimerQuery::endQueryEXT(GLenum target) |
| 102 { | 103 { |
| 103 WebGLExtensionScopedContext scoped(this); | 104 WebGLExtensionScopedContext scoped(this); |
| 104 if (scoped.isLost()) | 105 if (scoped.isLost()) |
| 105 return; | 106 return; |
| 106 | 107 |
| 107 if (target != GL_TIME_ELAPSED_EXT) { | 108 if (target != GL_TIME_ELAPSED_EXT) { |
| 108 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); | 109 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); |
| 109 return; | 110 return; |
| 110 } | 111 } |
| 111 | 112 |
| 112 if (!m_currentElapsedQuery) { | 113 if (!m_currentElapsedQuery) { |
| 113 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); | 114 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); |
| 114 return; | 115 return; |
| 115 } | 116 } |
| 116 | 117 |
| 117 scoped.context()->webContext()->endQueryEXT(target); | 118 scoped.context()->contextGL()->EndQueryEXT(target); |
| 118 m_currentElapsedQuery->resetCachedResult(); | 119 m_currentElapsedQuery->resetCachedResult(); |
| 119 m_currentElapsedQuery.clear(); | 120 m_currentElapsedQuery.clear(); |
| 120 } | 121 } |
| 121 | 122 |
| 122 void EXTDisjointTimerQuery::queryCounterEXT(WebGLTimerQueryEXT* query, GLenum ta
rget) | 123 void EXTDisjointTimerQuery::queryCounterEXT(WebGLTimerQueryEXT* query, GLenum ta
rget) |
| 123 { | 124 { |
| 124 WebGLExtensionScopedContext scoped(this); | 125 WebGLExtensionScopedContext scoped(this); |
| 125 if (scoped.isLost()) | 126 if (scoped.isLost()) |
| 126 return; | 127 return; |
| 127 | 128 |
| 128 if (!query || query->isDeleted() || !query->validate(0, scoped.context())) { | 129 if (!query || query->isDeleted() || !query->validate(0, scoped.context())) { |
| 129 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); | 130 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); |
| 130 return; | 131 return; |
| 131 } | 132 } |
| 132 | 133 |
| 133 if (target != GL_TIMESTAMP_EXT) { | 134 if (target != GL_TIMESTAMP_EXT) { |
| 134 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); | 135 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); |
| 135 return; | 136 return; |
| 136 } | 137 } |
| 137 | 138 |
| 138 if (query->hasTarget() && query->target() != target) { | 139 if (query->hasTarget() && query->target() != target) { |
| 139 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); | 140 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); |
| 140 return; | 141 return; |
| 141 } | 142 } |
| 142 | 143 |
| 143 scoped.context()->webContext()->queryCounterEXT(query->object(), target); | 144 scoped.context()->contextGL()->QueryCounterEXT(query->object(), target); |
| 144 query->setTarget(target); | 145 query->setTarget(target); |
| 145 query->resetCachedResult(); | 146 query->resetCachedResult(); |
| 146 } | 147 } |
| 147 | 148 |
| 148 ScriptValue EXTDisjointTimerQuery::getQueryEXT(ScriptState* scriptState, GLenum
target, GLenum pname) | 149 ScriptValue EXTDisjointTimerQuery::getQueryEXT(ScriptState* scriptState, GLenum
target, GLenum pname) |
| 149 { | 150 { |
| 150 WebGLExtensionScopedContext scoped(this); | 151 WebGLExtensionScopedContext scoped(this); |
| 151 if (scoped.isLost()) | 152 if (scoped.isLost()) |
| 152 return ScriptValue::createNull(scriptState); | 153 return ScriptValue::createNull(scriptState); |
| 153 | 154 |
| 154 if (target == GL_TIMESTAMP_EXT || target == GL_TIME_ELAPSED_EXT) { | 155 if (target == GL_TIMESTAMP_EXT || target == GL_TIME_ELAPSED_EXT) { |
| 155 switch (pname) { | 156 switch (pname) { |
| 156 case GL_CURRENT_QUERY_EXT: | 157 case GL_CURRENT_QUERY_EXT: |
| 157 if (GL_TIME_ELAPSED_EXT == target && m_currentElapsedQuery.get()) | 158 if (GL_TIME_ELAPSED_EXT == target && m_currentElapsedQuery.get()) |
| 158 return WebGLAny(scriptState, m_currentElapsedQuery.get()); | 159 return WebGLAny(scriptState, m_currentElapsedQuery.get()); |
| 159 return ScriptValue::createNull(scriptState); | 160 return ScriptValue::createNull(scriptState); |
| 160 case GL_QUERY_COUNTER_BITS_EXT: { | 161 case GL_QUERY_COUNTER_BITS_EXT: { |
| 161 GLint value = 0; | 162 GLint value = 0; |
| 162 scoped.context()->webContext()->getQueryivEXT(target, pname, &value)
; | 163 scoped.context()->contextGL()->GetQueryivEXT(target, pname, &value); |
| 163 return WebGLAny(scriptState, value); | 164 return WebGLAny(scriptState, value); |
| 164 } | 165 } |
| 165 default: | 166 default: |
| 166 break; | 167 break; |
| 167 } | 168 } |
| 168 } | 169 } |
| 169 | 170 |
| 170 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); | 171 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); |
| 171 return ScriptValue::createNull(scriptState); | 172 return ScriptValue::createNull(scriptState); |
| 172 } | 173 } |
| 173 | 174 |
| 174 ScriptValue EXTDisjointTimerQuery::getQueryObjectEXT(ScriptState* scriptState, W
ebGLTimerQueryEXT* query, GLenum pname) | 175 ScriptValue EXTDisjointTimerQuery::getQueryObjectEXT(ScriptState* scriptState, W
ebGLTimerQueryEXT* query, GLenum pname) |
| 175 { | 176 { |
| 176 WebGLExtensionScopedContext scoped(this); | 177 WebGLExtensionScopedContext scoped(this); |
| 177 if (scoped.isLost()) | 178 if (scoped.isLost()) |
| 178 return ScriptValue::createNull(scriptState); | 179 return ScriptValue::createNull(scriptState); |
| 179 | 180 |
| 180 if (!query || query->isDeleted() || !query->validate(0, scoped.context()) ||
m_currentElapsedQuery == query) { | 181 if (!query || query->isDeleted() || !query->validate(0, scoped.context()) ||
m_currentElapsedQuery == query) { |
| 181 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); | 182 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); |
| 182 return ScriptValue::createNull(scriptState); | 183 return ScriptValue::createNull(scriptState); |
| 183 } | 184 } |
| 184 | 185 |
| 185 switch (pname) { | 186 switch (pname) { |
| 186 case GL_QUERY_RESULT_EXT: { | 187 case GL_QUERY_RESULT_EXT: { |
| 187 query->updateCachedResult(scoped.context()->webContext()); | 188 query->updateCachedResult(scoped.context()->contextGL()); |
| 188 return WebGLAny(scriptState, query->getQueryResult()); | 189 return WebGLAny(scriptState, query->getQueryResult()); |
| 189 } | 190 } |
| 190 case GL_QUERY_RESULT_AVAILABLE_EXT: { | 191 case GL_QUERY_RESULT_AVAILABLE_EXT: { |
| 191 query->updateCachedResult(scoped.context()->webContext()); | 192 query->updateCachedResult(scoped.context()->contextGL()); |
| 192 return WebGLAny(scriptState, query->isQueryResultAvailable()); | 193 return WebGLAny(scriptState, query->isQueryResultAvailable()); |
| 193 } | 194 } |
| 194 default: | 195 default: |
| 195 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); | 196 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); |
| 196 break; | 197 break; |
| 197 } | 198 } |
| 198 | 199 |
| 199 return ScriptValue::createNull(scriptState); | 200 return ScriptValue::createNull(scriptState); |
| 200 } | 201 } |
| 201 | 202 |
| 202 DEFINE_TRACE(EXTDisjointTimerQuery) | 203 DEFINE_TRACE(EXTDisjointTimerQuery) |
| 203 { | 204 { |
| 204 visitor->trace(m_currentElapsedQuery); | 205 visitor->trace(m_currentElapsedQuery); |
| 205 WebGLExtension::trace(visitor); | 206 WebGLExtension::trace(visitor); |
| 206 } | 207 } |
| 207 | 208 |
| 208 EXTDisjointTimerQuery::EXTDisjointTimerQuery(WebGLRenderingContextBase* context) | 209 EXTDisjointTimerQuery::EXTDisjointTimerQuery(WebGLRenderingContextBase* context) |
| 209 : WebGLExtension(context) | 210 : WebGLExtension(context) |
| 210 { | 211 { |
| 211 context->extensionsUtil()->ensureExtensionEnabled("GL_EXT_disjoint_timer_que
ry"); | 212 context->extensionsUtil()->ensureExtensionEnabled("GL_EXT_disjoint_timer_que
ry"); |
| 212 } | 213 } |
| 213 | 214 |
| 214 } // namespace blink | 215 } // namespace blink |
| OLD | NEW |