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 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
17 #include "cc/base/cc_export.h" | 17 #include "cc/base/cc_export.h" |
18 #include "cc/base/contiguous_container.h" | 18 #include "cc/base/contiguous_container.h" |
19 #include "cc/base/rtree.h" | 19 #include "cc/base/rtree.h" |
20 #include "cc/playback/discardable_image_map.h" | 20 #include "cc/playback/discardable_image_map.h" |
21 #include "cc/playback/display_item.h" | 21 #include "cc/playback/display_item.h" |
22 #include "cc/playback/image_id.h" | 22 #include "cc/playback/image_id.h" |
23 #include "third_party/skia/include/core/SkPicture.h" | 23 #include "third_party/skia/include/core/SkPicture.h" |
24 #include "ui/gfx/color_space.h" | 24 #include "ui/gfx/color_space.h" |
25 #include "ui/gfx/geometry/rect.h" | 25 #include "ui/gfx/geometry/rect.h" |
26 #include "ui/gfx/geometry/rect_conversions.h" | 26 #include "ui/gfx/geometry/rect_conversions.h" |
27 | 27 |
28 class SkCanvas; | 28 class SkCanvas; |
29 | 29 |
| 30 namespace base { |
| 31 namespace trace_event { |
| 32 class TracedValue; |
| 33 } |
| 34 } |
| 35 |
30 namespace cc { | 36 namespace cc { |
31 class DisplayItem; | 37 class DisplayItem; |
32 | 38 |
33 class CC_EXPORT DisplayItemList | 39 class CC_EXPORT DisplayItemList |
34 : public base::RefCountedThreadSafe<DisplayItemList> { | 40 : public base::RefCountedThreadSafe<DisplayItemList> { |
35 public: | 41 public: |
36 DisplayItemList(); | 42 DisplayItemList(); |
37 | 43 |
38 // TODO(trchen): Deprecated. Apply clip and scale on the canvas instead. | 44 // TODO(trchen): Deprecated. Apply clip and scale on the canvas instead. |
39 void Raster(SkCanvas* canvas, | 45 void Raster(SkCanvas* canvas, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 129 |
124 void SetIsSuitableForGpuRasterization(bool is_suitable) { | 130 void SetIsSuitableForGpuRasterization(bool is_suitable) { |
125 inputs_.all_items_are_suitable_for_gpu_rasterization = is_suitable; | 131 inputs_.all_items_are_suitable_for_gpu_rasterization = is_suitable; |
126 } | 132 } |
127 bool IsSuitableForGpuRasterization() const; | 133 bool IsSuitableForGpuRasterization() const; |
128 | 134 |
129 int ApproximateOpCount() const; | 135 int ApproximateOpCount() const; |
130 size_t ApproximateMemoryUsage() const; | 136 size_t ApproximateMemoryUsage() const; |
131 bool ShouldBeAnalyzedForSolidColor() const; | 137 bool ShouldBeAnalyzedForSolidColor() const; |
132 | 138 |
133 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> AsValue( | |
134 bool include_items) const; | |
135 | |
136 void EmitTraceSnapshot() const; | 139 void EmitTraceSnapshot() const; |
137 | 140 |
138 void GenerateDiscardableImagesMetadata(); | 141 void GenerateDiscardableImagesMetadata(); |
139 void GetDiscardableImagesInRect(const gfx::Rect& rect, | 142 void GetDiscardableImagesInRect(const gfx::Rect& rect, |
140 float contents_scale, | 143 float contents_scale, |
141 std::vector<DrawImage>* images); | 144 std::vector<DrawImage>* images); |
142 gfx::Rect GetRectForImage(ImageId image_id) const; | 145 gfx::Rect GetRectForImage(ImageId image_id) const; |
143 | 146 |
144 void SetRetainVisualRectsForTesting(bool retain) { | 147 void SetRetainVisualRectsForTesting(bool retain) { |
145 retain_visual_rects_ = retain; | 148 retain_visual_rects_ = retain; |
146 } | 149 } |
147 | 150 |
148 size_t size() const { return inputs_.items.size(); } | 151 size_t size() const { return inputs_.items.size(); } |
149 | 152 |
150 gfx::Rect VisualRectForTesting(int index) { | 153 gfx::Rect VisualRectForTesting(int index) { |
151 return inputs_.visual_rects[index]; | 154 return inputs_.visual_rects[index]; |
152 } | 155 } |
153 | 156 |
154 ContiguousContainer<DisplayItem>::const_iterator begin() const { | 157 ContiguousContainer<DisplayItem>::const_iterator begin() const { |
155 return inputs_.items.begin(); | 158 return inputs_.items.begin(); |
156 } | 159 } |
157 | 160 |
158 ContiguousContainer<DisplayItem>::const_iterator end() const { | 161 ContiguousContainer<DisplayItem>::const_iterator end() const { |
159 return inputs_.items.end(); | 162 return inputs_.items.end(); |
160 } | 163 } |
161 | 164 |
162 private: | 165 private: |
| 166 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, AsValueWithNoItems); |
| 167 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, AsValueWithItems); |
| 168 |
163 ~DisplayItemList(); | 169 ~DisplayItemList(); |
164 | 170 |
| 171 std::unique_ptr<base::trace_event::TracedValue> CreateTracedValue( |
| 172 bool include_items) const; |
| 173 |
165 RTree rtree_; | 174 RTree rtree_; |
166 // For testing purposes only. Whether to keep visual rects across calls to | 175 // For testing purposes only. Whether to keep visual rects across calls to |
167 // Finalize(). | 176 // Finalize(). |
168 bool retain_visual_rects_ = false; | 177 bool retain_visual_rects_ = false; |
169 | 178 |
170 // If we're currently within a paired display item block, unions the | 179 // If we're currently within a paired display item block, unions the |
171 // given visual rect with the begin display item's visual rect. | 180 // given visual rect with the begin display item's visual rect. |
172 void GrowCurrentBeginItemVisualRect(const gfx::Rect& visual_rect); | 181 void GrowCurrentBeginItemVisualRect(const gfx::Rect& visual_rect); |
173 | 182 |
174 template <typename DisplayItemType, typename... Args> | 183 template <typename DisplayItemType, typename... Args> |
(...skipping 26 matching lines...) Expand all Loading... |
201 Inputs inputs_; | 210 Inputs inputs_; |
202 | 211 |
203 friend class base::RefCountedThreadSafe<DisplayItemList>; | 212 friend class base::RefCountedThreadSafe<DisplayItemList>; |
204 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); | 213 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); |
205 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); | 214 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); |
206 }; | 215 }; |
207 | 216 |
208 } // namespace cc | 217 } // namespace cc |
209 | 218 |
210 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ | 219 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ |
OLD | NEW |