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_impl.h" | 5 #include "cc/heads_up_display_layer_impl.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "cc/debug_rect_history.h" | 10 #include "cc/debug_rect_history.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 paint.setColorFilter(new SkColorMatrixFilter(swizzleMatrix))->unref(); | 41 paint.setColorFilter(new SkColorMatrixFilter(swizzleMatrix))->unref(); |
42 | 42 |
43 return paint; | 43 return paint; |
44 } | 44 } |
45 | 45 |
46 HeadsUpDisplayLayerImpl::HeadsUpDisplayLayerImpl(int id) | 46 HeadsUpDisplayLayerImpl::HeadsUpDisplayLayerImpl(int id) |
47 : LayerImpl(id) | 47 : LayerImpl(id) |
48 , m_averageFPS(0) | 48 , m_averageFPS(0) |
49 , m_minFPS(0) | 49 , m_minFPS(0) |
50 , m_maxFPS(0) | 50 , m_maxFPS(0) |
51 , m_showFPSCounter(false) | |
52 { | 51 { |
53 } | 52 } |
54 | 53 |
55 HeadsUpDisplayLayerImpl::~HeadsUpDisplayLayerImpl() | 54 HeadsUpDisplayLayerImpl::~HeadsUpDisplayLayerImpl() |
56 { | 55 { |
57 } | 56 } |
58 | 57 |
59 void HeadsUpDisplayLayerImpl::setFontAtlas(scoped_ptr<FontAtlas> fontAtlas) | 58 void HeadsUpDisplayLayerImpl::setFontAtlas(scoped_ptr<FontAtlas> fontAtlas) |
60 { | 59 { |
61 m_fontAtlas = fontAtlas.Pass(); | 60 m_fontAtlas = fontAtlas.Pass(); |
62 } | 61 } |
63 | 62 |
64 void HeadsUpDisplayLayerImpl::setShowFPSCounter(bool show) | 63 void HeadsUpDisplayLayerImpl::setFlags(HeadsUpDisplayLayerFlags flags) |
65 { | 64 { |
66 m_showFPSCounter = show; | 65 m_flags = flags; |
67 } | 66 } |
68 | 67 |
69 void HeadsUpDisplayLayerImpl::willDraw(ResourceProvider* resourceProvider) | 68 void HeadsUpDisplayLayerImpl::willDraw(ResourceProvider* resourceProvider) |
70 { | 69 { |
71 LayerImpl::willDraw(resourceProvider); | 70 LayerImpl::willDraw(resourceProvider); |
72 | 71 |
73 if (!m_hudTexture) | 72 if (!m_hudTexture) |
74 m_hudTexture = ScopedResource::create(resourceProvider); | 73 m_hudTexture = ScopedResource::create(resourceProvider); |
75 | 74 |
76 // FIXME: Scale the HUD by deviceScale to make it more friendly under high D
PI. | 75 // FIXME: Scale the HUD by deviceScale to make it more friendly under high D
PI. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 m_hudTexture.reset(); | 138 m_hudTexture.reset(); |
140 } | 139 } |
141 | 140 |
142 bool HeadsUpDisplayLayerImpl::layerIsAlwaysDamaged() const | 141 bool HeadsUpDisplayLayerImpl::layerIsAlwaysDamaged() const |
143 { | 142 { |
144 return true; | 143 return true; |
145 } | 144 } |
146 | 145 |
147 void HeadsUpDisplayLayerImpl::drawHudContents(SkCanvas* canvas) | 146 void HeadsUpDisplayLayerImpl::drawHudContents(SkCanvas* canvas) |
148 { | 147 { |
149 const LayerTreeSettings& settings = layerTreeHostImpl()->settings(); | 148 if (m_flags.showPlatformLayerTree) { |
150 | |
151 if (settings.showPlatformLayerTree) { | |
152 SkPaint paint = createPaint(); | 149 SkPaint paint = createPaint(); |
153 paint.setColor(SkColorSetARGB(192, 0, 0, 0)); | 150 paint.setColor(SkColorSetARGB(192, 0, 0, 0)); |
154 canvas->drawRect(SkRect::MakeXYWH(0, 0, bounds().width(), bounds().heigh
t()), paint); | 151 canvas->drawRect(SkRect::MakeXYWH(0, 0, bounds().width(), bounds().heigh
t()), paint); |
155 } | 152 } |
156 | 153 |
157 int platformLayerTreeTop = 0; | 154 int platformLayerTreeTop = 0; |
158 | 155 |
159 if (m_showFPSCounter) | 156 if (m_flags.showFPSCounter) |
160 platformLayerTreeTop = drawFPSCounter(canvas, layerTreeHostImpl()->fpsCo
unter()); | 157 platformLayerTreeTop = drawFPSCounter(canvas, layerTreeHostImpl()->fpsCo
unter()); |
161 | 158 |
162 if (settings.showPlatformLayerTree && m_fontAtlas.get()) { | 159 if (m_flags.showPlatformLayerTree && m_fontAtlas.get()) { |
163 std::string layerTree = layerTreeHostImpl()->layerTreeAsText(); | 160 std::string layerTree = layerTreeHostImpl()->layerTreeAsText(); |
164 m_fontAtlas->drawText(canvas, createPaint(), layerTree, gfx::Point(2, pl
atformLayerTreeTop), bounds()); | 161 m_fontAtlas->drawText(canvas, createPaint(), layerTree, gfx::Point(2, pl
atformLayerTreeTop), bounds()); |
165 } | 162 } |
166 | 163 |
167 if (settings.showDebugRects()) | 164 if (m_flags.showDebugRects()) |
168 drawDebugRects(canvas, layerTreeHostImpl()->debugRectHistory()); | 165 drawDebugRects(canvas, layerTreeHostImpl()->debugRectHistory()); |
169 } | 166 } |
170 | 167 |
171 int HeadsUpDisplayLayerImpl::drawFPSCounter(SkCanvas* canvas, FrameRateCounter*
fpsCounter) | 168 int HeadsUpDisplayLayerImpl::drawFPSCounter(SkCanvas* canvas, FrameRateCounter*
fpsCounter) |
172 { | 169 { |
173 const int padding = 4; | 170 const int padding = 4; |
174 const int gap = 6; | 171 const int gap = 6; |
175 | 172 |
176 const int fontHeight = m_fontAtlas.get() ? m_fontAtlas->fontHeight() : 0; | 173 const int fontHeight = m_fontAtlas.get() ? m_fontAtlas->fontHeight() : 0; |
177 | 174 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 canvas->drawRect(skRect, paint); | 365 canvas->drawRect(skRect, paint); |
369 } | 366 } |
370 } | 367 } |
371 | 368 |
372 const char* HeadsUpDisplayLayerImpl::layerTypeAsString() const | 369 const char* HeadsUpDisplayLayerImpl::layerTypeAsString() const |
373 { | 370 { |
374 return "HeadsUpDisplayLayer"; | 371 return "HeadsUpDisplayLayer"; |
375 } | 372 } |
376 | 373 |
377 } // namespace cc | 374 } // namespace cc |
OLD | NEW |