OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/heads_up_display_layer.h" | 5 #include "cc/heads_up_display_layer.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "cc/heads_up_display_layer_impl.h" | 8 #include "cc/heads_up_display_layer_impl.h" |
9 #include "cc/layer_tree_host.h" | 9 #include "cc/layer_tree_host.h" |
10 | 10 |
11 namespace cc { | 11 namespace cc { |
12 | 12 |
13 HeadsUpDisplayLayerSettings::HeadsUpDisplayLayerSettings() | |
14 : showFPSCounter(false) | |
15 , showPlatformLayerTree(false) | |
16 , showPaintRects(false) | |
17 , showPropertyChangedRects(false) | |
18 , showSurfaceDamageRects(false) | |
19 , showScreenSpaceRects(false) | |
20 , showReplicaScreenSpaceRects(false) | |
21 , showOccludingRects(false) | |
22 , showNonOccludingRects(false) | |
23 { | |
24 } | |
25 | |
26 bool HeadsUpDisplayLayerSettings::showDebugInfo() const | |
27 { | |
28 return showFPSCounter || showPlatformLayerTree || showDebugRects(); | |
29 } | |
30 | |
31 bool HeadsUpDisplayLayerSettings::showDebugRects() const | |
32 { | |
33 return showPaintRects || showPropertyChangedRects || showSurfaceDamageRects || showScreenSpaceRects || showReplicaScreenSpaceRects || showOccludingRects || showNonOccludingRects; | |
34 } | |
35 | |
36 HeadsUpDisplayLayerSettings HeadsUpDisplayLayerSettings::merge(HeadsUpDisplayLay erSettings& other) | |
37 { | |
38 HeadsUpDisplayLayerSettings settings; | |
39 | |
40 settings.showFPSCounter = showFPSCounter | other.showFPSCounter; | |
41 settings.showPlatformLayerTree = showPlatformLayerTree | other.showPlatformL ayerTree; | |
42 | |
43 settings.showPaintRects = showPaintRects | other.showPaintRects; | |
44 settings.showPropertyChangedRects = showPropertyChangedRects | other.showPro pertyChangedRects; | |
45 settings.showSurfaceDamageRects = showSurfaceDamageRects | other.showSurface DamageRects; | |
46 settings.showScreenSpaceRects = showScreenSpaceRects | other.showScreenSpace Rects; | |
47 settings.showReplicaScreenSpaceRects = showReplicaScreenSpaceRects | other.s howReplicaScreenSpaceRects; | |
48 settings.showNonOccludingRects = showNonOccludingRects | other.showNonOcclud ingRects; | |
49 | |
50 return settings; | |
51 } | |
52 | |
13 scoped_refptr<HeadsUpDisplayLayer> HeadsUpDisplayLayer::create() | 53 scoped_refptr<HeadsUpDisplayLayer> HeadsUpDisplayLayer::create() |
14 { | 54 { |
15 return make_scoped_refptr(new HeadsUpDisplayLayer()); | 55 return make_scoped_refptr(new HeadsUpDisplayLayer()); |
16 } | 56 } |
17 | 57 |
18 HeadsUpDisplayLayer::HeadsUpDisplayLayer() | 58 HeadsUpDisplayLayer::HeadsUpDisplayLayer() |
19 : Layer() | 59 : Layer() |
20 , m_showFPSCounter(false) | |
21 { | 60 { |
22 setBounds(gfx::Size(256, 128)); | 61 setBounds(gfx::Size(256, 128)); |
23 } | 62 } |
24 | 63 |
25 HeadsUpDisplayLayer::~HeadsUpDisplayLayer() | 64 HeadsUpDisplayLayer::~HeadsUpDisplayLayer() |
26 { | 65 { |
27 } | 66 } |
28 | 67 |
29 void HeadsUpDisplayLayer::update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats&) | 68 void HeadsUpDisplayLayer::update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats&) |
30 { | 69 { |
31 const LayerTreeSettings& settings = layerTreeHost()->settings(); | |
32 int maxTextureSize = layerTreeHost()->rendererCapabilities().maxTextureSize; | 70 int maxTextureSize = layerTreeHost()->rendererCapabilities().maxTextureSize; |
33 | 71 |
34 gfx::Size bounds; | 72 gfx::Size bounds; |
35 WebKit::WebTransformationMatrix matrix; | 73 WebKit::WebTransformationMatrix matrix; |
36 matrix.makeIdentity(); | 74 matrix.makeIdentity(); |
37 | 75 |
38 if (settings.showPlatformLayerTree || settings.showDebugRects()) { | 76 if (m_settings.showPlatformLayerTree || m_settings.showDebugRects()) { |
39 int width = std::min(maxTextureSize, layerTreeHost()->deviceViewportSize ().width()); | 77 int width = std::min(maxTextureSize, layerTreeHost()->deviceViewportSize ().width()); |
40 int height = std::min(maxTextureSize, layerTreeHost()->deviceViewportSiz e().height()); | 78 int height = std::min(maxTextureSize, layerTreeHost()->deviceViewportSiz e().height()); |
41 bounds = gfx::Size(width, height); | 79 bounds = gfx::Size(width, height); |
42 } else { | 80 } else { |
43 bounds = gfx::Size(256, 128); | 81 bounds = gfx::Size(256, 128); |
44 matrix.translate(layerTreeHost()->deviceViewportSize().width() - 256, 0) ; | 82 matrix.translate(layerTreeHost()->deviceViewportSize().width() - 256, 0) ; |
45 } | 83 } |
46 | 84 |
47 setBounds(bounds); | 85 setBounds(bounds); |
48 setTransform(matrix); | 86 setTransform(matrix); |
49 } | 87 } |
50 | 88 |
51 bool HeadsUpDisplayLayer::drawsContent() const | 89 bool HeadsUpDisplayLayer::drawsContent() const |
52 { | 90 { |
53 return true; | 91 return m_settings.showDebugInfo(); |
egraether
2012/11/20 21:30:30
prevent drawing when nothing is displayed.
| |
54 } | 92 } |
55 | 93 |
56 void HeadsUpDisplayLayer::setFontAtlas(scoped_ptr<FontAtlas> fontAtlas) | 94 void HeadsUpDisplayLayer::setFontAtlas(scoped_ptr<FontAtlas> fontAtlas) |
57 { | 95 { |
58 m_fontAtlas = fontAtlas.Pass(); | 96 m_fontAtlas = fontAtlas.Pass(); |
59 setNeedsCommit(); | 97 setNeedsCommit(); |
60 } | 98 } |
61 | 99 |
62 void HeadsUpDisplayLayer::setShowFPSCounter(bool show) | |
63 { | |
64 m_showFPSCounter = show; | |
65 setNeedsCommit(); | |
66 } | |
67 | |
68 scoped_ptr<LayerImpl> HeadsUpDisplayLayer::createLayerImpl() | 100 scoped_ptr<LayerImpl> HeadsUpDisplayLayer::createLayerImpl() |
69 { | 101 { |
70 return HeadsUpDisplayLayerImpl::create(m_layerId).PassAs<LayerImpl>(); | 102 return HeadsUpDisplayLayerImpl::create(m_layerId).PassAs<LayerImpl>(); |
71 } | 103 } |
72 | 104 |
73 void HeadsUpDisplayLayer::pushPropertiesTo(LayerImpl* layerImpl) | 105 void HeadsUpDisplayLayer::pushPropertiesTo(LayerImpl* layerImpl) |
74 { | 106 { |
75 Layer::pushPropertiesTo(layerImpl); | 107 Layer::pushPropertiesTo(layerImpl); |
76 | 108 |
77 HeadsUpDisplayLayerImpl* hudLayerImpl = static_cast<HeadsUpDisplayLayerImpl* >(layerImpl); | 109 HeadsUpDisplayLayerImpl* hudLayerImpl = static_cast<HeadsUpDisplayLayerImpl* >(layerImpl); |
78 hudLayerImpl->setShowFPSCounter(m_showFPSCounter); | 110 hudLayerImpl->setSettings(m_settings); |
79 | 111 |
80 if (m_fontAtlas.get()) | 112 if (m_fontAtlas.get()) |
81 hudLayerImpl->setFontAtlas(m_fontAtlas.Pass()); | 113 hudLayerImpl->setFontAtlas(m_fontAtlas.Pass()); |
82 } | 114 } |
83 | 115 |
84 } // namespace cc | 116 } // namespace cc |
OLD | NEW |