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" |
11 #include "cc/graphics_context.h" | 11 #include "cc/graphics_context.h" |
12 #include "cc/heads_up_display_layer.h" | 12 #include "cc/heads_up_display_layer.h" |
13 #include "cc/heads_up_display_layer_impl.h" | 13 #include "cc/heads_up_display_layer_impl.h" |
14 #include "cc/layer.h" | 14 #include "cc/layer.h" |
15 #include "cc/layer_animation_controller.h" | 15 #include "cc/layer_animation_controller.h" |
16 #include "cc/layer_iterator.h" | 16 #include "cc/layer_iterator.h" |
17 #include "cc/layer_tree_host_client.h" | 17 #include "cc/layer_tree_host_client.h" |
18 #include "cc/layer_tree_host_common.h" | 18 #include "cc/layer_tree_host_common.h" |
19 #include "cc/layer_tree_host_impl.h" | 19 #include "cc/layer_tree_host_impl.h" |
20 #include "cc/math_util.h" | 20 #include "cc/math_util.h" |
21 #include "cc/occlusion_tracker.h" | 21 #include "cc/occlusion_tracker.h" |
22 #include "cc/overdraw_metrics.h" | 22 #include "cc/overdraw_metrics.h" |
23 #include "cc/settings.h" | |
24 #include "cc/single_thread_proxy.h" | 23 #include "cc/single_thread_proxy.h" |
25 #include "cc/switches.h" | 24 #include "cc/switches.h" |
26 #include "cc/thread.h" | 25 #include "cc/thread.h" |
27 #include "cc/thread_proxy.h" | 26 #include "cc/thread_proxy.h" |
28 #include "cc/tree_synchronizer.h" | 27 #include "cc/tree_synchronizer.h" |
29 | 28 |
30 using namespace std; | 29 using namespace std; |
31 | 30 |
32 namespace { | 31 namespace { |
33 static int numLayerTreeInstances; | 32 static int numLayerTreeInstances; |
34 } | 33 } |
35 | 34 |
36 namespace cc { | 35 namespace cc { |
37 | 36 |
38 bool LayerTreeHost::s_needsFilterContext = false; | 37 bool LayerTreeHost::s_needsFilterContext = false; |
39 | 38 |
40 LayerTreeSettings::LayerTreeSettings() | 39 LayerTreeSettings::LayerTreeSettings() |
41 : acceleratePainting(false) | 40 : acceleratePainting(false) |
42 , showPlatformLayerTree(false) | 41 , 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 , renderVSyncEnabled(true) | 48 , renderVSyncEnabled(true) |
| 49 , perTilePaintingEnabled(false) |
| 50 , partialSwapEnabled(false) |
| 51 , acceleratedAnimationEnabled(true) |
| 52 , pageScalePinchZoomEnabled(false) |
| 53 , backgroundColorInsteadOfCheckerboard(false) |
| 54 , showOverdrawInTracing(false) |
50 , refreshRate(0) | 55 , refreshRate(0) |
51 , maxPartialTextureUpdates(std::numeric_limits<size_t>::max()) | 56 , maxPartialTextureUpdates(std::numeric_limits<size_t>::max()) |
52 , defaultTileSize(gfx::Size(256, 256)) | 57 , defaultTileSize(gfx::Size(256, 256)) |
53 , maxUntiledLayerSize(gfx::Size(512, 512)) | 58 , maxUntiledLayerSize(gfx::Size(512, 512)) |
54 , minimumOcclusionTrackingSize(gfx::Size(160, 160)) | 59 , minimumOcclusionTrackingSize(gfx::Size(160, 160)) |
55 { | 60 { |
56 // TODO(danakj): Move this to chromium when we don't go through the WebKit A
PI anymore. | 61 // TODO(danakj): Move this to chromium when we don't go through the WebKit A
PI anymore. |
57 showPropertyChangedRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::s
witches::kShowPropertyChangedRects); | 62 showPropertyChangedRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::s
witches::kShowPropertyChangedRects); |
58 showSurfaceDamageRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::swi
tches::kShowSurfaceDamageRects); | 63 showSurfaceDamageRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::swi
tches::kShowSurfaceDamageRects); |
59 showScreenSpaceRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::switc
hes::kShowScreenSpaceRects); | 64 showScreenSpaceRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::switc
hes::kShowScreenSpaceRects); |
60 showReplicaScreenSpaceRects = CommandLine::ForCurrentProcess()->HasSwitch(cc
::switches::kShowReplicaScreenSpaceRects); | 65 showReplicaScreenSpaceRects = CommandLine::ForCurrentProcess()->HasSwitch(cc
::switches::kShowReplicaScreenSpaceRects); |
61 showOccludingRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::switche
s::kShowOccludingRects); | 66 showOccludingRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::switche
s::kShowOccludingRects); |
| 67 partialSwapEnabled = CommandLine::ForCurrentProcess()->HasSwitch(switches::k
EnablePartialSwap); |
| 68 backgroundColorInsteadOfCheckerboard = CommandLine::ForCurrentProcess()->Has
Switch(switches::kBackgroundColorInsteadOfCheckerboard); |
| 69 showOverdrawInTracing = CommandLine::ForCurrentProcess()->HasSwitch(switches
::kTraceOverdraw); |
62 } | 70 } |
63 | 71 |
64 LayerTreeSettings::~LayerTreeSettings() | 72 LayerTreeSettings::~LayerTreeSettings() |
65 { | 73 { |
66 } | 74 } |
67 | 75 |
68 RendererCapabilities::RendererCapabilities() | 76 RendererCapabilities::RendererCapabilities() |
69 : bestTextureFormat(0) | 77 : bestTextureFormat(0) |
70 , contextHasCachedFrontBuffer(false) | 78 , contextHasCachedFrontBuffer(false) |
71 , usingPartialSwap(false) | 79 , usingPartialSwap(false) |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 return 0; | 546 return 0; |
539 } | 547 } |
540 | 548 |
541 void LayerTreeHost::updateLayers(Layer* rootLayer, ResourceUpdateQueue& queue) | 549 void LayerTreeHost::updateLayers(Layer* rootLayer, ResourceUpdateQueue& queue) |
542 { | 550 { |
543 TRACE_EVENT0("cc", "LayerTreeHost::updateLayers"); | 551 TRACE_EVENT0("cc", "LayerTreeHost::updateLayers"); |
544 | 552 |
545 LayerList updateList; | 553 LayerList updateList; |
546 | 554 |
547 { | 555 { |
548 if (Settings::pageScalePinchZoomEnabled()) { | 556 if (m_settings.pageScalePinchZoomEnabled) { |
549 Layer* rootScroll = findFirstScrollableLayer(rootLayer); | 557 Layer* rootScroll = findFirstScrollableLayer(rootLayer); |
550 if (rootScroll) | 558 if (rootScroll) |
551 rootScroll->setImplTransform(m_implTransform); | 559 rootScroll->setImplTransform(m_implTransform); |
552 } | 560 } |
553 | 561 |
554 TRACE_EVENT0("cc", "LayerTreeHost::updateLayers::calcDrawEtc"); | 562 TRACE_EVENT0("cc", "LayerTreeHost::updateLayers::calcDrawEtc"); |
555 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSi
ze(), m_deviceScaleFactor, m_pageScaleFactor, rendererCapabilities().maxTextureS
ize, updateList); | 563 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSi
ze(), m_deviceScaleFactor, m_pageScaleFactor, rendererCapabilities().maxTextureS
ize, updateList); |
556 } | 564 } |
557 | 565 |
558 // Reset partial texture update requests. | 566 // Reset partial texture update requests. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 } | 673 } |
666 return needMoreUpdates; | 674 return needMoreUpdates; |
667 } | 675 } |
668 | 676 |
669 bool LayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList,
ResourceUpdateQueue& queue) | 677 bool LayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList,
ResourceUpdateQueue& queue) |
670 { | 678 { |
671 // Use FrontToBack to allow for testing occlusion and performing culling dur
ing the tree walk. | 679 // Use FrontToBack to allow for testing occlusion and performing culling dur
ing the tree walk. |
672 typedef LayerIterator<Layer, LayerList, RenderSurface, LayerIteratorActions:
:FrontToBack> LayerIteratorType; | 680 typedef LayerIterator<Layer, LayerList, RenderSurface, LayerIteratorActions:
:FrontToBack> LayerIteratorType; |
673 | 681 |
674 bool needMoreUpdates = false; | 682 bool needMoreUpdates = false; |
675 bool recordMetricsForFrame = Settings::traceOverdraw() && base::debug::Trace
Log::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled(); | 683 bool recordMetricsForFrame = m_settings.showOverdrawInTracing && base::debug
::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled(); |
676 OcclusionTracker occlusionTracker(m_rootLayer->renderSurface()->contentRect(
), recordMetricsForFrame); | 684 OcclusionTracker occlusionTracker(m_rootLayer->renderSurface()->contentRect(
), recordMetricsForFrame); |
677 occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingS
ize); | 685 occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingS
ize); |
678 | 686 |
679 prioritizeTextures(renderSurfaceLayerList, occlusionTracker.overdrawMetrics(
)); | 687 prioritizeTextures(renderSurfaceLayerList, occlusionTracker.overdrawMetrics(
)); |
680 | 688 |
681 LayerIteratorType end = LayerIteratorType::end(&renderSurfaceLayerList); | 689 LayerIteratorType end = LayerIteratorType::end(&renderSurfaceLayerList); |
682 for (LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList
); it != end; ++it) { | 690 for (LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList
); it != end; ++it) { |
683 occlusionTracker.enterLayer(it); | 691 occlusionTracker.enterLayer(it); |
684 | 692 |
685 if (it.representsTargetRenderSurface()) { | 693 if (it.representsTargetRenderSurface()) { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 { | 804 { |
797 if (deviceScaleFactor == m_deviceScaleFactor) | 805 if (deviceScaleFactor == m_deviceScaleFactor) |
798 return; | 806 return; |
799 m_deviceScaleFactor = deviceScaleFactor; | 807 m_deviceScaleFactor = deviceScaleFactor; |
800 | 808 |
801 setNeedsCommit(); | 809 setNeedsCommit(); |
802 } | 810 } |
803 | 811 |
804 void LayerTreeHost::animateLayers(base::TimeTicks time) | 812 void LayerTreeHost::animateLayers(base::TimeTicks time) |
805 { | 813 { |
806 if (!Settings::acceleratedAnimationEnabled() || !m_needsAnimateLayers) | 814 if (!m_settings.acceleratedAnimationEnabled || !m_needsAnimateLayers) |
807 return; | 815 return; |
808 | 816 |
809 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); | 817 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); |
810 m_needsAnimateLayers = animateLayersRecursive(m_rootLayer.get(), time); | 818 m_needsAnimateLayers = animateLayersRecursive(m_rootLayer.get(), time); |
811 } | 819 } |
812 | 820 |
813 bool LayerTreeHost::animateLayersRecursive(Layer* current, base::TimeTicks time) | 821 bool LayerTreeHost::animateLayersRecursive(Layer* current, base::TimeTicks time) |
814 { | 822 { |
815 if (!current) | 823 if (!current) |
816 return false; | 824 return false; |
(...skipping 27 matching lines...) Expand all Loading... |
844 else | 852 else |
845 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); | 853 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); |
846 } | 854 } |
847 } | 855 } |
848 | 856 |
849 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) | 857 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) |
850 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); | 858 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); |
851 } | 859 } |
852 | 860 |
853 } // namespace cc | 861 } // namespace cc |
OLD | NEW |