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" | 10 #include "cc/font_atlas.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 namespace { | 31 namespace { |
| 32 static int numLayerTreeInstances; | 32 static int numLayerTreeInstances; |
| 33 } | 33 } |
| 34 | 34 |
| 35 namespace cc { | 35 namespace cc { |
| 36 | 36 |
| 37 bool LayerTreeHost::s_needsFilterContext = false; | 37 bool LayerTreeHost::s_needsFilterContext = false; |
| 38 | 38 |
| 39 LayerTreeSettings::LayerTreeSettings() | 39 LayerTreeSettings::LayerTreeSettings() |
| 40 : acceleratePainting(false) | 40 : 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) | 41 , renderVSyncEnabled(true) |
| 51 , perTilePaintingEnabled(false) | 42 , perTilePaintingEnabled(false) |
| 52 , partialSwapEnabled(false) | 43 , partialSwapEnabled(false) |
| 53 , acceleratedAnimationEnabled(true) | 44 , acceleratedAnimationEnabled(true) |
| 54 , pageScalePinchZoomEnabled(false) | 45 , pageScalePinchZoomEnabled(false) |
| 55 , backgroundColorInsteadOfCheckerboard(false) | 46 , backgroundColorInsteadOfCheckerboard(false) |
| 56 , showOverdrawInTracing(false) | 47 , showOverdrawInTracing(false) |
| 57 , refreshRate(0) | 48 , refreshRate(0) |
| 58 , maxPartialTextureUpdates(std::numeric_limits<size_t>::max()) | 49 , maxPartialTextureUpdates(std::numeric_limits<size_t>::max()) |
| 59 , defaultTileSize(gfx::Size(256, 256)) | 50 , defaultTileSize(gfx::Size(256, 256)) |
| 60 , maxUntiledLayerSize(gfx::Size(512, 512)) | 51 , maxUntiledLayerSize(gfx::Size(512, 512)) |
| 61 , minimumOcclusionTrackingSize(gfx::Size(160, 160)) | 52 , minimumOcclusionTrackingSize(gfx::Size(160, 160)) |
| 62 { | 53 { |
| 63 // TODO(danakj): Move this to chromium when we don't go through the WebKit A PI anymore. | 54 // 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); | 55 partialSwapEnabled = CommandLine::ForCurrentProcess()->HasSwitch(switches::k EnablePartialSwap); |
| 71 backgroundColorInsteadOfCheckerboard = CommandLine::ForCurrentProcess()->Has Switch(switches::kBackgroundColorInsteadOfCheckerboard); | 56 backgroundColorInsteadOfCheckerboard = CommandLine::ForCurrentProcess()->Has Switch(switches::kBackgroundColorInsteadOfCheckerboard); |
| 72 showOverdrawInTracing = CommandLine::ForCurrentProcess()->HasSwitch(switches ::kTraceOverdraw); | 57 showOverdrawInTracing = CommandLine::ForCurrentProcess()->HasSwitch(switches ::kTraceOverdraw); |
| 73 } | 58 } |
| 74 | 59 |
| 75 LayerTreeSettings::~LayerTreeSettings() | 60 LayerTreeSettings::~LayerTreeSettings() |
| 76 { | 61 { |
| 77 } | 62 } |
| 78 | 63 |
| 79 RendererCapabilities::RendererCapabilities() | 64 RendererCapabilities::RendererCapabilities() |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 , m_visible(true) | 107 , m_visible(true) |
| 123 , m_pageScaleFactor(1) | 108 , m_pageScaleFactor(1) |
| 124 , m_minPageScaleFactor(1) | 109 , m_minPageScaleFactor(1) |
| 125 , m_maxPageScaleFactor(1) | 110 , m_maxPageScaleFactor(1) |
| 126 , m_triggerIdleUpdates(true) | 111 , m_triggerIdleUpdates(true) |
| 127 , m_backgroundColor(SK_ColorWHITE) | 112 , m_backgroundColor(SK_ColorWHITE) |
| 128 , m_hasTransparentBackground(false) | 113 , m_hasTransparentBackground(false) |
| 129 , m_partialTextureUpdateRequests(0) | 114 , m_partialTextureUpdateRequests(0) |
| 130 { | 115 { |
| 131 numLayerTreeInstances++; | 116 numLayerTreeInstances++; |
| 117 | |
| 118 HeadsUpDisplayLayerFlags flags; | |
| 119 | |
| 120 // TODO(danakj): Move this to chromium when we don't go through the WebKit A PI anymore. | |
| 121 flags.showPropertyChangedRects = CommandLine::ForCurrentProcess()->HasSwitch (cc::switches::kShowPropertyChangedRects); | |
|
egraether
2012/11/15 23:37:07
I moved the commandline reading for the rectangle
| |
| 122 flags.showSurfaceDamageRects = CommandLine::ForCurrentProcess()->HasSwitch(c c::switches::kShowSurfaceDamageRects); | |
| 123 flags.showScreenSpaceRects = CommandLine::ForCurrentProcess()->HasSwitch(cc: :switches::kShowScreenSpaceRects); | |
| 124 flags.showReplicaScreenSpaceRects = CommandLine::ForCurrentProcess()->HasSwi tch(cc::switches::kShowReplicaScreenSpaceRects); | |
| 125 flags.showOccludingRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::s witches::kShowOccludingRects); | |
| 126 flags.showNonOccludingRects = CommandLine::ForCurrentProcess()->HasSwitch(cc ::switches::kShowNonOccludingRects); | |
| 127 | |
| 128 if (flags.showDebugInfo()) | |
| 129 requestHUDLayer()->setFlags(flags); | |
| 132 } | 130 } |
| 133 | 131 |
| 134 bool LayerTreeHost::initialize(scoped_ptr<Thread> implThread) | 132 bool LayerTreeHost::initialize(scoped_ptr<Thread> implThread) |
| 135 { | 133 { |
| 136 TRACE_EVENT0("cc", "LayerTreeHost::initialize"); | 134 TRACE_EVENT0("cc", "LayerTreeHost::initialize"); |
| 137 | 135 |
| 138 if (implThread) | 136 if (implThread) |
| 139 m_proxy = ThreadProxy::create(this, implThread.Pass()); | 137 m_proxy = ThreadProxy::create(this, implThread.Pass()); |
| 140 else | 138 else |
| 141 m_proxy = SingleThreadProxy::create(this); | 139 m_proxy = SingleThreadProxy::create(this); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 hostImpl->setSourceFrameNumber(commitNumber()); | 283 hostImpl->setSourceFrameNumber(commitNumber()); |
| 286 hostImpl->setViewportSize(layoutViewportSize(), deviceViewportSize()); | 284 hostImpl->setViewportSize(layoutViewportSize(), deviceViewportSize()); |
| 287 hostImpl->setDeviceScaleFactor(deviceScaleFactor()); | 285 hostImpl->setDeviceScaleFactor(deviceScaleFactor()); |
| 288 hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFacto r, m_maxPageScaleFactor); | 286 hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFacto r, m_maxPageScaleFactor); |
| 289 hostImpl->setBackgroundColor(m_backgroundColor); | 287 hostImpl->setBackgroundColor(m_backgroundColor); |
| 290 hostImpl->setHasTransparentBackground(m_hasTransparentBackground); | 288 hostImpl->setHasTransparentBackground(m_hasTransparentBackground); |
| 291 | 289 |
| 292 m_commitNumber++; | 290 m_commitNumber++; |
| 293 } | 291 } |
| 294 | 292 |
| 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() | 293 void LayerTreeHost::willCommit() |
| 314 { | 294 { |
| 315 m_client->willCommit(); | 295 m_client->willCommit(); |
| 316 | 296 |
| 317 if (m_settings.showDebugInfo()) | |
| 318 createHUDLayerIfNeeded(); | |
| 319 | |
| 320 if (m_rootLayer && m_hudLayer && !m_hudLayer->parent()) | 297 if (m_rootLayer && m_hudLayer && !m_hudLayer->parent()) |
| 321 m_rootLayer->addChild(m_hudLayer); | 298 m_rootLayer->addChild(m_hudLayer); |
| 322 } | 299 } |
| 323 | 300 |
| 324 void LayerTreeHost::commitComplete() | 301 void LayerTreeHost::commitComplete() |
| 325 { | 302 { |
| 326 m_client->didCommit(); | 303 m_client->didCommit(); |
| 327 } | 304 } |
| 328 | 305 |
| 329 scoped_ptr<GraphicsContext> LayerTreeHost::createContext() | 306 scoped_ptr<GraphicsContext> LayerTreeHost::createContext() |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 805 | 782 |
| 806 void LayerTreeHost::setDeviceScaleFactor(float deviceScaleFactor) | 783 void LayerTreeHost::setDeviceScaleFactor(float deviceScaleFactor) |
| 807 { | 784 { |
| 808 if (deviceScaleFactor == m_deviceScaleFactor) | 785 if (deviceScaleFactor == m_deviceScaleFactor) |
| 809 return; | 786 return; |
| 810 m_deviceScaleFactor = deviceScaleFactor; | 787 m_deviceScaleFactor = deviceScaleFactor; |
| 811 | 788 |
| 812 setNeedsCommit(); | 789 setNeedsCommit(); |
| 813 } | 790 } |
| 814 | 791 |
| 792 HeadsUpDisplayLayer* LayerTreeHost::requestHUDLayer() | |
| 793 { | |
| 794 if (!m_hudLayer.get()) | |
| 795 m_hudLayer = HeadsUpDisplayLayer::create(); | |
| 796 | |
| 797 return m_hudLayer.get(); | |
| 798 } | |
| 799 | |
| 815 void LayerTreeHost::animateLayers(base::TimeTicks time) | 800 void LayerTreeHost::animateLayers(base::TimeTicks time) |
| 816 { | 801 { |
| 817 if (!m_settings.acceleratedAnimationEnabled || !m_needsAnimateLayers) | 802 if (!m_settings.acceleratedAnimationEnabled || !m_needsAnimateLayers) |
| 818 return; | 803 return; |
| 819 | 804 |
| 820 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); | 805 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); |
| 821 m_needsAnimateLayers = animateLayersRecursive(m_rootLayer.get(), time); | 806 m_needsAnimateLayers = animateLayersRecursive(m_rootLayer.get(), time); |
| 822 } | 807 } |
| 823 | 808 |
| 824 bool LayerTreeHost::animateLayersRecursive(Layer* current, base::TimeTicks time) | 809 bool LayerTreeHost::animateLayersRecursive(Layer* current, base::TimeTicks time) |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 855 else | 840 else |
| 856 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); | 841 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); |
| 857 } | 842 } |
| 858 } | 843 } |
| 859 | 844 |
| 860 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex) | 845 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex) |
| 861 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime); | 846 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime); |
| 862 } | 847 } |
| 863 | 848 |
| 864 } // namespace cc | 849 } // namespace cc |
| OLD | NEW |