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

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 Dana's code review suggestions 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 "CCAppendQuadsData.h" 9 #include "CCAppendQuadsData.h"
10 #include "CCDamageTracker.h" 10 #include "CCDamageTracker.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 { 166 {
167 m_timeSource->setClient(0); 167 m_timeSource->setClient(0);
168 m_timeSource->setActive(false); 168 m_timeSource->setActive(false);
169 } 169 }
170 170
171 virtual void onTimerTick() OVERRIDE 171 virtual void onTimerTick() OVERRIDE
172 { 172 {
173 // FIXME: We require that animate be called on the impl thread. This 173 // FIXME: We require that animate be called on the impl thread. This
174 // avoids asserts in single threaded mode. Ideally background ticking 174 // avoids asserts in single threaded mode. Ideally background ticking
175 // would be handled by the proxy/scheduler and this could be removed. 175 // would be handled by the proxy/scheduler and this could be removed.
176 DebugScopedSetImplThread impl; 176 DebugScopedSetImplThread impl(m_layerTreeHostImpl->proxy());
177 177
178 m_layerTreeHostImpl->animate(monotonicallyIncreasingTime(), currentTime( )); 178 m_layerTreeHostImpl->animate(monotonicallyIncreasingTime(), currentTime( ));
179 } 179 }
180 180
181 void setActive(bool active) 181 void setActive(bool active)
182 { 182 {
183 if (active != m_timeSource->active()) 183 if (active != m_timeSource->active())
184 m_timeSource->setActive(active); 184 m_timeSource->setActive(active);
185 } 185 }
186 186
(...skipping 12 matching lines...) Expand all
199 }; 199 };
200 200
201 LayerTreeHostImpl::FrameData::FrameData() 201 LayerTreeHostImpl::FrameData::FrameData()
202 { 202 {
203 } 203 }
204 204
205 LayerTreeHostImpl::FrameData::~FrameData() 205 LayerTreeHostImpl::FrameData::~FrameData()
206 { 206 {
207 } 207 }
208 208
209 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::create(const LayerTreeSettings& settings, LayerTreeHostImplClient* client) 209 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::create(const LayerTreeSettings& settings, LayerTreeHostImplClient* client, Proxy* proxy)
210 { 210 {
211 return make_scoped_ptr(new LayerTreeHostImpl(settings, client)); 211 return make_scoped_ptr(new LayerTreeHostImpl(settings, client, proxy));
212 } 212 }
213 213
214 LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre eHostImplClient* client) 214 LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre eHostImplClient* client, Proxy* proxy)
215 : m_client(client) 215 : m_client(client)
216 , m_proxy(proxy)
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_managedMemoryPolicy(PrioritizedTextureManager::defaultMemoryAllocationLi mit(), 227 , m_managedMemoryPolicy(PrioritizedTextureManager::defaultMemoryAllocationLi mit(),
227 PriorityCalculator::allowEverythingCutoff(), 228 PriorityCalculator::allowEverythingCutoff(),
228 0, 229 0,
229 PriorityCalculator::allowNothingCutoff()) 230 PriorityCalculator::allowNothingCutoff())
230 , m_backgroundColor(0) 231 , m_backgroundColor(0)
231 , m_hasTransparentBackground(false) 232 , m_hasTransparentBackground(false)
232 , m_needsAnimateLayers(false) 233 , m_needsAnimateLayers(false)
233 , m_pinchGestureActive(false) 234 , m_pinchGestureActive(false)
234 , m_fpsCounter(FrameRateCounter::create()) 235 , m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread()))
235 , m_debugRectHistory(DebugRectHistory::create()) 236 , m_debugRectHistory(DebugRectHistory::create())
236 , m_numImplThreadScrolls(0) 237 , m_numImplThreadScrolls(0)
237 , m_numMainThreadScrolls(0) 238 , m_numMainThreadScrolls(0)
238 { 239 {
239 DCHECK(Proxy::isImplThread()); 240 DCHECK(m_proxy->isImplThread());
240 didVisibilityChange(this, m_visible); 241 didVisibilityChange(this, m_visible);
241 } 242 }
242 243
243 LayerTreeHostImpl::~LayerTreeHostImpl() 244 LayerTreeHostImpl::~LayerTreeHostImpl()
244 { 245 {
245 DCHECK(Proxy::isImplThread()); 246 DCHECK(m_proxy->isImplThread());
246 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); 247 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()");
247 248
248 if (m_rootLayerImpl) 249 if (m_rootLayerImpl)
249 clearRenderSurfaces(); 250 clearRenderSurfaces();
250 } 251 }
251 252
252 void LayerTreeHostImpl::beginCommit() 253 void LayerTreeHostImpl::beginCommit()
253 { 254 {
254 } 255 }
255 256
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 subtreeNeedsAnimateLayers = true; 499 subtreeNeedsAnimateLayers = true;
499 } 500 }
500 501
501 needsAnimateLayers = subtreeNeedsAnimateLayers; 502 needsAnimateLayers = subtreeNeedsAnimateLayers;
502 } 503 }
503 504
504 void LayerTreeHostImpl::setBackgroundTickingEnabled(bool enabled) 505 void LayerTreeHostImpl::setBackgroundTickingEnabled(bool enabled)
505 { 506 {
506 // Lazily create the timeSource adapter so that we can vary the interval for testing. 507 // Lazily create the timeSource adapter so that we can vary the interval for testing.
507 if (!m_timeSourceClientAdapter) 508 if (!m_timeSourceClientAdapter)
508 m_timeSourceClientAdapter = LayerTreeHostImplTimeSourceAdapter::create(t his, DelayBasedTimeSource::create(lowFrequencyAnimationInterval(), Proxy::curren tThread())); 509 m_timeSourceClientAdapter = LayerTreeHostImplTimeSourceAdapter::create(t his, DelayBasedTimeSource::create(lowFrequencyAnimationInterval(), m_proxy->curr entThread()));
509 510
510 m_timeSourceClientAdapter->setActive(enabled); 511 m_timeSourceClientAdapter->setActive(enabled);
511 } 512 }
512 513
513 IntSize LayerTreeHostImpl::contentSize() const 514 IntSize LayerTreeHostImpl::contentSize() const
514 { 515 {
515 // TODO(aelias): Hardcoding the first child here is weird. Think of 516 // TODO(aelias): Hardcoding the first child here is weird. Think of
516 // a cleaner way to get the contentBounds on the Impl side. 517 // a cleaner way to get the contentBounds on the Impl side.
517 if (!m_rootScrollLayerImpl || m_rootScrollLayerImpl->children().isEmpty()) 518 if (!m_rootScrollLayerImpl || m_rootScrollLayerImpl->children().isEmpty())
518 return IntSize(); 519 return IntSize();
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 setContentsTexturesPurged(); 647 setContentsTexturesPurged();
647 m_client->setNeedsCommitOnImplThread(); 648 m_client->setNeedsCommitOnImplThread();
648 m_client->onCanDrawStateChanged(canDraw()); 649 m_client->onCanDrawStateChanged(canDraw());
649 } 650 }
650 } 651 }
651 652
652 void LayerTreeHostImpl::setManagedMemoryPolicy(const ManagedMemoryPolicy& policy ) 653 void LayerTreeHostImpl::setManagedMemoryPolicy(const ManagedMemoryPolicy& policy )
653 { 654 {
654 if (m_managedMemoryPolicy == policy) 655 if (m_managedMemoryPolicy == policy)
655 return; 656 return;
657
658 // FIXME: In single-thread mode, this can be called on the main thread
659 // by GLRenderer::onMemoryAllocationChanged.
660 DebugScopedSetImplThread implThread(m_proxy);
661
656 m_managedMemoryPolicy = policy; 662 m_managedMemoryPolicy = policy;
657 enforceManagedMemoryPolicy(m_managedMemoryPolicy); 663 enforceManagedMemoryPolicy(m_managedMemoryPolicy);
658 // We always need to commit after changing the memory policy because the new 664 // 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. 665 // limit can result in more or less content having texture allocated for it.
660 m_client->setNeedsCommitOnImplThread(); 666 m_client->setNeedsCommitOnImplThread();
661 } 667 }
662 668
663 void LayerTreeHostImpl::onVSyncParametersChanged(double monotonicTimebase, doubl e intervalInSeconds) 669 void LayerTreeHostImpl::onVSyncParametersChanged(double monotonicTimebase, doubl e intervalInSeconds)
664 { 670 {
665 m_client->onVSyncParametersChanged(monotonicTimebase, intervalInSeconds); 671 m_client->onVSyncParametersChanged(monotonicTimebase, intervalInSeconds);
(...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. 816 // Clear all data structures that have direct references to the layer tree.
811 m_scrollingLayerIdFromPreviousTree = m_currentlyScrollingLayerImpl ? m_curre ntlyScrollingLayerImpl->id() : -1; 817 m_scrollingLayerIdFromPreviousTree = m_currentlyScrollingLayerImpl ? m_curre ntlyScrollingLayerImpl->id() : -1;
812 m_currentlyScrollingLayerImpl = 0; 818 m_currentlyScrollingLayerImpl = 0;
813 m_renderSurfaceLayerList.clear(); 819 m_renderSurfaceLayerList.clear();
814 820
815 return m_rootLayerImpl.Pass(); 821 return m_rootLayerImpl.Pass();
816 } 822 }
817 823
818 void LayerTreeHostImpl::setVisible(bool visible) 824 void LayerTreeHostImpl::setVisible(bool visible)
819 { 825 {
820 DCHECK(Proxy::isImplThread()); 826 DCHECK(m_proxy->isImplThread());
821 827
822 if (m_visible == visible) 828 if (m_visible == visible)
823 return; 829 return;
824 m_visible = visible; 830 m_visible = visible;
825 didVisibilityChange(this, m_visible); 831 didVisibilityChange(this, m_visible);
826 enforceManagedMemoryPolicy(m_managedMemoryPolicy); 832 enforceManagedMemoryPolicy(m_managedMemoryPolicy);
827 833
828 if (!m_renderer) 834 if (!m_renderer)
829 return; 835 return;
830 836
(...skipping 17 matching lines...) Expand all
848 m_context.reset(); 854 m_context.reset();
849 855
850 if (!context->bindToClient(this)) 856 if (!context->bindToClient(this))
851 return false; 857 return false;
852 858
853 scoped_ptr<ResourceProvider> resourceProvider = ResourceProvider::create(con text.get()); 859 scoped_ptr<ResourceProvider> resourceProvider = ResourceProvider::create(con text.get());
854 if (!resourceProvider) 860 if (!resourceProvider)
855 return false; 861 return false;
856 862
857 if (context->context3D()) 863 if (context->context3D())
858 m_renderer = GLRenderer::create(this, resourceProvider.get()); 864 m_renderer = GLRenderer::create(this, resourceProvider.get(), m_proxy->h asImplThread());
859 else if (context->softwareDevice()) 865 else if (context->softwareDevice())
860 m_renderer = SoftwareRenderer::create(this, resourceProvider.get(), cont ext->softwareDevice()); 866 m_renderer = SoftwareRenderer::create(this, resourceProvider.get(), cont ext->softwareDevice(), m_proxy->hasImplThread());
861 if (!m_renderer) 867 if (!m_renderer)
862 return false; 868 return false;
863 869
864 m_resourceProvider = resourceProvider.Pass(); 870 m_resourceProvider = resourceProvider.Pass();
865 m_context = context.Pass(); 871 m_context = context.Pass();
866 872
867 if (!m_visible) 873 if (!m_visible)
868 m_renderer->setVisible(m_visible); 874 m_renderer->setVisible(m_visible);
869 875
870 m_client->onCanDrawStateChanged(canDraw()); 876 m_client->onCanDrawStateChanged(canDraw());
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 1487
1482 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController(); 1488 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController();
1483 if (scrollbarController && scrollbarController->animate(monotonicTime)) 1489 if (scrollbarController && scrollbarController->animate(monotonicTime))
1484 m_client->setNeedsRedrawOnImplThread(); 1490 m_client->setNeedsRedrawOnImplThread();
1485 1491
1486 for (size_t i = 0; i < layer->children().size(); ++i) 1492 for (size_t i = 0; i < layer->children().size(); ++i)
1487 animateScrollbarsRecursive(layer->children()[i], monotonicTime); 1493 animateScrollbarsRecursive(layer->children()[i], monotonicTime);
1488 } 1494 }
1489 1495
1490 } // namespace cc 1496 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698