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

Side by Side Diff: cc/layer_tree_host_impl.cc

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