| 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> |
| 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/contiguous_container.h" | 17 #include "cc/base/contiguous_container.h" |
| 18 #include "cc/base/rtree.h" | 18 #include "cc/base/rtree.h" |
| 19 #include "cc/paint/discardable_image_map.h" | 19 #include "cc/paint/discardable_image_map.h" |
| 20 #include "cc/paint/display_item.h" | 20 #include "cc/paint/display_item.h" |
| 21 #include "cc/paint/drawing_display_item.h" |
| 21 #include "cc/paint/image_id.h" | 22 #include "cc/paint/image_id.h" |
| 22 #include "cc/paint/paint_export.h" | 23 #include "cc/paint/paint_export.h" |
| 23 #include "third_party/skia/include/core/SkPicture.h" | 24 #include "third_party/skia/include/core/SkPicture.h" |
| 24 #include "ui/gfx/color_space.h" | 25 #include "ui/gfx/color_space.h" |
| 25 #include "ui/gfx/geometry/rect.h" | 26 #include "ui/gfx/geometry/rect.h" |
| 26 #include "ui/gfx/geometry/rect_conversions.h" | 27 #include "ui/gfx/geometry/rect_conversions.h" |
| 27 | 28 |
| 28 class SkCanvas; | 29 class SkCanvas; |
| 29 | 30 |
| 30 namespace base { | 31 namespace base { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 return AllocateAndConstruct<DisplayItemType>(std::forward<Args>(args)...); | 113 return AllocateAndConstruct<DisplayItemType>(std::forward<Args>(args)...); |
| 113 } | 114 } |
| 114 | 115 |
| 115 template <typename DisplayItemType, typename... Args> | 116 template <typename DisplayItemType, typename... Args> |
| 116 const DisplayItemType& CreateAndAppendDrawingItem( | 117 const DisplayItemType& CreateAndAppendDrawingItem( |
| 117 const gfx::Rect& visual_rect, | 118 const gfx::Rect& visual_rect, |
| 118 Args&&... args) { | 119 Args&&... args) { |
| 119 visual_rects_.push_back(visual_rect); | 120 visual_rects_.push_back(visual_rect); |
| 120 GrowCurrentBeginItemVisualRect(visual_rect); | 121 GrowCurrentBeginItemVisualRect(visual_rect); |
| 121 | 122 |
| 122 return AllocateAndConstruct<DisplayItemType>(std::forward<Args>(args)...); | 123 const auto& item = |
| 124 AllocateAndConstruct<DisplayItemType>(std::forward<Args>(args)...); |
| 125 has_discardable_images_ |= item.picture->HasDiscardableImages(); |
| 126 return item; |
| 123 } | 127 } |
| 124 | 128 |
| 125 // Called after all items are appended, to process the items and, if | 129 // Called after all items are appended, to process the items and, if |
| 126 // applicable, create an internally cached SkPicture. | 130 // applicable, create an internally cached SkPicture. |
| 127 void Finalize(); | 131 void Finalize(); |
| 128 | 132 |
| 129 void SetIsSuitableForGpuRasterization(bool is_suitable) { | 133 void SetIsSuitableForGpuRasterization(bool is_suitable) { |
| 130 all_items_are_suitable_for_gpu_rasterization_ = is_suitable; | 134 all_items_are_suitable_for_gpu_rasterization_ = is_suitable; |
| 131 } | 135 } |
| 132 bool IsSuitableForGpuRasterization() const; | 136 bool IsSuitableForGpuRasterization() const; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 153 gfx::Rect VisualRectForTesting(int index) { return visual_rects_[index]; } | 157 gfx::Rect VisualRectForTesting(int index) { return visual_rects_[index]; } |
| 154 | 158 |
| 155 ContiguousContainer<DisplayItem>::const_iterator begin() const { | 159 ContiguousContainer<DisplayItem>::const_iterator begin() const { |
| 156 return items_.begin(); | 160 return items_.begin(); |
| 157 } | 161 } |
| 158 | 162 |
| 159 ContiguousContainer<DisplayItem>::const_iterator end() const { | 163 ContiguousContainer<DisplayItem>::const_iterator end() const { |
| 160 return items_.end(); | 164 return items_.end(); |
| 161 } | 165 } |
| 162 | 166 |
| 167 bool has_discardable_images() const { return has_discardable_images_; } |
| 168 |
| 163 private: | 169 private: |
| 164 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, AsValueWithNoItems); | 170 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, AsValueWithNoItems); |
| 165 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, AsValueWithItems); | 171 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, AsValueWithItems); |
| 166 | 172 |
| 167 ~DisplayItemList(); | 173 ~DisplayItemList(); |
| 168 | 174 |
| 169 std::unique_ptr<base::trace_event::TracedValue> CreateTracedValue( | 175 std::unique_ptr<base::trace_event::TracedValue> CreateTracedValue( |
| 170 bool include_items) const; | 176 bool include_items) const; |
| 171 | 177 |
| 172 // 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 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 191 // |items| . These rects are intentionally kept separate | 197 // |items| . These rects are intentionally kept separate |
| 192 // because they are not needed while walking the |items| for raster. | 198 // because they are not needed while walking the |items| for raster. |
| 193 std::vector<gfx::Rect> visual_rects_; | 199 std::vector<gfx::Rect> visual_rects_; |
| 194 std::vector<size_t> begin_item_indices_; | 200 std::vector<size_t> begin_item_indices_; |
| 195 | 201 |
| 196 int approximate_op_count_ = 0; | 202 int approximate_op_count_ = 0; |
| 197 bool all_items_are_suitable_for_gpu_rasterization_ = true; | 203 bool all_items_are_suitable_for_gpu_rasterization_ = true; |
| 198 // 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 |
| 199 // Finalize(). | 205 // Finalize(). |
| 200 bool retain_visual_rects_ = false; | 206 bool retain_visual_rects_ = false; |
| 207 bool has_discardable_images_ = false; |
| 201 | 208 |
| 202 friend class base::RefCountedThreadSafe<DisplayItemList>; | 209 friend class base::RefCountedThreadSafe<DisplayItemList>; |
| 203 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); | 210 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); |
| 204 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); | 211 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); |
| 205 }; | 212 }; |
| 206 | 213 |
| 207 } // namespace cc | 214 } // namespace cc |
| 208 | 215 |
| 209 #endif // CC_PAINT_DISPLAY_ITEM_LIST_H_ | 216 #endif // CC_PAINT_DISPLAY_ITEM_LIST_H_ |
| OLD | NEW |