Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Side by Side Diff: cc/layers/heads_up_display_layer_impl.h

Issue 187343007: Adding fading effect for paint rectangles in HUD. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More fixes. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_LAYERS_HEADS_UP_DISPLAY_LAYER_IMPL_H_ 5 #ifndef CC_LAYERS_HEADS_UP_DISPLAY_LAYER_IMPL_H_
6 #define CC_LAYERS_HEADS_UP_DISPLAY_LAYER_IMPL_H_ 6 #define CC_LAYERS_HEADS_UP_DISPLAY_LAYER_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector>
9 10
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/time/time.h" 12 #include "base/time/time.h"
12 #include "cc/base/cc_export.h" 13 #include "cc/base/cc_export.h"
14 #include "cc/debug/debug_rect_history.h"
13 #include "cc/layers/layer_impl.h" 15 #include "cc/layers/layer_impl.h"
14 #include "cc/resources/memory_history.h" 16 #include "cc/resources/memory_history.h"
15 #include "cc/resources/scoped_resource.h" 17 #include "cc/resources/scoped_resource.h"
16 18
17 class SkCanvas; 19 class SkCanvas;
18 class SkPaint; 20 class SkPaint;
19 class SkTypeface; 21 class SkTypeface;
20 struct SkRect; 22 struct SkRect;
21 23
22 namespace cc { 24 namespace cc {
23 25
24 class DebugRectHistory;
25 class FrameRateCounter; 26 class FrameRateCounter;
26 class PaintTimeCounter; 27 class PaintTimeCounter;
27 28
28 class CC_EXPORT HeadsUpDisplayLayerImpl : public LayerImpl { 29 class CC_EXPORT HeadsUpDisplayLayerImpl : public LayerImpl {
29 public: 30 public:
30 static scoped_ptr<HeadsUpDisplayLayerImpl> Create(LayerTreeImpl* tree_impl, 31 static scoped_ptr<HeadsUpDisplayLayerImpl> Create(LayerTreeImpl* tree_impl,
31 int id) { 32 int id) {
32 return make_scoped_ptr(new HeadsUpDisplayLayerImpl(tree_impl, id)); 33 return make_scoped_ptr(new HeadsUpDisplayLayerImpl(tree_impl, id));
33 } 34 }
34 virtual ~HeadsUpDisplayLayerImpl(); 35 virtual ~HeadsUpDisplayLayerImpl();
35 36
36 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) 37 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
37 OVERRIDE; 38 OVERRIDE;
38 39
39 virtual bool WillDraw(DrawMode draw_mode, 40 virtual bool WillDraw(DrawMode draw_mode,
40 ResourceProvider* resource_provider) OVERRIDE; 41 ResourceProvider* resource_provider) OVERRIDE;
41 virtual void AppendQuads(QuadSink* quad_sink, 42 virtual void AppendQuads(QuadSink* quad_sink,
42 AppendQuadsData* append_quads_data) OVERRIDE; 43 AppendQuadsData* append_quads_data) OVERRIDE;
43 void UpdateHudTexture(DrawMode draw_mode, 44 void UpdateHudTexture(DrawMode draw_mode,
44 ResourceProvider* resource_provider); 45 ResourceProvider* resource_provider);
45 46
46 virtual void ReleaseResources() OVERRIDE; 47 virtual void ReleaseResources() OVERRIDE;
47 48
48 virtual bool LayerIsAlwaysDamaged() const OVERRIDE; 49 virtual bool LayerIsAlwaysDamaged() const OVERRIDE;
49 50
51 bool NeedsUpdate() const { return needs_update_; }
52
50 private: 53 private:
51 class Graph { 54 class Graph {
52 public: 55 public:
53 Graph(double indicator_value, double start_upper_bound); 56 Graph(double indicator_value, double start_upper_bound);
54 57
55 // Eases the upper bound, which limits what is currently visible in the 58 // 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 59 // graph, so that the graph always scales to either it's max or
57 // default_upper_bound. 60 // default_upper_bound.
58 double UpdateUpperBound(); 61 double UpdateUpperBound();
59 62
60 double value; 63 double value;
61 double min; 64 double min;
62 double max; 65 double max;
63 66
64 double current_upper_bound; 67 double current_upper_bound;
65 const double default_upper_bound; 68 const double default_upper_bound;
66 const double indicator; 69 const double indicator;
67 }; 70 };
68 71
69 HeadsUpDisplayLayerImpl(LayerTreeImpl* tree_impl, int id); 72 HeadsUpDisplayLayerImpl(LayerTreeImpl* tree_impl, int id);
70 73
71 virtual const char* LayerTypeAsString() const OVERRIDE; 74 virtual const char* LayerTypeAsString() const OVERRIDE;
72 75
73 virtual void AsValueInto(base::DictionaryValue* dict) const OVERRIDE; 76 virtual void AsValueInto(base::DictionaryValue* dict) const OVERRIDE;
74 77
75 void UpdateHudContents(); 78 void UpdateHudContents();
76 void DrawHudContents(SkCanvas* canvas) const; 79 void DrawHudContents(SkCanvas* canvas);
77 80
78 void DrawText(SkCanvas* canvas, 81 void DrawText(SkCanvas* canvas,
79 SkPaint* paint, 82 SkPaint* paint,
80 const std::string& text, 83 const std::string& text,
81 SkPaint::Align align, 84 SkPaint::Align align,
82 int size, 85 int size,
83 int x, 86 int x,
84 int y) const; 87 int y) const;
85 void DrawText(SkCanvas* canvas, 88 void DrawText(SkCanvas* canvas,
86 SkPaint* paint, 89 SkPaint* paint,
(...skipping 14 matching lines...) Expand all
101 int right, 104 int right,
102 int top) const; 105 int top) const;
103 SkRect DrawMemoryDisplay(SkCanvas* canvas, 106 SkRect DrawMemoryDisplay(SkCanvas* canvas,
104 int top, 107 int top,
105 int right, 108 int right,
106 int width) const; 109 int width) const;
107 SkRect DrawPaintTimeDisplay(SkCanvas* canvas, 110 SkRect DrawPaintTimeDisplay(SkCanvas* canvas,
108 const PaintTimeCounter* paint_time_counter, 111 const PaintTimeCounter* paint_time_counter,
109 int top, 112 int top,
110 int right) const; 113 int right) const;
111 void DrawDebugRects(SkCanvas* canvas, 114 void DrawDebugRect(SkCanvas* canvas,
112 DebugRectHistory* debug_rect_history) const; 115 const DebugRect& rect,
116 const SkColor stroke_color,
117 const SkColor fill_color,
118 const float stroke_width,
119 const std::string label_text) const;
120 void DrawDebugRects(SkCanvas* canvas, DebugRectHistory* debug_rect_history);
113 121
114 scoped_ptr<ScopedResource> hud_resource_; 122 scoped_ptr<ScopedResource> hud_resource_;
115 scoped_ptr<SkCanvas> hud_canvas_; 123 scoped_ptr<SkCanvas> hud_canvas_;
116 124
117 skia::RefPtr<SkTypeface> typeface_; 125 skia::RefPtr<SkTypeface> typeface_;
118 126
119 Graph fps_graph_; 127 Graph fps_graph_;
120 Graph paint_time_graph_; 128 Graph paint_time_graph_;
121 MemoryHistory::Entry memory_entry_; 129 MemoryHistory::Entry memory_entry_;
130 bool needs_update_;
131 int fade_step_;
132 std::vector<DebugRect> paint_rects_;
122 133
123 base::TimeTicks time_of_last_graph_update_; 134 base::TimeTicks time_of_last_graph_update_;
124 135
125 DISALLOW_COPY_AND_ASSIGN(HeadsUpDisplayLayerImpl); 136 DISALLOW_COPY_AND_ASSIGN(HeadsUpDisplayLayerImpl);
126 }; 137 };
127 138
128 } // namespace cc 139 } // namespace cc
129 140
130 #endif // CC_LAYERS_HEADS_UP_DISPLAY_LAYER_IMPL_H_ 141 #endif // CC_LAYERS_HEADS_UP_DISPLAY_LAYER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698