Index: cc/layer_tree_host.cc |
diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc |
index dde70427c7d9ba4ab05ba57a5d36463e969cf8ad..5ad5edea95cdc33be401bfe3ae0ce874f3b433ca 100644 |
--- a/cc/layer_tree_host.cc |
+++ b/cc/layer_tree_host.cc |
@@ -24,6 +24,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" |
@@ -82,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, 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(); |
} |
@@ -111,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(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(); |
@@ -132,11 +132,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()) |
@@ -163,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 = 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; |
@@ -198,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; |
} |
@@ -211,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(); |
} |
@@ -239,7 +238,7 @@ void LayerTreeHost::layout() |
void LayerTreeHost::beginCommitOnImplThread(LayerTreeHostImpl* hostImpl) |
{ |
- DCHECK(Proxy::isImplThread()); |
+ DCHECK(m_proxy->isImplThread()); |
TRACE_EVENT0("cc", "LayerTreeHost::commitTo"); |
} |
@@ -250,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); |
@@ -325,13 +324,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(); |
@@ -374,7 +373,7 @@ const RendererCapabilities& LayerTreeHost::rendererCapabilities() const |
void LayerTreeHost::setNeedsAnimate() |
{ |
- DCHECK(Proxy::hasImplThread()); |
+ DCHECK(m_proxy->hasImplThread()); |
m_proxy->setNeedsAnimate(); |
} |
@@ -390,7 +389,7 @@ void LayerTreeHost::setNeedsCommit() |
void LayerTreeHost::setNeedsRedraw() |
{ |
m_proxy->setNeedsRedraw(); |
- if (!ThreadProxy::implThread()) |
+ if (!m_proxy->implThread()) |
m_client->scheduleComposite(); |
} |
@@ -401,7 +400,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); |
} |
@@ -477,8 +476,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() |
@@ -752,7 +753,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(); |
} |