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 11 matching lines...) Expand all Loading... | |
22 #include "cc/overdraw_metrics.h" | 22 #include "cc/overdraw_metrics.h" |
23 #include "cc/single_thread_proxy.h" | 23 #include "cc/single_thread_proxy.h" |
24 #include "cc/switches.h" | 24 #include "cc/switches.h" |
25 #include "cc/thread.h" | 25 #include "cc/thread.h" |
26 #include "cc/thread_proxy.h" | 26 #include "cc/thread_proxy.h" |
27 #include "cc/tree_synchronizer.h" | 27 #include "cc/tree_synchronizer.h" |
28 | 28 |
29 using namespace std; | 29 using namespace std; |
30 | 30 |
31 namespace { | 31 namespace { |
32 | |
32 static int numLayerTreeInstances; | 33 static int numLayerTreeInstances; |
34 | |
35 // merge blocks of memory - ORs num bytes from source into destination | |
36 void* memmrg(void* destination, const void* source, size_t num) | |
37 { | |
38 char* dstPtr = (char*)destination; | |
39 char* srcPtr = (char*)source; | |
40 | |
41 for (size_t i = 0; i < num; i++) | |
42 dstPtr[i] |= srcPtr[i]; | |
43 | |
44 return destination; | |
45 } | |
46 | |
33 } | 47 } |
34 | 48 |
35 namespace cc { | 49 namespace cc { |
36 | 50 |
37 bool LayerTreeHost::s_needsFilterContext = false; | 51 bool LayerTreeHost::s_needsFilterContext = false; |
38 | 52 |
39 LayerTreeSettings::LayerTreeSettings() | 53 LayerTreeDebugState::LayerTreeDebugState() |
40 : acceleratePainting(false) | 54 : showFPSCounter(false) |
55 , showPlatformLayerTree(false) | |
41 , showDebugBorders(false) | 56 , showDebugBorders(false) |
42 , showPlatformLayerTree(false) | |
43 , showPaintRects(false) | 57 , showPaintRects(false) |
44 , showPropertyChangedRects(false) | 58 , showPropertyChangedRects(false) |
45 , showSurfaceDamageRects(false) | 59 , showSurfaceDamageRects(false) |
46 , showScreenSpaceRects(false) | 60 , showScreenSpaceRects(false) |
47 , showReplicaScreenSpaceRects(false) | 61 , showReplicaScreenSpaceRects(false) |
48 , showOccludingRects(false) | 62 , showOccludingRects(false) |
49 , showNonOccludingRects(false) | 63 , showNonOccludingRects(false) |
64 { | |
65 } | |
66 | |
67 LayerTreeDebugState::~LayerTreeDebugState() | |
68 { | |
69 } | |
70 | |
71 bool LayerTreeDebugState::showHudInfo() const | |
72 { | |
73 return showFPSCounter || showPlatformLayerTree || showHudRects(); | |
74 } | |
75 | |
76 bool LayerTreeDebugState::showHudRects() const | |
77 { | |
78 return showPaintRects || showPropertyChangedRects || showSurfaceDamageRects || showScreenSpaceRects || showReplicaScreenSpaceRects || showOccludingRects || showNonOccludingRects; | |
79 } | |
80 | |
81 bool LayerTreeDebugState::equal(const LayerTreeDebugState& a, const LayerTreeDeb ugState& b) | |
82 { | |
83 return memcmp(&a, &b, sizeof(LayerTreeDebugState)) == 0; | |
danakj
2012/11/27 20:23:15
this is fine.
| |
84 } | |
85 | |
86 LayerTreeDebugState LayerTreeDebugState::merge(const LayerTreeDebugState& a, con st LayerTreeDebugState& b) | |
danakj
2012/11/27 20:23:15
better names than "a" and "b" please. initialState
egraether
2012/11/27 22:10:47
this method just ORs the states and returns a new
| |
87 { | |
88 LayerTreeDebugState r(a); | |
89 memmrg(&r, &b, sizeof(LayerTreeDebugState)); | |
danakj
2012/11/27 20:23:15
i liked just doing the | for each flag before bett
egraether
2012/11/27 22:10:47
that was just a little experiment, because I don't
danakj
2012/11/27 22:15:00
merge(a, b) is super not clear what is happening t
| |
90 return r; | |
91 } | |
92 | |
93 LayerTreeSettings::LayerTreeSettings() | |
94 : acceleratePainting(false) | |
50 , renderVSyncEnabled(true) | 95 , renderVSyncEnabled(true) |
51 , perTilePaintingEnabled(false) | 96 , perTilePaintingEnabled(false) |
52 , partialSwapEnabled(false) | 97 , partialSwapEnabled(false) |
53 , acceleratedAnimationEnabled(true) | 98 , acceleratedAnimationEnabled(true) |
54 , pageScalePinchZoomEnabled(false) | 99 , pageScalePinchZoomEnabled(false) |
55 , backgroundColorInsteadOfCheckerboard(false) | 100 , backgroundColorInsteadOfCheckerboard(false) |
56 , showOverdrawInTracing(false) | 101 , showOverdrawInTracing(false) |
57 , refreshRate(0) | 102 , refreshRate(0) |
58 , maxPartialTextureUpdates(std::numeric_limits<size_t>::max()) | 103 , maxPartialTextureUpdates(std::numeric_limits<size_t>::max()) |
59 , defaultTileSize(gfx::Size(256, 256)) | 104 , defaultTileSize(gfx::Size(256, 256)) |
60 , maxUntiledLayerSize(gfx::Size(512, 512)) | 105 , maxUntiledLayerSize(gfx::Size(512, 512)) |
61 , minimumOcclusionTrackingSize(gfx::Size(160, 160)) | 106 , minimumOcclusionTrackingSize(gfx::Size(160, 160)) |
62 { | 107 { |
63 // TODO(danakj): Move this to chromium when we don't go through the WebKit A PI anymore. | 108 // 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); | 109 partialSwapEnabled = CommandLine::ForCurrentProcess()->HasSwitch(switches::k EnablePartialSwap); |
71 backgroundColorInsteadOfCheckerboard = CommandLine::ForCurrentProcess()->Has Switch(switches::kBackgroundColorInsteadOfCheckerboard); | 110 backgroundColorInsteadOfCheckerboard = CommandLine::ForCurrentProcess()->Has Switch(switches::kBackgroundColorInsteadOfCheckerboard); |
72 showOverdrawInTracing = CommandLine::ForCurrentProcess()->HasSwitch(switches ::kTraceOverdraw); | 111 showOverdrawInTracing = CommandLine::ForCurrentProcess()->HasSwitch(switches ::kTraceOverdraw); |
112 | |
113 initialDebugState.showPropertyChangedRects = CommandLine::ForCurrentProcess( )->HasSwitch(cc::switches::kShowPropertyChangedRects); | |
114 initialDebugState.showSurfaceDamageRects = CommandLine::ForCurrentProcess()- >HasSwitch(cc::switches::kShowSurfaceDamageRects); | |
115 initialDebugState.showScreenSpaceRects = CommandLine::ForCurrentProcess()->H asSwitch(cc::switches::kShowScreenSpaceRects); | |
116 initialDebugState.showReplicaScreenSpaceRects = CommandLine::ForCurrentProce ss()->HasSwitch(cc::switches::kShowReplicaScreenSpaceRects); | |
117 initialDebugState.showOccludingRects = CommandLine::ForCurrentProcess()->Has Switch(cc::switches::kShowOccludingRects); | |
118 initialDebugState.showNonOccludingRects = CommandLine::ForCurrentProcess()-> HasSwitch(cc::switches::kShowNonOccludingRects); | |
73 } | 119 } |
74 | 120 |
75 LayerTreeSettings::~LayerTreeSettings() | 121 LayerTreeSettings::~LayerTreeSettings() |
76 { | 122 { |
77 } | 123 } |
78 | 124 |
79 RendererCapabilities::RendererCapabilities() | 125 RendererCapabilities::RendererCapabilities() |
80 : bestTextureFormat(0) | 126 : bestTextureFormat(0) |
81 , contextHasCachedFrontBuffer(false) | 127 , contextHasCachedFrontBuffer(false) |
82 , usingPartialSwap(false) | 128 , usingPartialSwap(false) |
(...skipping 28 matching lines...) Expand all Loading... | |
111 : m_animating(false) | 157 : m_animating(false) |
112 , m_needsAnimateLayers(false) | 158 , m_needsAnimateLayers(false) |
113 , m_client(client) | 159 , m_client(client) |
114 , m_commitNumber(0) | 160 , m_commitNumber(0) |
115 , m_renderingStats() | 161 , m_renderingStats() |
116 , m_rendererInitialized(false) | 162 , m_rendererInitialized(false) |
117 , m_contextLost(false) | 163 , m_contextLost(false) |
118 , m_numTimesRecreateShouldFail(0) | 164 , m_numTimesRecreateShouldFail(0) |
119 , m_numFailedRecreateAttempts(0) | 165 , m_numFailedRecreateAttempts(0) |
120 , m_settings(settings) | 166 , m_settings(settings) |
167 , m_debugState(settings.initialDebugState) | |
121 , m_deviceScaleFactor(1) | 168 , m_deviceScaleFactor(1) |
122 , m_visible(true) | 169 , m_visible(true) |
123 , m_pageScaleFactor(1) | 170 , m_pageScaleFactor(1) |
124 , m_minPageScaleFactor(1) | 171 , m_minPageScaleFactor(1) |
125 , m_maxPageScaleFactor(1) | 172 , m_maxPageScaleFactor(1) |
126 , m_triggerIdleUpdates(true) | 173 , m_triggerIdleUpdates(true) |
127 , m_backgroundColor(SK_ColorWHITE) | 174 , m_backgroundColor(SK_ColorWHITE) |
128 , m_hasTransparentBackground(false) | 175 , m_hasTransparentBackground(false) |
129 , m_partialTextureUpdateRequests(0) | 176 , m_partialTextureUpdateRequests(0) |
130 { | 177 { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
281 // to visit their controllers. | 328 // to visit their controllers. |
282 if (rootLayer() && m_needsAnimateLayers) | 329 if (rootLayer() && m_needsAnimateLayers) |
283 hostImpl->setNeedsAnimateLayers(); | 330 hostImpl->setNeedsAnimateLayers(); |
284 | 331 |
285 hostImpl->setSourceFrameNumber(commitNumber()); | 332 hostImpl->setSourceFrameNumber(commitNumber()); |
286 hostImpl->setViewportSize(layoutViewportSize(), deviceViewportSize()); | 333 hostImpl->setViewportSize(layoutViewportSize(), deviceViewportSize()); |
287 hostImpl->setDeviceScaleFactor(deviceScaleFactor()); | 334 hostImpl->setDeviceScaleFactor(deviceScaleFactor()); |
288 hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFacto r, m_maxPageScaleFactor); | 335 hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFacto r, m_maxPageScaleFactor); |
289 hostImpl->setBackgroundColor(m_backgroundColor); | 336 hostImpl->setBackgroundColor(m_backgroundColor); |
290 hostImpl->setHasTransparentBackground(m_hasTransparentBackground); | 337 hostImpl->setHasTransparentBackground(m_hasTransparentBackground); |
338 hostImpl->setDebugState(m_debugState); | |
291 | 339 |
292 m_commitNumber++; | 340 m_commitNumber++; |
293 } | 341 } |
294 | 342 |
295 void LayerTreeHost::createHUDLayerIfNeeded() | 343 void LayerTreeHost::createHUDLayerIfNeeded() |
296 { | 344 { |
297 if (!m_hudLayer) | 345 if (!m_hudLayer) |
298 m_hudLayer = HeadsUpDisplayLayer::create(); | 346 m_hudLayer = HeadsUpDisplayLayer::create(); |
299 } | 347 } |
300 | 348 |
301 void LayerTreeHost::setShowFPSCounter(bool show) | |
302 { | |
303 createHUDLayerIfNeeded(); | |
304 m_hudLayer->setShowFPSCounter(show); | |
305 } | |
306 | |
307 void LayerTreeHost::setFontAtlas(scoped_ptr<FontAtlas> fontAtlas) | 349 void LayerTreeHost::setFontAtlas(scoped_ptr<FontAtlas> fontAtlas) |
308 { | 350 { |
309 createHUDLayerIfNeeded(); | 351 createHUDLayerIfNeeded(); |
310 m_hudLayer->setFontAtlas(fontAtlas.Pass()); | 352 m_hudLayer->setFontAtlas(fontAtlas.Pass()); |
311 } | 353 } |
312 | 354 |
313 void LayerTreeHost::willCommit() | 355 void LayerTreeHost::willCommit() |
314 { | 356 { |
315 m_client->willCommit(); | 357 m_client->willCommit(); |
316 | 358 |
317 if (m_settings.showDebugInfo()) | 359 if (m_debugState.showHudInfo()) |
318 createHUDLayerIfNeeded(); | 360 createHUDLayerIfNeeded(); |
319 | 361 |
320 if (m_rootLayer && m_hudLayer && !m_hudLayer->parent()) | 362 if (m_rootLayer && m_hudLayer && !m_hudLayer->parent()) |
321 m_rootLayer->addChild(m_hudLayer); | 363 m_rootLayer->addChild(m_hudLayer); |
322 } | 364 } |
323 | 365 |
324 void LayerTreeHost::commitComplete() | 366 void LayerTreeHost::commitComplete() |
325 { | 367 { |
326 m_client->didCommit(); | 368 m_client->didCommit(); |
327 } | 369 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
434 m_rootLayer = rootLayer; | 476 m_rootLayer = rootLayer; |
435 if (m_rootLayer) | 477 if (m_rootLayer) |
436 m_rootLayer->setLayerTreeHost(this); | 478 m_rootLayer->setLayerTreeHost(this); |
437 | 479 |
438 if (m_hudLayer) | 480 if (m_hudLayer) |
439 m_hudLayer->removeFromParent(); | 481 m_hudLayer->removeFromParent(); |
440 | 482 |
441 setNeedsCommit(); | 483 setNeedsCommit(); |
442 } | 484 } |
443 | 485 |
486 void LayerTreeHost::setDebugState(const LayerTreeDebugState& debugState) | |
487 { | |
488 if (!LayerTreeDebugState::equal(m_debugState, debugState)) { | |
danakj
2012/11/27 20:23:15
I think you want to merge, then compare to m_debug
egraether
2012/11/27 22:10:47
Yeah, that sounds more stable. I just tried to be
| |
489 m_debugState = LayerTreeDebugState::merge(m_settings.initialDebugState, debugState); | |
490 setNeedsCommit(); | |
491 } | |
492 } | |
493 | |
444 void LayerTreeHost::setViewportSize(const gfx::Size& layoutViewportSize, const g fx::Size& deviceViewportSize) | 494 void LayerTreeHost::setViewportSize(const gfx::Size& layoutViewportSize, const g fx::Size& deviceViewportSize) |
445 { | 495 { |
446 if (layoutViewportSize == m_layoutViewportSize && deviceViewportSize == m_de viceViewportSize) | 496 if (layoutViewportSize == m_layoutViewportSize && deviceViewportSize == m_de viceViewportSize) |
447 return; | 497 return; |
448 | 498 |
449 m_layoutViewportSize = layoutViewportSize; | 499 m_layoutViewportSize = layoutViewportSize; |
450 m_deviceViewportSize = deviceViewportSize; | 500 m_deviceViewportSize = deviceViewportSize; |
451 | 501 |
452 setNeedsCommit(); | 502 setNeedsCommit(); |
453 } | 503 } |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
856 else | 906 else |
857 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); | 907 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); |
858 } | 908 } |
859 } | 909 } |
860 | 910 |
861 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex) | 911 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex) |
862 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime); | 912 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime); |
863 } | 913 } |
864 | 914 |
865 } // namespace cc | 915 } // namespace cc |
OLD | NEW |