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 ~HeadsUpDisplayLayerImpl() override
;
37 scoped_ptr
<LayerImpl
> CreateLayerImpl(LayerTreeImpl
* tree_impl
) override
;
39 bool WillDraw(DrawMode draw_mode
,
40 ResourceProvider
* resource_provider
) override
;
41 void AppendQuads(RenderPass
* render_pass
,
42 const Occlusion
& occlusion_in_content_space
,
43 AppendQuadsData
* append_quads_data
) override
;
44 void UpdateHudTexture(DrawMode draw_mode
,
45 ResourceProvider
* resource_provider
);
47 void ReleaseResources() override
;
49 bool IsAnimatingHUDContents() const { return fade_step_
> 0; }
54 Graph(double indicator_value
, double start_upper_bound
);
56 // Eases the upper bound, which limits what is currently visible in the
57 // graph, so that the graph always scales to either it's max or
58 // default_upper_bound.
59 double UpdateUpperBound();
65 double current_upper_bound
;
66 const double default_upper_bound
;
67 const double indicator
;
70 HeadsUpDisplayLayerImpl(LayerTreeImpl
* tree_impl
, int id
);
72 const char* LayerTypeAsString() const override
;
74 void AsValueInto(base::debug::TracedValue
* dict
) const override
;
76 void UpdateHudContents();
77 void DrawHudContents(SkCanvas
* canvas
);
79 void DrawText(SkCanvas
* canvas
,
81 const std::string
& text
,
86 void DrawText(SkCanvas
* canvas
,
88 const std::string
& text
,
91 const SkPoint
& pos
) const;
92 void DrawGraphBackground(SkCanvas
* canvas
,
94 const SkRect
& bounds
) const;
95 void DrawGraphLines(SkCanvas
* canvas
,
98 const Graph
& graph
) const;
100 SkRect
DrawFPSDisplay(SkCanvas
* canvas
,
101 const FrameRateCounter
* fps_counter
,
104 SkRect
DrawMemoryDisplay(SkCanvas
* canvas
,
108 SkRect
DrawGpuRasterizationStatus(SkCanvas
* canvas
,
112 SkRect
DrawPaintTimeDisplay(SkCanvas
* canvas
,
113 const PaintTimeCounter
* paint_time_counter
,
116 void DrawDebugRect(SkCanvas
* canvas
,
118 const DebugRect
& rect
,
119 SkColor stroke_color
,
122 const std::string
& label_text
) const;
123 void DrawDebugRects(SkCanvas
* canvas
, DebugRectHistory
* debug_rect_history
);
125 void AcquireResource(ResourceProvider
* resource_provider
);
126 void ReleaseUnmatchedSizeResources(ResourceProvider
* resource_provider
);
128 ScopedPtrVector
<ScopedResource
> resources_
;
129 scoped_ptr
<SkCanvas
> hud_canvas_
;
131 skia::RefPtr
<SkTypeface
> typeface_
;
134 Graph paint_time_graph_
;
135 MemoryHistory::Entry memory_entry_
;
137 std::vector
<DebugRect
> paint_rects_
;
139 base::TimeTicks time_of_last_graph_update_
;
141 DISALLOW_COPY_AND_ASSIGN(HeadsUpDisplayLayerImpl
);
146 #endif // CC_LAYERS_HEADS_UP_DISPLAY_LAYER_IMPL_H_