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