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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLTimerQueryEXT.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/WebGLTimerQueryEXT.h" 5 #include "modules/webgl/WebGLTimerQueryEXT.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/WebGLRenderingContextBase.h" 9 #include "modules/webgl/WebGLRenderingContextBase.h"
10 #include "public/platform/Platform.h" 10 #include "public/platform/Platform.h"
(...skipping 11 matching lines...) Expand all
22 22
23 WebGLTimerQueryEXT::WebGLTimerQueryEXT(WebGLRenderingContextBase* ctx) 23 WebGLTimerQueryEXT::WebGLTimerQueryEXT(WebGLRenderingContextBase* ctx)
24 : WebGLContextObject(ctx), 24 : WebGLContextObject(ctx),
25 m_target(0), 25 m_target(0),
26 m_queryId(0), 26 m_queryId(0),
27 m_canUpdateAvailability(false), 27 m_canUpdateAvailability(false),
28 m_queryResultAvailable(false), 28 m_queryResultAvailable(false),
29 m_queryResult(0), 29 m_queryResult(0),
30 m_taskRunner(TaskRunnerHelper::get(TaskType::Unthrottled, 30 m_taskRunner(TaskRunnerHelper::get(TaskType::Unthrottled,
31 &ctx->canvas()->document()) 31 &ctx->canvas()->document())
32 ->clone()), 32 ->clone()) {
33 m_cancellableTaskFactory(CancellableTaskFactory::create(
34 this,
35 &WebGLTimerQueryEXT::allowAvailabilityUpdate)) {
36 context()->contextGL()->GenQueriesEXT(1, &m_queryId); 33 context()->contextGL()->GenQueriesEXT(1, &m_queryId);
37 } 34 }
38 35
39 void WebGLTimerQueryEXT::resetCachedResult() { 36 void WebGLTimerQueryEXT::resetCachedResult() {
40 m_canUpdateAvailability = false; 37 m_canUpdateAvailability = false;
41 m_queryResultAvailable = false; 38 m_queryResultAvailable = false;
42 m_queryResult = 0; 39 m_queryResult = 0;
43 // When this is called, the implication is that we should start 40 // When this is called, the implication is that we should start
44 // keeping track of whether we can update the cached availability 41 // keeping track of whether we can update the cached availability
45 // and result. 42 // and result.
(...skipping 21 matching lines...) Expand all
67 64
68 // We can only update the cached result when control returns to the browser. 65 // We can only update the cached result when control returns to the browser.
69 m_canUpdateAvailability = false; 66 m_canUpdateAvailability = false;
70 GLuint available = 0; 67 GLuint available = 0;
71 gl->GetQueryObjectuivEXT(object(), GL_QUERY_RESULT_AVAILABLE_EXT, &available); 68 gl->GetQueryObjectuivEXT(object(), GL_QUERY_RESULT_AVAILABLE_EXT, &available);
72 m_queryResultAvailable = !!available; 69 m_queryResultAvailable = !!available;
73 if (m_queryResultAvailable) { 70 if (m_queryResultAvailable) {
74 GLuint64 result = 0; 71 GLuint64 result = 0;
75 gl->GetQueryObjectui64vEXT(object(), GL_QUERY_RESULT_EXT, &result); 72 gl->GetQueryObjectui64vEXT(object(), GL_QUERY_RESULT_EXT, &result);
76 m_queryResult = result; 73 m_queryResult = result;
77 m_cancellableTaskFactory->cancel(); 74 m_taskHandle.cancel();
78 } else { 75 } else {
79 scheduleAllowAvailabilityUpdate(); 76 scheduleAllowAvailabilityUpdate();
80 } 77 }
81 } 78 }
82 79
83 bool WebGLTimerQueryEXT::isQueryResultAvailable() { 80 bool WebGLTimerQueryEXT::isQueryResultAvailable() {
84 return m_queryResultAvailable; 81 return m_queryResultAvailable;
85 } 82 }
86 83
87 GLuint64 WebGLTimerQueryEXT::getQueryResult() { 84 GLuint64 WebGLTimerQueryEXT::getQueryResult() {
88 return m_queryResult; 85 return m_queryResult;
89 } 86 }
90 87
91 void WebGLTimerQueryEXT::deleteObjectImpl(gpu::gles2::GLES2Interface* gl) { 88 void WebGLTimerQueryEXT::deleteObjectImpl(gpu::gles2::GLES2Interface* gl) {
92 gl->DeleteQueriesEXT(1, &m_queryId); 89 gl->DeleteQueriesEXT(1, &m_queryId);
93 m_queryId = 0; 90 m_queryId = 0;
94 } 91 }
95 92
96 void WebGLTimerQueryEXT::scheduleAllowAvailabilityUpdate() { 93 void WebGLTimerQueryEXT::scheduleAllowAvailabilityUpdate() {
97 if (!m_cancellableTaskFactory->isPending()) 94 if (m_taskHandle.isActive())
98 m_taskRunner->postTask(BLINK_FROM_HERE, 95 return;
99 m_cancellableTaskFactory->cancelAndCreate()); 96 m_taskHandle = m_taskRunner->postCancellableTask(
97 BLINK_FROM_HERE, WTF::bind(&WebGLTimerQueryEXT::allowAvailabilityUpdate,
98 wrapWeakPersistent(this)));
100 } 99 }
101 100
102 void WebGLTimerQueryEXT::allowAvailabilityUpdate() { 101 void WebGLTimerQueryEXT::allowAvailabilityUpdate() {
103 m_canUpdateAvailability = true; 102 m_canUpdateAvailability = true;
104 } 103 }
105 104
106 } // namespace blink 105 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLTimerQueryEXT.h ('k') | third_party/WebKit/Source/platform/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698