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

Unified Diff: third_party/WebKit/Source/modules/webgl/WebGLQuery.cpp

Issue 2341043002: webgl: Replace query task observer with a posted task (Closed)
Patch Set: Use CancellableTaskFactory instead Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/webgl/WebGLQuery.cpp
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLQuery.cpp b/third_party/WebKit/Source/modules/webgl/WebGLQuery.cpp
index 853dc0118882f0adfd286c2ea1dc569d26011d4e..e120324ac6a2317eb15ed9d672942c568821861c 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLQuery.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGLQuery.cpp
@@ -4,6 +4,7 @@
#include "modules/webgl/WebGLQuery.h"
+#include "core/dom/TaskRunnerHelper.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "modules/webgl/WebGL2RenderingContextBase.h"
#include "public/platform/Platform.h"
@@ -17,8 +18,6 @@ WebGLQuery* WebGLQuery::create(WebGL2RenderingContextBase* ctx)
WebGLQuery::~WebGLQuery()
{
- unregisterTaskObserver();
-
// See the comment in WebGLObject::detachAndDeleteObject().
detachAndDeleteObject();
}
@@ -26,10 +25,11 @@ WebGLQuery::~WebGLQuery()
WebGLQuery::WebGLQuery(WebGL2RenderingContextBase* ctx)
: WebGLSharedPlatform3DObject(ctx)
, m_target(0)
- , m_taskObserverRegistered(false)
, m_canUpdateAvailability(false)
, m_queryResultAvailable(false)
, m_queryResult(0)
+ , m_taskRunner(TaskRunnerHelper::get(TaskType::Unthrottled, &ctx->canvas()->document())->clone())
+ , m_cancellableTaskFactory(CancellableTaskFactory::create(this, &WebGLQuery::allowAvailabilityUpdate))
{
GLuint query;
ctx->contextGL()->GenQueriesEXT(1, &query);
@@ -57,7 +57,7 @@ void WebGLQuery::resetCachedResult()
// When this is called, the implication is that we should start
// keeping track of whether we can update the cached availability
// and result.
- registerTaskObserver();
+ scheduleAllowAvailabilityUpdate();
}
void WebGLQuery::updateCachedResult(gpu::gles2::GLES2Interface* gl)
@@ -80,7 +80,9 @@ void WebGLQuery::updateCachedResult(gpu::gles2::GLES2Interface* gl)
GLuint result = 0;
gl->GetQueryObjectuivEXT(object(), GL_QUERY_RESULT_EXT, &result);
m_queryResult = result;
- unregisterTaskObserver();
+ m_cancellableTaskFactory->cancel();
+ } else {
+ scheduleAllowAvailabilityUpdate();
}
}
@@ -94,23 +96,13 @@ GLuint WebGLQuery::getQueryResult()
return m_queryResult;
}
-void WebGLQuery::registerTaskObserver()
-{
- if (!m_taskObserverRegistered) {
- m_taskObserverRegistered = true;
- Platform::current()->currentThread()->addTaskObserver(this);
- }
-}
-
-void WebGLQuery::unregisterTaskObserver()
+void WebGLQuery::scheduleAllowAvailabilityUpdate()
{
- if (m_taskObserverRegistered) {
- m_taskObserverRegistered = false;
- Platform::current()->currentThread()->removeTaskObserver(this);
- }
+ if (!m_cancellableTaskFactory->isPending())
+ m_taskRunner->postTask(BLINK_FROM_HERE, m_cancellableTaskFactory->cancelAndCreate());
}
-void WebGLQuery::didProcessTask()
+void WebGLQuery::allowAvailabilityUpdate()
{
m_canUpdateAvailability = true;
}
« 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