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

Side by Side Diff: cc/layer_tree_host.cc

Issue 11414017: cc: handling debug settings in new LayerTreeDebugState structure (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rewrote to LayerTreeSwitches 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 "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"
21 #include "cc/occlusion_tracker.h" 20 #include "cc/occlusion_tracker.h"
22 #include "cc/overdraw_metrics.h" 21 #include "cc/overdraw_metrics.h"
23 #include "cc/single_thread_proxy.h" 22 #include "cc/single_thread_proxy.h"
24 #include "cc/switches.h" 23 #include "cc/switches.h"
25 #include "cc/thread.h" 24 #include "cc/thread.h"
26 #include "cc/thread_proxy.h" 25 #include "cc/thread_proxy.h"
27 #include "cc/tree_synchronizer.h" 26 #include "cc/tree_synchronizer.h"
28 27
29 using namespace std; 28 using namespace std;
30 29
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 LayerTreeSwitches::LayerTreeSwitches()
40 : acceleratePainting(false) 39 : showFPSCounter(false)
40 , showPlatformLayerTree(false)
41 , showDebugBorders(false) 41 , showDebugBorders(false)
42 , showPlatformLayerTree(false)
43 , showPaintRects(false) 42 , showPaintRects(false)
44 , showPropertyChangedRects(false) 43 , showPropertyChangedRects(false)
45 , showSurfaceDamageRects(false) 44 , showSurfaceDamageRects(false)
46 , showScreenSpaceRects(false) 45 , showScreenSpaceRects(false)
47 , showReplicaScreenSpaceRects(false) 46 , showReplicaScreenSpaceRects(false)
48 , showOccludingRects(false) 47 , showOccludingRects(false)
49 , showNonOccludingRects(false) 48 , showNonOccludingRects(false)
49 {
50 }
51
52 LayerTreeSwitches::~LayerTreeSwitches()
53 {
54 }
55
56 bool LayerTreeSwitches::showHudInfo() const
57 {
58 return showFPSCounter || showPlatformLayerTree || showHudRects();
59 }
60
61 bool LayerTreeSwitches::showHudRects() const
62 {
63 return showPaintRects || showPropertyChangedRects || showSurfaceDamageRects || showScreenSpaceRects || showReplicaScreenSpaceRects || showOccludingRects || showNonOccludingRects;
64 }
65
66 LayerTreeSwitches LayerTreeSwitches::merge(const LayerTreeSwitches& other) const
67 {
68 LayerTreeSwitches switches;
69
70 switches.showFPSCounter = showFPSCounter | other.showFPSCounter;
71 switches.showPlatformLayerTree = showPlatformLayerTree | other.showPlatformL ayerTree;
72 switches.showDebugBorders = showDebugBorders | other.showDebugBorders;
73
74 switches.showPaintRects = showPaintRects | other.showPaintRects;
75 switches.showPropertyChangedRects = showPropertyChangedRects | other.showPro pertyChangedRects;
76 switches.showSurfaceDamageRects = showSurfaceDamageRects | other.showSurface DamageRects;
77 switches.showScreenSpaceRects = showScreenSpaceRects | other.showScreenSpace Rects;
78 switches.showReplicaScreenSpaceRects = showReplicaScreenSpaceRects | other.s howReplicaScreenSpaceRects;
79 switches.showOccludingRects = showOccludingRects | other.showOccludingRects;
80 switches.showNonOccludingRects = showNonOccludingRects | other.showNonOcclud ingRects;
81
82 return switches;
83 }
84
85 LayerTreeSettings::LayerTreeSettings()
86 : acceleratePainting(false)
50 , renderVSyncEnabled(true) 87 , renderVSyncEnabled(true)
51 , perTilePaintingEnabled(false) 88 , perTilePaintingEnabled(false)
52 , partialSwapEnabled(false) 89 , partialSwapEnabled(false)
53 , acceleratedAnimationEnabled(true) 90 , acceleratedAnimationEnabled(true)
54 , pageScalePinchZoomEnabled(false) 91 , pageScalePinchZoomEnabled(false)
55 , backgroundColorInsteadOfCheckerboard(false) 92 , backgroundColorInsteadOfCheckerboard(false)
56 , showOverdrawInTracing(false) 93 , showOverdrawInTracing(false)
57 , refreshRate(0) 94 , refreshRate(0)
58 , maxPartialTextureUpdates(std::numeric_limits<size_t>::max()) 95 , maxPartialTextureUpdates(std::numeric_limits<size_t>::max())
59 , defaultTileSize(gfx::Size(256, 256)) 96 , defaultTileSize(gfx::Size(256, 256))
60 , maxUntiledLayerSize(gfx::Size(512, 512)) 97 , maxUntiledLayerSize(gfx::Size(512, 512))
61 , minimumOcclusionTrackingSize(gfx::Size(160, 160)) 98 , minimumOcclusionTrackingSize(gfx::Size(160, 160))
62 { 99 {
63 // TODO(danakj): Move this to chromium when we don't go through the WebKit A PI anymore. 100 // 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); 101 partialSwapEnabled = CommandLine::ForCurrentProcess()->HasSwitch(switches::k EnablePartialSwap);
71 backgroundColorInsteadOfCheckerboard = CommandLine::ForCurrentProcess()->Has Switch(switches::kBackgroundColorInsteadOfCheckerboard); 102 backgroundColorInsteadOfCheckerboard = CommandLine::ForCurrentProcess()->Has Switch(switches::kBackgroundColorInsteadOfCheckerboard);
72 showOverdrawInTracing = CommandLine::ForCurrentProcess()->HasSwitch(switches ::kTraceOverdraw); 103 showOverdrawInTracing = CommandLine::ForCurrentProcess()->HasSwitch(switches ::kTraceOverdraw);
104
105 initialSwitchSettings.showPropertyChangedRects = CommandLine::ForCurrentProc ess()->HasSwitch(cc::switches::kShowPropertyChangedRects);
106 initialSwitchSettings.showSurfaceDamageRects = CommandLine::ForCurrentProces s()->HasSwitch(cc::switches::kShowSurfaceDamageRects);
107 initialSwitchSettings.showScreenSpaceRects = CommandLine::ForCurrentProcess( )->HasSwitch(cc::switches::kShowScreenSpaceRects);
108 initialSwitchSettings.showReplicaScreenSpaceRects = CommandLine::ForCurrentP rocess()->HasSwitch(cc::switches::kShowReplicaScreenSpaceRects);
109 initialSwitchSettings.showOccludingRects = CommandLine::ForCurrentProcess()- >HasSwitch(cc::switches::kShowOccludingRects);
110 initialSwitchSettings.showNonOccludingRects = CommandLine::ForCurrentProcess ()->HasSwitch(cc::switches::kShowNonOccludingRects);
73 } 111 }
74 112
75 LayerTreeSettings::~LayerTreeSettings() 113 LayerTreeSettings::~LayerTreeSettings()
76 { 114 {
77 } 115 }
78 116
79 RendererCapabilities::RendererCapabilities() 117 RendererCapabilities::RendererCapabilities()
80 : bestTextureFormat(0) 118 : bestTextureFormat(0)
81 , contextHasCachedFrontBuffer(false) 119 , contextHasCachedFrontBuffer(false)
82 , usingPartialSwap(false) 120 , usingPartialSwap(false)
(...skipping 28 matching lines...) Expand all
111 : m_animating(false) 149 : m_animating(false)
112 , m_needsAnimateLayers(false) 150 , m_needsAnimateLayers(false)
113 , m_client(client) 151 , m_client(client)
114 , m_commitNumber(0) 152 , m_commitNumber(0)
115 , m_renderingStats() 153 , m_renderingStats()
116 , m_rendererInitialized(false) 154 , m_rendererInitialized(false)
117 , m_contextLost(false) 155 , m_contextLost(false)
118 , m_numTimesRecreateShouldFail(0) 156 , m_numTimesRecreateShouldFail(0)
119 , m_numFailedRecreateAttempts(0) 157 , m_numFailedRecreateAttempts(0)
120 , m_settings(settings) 158 , m_settings(settings)
159 , m_switches(settings.initialSwitchSettings)
121 , m_deviceScaleFactor(1) 160 , m_deviceScaleFactor(1)
122 , m_visible(true) 161 , m_visible(true)
123 , m_pageScaleFactor(1) 162 , m_pageScaleFactor(1)
124 , m_minPageScaleFactor(1) 163 , m_minPageScaleFactor(1)
125 , m_maxPageScaleFactor(1) 164 , m_maxPageScaleFactor(1)
126 , m_triggerIdleUpdates(true) 165 , m_triggerIdleUpdates(true)
127 , m_backgroundColor(SK_ColorWHITE) 166 , m_backgroundColor(SK_ColorWHITE)
128 , m_hasTransparentBackground(false) 167 , m_hasTransparentBackground(false)
129 , m_partialTextureUpdateRequests(0) 168 , m_partialTextureUpdateRequests(0)
130 { 169 {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 // to visit their controllers. 320 // to visit their controllers.
282 if (rootLayer() && m_needsAnimateLayers) 321 if (rootLayer() && m_needsAnimateLayers)
283 hostImpl->setNeedsAnimateLayers(); 322 hostImpl->setNeedsAnimateLayers();
284 323
285 hostImpl->setSourceFrameNumber(commitNumber()); 324 hostImpl->setSourceFrameNumber(commitNumber());
286 hostImpl->setViewportSize(layoutViewportSize(), deviceViewportSize()); 325 hostImpl->setViewportSize(layoutViewportSize(), deviceViewportSize());
287 hostImpl->setDeviceScaleFactor(deviceScaleFactor()); 326 hostImpl->setDeviceScaleFactor(deviceScaleFactor());
288 hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFacto r, m_maxPageScaleFactor); 327 hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFacto r, m_maxPageScaleFactor);
289 hostImpl->setBackgroundColor(m_backgroundColor); 328 hostImpl->setBackgroundColor(m_backgroundColor);
290 hostImpl->setHasTransparentBackground(m_hasTransparentBackground); 329 hostImpl->setHasTransparentBackground(m_hasTransparentBackground);
330 hostImpl->setSwitches(m_switches);
egraether 2012/11/22 00:23:15 The switches get pushed to hostImpl. No more need
291 331
292 m_commitNumber++; 332 m_commitNumber++;
293 } 333 }
294 334
295 void LayerTreeHost::createHUDLayerIfNeeded() 335 void LayerTreeHost::createHUDLayerIfNeeded()
296 { 336 {
297 if (!m_hudLayer) 337 if (!m_hudLayer)
298 m_hudLayer = HeadsUpDisplayLayer::create(); 338 m_hudLayer = HeadsUpDisplayLayer::create();
299 } 339 }
300 340
301 void LayerTreeHost::setShowFPSCounter(bool show)
302 {
303 createHUDLayerIfNeeded();
304 m_hudLayer->setShowFPSCounter(show);
305 }
306
307 void LayerTreeHost::setFontAtlas(scoped_ptr<FontAtlas> fontAtlas) 341 void LayerTreeHost::setFontAtlas(scoped_ptr<FontAtlas> fontAtlas)
308 { 342 {
309 createHUDLayerIfNeeded(); 343 createHUDLayerIfNeeded();
310 m_hudLayer->setFontAtlas(fontAtlas.Pass()); 344 m_hudLayer->setFontAtlas(fontAtlas.Pass());
311 } 345 }
312 346
313 void LayerTreeHost::willCommit() 347 void LayerTreeHost::willCommit()
314 { 348 {
315 m_client->willCommit(); 349 m_client->willCommit();
316 350
317 if (m_settings.showDebugInfo()) 351 if (m_switches.showHudInfo())
318 createHUDLayerIfNeeded(); 352 createHUDLayerIfNeeded();
319 353
320 if (m_rootLayer && m_hudLayer && !m_hudLayer->parent()) 354 if (m_rootLayer && m_hudLayer && !m_hudLayer->parent())
321 m_rootLayer->addChild(m_hudLayer); 355 m_rootLayer->addChild(m_hudLayer);
322 } 356 }
323 357
324 void LayerTreeHost::commitComplete() 358 void LayerTreeHost::commitComplete()
325 { 359 {
326 m_client->didCommit(); 360 m_client->didCommit();
327 } 361 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 m_rootLayer = rootLayer; 468 m_rootLayer = rootLayer;
435 if (m_rootLayer) 469 if (m_rootLayer)
436 m_rootLayer->setLayerTreeHost(this); 470 m_rootLayer->setLayerTreeHost(this);
437 471
438 if (m_hudLayer) 472 if (m_hudLayer)
439 m_hudLayer->removeFromParent(); 473 m_hudLayer->removeFromParent();
440 474
441 setNeedsCommit(); 475 setNeedsCommit();
442 } 476 }
443 477
478 void LayerTreeHost::setSwitches(const LayerTreeSwitches& switches)
479 {
480 m_switches = m_settings.initialSwitchSettings.merge(switches);
egraether 2012/11/22 00:23:15 The switches get or'ed together with the initial o
481 setNeedsCommit();
danakj 2012/11/26 19:57:18 We should avoid setting needsCommit if the new swi
482 }
483
444 void LayerTreeHost::setViewportSize(const gfx::Size& layoutViewportSize, const g fx::Size& deviceViewportSize) 484 void LayerTreeHost::setViewportSize(const gfx::Size& layoutViewportSize, const g fx::Size& deviceViewportSize)
445 { 485 {
446 if (layoutViewportSize == m_layoutViewportSize && deviceViewportSize == m_de viceViewportSize) 486 if (layoutViewportSize == m_layoutViewportSize && deviceViewportSize == m_de viceViewportSize)
447 return; 487 return;
448 488
449 m_layoutViewportSize = layoutViewportSize; 489 m_layoutViewportSize = layoutViewportSize;
450 m_deviceViewportSize = deviceViewportSize; 490 m_deviceViewportSize = deviceViewportSize;
451 491
452 setNeedsCommit(); 492 setNeedsCommit();
453 } 493 }
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 else 895 else
856 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); 896 layer->notifyAnimationFinished(wallClockTime.ToDoubleT());
857 } 897 }
858 } 898 }
859 899
860 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex) 900 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex)
861 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime); 901 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime);
862 } 902 }
863 903
864 } // namespace cc 904 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698