Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(842)

Side by Side Diff: cc/layer_tree_host_impl.cc

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Apply code review comments Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layer_tree_host_impl.h ('k') | cc/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 }; 192 };
193 193
194 LayerTreeHostImpl::FrameData::FrameData() 194 LayerTreeHostImpl::FrameData::FrameData()
195 { 195 {
196 } 196 }
197 197
198 LayerTreeHostImpl::FrameData::~FrameData() 198 LayerTreeHostImpl::FrameData::~FrameData()
199 { 199 {
200 } 200 }
201 201
202 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::create(const LayerTreeSettings& settings, LayerTreeHostImplClient* client) 202 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::create(const LayerTreeSettings& settings, LayerTreeHostImplClient* client, Proxy* proxy)
203 { 203 {
204 return make_scoped_ptr(new LayerTreeHostImpl(settings, client)); 204 return make_scoped_ptr(new LayerTreeHostImpl(settings, client, proxy));
205 } 205 }
206 206
207 LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre eHostImplClient* client) 207 LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre eHostImplClient* client, Proxy* proxy)
208 : m_client(client) 208 : m_client(client)
209 , m_proxy(proxy)
209 , m_sourceFrameNumber(-1) 210 , m_sourceFrameNumber(-1)
210 , m_rootScrollLayerImpl(0) 211 , m_rootScrollLayerImpl(0)
211 , m_currentlyScrollingLayerImpl(0) 212 , m_currentlyScrollingLayerImpl(0)
212 , m_hudLayerImpl(0) 213 , m_hudLayerImpl(0)
213 , m_scrollingLayerIdFromPreviousTree(-1) 214 , m_scrollingLayerIdFromPreviousTree(-1)
214 , m_scrollDeltaIsInViewportSpace(false) 215 , m_scrollDeltaIsInViewportSpace(false)
215 , m_settings(settings) 216 , m_settings(settings)
216 , m_deviceScaleFactor(1) 217 , m_deviceScaleFactor(1)
217 , m_visible(true) 218 , m_visible(true)
218 , m_contentsTexturesPurged(false) 219 , m_contentsTexturesPurged(false)
219 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL imit(), 220 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL imit(),
220 PriorityCalculator::allowEverythingCutoff(), 221 PriorityCalculator::allowEverythingCutoff(),
221 0, 222 0,
222 PriorityCalculator::allowNothingCutoff()) 223 PriorityCalculator::allowNothingCutoff())
223 , m_backgroundColor(0) 224 , m_backgroundColor(0)
224 , m_hasTransparentBackground(false) 225 , m_hasTransparentBackground(false)
225 , m_needsAnimateLayers(false) 226 , m_needsAnimateLayers(false)
226 , m_pinchGestureActive(false) 227 , m_pinchGestureActive(false)
227 , m_fpsCounter(FrameRateCounter::create()) 228 , m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread()))
228 , m_debugRectHistory(DebugRectHistory::create()) 229 , m_debugRectHistory(DebugRectHistory::create())
229 , m_numImplThreadScrolls(0) 230 , m_numImplThreadScrolls(0)
230 , m_numMainThreadScrolls(0) 231 , m_numMainThreadScrolls(0)
231 { 232 {
232 DCHECK(Proxy::isImplThread()); 233 DCHECK(m_proxy->isImplThread());
233 didVisibilityChange(this, m_visible); 234 didVisibilityChange(this, m_visible);
234 } 235 }
235 236
236 LayerTreeHostImpl::~LayerTreeHostImpl() 237 LayerTreeHostImpl::~LayerTreeHostImpl()
237 { 238 {
238 DCHECK(Proxy::isImplThread()); 239 DCHECK(m_proxy->isImplThread());
239 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); 240 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()");
240 241
241 if (m_rootLayerImpl) 242 if (m_rootLayerImpl)
242 clearRenderSurfaces(); 243 clearRenderSurfaces();
243 } 244 }
244 245
245 void LayerTreeHostImpl::beginCommit() 246 void LayerTreeHostImpl::beginCommit()
246 { 247 {
247 } 248 }
248 249
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 subtreeNeedsAnimateLayers = true; 496 subtreeNeedsAnimateLayers = true;
496 } 497 }
497 498
498 needsAnimateLayers = subtreeNeedsAnimateLayers; 499 needsAnimateLayers = subtreeNeedsAnimateLayers;
499 } 500 }
500 501
501 void LayerTreeHostImpl::setBackgroundTickingEnabled(bool enabled) 502 void LayerTreeHostImpl::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 = LayerTreeHostImplTimeSourceAdapter::create(t his, DelayBasedTimeSource::create(lowFrequencyAnimationInterval(), Proxy::curren tThread())); 506 m_timeSourceClientAdapter = LayerTreeHostImplTimeSourceAdapter::create(t his, DelayBasedTimeSource::create(lowFrequencyAnimationInterval(), m_proxy->curr entThread()));
506 507
507 m_timeSourceClientAdapter->setActive(enabled); 508 m_timeSourceClientAdapter->setActive(enabled);
508 } 509 }
509 510
510 gfx::Size LayerTreeHostImpl::contentSize() const 511 gfx::Size LayerTreeHostImpl::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 gfx::Size(); 516 return gfx::Size();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 m_visible ? policy.bytesLimitWhenVisible : policy.bytesLimitWhenNotVisib le, 641 m_visible ? policy.bytesLimitWhenVisible : policy.bytesLimitWhenNotVisib le,
641 m_visible ? policy.priorityCutoffWhenVisible : policy.priorityCutoffWhen NotVisible); 642 m_visible ? policy.priorityCutoffWhenVisible : policy.priorityCutoffWhen NotVisible);
642 if (evictedResources) { 643 if (evictedResources) {
643 setContentsTexturesPurged(); 644 setContentsTexturesPurged();
644 m_client->setNeedsCommitOnImplThread(); 645 m_client->setNeedsCommitOnImplThread();
645 m_client->onCanDrawStateChanged(canDraw()); 646 m_client->onCanDrawStateChanged(canDraw());
646 } 647 }
647 m_client->sendManagedMemoryStats(); 648 m_client->sendManagedMemoryStats();
648 } 649 }
649 650
651 bool LayerTreeHostImpl::hasImplThread() const
652 {
653 return m_proxy->hasImplThread();
654 }
655
650 void LayerTreeHostImpl::setManagedMemoryPolicy(const ManagedMemoryPolicy& policy ) 656 void LayerTreeHostImpl::setManagedMemoryPolicy(const ManagedMemoryPolicy& policy )
651 { 657 {
652 if (m_managedMemoryPolicy == policy) 658 if (m_managedMemoryPolicy == policy)
653 return; 659 return;
660
654 m_managedMemoryPolicy = policy; 661 m_managedMemoryPolicy = policy;
655 enforceManagedMemoryPolicy(m_managedMemoryPolicy); 662 if (!m_proxy->hasImplThread()) {
663 // FIXME: In single-thread mode, this can be called on the main thread
664 // by GLRenderer::onMemoryAllocationChanged.
665 DebugScopedSetImplThread implThread(m_proxy);
666 enforceManagedMemoryPolicy(m_managedMemoryPolicy);
667 } else {
668 DCHECK(m_proxy->isImplThread());
669 enforceManagedMemoryPolicy(m_managedMemoryPolicy);
670 }
656 // We always need to commit after changing the memory policy because the new 671 // We always need to commit after changing the memory policy because the new
657 // limit can result in more or less content having texture allocated for it. 672 // limit can result in more or less content having texture allocated for it.
658 m_client->setNeedsCommitOnImplThread(); 673 m_client->setNeedsCommitOnImplThread();
659 } 674 }
660 675
661 void LayerTreeHostImpl::onVSyncParametersChanged(double monotonicTimebase, doubl e intervalInSeconds) 676 void LayerTreeHostImpl::onVSyncParametersChanged(double monotonicTimebase, doubl e intervalInSeconds)
662 { 677 {
663 base::TimeTicks timebase = base::TimeTicks::FromInternalValue(monotonicTimeb ase * base::Time::kMicrosecondsPerSecond); 678 base::TimeTicks timebase = base::TimeTicks::FromInternalValue(monotonicTimeb ase * base::Time::kMicrosecondsPerSecond);
664 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(intervalInSecon ds * base::Time::kMicrosecondsPerSecond); 679 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(intervalInSecon ds * base::Time::kMicrosecondsPerSecond);
665 m_client->onVSyncParametersChanged(timebase, interval); 680 m_client->onVSyncParametersChanged(timebase, interval);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 // Clear all data structures that have direct references to the layer tree. 825 // Clear all data structures that have direct references to the layer tree.
811 m_scrollingLayerIdFromPreviousTree = m_currentlyScrollingLayerImpl ? m_curre ntlyScrollingLayerImpl->id() : -1; 826 m_scrollingLayerIdFromPreviousTree = m_currentlyScrollingLayerImpl ? m_curre ntlyScrollingLayerImpl->id() : -1;
812 m_currentlyScrollingLayerImpl = 0; 827 m_currentlyScrollingLayerImpl = 0;
813 m_renderSurfaceLayerList.clear(); 828 m_renderSurfaceLayerList.clear();
814 829
815 return m_rootLayerImpl.Pass(); 830 return m_rootLayerImpl.Pass();
816 } 831 }
817 832
818 void LayerTreeHostImpl::setVisible(bool visible) 833 void LayerTreeHostImpl::setVisible(bool visible)
819 { 834 {
820 DCHECK(Proxy::isImplThread()); 835 DCHECK(m_proxy->isImplThread());
821 836
822 if (m_visible == visible) 837 if (m_visible == visible)
823 return; 838 return;
824 m_visible = visible; 839 m_visible = visible;
825 didVisibilityChange(this, m_visible); 840 didVisibilityChange(this, m_visible);
826 enforceManagedMemoryPolicy(m_managedMemoryPolicy); 841 enforceManagedMemoryPolicy(m_managedMemoryPolicy);
827 842
828 if (!m_renderer) 843 if (!m_renderer)
829 return; 844 return;
830 845
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController(); 1488 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController();
1474 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); 1489 double monotonicTime = (time - base::TimeTicks()).InSecondsF();
1475 if (scrollbarController && scrollbarController->animate(monotonicTime)) 1490 if (scrollbarController && scrollbarController->animate(monotonicTime))
1476 m_client->setNeedsRedrawOnImplThread(); 1491 m_client->setNeedsRedrawOnImplThread();
1477 1492
1478 for (size_t i = 0; i < layer->children().size(); ++i) 1493 for (size_t i = 0; i < layer->children().size(); ++i)
1479 animateScrollbarsRecursive(layer->children()[i], time); 1494 animateScrollbarsRecursive(layer->children()[i], time);
1480 } 1495 }
1481 1496
1482 } // namespace cc 1497 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_impl.h ('k') | cc/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698