| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CC_LAYERS_HEADS_UP_DISPLAY_LAYER_IMPL_H_ | |
| 6 #define CC_LAYERS_HEADS_UP_DISPLAY_LAYER_IMPL_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 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" | |
| 18 | |
| 19 class SkCanvas; | |
| 20 class SkPaint; | |
| 21 class SkTypeface; | |
| 22 struct SkRect; | |
| 23 | |
| 24 namespace cc { | |
| 25 | |
| 26 class FrameRateCounter; | |
| 27 class PaintTimeCounter; | |
| 28 | |
| 29 class CC_EXPORT HeadsUpDisplayLayerImpl : public LayerImpl { | |
| 30 public: | |
| 31 static scoped_ptr<HeadsUpDisplayLayerImpl> Create(LayerTreeImpl* tree_impl, | |
| 32 int id) { | |
| 33 return make_scoped_ptr(new HeadsUpDisplayLayerImpl(tree_impl, id)); | |
| 34 } | |
| 35 ~HeadsUpDisplayLayerImpl() override; | |
| 36 | |
| 37 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; | |
| 38 | |
| 39 bool WillDraw(DrawMode draw_mode, | |
| 40 ResourceProvider* resource_provider) override; | |
| 41 void AppendQuads(RenderPass* render_pass, | |
| 42 AppendQuadsData* append_quads_data) override; | |
| 43 void UpdateHudTexture(DrawMode draw_mode, | |
| 44 ResourceProvider* resource_provider); | |
| 45 | |
| 46 void ReleaseResources() override; | |
| 47 | |
| 48 gfx::Rect GetEnclosingRectInTargetSpace() const override; | |
| 49 | |
| 50 bool IsAnimatingHUDContents() const { return fade_step_ > 0; } | |
| 51 | |
| 52 private: | |
| 53 class Graph { | |
| 54 public: | |
| 55 Graph(double indicator_value, double start_upper_bound); | |
| 56 | |
| 57 // Eases the upper bound, which limits what is currently visible in the | |
| 58 // graph, so that the graph always scales to either it's max or | |
| 59 // default_upper_bound. | |
| 60 double UpdateUpperBound(); | |
| 61 | |
| 62 double value; | |
| 63 double min; | |
| 64 double max; | |
| 65 | |
| 66 double current_upper_bound; | |
| 67 const double default_upper_bound; | |
| 68 const double indicator; | |
| 69 }; | |
| 70 | |
| 71 HeadsUpDisplayLayerImpl(LayerTreeImpl* tree_impl, int id); | |
| 72 | |
| 73 const char* LayerTypeAsString() const override; | |
| 74 | |
| 75 void AsValueInto(base::trace_event::TracedValue* dict) const override; | |
| 76 | |
| 77 void UpdateHudContents(); | |
| 78 void DrawHudContents(SkCanvas* canvas); | |
| 79 | |
| 80 void DrawText(SkCanvas* canvas, | |
| 81 SkPaint* paint, | |
| 82 const std::string& text, | |
| 83 SkPaint::Align align, | |
| 84 int size, | |
| 85 int x, | |
| 86 int y) const; | |
| 87 void DrawText(SkCanvas* canvas, | |
| 88 SkPaint* paint, | |
| 89 const std::string& text, | |
| 90 SkPaint::Align align, | |
| 91 int size, | |
| 92 const SkPoint& pos) const; | |
| 93 void DrawGraphBackground(SkCanvas* canvas, | |
| 94 SkPaint* paint, | |
| 95 const SkRect& bounds) const; | |
| 96 void DrawGraphLines(SkCanvas* canvas, | |
| 97 SkPaint* paint, | |
| 98 const SkRect& bounds, | |
| 99 const Graph& graph) const; | |
| 100 | |
| 101 SkRect DrawFPSDisplay(SkCanvas* canvas, | |
| 102 const FrameRateCounter* fps_counter, | |
| 103 int right, | |
| 104 int top) const; | |
| 105 SkRect DrawMemoryDisplay(SkCanvas* canvas, | |
| 106 int top, | |
| 107 int right, | |
| 108 int width) const; | |
| 109 SkRect DrawGpuRasterizationStatus(SkCanvas* canvas, | |
| 110 int right, | |
| 111 int top, | |
| 112 int width) const; | |
| 113 SkRect DrawPaintTimeDisplay(SkCanvas* canvas, | |
| 114 const PaintTimeCounter* paint_time_counter, | |
| 115 int top, | |
| 116 int right) const; | |
| 117 void DrawDebugRect(SkCanvas* canvas, | |
| 118 SkPaint* paint, | |
| 119 const DebugRect& rect, | |
| 120 SkColor stroke_color, | |
| 121 SkColor fill_color, | |
| 122 float stroke_width, | |
| 123 const std::string& label_text) const; | |
| 124 void DrawDebugRects(SkCanvas* canvas, DebugRectHistory* debug_rect_history); | |
| 125 | |
| 126 void AcquireResource(ResourceProvider* resource_provider); | |
| 127 void ReleaseUnmatchedSizeResources(ResourceProvider* resource_provider); | |
| 128 | |
| 129 ScopedPtrVector<ScopedResource> resources_; | |
| 130 skia::RefPtr<SkSurface> hud_surface_; | |
| 131 | |
| 132 skia::RefPtr<SkTypeface> typeface_; | |
| 133 | |
| 134 float internal_contents_scale_; | |
| 135 gfx::Size internal_content_bounds_; | |
| 136 | |
| 137 Graph fps_graph_; | |
| 138 Graph paint_time_graph_; | |
| 139 MemoryHistory::Entry memory_entry_; | |
| 140 int fade_step_; | |
| 141 std::vector<DebugRect> paint_rects_; | |
| 142 | |
| 143 base::TimeTicks time_of_last_graph_update_; | |
| 144 | |
| 145 DISALLOW_COPY_AND_ASSIGN(HeadsUpDisplayLayerImpl); | |
| 146 }; | |
| 147 | |
| 148 } // namespace cc | |
| 149 | |
| 150 #endif // CC_LAYERS_HEADS_UP_DISPLAY_LAYER_IMPL_H_ | |
| OLD | NEW |