diff options
author | aelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-08 07:03:44 +0000 |
---|---|---|
committer | aelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-08 07:03:44 +0000 |
commit | 61de581375ce3d76628772a78719cad63f0aabae (patch) | |
tree | 90e5818095cfa31182ceca09224c42d999644e4d /cc/layer_tree_host.cc | |
parent | de8686ed05a28324b0978b2bb81cf3407f13762b (diff) | |
download | chromium_src-61de581375ce3d76628772a78719cad63f0aabae.zip chromium_src-61de581375ce3d76628772a78719cad63f0aabae.tar.gz chromium_src-61de581375ce3d76628772a78719cad63f0aabae.tar.bz2 |
Remove static thread pointers from CC, attempt 3
BUG=152904
Review URL: https://chromiumcodereview.appspot.com/11232051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166627 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/layer_tree_host.cc')
-rw-r--r-- | cc/layer_tree_host.cc | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc index 2dc15171..6a0f825 100644 --- a/cc/layer_tree_host.cc +++ b/cc/layer_tree_host.cc @@ -23,6 +23,7 @@ #include "cc/overdraw_metrics.h" #include "cc/settings.h" #include "cc/single_thread_proxy.h" +#include "cc/thread.h" #include "cc/thread_proxy.h" #include "cc/tree_synchronizer.h" @@ -81,10 +82,10 @@ bool LayerTreeHost::anyLayerTreeHostInstanceExists() return numLayerTreeInstances > 0; } -scoped_ptr<LayerTreeHost> LayerTreeHost::create(LayerTreeHostClient* client, const LayerTreeSettings& settings) +scoped_ptr<LayerTreeHost> LayerTreeHost::create(LayerTreeHostClient* client, const LayerTreeSettings& settings, scoped_ptr<Thread> implThread) { scoped_ptr<LayerTreeHost> layerTreeHost(new LayerTreeHost(client, settings)); - if (!layerTreeHost->initialize()) + if (!layerTreeHost->initialize(implThread.Pass())) return scoped_ptr<LayerTreeHost>(); return layerTreeHost.Pass(); } @@ -110,16 +111,15 @@ LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSetting , m_hasTransparentBackground(false) , m_partialTextureUpdateRequests(0) { - DCHECK(Proxy::isMainThread()); numLayerTreeInstances++; } -bool LayerTreeHost::initialize() +bool LayerTreeHost::initialize(scoped_ptr<Thread> implThread) { TRACE_EVENT0("cc", "LayerTreeHost::initialize"); - if (Proxy::hasImplThread()) - m_proxy = ThreadProxy::create(this); + if (implThread) + m_proxy = ThreadProxy::create(this, implThread.Pass()); else m_proxy = SingleThreadProxy::create(this); m_proxy->start(); @@ -131,11 +131,10 @@ LayerTreeHost::~LayerTreeHost() { if (m_rootLayer) m_rootLayer->setLayerTreeHost(0); - DCHECK(Proxy::isMainThread()); + DCHECK(m_proxy); + DCHECK(m_proxy->isMainThread()); TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); - DCHECK(m_proxy.get()); m_proxy->stop(); - m_proxy.reset(); numLayerTreeInstances--; RateLimiterMap::iterator it = m_rateLimiters.begin(); if (it != m_rateLimiters.end()) @@ -162,7 +161,7 @@ void LayerTreeHost::initializeRenderer() // Update m_settings based on partial update capability. m_settings.maxPartialTextureUpdates = min(m_settings.maxPartialTextureUpdates, m_proxy->maxPartialTextureUpdates()); - m_contentsTextureManager = PrioritizedResourceManager::create(0, m_proxy->rendererCapabilities().maxTextureSize, Renderer::ContentPool); + m_contentsTextureManager = PrioritizedResourceManager::create(0, m_proxy->rendererCapabilities().maxTextureSize, Renderer::ContentPool, m_proxy.get()); m_surfaceMemoryPlaceholder = m_contentsTextureManager->createTexture(gfx::Size(), GL_RGBA); m_rendererInitialized = true; @@ -197,7 +196,7 @@ LayerTreeHost::RecreateResult LayerTreeHost::recreateContext() // FIXME: The single thread does not self-schedule context // recreation. So force another recreation attempt to happen by requesting // another commit. - if (!Proxy::hasImplThread()) + if (!m_proxy->hasImplThread()) setNeedsCommit(); return RecreateFailedButTryAgain; } @@ -210,14 +209,14 @@ LayerTreeHost::RecreateResult LayerTreeHost::recreateContext() void LayerTreeHost::deleteContentsTexturesOnImplThread(ResourceProvider* resourceProvider) { - DCHECK(Proxy::isImplThread()); + DCHECK(m_proxy->isImplThread()); if (m_rendererInitialized) m_contentsTextureManager->clearAllMemory(resourceProvider); } void LayerTreeHost::acquireLayerTextures() { - DCHECK(Proxy::isMainThread()); + DCHECK(m_proxy->isMainThread()); m_proxy->acquireLayerTextures(); } @@ -238,7 +237,7 @@ void LayerTreeHost::layout() void LayerTreeHost::beginCommitOnImplThread(LayerTreeHostImpl* hostImpl) { - DCHECK(Proxy::isImplThread()); + DCHECK(m_proxy->isImplThread()); TRACE_EVENT0("cc", "LayerTreeHost::commitTo"); } @@ -249,7 +248,7 @@ void LayerTreeHost::beginCommitOnImplThread(LayerTreeHostImpl* hostImpl) // after the commit, but on the main thread. void LayerTreeHost::finishCommitOnImplThread(LayerTreeHostImpl* hostImpl) { - DCHECK(Proxy::isImplThread()); + DCHECK(m_proxy->isImplThread()); m_contentsTextureManager->updateBackingsInDrawingImplTree(); ResourceProvider::debugNotifyEnterZone(0xA000000); @@ -324,13 +323,13 @@ scoped_ptr<InputHandler> LayerTreeHost::createInputHandler() scoped_ptr<LayerTreeHostImpl> LayerTreeHost::createLayerTreeHostImpl(LayerTreeHostImplClient* client) { - return LayerTreeHostImpl::create(m_settings, client); + return LayerTreeHostImpl::create(m_settings, client, m_proxy.get()); } void LayerTreeHost::didLoseContext() { TRACE_EVENT0("cc", "LayerTreeHost::didLoseContext"); - DCHECK(Proxy::isMainThread()); + DCHECK(m_proxy->isMainThread()); m_contextLost = true; m_numFailedRecreateAttempts = 0; setNeedsCommit(); @@ -373,7 +372,7 @@ const RendererCapabilities& LayerTreeHost::rendererCapabilities() const void LayerTreeHost::setNeedsAnimate() { - DCHECK(Proxy::hasImplThread()); + DCHECK(m_proxy->hasImplThread()); m_proxy->setNeedsAnimate(); } @@ -389,7 +388,7 @@ void LayerTreeHost::setNeedsCommit() void LayerTreeHost::setNeedsRedraw() { m_proxy->setNeedsRedraw(); - if (!ThreadProxy::implThread()) + if (!m_proxy->implThread()) m_client->scheduleComposite(); } @@ -400,7 +399,7 @@ bool LayerTreeHost::commitRequested() const void LayerTreeHost::setAnimationEvents(scoped_ptr<AnimationEventsVector> events, base::Time wallClockTime) { - DCHECK(ThreadProxy::isMainThread()); + DCHECK(m_proxy->isMainThread()); setAnimationEventsRecursive(*events.get(), m_rootLayer.get(), wallClockTime); } @@ -476,8 +475,10 @@ PrioritizedResourceManager* LayerTreeHost::contentsTextureManager() const void LayerTreeHost::composite() { - DCHECK(!ThreadProxy::implThread()); - static_cast<SingleThreadProxy*>(m_proxy.get())->compositeImmediately(); + if (!m_proxy->hasImplThread()) + static_cast<SingleThreadProxy*>(m_proxy.get())->compositeImmediately(); + else + setNeedsCommit(); } void LayerTreeHost::scheduleComposite() @@ -751,7 +752,7 @@ void LayerTreeHost::startRateLimiter(WebKit::WebGraphicsContext3D* context) if (it != m_rateLimiters.end()) it->second->start(); else { - scoped_refptr<RateLimiter> rateLimiter = RateLimiter::create(context, this); + scoped_refptr<RateLimiter> rateLimiter = RateLimiter::create(context, this, m_proxy->mainThread()); m_rateLimiters[context] = rateLimiter; rateLimiter->start(); } |