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

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

Issue 1325453007: Added support for EXTDisjointTimerQuery on the Blink side. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: GL_INVALID_ENUM when timer query not enabled for GetParameter, use context3d for deletion Created 5 years, 3 months 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6
7 #include "modules/webgl/EXTDisjointTimerQuery.h"
8
9 #include "bindings/modules/v8/WebGLAny.h"
10 #include "modules/webgl/WebGLRenderingContextBase.h"
11 #include "modules/webgl/WebGLTimerQueryEXT.h"
12
13 namespace blink {
14
15 EXTDisjointTimerQuery::~EXTDisjointTimerQuery()
16 {
17 }
18
19 WebGLExtensionName EXTDisjointTimerQuery::name() const
20 {
21 return EXTDisjointTimerQueryName;
22 }
23
24 EXTDisjointTimerQuery* EXTDisjointTimerQuery::create(WebGLRenderingContextBase* context)
25 {
26 EXTDisjointTimerQuery* o = new EXTDisjointTimerQuery(context);
27 return o;
28 }
29
30 bool EXTDisjointTimerQuery::supported(WebGLRenderingContextBase* context)
31 {
32 return context->extensionsUtil()->supportsExtension("GL_EXT_disjoint_timer_q uery");
33 }
34
35 const char* EXTDisjointTimerQuery::extensionName()
36 {
37 return "EXT_disjoint_timer_query";
38 }
39
40 WebGLTimerQueryEXT* EXTDisjointTimerQuery::createQueryEXT()
41 {
42 WebGLExtensionScopedContext scoped(this);
43 if (scoped.isLost())
44 return nullptr;
45
46 WebGLTimerQueryEXT* o = WebGLTimerQueryEXT::create(scoped.context());
47 scoped.context()->addContextObject(o);
48 return o;
49 }
50
51 void EXTDisjointTimerQuery::deleteQueryEXT(WebGLTimerQueryEXT* query)
52 {
53 WebGLExtensionScopedContext scoped(this);
54 if (!query || scoped.isLost())
55 return;
56 query->deleteObject(scoped.context()->webContext());
57
58 if (query == m_currentElapsedQuery)
59 m_currentElapsedQuery.clear();
60 }
61
62 GLboolean EXTDisjointTimerQuery::isQueryEXT(WebGLTimerQueryEXT* query)
63 {
64 WebGLExtensionScopedContext scoped(this);
65 if (!query || scoped.isLost() || query->isDeleted() || !query->validate(0, s coped.context())) {
66 return false;
67 }
68
69 return scoped.context()->webContext()->isQueryEXT(query->object());
70 }
71
72 void EXTDisjointTimerQuery::beginQueryEXT(GLenum target, WebGLTimerQueryEXT* que ry)
73 {
74 WebGLExtensionScopedContext scoped(this);
75 if (scoped.isLost())
76 return;
77
78 if (!query || query->isDeleted() || !query->validate(0, scoped.context())) {
79 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION);
80 return;
81 }
82
83 if (target != GL_TIME_ELAPSED_EXT) {
84 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM);
85 return;
86 }
87
88 if (m_currentElapsedQuery.get()) {
89 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION);
90 return;
91 }
92
93 if (query->hasTarget() && query->target() != target) {
94 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION);
95 return;
96 }
97
98 scoped.context()->webContext()->beginQueryEXT(target, query->object());
99 query->setTarget(target);
100 m_currentElapsedQuery = query;
101 }
102
103 void EXTDisjointTimerQuery::endQueryEXT(GLenum target)
104 {
105 WebGLExtensionScopedContext scoped(this);
106 if (scoped.isLost())
107 return;
108
109 if (target != GL_TIME_ELAPSED_EXT) {
110 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM);
111 return;
112 }
113
114 if (!m_currentElapsedQuery) {
115 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION);
116 return;
117 }
118
119 scoped.context()->webContext()->endQueryEXT(target);
120 m_currentElapsedQuery.clear();
121 }
122
123 void EXTDisjointTimerQuery::queryCounterEXT(WebGLTimerQueryEXT* query, GLenum ta rget)
124 {
125 WebGLExtensionScopedContext scoped(this);
126 if (scoped.isLost())
127 return;
128
129 if (!query || query->isDeleted() || !query->validate(0, scoped.context())) {
130 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION);
131 return;
132 }
133
134 if (target != GL_TIMESTAMP_EXT) {
135 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM);
136 return;
137 }
138
139 if (query->hasTarget() && query->target() != target) {
140 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION);
141 return;
142 }
143
144 scoped.context()->webContext()->queryCounterEXT(query->object(), target);
145 query->setTarget(target);
146 }
147
148 ScriptValue EXTDisjointTimerQuery::getQueryEXT(ScriptState* scriptState, GLenum target, GLenum pname)
149 {
150 WebGLExtensionScopedContext scoped(this);
151 if (scoped.isLost())
152 return ScriptValue::createNull(scriptState);
153
154 if (target == GL_TIMESTAMP_EXT || target == GL_TIME_ELAPSED_EXT) {
155 switch (pname) {
156 case GL_CURRENT_QUERY_EXT:
157 if (GL_TIME_ELAPSED_EXT == target && m_currentElapsedQuery.get())
158 return WebGLAny(scriptState, m_currentElapsedQuery.get());
159 return ScriptValue::createNull(scriptState);
160 case GL_QUERY_COUNTER_BITS_EXT: {
161 GLint value = 0;
162 scoped.context()->webContext()->getQueryivEXT(target, pname, &value) ;
163 return WebGLAny(scriptState, value);
164 }
165 default:
166 break;
167 }
168 }
169
170 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM);
171 return ScriptValue::createNull(scriptState);
172 }
173
174 ScriptValue EXTDisjointTimerQuery::getQueryObjectEXT(ScriptState* scriptState, W ebGLTimerQueryEXT* query, GLenum pname)
175 {
176 WebGLExtensionScopedContext scoped(this);
177 if (scoped.isLost())
178 return ScriptValue::createNull(scriptState);
179
180 if (!query || query->isDeleted() || !query->validate(0, scoped.context())) {
181 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION);
182 return ScriptValue::createNull(scriptState);
183 }
184
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) {
188 case GL_QUERY_RESULT_EXT: {
189 GLuint64 result = 0;
190 scoped.context()->webContext()->getQueryObjectui64vEXT(query->object(), pname, &result);
191 return WebGLAny(scriptState, result);
192 }
193 case GL_QUERY_RESULT_AVAILABLE_EXT: {
194 GLuint available = 0;
195 scoped.context()->webContext()->getQueryObjectuivEXT(query->object(), pn ame, &available);
196 return WebGLAny(scriptState, !!available);
197 }
198 default:
199 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM);
200 break;
201 }
202
203 return ScriptValue::createNull(scriptState);
204 }
205
206 DEFINE_TRACE(EXTDisjointTimerQuery)
207 {
208 visitor->trace(m_currentElapsedQuery);
209 WebGLExtension::trace(visitor);
210 }
211
212 EXTDisjointTimerQuery::EXTDisjointTimerQuery(WebGLRenderingContextBase* context)
213 : WebGLExtension(context)
214 {
215 context->extensionsUtil()->ensureExtensionEnabled("GL_EXT_disjoint_timer_que ry");
216 }
217
218 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/webgl/EXTDisjointTimerQuery.h ('k') | Source/modules/webgl/EXTDisjointTimerQuery.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698