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