| 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 |
| 49 bool IsAnimatingHUDContents() const { return fade_step_ > 0; } |
| 50 |
| 48 private: | 51 private: |
| 49 class Graph { | 52 class Graph { |
| 50 public: | 53 public: |
| 51 Graph(double indicator_value, double start_upper_bound); | 54 Graph(double indicator_value, double start_upper_bound); |
| 52 | 55 |
| 53 // Eases the upper bound, which limits what is currently visible in the | 56 // Eases the upper bound, which limits what is currently visible in the |
| 54 // graph, so that the graph always scales to either it's max or | 57 // graph, so that the graph always scales to either it's max or |
| 55 // default_upper_bound. | 58 // default_upper_bound. |
| 56 double UpdateUpperBound(); | 59 double UpdateUpperBound(); |
| 57 | 60 |
| 58 double value; | 61 double value; |
| 59 double min; | 62 double min; |
| 60 double max; | 63 double max; |
| 61 | 64 |
| 62 double current_upper_bound; | 65 double current_upper_bound; |
| 63 const double default_upper_bound; | 66 const double default_upper_bound; |
| 64 const double indicator; | 67 const double indicator; |
| 65 }; | 68 }; |
| 66 | 69 |
| 67 HeadsUpDisplayLayerImpl(LayerTreeImpl* tree_impl, int id); | 70 HeadsUpDisplayLayerImpl(LayerTreeImpl* tree_impl, int id); |
| 68 | 71 |
| 69 virtual const char* LayerTypeAsString() const OVERRIDE; | 72 virtual const char* LayerTypeAsString() const OVERRIDE; |
| 70 | 73 |
| 71 virtual void AsValueInto(base::DictionaryValue* dict) const OVERRIDE; | 74 virtual void AsValueInto(base::DictionaryValue* dict) const OVERRIDE; |
| 72 | 75 |
| 73 void UpdateHudContents(); | 76 void UpdateHudContents(); |
| 74 void DrawHudContents(SkCanvas* canvas) const; | 77 void DrawHudContents(SkCanvas* canvas); |
| 75 | 78 |
| 76 void DrawText(SkCanvas* canvas, | 79 void DrawText(SkCanvas* canvas, |
| 77 SkPaint* paint, | 80 SkPaint* paint, |
| 78 const std::string& text, | 81 const std::string& text, |
| 79 SkPaint::Align align, | 82 SkPaint::Align align, |
| 80 int size, | 83 int size, |
| 81 int x, | 84 int x, |
| 82 int y) const; | 85 int y) const; |
| 83 void DrawText(SkCanvas* canvas, | 86 void DrawText(SkCanvas* canvas, |
| 84 SkPaint* paint, | 87 SkPaint* paint, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 99 int right, | 102 int right, |
| 100 int top) const; | 103 int top) const; |
| 101 SkRect DrawMemoryDisplay(SkCanvas* canvas, | 104 SkRect DrawMemoryDisplay(SkCanvas* canvas, |
| 102 int top, | 105 int top, |
| 103 int right, | 106 int right, |
| 104 int width) const; | 107 int width) const; |
| 105 SkRect DrawPaintTimeDisplay(SkCanvas* canvas, | 108 SkRect DrawPaintTimeDisplay(SkCanvas* canvas, |
| 106 const PaintTimeCounter* paint_time_counter, | 109 const PaintTimeCounter* paint_time_counter, |
| 107 int top, | 110 int top, |
| 108 int right) const; | 111 int right) const; |
| 109 void DrawDebugRects(SkCanvas* canvas, | 112 void DrawDebugRect(SkCanvas* canvas, |
| 110 DebugRectHistory* debug_rect_history) const; | 113 SkPaint& paint, |
| 114 const DebugRect& rect, |
| 115 SkColor stroke_color, |
| 116 SkColor fill_color, |
| 117 float stroke_width, |
| 118 const std::string& label_text) const; |
| 119 void DrawDebugRects(SkCanvas* canvas, DebugRectHistory* debug_rect_history); |
| 111 | 120 |
| 112 scoped_ptr<ScopedResource> hud_resource_; | 121 scoped_ptr<ScopedResource> hud_resource_; |
| 113 scoped_ptr<SkCanvas> hud_canvas_; | 122 scoped_ptr<SkCanvas> hud_canvas_; |
| 114 | 123 |
| 115 skia::RefPtr<SkTypeface> typeface_; | 124 skia::RefPtr<SkTypeface> typeface_; |
| 116 | 125 |
| 117 Graph fps_graph_; | 126 Graph fps_graph_; |
| 118 Graph paint_time_graph_; | 127 Graph paint_time_graph_; |
| 119 MemoryHistory::Entry memory_entry_; | 128 MemoryHistory::Entry memory_entry_; |
| 129 int fade_step_; |
| 130 std::vector<DebugRect> paint_rects_; |
| 120 | 131 |
| 121 base::TimeTicks time_of_last_graph_update_; | 132 base::TimeTicks time_of_last_graph_update_; |
| 122 | 133 |
| 123 DISALLOW_COPY_AND_ASSIGN(HeadsUpDisplayLayerImpl); | 134 DISALLOW_COPY_AND_ASSIGN(HeadsUpDisplayLayerImpl); |
| 124 }; | 135 }; |
| 125 | 136 |
| 126 } // namespace cc | 137 } // namespace cc |
| 127 | 138 |
| 128 #endif // CC_LAYERS_HEADS_UP_DISPLAY_LAYER_IMPL_H_ | 139 #endif // CC_LAYERS_HEADS_UP_DISPLAY_LAYER_IMPL_H_ |
| OLD | NEW |