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

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

Issue 2514733002: Scheduler: Deprecate CancellableTaskFactory in favor of WebTaskRunner::postCancellableTask (3) (Closed)
Patch Set: rebase Created 4 years 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/WebGLQuery.h" 5 #include "modules/webgl/WebGLQuery.h"
6 6
7 #include "core/dom/TaskRunnerHelper.h" 7 #include "core/dom/TaskRunnerHelper.h"
8 #include "gpu/command_buffer/client/gles2_interface.h" 8 #include "gpu/command_buffer/client/gles2_interface.h"
9 #include "modules/webgl/WebGL2RenderingContextBase.h" 9 #include "modules/webgl/WebGL2RenderingContextBase.h"
10 #include "public/platform/Platform.h" 10 #include "public/platform/Platform.h"
(...skipping 10 matching lines...) Expand all
21 } 21 }
22 22
23 WebGLQuery::WebGLQuery(WebGL2RenderingContextBase* ctx) 23 WebGLQuery::WebGLQuery(WebGL2RenderingContextBase* ctx)
24 : WebGLSharedPlatform3DObject(ctx), 24 : WebGLSharedPlatform3DObject(ctx),
25 m_target(0), 25 m_target(0),
26 m_canUpdateAvailability(false), 26 m_canUpdateAvailability(false),
27 m_queryResultAvailable(false), 27 m_queryResultAvailable(false),
28 m_queryResult(0), 28 m_queryResult(0),
29 m_taskRunner(TaskRunnerHelper::get(TaskType::Unthrottled, 29 m_taskRunner(TaskRunnerHelper::get(TaskType::Unthrottled,
30 &ctx->canvas()->document()) 30 &ctx->canvas()->document())
31 ->clone()), 31 ->clone()) {
32 m_cancellableTaskFactory(CancellableTaskFactory::create(
33 this,
34 &WebGLQuery::allowAvailabilityUpdate)) {
35 GLuint query; 32 GLuint query;
36 ctx->contextGL()->GenQueriesEXT(1, &query); 33 ctx->contextGL()->GenQueriesEXT(1, &query);
37 setObject(query); 34 setObject(query);
38 } 35 }
39 36
40 void WebGLQuery::setTarget(GLenum target) { 37 void WebGLQuery::setTarget(GLenum target) {
41 ASSERT(object()); 38 ASSERT(object());
42 ASSERT(!m_target); 39 ASSERT(!m_target);
43 m_target = target; 40 m_target = target;
44 } 41 }
(...skipping 25 matching lines...) Expand all
70 67
71 // We can only update the cached result when control returns to the browser. 68 // We can only update the cached result when control returns to the browser.
72 m_canUpdateAvailability = false; 69 m_canUpdateAvailability = false;
73 GLuint available = 0; 70 GLuint available = 0;
74 gl->GetQueryObjectuivEXT(object(), GL_QUERY_RESULT_AVAILABLE_EXT, &available); 71 gl->GetQueryObjectuivEXT(object(), GL_QUERY_RESULT_AVAILABLE_EXT, &available);
75 m_queryResultAvailable = !!available; 72 m_queryResultAvailable = !!available;
76 if (m_queryResultAvailable) { 73 if (m_queryResultAvailable) {
77 GLuint result = 0; 74 GLuint result = 0;
78 gl->GetQueryObjectuivEXT(object(), GL_QUERY_RESULT_EXT, &result); 75 gl->GetQueryObjectuivEXT(object(), GL_QUERY_RESULT_EXT, &result);
79 m_queryResult = result; 76 m_queryResult = result;
80 m_cancellableTaskFactory->cancel(); 77 m_taskHandle.cancel();
81 } else { 78 } else {
82 scheduleAllowAvailabilityUpdate(); 79 scheduleAllowAvailabilityUpdate();
83 } 80 }
84 } 81 }
85 82
86 bool WebGLQuery::isQueryResultAvailable() { 83 bool WebGLQuery::isQueryResultAvailable() {
87 return m_queryResultAvailable; 84 return m_queryResultAvailable;
88 } 85 }
89 86
90 GLuint WebGLQuery::getQueryResult() { 87 GLuint WebGLQuery::getQueryResult() {
91 return m_queryResult; 88 return m_queryResult;
92 } 89 }
93 90
94 void WebGLQuery::scheduleAllowAvailabilityUpdate() { 91 void WebGLQuery::scheduleAllowAvailabilityUpdate() {
95 if (!m_cancellableTaskFactory->isPending()) 92 if (m_taskHandle.isActive())
96 m_taskRunner->postTask(BLINK_FROM_HERE, 93 return;
97 m_cancellableTaskFactory->cancelAndCreate()); 94 m_taskHandle = m_taskRunner->postCancellableTask(
95 BLINK_FROM_HERE, WTF::bind(&WebGLQuery::allowAvailabilityUpdate,
96 wrapWeakPersistent(this)));
98 } 97 }
99 98
100 void WebGLQuery::allowAvailabilityUpdate() { 99 void WebGLQuery::allowAvailabilityUpdate() {
101 m_canUpdateAvailability = true; 100 m_canUpdateAvailability = true;
102 } 101 }
103 102
104 } // namespace blink 103 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLQuery.h ('k') | third_party/WebKit/Source/modules/webgl/WebGLTimerQueryEXT.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698