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/playback/discardable_image_map.h" | 19 #include "cc/playback/discardable_image_map.h" |
20 #include "cc/playback/display_item.h" | 20 #include "cc/playback/display_item.h" |
21 #include "cc/playback/display_item_list_settings.h" | 21 #include "cc/playback/display_item_list_settings.h" |
22 #include "third_party/skia/include/core/SkPicture.h" | 22 #include "third_party/skia/include/core/SkPicture.h" |
23 #include "ui/gfx/geometry/rect.h" | 23 #include "ui/gfx/geometry/rect.h" |
24 | 24 |
25 class SkCanvas; | 25 class SkCanvas; |
26 class SkPictureRecorder; | 26 class SkPictureRecorder; |
27 | 27 |
28 namespace cc { | 28 namespace cc { |
29 class ClientPictureCache; | |
29 class DisplayItem; | 30 class DisplayItem; |
30 class DrawingDisplayItem; | 31 class DrawingDisplayItem; |
31 class ImageSerializationProcessor; | 32 class EnginePictureCache; |
32 | 33 |
33 namespace proto { | 34 namespace proto { |
34 class DisplayItemList; | 35 class DisplayItemList; |
35 } | 36 } |
36 | 37 |
37 class CC_EXPORT DisplayItemList | 38 class CC_EXPORT DisplayItemList |
38 : public base::RefCountedThreadSafe<DisplayItemList> { | 39 : public base::RefCountedThreadSafe<DisplayItemList> { |
39 public: | 40 public: |
40 // Creates a display item list. If picture caching is used, then layer_rect | 41 // Creates a display item list. If picture caching is used, then layer_rect |
41 // specifies the cull rect of the display item list (the picture will not | 42 // specifies the cull rect of the display item list (the picture will not |
42 // exceed this rect). If picture caching is not used, then the given rect can | 43 // exceed this rect). If picture caching is not used, then the given rect can |
43 // be empty. | 44 // be empty. |
44 // TODO(vmpstr): Maybe this cull rect can be part of the settings instead. | 45 // TODO(vmpstr): Maybe this cull rect can be part of the settings instead. |
45 static scoped_refptr<DisplayItemList> Create( | 46 static scoped_refptr<DisplayItemList> Create( |
46 const gfx::Rect& layer_rect, | 47 const gfx::Rect& layer_rect, |
47 const DisplayItemListSettings& settings); | 48 const DisplayItemListSettings& settings); |
48 | 49 |
49 // Creates a DisplayItemList from a Protobuf. | 50 // Creates a DisplayItemList from a Protobuf. |
50 // TODO(dtrainor): Pass in a list of possible DisplayItems to reuse | 51 // TODO(dtrainor): Pass in a list of possible DisplayItems to reuse |
51 // (crbug.com/548434). | 52 // (crbug.com/548434). |
52 static scoped_refptr<DisplayItemList> CreateFromProto( | 53 static scoped_refptr<DisplayItemList> CreateFromProto( |
53 const proto::DisplayItemList& proto, | 54 const proto::DisplayItemList& proto, |
54 ImageSerializationProcessor* image_serialization_processor); | 55 ClientPictureCache* client_picture_cache); |
55 | 56 |
56 // Creates a Protobuf representing the state of this DisplayItemList. | 57 // Creates a Protobuf representing the state of this DisplayItemList. |
57 // TODO(dtrainor): Don't resend DisplayItems that were already serialized | 58 // TODO(dtrainor): Don't resend DisplayItems that were already serialized |
58 // (crbug.com/548434). | 59 // (crbug.com/548434). |
59 void ToProtobuf(proto::DisplayItemList* proto, | 60 void ToProtobuf(proto::DisplayItemList* proto); |
60 ImageSerializationProcessor* image_serialization_processor); | 61 |
62 // Informs the EnginePictureCache about which SkPictures that are in use. | |
63 void MarkForRegistrationEngine(EnginePictureCache* engine_picture_cache); | |
vmpstr
2016/06/16 22:09:59
I'm really not a fan of having duplicate set of fu
nyquist
2016/06/24 11:11:14
Done.
| |
64 void MarkForUnregistrationEngine(EnginePictureCache* engine_picture_cache); | |
65 | |
66 // Informs the ClientPictureCache about which SkPictures that are in use. | |
67 void MarkForRegistrationClient(ClientPictureCache* client_picture_cache); | |
68 void MarkForUnregistrationClient(ClientPictureCache* client_picture_cache); | |
61 | 69 |
62 void Raster(SkCanvas* canvas, | 70 void Raster(SkCanvas* canvas, |
63 SkPicture::AbortCallback* callback, | 71 SkPicture::AbortCallback* callback, |
64 const gfx::Rect& canvas_target_playback_rect, | 72 const gfx::Rect& canvas_target_playback_rect, |
65 float contents_scale) const; | 73 float contents_scale) const; |
66 | 74 |
67 // This is a fast path for use only if canvas_ is set and | 75 // This is a fast path for use only if canvas_ is set and |
68 // retain_individual_display_items_ is false. This method also updates | 76 // retain_individual_display_items_ is false. This method also updates |
69 // approximate_op_count_. | 77 // approximate_op_count_. |
70 void RasterIntoCanvas(const DisplayItem& display_item); | 78 void RasterIntoCanvas(const DisplayItem& display_item); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 | 125 |
118 void ProcessAppendedItem(const DisplayItem* item); | 126 void ProcessAppendedItem(const DisplayItem* item); |
119 | 127 |
120 ContiguousContainer<DisplayItem> items_; | 128 ContiguousContainer<DisplayItem> items_; |
121 // The visual rects associated with each of the display items in the | 129 // The visual rects associated with each of the display items in the |
122 // display item list. There is one rect per display item, and the | 130 // display item list. There is one rect per display item, and the |
123 // position in |visual_rects_| matches the position of the item in | 131 // position in |visual_rects_| matches the position of the item in |
124 // |items_| . These rects are intentionally kept separate | 132 // |items_| . These rects are intentionally kept separate |
125 // because they are not needed while walking the |items_| for raster. | 133 // because they are not needed while walking the |items_| for raster. |
126 std::vector<gfx::Rect> visual_rects_; | 134 std::vector<gfx::Rect> visual_rects_; |
135 | |
136 // The engine SkPicture IDs associated with each of the display items in the | |
137 // display item list. There is one ID per display item, and the | |
138 // position in |engine_picture_ids_| matches the position of the item in | |
139 // |items_| . These IDs are intentionally kept separate | |
140 // because they are not needed while walking the |items_| for raster. | |
141 std::vector<uint32_t> engine_picture_ids_; | |
142 | |
127 sk_sp<SkPicture> picture_; | 143 sk_sp<SkPicture> picture_; |
128 | 144 |
129 std::unique_ptr<SkPictureRecorder> recorder_; | 145 std::unique_ptr<SkPictureRecorder> recorder_; |
130 const DisplayItemListSettings settings_; | 146 const DisplayItemListSettings settings_; |
131 bool retain_individual_display_items_; | 147 bool retain_individual_display_items_; |
132 | 148 |
133 gfx::Rect layer_rect_; | 149 gfx::Rect layer_rect_; |
134 bool is_suitable_for_gpu_rasterization_; | 150 bool is_suitable_for_gpu_rasterization_; |
135 int approximate_op_count_; | 151 int approximate_op_count_; |
136 | 152 |
137 // Memory usage due to the cached SkPicture. | 153 // Memory usage due to the cached SkPicture. |
138 size_t picture_memory_usage_; | 154 size_t picture_memory_usage_; |
139 | 155 |
140 DiscardableImageMap image_map_; | 156 DiscardableImageMap image_map_; |
141 | 157 |
158 // |marked_| is true when the last call was for marking SkPictures for | |
159 // registration, and set to false when they are marked for unregistration. | |
160 // It is illegal to call the same method twice in a row. | |
161 bool marked_ = false; | |
162 | |
142 friend class base::RefCountedThreadSafe<DisplayItemList>; | 163 friend class base::RefCountedThreadSafe<DisplayItemList>; |
143 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); | 164 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); |
144 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); | 165 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); |
145 }; | 166 }; |
146 | 167 |
147 } // namespace cc | 168 } // namespace cc |
148 | 169 |
149 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ | 170 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ |
OLD | NEW |