Chromium Code Reviews| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/heads_up_display_layer_impl.h" | 7 #include "cc/heads_up_display_layer_impl.h" |
| 8 | 8 |
| 9 #include "CCDebugRectHistory.h" | 9 #include "CCDebugRectHistory.h" |
| 10 #include "CCFontAtlas.h" | 10 #include "CCFontAtlas.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 swizzleMatrix.fMat[2 + 5 * 0] = 1; | 36 swizzleMatrix.fMat[2 + 5 * 0] = 1; |
| 37 swizzleMatrix.fMat[3 + 5 * 3] = 1; | 37 swizzleMatrix.fMat[3 + 5 * 3] = 1; |
| 38 | 38 |
| 39 SkPaint paint; | 39 SkPaint paint; |
| 40 paint.setColorFilter(new SkColorMatrixFilter(swizzleMatrix))->unref(); | 40 paint.setColorFilter(new SkColorMatrixFilter(swizzleMatrix))->unref(); |
| 41 return paint; | 41 return paint; |
| 42 } | 42 } |
| 43 | 43 |
| 44 HeadsUpDisplayLayerImpl::HeadsUpDisplayLayerImpl(int id) | 44 HeadsUpDisplayLayerImpl::HeadsUpDisplayLayerImpl(int id) |
| 45 : LayerImpl(id) | 45 : LayerImpl(id) |
| 46 , m_showFPSCounter(false) | |
| 46 { | 47 { |
| 47 } | 48 } |
| 48 | 49 |
| 49 HeadsUpDisplayLayerImpl::~HeadsUpDisplayLayerImpl() | 50 HeadsUpDisplayLayerImpl::~HeadsUpDisplayLayerImpl() |
| 50 { | 51 { |
| 51 } | 52 } |
| 52 | 53 |
| 53 void HeadsUpDisplayLayerImpl::setFontAtlas(scoped_ptr<FontAtlas> fontAtlas) | 54 void HeadsUpDisplayLayerImpl::setFontAtlas(scoped_ptr<FontAtlas> fontAtlas) |
| 54 { | 55 { |
| 55 m_fontAtlas = fontAtlas.Pass(); | 56 m_fontAtlas = fontAtlas.Pass(); |
| 56 } | 57 } |
| 57 | 58 |
| 59 void HeadsUpDisplayLayerImpl::setShowFPSCounter(bool show) | |
| 60 { | |
| 61 m_showFPSCounter = show; | |
| 62 } | |
| 63 | |
| 58 void HeadsUpDisplayLayerImpl::willDraw(ResourceProvider* resourceProvider) | 64 void HeadsUpDisplayLayerImpl::willDraw(ResourceProvider* resourceProvider) |
| 59 { | 65 { |
| 60 LayerImpl::willDraw(resourceProvider); | 66 LayerImpl::willDraw(resourceProvider); |
| 61 | 67 |
| 62 if (!m_hudTexture) | 68 if (!m_hudTexture) |
| 63 m_hudTexture = ScopedTexture::create(resourceProvider); | 69 m_hudTexture = ScopedTexture::create(resourceProvider); |
| 64 | 70 |
| 65 // 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. |
| 66 | 72 |
| 67 if (m_hudTexture->size() != bounds()) | 73 if (m_hudTexture->size() != bounds()) |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 if (settings.showPlatformLayerTree) { | 146 if (settings.showPlatformLayerTree) { |
| 141 SkPaint paint = createPaint(); | 147 SkPaint paint = createPaint(); |
| 142 paint.setColor(SkColorSetARGB(192, 0, 0, 0)); | 148 paint.setColor(SkColorSetARGB(192, 0, 0, 0)); |
| 143 canvas->drawRect(SkRect::MakeXYWH(0, 0, bounds().width(), bounds().heigh t()), paint); | 149 canvas->drawRect(SkRect::MakeXYWH(0, 0, bounds().width(), bounds().heigh t()), paint); |
| 144 } | 150 } |
| 145 | 151 |
| 146 int fpsCounterHeight = 40; | 152 int fpsCounterHeight = 40; |
| 147 int fpsCounterTop = 2; | 153 int fpsCounterTop = 2; |
| 148 int platformLayerTreeTop; | 154 int platformLayerTreeTop; |
| 149 | 155 |
| 150 if (settings.showFPSCounter) | 156 if (m_showFPSCounter) { |
| 157 DCHECK(m_fontAtlas.get()); | |
|
egraether
2012/10/25 02:01:11
I put DCHECKs in here, so that the fontAtlas still
| |
| 158 drawFPSCounter(canvas, layerTreeHostImpl()->fpsCounter(), fpsCounterTop, fpsCounterHeight); | |
| 151 platformLayerTreeTop = fpsCounterTop + fpsCounterHeight; | 159 platformLayerTreeTop = fpsCounterTop + fpsCounterHeight; |
| 152 else | 160 } else |
| 153 platformLayerTreeTop = 0; | 161 platformLayerTreeTop = 0; |
| 154 | 162 |
| 155 if (settings.showFPSCounter) | 163 if (settings.showPlatformLayerTree) { |
| 156 drawFPSCounter(canvas, layerTreeHostImpl()->fpsCounter(), fpsCounterTop, fpsCounterHeight); | 164 DCHECK(m_fontAtlas.get()); |
| 157 | |
| 158 if (settings.showPlatformLayerTree && m_fontAtlas.get()) { | |
| 159 std::string layerTree = layerTreeHostImpl()->layerTreeAsText(); | 165 std::string layerTree = layerTreeHostImpl()->layerTreeAsText(); |
| 160 m_fontAtlas->drawText(canvas, createPaint(), layerTree, gfx::Point(2, pl atformLayerTreeTop), bounds()); | 166 m_fontAtlas->drawText(canvas, createPaint(), layerTree, gfx::Point(2, pl atformLayerTreeTop), bounds()); |
| 161 } | 167 } |
| 162 | 168 |
| 163 if (settings.showDebugRects()) | 169 if (settings.showDebugRects()) |
| 164 drawDebugRects(canvas, layerTreeHostImpl()->debugRectHistory()); | 170 drawDebugRects(canvas, layerTreeHostImpl()->debugRectHistory()); |
| 165 } | 171 } |
| 166 | 172 |
| 167 void HeadsUpDisplayLayerImpl::drawFPSCounter(SkCanvas* canvas, FrameRateCounter* fpsCounter, int top, int height) | 173 void HeadsUpDisplayLayerImpl::drawFPSCounter(SkCanvas* canvas, FrameRateCounter* fpsCounter, int top, int height) |
| 168 { | 174 { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 canvas->drawRect(skRect, paint); | 294 canvas->drawRect(skRect, paint); |
| 289 } | 295 } |
| 290 } | 296 } |
| 291 | 297 |
| 292 const char* HeadsUpDisplayLayerImpl::layerTypeAsString() const | 298 const char* HeadsUpDisplayLayerImpl::layerTypeAsString() const |
| 293 { | 299 { |
| 294 return "HeadsUpDisplayLayer"; | 300 return "HeadsUpDisplayLayer"; |
| 295 } | 301 } |
| 296 | 302 |
| 297 } | 303 } |
| OLD | NEW |