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_impl.h" | 7 #include "cc/layer_tree_host_impl.h" |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 }; | 193 }; |
194 | 194 |
195 LayerTreeHostImpl::FrameData::FrameData() | 195 LayerTreeHostImpl::FrameData::FrameData() |
196 { | 196 { |
197 } | 197 } |
198 | 198 |
199 LayerTreeHostImpl::FrameData::~FrameData() | 199 LayerTreeHostImpl::FrameData::~FrameData() |
200 { | 200 { |
201 } | 201 } |
202 | 202 |
203 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::create(const LayerTreeSettings&
settings, LayerTreeHostImplClient* client) | 203 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::create(const LayerTreeSettings&
settings, LayerTreeHostImplClient* client, Proxy* proxy) |
204 { | 204 { |
205 return make_scoped_ptr(new LayerTreeHostImpl(settings, client)); | 205 return make_scoped_ptr(new LayerTreeHostImpl(settings, client, proxy)); |
206 } | 206 } |
207 | 207 |
208 LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre
eHostImplClient* client) | 208 LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre
eHostImplClient* client, Proxy* proxy) |
209 : m_client(client) | 209 : m_client(client) |
| 210 , m_proxy(proxy) |
210 , m_sourceFrameNumber(-1) | 211 , m_sourceFrameNumber(-1) |
211 , m_rootScrollLayerImpl(0) | 212 , m_rootScrollLayerImpl(0) |
212 , m_currentlyScrollingLayerImpl(0) | 213 , m_currentlyScrollingLayerImpl(0) |
213 , m_hudLayerImpl(0) | 214 , m_hudLayerImpl(0) |
214 , m_scrollingLayerIdFromPreviousTree(-1) | 215 , m_scrollingLayerIdFromPreviousTree(-1) |
215 , m_scrollDeltaIsInViewportSpace(false) | 216 , m_scrollDeltaIsInViewportSpace(false) |
216 , m_settings(settings) | 217 , m_settings(settings) |
217 , m_deviceScaleFactor(1) | 218 , m_deviceScaleFactor(1) |
218 , m_visible(true) | 219 , m_visible(true) |
219 , m_contentsTexturesPurged(false) | 220 , m_contentsTexturesPurged(false) |
220 , m_managedMemoryPolicy(PrioritizedTextureManager::defaultMemoryAllocationLi
mit(), | 221 , m_managedMemoryPolicy(PrioritizedTextureManager::defaultMemoryAllocationLi
mit(), |
221 PriorityCalculator::allowEverythingCutoff(), | 222 PriorityCalculator::allowEverythingCutoff(), |
222 0, | 223 0, |
223 PriorityCalculator::allowNothingCutoff()) | 224 PriorityCalculator::allowNothingCutoff()) |
224 , m_backgroundColor(0) | 225 , m_backgroundColor(0) |
225 , m_hasTransparentBackground(false) | 226 , m_hasTransparentBackground(false) |
226 , m_needsAnimateLayers(false) | 227 , m_needsAnimateLayers(false) |
227 , m_pinchGestureActive(false) | 228 , m_pinchGestureActive(false) |
228 , m_fpsCounter(FrameRateCounter::create()) | 229 , m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread())) |
229 , m_debugRectHistory(DebugRectHistory::create()) | 230 , m_debugRectHistory(DebugRectHistory::create()) |
230 , m_numImplThreadScrolls(0) | 231 , m_numImplThreadScrolls(0) |
231 , m_numMainThreadScrolls(0) | 232 , m_numMainThreadScrolls(0) |
232 { | 233 { |
233 DCHECK(Proxy::isImplThread()); | 234 DCHECK(m_proxy->isImplThread()); |
234 didVisibilityChange(this, m_visible); | 235 didVisibilityChange(this, m_visible); |
235 } | 236 } |
236 | 237 |
237 LayerTreeHostImpl::~LayerTreeHostImpl() | 238 LayerTreeHostImpl::~LayerTreeHostImpl() |
238 { | 239 { |
239 DCHECK(Proxy::isImplThread()); | 240 DCHECK(m_proxy->isImplThread()); |
240 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); | 241 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); |
241 | 242 |
242 if (m_rootLayerImpl) | 243 if (m_rootLayerImpl) |
243 clearRenderSurfaces(); | 244 clearRenderSurfaces(); |
244 } | 245 } |
245 | 246 |
246 void LayerTreeHostImpl::beginCommit() | 247 void LayerTreeHostImpl::beginCommit() |
247 { | 248 { |
248 } | 249 } |
249 | 250 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 subtreeNeedsAnimateLayers = true; | 498 subtreeNeedsAnimateLayers = true; |
498 } | 499 } |
499 | 500 |
500 needsAnimateLayers = subtreeNeedsAnimateLayers; | 501 needsAnimateLayers = subtreeNeedsAnimateLayers; |
501 } | 502 } |
502 | 503 |
503 void LayerTreeHostImpl::setBackgroundTickingEnabled(bool enabled) | 504 void LayerTreeHostImpl::setBackgroundTickingEnabled(bool enabled) |
504 { | 505 { |
505 // Lazily create the timeSource adapter so that we can vary the interval for
testing. | 506 // Lazily create the timeSource adapter so that we can vary the interval for
testing. |
506 if (!m_timeSourceClientAdapter) | 507 if (!m_timeSourceClientAdapter) |
507 m_timeSourceClientAdapter = LayerTreeHostImplTimeSourceAdapter::create(t
his, DelayBasedTimeSource::create(lowFrequencyAnimationInterval(), Proxy::curren
tThread())); | 508 m_timeSourceClientAdapter = LayerTreeHostImplTimeSourceAdapter::create(t
his, DelayBasedTimeSource::create(lowFrequencyAnimationInterval(), m_proxy->curr
entThread())); |
508 | 509 |
509 m_timeSourceClientAdapter->setActive(enabled); | 510 m_timeSourceClientAdapter->setActive(enabled); |
510 } | 511 } |
511 | 512 |
512 IntSize LayerTreeHostImpl::contentSize() const | 513 IntSize LayerTreeHostImpl::contentSize() const |
513 { | 514 { |
514 // TODO(aelias): Hardcoding the first child here is weird. Think of | 515 // TODO(aelias): Hardcoding the first child here is weird. Think of |
515 // a cleaner way to get the contentBounds on the Impl side. | 516 // a cleaner way to get the contentBounds on the Impl side. |
516 if (!m_rootScrollLayerImpl || m_rootScrollLayerImpl->children().isEmpty()) | 517 if (!m_rootScrollLayerImpl || m_rootScrollLayerImpl->children().isEmpty()) |
517 return IntSize(); | 518 return IntSize(); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 m_visible ? policy.bytesLimitWhenVisible : policy.bytesLimitWhenNotVisib
le, | 643 m_visible ? policy.bytesLimitWhenVisible : policy.bytesLimitWhenNotVisib
le, |
643 m_visible ? policy.priorityCutoffWhenVisible : policy.priorityCutoffWhen
NotVisible); | 644 m_visible ? policy.priorityCutoffWhenVisible : policy.priorityCutoffWhen
NotVisible); |
644 if (evictedResources) { | 645 if (evictedResources) { |
645 setContentsTexturesPurged(); | 646 setContentsTexturesPurged(); |
646 m_client->setNeedsCommitOnImplThread(); | 647 m_client->setNeedsCommitOnImplThread(); |
647 m_client->onCanDrawStateChanged(canDraw()); | 648 m_client->onCanDrawStateChanged(canDraw()); |
648 } | 649 } |
649 m_client->sendManagedMemoryStats(); | 650 m_client->sendManagedMemoryStats(); |
650 } | 651 } |
651 | 652 |
| 653 bool LayerTreeHostImpl::hasImplThread() const |
| 654 { |
| 655 return m_proxy->hasImplThread(); |
| 656 } |
| 657 |
652 void LayerTreeHostImpl::setManagedMemoryPolicy(const ManagedMemoryPolicy& policy
) | 658 void LayerTreeHostImpl::setManagedMemoryPolicy(const ManagedMemoryPolicy& policy
) |
653 { | 659 { |
654 if (m_managedMemoryPolicy == policy) | 660 if (m_managedMemoryPolicy == policy) |
655 return; | 661 return; |
| 662 |
| 663 // FIXME: In single-thread mode, this can be called on the main thread |
| 664 // by GLRenderer::onMemoryAllocationChanged. |
| 665 DebugScopedSetImplThread implThread(m_proxy); |
| 666 |
656 m_managedMemoryPolicy = policy; | 667 m_managedMemoryPolicy = policy; |
657 enforceManagedMemoryPolicy(m_managedMemoryPolicy); | 668 enforceManagedMemoryPolicy(m_managedMemoryPolicy); |
658 // We always need to commit after changing the memory policy because the new | 669 // We always need to commit after changing the memory policy because the new |
659 // limit can result in more or less content having texture allocated for it. | 670 // limit can result in more or less content having texture allocated for it. |
660 m_client->setNeedsCommitOnImplThread(); | 671 m_client->setNeedsCommitOnImplThread(); |
661 } | 672 } |
662 | 673 |
663 void LayerTreeHostImpl::onVSyncParametersChanged(double monotonicTimebase, doubl
e intervalInSeconds) | 674 void LayerTreeHostImpl::onVSyncParametersChanged(double monotonicTimebase, doubl
e intervalInSeconds) |
664 { | 675 { |
665 base::TimeTicks timebase = base::TimeTicks::FromInternalValue(monotonicTimeb
ase * base::Time::kMicrosecondsPerSecond); | 676 base::TimeTicks timebase = base::TimeTicks::FromInternalValue(monotonicTimeb
ase * base::Time::kMicrosecondsPerSecond); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 // Clear all data structures that have direct references to the layer tree. | 823 // Clear all data structures that have direct references to the layer tree. |
813 m_scrollingLayerIdFromPreviousTree = m_currentlyScrollingLayerImpl ? m_curre
ntlyScrollingLayerImpl->id() : -1; | 824 m_scrollingLayerIdFromPreviousTree = m_currentlyScrollingLayerImpl ? m_curre
ntlyScrollingLayerImpl->id() : -1; |
814 m_currentlyScrollingLayerImpl = 0; | 825 m_currentlyScrollingLayerImpl = 0; |
815 m_renderSurfaceLayerList.clear(); | 826 m_renderSurfaceLayerList.clear(); |
816 | 827 |
817 return m_rootLayerImpl.Pass(); | 828 return m_rootLayerImpl.Pass(); |
818 } | 829 } |
819 | 830 |
820 void LayerTreeHostImpl::setVisible(bool visible) | 831 void LayerTreeHostImpl::setVisible(bool visible) |
821 { | 832 { |
822 DCHECK(Proxy::isImplThread()); | 833 DCHECK(m_proxy->isImplThread()); |
823 | 834 |
824 if (m_visible == visible) | 835 if (m_visible == visible) |
825 return; | 836 return; |
826 m_visible = visible; | 837 m_visible = visible; |
827 didVisibilityChange(this, m_visible); | 838 didVisibilityChange(this, m_visible); |
828 enforceManagedMemoryPolicy(m_managedMemoryPolicy); | 839 enforceManagedMemoryPolicy(m_managedMemoryPolicy); |
829 | 840 |
830 if (!m_renderer) | 841 if (!m_renderer) |
831 return; | 842 return; |
832 | 843 |
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1485 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); | 1496 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); |
1486 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1497 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
1487 if (scrollbarController && scrollbarController->animate(monotonicTime)) | 1498 if (scrollbarController && scrollbarController->animate(monotonicTime)) |
1488 m_client->setNeedsRedrawOnImplThread(); | 1499 m_client->setNeedsRedrawOnImplThread(); |
1489 | 1500 |
1490 for (size_t i = 0; i < layer->children().size(); ++i) | 1501 for (size_t i = 0; i < layer->children().size(); ++i) |
1491 animateScrollbarsRecursive(layer->children()[i], time); | 1502 animateScrollbarsRecursive(layer->children()[i], time); |
1492 } | 1503 } |
1493 | 1504 |
1494 } // namespace cc | 1505 } // namespace cc |
OLD | NEW |