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