| 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); |
| 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 // is_suitable_for_gpu_rasterization_ and approximate_op_count_. | 77 // is_suitable_for_gpu_rasterization_ and approximate_op_count_. |
| 70 void RasterIntoCanvas(const DisplayItem& display_item); | 78 void RasterIntoCanvas(const DisplayItem& display_item); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 126 |
| 119 void ProcessAppendedItem(const DisplayItem* item); | 127 void ProcessAppendedItem(const DisplayItem* item); |
| 120 | 128 |
| 121 ContiguousContainer<DisplayItem> items_; | 129 ContiguousContainer<DisplayItem> items_; |
| 122 // The visual rects associated with each of the display items in the | 130 // The visual rects associated with each of the display items in the |
| 123 // display item list. There is one rect per display item, and the | 131 // display item list. There is one rect per display item, and the |
| 124 // position in |visual_rects_| matches the position of the item in | 132 // position in |visual_rects_| matches the position of the item in |
| 125 // |items_| . These rects are intentionally kept separate | 133 // |items_| . These rects are intentionally kept separate |
| 126 // because they are not needed while walking the |items_| for raster. | 134 // because they are not needed while walking the |items_| for raster. |
| 127 std::vector<gfx::Rect> visual_rects_; | 135 std::vector<gfx::Rect> visual_rects_; |
| 136 |
| 137 // The engine SkPicture IDs associated with each of the display items in the |
| 138 // display item list. There is one ID per display item, and the |
| 139 // position in |engine_picture_ids_| matches the position of the item in |
| 140 // |items_| . These IDs are intentionally kept separate |
| 141 // because they are not needed while walking the |items_| for raster. |
| 142 std::vector<uint32_t> engine_picture_ids_; |
| 143 |
| 128 sk_sp<SkPicture> picture_; | 144 sk_sp<SkPicture> picture_; |
| 129 | 145 |
| 130 std::unique_ptr<SkPictureRecorder> recorder_; | 146 std::unique_ptr<SkPictureRecorder> recorder_; |
| 131 const DisplayItemListSettings settings_; | 147 const DisplayItemListSettings settings_; |
| 132 bool retain_individual_display_items_; | 148 bool retain_individual_display_items_; |
| 133 | 149 |
| 134 gfx::Rect layer_rect_; | 150 gfx::Rect layer_rect_; |
| 135 bool is_suitable_for_gpu_rasterization_; | 151 bool is_suitable_for_gpu_rasterization_; |
| 136 int approximate_op_count_; | 152 int approximate_op_count_; |
| 137 | 153 |
| 138 // Memory usage due to the cached SkPicture. | 154 // Memory usage due to the cached SkPicture. |
| 139 size_t picture_memory_usage_; | 155 size_t picture_memory_usage_; |
| 140 | 156 |
| 141 DiscardableImageMap image_map_; | 157 DiscardableImageMap image_map_; |
| 142 | 158 |
| 159 // |marked_| is true when the last call was for marking SkPictures for |
| 160 // registration, and set to false when they are marked for unregistration. |
| 161 // It is illegal to call the same method twice in a row. |
| 162 bool marked_ = false; |
| 163 |
| 143 friend class base::RefCountedThreadSafe<DisplayItemList>; | 164 friend class base::RefCountedThreadSafe<DisplayItemList>; |
| 144 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); | 165 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); |
| 145 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); | 166 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); |
| 146 }; | 167 }; |
| 147 | 168 |
| 148 } // namespace cc | 169 } // namespace cc |
| 149 | 170 |
| 150 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ | 171 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ |
| OLD | NEW |