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

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

Powered by Google App Engine
This is Rietveld 408576698