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

Unified Diff: third_party/WebKit/Source/platform/graphics/gpu/SharedContextRateLimiter.cpp

Issue 1542283002: Adding null pointer checks to SharedContextRateLimiter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/graphics/gpu/SharedContextRateLimiter.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/gpu/SharedContextRateLimiter.cpp b/third_party/WebKit/Source/platform/graphics/gpu/SharedContextRateLimiter.cpp
index 0d5868f4712682c0727f11371ac8646ab26f7e66..3a994b1ec4a74ab0fefda07341261e996270af74 100644
--- a/third_party/WebKit/Source/platform/graphics/gpu/SharedContextRateLimiter.cpp
+++ b/third_party/WebKit/Source/platform/graphics/gpu/SharedContextRateLimiter.cpp
@@ -22,39 +22,53 @@ PassOwnPtr<SharedContextRateLimiter> SharedContextRateLimiter::create(unsigned m
SharedContextRateLimiter::SharedContextRateLimiter(unsigned maxPendingTicks)
: m_maxPendingTicks(maxPendingTicks)
+ , m_canUseSyncQueries(false)
{
m_contextProvider = adoptPtr(Platform::current()->createSharedOffscreenGraphicsContext3DProvider());
+ if (!m_contextProvider)
+ return;
+
WebGraphicsContext3D* context = m_contextProvider->context3d();
- OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context);
- // TODO(junov): when the GLES 3.0 command buffer is ready, we could use fenceSync instead
- m_canUseSyncQueries = extensionsUtil->supportsExtension("GL_CHROMIUM_sync_query");
+ if (context && !context->isContextLost()) {
+ OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context);
+ // TODO(junov): when the GLES 3.0 command buffer is ready, we could use fenceSync instead
+ m_canUseSyncQueries = extensionsUtil->supportsExtension("GL_CHROMIUM_sync_query");
+ }
}
void SharedContextRateLimiter::tick()
{
+ if (!m_contextProvider)
+ return;
+
WebGraphicsContext3D* context = m_contextProvider->context3d();
- if (context && !context->isContextLost()) {
- m_queries.append(m_canUseSyncQueries ? context->createQueryEXT() : 0);
+
+ if (!context || context->isContextLost())
+ return;
+
+ m_queries.append(m_canUseSyncQueries ? context->createQueryEXT() : 0);
+ if (m_canUseSyncQueries) {
+ context->beginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, m_queries.last());
+ context->endQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM);
+ }
+ if (m_queries.size() > m_maxPendingTicks) {
if (m_canUseSyncQueries) {
- context->beginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, m_queries.last());
- context->endQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM);
- }
- if (m_queries.size() > m_maxPendingTicks) {
- if (m_canUseSyncQueries) {
- WGC3Duint result;
- context->getQueryObjectuivEXT(m_queries.first(), GL_QUERY_RESULT_EXT, &result);
- context->deleteQueryEXT(m_queries.first());
- m_queries.removeFirst();
- } else {
- context->finish();
- reset();
- }
+ WGC3Duint result;
+ context->getQueryObjectuivEXT(m_queries.first(), GL_QUERY_RESULT_EXT, &result);
+ context->deleteQueryEXT(m_queries.first());
+ m_queries.removeFirst();
+ } else {
+ context->finish();
+ reset();
}
}
}
void SharedContextRateLimiter::reset()
{
+ if (!m_contextProvider)
+ return;
+
WebGraphicsContext3D* context = m_contextProvider->context3d();
if (context && !context->isContextLost()) {
while (m_queries.size() > 0) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698