| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/layer_tree_host.h" | 7 #include "cc/layer_tree_host.h" |
| 8 | 8 |
| 9 #include "Region.h" | 9 #include "Region.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "cc/font_atlas.h" | 12 #include "cc/font_atlas.h" |
| 13 #include "cc/graphics_context.h" | 13 #include "cc/graphics_context.h" |
| 14 #include "cc/heads_up_display_layer.h" | 14 #include "cc/heads_up_display_layer.h" |
| 15 #include "cc/heads_up_display_layer_impl.h" | 15 #include "cc/heads_up_display_layer_impl.h" |
| 16 #include "cc/layer.h" | 16 #include "cc/layer.h" |
| 17 #include "cc/layer_animation_controller.h" | 17 #include "cc/layer_animation_controller.h" |
| 18 #include "cc/layer_iterator.h" | 18 #include "cc/layer_iterator.h" |
| 19 #include "cc/layer_tree_host_client.h" | 19 #include "cc/layer_tree_host_client.h" |
| 20 #include "cc/layer_tree_host_common.h" | 20 #include "cc/layer_tree_host_common.h" |
| 21 #include "cc/layer_tree_host_impl.h" | 21 #include "cc/layer_tree_host_impl.h" |
| 22 #include "cc/math_util.h" | 22 #include "cc/math_util.h" |
| 23 #include "cc/occlusion_tracker.h" | 23 #include "cc/occlusion_tracker.h" |
| 24 #include "cc/overdraw_metrics.h" | 24 #include "cc/overdraw_metrics.h" |
| 25 #include "cc/settings.h" | 25 #include "cc/settings.h" |
| 26 #include "cc/single_thread_proxy.h" | 26 #include "cc/single_thread_proxy.h" |
| 27 #include "cc/thread.h" |
| 27 #include "cc/thread_proxy.h" | 28 #include "cc/thread_proxy.h" |
| 28 #include "cc/tree_synchronizer.h" | 29 #include "cc/tree_synchronizer.h" |
| 29 | 30 |
| 30 using namespace std; | 31 using namespace std; |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 static int numLayerTreeInstances; | 34 static int numLayerTreeInstances; |
| 34 } | 35 } |
| 35 | 36 |
| 36 namespace cc { | 37 namespace cc { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 76 |
| 76 RendererCapabilities::~RendererCapabilities() | 77 RendererCapabilities::~RendererCapabilities() |
| 77 { | 78 { |
| 78 } | 79 } |
| 79 | 80 |
| 80 bool LayerTreeHost::anyLayerTreeHostInstanceExists() | 81 bool LayerTreeHost::anyLayerTreeHostInstanceExists() |
| 81 { | 82 { |
| 82 return numLayerTreeInstances > 0; | 83 return numLayerTreeInstances > 0; |
| 83 } | 84 } |
| 84 | 85 |
| 85 scoped_ptr<LayerTreeHost> LayerTreeHost::create(LayerTreeHostClient* client, con
st LayerTreeSettings& settings) | 86 scoped_ptr<LayerTreeHost> LayerTreeHost::create(LayerTreeHostClient* client, con
st LayerTreeSettings& settings, scoped_ptr<Thread> implThread) |
| 86 { | 87 { |
| 87 scoped_ptr<LayerTreeHost> layerTreeHost(new LayerTreeHost(client, settings))
; | 88 scoped_ptr<LayerTreeHost> layerTreeHost(new LayerTreeHost(client, settings))
; |
| 88 if (!layerTreeHost->initialize()) | 89 if (!layerTreeHost->initialize(implThread.Pass())) |
| 89 return scoped_ptr<LayerTreeHost>(); | 90 return scoped_ptr<LayerTreeHost>(); |
| 90 return layerTreeHost.Pass(); | 91 return layerTreeHost.Pass(); |
| 91 } | 92 } |
| 92 | 93 |
| 93 LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSetting
s& settings) | 94 LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSetting
s& settings) |
| 94 : m_animating(false) | 95 : m_animating(false) |
| 95 , m_needsAnimateLayers(false) | 96 , m_needsAnimateLayers(false) |
| 96 , m_client(client) | 97 , m_client(client) |
| 97 , m_commitNumber(0) | 98 , m_commitNumber(0) |
| 98 , m_renderingStats() | 99 , m_renderingStats() |
| 99 , m_rendererInitialized(false) | 100 , m_rendererInitialized(false) |
| 100 , m_contextLost(false) | 101 , m_contextLost(false) |
| 101 , m_numTimesRecreateShouldFail(0) | 102 , m_numTimesRecreateShouldFail(0) |
| 102 , m_numFailedRecreateAttempts(0) | 103 , m_numFailedRecreateAttempts(0) |
| 103 , m_settings(settings) | 104 , m_settings(settings) |
| 104 , m_deviceScaleFactor(1) | 105 , m_deviceScaleFactor(1) |
| 105 , m_visible(true) | 106 , m_visible(true) |
| 106 , m_pageScaleFactor(1) | 107 , m_pageScaleFactor(1) |
| 107 , m_minPageScaleFactor(1) | 108 , m_minPageScaleFactor(1) |
| 108 , m_maxPageScaleFactor(1) | 109 , m_maxPageScaleFactor(1) |
| 109 , m_triggerIdleUpdates(true) | 110 , m_triggerIdleUpdates(true) |
| 110 , m_backgroundColor(SK_ColorWHITE) | 111 , m_backgroundColor(SK_ColorWHITE) |
| 111 , m_hasTransparentBackground(false) | 112 , m_hasTransparentBackground(false) |
| 112 , m_partialTextureUpdateRequests(0) | 113 , m_partialTextureUpdateRequests(0) |
| 113 { | 114 { |
| 114 DCHECK(Proxy::isMainThread()); | |
| 115 numLayerTreeInstances++; | 115 numLayerTreeInstances++; |
| 116 } | 116 } |
| 117 | 117 |
| 118 bool LayerTreeHost::initialize() | 118 bool LayerTreeHost::initialize(scoped_ptr<Thread> implThread) |
| 119 { | 119 { |
| 120 TRACE_EVENT0("cc", "LayerTreeHost::initialize"); | 120 TRACE_EVENT0("cc", "LayerTreeHost::initialize"); |
| 121 | 121 |
| 122 if (Proxy::hasImplThread()) | 122 if (implThread) |
| 123 m_proxy = ThreadProxy::create(this); | 123 m_proxy = ThreadProxy::create(this, implThread.Pass()); |
| 124 else | 124 else |
| 125 m_proxy = SingleThreadProxy::create(this); | 125 m_proxy = SingleThreadProxy::create(this); |
| 126 m_proxy->start(); | 126 m_proxy->start(); |
| 127 | 127 |
| 128 return m_proxy->initializeContext(); | 128 return m_proxy->initializeContext(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 LayerTreeHost::~LayerTreeHost() | 131 LayerTreeHost::~LayerTreeHost() |
| 132 { | 132 { |
| 133 if (m_rootLayer) | 133 if (m_rootLayer) |
| 134 m_rootLayer->setLayerTreeHost(0); | 134 m_rootLayer->setLayerTreeHost(0); |
| 135 DCHECK(Proxy::isMainThread()); | 135 DCHECK(m_proxy); |
| 136 DCHECK(m_proxy->isMainThread()); |
| 136 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); | 137 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); |
| 137 DCHECK(m_proxy.get()); | |
| 138 m_proxy->stop(); | 138 m_proxy->stop(); |
| 139 m_proxy.reset(); | |
| 140 numLayerTreeInstances--; | 139 numLayerTreeInstances--; |
| 141 RateLimiterMap::iterator it = m_rateLimiters.begin(); | 140 RateLimiterMap::iterator it = m_rateLimiters.begin(); |
| 142 if (it != m_rateLimiters.end()) | 141 if (it != m_rateLimiters.end()) |
| 143 it->second->stop(); | 142 it->second->stop(); |
| 144 } | 143 } |
| 145 | 144 |
| 146 void LayerTreeHost::setSurfaceReady() | 145 void LayerTreeHost::setSurfaceReady() |
| 147 { | 146 { |
| 148 m_proxy->setSurfaceReady(); | 147 m_proxy->setSurfaceReady(); |
| 149 } | 148 } |
| 150 | 149 |
| 151 void LayerTreeHost::initializeRenderer() | 150 void LayerTreeHost::initializeRenderer() |
| 152 { | 151 { |
| 153 TRACE_EVENT0("cc", "LayerTreeHost::initializeRenderer"); | 152 TRACE_EVENT0("cc", "LayerTreeHost::initializeRenderer"); |
| 154 if (!m_proxy->initializeRenderer()) { | 153 if (!m_proxy->initializeRenderer()) { |
| 155 // Uh oh, better tell the client that we can't do anything with this con
text. | 154 // Uh oh, better tell the client that we can't do anything with this con
text. |
| 156 m_client->didRecreateOutputSurface(false); | 155 m_client->didRecreateOutputSurface(false); |
| 157 return; | 156 return; |
| 158 } | 157 } |
| 159 | 158 |
| 160 // Update m_settings based on capabilities that we got back from the rendere
r. | 159 // Update m_settings based on capabilities that we got back from the rendere
r. |
| 161 m_settings.acceleratePainting = m_proxy->rendererCapabilities().usingAcceler
atedPainting; | 160 m_settings.acceleratePainting = m_proxy->rendererCapabilities().usingAcceler
atedPainting; |
| 162 | 161 |
| 163 // Update m_settings based on partial update capability. | 162 // Update m_settings based on partial update capability. |
| 164 m_settings.maxPartialTextureUpdates = min(m_settings.maxPartialTextureUpdate
s, m_proxy->maxPartialTextureUpdates()); | 163 m_settings.maxPartialTextureUpdates = min(m_settings.maxPartialTextureUpdate
s, m_proxy->maxPartialTextureUpdates()); |
| 165 | 164 |
| 166 m_contentsTextureManager = PrioritizedResourceManager::create(0, m_proxy->re
ndererCapabilities().maxTextureSize, Renderer::ContentPool); | 165 m_contentsTextureManager = PrioritizedResourceManager::create(0, m_proxy->re
ndererCapabilities().maxTextureSize, Renderer::ContentPool, m_proxy.get()); |
| 167 m_surfaceMemoryPlaceholder = m_contentsTextureManager->createTexture(gfx::Si
ze(), GL_RGBA); | 166 m_surfaceMemoryPlaceholder = m_contentsTextureManager->createTexture(gfx::Si
ze(), GL_RGBA); |
| 168 | 167 |
| 169 m_rendererInitialized = true; | 168 m_rendererInitialized = true; |
| 170 | 169 |
| 171 m_settings.defaultTileSize = gfx::Size(min(m_settings.defaultTileSize.width(
), m_proxy->rendererCapabilities().maxTextureSize), | 170 m_settings.defaultTileSize = gfx::Size(min(m_settings.defaultTileSize.width(
), m_proxy->rendererCapabilities().maxTextureSize), |
| 172 min(m_settings.defaultTileSize.height
(), m_proxy->rendererCapabilities().maxTextureSize)); | 171 min(m_settings.defaultTileSize.height
(), m_proxy->rendererCapabilities().maxTextureSize)); |
| 173 m_settings.maxUntiledLayerSize = gfx::Size(min(m_settings.maxUntiledLayerSiz
e.width(), m_proxy->rendererCapabilities().maxTextureSize), | 172 m_settings.maxUntiledLayerSize = gfx::Size(min(m_settings.maxUntiledLayerSiz
e.width(), m_proxy->rendererCapabilities().maxTextureSize), |
| 174 min(m_settings.maxUntiledLayerSiz
e.height(), m_proxy->rendererCapabilities().maxTextureSize)); | 173 min(m_settings.maxUntiledLayerSiz
e.height(), m_proxy->rendererCapabilities().maxTextureSize)); |
| 175 } | 174 } |
| 176 | 175 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 191 return RecreateSucceeded; | 190 return RecreateSucceeded; |
| 192 } | 191 } |
| 193 | 192 |
| 194 // Tolerate a certain number of recreation failures to work around races | 193 // Tolerate a certain number of recreation failures to work around races |
| 195 // in the context-lost machinery. | 194 // in the context-lost machinery. |
| 196 m_numFailedRecreateAttempts++; | 195 m_numFailedRecreateAttempts++; |
| 197 if (m_numFailedRecreateAttempts < 5) { | 196 if (m_numFailedRecreateAttempts < 5) { |
| 198 // FIXME: The single thread does not self-schedule context | 197 // FIXME: The single thread does not self-schedule context |
| 199 // recreation. So force another recreation attempt to happen by requesti
ng | 198 // recreation. So force another recreation attempt to happen by requesti
ng |
| 200 // another commit. | 199 // another commit. |
| 201 if (!Proxy::hasImplThread()) | 200 if (!m_proxy->hasImplThread()) |
| 202 setNeedsCommit(); | 201 setNeedsCommit(); |
| 203 return RecreateFailedButTryAgain; | 202 return RecreateFailedButTryAgain; |
| 204 } | 203 } |
| 205 | 204 |
| 206 // We have tried too many times to recreate the context. Tell the host to fa
ll | 205 // We have tried too many times to recreate the context. Tell the host to fa
ll |
| 207 // back to software rendering. | 206 // back to software rendering. |
| 208 m_client->didRecreateOutputSurface(false); | 207 m_client->didRecreateOutputSurface(false); |
| 209 return RecreateFailedAndGaveUp; | 208 return RecreateFailedAndGaveUp; |
| 210 } | 209 } |
| 211 | 210 |
| 212 void LayerTreeHost::deleteContentsTexturesOnImplThread(ResourceProvider* resourc
eProvider) | 211 void LayerTreeHost::deleteContentsTexturesOnImplThread(ResourceProvider* resourc
eProvider) |
| 213 { | 212 { |
| 214 DCHECK(Proxy::isImplThread()); | 213 DCHECK(m_proxy->isImplThread()); |
| 215 if (m_rendererInitialized) | 214 if (m_rendererInitialized) |
| 216 m_contentsTextureManager->clearAllMemory(resourceProvider); | 215 m_contentsTextureManager->clearAllMemory(resourceProvider); |
| 217 } | 216 } |
| 218 | 217 |
| 219 void LayerTreeHost::acquireLayerTextures() | 218 void LayerTreeHost::acquireLayerTextures() |
| 220 { | 219 { |
| 221 DCHECK(Proxy::isMainThread()); | 220 DCHECK(m_proxy->isMainThread()); |
| 222 m_proxy->acquireLayerTextures(); | 221 m_proxy->acquireLayerTextures(); |
| 223 } | 222 } |
| 224 | 223 |
| 225 void LayerTreeHost::updateAnimations(base::TimeTicks frameBeginTime) | 224 void LayerTreeHost::updateAnimations(base::TimeTicks frameBeginTime) |
| 226 { | 225 { |
| 227 m_animating = true; | 226 m_animating = true; |
| 228 m_client->animate((frameBeginTime - base::TimeTicks()).InSecondsF()); | 227 m_client->animate((frameBeginTime - base::TimeTicks()).InSecondsF()); |
| 229 animateLayers(frameBeginTime); | 228 animateLayers(frameBeginTime); |
| 230 m_animating = false; | 229 m_animating = false; |
| 231 | 230 |
| 232 m_renderingStats.numAnimationFrames++; | 231 m_renderingStats.numAnimationFrames++; |
| 233 } | 232 } |
| 234 | 233 |
| 235 void LayerTreeHost::layout() | 234 void LayerTreeHost::layout() |
| 236 { | 235 { |
| 237 m_client->layout(); | 236 m_client->layout(); |
| 238 } | 237 } |
| 239 | 238 |
| 240 void LayerTreeHost::beginCommitOnImplThread(LayerTreeHostImpl* hostImpl) | 239 void LayerTreeHost::beginCommitOnImplThread(LayerTreeHostImpl* hostImpl) |
| 241 { | 240 { |
| 242 DCHECK(Proxy::isImplThread()); | 241 DCHECK(m_proxy->isImplThread()); |
| 243 TRACE_EVENT0("cc", "LayerTreeHost::commitTo"); | 242 TRACE_EVENT0("cc", "LayerTreeHost::commitTo"); |
| 244 } | 243 } |
| 245 | 244 |
| 246 // This function commits the LayerTreeHost to an impl tree. When modifying | 245 // This function commits the LayerTreeHost to an impl tree. When modifying |
| 247 // this function, keep in mind that the function *runs* on the impl thread! Any | 246 // this function, keep in mind that the function *runs* on the impl thread! Any |
| 248 // code that is logically a main thread operation, e.g. deletion of a Layer, | 247 // code that is logically a main thread operation, e.g. deletion of a Layer, |
| 249 // should be delayed until the LayerTreeHost::commitComplete, which will run | 248 // should be delayed until the LayerTreeHost::commitComplete, which will run |
| 250 // after the commit, but on the main thread. | 249 // after the commit, but on the main thread. |
| 251 void LayerTreeHost::finishCommitOnImplThread(LayerTreeHostImpl* hostImpl) | 250 void LayerTreeHost::finishCommitOnImplThread(LayerTreeHostImpl* hostImpl) |
| 252 { | 251 { |
| 253 DCHECK(Proxy::isImplThread()); | 252 DCHECK(m_proxy->isImplThread()); |
| 254 | 253 |
| 255 m_contentsTextureManager->updateBackingsInDrawingImplTree(); | 254 m_contentsTextureManager->updateBackingsInDrawingImplTree(); |
| 256 ResourceProvider::debugNotifyEnterZone(0xA000000); | 255 ResourceProvider::debugNotifyEnterZone(0xA000000); |
| 257 m_contentsTextureManager->reduceMemory(hostImpl->resourceProvider()); | 256 m_contentsTextureManager->reduceMemory(hostImpl->resourceProvider()); |
| 258 ResourceProvider::debugNotifyLeaveZone(); | 257 ResourceProvider::debugNotifyLeaveZone(); |
| 259 | 258 |
| 260 hostImpl->setRootLayer(TreeSynchronizer::synchronizeTrees(rootLayer(), hostI
mpl->detachLayerTree(), hostImpl)); | 259 hostImpl->setRootLayer(TreeSynchronizer::synchronizeTrees(rootLayer(), hostI
mpl->detachLayerTree(), hostImpl)); |
| 261 | 260 |
| 262 if (m_rootLayer && m_hudLayer) | 261 if (m_rootLayer && m_hudLayer) |
| 263 hostImpl->setHudLayer(static_cast<HeadsUpDisplayLayerImpl*>(LayerTreeHos
tCommon::findLayerInSubtree(hostImpl->rootLayer(), m_hudLayer->id()))); | 262 hostImpl->setHudLayer(static_cast<HeadsUpDisplayLayerImpl*>(LayerTreeHos
tCommon::findLayerInSubtree(hostImpl->rootLayer(), m_hudLayer->id()))); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 return m_client->createOutputSurface(); | 317 return m_client->createOutputSurface(); |
| 319 } | 318 } |
| 320 | 319 |
| 321 scoped_ptr<InputHandler> LayerTreeHost::createInputHandler() | 320 scoped_ptr<InputHandler> LayerTreeHost::createInputHandler() |
| 322 { | 321 { |
| 323 return m_client->createInputHandler(); | 322 return m_client->createInputHandler(); |
| 324 } | 323 } |
| 325 | 324 |
| 326 scoped_ptr<LayerTreeHostImpl> LayerTreeHost::createLayerTreeHostImpl(LayerTreeHo
stImplClient* client) | 325 scoped_ptr<LayerTreeHostImpl> LayerTreeHost::createLayerTreeHostImpl(LayerTreeHo
stImplClient* client) |
| 327 { | 326 { |
| 328 return LayerTreeHostImpl::create(m_settings, client); | 327 return LayerTreeHostImpl::create(m_settings, client, m_proxy.get()); |
| 329 } | 328 } |
| 330 | 329 |
| 331 void LayerTreeHost::didLoseContext() | 330 void LayerTreeHost::didLoseContext() |
| 332 { | 331 { |
| 333 TRACE_EVENT0("cc", "LayerTreeHost::didLoseContext"); | 332 TRACE_EVENT0("cc", "LayerTreeHost::didLoseContext"); |
| 334 DCHECK(Proxy::isMainThread()); | 333 DCHECK(m_proxy->isMainThread()); |
| 335 m_contextLost = true; | 334 m_contextLost = true; |
| 336 m_numFailedRecreateAttempts = 0; | 335 m_numFailedRecreateAttempts = 0; |
| 337 setNeedsCommit(); | 336 setNeedsCommit(); |
| 338 } | 337 } |
| 339 | 338 |
| 340 bool LayerTreeHost::compositeAndReadback(void *pixels, const gfx::Rect& rect) | 339 bool LayerTreeHost::compositeAndReadback(void *pixels, const gfx::Rect& rect) |
| 341 { | 340 { |
| 342 m_triggerIdleUpdates = false; | 341 m_triggerIdleUpdates = false; |
| 343 bool ret = m_proxy->compositeAndReadback(pixels, rect); | 342 bool ret = m_proxy->compositeAndReadback(pixels, rect); |
| 344 m_triggerIdleUpdates = true; | 343 m_triggerIdleUpdates = true; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 367 m_proxy->renderingStats(stats); | 366 m_proxy->renderingStats(stats); |
| 368 } | 367 } |
| 369 | 368 |
| 370 const RendererCapabilities& LayerTreeHost::rendererCapabilities() const | 369 const RendererCapabilities& LayerTreeHost::rendererCapabilities() const |
| 371 { | 370 { |
| 372 return m_proxy->rendererCapabilities(); | 371 return m_proxy->rendererCapabilities(); |
| 373 } | 372 } |
| 374 | 373 |
| 375 void LayerTreeHost::setNeedsAnimate() | 374 void LayerTreeHost::setNeedsAnimate() |
| 376 { | 375 { |
| 377 DCHECK(Proxy::hasImplThread()); | 376 DCHECK(m_proxy->hasImplThread()); |
| 378 m_proxy->setNeedsAnimate(); | 377 m_proxy->setNeedsAnimate(); |
| 379 } | 378 } |
| 380 | 379 |
| 381 void LayerTreeHost::setNeedsCommit() | 380 void LayerTreeHost::setNeedsCommit() |
| 382 { | 381 { |
| 383 if (!m_prepaintCallback.IsCancelled()) { | 382 if (!m_prepaintCallback.IsCancelled()) { |
| 384 TRACE_EVENT_INSTANT0("cc", "LayerTreeHost::setNeedsCommit::cancel prepai
nt"); | 383 TRACE_EVENT_INSTANT0("cc", "LayerTreeHost::setNeedsCommit::cancel prepai
nt"); |
| 385 m_prepaintCallback.Cancel(); | 384 m_prepaintCallback.Cancel(); |
| 386 } | 385 } |
| 387 m_proxy->setNeedsCommit(); | 386 m_proxy->setNeedsCommit(); |
| 388 } | 387 } |
| 389 | 388 |
| 390 void LayerTreeHost::setNeedsRedraw() | 389 void LayerTreeHost::setNeedsRedraw() |
| 391 { | 390 { |
| 392 m_proxy->setNeedsRedraw(); | 391 m_proxy->setNeedsRedraw(); |
| 393 if (!ThreadProxy::implThread()) | 392 if (!m_proxy->implThread()) |
| 394 m_client->scheduleComposite(); | 393 m_client->scheduleComposite(); |
| 395 } | 394 } |
| 396 | 395 |
| 397 bool LayerTreeHost::commitRequested() const | 396 bool LayerTreeHost::commitRequested() const |
| 398 { | 397 { |
| 399 return m_proxy->commitRequested(); | 398 return m_proxy->commitRequested(); |
| 400 } | 399 } |
| 401 | 400 |
| 402 void LayerTreeHost::setAnimationEvents(scoped_ptr<AnimationEventsVector> events,
base::Time wallClockTime) | 401 void LayerTreeHost::setAnimationEvents(scoped_ptr<AnimationEventsVector> events,
base::Time wallClockTime) |
| 403 { | 402 { |
| 404 DCHECK(ThreadProxy::isMainThread()); | 403 DCHECK(m_proxy->isMainThread()); |
| 405 setAnimationEventsRecursive(*events.get(), m_rootLayer.get(), wallClockTime)
; | 404 setAnimationEventsRecursive(*events.get(), m_rootLayer.get(), wallClockTime)
; |
| 406 } | 405 } |
| 407 | 406 |
| 408 void LayerTreeHost::didAddAnimation() | 407 void LayerTreeHost::didAddAnimation() |
| 409 { | 408 { |
| 410 m_needsAnimateLayers = true; | 409 m_needsAnimateLayers = true; |
| 411 m_proxy->didAddAnimation(); | 410 m_proxy->didAddAnimation(); |
| 412 } | 411 } |
| 413 | 412 |
| 414 void LayerTreeHost::setRootLayer(scoped_refptr<Layer> rootLayer) | 413 void LayerTreeHost::setRootLayer(scoped_refptr<Layer> rootLayer) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 m_proxy->loseContext(); | 469 m_proxy->loseContext(); |
| 471 } | 470 } |
| 472 | 471 |
| 473 PrioritizedResourceManager* LayerTreeHost::contentsTextureManager() const | 472 PrioritizedResourceManager* LayerTreeHost::contentsTextureManager() const |
| 474 { | 473 { |
| 475 return m_contentsTextureManager.get(); | 474 return m_contentsTextureManager.get(); |
| 476 } | 475 } |
| 477 | 476 |
| 478 void LayerTreeHost::composite() | 477 void LayerTreeHost::composite() |
| 479 { | 478 { |
| 480 DCHECK(!ThreadProxy::implThread()); | 479 if (!m_proxy->hasImplThread()) |
| 481 static_cast<SingleThreadProxy*>(m_proxy.get())->compositeImmediately(); | 480 static_cast<SingleThreadProxy*>(m_proxy.get())->compositeImmediately(); |
| 481 else |
| 482 setNeedsCommit(); |
| 482 } | 483 } |
| 483 | 484 |
| 484 void LayerTreeHost::scheduleComposite() | 485 void LayerTreeHost::scheduleComposite() |
| 485 { | 486 { |
| 486 m_client->scheduleComposite(); | 487 m_client->scheduleComposite(); |
| 487 } | 488 } |
| 488 | 489 |
| 489 bool LayerTreeHost::initializeRendererIfNeeded() | 490 bool LayerTreeHost::initializeRendererIfNeeded() |
| 490 { | 491 { |
| 491 if (!m_rendererInitialized) { | 492 if (!m_rendererInitialized) { |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 void LayerTreeHost::startRateLimiter(WebKit::WebGraphicsContext3D* context) | 746 void LayerTreeHost::startRateLimiter(WebKit::WebGraphicsContext3D* context) |
| 746 { | 747 { |
| 747 if (m_animating) | 748 if (m_animating) |
| 748 return; | 749 return; |
| 749 | 750 |
| 750 DCHECK(context); | 751 DCHECK(context); |
| 751 RateLimiterMap::iterator it = m_rateLimiters.find(context); | 752 RateLimiterMap::iterator it = m_rateLimiters.find(context); |
| 752 if (it != m_rateLimiters.end()) | 753 if (it != m_rateLimiters.end()) |
| 753 it->second->start(); | 754 it->second->start(); |
| 754 else { | 755 else { |
| 755 scoped_refptr<RateLimiter> rateLimiter = RateLimiter::create(context, th
is); | 756 scoped_refptr<RateLimiter> rateLimiter = RateLimiter::create(context, th
is, m_proxy->mainThread()); |
| 756 m_rateLimiters[context] = rateLimiter; | 757 m_rateLimiters[context] = rateLimiter; |
| 757 rateLimiter->start(); | 758 rateLimiter->start(); |
| 758 } | 759 } |
| 759 } | 760 } |
| 760 | 761 |
| 761 void LayerTreeHost::stopRateLimiter(WebKit::WebGraphicsContext3D* context) | 762 void LayerTreeHost::stopRateLimiter(WebKit::WebGraphicsContext3D* context) |
| 762 { | 763 { |
| 763 RateLimiterMap::iterator it = m_rateLimiters.find(context); | 764 RateLimiterMap::iterator it = m_rateLimiters.find(context); |
| 764 if (it != m_rateLimiters.end()) { | 765 if (it != m_rateLimiters.end()) { |
| 765 it->second->stop(); | 766 it->second->stop(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 else | 841 else |
| 841 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); | 842 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); |
| 842 } | 843 } |
| 843 } | 844 } |
| 844 | 845 |
| 845 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) | 846 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) |
| 846 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); | 847 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); |
| 847 } | 848 } |
| 848 | 849 |
| 849 } // namespace cc | 850 } // namespace cc |
| OLD | NEW |