| 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) | |
| 66 { | |
| 67 m_showFPSCounter = show; | |
| 68 } | |
| 69 | |
| 70 void HeadsUpDisplayLayerImpl::willDraw(ResourceProvider* resourceProvider) | 64 void HeadsUpDisplayLayerImpl::willDraw(ResourceProvider* resourceProvider) |
| 71 { | 65 { |
| 72 LayerImpl::willDraw(resourceProvider); | 66 LayerImpl::willDraw(resourceProvider); |
| 73 | 67 |
| 74 if (!m_hudTexture) | 68 if (!m_hudTexture) |
| 75 m_hudTexture = ScopedResource::create(resourceProvider); | 69 m_hudTexture = ScopedResource::create(resourceProvider); |
| 76 | 70 |
| 77 // FIXME: Scale the HUD by deviceScale to make it more friendly under high D
PI. | 71 // FIXME: Scale the HUD by deviceScale to make it more friendly under high D
PI. |
| 78 | 72 |
| 79 if (m_hudTexture->size() != bounds()) | 73 if (m_hudTexture->size() != bounds()) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 m_hudTexture.reset(); | 137 m_hudTexture.reset(); |
| 144 } | 138 } |
| 145 | 139 |
| 146 bool HeadsUpDisplayLayerImpl::layerIsAlwaysDamaged() const | 140 bool HeadsUpDisplayLayerImpl::layerIsAlwaysDamaged() const |
| 147 { | 141 { |
| 148 return true; | 142 return true; |
| 149 } | 143 } |
| 150 | 144 |
| 151 void HeadsUpDisplayLayerImpl::drawHudContents(SkCanvas* canvas) | 145 void HeadsUpDisplayLayerImpl::drawHudContents(SkCanvas* canvas) |
| 152 { | 146 { |
| 153 const LayerTreeSettings& settings = layerTreeHostImpl()->settings(); | 147 const LayerTreeSwitches& switches = layerTreeHostImpl()->switches(); |
| 154 | 148 |
| 155 if (settings.showPlatformLayerTree) { | 149 if (switches.showPlatformLayerTree) { |
| 156 SkPaint paint = createPaint(); | 150 SkPaint paint = createPaint(); |
| 157 paint.setColor(SkColorSetARGB(192, 0, 0, 0)); | 151 paint.setColor(SkColorSetARGB(192, 0, 0, 0)); |
| 158 canvas->drawRect(SkRect::MakeXYWH(0, 0, bounds().width(), bounds().heigh
t()), paint); | 152 canvas->drawRect(SkRect::MakeXYWH(0, 0, bounds().width(), bounds().heigh
t()), paint); |
| 159 } | 153 } |
| 160 | 154 |
| 161 int platformLayerTreeTop = 0; | 155 int platformLayerTreeTop = 0; |
| 162 | 156 |
| 163 if (m_showFPSCounter) | 157 if (switches.showFPSCounter) |
| 164 platformLayerTreeTop = drawFPSCounter(canvas, layerTreeHostImpl()->fpsCo
unter()); | 158 platformLayerTreeTop = drawFPSCounter(canvas, layerTreeHostImpl()->fpsCo
unter()); |
| 165 | 159 |
| 166 if (settings.showPlatformLayerTree && m_fontAtlas.get()) { | 160 if (switches.showPlatformLayerTree && m_fontAtlas.get()) { |
| 167 std::string layerTree = layerTreeHostImpl()->layerTreeAsText(); | 161 std::string layerTree = layerTreeHostImpl()->layerTreeAsText(); |
| 168 m_fontAtlas->drawText(canvas, createPaint(), layerTree, gfx::Point(2, pl
atformLayerTreeTop), bounds()); | 162 m_fontAtlas->drawText(canvas, createPaint(), layerTree, gfx::Point(2, pl
atformLayerTreeTop), bounds()); |
| 169 } | 163 } |
| 170 | 164 |
| 171 if (settings.showDebugRects()) | 165 if (switches.showHudRects()) |
| 172 drawDebugRects(canvas, layerTreeHostImpl()->debugRectHistory()); | 166 drawDebugRects(canvas, layerTreeHostImpl()->debugRectHistory()); |
| 173 } | 167 } |
| 174 | 168 |
| 175 int HeadsUpDisplayLayerImpl::drawFPSCounter(SkCanvas* canvas, FrameRateCounter*
fpsCounter) | 169 int HeadsUpDisplayLayerImpl::drawFPSCounter(SkCanvas* canvas, FrameRateCounter*
fpsCounter) |
| 176 { | 170 { |
| 177 const int padding = 4; | 171 const int padding = 4; |
| 178 const int gap = 6; | 172 const int gap = 6; |
| 179 | 173 |
| 180 const int fontHeight = m_fontAtlas.get() ? m_fontAtlas->fontHeight() : 0; | 174 const int fontHeight = m_fontAtlas.get() ? m_fontAtlas->fontHeight() : 0; |
| 181 | 175 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 canvas->drawRect(skRect, paint); | 367 canvas->drawRect(skRect, paint); |
| 374 } | 368 } |
| 375 } | 369 } |
| 376 | 370 |
| 377 const char* HeadsUpDisplayLayerImpl::layerTypeAsString() const | 371 const char* HeadsUpDisplayLayerImpl::layerTypeAsString() const |
| 378 { | 372 { |
| 379 return "HeadsUpDisplayLayer"; | 373 return "HeadsUpDisplayLayer"; |
| 380 } | 374 } |
| 381 | 375 |
| 382 } // namespace cc | 376 } // namespace cc |
| OLD | NEW |