Chromium Code Reviews| Index: cc/layer_tree_host.cc |
| diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc |
| index 3377b758efc1c0bb757db14d46a882cb81bc74be..24bf85bfe66ba2a8e1bfeccfe0f712deb94da045 100644 |
| --- a/cc/layer_tree_host.cc |
| +++ b/cc/layer_tree_host.cc |
| @@ -83,10 +83,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, Thread* implThread) |
| { |
| scoped_ptr<LayerTreeHost> layerTreeHost(new LayerTreeHost(client, settings)); |
| - if (!layerTreeHost->initialize()) |
| + if (!layerTreeHost->initialize(implThread)) |
| return scoped_ptr<LayerTreeHost>(); |
| return layerTreeHost.Pass(); |
| } |
| @@ -112,16 +112,15 @@ LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSetting |
| , m_hasTransparentBackground(false) |
| , m_partialTextureUpdateRequests(0) |
| { |
| - DCHECK(Proxy::isMainThread()); |
| numLayerTreeInstances++; |
| } |
| -bool LayerTreeHost::initialize() |
| +bool LayerTreeHost::initialize(Thread* implThread) |
| { |
| TRACE_EVENT0("cc", "LayerTreeHost::initialize"); |
| - if (Proxy::hasImplThread()) |
| - m_proxy = ThreadProxy::create(this); |
| + if (implThread) |
| + m_proxy = ThreadProxy::create(this, implThread); |
| else |
| m_proxy = SingleThreadProxy::create(this); |
| m_proxy->start(); |
| @@ -133,11 +132,10 @@ LayerTreeHost::~LayerTreeHost() |
| { |
| if (m_rootLayer) |
| m_rootLayer->setLayerTreeHost(0); |
| - DCHECK(Proxy::isMainThread()); |
| - TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); |
| DCHECK(m_proxy.get()); |
|
jamesr
2012/10/31 04:42:13
I think DCHECK(m_proxy) works too
|
| + DCHECK(m_proxy->isMainThread()); |
| + TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); |
| m_proxy->stop(); |
| - m_proxy.reset(); |
| numLayerTreeInstances--; |
| RateLimiterMap::iterator it = m_rateLimiters.begin(); |
| if (it != m_rateLimiters.end()) |
| @@ -164,7 +162,7 @@ void LayerTreeHost::initializeRenderer() |
| // Update m_settings based on partial update capability. |
| m_settings.maxPartialTextureUpdates = min(m_settings.maxPartialTextureUpdates, m_proxy->maxPartialTextureUpdates()); |
| - m_contentsTextureManager = PrioritizedTextureManager::create(0, m_proxy->rendererCapabilities().maxTextureSize, Renderer::ContentPool); |
| + m_contentsTextureManager = PrioritizedTextureManager::create(0, m_proxy->rendererCapabilities().maxTextureSize, Renderer::ContentPool, m_proxy.get()); |
| m_surfaceMemoryPlaceholder = m_contentsTextureManager->createTexture(IntSize(), GL_RGBA); |
| m_rendererInitialized = true; |
| @@ -199,7 +197,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; |
| } |
| @@ -212,14 +210,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(); |
| } |
| @@ -240,7 +238,7 @@ void LayerTreeHost::layout() |
| void LayerTreeHost::beginCommitOnImplThread(LayerTreeHostImpl* hostImpl) |
| { |
| - DCHECK(Proxy::isImplThread()); |
| + DCHECK(m_proxy->isImplThread()); |
| TRACE_EVENT0("cc", "LayerTreeHost::commitTo"); |
| } |
| @@ -251,7 +249,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); |
| @@ -318,13 +316,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(); |
| @@ -367,7 +365,7 @@ const RendererCapabilities& LayerTreeHost::rendererCapabilities() const |
| void LayerTreeHost::setNeedsAnimate() |
| { |
| - DCHECK(Proxy::hasImplThread()); |
| + DCHECK(m_proxy->hasImplThread()); |
| m_proxy->setNeedsAnimate(); |
| } |
| @@ -383,7 +381,7 @@ void LayerTreeHost::setNeedsCommit() |
| void LayerTreeHost::setNeedsRedraw() |
| { |
| m_proxy->setNeedsRedraw(); |
| - if (!ThreadProxy::implThread()) |
| + if (!m_proxy->implThread()) |
| m_client->scheduleComposite(); |
| } |
| @@ -394,7 +392,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); |
| } |
| @@ -470,7 +468,7 @@ PrioritizedTextureManager* LayerTreeHost::contentsTextureManager() const |
| void LayerTreeHost::composite() |
| { |
| - DCHECK(!ThreadProxy::implThread()); |
| + DCHECK(!m_proxy->implThread()); |
| static_cast<SingleThreadProxy*>(m_proxy.get())->compositeImmediately(); |
| } |
| @@ -724,7 +722,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.get()); |
| m_rateLimiters[context] = rateLimiter; |
| rateLimiter->start(); |
| } |