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

Unified Diff: cc/layer_tree_host_impl.cc

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address code review comments and fix all cc_unittests Created 8 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
Index: cc/layer_tree_host_impl.cc
diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc
index a87302e371b9f5ad343c8f8bd85ee10e9f633bb0..dc8f5020fd17953e906631c7e10c3229e964f285 100644
--- a/cc/layer_tree_host_impl.cc
+++ b/cc/layer_tree_host_impl.cc
@@ -173,7 +173,7 @@ public:
// FIXME: We require that animate be called on the impl thread. This
// avoids asserts in single threaded mode. Ideally background ticking
// would be handled by the proxy/scheduler and this could be removed.
- DebugScopedSetImplThread impl;
+ DebugScopedSetImplThread impl(m_layerTreeHostImpl->proxy());
m_layerTreeHostImpl->animate(monotonicallyIncreasingTime(), currentTime());
}
@@ -206,13 +206,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)
@@ -231,18 +232,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)
@@ -505,7 +506,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);
}
@@ -653,6 +654,11 @@ void LayerTreeHostImpl::setManagedMemoryPolicy(const ManagedMemoryPolicy& policy
{
if (m_managedMemoryPolicy == policy)
return;
+
+ // FIXME: In single-thread mode, this can be called on the main thread
+ // by GLRenderer::onMemoryAllocationChanged.
+ DebugScopedSetImplThread implThread(m_proxy);
+
m_managedMemoryPolicy = policy;
enforceManagedMemoryPolicy(m_managedMemoryPolicy);
// We always need to commit after changing the memory policy because the new
@@ -817,7 +823,7 @@ scoped_ptr<LayerImpl> LayerTreeHostImpl::detachLayerTree()
void LayerTreeHostImpl::setVisible(bool visible)
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_proxy->isImplThread());
if (m_visible == visible)
return;
@@ -855,9 +861,9 @@ bool LayerTreeHostImpl::initializeRenderer(scoped_ptr<GraphicsContext> context)
return false;
if (context->context3D())
- m_renderer = GLRenderer::create(this, resourceProvider.get());
+ m_renderer = GLRenderer::create(this, resourceProvider.get(), m_proxy->hasImplThread());
else if (context->softwareDevice())
- m_renderer = SoftwareRenderer::create(this, resourceProvider.get(), context->softwareDevice());
+ m_renderer = SoftwareRenderer::create(this, resourceProvider.get(), context->softwareDevice(), m_proxy->hasImplThread());
if (!m_renderer)
return false;

Powered by Google App Engine
This is Rietveld 408576698