Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: third_party/WebKit/Source/modules/webgl/EXTDisjointTimerQuery.cpp

Issue 2437233002: Implement EXT_disjoint_timer_query_webgl2 (Closed)
Patch Set: fix logic again Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 76
77 if (target != GL_TIME_ELAPSED_EXT) { 77 if (target != GL_TIME_ELAPSED_EXT) {
78 scoped.context()->synthesizeGLError(GL_INVALID_ENUM, "beginQueryEXT", 78 scoped.context()->synthesizeGLError(GL_INVALID_ENUM, "beginQueryEXT",
79 "invalid target"); 79 "invalid target");
80 return; 80 return;
81 } 81 }
82 82
83 if (m_currentElapsedQuery) { 83 if (m_currentElapsedQuery) {
84 scoped.context()->synthesizeGLError(GL_INVALID_OPERATION, "beginQueryEXT", 84 scoped.context()->synthesizeGLError(GL_INVALID_OPERATION, "beginQueryEXT",
85 "no current query"); 85 "a query is already active for target");
86 return; 86 return;
87 } 87 }
88 88
89 if (query->hasTarget() && query->target() != target) { 89 if (query->hasTarget() && query->target() != target) {
90 scoped.context()->synthesizeGLError(GL_INVALID_OPERATION, "beginQueryEXT", 90 scoped.context()->synthesizeGLError(GL_INVALID_OPERATION, "beginQueryEXT",
91 "target does not match query"); 91 "target does not match query");
92 return; 92 return;
93 } 93 }
94 94
95 scoped.context()->contextGL()->BeginQueryEXT(target, query->object()); 95 scoped.context()->contextGL()->BeginQueryEXT(target, query->object());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 query->resetCachedResult(); 149 query->resetCachedResult();
150 } 150 }
151 151
152 ScriptValue EXTDisjointTimerQuery::getQueryEXT(ScriptState* scriptState, 152 ScriptValue EXTDisjointTimerQuery::getQueryEXT(ScriptState* scriptState,
153 GLenum target, 153 GLenum target,
154 GLenum pname) { 154 GLenum pname) {
155 WebGLExtensionScopedContext scoped(this); 155 WebGLExtensionScopedContext scoped(this);
156 if (scoped.isLost()) 156 if (scoped.isLost())
157 return ScriptValue::createNull(scriptState); 157 return ScriptValue::createNull(scriptState);
158 158
159 if (target == GL_TIMESTAMP_EXT || target == GL_TIME_ELAPSED_EXT) { 159 if (pname == GL_QUERY_COUNTER_BITS_EXT) {
160 switch (pname) { 160 if (target == GL_TIMESTAMP_EXT || target == GL_TIME_ELAPSED_EXT) {
161 case GL_CURRENT_QUERY_EXT: 161 GLint value = 0;
162 if (GL_TIME_ELAPSED_EXT == target && m_currentElapsedQuery.get()) 162 scoped.context()->contextGL()->GetQueryivEXT(target, pname, &value);
163 return WebGLAny(scriptState, m_currentElapsedQuery.get()); 163 return WebGLAny(scriptState, value);
164 return ScriptValue::createNull(scriptState);
165 case GL_QUERY_COUNTER_BITS_EXT: {
166 GLint value = 0;
167 scoped.context()->contextGL()->GetQueryivEXT(target, pname, &value);
168 return WebGLAny(scriptState, value);
169 }
170 default:
171 break;
172 } 164 }
165 scoped.context()->synthesizeGLError(GL_INVALID_ENUM, "getQuery",
166 "invalid target/pname combination");
167 return ScriptValue::createNull(scriptState);
173 } 168 }
174 169
175 scoped.context()->synthesizeGLError(GL_INVALID_ENUM, "getQueryEXT", 170 if (target == GL_TIME_ELAPSED_EXT && pname == GL_CURRENT_QUERY) {
176 "invalid target or pname"); 171 return m_currentElapsedQuery ? WebGLAny(scriptState, m_currentElapsedQuery)
172 : ScriptValue::createNull(scriptState);
173 }
174
175 if (target == GL_TIMESTAMP_EXT && pname == GL_CURRENT_QUERY) {
176 return ScriptValue::createNull(scriptState);
177 }
178
179 scoped.context()->synthesizeGLError(GL_INVALID_ENUM, "getQuery",
180 "invalid target/pname combination");
177 return ScriptValue::createNull(scriptState); 181 return ScriptValue::createNull(scriptState);
178 } 182 }
179 183
180 ScriptValue EXTDisjointTimerQuery::getQueryObjectEXT(ScriptState* scriptState, 184 ScriptValue EXTDisjointTimerQuery::getQueryObjectEXT(ScriptState* scriptState,
181 WebGLTimerQueryEXT* query, 185 WebGLTimerQueryEXT* query,
182 GLenum pname) { 186 GLenum pname) {
183 WebGLExtensionScopedContext scoped(this); 187 WebGLExtensionScopedContext scoped(this);
184 if (scoped.isLost()) 188 if (scoped.isLost())
185 return ScriptValue::createNull(scriptState); 189 return ScriptValue::createNull(scriptState);
186 190
(...skipping 27 matching lines...) Expand all
214 WebGLExtension::trace(visitor); 218 WebGLExtension::trace(visitor);
215 } 219 }
216 220
217 EXTDisjointTimerQuery::EXTDisjointTimerQuery(WebGLRenderingContextBase* context) 221 EXTDisjointTimerQuery::EXTDisjointTimerQuery(WebGLRenderingContextBase* context)
218 : WebGLExtension(context) { 222 : WebGLExtension(context) {
219 context->extensionsUtil()->ensureExtensionEnabled( 223 context->extensionsUtil()->ensureExtensionEnabled(
220 "GL_EXT_disjoint_timer_query"); 224 "GL_EXT_disjoint_timer_query");
221 } 225 }
222 226
223 } // namespace blink 227 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698