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) { |