| 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 | 32 |
| 33 namespace proto { | 33 namespace proto { |
| 34 class DisplayItemList; | 34 class DisplayItemList; |
| 35 } | 35 } |
| 36 | 36 |
| 37 class CC_EXPORT DisplayItemList | 37 class CC_EXPORT DisplayItemList |
| 38 : public base::RefCountedThreadSafe<DisplayItemList> { | 38 : public base::RefCountedThreadSafe<DisplayItemList> { |
| 39 public: | 39 public: |
| 40 // Creates a display item list. If picture caching is used, then layer_rect | 40 // 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 | 41 // 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 | 42 // exceed this rect). If picture caching is not used, then the given rect can |
| 43 // be empty. | 43 // be empty. |
| 44 // TODO(vmpstr): Maybe this cull rect can be part of the settings instead. | 44 // TODO(vmpstr): Maybe this cull rect can be part of the settings instead. |
| 45 static scoped_refptr<DisplayItemList> Create( | 45 static scoped_refptr<DisplayItemList> Create( |
| 46 const gfx::Rect& layer_rect, | 46 const gfx::Rect& layer_rect, |
| 47 const DisplayItemListSettings& settings); | 47 const DisplayItemListSettings& settings); |
| 48 | 48 |
| 49 // Creates a DisplayItemList from a Protobuf. | 49 // Creates a DisplayItemList from a Protobuf. |
| 50 // TODO(dtrainor): Pass in a list of possible DisplayItems to reuse | 50 // TODO(dtrainor): Pass in a list of possible DisplayItems to reuse |
| 51 // (crbug.com/548434). | 51 // (crbug.com/548434). |
| 52 static scoped_refptr<DisplayItemList> CreateFromProto( | 52 static scoped_refptr<DisplayItemList> CreateFromProto( |
| 53 const proto::DisplayItemList& proto, | 53 const proto::DisplayItemList& proto, |
| 54 ImageSerializationProcessor* image_serialization_processor); | 54 ClientPictureCache* client_picture_cache, |
| 55 std::vector<uint32_t>* used_engine_picture_ids); |
| 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 void ToProtobuf(proto::DisplayItemList* proto); |
| 58 // (crbug.com/548434). | |
| 59 void ToProtobuf(proto::DisplayItemList* proto, | |
| 60 ImageSerializationProcessor* image_serialization_processor); | |
| 61 | 59 |
| 62 // TODO(trchen): Deprecated. Apply clip and scale on the canvas instead. | 60 // TODO(trchen): Deprecated. Apply clip and scale on the canvas instead. |
| 63 void Raster(SkCanvas* canvas, | 61 void Raster(SkCanvas* canvas, |
| 64 SkPicture::AbortCallback* callback, | 62 SkPicture::AbortCallback* callback, |
| 65 const gfx::Rect& canvas_target_playback_rect, | 63 const gfx::Rect& canvas_target_playback_rect, |
| 66 float contents_scale) const; | 64 float contents_scale) const; |
| 67 | 65 |
| 68 void Raster(SkCanvas* canvas, SkPicture::AbortCallback* callback) const; | 66 void Raster(SkCanvas* canvas, SkPicture::AbortCallback* callback) const; |
| 69 | 67 |
| 70 // This is a fast path for use only if canvas_ is set and | 68 // This is a fast path for use only if canvas_ is set and |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 103 |
| 106 void EmitTraceSnapshot() const; | 104 void EmitTraceSnapshot() const; |
| 107 | 105 |
| 108 void GenerateDiscardableImagesMetadata(); | 106 void GenerateDiscardableImagesMetadata(); |
| 109 void GetDiscardableImagesInRect(const gfx::Rect& rect, | 107 void GetDiscardableImagesInRect(const gfx::Rect& rect, |
| 110 float raster_scale, | 108 float raster_scale, |
| 111 std::vector<DrawImage>* images); | 109 std::vector<DrawImage>* images); |
| 112 | 110 |
| 113 gfx::Rect VisualRectForTesting(int index) { return visual_rects_[index]; } | 111 gfx::Rect VisualRectForTesting(int index) { return visual_rects_[index]; } |
| 114 | 112 |
| 113 ContiguousContainer<DisplayItem>::const_iterator begin() const { |
| 114 return items_.begin(); |
| 115 } |
| 116 |
| 117 ContiguousContainer<DisplayItem>::const_iterator end() const { |
| 118 return items_.end(); |
| 119 } |
| 120 |
| 115 private: | 121 private: |
| 116 DisplayItemList(gfx::Rect layer_rect, | 122 DisplayItemList(gfx::Rect layer_rect, |
| 117 const DisplayItemListSettings& display_list_settings, | 123 const DisplayItemListSettings& display_list_settings, |
| 118 bool retain_individual_display_items); | 124 bool retain_individual_display_items); |
| 119 ~DisplayItemList(); | 125 ~DisplayItemList(); |
| 120 | 126 |
| 121 void ProcessAppendedItem(const DisplayItem* item); | 127 void ProcessAppendedItem(const DisplayItem* item); |
| 122 | 128 |
| 123 ContiguousContainer<DisplayItem> items_; | 129 ContiguousContainer<DisplayItem> items_; |
| 124 // 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 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 143 DiscardableImageMap image_map_; | 149 DiscardableImageMap image_map_; |
| 144 | 150 |
| 145 friend class base::RefCountedThreadSafe<DisplayItemList>; | 151 friend class base::RefCountedThreadSafe<DisplayItemList>; |
| 146 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); | 152 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); |
| 147 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); | 153 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); |
| 148 }; | 154 }; |
| 149 | 155 |
| 150 } // namespace cc | 156 } // namespace cc |
| 151 | 157 |
| 152 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ | 158 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ |
| OLD | NEW |