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 "CCAppendQuadsData.h" | 9 #include "CCAppendQuadsData.h" |
10 #include "CCDamageTracker.h" | 10 #include "CCDamageTracker.h" |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 { | 206 { |
207 } | 207 } |
208 | 208 |
209 scoped_ptr<CCLayerTreeHostImpl> CCLayerTreeHostImpl::create(const CCLayerTreeSet
tings& settings, CCLayerTreeHostImplClient* client) | 209 scoped_ptr<CCLayerTreeHostImpl> CCLayerTreeHostImpl::create(const CCLayerTreeSet
tings& settings, CCLayerTreeHostImplClient* client) |
210 { | 210 { |
211 return make_scoped_ptr(new CCLayerTreeHostImpl(settings, client)); | 211 return make_scoped_ptr(new CCLayerTreeHostImpl(settings, client)); |
212 } | 212 } |
213 | 213 |
214 CCLayerTreeHostImpl::CCLayerTreeHostImpl(const CCLayerTreeSettings& settings, CC
LayerTreeHostImplClient* client) | 214 CCLayerTreeHostImpl::CCLayerTreeHostImpl(const CCLayerTreeSettings& settings, CC
LayerTreeHostImplClient* client) |
215 : m_client(client) | 215 : m_client(client) |
| 216 , m_proxy(reinterpret_cast<CCProxy*>(client)) |
216 , m_sourceFrameNumber(-1) | 217 , m_sourceFrameNumber(-1) |
217 , m_rootScrollLayerImpl(0) | 218 , m_rootScrollLayerImpl(0) |
218 , m_currentlyScrollingLayerImpl(0) | 219 , m_currentlyScrollingLayerImpl(0) |
219 , m_hudLayerImpl(0) | 220 , m_hudLayerImpl(0) |
220 , m_scrollingLayerIdFromPreviousTree(-1) | 221 , m_scrollingLayerIdFromPreviousTree(-1) |
221 , m_scrollDeltaIsInViewportSpace(false) | 222 , m_scrollDeltaIsInViewportSpace(false) |
222 , m_settings(settings) | 223 , m_settings(settings) |
223 , m_deviceScaleFactor(1) | 224 , m_deviceScaleFactor(1) |
224 , m_visible(true) | 225 , m_visible(true) |
225 , m_contentsTexturesPurged(false) | 226 , m_contentsTexturesPurged(false) |
226 , m_memoryAllocationLimitBytes(CCPrioritizedTextureManager::defaultMemoryAll
ocationLimit()) | 227 , m_memoryAllocationLimitBytes(CCPrioritizedTextureManager::defaultMemoryAll
ocationLimit()) |
227 , m_backgroundColor(0) | 228 , m_backgroundColor(0) |
228 , m_hasTransparentBackground(false) | 229 , m_hasTransparentBackground(false) |
229 , m_needsAnimateLayers(false) | 230 , m_needsAnimateLayers(false) |
230 , m_pinchGestureActive(false) | 231 , m_pinchGestureActive(false) |
231 , m_fpsCounter(CCFrameRateCounter::create()) | 232 , m_fpsCounter(CCFrameRateCounter::create(m_proxy->hasImplThread())) |
232 , m_debugRectHistory(CCDebugRectHistory::create()) | 233 , m_debugRectHistory(CCDebugRectHistory::create()) |
233 , m_numImplThreadScrolls(0) | 234 , m_numImplThreadScrolls(0) |
234 , m_numMainThreadScrolls(0) | 235 , m_numMainThreadScrolls(0) |
235 { | 236 { |
236 DCHECK(CCProxy::isImplThread()); | 237 DCHECK(m_proxy->isImplThread()); |
237 didVisibilityChange(this, m_visible); | 238 didVisibilityChange(this, m_visible); |
238 } | 239 } |
239 | 240 |
240 CCLayerTreeHostImpl::~CCLayerTreeHostImpl() | 241 CCLayerTreeHostImpl::~CCLayerTreeHostImpl() |
241 { | 242 { |
242 DCHECK(CCProxy::isImplThread()); | 243 DCHECK(m_proxy->isImplThread()); |
243 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::~CCLayerTreeHostImpl()"); | 244 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::~CCLayerTreeHostImpl()"); |
244 | 245 |
245 if (m_rootLayerImpl) | 246 if (m_rootLayerImpl) |
246 clearRenderSurfaces(); | 247 clearRenderSurfaces(); |
247 } | 248 } |
248 | 249 |
249 void CCLayerTreeHostImpl::beginCommit() | 250 void CCLayerTreeHostImpl::beginCommit() |
250 { | 251 { |
251 } | 252 } |
252 | 253 |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 subtreeNeedsAnimateLayers = true; | 496 subtreeNeedsAnimateLayers = true; |
496 } | 497 } |
497 | 498 |
498 needsAnimateLayers = subtreeNeedsAnimateLayers; | 499 needsAnimateLayers = subtreeNeedsAnimateLayers; |
499 } | 500 } |
500 | 501 |
501 void CCLayerTreeHostImpl::setBackgroundTickingEnabled(bool enabled) | 502 void CCLayerTreeHostImpl::setBackgroundTickingEnabled(bool enabled) |
502 { | 503 { |
503 // Lazily create the timeSource adapter so that we can vary the interval for
testing. | 504 // Lazily create the timeSource adapter so that we can vary the interval for
testing. |
504 if (!m_timeSourceClientAdapter) | 505 if (!m_timeSourceClientAdapter) |
505 m_timeSourceClientAdapter = CCLayerTreeHostImplTimeSourceAdapter::create
(this, CCDelayBasedTimeSource::create(lowFrequencyAnimationInterval(), CCProxy::
currentThread())); | 506 m_timeSourceClientAdapter = CCLayerTreeHostImplTimeSourceAdapter::create
(this, CCDelayBasedTimeSource::create(lowFrequencyAnimationInterval(), m_proxy->
currentThread())); |
506 | 507 |
507 m_timeSourceClientAdapter->setActive(enabled); | 508 m_timeSourceClientAdapter->setActive(enabled); |
508 } | 509 } |
509 | 510 |
510 IntSize CCLayerTreeHostImpl::contentSize() const | 511 IntSize CCLayerTreeHostImpl::contentSize() const |
511 { | 512 { |
512 // TODO(aelias): Hardcoding the first child here is weird. Think of | 513 // TODO(aelias): Hardcoding the first child here is weird. Think of |
513 // a cleaner way to get the contentBounds on the Impl side. | 514 // a cleaner way to get the contentBounds on the Impl side. |
514 if (!m_rootScrollLayerImpl || m_rootScrollLayerImpl->children().isEmpty()) | 515 if (!m_rootScrollLayerImpl || m_rootScrollLayerImpl->children().isEmpty()) |
515 return IntSize(); | 516 return IntSize(); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 // Clear all data structures that have direct references to the layer tree. | 805 // Clear all data structures that have direct references to the layer tree. |
805 m_scrollingLayerIdFromPreviousTree = m_currentlyScrollingLayerImpl ? m_curre
ntlyScrollingLayerImpl->id() : -1; | 806 m_scrollingLayerIdFromPreviousTree = m_currentlyScrollingLayerImpl ? m_curre
ntlyScrollingLayerImpl->id() : -1; |
806 m_currentlyScrollingLayerImpl = 0; | 807 m_currentlyScrollingLayerImpl = 0; |
807 m_renderSurfaceLayerList.clear(); | 808 m_renderSurfaceLayerList.clear(); |
808 | 809 |
809 return m_rootLayerImpl.Pass(); | 810 return m_rootLayerImpl.Pass(); |
810 } | 811 } |
811 | 812 |
812 void CCLayerTreeHostImpl::setVisible(bool visible) | 813 void CCLayerTreeHostImpl::setVisible(bool visible) |
813 { | 814 { |
814 DCHECK(CCProxy::isImplThread()); | 815 DCHECK(m_proxy->isImplThread()); |
815 | 816 |
816 if (m_visible == visible) | 817 if (m_visible == visible) |
817 return; | 818 return; |
818 m_visible = visible; | 819 m_visible = visible; |
819 didVisibilityChange(this, m_visible); | 820 didVisibilityChange(this, m_visible); |
820 reduceContentsTextureMemoryOnImplThread(m_visible ? m_memoryAllocationLimitB
ytes : 0); | 821 reduceContentsTextureMemoryOnImplThread(m_visible ? m_memoryAllocationLimitB
ytes : 0); |
821 | 822 |
822 if (!m_renderer) | 823 if (!m_renderer) |
823 return; | 824 return; |
824 | 825 |
(...skipping 12 matching lines...) Expand all Loading... |
837 sendDidLoseContextRecursive(m_rootLayerImpl.get()); | 838 sendDidLoseContextRecursive(m_rootLayerImpl.get()); |
838 } | 839 } |
839 // Note: order is important here. | 840 // Note: order is important here. |
840 m_renderer.reset(); | 841 m_renderer.reset(); |
841 m_resourceProvider.reset(); | 842 m_resourceProvider.reset(); |
842 m_context.reset(); | 843 m_context.reset(); |
843 | 844 |
844 if (!context->bindToClient(this)) | 845 if (!context->bindToClient(this)) |
845 return false; | 846 return false; |
846 | 847 |
847 scoped_ptr<CCResourceProvider> resourceProvider = CCResourceProvider::create
(context.get()); | 848 scoped_ptr<CCResourceProvider> resourceProvider = CCResourceProvider::create
(context.get(), m_proxy); |
848 if (!resourceProvider) | 849 if (!resourceProvider) |
849 return false; | 850 return false; |
850 | 851 |
851 if (context->context3D()) | 852 if (context->context3D()) |
852 m_renderer = CCRendererGL::create(this, resourceProvider.get()); | 853 m_renderer = CCRendererGL::create(this, resourceProvider.get()); |
853 else if (context->softwareDevice()) | 854 else if (context->softwareDevice()) |
854 m_renderer = CCRendererSoftware::create(this, resourceProvider.get(), co
ntext->softwareDevice()); | 855 m_renderer = CCRendererSoftware::create(this, resourceProvider.get(), co
ntext->softwareDevice()); |
855 if (!m_renderer) | 856 if (!m_renderer) |
856 return false; | 857 return false; |
857 | 858 |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 | 1476 |
1476 CCScrollbarAnimationController* scrollbarController = layer->scrollbarAnimat
ionController(); | 1477 CCScrollbarAnimationController* scrollbarController = layer->scrollbarAnimat
ionController(); |
1477 if (scrollbarController && scrollbarController->animate(monotonicTime)) | 1478 if (scrollbarController && scrollbarController->animate(monotonicTime)) |
1478 m_client->setNeedsRedrawOnImplThread(); | 1479 m_client->setNeedsRedrawOnImplThread(); |
1479 | 1480 |
1480 for (size_t i = 0; i < layer->children().size(); ++i) | 1481 for (size_t i = 0; i < layer->children().size(); ++i) |
1481 animateScrollbarsRecursive(layer->children()[i], monotonicTime); | 1482 animateScrollbarsRecursive(layer->children()[i], monotonicTime); |
1482 } | 1483 } |
1483 | 1484 |
1484 } // namespace cc | 1485 } // namespace cc |
OLD | NEW |