Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 fade_step_ > 0; } | |
| 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 Loading... | |
| 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, | |
|
caseq
2014/03/06 11:48:37
No need to specify const for anything passed by va
malch
2014/03/06 12:06:23
Done.
| |
| 117 const SkColor fill_color, | |
| 118 const float stroke_width, | |
| 119 const std::string label_text) const; | |
|
caseq
2014/03/06 11:48:37
This should by passed by reference.
malch
2014/03/06 12:06:23
Done.
| |
| 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 int fade_step_; | |
| 131 std::vector<DebugRect> paint_rects_; | |
| 122 | 132 |
| 123 base::TimeTicks time_of_last_graph_update_; | 133 base::TimeTicks time_of_last_graph_update_; |
| 124 | 134 |
| 125 DISALLOW_COPY_AND_ASSIGN(HeadsUpDisplayLayerImpl); | 135 DISALLOW_COPY_AND_ASSIGN(HeadsUpDisplayLayerImpl); |
| 126 }; | 136 }; |
| 127 | 137 |
| 128 } // namespace cc | 138 } // namespace cc |
| 129 | 139 |
| 130 #endif // CC_LAYERS_HEADS_UP_DISPLAY_LAYER_IMPL_H_ | 140 #endif // CC_LAYERS_HEADS_UP_DISPLAY_LAYER_IMPL_H_ |
| OLD | NEW |