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.
5 #ifndef CC_LAYERS_HEADS_UP_DISPLAY_LAYER_IMPL_H_
6 #define CC_LAYERS_HEADS_UP_DISPLAY_LAYER_IMPL_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "base/time/time.h"
12 #include "cc/base/cc_export.h"
13 #include "cc/layers/layer_impl.h"
14 #include "cc/resources/memory_history.h"
15 #include "cc/resources/scoped_resource.h"
24 class DebugRectHistory;
25 class FrameRateCounter;
26 class PaintTimeCounter;
28 class CC_EXPORT HeadsUpDisplayLayerImpl : public LayerImpl {
30 static scoped_ptr<HeadsUpDisplayLayerImpl> Create(LayerTreeImpl* tree_impl,
32 return make_scoped_ptr(new HeadsUpDisplayLayerImpl(tree_impl, id));
34 virtual ~HeadsUpDisplayLayerImpl();
36 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
39 virtual bool WillDraw(DrawMode draw_mode,
40 ResourceProvider* resource_provider) OVERRIDE;
41 virtual void AppendQuads(QuadSink* quad_sink,
42 AppendQuadsData* append_quads_data) OVERRIDE;
43 void UpdateHudTexture(DrawMode draw_mode,
44 ResourceProvider* resource_provider);
46 virtual void DidLoseOutputSurface() OVERRIDE;
48 virtual bool LayerIsAlwaysDamaged() const OVERRIDE;
53 Graph(double indicator_value, double start_upper_bound);
55 // Eases the upper bound, which limits what is currently visible in the
56 // graph, so that the graph always scales to either it's max or
57 // default_upper_bound.
58 double UpdateUpperBound();
64 double current_upper_bound;
65 const double default_upper_bound;
66 const double indicator;
69 HeadsUpDisplayLayerImpl(LayerTreeImpl* tree_impl, int id);
71 virtual const char* LayerTypeAsString() const OVERRIDE;
73 void UpdateHudContents();
74 void DrawHudContents(SkCanvas* canvas) const;
76 void DrawText(SkCanvas* canvas,
78 const std::string& text,
83 void DrawText(SkCanvas* canvas,
85 const std::string& text,
88 const SkPoint& pos) const;
89 void DrawGraphBackground(SkCanvas* canvas,
91 const SkRect& bounds) const;
92 void DrawGraphLines(SkCanvas* canvas,
95 const Graph& graph) const;
97 SkRect DrawFPSDisplay(SkCanvas* canvas,
98 const FrameRateCounter* fps_counter,
101 SkRect DrawMemoryDisplay(SkCanvas* canvas,
105 SkRect DrawPaintTimeDisplay(SkCanvas* canvas,
106 const PaintTimeCounter* paint_time_counter,
109 void DrawDebugRects(SkCanvas* canvas,
110 DebugRectHistory* debug_rect_history) const;
112 scoped_ptr<ScopedResource> hud_resource_;
113 scoped_ptr<SkCanvas> hud_canvas_;
115 skia::RefPtr<SkTypeface> typeface_;
118 Graph paint_time_graph_;
119 MemoryHistory::Entry memory_entry_;
121 base::TimeTicks time_of_last_graph_update_;
123 DISALLOW_COPY_AND_ASSIGN(HeadsUpDisplayLayerImpl);
128 #endif // CC_LAYERS_HEADS_UP_DISPLAY_LAYER_IMPL_H_