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 #ifndef CC_HEADS_UP_DISPLAY_LAYER_IMPL_H_ | 5 #ifndef CC_HEADS_UP_DISPLAY_LAYER_IMPL_H_ |
6 #define CC_HEADS_UP_DISPLAY_LAYER_IMPL_H_ | 6 #define CC_HEADS_UP_DISPLAY_LAYER_IMPL_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "cc/cc_export.h" | 10 #include "cc/cc_export.h" |
11 #include "cc/font_atlas.h" | 11 #include "cc/font_atlas.h" |
12 #include "cc/layer_impl.h" | 12 #include "cc/layer_impl.h" |
13 #include "cc/scoped_resource.h" | 13 #include "cc/scoped_resource.h" |
14 | 14 |
15 class SkCanvas; | 15 class SkCanvas; |
16 class SkPaint; | 16 class SkPaint; |
17 struct SkRect; | 17 struct SkRect; |
18 | 18 |
19 namespace cc { | 19 namespace cc { |
20 | 20 |
21 class DebugRectHistory; | 21 class DebugRectHistory; |
22 class FontAtlas; | 22 class FontAtlas; |
23 class FrameRateCounter; | 23 class FrameRateCounter; |
| 24 class PaintTimeCounter; |
24 | 25 |
25 class CC_EXPORT HeadsUpDisplayLayerImpl : public LayerImpl { | 26 class CC_EXPORT HeadsUpDisplayLayerImpl : public LayerImpl { |
26 public: | 27 public: |
27 static scoped_ptr<HeadsUpDisplayLayerImpl> create(LayerTreeImpl* treeImpl, i
nt id) | 28 static scoped_ptr<HeadsUpDisplayLayerImpl> create(LayerTreeImpl* treeImpl, i
nt id) |
28 { | 29 { |
29 return make_scoped_ptr(new HeadsUpDisplayLayerImpl(treeImpl, id)); | 30 return make_scoped_ptr(new HeadsUpDisplayLayerImpl(treeImpl, id)); |
30 } | 31 } |
31 virtual ~HeadsUpDisplayLayerImpl(); | 32 virtual ~HeadsUpDisplayLayerImpl(); |
32 | 33 |
33 void setFontAtlas(scoped_ptr<FontAtlas>); | 34 void setFontAtlas(scoped_ptr<FontAtlas>); |
34 | 35 |
35 virtual void willDraw(ResourceProvider*) OVERRIDE; | 36 virtual void willDraw(ResourceProvider*) OVERRIDE; |
36 virtual void appendQuads(QuadSink&, AppendQuadsData&) OVERRIDE; | 37 virtual void appendQuads(QuadSink&, AppendQuadsData&) OVERRIDE; |
37 void updateHudTexture(ResourceProvider*); | 38 void updateHudTexture(ResourceProvider*); |
38 virtual void didDraw(ResourceProvider*) OVERRIDE; | 39 virtual void didDraw(ResourceProvider*) OVERRIDE; |
39 | 40 |
40 virtual void didLoseOutputSurface() OVERRIDE; | 41 virtual void didLoseOutputSurface() OVERRIDE; |
41 | 42 |
42 virtual bool layerIsAlwaysDamaged() const OVERRIDE; | 43 virtual bool layerIsAlwaysDamaged() const OVERRIDE; |
43 | 44 |
44 private: | 45 private: |
| 46 struct Graph { |
| 47 Graph(double indicatorValue, double startUpperBound); |
| 48 |
| 49 // Eases the upper bound, which limits what is currently visible in the
graph, |
| 50 // so that the graph always scales to either it's max or defaultUpperBou
nd. |
| 51 static double updateUpperBound(Graph*); |
| 52 |
| 53 double value; |
| 54 double min; |
| 55 double max; |
| 56 |
| 57 double currentUpperBound; |
| 58 const double defaultUpperBound; |
| 59 const double indicator; |
| 60 }; |
| 61 |
45 HeadsUpDisplayLayerImpl(LayerTreeImpl* treeImpl, int id); | 62 HeadsUpDisplayLayerImpl(LayerTreeImpl* treeImpl, int id); |
46 | 63 |
47 virtual const char* layerTypeAsString() const OVERRIDE; | 64 virtual const char* layerTypeAsString() const OVERRIDE; |
48 | 65 |
49 void drawHudContents(SkCanvas*); | 66 void drawHudContents(SkCanvas*); |
50 int drawFPSCounter(SkCanvas*, FrameRateCounter*); | 67 |
51 void drawFPSCounterText(SkCanvas*, SkPaint&, FrameRateCounter*, SkRect); | 68 void drawTextLeftAligned(SkCanvas*, SkPaint*, const SkRect& bounds, const st
d::string& text); |
52 void drawFPSCounterGraphAndHistogram(SkCanvas* canvas, SkPaint& paint, Frame
RateCounter* fpsCounter, SkRect graphBounds, SkRect histogramBounds); | 69 void drawTextRightAligned(SkCanvas*, SkPaint*, const SkRect& bounds, const s
td::string& text); |
| 70 |
| 71 void drawGraphBackground(SkCanvas*, SkPaint*, const SkRect& bounds); |
| 72 void drawGraphLines(SkCanvas*, SkPaint*, const SkRect& bounds, const Graph&)
; |
| 73 |
| 74 int drawFPSDisplay(SkCanvas*, FrameRateCounter*, const int& top); |
| 75 int drawPaintTimeDisplay(SkCanvas*, PaintTimeCounter*, const int& top); |
| 76 |
53 void drawDebugRects(SkCanvas*, DebugRectHistory*); | 77 void drawDebugRects(SkCanvas*, DebugRectHistory*); |
54 | 78 |
55 scoped_ptr<FontAtlas> m_fontAtlas; | 79 scoped_ptr<FontAtlas> m_fontAtlas; |
56 scoped_ptr<ScopedResource> m_hudTexture; | 80 scoped_ptr<ScopedResource> m_hudTexture; |
57 scoped_ptr<SkCanvas> m_hudCanvas; | 81 scoped_ptr<SkCanvas> m_hudCanvas; |
58 | 82 |
59 double m_averageFPS; | 83 Graph m_fpsGraph; |
60 double m_minFPS; | 84 Graph m_paintTimeGraph; |
61 double m_maxFPS; | |
62 | 85 |
63 base::TimeTicks textUpdateTime; | 86 base::TimeTicks m_timeOfLastGraphUpdate; |
64 }; | 87 }; |
65 | 88 |
66 } // namespace cc | 89 } // namespace cc |
67 | 90 |
68 #endif // CC_HEADS_UP_DISPLAY_LAYER_IMPL_H_ | 91 #endif // CC_HEADS_UP_DISPLAY_LAYER_IMPL_H_ |
OLD | NEW |