Index: cc/layer_tree_host_impl.cc |
diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc |
index 5675aba5d41e0d1de80352007ae649aba787fe42..9c115cc052b756ea7b93753120552195e984f1d4 100644 |
--- a/cc/layer_tree_host_impl.cc |
+++ b/cc/layer_tree_host_impl.cc |
@@ -199,13 +199,14 @@ LayerTreeHostImpl::FrameData::~FrameData() |
{ |
} |
-scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::create(const LayerTreeSettings& settings, LayerTreeHostImplClient* client) |
+scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::create(const LayerTreeSettings& settings, LayerTreeHostImplClient* client, Proxy* proxy) |
{ |
- return make_scoped_ptr(new LayerTreeHostImpl(settings, client)); |
+ return make_scoped_ptr(new LayerTreeHostImpl(settings, client, proxy)); |
} |
-LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTreeHostImplClient* client) |
+LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTreeHostImplClient* client, Proxy* proxy) |
: m_client(client) |
+ , m_proxy(proxy) |
, m_sourceFrameNumber(-1) |
, m_rootScrollLayerImpl(0) |
, m_currentlyScrollingLayerImpl(0) |
@@ -224,18 +225,18 @@ LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre |
, m_hasTransparentBackground(false) |
, m_needsAnimateLayers(false) |
, m_pinchGestureActive(false) |
- , m_fpsCounter(FrameRateCounter::create()) |
+ , m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread())) |
, m_debugRectHistory(DebugRectHistory::create()) |
, m_numImplThreadScrolls(0) |
, m_numMainThreadScrolls(0) |
{ |
- DCHECK(Proxy::isImplThread()); |
+ DCHECK(m_proxy->isImplThread()); |
didVisibilityChange(this, m_visible); |
} |
LayerTreeHostImpl::~LayerTreeHostImpl() |
{ |
- DCHECK(Proxy::isImplThread()); |
+ DCHECK(m_proxy->isImplThread()); |
TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); |
if (m_rootLayerImpl) |
@@ -502,7 +503,7 @@ void LayerTreeHostImpl::setBackgroundTickingEnabled(bool enabled) |
{ |
// Lazily create the timeSource adapter so that we can vary the interval for testing. |
if (!m_timeSourceClientAdapter) |
- m_timeSourceClientAdapter = LayerTreeHostImplTimeSourceAdapter::create(this, DelayBasedTimeSource::create(lowFrequencyAnimationInterval(), Proxy::currentThread())); |
+ m_timeSourceClientAdapter = LayerTreeHostImplTimeSourceAdapter::create(this, DelayBasedTimeSource::create(lowFrequencyAnimationInterval(), m_proxy->currentThread())); |
m_timeSourceClientAdapter->setActive(enabled); |
} |
@@ -647,12 +648,26 @@ void LayerTreeHostImpl::enforceManagedMemoryPolicy(const ManagedMemoryPolicy& po |
m_client->sendManagedMemoryStats(); |
} |
+bool LayerTreeHostImpl::hasImplThread() const |
+{ |
+ return m_proxy->hasImplThread(); |
+} |
+ |
void LayerTreeHostImpl::setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) |
{ |
if (m_managedMemoryPolicy == policy) |
return; |
+ |
m_managedMemoryPolicy = policy; |
- enforceManagedMemoryPolicy(m_managedMemoryPolicy); |
+ if (!m_proxy->hasImplThread()) { |
+ // FIXME: In single-thread mode, this can be called on the main thread |
+ // by GLRenderer::onMemoryAllocationChanged. |
+ DebugScopedSetImplThread implThread(m_proxy); |
+ enforceManagedMemoryPolicy(m_managedMemoryPolicy); |
+ } else { |
+ DCHECK(m_proxy->isImplThread()); |
+ enforceManagedMemoryPolicy(m_managedMemoryPolicy); |
+ } |
// We always need to commit after changing the memory policy because the new |
// limit can result in more or less content having texture allocated for it. |
m_client->setNeedsCommitOnImplThread(); |
@@ -817,7 +832,7 @@ scoped_ptr<LayerImpl> LayerTreeHostImpl::detachLayerTree() |
void LayerTreeHostImpl::setVisible(bool visible) |
{ |
- DCHECK(Proxy::isImplThread()); |
+ DCHECK(m_proxy->isImplThread()); |
if (m_visible == visible) |
return; |