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

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

Issue 1385793002: Only make timer queries' results available when control returns to browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed review feedback from dyen. Created 5 years, 2 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
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLTimerQueryEXT.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webgl/WebGLTimerQueryEXT.cpp
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLTimerQueryEXT.cpp b/third_party/WebKit/Source/modules/webgl/WebGLTimerQueryEXT.cpp
index e61cb6e066560f5ad98fc985db550eec99a4a468..2557991243f893e85d09a798ee7d1d9a3e907a97 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLTimerQueryEXT.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGLTimerQueryEXT.cpp
@@ -7,6 +7,7 @@
#include "modules/webgl/WebGLTimerQueryEXT.h"
#include "modules/webgl/WebGLRenderingContextBase.h"
+#include "public/platform/Platform.h"
namespace blink {
@@ -17,6 +18,8 @@ WebGLTimerQueryEXT* WebGLTimerQueryEXT::create(WebGLRenderingContextBase* ctx)
WebGLTimerQueryEXT::~WebGLTimerQueryEXT()
{
+ unregisterTaskObserver();
+
// See the comment in WebGLObject::detachAndDeleteObject().
detachAndDeleteObject();
}
@@ -25,14 +28,84 @@ WebGLTimerQueryEXT::WebGLTimerQueryEXT(WebGLRenderingContextBase* ctx)
: WebGLContextObject(ctx)
, m_target(0)
, m_queryId(0)
+ , m_taskObserverRegistered(false)
+ , m_canUpdateAvailability(false)
+ , m_queryResultAvailable(false)
+ , m_queryResult(0)
{
m_queryId = context()->webContext()->createQueryEXT();
}
+void WebGLTimerQueryEXT::resetCachedResult()
+{
+ m_canUpdateAvailability = false;
+ m_queryResultAvailable = false;
+ m_queryResult = 0;
+ // When this is called, the implication is that we should start
+ // keeping track of whether we can update the cached availability
+ // and result.
+ registerTaskObserver();
+}
+
+void WebGLTimerQueryEXT::updateCachedResult(WebGraphicsContext3D* ctx)
+{
+ if (m_queryResultAvailable)
+ return;
+
+ if (!m_canUpdateAvailability)
+ return;
+
+ if (!hasTarget())
+ return;
+
+ // We can only update the cached result when control returns to the browser.
+ m_canUpdateAvailability = false;
+ GLuint available = 0;
+ ctx->getQueryObjectuivEXT(object(), GL_QUERY_RESULT_AVAILABLE_EXT, &available);
+ m_queryResultAvailable = !!available;
+ if (m_queryResultAvailable) {
+ GLuint64 result = 0;
+ ctx->getQueryObjectui64vEXT(object(), GL_QUERY_RESULT_EXT, &result);
+ m_queryResult = result;
+ unregisterTaskObserver();
+ }
+}
+
+bool WebGLTimerQueryEXT::isQueryResultAvailable()
+{
+ return m_queryResultAvailable;
+}
+
+GLuint64 WebGLTimerQueryEXT::getQueryResult()
+{
+ return m_queryResult;
+}
+
void WebGLTimerQueryEXT::deleteObjectImpl(WebGraphicsContext3D* context3d)
{
context3d->deleteQueryEXT(m_queryId);
m_queryId = 0;
}
+void WebGLTimerQueryEXT::registerTaskObserver()
+{
+ if (!m_taskObserverRegistered) {
+ m_taskObserverRegistered = true;
+ Platform::current()->currentThread()->addTaskObserver(this);
+ }
+}
+
+void WebGLTimerQueryEXT::unregisterTaskObserver()
+{
+ if (m_taskObserverRegistered) {
+ m_taskObserverRegistered = false;
+ Platform::current()->currentThread()->removeTaskObserver(this);
+ }
+}
+
+void WebGLTimerQueryEXT::didProcessTask()
+{
+ m_canUpdateAvailability = true;
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLTimerQueryEXT.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698