| 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_PAINT_DISPLAY_ITEM_LIST_H_ | 5 #ifndef CC_PAINT_DISPLAY_ITEM_LIST_H_ |
| 6 #define CC_PAINT_DISPLAY_ITEM_LIST_H_ | 6 #define CC_PAINT_DISPLAY_ITEM_LIST_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 123 |
| 124 // Called after all items are appended, to process the items and, if | 124 // Called after all items are appended, to process the items and, if |
| 125 // applicable, create an internally cached SkPicture. | 125 // applicable, create an internally cached SkPicture. |
| 126 void Finalize(); | 126 void Finalize(); |
| 127 | 127 |
| 128 void SetIsSuitableForGpuRasterization(bool is_suitable) { | 128 void SetIsSuitableForGpuRasterization(bool is_suitable) { |
| 129 all_items_are_suitable_for_gpu_rasterization_ = is_suitable; | 129 all_items_are_suitable_for_gpu_rasterization_ = is_suitable; |
| 130 } | 130 } |
| 131 bool IsSuitableForGpuRasterization() const; | 131 bool IsSuitableForGpuRasterization() const; |
| 132 | 132 |
| 133 int ApproximateOpCount() const; | 133 size_t OpCount() const; |
| 134 size_t ApproximateMemoryUsage() const; | 134 size_t ApproximateMemoryUsage() const; |
| 135 bool ShouldBeAnalyzedForSolidColor() const; | 135 bool ShouldBeAnalyzedForSolidColor() const; |
| 136 | 136 |
| 137 void EmitTraceSnapshot() const; | 137 void EmitTraceSnapshot() const; |
| 138 | 138 |
| 139 void GenerateDiscardableImagesMetadata(); | 139 void GenerateDiscardableImagesMetadata(); |
| 140 void GetDiscardableImagesInRect(const gfx::Rect& rect, | 140 void GetDiscardableImagesInRect(const gfx::Rect& rect, |
| 141 float contents_scale, | 141 float contents_scale, |
| 142 const gfx::ColorSpace& target_color_space, | 142 const gfx::ColorSpace& target_color_space, |
| 143 std::vector<DrawImage>* images); | 143 std::vector<DrawImage>* images); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 bool include_items) const; | 176 bool include_items) const; |
| 177 | 177 |
| 178 // If we're currently within a paired display item block, unions the | 178 // If we're currently within a paired display item block, unions the |
| 179 // given visual rect with the begin display item's visual rect. | 179 // given visual rect with the begin display item's visual rect. |
| 180 void GrowCurrentBeginItemVisualRect(const gfx::Rect& visual_rect); | 180 void GrowCurrentBeginItemVisualRect(const gfx::Rect& visual_rect); |
| 181 | 181 |
| 182 template <typename DisplayItemType, typename... Args> | 182 template <typename DisplayItemType, typename... Args> |
| 183 const DisplayItemType& AllocateAndConstruct(Args&&... args) { | 183 const DisplayItemType& AllocateAndConstruct(Args&&... args) { |
| 184 auto* item = &items_.AllocateAndConstruct<DisplayItemType>( | 184 auto* item = &items_.AllocateAndConstruct<DisplayItemType>( |
| 185 std::forward<Args>(args)...); | 185 std::forward<Args>(args)...); |
| 186 approximate_op_count_ += item->ApproximateOpCount(); | 186 op_count_ += item->OpCount(); |
| 187 return *item; | 187 return *item; |
| 188 } | 188 } |
| 189 | 189 |
| 190 RTree rtree_; | 190 RTree rtree_; |
| 191 DiscardableImageMap image_map_; | 191 DiscardableImageMap image_map_; |
| 192 ContiguousContainer<DisplayItem> items_; | 192 ContiguousContainer<DisplayItem> items_; |
| 193 | 193 |
| 194 // The visual rects associated with each of the display items in the | 194 // The visual rects associated with each of the display items in the |
| 195 // display item list. There is one rect per display item, and the | 195 // display item list. There is one rect per display item, and the |
| 196 // position in |visual_rects| matches the position of the item in | 196 // position in |visual_rects| matches the position of the item in |
| 197 // |items| . These rects are intentionally kept separate | 197 // |items| . These rects are intentionally kept separate |
| 198 // because they are not needed while walking the |items| for raster. | 198 // because they are not needed while walking the |items| for raster. |
| 199 std::vector<gfx::Rect> visual_rects_; | 199 std::vector<gfx::Rect> visual_rects_; |
| 200 std::vector<size_t> begin_item_indices_; | 200 std::vector<size_t> begin_item_indices_; |
| 201 | 201 |
| 202 int approximate_op_count_ = 0; | 202 size_t op_count_ = 0u; |
| 203 bool all_items_are_suitable_for_gpu_rasterization_ = true; | 203 bool all_items_are_suitable_for_gpu_rasterization_ = true; |
| 204 // For testing purposes only. Whether to keep visual rects across calls to | 204 // For testing purposes only. Whether to keep visual rects across calls to |
| 205 // Finalize(). | 205 // Finalize(). |
| 206 bool retain_visual_rects_ = false; | 206 bool retain_visual_rects_ = false; |
| 207 bool has_discardable_images_ = false; | 207 bool has_discardable_images_ = false; |
| 208 | 208 |
| 209 friend class base::RefCountedThreadSafe<DisplayItemList>; | 209 friend class base::RefCountedThreadSafe<DisplayItemList>; |
| 210 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); | 210 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); |
| 211 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); | 211 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); |
| 212 }; | 212 }; |
| 213 | 213 |
| 214 } // namespace cc | 214 } // namespace cc |
| 215 | 215 |
| 216 #endif // CC_PAINT_DISPLAY_ITEM_LIST_H_ | 216 #endif // CC_PAINT_DISPLAY_ITEM_LIST_H_ |
| OLD | NEW |