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 18 matching lines...) Expand all Loading... |
29 using namespace std; | 29 using namespace std; |
30 | 30 |
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 LayerTreeDebugState::LayerTreeDebugState() |
40 : acceleratePainting(false) | 40 : showFPSCounter(false) |
41 , implSidePainting(false) | 41 , showPlatformLayerTree(false) |
42 , showDebugBorders(false) | 42 , showDebugBorders(false) |
43 , showPlatformLayerTree(false) | |
44 , showPaintRects(false) | 43 , showPaintRects(false) |
45 , showPropertyChangedRects(false) | 44 , showPropertyChangedRects(false) |
46 , showSurfaceDamageRects(false) | 45 , showSurfaceDamageRects(false) |
47 , showScreenSpaceRects(false) | 46 , showScreenSpaceRects(false) |
48 , showReplicaScreenSpaceRects(false) | 47 , showReplicaScreenSpaceRects(false) |
49 , showOccludingRects(false) | 48 , showOccludingRects(false) |
50 , showNonOccludingRects(false) | 49 , showNonOccludingRects(false) |
| 50 { |
| 51 } |
| 52 |
| 53 LayerTreeDebugState::~LayerTreeDebugState() |
| 54 { |
| 55 } |
| 56 |
| 57 bool LayerTreeDebugState::showHudInfo() const |
| 58 { |
| 59 return showFPSCounter || showPlatformLayerTree || showHudRects(); |
| 60 } |
| 61 |
| 62 bool LayerTreeDebugState::showHudRects() const |
| 63 { |
| 64 return showPaintRects || showPropertyChangedRects || showSurfaceDamageRects
|| showScreenSpaceRects || showReplicaScreenSpaceRects || showOccludingRects ||
showNonOccludingRects; |
| 65 } |
| 66 |
| 67 bool LayerTreeDebugState::equal(const LayerTreeDebugState& a, const LayerTreeDeb
ugState& b) |
| 68 { |
| 69 return memcmp(&a, &b, sizeof(LayerTreeDebugState)) == 0; |
| 70 } |
| 71 |
| 72 LayerTreeDebugState LayerTreeDebugState::unite(const LayerTreeDebugState& a, con
st LayerTreeDebugState& b) |
| 73 { |
| 74 LayerTreeDebugState r(a); |
| 75 |
| 76 r.showFPSCounter |= b.showFPSCounter; |
| 77 r.showPlatformLayerTree |= b.showPlatformLayerTree; |
| 78 r.showDebugBorders |= b.showDebugBorders; |
| 79 |
| 80 r.showPaintRects |= b.showPaintRects; |
| 81 r.showPropertyChangedRects |= b.showPropertyChangedRects; |
| 82 r.showSurfaceDamageRects |= b.showSurfaceDamageRects; |
| 83 r.showScreenSpaceRects |= b.showScreenSpaceRects; |
| 84 r.showReplicaScreenSpaceRects |= b.showReplicaScreenSpaceRects; |
| 85 r.showOccludingRects |= b.showOccludingRects; |
| 86 r.showNonOccludingRects |= b.showNonOccludingRects; |
| 87 |
| 88 return r; |
| 89 } |
| 90 |
| 91 LayerTreeSettings::LayerTreeSettings() |
| 92 : acceleratePainting(false) |
| 93 , implSidePainting(false) |
51 , renderVSyncEnabled(true) | 94 , renderVSyncEnabled(true) |
52 , perTilePaintingEnabled(false) | 95 , perTilePaintingEnabled(false) |
53 , partialSwapEnabled(false) | 96 , partialSwapEnabled(false) |
54 , acceleratedAnimationEnabled(true) | 97 , acceleratedAnimationEnabled(true) |
55 , pageScalePinchZoomEnabled(false) | 98 , pageScalePinchZoomEnabled(false) |
56 , backgroundColorInsteadOfCheckerboard(false) | 99 , backgroundColorInsteadOfCheckerboard(false) |
57 , showOverdrawInTracing(false) | 100 , showOverdrawInTracing(false) |
58 , refreshRate(0) | 101 , refreshRate(0) |
59 , maxPartialTextureUpdates(std::numeric_limits<size_t>::max()) | 102 , maxPartialTextureUpdates(std::numeric_limits<size_t>::max()) |
60 , defaultTileSize(gfx::Size(256, 256)) | 103 , defaultTileSize(gfx::Size(256, 256)) |
61 , maxUntiledLayerSize(gfx::Size(512, 512)) | 104 , maxUntiledLayerSize(gfx::Size(512, 512)) |
62 , minimumOcclusionTrackingSize(gfx::Size(160, 160)) | 105 , minimumOcclusionTrackingSize(gfx::Size(160, 160)) |
63 { | 106 { |
64 // TODO(danakj): Move this to chromium when we don't go through the WebKit A
PI anymore. | 107 // TODO(danakj): Move this to chromium when we don't go through the WebKit A
PI anymore. |
65 showPropertyChangedRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::s
witches::kShowPropertyChangedRects); | |
66 showSurfaceDamageRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::swi
tches::kShowSurfaceDamageRects); | |
67 showScreenSpaceRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::switc
hes::kShowScreenSpaceRects); | |
68 showReplicaScreenSpaceRects = CommandLine::ForCurrentProcess()->HasSwitch(cc
::switches::kShowReplicaScreenSpaceRects); | |
69 showOccludingRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::switche
s::kShowOccludingRects); | |
70 showNonOccludingRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::swit
ches::kShowNonOccludingRects); | |
71 partialSwapEnabled = CommandLine::ForCurrentProcess()->HasSwitch(switches::k
EnablePartialSwap); | 108 partialSwapEnabled = CommandLine::ForCurrentProcess()->HasSwitch(switches::k
EnablePartialSwap); |
72 backgroundColorInsteadOfCheckerboard = CommandLine::ForCurrentProcess()->Has
Switch(switches::kBackgroundColorInsteadOfCheckerboard); | 109 backgroundColorInsteadOfCheckerboard = CommandLine::ForCurrentProcess()->Has
Switch(switches::kBackgroundColorInsteadOfCheckerboard); |
73 showOverdrawInTracing = CommandLine::ForCurrentProcess()->HasSwitch(switches
::kTraceOverdraw); | 110 showOverdrawInTracing = CommandLine::ForCurrentProcess()->HasSwitch(switches
::kTraceOverdraw); |
| 111 |
| 112 initialDebugState.showPropertyChangedRects = CommandLine::ForCurrentProcess(
)->HasSwitch(cc::switches::kShowPropertyChangedRects); |
| 113 initialDebugState.showSurfaceDamageRects = CommandLine::ForCurrentProcess()-
>HasSwitch(cc::switches::kShowSurfaceDamageRects); |
| 114 initialDebugState.showScreenSpaceRects = CommandLine::ForCurrentProcess()->H
asSwitch(cc::switches::kShowScreenSpaceRects); |
| 115 initialDebugState.showReplicaScreenSpaceRects = CommandLine::ForCurrentProce
ss()->HasSwitch(cc::switches::kShowReplicaScreenSpaceRects); |
| 116 initialDebugState.showOccludingRects = CommandLine::ForCurrentProcess()->Has
Switch(cc::switches::kShowOccludingRects); |
| 117 initialDebugState.showNonOccludingRects = CommandLine::ForCurrentProcess()->
HasSwitch(cc::switches::kShowNonOccludingRects); |
74 } | 118 } |
75 | 119 |
76 LayerTreeSettings::~LayerTreeSettings() | 120 LayerTreeSettings::~LayerTreeSettings() |
77 { | 121 { |
78 } | 122 } |
79 | 123 |
80 RendererCapabilities::RendererCapabilities() | 124 RendererCapabilities::RendererCapabilities() |
81 : bestTextureFormat(0) | 125 : bestTextureFormat(0) |
82 , contextHasCachedFrontBuffer(false) | 126 , contextHasCachedFrontBuffer(false) |
83 , usingPartialSwap(false) | 127 , usingPartialSwap(false) |
(...skipping 28 matching lines...) Expand all Loading... |
112 : m_animating(false) | 156 : m_animating(false) |
113 , m_needsAnimateLayers(false) | 157 , m_needsAnimateLayers(false) |
114 , m_client(client) | 158 , m_client(client) |
115 , m_commitNumber(0) | 159 , m_commitNumber(0) |
116 , m_renderingStats() | 160 , m_renderingStats() |
117 , m_rendererInitialized(false) | 161 , m_rendererInitialized(false) |
118 , m_contextLost(false) | 162 , m_contextLost(false) |
119 , m_numTimesRecreateShouldFail(0) | 163 , m_numTimesRecreateShouldFail(0) |
120 , m_numFailedRecreateAttempts(0) | 164 , m_numFailedRecreateAttempts(0) |
121 , m_settings(settings) | 165 , m_settings(settings) |
| 166 , m_debugState(settings.initialDebugState) |
122 , m_deviceScaleFactor(1) | 167 , m_deviceScaleFactor(1) |
123 , m_visible(true) | 168 , m_visible(true) |
124 , m_pageScaleFactor(1) | 169 , m_pageScaleFactor(1) |
125 , m_minPageScaleFactor(1) | 170 , m_minPageScaleFactor(1) |
126 , m_maxPageScaleFactor(1) | 171 , m_maxPageScaleFactor(1) |
127 , m_triggerIdleUpdates(true) | 172 , m_triggerIdleUpdates(true) |
128 , m_backgroundColor(SK_ColorWHITE) | 173 , m_backgroundColor(SK_ColorWHITE) |
129 , m_hasTransparentBackground(false) | 174 , m_hasTransparentBackground(false) |
130 , m_partialTextureUpdateRequests(0) | 175 , m_partialTextureUpdateRequests(0) |
131 { | 176 { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 // to visit their controllers. | 327 // to visit their controllers. |
283 if (rootLayer() && m_needsAnimateLayers) | 328 if (rootLayer() && m_needsAnimateLayers) |
284 hostImpl->setNeedsAnimateLayers(); | 329 hostImpl->setNeedsAnimateLayers(); |
285 | 330 |
286 hostImpl->setSourceFrameNumber(commitNumber()); | 331 hostImpl->setSourceFrameNumber(commitNumber()); |
287 hostImpl->setViewportSize(layoutViewportSize(), deviceViewportSize()); | 332 hostImpl->setViewportSize(layoutViewportSize(), deviceViewportSize()); |
288 hostImpl->setDeviceScaleFactor(deviceScaleFactor()); | 333 hostImpl->setDeviceScaleFactor(deviceScaleFactor()); |
289 hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFacto
r, m_maxPageScaleFactor); | 334 hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFacto
r, m_maxPageScaleFactor); |
290 hostImpl->setBackgroundColor(m_backgroundColor); | 335 hostImpl->setBackgroundColor(m_backgroundColor); |
291 hostImpl->setHasTransparentBackground(m_hasTransparentBackground); | 336 hostImpl->setHasTransparentBackground(m_hasTransparentBackground); |
| 337 hostImpl->setDebugState(m_debugState); |
292 | 338 |
293 m_commitNumber++; | 339 m_commitNumber++; |
294 } | 340 } |
295 | 341 |
296 void LayerTreeHost::createHUDLayerIfNeeded() | 342 void LayerTreeHost::createHUDLayerIfNeeded() |
297 { | 343 { |
298 if (!m_hudLayer) | 344 if (!m_hudLayer) |
299 m_hudLayer = HeadsUpDisplayLayer::create(); | 345 m_hudLayer = HeadsUpDisplayLayer::create(); |
300 } | 346 } |
301 | 347 |
302 void LayerTreeHost::setShowFPSCounter(bool show) | |
303 { | |
304 createHUDLayerIfNeeded(); | |
305 m_hudLayer->setShowFPSCounter(show); | |
306 } | |
307 | |
308 void LayerTreeHost::setFontAtlas(scoped_ptr<FontAtlas> fontAtlas) | 348 void LayerTreeHost::setFontAtlas(scoped_ptr<FontAtlas> fontAtlas) |
309 { | 349 { |
310 createHUDLayerIfNeeded(); | 350 createHUDLayerIfNeeded(); |
311 m_hudLayer->setFontAtlas(fontAtlas.Pass()); | 351 m_hudLayer->setFontAtlas(fontAtlas.Pass()); |
312 } | 352 } |
313 | 353 |
314 void LayerTreeHost::willCommit() | 354 void LayerTreeHost::willCommit() |
315 { | 355 { |
316 m_client->willCommit(); | 356 m_client->willCommit(); |
317 | 357 |
318 if (m_settings.showDebugInfo()) | 358 if (m_debugState.showHudInfo()) |
319 createHUDLayerIfNeeded(); | 359 createHUDLayerIfNeeded(); |
320 | 360 |
321 if (m_rootLayer && m_hudLayer && !m_hudLayer->parent()) | 361 if (m_rootLayer && m_hudLayer && !m_hudLayer->parent()) |
322 m_rootLayer->addChild(m_hudLayer); | 362 m_rootLayer->addChild(m_hudLayer); |
323 } | 363 } |
324 | 364 |
325 void LayerTreeHost::commitComplete() | 365 void LayerTreeHost::commitComplete() |
326 { | 366 { |
327 m_client->didCommit(); | 367 m_client->didCommit(); |
328 } | 368 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 m_rootLayer = rootLayer; | 475 m_rootLayer = rootLayer; |
436 if (m_rootLayer) | 476 if (m_rootLayer) |
437 m_rootLayer->setLayerTreeHost(this); | 477 m_rootLayer->setLayerTreeHost(this); |
438 | 478 |
439 if (m_hudLayer) | 479 if (m_hudLayer) |
440 m_hudLayer->removeFromParent(); | 480 m_hudLayer->removeFromParent(); |
441 | 481 |
442 setNeedsCommit(); | 482 setNeedsCommit(); |
443 } | 483 } |
444 | 484 |
| 485 void LayerTreeHost::setDebugState(const LayerTreeDebugState& debugState) |
| 486 { |
| 487 LayerTreeDebugState newDebugState = LayerTreeDebugState::unite(m_settings.in
itialDebugState, debugState); |
| 488 |
| 489 if (LayerTreeDebugState::equal(m_debugState, newDebugState)) |
| 490 return; |
| 491 |
| 492 m_debugState = newDebugState; |
| 493 setNeedsCommit(); |
| 494 } |
| 495 |
445 void LayerTreeHost::setViewportSize(const gfx::Size& layoutViewportSize, const g
fx::Size& deviceViewportSize) | 496 void LayerTreeHost::setViewportSize(const gfx::Size& layoutViewportSize, const g
fx::Size& deviceViewportSize) |
446 { | 497 { |
447 if (layoutViewportSize == m_layoutViewportSize && deviceViewportSize == m_de
viceViewportSize) | 498 if (layoutViewportSize == m_layoutViewportSize && deviceViewportSize == m_de
viceViewportSize) |
448 return; | 499 return; |
449 | 500 |
450 m_layoutViewportSize = layoutViewportSize; | 501 m_layoutViewportSize = layoutViewportSize; |
451 m_deviceViewportSize = deviceViewportSize; | 502 m_deviceViewportSize = deviceViewportSize; |
452 | 503 |
453 setNeedsCommit(); | 504 setNeedsCommit(); |
454 } | 505 } |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 else | 908 else |
858 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); | 909 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); |
859 } | 910 } |
860 } | 911 } |
861 | 912 |
862 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) | 913 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) |
863 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); | 914 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); |
864 } | 915 } |
865 | 916 |
866 } // namespace cc | 917 } // namespace cc |
OLD | NEW |