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 "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 SkPicture::AbortCallback* callback, | 54 SkPicture::AbortCallback* callback, |
55 const gfx::Rect& canvas_target_playback_rect, | 55 const gfx::Rect& canvas_target_playback_rect, |
56 float contents_scale) const; | 56 float contents_scale) const; |
57 | 57 |
58 // This is a fast path for use only if canvas_ is set and | 58 // This is a fast path for use only if canvas_ is set and |
59 // retain_individual_display_items_ is false. This method also updates | 59 // retain_individual_display_items_ is false. This method also updates |
60 // is_suitable_for_gpu_rasterization_ and approximate_op_count_. | 60 // is_suitable_for_gpu_rasterization_ and approximate_op_count_. |
61 void RasterIntoCanvas(const DisplayItem& display_item); | 61 void RasterIntoCanvas(const DisplayItem& display_item); |
62 | 62 |
63 template <typename DisplayItemType> | 63 template <typename DisplayItemType> |
64 DisplayItemType* CreateAndAppendItem() { | 64 DisplayItemType* CreateAndAppendItem(const gfx::Rect& visual_rect) { |
65 #if DCHECK_IS_ON() | 65 #if DCHECK_IS_ON() |
66 needs_process_ = true; | 66 needs_process_ = true; |
67 #endif | 67 #endif |
68 visual_rects_.push_back(visual_rect); | |
68 ProcessAppendedItemsOnTheFly(); | 69 ProcessAppendedItemsOnTheFly(); |
69 return items_.AllocateAndConstruct<DisplayItemType>(); | 70 return items_.AllocateAndConstruct<DisplayItemType>(); |
70 } | 71 } |
71 | 72 |
72 // Removes the last item. This cannot be called on lists with cached pictures | 73 // Removes the last item. This cannot be called on lists with cached pictures |
73 // (since the data may already have been incorporated into cached picture | 74 // (since the data may already have been incorporated into cached picture |
74 // sizes, etc). | 75 // sizes, etc). |
75 void RemoveLast(); | 76 void RemoveLast(); |
76 | 77 |
77 // Called after all items are appended, to process the items and, if | 78 // Called after all items are appended, to process the items and, if |
(...skipping 28 matching lines...) Expand all Loading... | |
106 void ProcessAppendedItemsOnTheFly(); | 107 void ProcessAppendedItemsOnTheFly(); |
107 void ProcessAppendedItems(); | 108 void ProcessAppendedItems(); |
108 #if DCHECK_IS_ON() | 109 #if DCHECK_IS_ON() |
109 bool ProcessAppendedItemsCalled() const { return !needs_process_; } | 110 bool ProcessAppendedItemsCalled() const { return !needs_process_; } |
110 bool needs_process_; | 111 bool needs_process_; |
111 #else | 112 #else |
112 bool ProcessAppendedItemsCalled() const { return true; } | 113 bool ProcessAppendedItemsCalled() const { return true; } |
113 #endif | 114 #endif |
114 | 115 |
115 ListContainer<DisplayItem> items_; | 116 ListContainer<DisplayItem> items_; |
117 // The visual rects associated with each of the display items in the | |
118 // display item list. There is one rect per display item, and the | |
119 // position in the vector matches the position of the item in the | |
danakj
2015/11/05 23:54:27
nit: the position in |visual_rects_| matches the p
wkorman
2015/11/17 01:47:23
Done.
| |
120 // display item list. These rects are intentionally kept separate | |
121 // from the items so as to keep the display items small. | |
danakj
2015/11/05 23:54:27
because they are not needed while walking the |ite
wkorman
2015/11/17 01:47:23
Done.
| |
122 std::vector<gfx::Rect> visual_rects_; | |
116 skia::RefPtr<SkPicture> picture_; | 123 skia::RefPtr<SkPicture> picture_; |
117 | 124 |
118 scoped_ptr<SkPictureRecorder> recorder_; | 125 scoped_ptr<SkPictureRecorder> recorder_; |
119 skia::RefPtr<SkCanvas> canvas_; | 126 skia::RefPtr<SkCanvas> canvas_; |
120 const DisplayItemListSettings settings_; | 127 const DisplayItemListSettings settings_; |
121 bool retain_individual_display_items_; | 128 bool retain_individual_display_items_; |
122 | 129 |
123 gfx::Rect layer_rect_; | 130 gfx::Rect layer_rect_; |
124 bool is_suitable_for_gpu_rasterization_; | 131 bool is_suitable_for_gpu_rasterization_; |
125 int approximate_op_count_; | 132 int approximate_op_count_; |
126 | 133 |
127 // Memory usage due to the cached SkPicture. | 134 // Memory usage due to the cached SkPicture. |
128 size_t picture_memory_usage_; | 135 size_t picture_memory_usage_; |
129 | 136 |
130 // Memory usage due to external data held by display items. | 137 // Memory usage due to external data held by display items. |
131 size_t external_memory_usage_; | 138 size_t external_memory_usage_; |
132 | 139 |
133 DiscardableImageMap image_map_; | 140 DiscardableImageMap image_map_; |
134 | 141 |
135 friend class base::RefCountedThreadSafe<DisplayItemList>; | 142 friend class base::RefCountedThreadSafe<DisplayItemList>; |
136 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); | 143 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); |
137 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); | 144 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); |
138 }; | 145 }; |
139 | 146 |
140 } // namespace cc | 147 } // namespace cc |
141 | 148 |
142 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ | 149 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ |
OLD | NEW |