OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PLAYBACK_DISPLAY_ITEM_LIST_H_ | 5 #ifndef CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ |
6 #define CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ | 6 #define CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 |
| 10 #include <memory> |
9 #include <utility> | 11 #include <utility> |
10 | 12 |
11 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
12 #include "base/macros.h" | 14 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
16 #include "cc/base/cc_export.h" | 17 #include "cc/base/cc_export.h" |
17 #include "cc/base/contiguous_container.h" | 18 #include "cc/base/contiguous_container.h" |
18 #include "cc/playback/discardable_image_map.h" | 19 #include "cc/playback/discardable_image_map.h" |
19 #include "cc/playback/display_item.h" | 20 #include "cc/playback/display_item.h" |
20 #include "cc/playback/display_item_list_settings.h" | 21 #include "cc/playback/display_item_list_settings.h" |
21 #include "skia/ext/refptr.h" | 22 #include "skia/ext/refptr.h" |
22 #include "third_party/skia/include/core/SkPicture.h" | 23 #include "third_party/skia/include/core/SkPicture.h" |
23 #include "ui/gfx/geometry/rect.h" | 24 #include "ui/gfx/geometry/rect.h" |
24 | 25 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // applicable, create an internally cached SkPicture. | 92 // applicable, create an internally cached SkPicture. |
92 void Finalize(); | 93 void Finalize(); |
93 | 94 |
94 bool IsSuitableForGpuRasterization() const; | 95 bool IsSuitableForGpuRasterization() const; |
95 int ApproximateOpCount() const; | 96 int ApproximateOpCount() const; |
96 size_t ApproximateMemoryUsage() const; | 97 size_t ApproximateMemoryUsage() const; |
97 bool ShouldBeAnalyzedForSolidColor() const; | 98 bool ShouldBeAnalyzedForSolidColor() const; |
98 | 99 |
99 bool RetainsIndividualDisplayItems() const; | 100 bool RetainsIndividualDisplayItems() const; |
100 | 101 |
101 scoped_ptr<base::trace_event::ConvertableToTraceFormat> AsValue( | 102 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> AsValue( |
102 bool include_items) const; | 103 bool include_items) const; |
103 | 104 |
104 void EmitTraceSnapshot() const; | 105 void EmitTraceSnapshot() const; |
105 | 106 |
106 void GenerateDiscardableImagesMetadata(); | 107 void GenerateDiscardableImagesMetadata(); |
107 void GetDiscardableImagesInRect(const gfx::Rect& rect, | 108 void GetDiscardableImagesInRect(const gfx::Rect& rect, |
108 float raster_scale, | 109 float raster_scale, |
109 std::vector<DrawImage>* images); | 110 std::vector<DrawImage>* images); |
110 bool MayHaveDiscardableImages() const; | 111 bool MayHaveDiscardableImages() const; |
111 | 112 |
112 gfx::Rect VisualRectForTesting(int index) { return visual_rects_[index]; } | 113 gfx::Rect VisualRectForTesting(int index) { return visual_rects_[index]; } |
113 | 114 |
114 private: | 115 private: |
115 DisplayItemList(gfx::Rect layer_rect, | 116 DisplayItemList(gfx::Rect layer_rect, |
116 const DisplayItemListSettings& display_list_settings, | 117 const DisplayItemListSettings& display_list_settings, |
117 bool retain_individual_display_items); | 118 bool retain_individual_display_items); |
118 ~DisplayItemList(); | 119 ~DisplayItemList(); |
119 | 120 |
120 void ProcessAppendedItem(const DisplayItem* item); | 121 void ProcessAppendedItem(const DisplayItem* item); |
121 | 122 |
122 ContiguousContainer<DisplayItem> items_; | 123 ContiguousContainer<DisplayItem> items_; |
123 // The visual rects associated with each of the display items in the | 124 // The visual rects associated with each of the display items in the |
124 // display item list. There is one rect per display item, and the | 125 // display item list. There is one rect per display item, and the |
125 // position in |visual_rects_| matches the position of the item in | 126 // position in |visual_rects_| matches the position of the item in |
126 // |items_| . These rects are intentionally kept separate | 127 // |items_| . These rects are intentionally kept separate |
127 // because they are not needed while walking the |items_| for raster. | 128 // because they are not needed while walking the |items_| for raster. |
128 std::vector<gfx::Rect> visual_rects_; | 129 std::vector<gfx::Rect> visual_rects_; |
129 sk_sp<SkPicture> picture_; | 130 sk_sp<SkPicture> picture_; |
130 | 131 |
131 scoped_ptr<SkPictureRecorder> recorder_; | 132 std::unique_ptr<SkPictureRecorder> recorder_; |
132 skia::RefPtr<SkCanvas> canvas_; | 133 skia::RefPtr<SkCanvas> canvas_; |
133 const DisplayItemListSettings settings_; | 134 const DisplayItemListSettings settings_; |
134 bool retain_individual_display_items_; | 135 bool retain_individual_display_items_; |
135 | 136 |
136 gfx::Rect layer_rect_; | 137 gfx::Rect layer_rect_; |
137 bool is_suitable_for_gpu_rasterization_; | 138 bool is_suitable_for_gpu_rasterization_; |
138 int approximate_op_count_; | 139 int approximate_op_count_; |
139 | 140 |
140 // Memory usage due to the cached SkPicture. | 141 // Memory usage due to the cached SkPicture. |
141 size_t picture_memory_usage_; | 142 size_t picture_memory_usage_; |
142 | 143 |
143 DiscardableImageMap image_map_; | 144 DiscardableImageMap image_map_; |
144 | 145 |
145 friend class base::RefCountedThreadSafe<DisplayItemList>; | 146 friend class base::RefCountedThreadSafe<DisplayItemList>; |
146 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); | 147 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); |
147 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); | 148 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); |
148 }; | 149 }; |
149 | 150 |
150 } // namespace cc | 151 } // namespace cc |
151 | 152 |
152 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ | 153 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ |
OLD | NEW |