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_
11 #include "base/memory/scoped_ptr.h"
12 #include "base/time/time.h"
13 #include "cc/base/cc_export.h"
14 #include "cc/debug/debug_rect_history.h"
15 #include "cc/layers/layer_impl.h"
16 #include "cc/resources/memory_history.h"
17 #include "cc/resources/scoped_resource.h"
26 class FrameRateCounter
;
27 class PaintTimeCounter
;
29 class CC_EXPORT HeadsUpDisplayLayerImpl
: public LayerImpl
{
31 static scoped_ptr
<HeadsUpDisplayLayerImpl
> Create(LayerTreeImpl
* tree_impl
,
33 return make_scoped_ptr(new HeadsUpDisplayLayerImpl(tree_impl
, id
));
35 virtual ~HeadsUpDisplayLayerImpl();
37 virtual scoped_ptr
<LayerImpl
> CreateLayerImpl(LayerTreeImpl
* tree_impl
)
40 virtual bool WillDraw(DrawMode draw_mode
,
41 ResourceProvider
* resource_provider
) OVERRIDE
;
42 virtual void AppendQuads(RenderPass
* render_pass
,
43 const OcclusionTracker
<LayerImpl
>& occlusion_tracker
,
44 AppendQuadsData
* append_quads_data
) OVERRIDE
;
45 void UpdateHudTexture(DrawMode draw_mode
,
46 ResourceProvider
* resource_provider
);
48 virtual void ReleaseResources() OVERRIDE
;
50 bool IsAnimatingHUDContents() const { return fade_step_
> 0; }
55 Graph(double indicator_value
, double start_upper_bound
);
57 // Eases the upper bound, which limits what is currently visible in the
58 // graph, so that the graph always scales to either it's max or
59 // default_upper_bound.
60 double UpdateUpperBound();
66 double current_upper_bound
;
67 const double default_upper_bound
;
68 const double indicator
;
71 HeadsUpDisplayLayerImpl(LayerTreeImpl
* tree_impl
, int id
);
73 virtual const char* LayerTypeAsString() const OVERRIDE
;
75 virtual void AsValueInto(base::DictionaryValue
* dict
) const OVERRIDE
;
77 void UpdateHudContents();
78 void DrawHudContents(SkCanvas
* canvas
);
80 void DrawText(SkCanvas
* canvas
,
82 const std::string
& text
,
87 void DrawText(SkCanvas
* canvas
,
89 const std::string
& text
,
92 const SkPoint
& pos
) const;
93 void DrawGraphBackground(SkCanvas
* canvas
,
95 const SkRect
& bounds
) const;
96 void DrawGraphLines(SkCanvas
* canvas
,
99 const Graph
& graph
) const;
101 SkRect
DrawFPSDisplay(SkCanvas
* canvas
,
102 const FrameRateCounter
* fps_counter
,
105 SkRect
DrawMemoryDisplay(SkCanvas
* canvas
,
109 SkRect
DrawPaintTimeDisplay(SkCanvas
* canvas
,
110 const PaintTimeCounter
* paint_time_counter
,
113 void DrawDebugRect(SkCanvas
* canvas
,
115 const DebugRect
& rect
,
116 SkColor stroke_color
,
119 const std::string
& label_text
) const;
120 void DrawDebugRects(SkCanvas
* canvas
, DebugRectHistory
* debug_rect_history
);
122 scoped_ptr
<ScopedResource
> hud_resource_
;
123 scoped_ptr
<SkCanvas
> hud_canvas_
;
125 skia::RefPtr
<SkTypeface
> typeface_
;
128 Graph paint_time_graph_
;
129 MemoryHistory::Entry memory_entry_
;
131 std::vector
<DebugRect
> paint_rects_
;
133 base::TimeTicks time_of_last_graph_update_
;
135 DISALLOW_COPY_AND_ASSIGN(HeadsUpDisplayLayerImpl
);
140 #endif // CC_LAYERS_HEADS_UP_DISPLAY_LAYER_IMPL_H_