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" |
11 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
12 #include "cc/base/cc_export.h" | 12 #include "cc/base/cc_export.h" |
13 #include "cc/base/list_container.h" | 13 #include "cc/base/list_container.h" |
14 #include "cc/playback/discardable_image_map.h" | 14 #include "cc/playback/discardable_image_map.h" |
15 #include "cc/playback/display_item.h" | 15 #include "cc/playback/display_item.h" |
| 16 #include "cc/playback/display_item_list_settings.h" |
16 #include "skia/ext/refptr.h" | 17 #include "skia/ext/refptr.h" |
17 #include "third_party/skia/include/core/SkPicture.h" | 18 #include "third_party/skia/include/core/SkPicture.h" |
18 #include "ui/gfx/geometry/rect.h" | 19 #include "ui/gfx/geometry/rect.h" |
19 | 20 |
20 class SkCanvas; | 21 class SkCanvas; |
21 class SkPictureRecorder; | 22 class SkPictureRecorder; |
22 | 23 |
23 namespace cc { | 24 namespace cc { |
24 | 25 |
25 class DisplayItemListSettings; | 26 namespace proto { |
| 27 class DisplayItemList; |
| 28 } |
26 | 29 |
27 class CC_EXPORT DisplayItemList | 30 class CC_EXPORT DisplayItemList |
28 : public base::RefCountedThreadSafe<DisplayItemList> { | 31 : public base::RefCountedThreadSafe<DisplayItemList> { |
29 public: | 32 public: |
30 // Creates a display item list. If picture caching is used, then layer_rect | 33 // Creates a display item list. If picture caching is used, then layer_rect |
31 // specifies the cull rect of the display item list (the picture will not | 34 // specifies the cull rect of the display item list (the picture will not |
32 // exceed this rect). If picture caching is not used, then the given rect can | 35 // exceed this rect). If picture caching is not used, then the given rect can |
33 // be empty. | 36 // be empty. |
34 // TODO(vmpstr): Maybe this cull rect can be part of the settings instead. | 37 // TODO(vmpstr): Maybe this cull rect can be part of the settings instead. |
35 static scoped_refptr<DisplayItemList> Create( | 38 static scoped_refptr<DisplayItemList> Create( |
36 const gfx::Rect& layer_rect, | 39 const gfx::Rect& layer_rect, |
37 const DisplayItemListSettings& settings); | 40 const DisplayItemListSettings& settings); |
38 | 41 |
| 42 // Creates a DisplayItemList from a Protobuf. |
| 43 // TODO(dtrainor): Pass in a list of possible DisplayItems to reuse. |
| 44 static scoped_refptr<DisplayItemList> Create( |
| 45 const proto::DisplayItemList& proto); |
| 46 |
| 47 // Creates a Protobuf representing the state of this DisplayItemList. |
| 48 // TODO(dtrainor): Don't resend DisplayItems that were already serialized. |
| 49 void ToProtobuf(proto::DisplayItemList* proto); |
| 50 |
39 void Raster(SkCanvas* canvas, | 51 void Raster(SkCanvas* canvas, |
40 SkPicture::AbortCallback* callback, | 52 SkPicture::AbortCallback* callback, |
41 const gfx::Rect& canvas_target_playback_rect, | 53 const gfx::Rect& canvas_target_playback_rect, |
42 float contents_scale) const; | 54 float contents_scale) const; |
43 | 55 |
44 // This is a fast path for use only if canvas_ is set and | 56 // This is a fast path for use only if canvas_ is set and |
45 // retain_individual_display_items_ is false. This method also updates | 57 // retain_individual_display_items_ is false. This method also updates |
46 // is_suitable_for_gpu_rasterization_ and approximate_op_count_. | 58 // is_suitable_for_gpu_rasterization_ and approximate_op_count_. |
47 void RasterIntoCanvas(const DisplayItem& display_item); | 59 void RasterIntoCanvas(const DisplayItem& display_item); |
48 | 60 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 bool needs_process_; | 107 bool needs_process_; |
96 #else | 108 #else |
97 bool ProcessAppendedItemsCalled() const { return true; } | 109 bool ProcessAppendedItemsCalled() const { return true; } |
98 #endif | 110 #endif |
99 | 111 |
100 ListContainer<DisplayItem> items_; | 112 ListContainer<DisplayItem> items_; |
101 skia::RefPtr<SkPicture> picture_; | 113 skia::RefPtr<SkPicture> picture_; |
102 | 114 |
103 scoped_ptr<SkPictureRecorder> recorder_; | 115 scoped_ptr<SkPictureRecorder> recorder_; |
104 skia::RefPtr<SkCanvas> canvas_; | 116 skia::RefPtr<SkCanvas> canvas_; |
105 const bool use_cached_picture_; | 117 const DisplayItemListSettings settings_; |
106 bool retain_individual_display_items_; | 118 bool retain_individual_display_items_; |
107 | 119 |
108 gfx::Rect layer_rect_; | 120 gfx::Rect layer_rect_; |
109 bool is_suitable_for_gpu_rasterization_; | 121 bool is_suitable_for_gpu_rasterization_; |
110 int approximate_op_count_; | 122 int approximate_op_count_; |
111 | 123 |
112 // Memory usage due to the cached SkPicture. | 124 // Memory usage due to the cached SkPicture. |
113 size_t picture_memory_usage_; | 125 size_t picture_memory_usage_; |
114 | 126 |
115 // Memory usage due to external data held by display items. | 127 // Memory usage due to external data held by display items. |
116 size_t external_memory_usage_; | 128 size_t external_memory_usage_; |
117 | 129 |
118 DiscardableImageMap image_map_; | 130 DiscardableImageMap image_map_; |
119 | 131 |
120 friend class base::RefCountedThreadSafe<DisplayItemList>; | 132 friend class base::RefCountedThreadSafe<DisplayItemList>; |
121 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); | 133 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); |
122 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); | 134 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); |
123 }; | 135 }; |
124 | 136 |
125 } // namespace cc | 137 } // namespace cc |
126 | 138 |
127 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ | 139 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ |
OLD | NEW |