OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CC_HEADS_UP_DISPLAY_LAYER_IMPL_H_ | |
6 #define CC_HEADS_UP_DISPLAY_LAYER_IMPL_H_ | |
7 | |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "base/time.h" | |
10 #include "cc/base/cc_export.h" | |
11 #include "cc/layer_impl.h" | |
12 #include "cc/resources/memory_history.h" | |
13 #include "cc/resources/scoped_resource.h" | |
14 | |
15 class SkCanvas; | |
16 class SkPaint; | |
17 class SkTypeface; | |
18 struct SkRect; | |
19 | |
20 namespace cc { | |
21 | |
22 class DebugRectHistory; | |
23 class FrameRateCounter; | |
24 class PaintTimeCounter; | |
25 | |
26 class CC_EXPORT HeadsUpDisplayLayerImpl : public LayerImpl { | |
27 public: | |
28 static scoped_ptr<HeadsUpDisplayLayerImpl> Create(LayerTreeImpl* tree_impl, | |
29 int id) { | |
30 return make_scoped_ptr(new HeadsUpDisplayLayerImpl(tree_impl, id)); | |
31 } | |
32 virtual ~HeadsUpDisplayLayerImpl(); | |
33 | |
34 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) | |
35 OVERRIDE; | |
36 | |
37 virtual void WillDraw(ResourceProvider* resource_provider) OVERRIDE; | |
38 virtual void AppendQuads(QuadSink* quad_sink, | |
39 AppendQuadsData* append_quads_data) OVERRIDE; | |
40 void UpdateHudTexture(ResourceProvider* resource_provider); | |
41 virtual void DidDraw(ResourceProvider* resource_provider) OVERRIDE; | |
42 | |
43 virtual void DidLoseOutputSurface() OVERRIDE; | |
44 | |
45 virtual bool LayerIsAlwaysDamaged() const OVERRIDE; | |
46 | |
47 private: | |
48 class Graph { | |
49 public: | |
50 Graph(double indicator_value, double start_upper_bound); | |
51 | |
52 // Eases the upper bound, which limits what is currently visible in the | |
53 // graph, so that the graph always scales to either it's max or | |
54 // default_upper_bound. | |
55 double UpdateUpperBound(); | |
56 | |
57 double value; | |
58 double min; | |
59 double max; | |
60 | |
61 double current_upper_bound; | |
62 const double default_upper_bound; | |
63 const double indicator; | |
64 }; | |
65 | |
66 HeadsUpDisplayLayerImpl(LayerTreeImpl* tree_impl, int id); | |
67 | |
68 virtual const char* LayerTypeAsString() const OVERRIDE; | |
69 | |
70 void UpdateHudContents(); | |
71 void DrawHudContents(SkCanvas* canvas) const; | |
72 | |
73 void DrawText(SkCanvas* canvas, | |
74 SkPaint* paint, | |
75 const std::string& text, | |
76 SkPaint::Align align, | |
77 int size, | |
78 int x, | |
79 int y) const; | |
80 void DrawText(SkCanvas* canvas, | |
81 SkPaint* paint, | |
82 const std::string& text, | |
83 SkPaint::Align align, | |
84 int size, | |
85 const SkPoint& pos) const; | |
86 void DrawGraphBackground(SkCanvas* canvas, | |
87 SkPaint* paint, | |
88 const SkRect& bounds) const; | |
89 void DrawGraphLines(SkCanvas* canvas, | |
90 SkPaint* paint, | |
91 const SkRect& bounds, | |
92 const Graph& graph) const; | |
93 | |
94 void DrawPlatformLayerTree(SkCanvas* canvas) const; | |
95 SkRect DrawFPSDisplay(SkCanvas* canvas, | |
96 const FrameRateCounter* fps_counter, | |
97 int right, | |
98 int top) const; | |
99 SkRect DrawMemoryDisplay(SkCanvas* canvas, | |
100 int top, | |
101 int right, | |
102 int width) const; | |
103 SkRect DrawPaintTimeDisplay(SkCanvas* canvas, | |
104 const PaintTimeCounter* paint_time_counter, | |
105 int top, | |
106 int right) const; | |
107 void DrawDebugRects(SkCanvas* canvas, | |
108 DebugRectHistory* debug_rect_history) const; | |
109 | |
110 scoped_ptr<ScopedResource> hud_texture_; | |
111 scoped_ptr<SkCanvas> hud_canvas_; | |
112 | |
113 skia::RefPtr<SkTypeface> typeface_; | |
114 | |
115 Graph fps_graph_; | |
116 Graph paint_time_graph_; | |
117 MemoryHistory::Entry memory_entry_; | |
118 | |
119 base::TimeTicks time_of_last_graph_update_; | |
120 | |
121 DISALLOW_COPY_AND_ASSIGN(HeadsUpDisplayLayerImpl); | |
122 }; | |
123 | |
124 } // namespace cc | |
125 | |
126 #endif // CC_HEADS_UP_DISPLAY_LAYER_IMPL_H_ | |
OLD | NEW |