| 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 "CCHeadsUpDisplayLayerImpl.h" | 7 #include "CCHeadsUpDisplayLayerImpl.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 CCHeadsUpDisplayLayerImpl::CCHeadsUpDisplayLayerImpl(int id) | 44 CCHeadsUpDisplayLayerImpl::CCHeadsUpDisplayLayerImpl(int id) |
| 45 : CCLayerImpl(id) | 45 : CCLayerImpl(id) |
| 46 , m_showFPSCounter(false) |
| 46 { | 47 { |
| 47 } | 48 } |
| 48 | 49 |
| 49 CCHeadsUpDisplayLayerImpl::~CCHeadsUpDisplayLayerImpl() | 50 CCHeadsUpDisplayLayerImpl::~CCHeadsUpDisplayLayerImpl() |
| 50 { | 51 { |
| 51 } | 52 } |
| 52 | 53 |
| 53 void CCHeadsUpDisplayLayerImpl::setFontAtlas(scoped_ptr<CCFontAtlas> fontAtlas) | 54 void CCHeadsUpDisplayLayerImpl::setFontAtlas(scoped_ptr<CCFontAtlas> fontAtlas) |
| 54 { | 55 { |
| 55 m_fontAtlas = fontAtlas.Pass(); | 56 m_fontAtlas = fontAtlas.Pass(); |
| 56 } | 57 } |
| 57 | 58 |
| 59 void CCHeadsUpDisplayLayerImpl::setShowFPSCounter(bool show) |
| 60 { |
| 61 m_showFPSCounter = show; |
| 62 } |
| 63 |
| 58 void CCHeadsUpDisplayLayerImpl::willDraw(CCResourceProvider* resourceProvider) | 64 void CCHeadsUpDisplayLayerImpl::willDraw(CCResourceProvider* resourceProvider) |
| 59 { | 65 { |
| 60 CCLayerImpl::willDraw(resourceProvider); | 66 CCLayerImpl::willDraw(resourceProvider); |
| 61 | 67 |
| 62 if (!m_hudTexture) | 68 if (!m_hudTexture) |
| 63 m_hudTexture = CCScopedTexture::create(resourceProvider); | 69 m_hudTexture = CCScopedTexture::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 drawFPSCounter(canvas, layerTreeHostImpl()->fpsCounter(), fpsCounterTop,
fpsCounterHeight); |
| 151 platformLayerTreeTop = fpsCounterTop + fpsCounterHeight; | 158 platformLayerTreeTop = fpsCounterTop + fpsCounterHeight; |
| 152 else | 159 } else |
| 153 platformLayerTreeTop = 0; | 160 platformLayerTreeTop = 0; |
| 154 | 161 |
| 155 if (settings.showFPSCounter) | |
| 156 drawFPSCounter(canvas, layerTreeHostImpl()->fpsCounter(), fpsCounterTop,
fpsCounterHeight); | |
| 157 | |
| 158 if (settings.showPlatformLayerTree && m_fontAtlas.get()) { | 162 if (settings.showPlatformLayerTree && m_fontAtlas.get()) { |
| 159 std::string layerTree = layerTreeHostImpl()->layerTreeAsText(); | 163 std::string layerTree = layerTreeHostImpl()->layerTreeAsText(); |
| 160 m_fontAtlas->drawText(canvas, createPaint(), layerTree, gfx::Point(2, pl
atformLayerTreeTop), bounds()); | 164 m_fontAtlas->drawText(canvas, createPaint(), layerTree, gfx::Point(2, pl
atformLayerTreeTop), bounds()); |
| 161 } | 165 } |
| 162 | 166 |
| 163 if (settings.showDebugRects()) | 167 if (settings.showDebugRects()) |
| 164 drawDebugRects(canvas, layerTreeHostImpl()->debugRectHistory()); | 168 drawDebugRects(canvas, layerTreeHostImpl()->debugRectHistory()); |
| 165 } | 169 } |
| 166 | 170 |
| 167 void CCHeadsUpDisplayLayerImpl::drawFPSCounter(SkCanvas* canvas, CCFrameRateCoun
ter* fpsCounter, int top, int height) | 171 void CCHeadsUpDisplayLayerImpl::drawFPSCounter(SkCanvas* canvas, CCFrameRateCoun
ter* fpsCounter, int top, int height) |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 canvas->drawRect(skRect, paint); | 292 canvas->drawRect(skRect, paint); |
| 289 } | 293 } |
| 290 } | 294 } |
| 291 | 295 |
| 292 const char* CCHeadsUpDisplayLayerImpl::layerTypeAsString() const | 296 const char* CCHeadsUpDisplayLayerImpl::layerTypeAsString() const |
| 293 { | 297 { |
| 294 return "HeadsUpDisplayLayer"; | 298 return "HeadsUpDisplayLayer"; |
| 295 } | 299 } |
| 296 | 300 |
| 297 } | 301 } |
| OLD | NEW |