Chromium Code Reviews| 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 "cc/layer_tree_host.h" | 5 #include "cc/layer_tree_host.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "cc/font_atlas.h" | |
| 11 #include "cc/graphics_context.h" | 10 #include "cc/graphics_context.h" |
| 12 #include "cc/heads_up_display_layer.h" | 11 #include "cc/heads_up_display_layer.h" |
| 13 #include "cc/heads_up_display_layer_impl.h" | 12 #include "cc/heads_up_display_layer_impl.h" |
| 14 #include "cc/layer.h" | 13 #include "cc/layer.h" |
| 15 #include "cc/layer_animation_controller.h" | 14 #include "cc/layer_animation_controller.h" |
| 16 #include "cc/layer_iterator.h" | 15 #include "cc/layer_iterator.h" |
| 17 #include "cc/layer_tree_host_client.h" | 16 #include "cc/layer_tree_host_client.h" |
| 18 #include "cc/layer_tree_host_common.h" | 17 #include "cc/layer_tree_host_common.h" |
| 19 #include "cc/layer_tree_host_impl.h" | 18 #include "cc/layer_tree_host_impl.h" |
| 20 #include "cc/math_util.h" | 19 #include "cc/math_util.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 31 namespace { | 30 namespace { |
| 32 static int numLayerTreeInstances; | 31 static int numLayerTreeInstances; |
| 33 } | 32 } |
| 34 | 33 |
| 35 namespace cc { | 34 namespace cc { |
| 36 | 35 |
| 37 bool LayerTreeHost::s_needsFilterContext = false; | 36 bool LayerTreeHost::s_needsFilterContext = false; |
| 38 | 37 |
| 39 LayerTreeSettings::LayerTreeSettings() | 38 LayerTreeSettings::LayerTreeSettings() |
| 40 : acceleratePainting(false) | 39 : acceleratePainting(false) |
| 41 , showDebugBorders(false) | |
| 42 , showPlatformLayerTree(false) | |
| 43 , showPaintRects(false) | |
| 44 , showPropertyChangedRects(false) | |
| 45 , showSurfaceDamageRects(false) | |
| 46 , showScreenSpaceRects(false) | |
| 47 , showReplicaScreenSpaceRects(false) | |
| 48 , showOccludingRects(false) | |
| 49 , showNonOccludingRects(false) | |
| 50 , renderVSyncEnabled(true) | 40 , renderVSyncEnabled(true) |
| 51 , perTilePaintingEnabled(false) | 41 , perTilePaintingEnabled(false) |
| 52 , partialSwapEnabled(false) | 42 , partialSwapEnabled(false) |
| 53 , acceleratedAnimationEnabled(true) | 43 , acceleratedAnimationEnabled(true) |
| 54 , pageScalePinchZoomEnabled(false) | 44 , pageScalePinchZoomEnabled(false) |
| 55 , backgroundColorInsteadOfCheckerboard(false) | 45 , backgroundColorInsteadOfCheckerboard(false) |
| 56 , showOverdrawInTracing(false) | 46 , showOverdrawInTracing(false) |
| 57 , refreshRate(0) | 47 , refreshRate(0) |
| 58 , maxPartialTextureUpdates(std::numeric_limits<size_t>::max()) | 48 , maxPartialTextureUpdates(std::numeric_limits<size_t>::max()) |
| 59 , defaultTileSize(gfx::Size(256, 256)) | 49 , defaultTileSize(gfx::Size(256, 256)) |
| 60 , maxUntiledLayerSize(gfx::Size(512, 512)) | 50 , maxUntiledLayerSize(gfx::Size(512, 512)) |
| 61 , minimumOcclusionTrackingSize(gfx::Size(160, 160)) | 51 , minimumOcclusionTrackingSize(gfx::Size(160, 160)) |
| 62 { | 52 { |
| 63 // TODO(danakj): Move this to chromium when we don't go through the WebKit A PI anymore. | 53 // TODO(danakj): Move this to chromium when we don't go through the WebKit A PI anymore. |
| 64 showPropertyChangedRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::s witches::kShowPropertyChangedRects); | |
| 65 showSurfaceDamageRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::swi tches::kShowSurfaceDamageRects); | |
| 66 showScreenSpaceRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::switc hes::kShowScreenSpaceRects); | |
| 67 showReplicaScreenSpaceRects = CommandLine::ForCurrentProcess()->HasSwitch(cc ::switches::kShowReplicaScreenSpaceRects); | |
| 68 showOccludingRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::switche s::kShowOccludingRects); | |
| 69 showNonOccludingRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::swit ches::kShowNonOccludingRects); | |
| 70 partialSwapEnabled = CommandLine::ForCurrentProcess()->HasSwitch(switches::k EnablePartialSwap); | 54 partialSwapEnabled = CommandLine::ForCurrentProcess()->HasSwitch(switches::k EnablePartialSwap); |
| 71 backgroundColorInsteadOfCheckerboard = CommandLine::ForCurrentProcess()->Has Switch(switches::kBackgroundColorInsteadOfCheckerboard); | 55 backgroundColorInsteadOfCheckerboard = CommandLine::ForCurrentProcess()->Has Switch(switches::kBackgroundColorInsteadOfCheckerboard); |
| 72 showOverdrawInTracing = CommandLine::ForCurrentProcess()->HasSwitch(switches ::kTraceOverdraw); | 56 showOverdrawInTracing = CommandLine::ForCurrentProcess()->HasSwitch(switches ::kTraceOverdraw); |
| 57 | |
| 58 globalHudLayerSettings.showPropertyChangedRects = CommandLine::ForCurrentPro cess()->HasSwitch(cc::switches::kShowPropertyChangedRects); | |
| 59 globalHudLayerSettings.showSurfaceDamageRects = CommandLine::ForCurrentProce ss()->HasSwitch(cc::switches::kShowSurfaceDamageRects); | |
| 60 globalHudLayerSettings.showScreenSpaceRects = CommandLine::ForCurrentProcess ()->HasSwitch(cc::switches::kShowScreenSpaceRects); | |
| 61 globalHudLayerSettings.showReplicaScreenSpaceRects = CommandLine::ForCurrent Process()->HasSwitch(cc::switches::kShowReplicaScreenSpaceRects); | |
| 62 globalHudLayerSettings.showOccludingRects = CommandLine::ForCurrentProcess() ->HasSwitch(cc::switches::kShowOccludingRects); | |
| 63 globalHudLayerSettings.showNonOccludingRects = CommandLine::ForCurrentProces s()->HasSwitch(cc::switches::kShowNonOccludingRects); | |
| 73 } | 64 } |
| 74 | 65 |
| 75 LayerTreeSettings::~LayerTreeSettings() | 66 LayerTreeSettings::~LayerTreeSettings() |
| 76 { | 67 { |
| 77 } | 68 } |
| 78 | 69 |
| 79 RendererCapabilities::RendererCapabilities() | 70 RendererCapabilities::RendererCapabilities() |
| 80 : bestTextureFormat(0) | 71 : bestTextureFormat(0) |
| 81 , contextHasCachedFrontBuffer(false) | 72 , contextHasCachedFrontBuffer(false) |
| 82 , usingPartialSwap(false) | 73 , usingPartialSwap(false) |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 hostImpl->setSourceFrameNumber(commitNumber()); | 276 hostImpl->setSourceFrameNumber(commitNumber()); |
| 286 hostImpl->setViewportSize(layoutViewportSize(), deviceViewportSize()); | 277 hostImpl->setViewportSize(layoutViewportSize(), deviceViewportSize()); |
| 287 hostImpl->setDeviceScaleFactor(deviceScaleFactor()); | 278 hostImpl->setDeviceScaleFactor(deviceScaleFactor()); |
| 288 hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFacto r, m_maxPageScaleFactor); | 279 hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFacto r, m_maxPageScaleFactor); |
| 289 hostImpl->setBackgroundColor(m_backgroundColor); | 280 hostImpl->setBackgroundColor(m_backgroundColor); |
| 290 hostImpl->setHasTransparentBackground(m_hasTransparentBackground); | 281 hostImpl->setHasTransparentBackground(m_hasTransparentBackground); |
| 291 | 282 |
| 292 m_commitNumber++; | 283 m_commitNumber++; |
| 293 } | 284 } |
| 294 | 285 |
| 295 void LayerTreeHost::createHUDLayerIfNeeded() | |
| 296 { | |
| 297 if (!m_hudLayer) | |
| 298 m_hudLayer = HeadsUpDisplayLayer::create(); | |
| 299 } | |
| 300 | |
| 301 void LayerTreeHost::setShowFPSCounter(bool show) | |
| 302 { | |
| 303 createHUDLayerIfNeeded(); | |
| 304 m_hudLayer->setShowFPSCounter(show); | |
| 305 } | |
| 306 | |
| 307 void LayerTreeHost::setFontAtlas(scoped_ptr<FontAtlas> fontAtlas) | |
| 308 { | |
| 309 createHUDLayerIfNeeded(); | |
| 310 m_hudLayer->setFontAtlas(fontAtlas.Pass()); | |
| 311 } | |
| 312 | |
| 313 void LayerTreeHost::willCommit() | 286 void LayerTreeHost::willCommit() |
| 314 { | 287 { |
| 315 m_client->willCommit(); | 288 m_client->willCommit(); |
| 316 | 289 |
| 317 if (m_settings.showDebugInfo()) | 290 HeadsUpDisplayLayerSettings settings = m_settings.globalHudLayerSettings.mer ge(m_localHUDLayerSettings); |
|
egraether
2012/11/20 21:30:30
or'ing global and local settings
| |
| 318 createHUDLayerIfNeeded(); | |
| 319 | 291 |
| 320 if (m_rootLayer && m_hudLayer && !m_hudLayer->parent()) | 292 if (settings.showDebugInfo()) |
| 321 m_rootLayer->addChild(m_hudLayer); | 293 requestHudLayer(); |
| 294 | |
| 295 if (m_hudLayer) { | |
| 296 m_hudLayer->setSettings(settings); | |
| 297 | |
| 298 if (m_rootLayer && !m_hudLayer->parent()) | |
| 299 m_rootLayer->addChild(m_hudLayer); | |
| 300 } | |
| 322 } | 301 } |
| 323 | 302 |
| 324 void LayerTreeHost::commitComplete() | 303 void LayerTreeHost::commitComplete() |
| 325 { | 304 { |
| 326 m_client->didCommit(); | 305 m_client->didCommit(); |
| 327 } | 306 } |
| 328 | 307 |
| 329 scoped_ptr<GraphicsContext> LayerTreeHost::createContext() | 308 scoped_ptr<GraphicsContext> LayerTreeHost::createContext() |
| 330 { | 309 { |
| 331 return m_client->createOutputSurface(); | 310 return m_client->createOutputSurface(); |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 805 | 784 |
| 806 void LayerTreeHost::setDeviceScaleFactor(float deviceScaleFactor) | 785 void LayerTreeHost::setDeviceScaleFactor(float deviceScaleFactor) |
| 807 { | 786 { |
| 808 if (deviceScaleFactor == m_deviceScaleFactor) | 787 if (deviceScaleFactor == m_deviceScaleFactor) |
| 809 return; | 788 return; |
| 810 m_deviceScaleFactor = deviceScaleFactor; | 789 m_deviceScaleFactor = deviceScaleFactor; |
| 811 | 790 |
| 812 setNeedsCommit(); | 791 setNeedsCommit(); |
| 813 } | 792 } |
| 814 | 793 |
| 794 HeadsUpDisplayLayer* LayerTreeHost::requestHudLayer() | |
| 795 { | |
| 796 if (!m_hudLayer.get()) | |
| 797 m_hudLayer = HeadsUpDisplayLayer::create(); | |
| 798 | |
| 799 return m_hudLayer.get(); | |
| 800 } | |
| 801 | |
| 802 void LayerTreeHost::setHudLayerSettings(const HeadsUpDisplayLayerSettings& setti ngs) | |
| 803 { | |
| 804 m_localHUDLayerSettings = settings; | |
| 805 setNeedsCommit(); | |
| 806 } | |
| 807 | |
| 815 void LayerTreeHost::animateLayers(base::TimeTicks time) | 808 void LayerTreeHost::animateLayers(base::TimeTicks time) |
| 816 { | 809 { |
| 817 if (!m_settings.acceleratedAnimationEnabled || !m_needsAnimateLayers) | 810 if (!m_settings.acceleratedAnimationEnabled || !m_needsAnimateLayers) |
| 818 return; | 811 return; |
| 819 | 812 |
| 820 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); | 813 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); |
| 821 m_needsAnimateLayers = animateLayersRecursive(m_rootLayer.get(), time); | 814 m_needsAnimateLayers = animateLayersRecursive(m_rootLayer.get(), time); |
| 822 } | 815 } |
| 823 | 816 |
| 824 bool LayerTreeHost::animateLayersRecursive(Layer* current, base::TimeTicks time) | 817 bool LayerTreeHost::animateLayersRecursive(Layer* current, base::TimeTicks time) |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 855 else | 848 else |
| 856 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); | 849 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); |
| 857 } | 850 } |
| 858 } | 851 } |
| 859 | 852 |
| 860 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex) | 853 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex) |
| 861 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime); | 854 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime); |
| 862 } | 855 } |
| 863 | 856 |
| 864 } // namespace cc | 857 } // namespace cc |
| OLD | NEW |