Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: cc/playback/display_item_list.h

Issue 2217263003: Revert "Raster display item lists via a visual rect RTree." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restore NeedsRebaseline entries. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/playback/discardable_image_map_unittest.cc ('k') | cc/playback/display_item_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/base/rtree.h"
20 #include "cc/playback/discardable_image_map.h" 19 #include "cc/playback/discardable_image_map.h"
21 #include "cc/playback/display_item.h" 20 #include "cc/playback/display_item.h"
22 #include "cc/playback/display_item_list_settings.h" 21 #include "cc/playback/display_item_list_settings.h"
23 #include "third_party/skia/include/core/SkPicture.h" 22 #include "third_party/skia/include/core/SkPicture.h"
24 #include "ui/gfx/geometry/rect.h" 23 #include "ui/gfx/geometry/rect.h"
25 #include "ui/gfx/geometry/rect_conversions.h"
26 24
27 class SkCanvas; 25 class SkCanvas;
28 class SkPictureRecorder; 26 class SkPictureRecorder;
29 27
30 namespace cc { 28 namespace cc {
31 class ClientPictureCache; 29 class ClientPictureCache;
32 class DisplayItem; 30 class DisplayItem;
33 class DrawingDisplayItem; 31 class DrawingDisplayItem;
34 32
35 namespace proto { 33 namespace proto {
36 class DisplayItemList; 34 class DisplayItemList;
37 } 35 }
38 36
39 class CC_EXPORT DisplayItemList 37 class CC_EXPORT DisplayItemList
40 : public base::RefCountedThreadSafe<DisplayItemList> { 38 : public base::RefCountedThreadSafe<DisplayItemList> {
41 public: 39 public:
42 // Creates a display item list. 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
42 // exceed this rect). If picture caching is not used, then the given rect can
43 // be empty.
44 // TODO(vmpstr): Maybe this cull rect can be part of the settings instead.
43 static scoped_refptr<DisplayItemList> Create( 45 static scoped_refptr<DisplayItemList> Create(
46 const gfx::Rect& layer_rect,
44 const DisplayItemListSettings& settings); 47 const DisplayItemListSettings& settings);
45 48
46 // Creates a DisplayItemList from a Protobuf. 49 // Creates a DisplayItemList from a Protobuf.
47 // TODO(dtrainor): Pass in a list of possible DisplayItems to reuse 50 // TODO(dtrainor): Pass in a list of possible DisplayItems to reuse
48 // (crbug.com/548434). 51 // (crbug.com/548434).
49 static scoped_refptr<DisplayItemList> CreateFromProto( 52 static scoped_refptr<DisplayItemList> CreateFromProto(
50 const proto::DisplayItemList& proto, 53 const proto::DisplayItemList& proto,
51 ClientPictureCache* client_picture_cache, 54 ClientPictureCache* client_picture_cache,
52 std::vector<uint32_t>* used_engine_picture_ids); 55 std::vector<uint32_t>* used_engine_picture_ids);
53 56
54 // Creates a Protobuf representing the state of this DisplayItemList. 57 // Creates a Protobuf representing the state of this DisplayItemList.
55 void ToProtobuf(proto::DisplayItemList* proto); 58 void ToProtobuf(proto::DisplayItemList* proto);
56 59
57 // TODO(trchen): Deprecated. Apply clip and scale on the canvas instead. 60 // TODO(trchen): Deprecated. Apply clip and scale on the canvas instead.
58 void Raster(SkCanvas* canvas, 61 void Raster(SkCanvas* canvas,
59 SkPicture::AbortCallback* callback, 62 SkPicture::AbortCallback* callback,
60 const gfx::Rect& canvas_target_playback_rect, 63 const gfx::Rect& canvas_target_playback_rect,
61 float contents_scale) const; 64 float contents_scale) const;
62 65
63 void Raster(SkCanvas* canvas, SkPicture::AbortCallback* callback) const; 66 void Raster(SkCanvas* canvas, SkPicture::AbortCallback* callback) const;
64 67
68 // This is a fast path for use only if canvas_ is set and
69 // retain_individual_display_items_ is false. This method also updates
70 // approximate_op_count_.
71 void RasterIntoCanvas(const DisplayItem& display_item);
72
65 // Because processing happens in this function, all the set up for 73 // Because processing happens in this function, all the set up for
66 // this item should be done via the args, which is why the return 74 // this item should be done via the args, which is why the return
67 // type needs to be const, to prevent set-after-processing mistakes. 75 // type needs to be const, to prevent set-after-processing mistakes.
68 template <typename DisplayItemType, typename... Args> 76 template <typename DisplayItemType, typename... Args>
69 const DisplayItemType& CreateAndAppendItem(const gfx::Rect& visual_rect, 77 const DisplayItemType& CreateAndAppendItem(const gfx::Rect& visual_rect,
70 Args&&... args) { 78 Args&&... args) {
71 inputs_.visual_rects.push_back(visual_rect); 79 inputs_.visual_rects.push_back(visual_rect);
72 auto* item = &inputs_.items.AllocateAndConstruct<DisplayItemType>( 80 auto* item = &inputs_.items.AllocateAndConstruct<DisplayItemType>(
73 std::forward<Args>(args)...); 81 std::forward<Args>(args)...);
74 approximate_op_count_ += item->ApproximateOpCount(); 82 approximate_op_count_ += item->ApproximateOpCount();
83 ProcessAppendedItem(item);
75 return *item; 84 return *item;
76 } 85 }
77 86
78 // Called after all items are appended, to process the items and, if 87 // Called after all items are appended, to process the items and, if
79 // applicable, create an internally cached SkPicture. 88 // applicable, create an internally cached SkPicture.
80 void Finalize(); 89 void Finalize();
81 90
82 void SetIsSuitableForGpuRasterization(bool is_suitable) { 91 void SetIsSuitableForGpuRasterization(bool is_suitable) {
83 inputs_.all_items_are_suitable_for_gpu_rasterization = is_suitable; 92 inputs_.is_suitable_for_gpu_rasterization = is_suitable;
84 } 93 }
85 bool IsSuitableForGpuRasterization() const; 94 bool IsSuitableForGpuRasterization() const;
86 int ApproximateOpCount() const; 95 int ApproximateOpCount() const;
87 size_t ApproximateMemoryUsage() const; 96 size_t ApproximateMemoryUsage() const;
88 bool ShouldBeAnalyzedForSolidColor() const; 97 bool ShouldBeAnalyzedForSolidColor() const;
89 98
99 bool RetainsIndividualDisplayItems() const;
100
90 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> AsValue( 101 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> AsValue(
91 bool include_items) const; 102 bool include_items) const;
92 103
93 void EmitTraceSnapshot() const; 104 void EmitTraceSnapshot() const;
94 105
95 void GenerateDiscardableImagesMetadata(); 106 void GenerateDiscardableImagesMetadata();
96 void GetDiscardableImagesInRect(const gfx::Rect& rect, 107 void GetDiscardableImagesInRect(const gfx::Rect& rect,
97 float raster_scale, 108 float raster_scale,
98 std::vector<DrawImage>* images); 109 std::vector<DrawImage>* images);
99 110
100 void SetRetainVisualRectsForTesting(bool retain) {
101 retain_visual_rects_ = retain;
102 }
103
104 gfx::Rect VisualRectForTesting(int index) { 111 gfx::Rect VisualRectForTesting(int index) {
105 return inputs_.visual_rects[index]; 112 return inputs_.visual_rects[index];
106 } 113 }
107 114
108 ContiguousContainer<DisplayItem>::const_iterator begin() const { 115 ContiguousContainer<DisplayItem>::const_iterator begin() const {
109 return inputs_.items.begin(); 116 return inputs_.items.begin();
110 } 117 }
111 118
112 ContiguousContainer<DisplayItem>::const_iterator end() const { 119 ContiguousContainer<DisplayItem>::const_iterator end() const {
113 return inputs_.items.end(); 120 return inputs_.items.end();
114 } 121 }
115 122
116 private: 123 private:
117 explicit DisplayItemList( 124 DisplayItemList(gfx::Rect layer_rect,
118 const DisplayItemListSettings& display_list_settings); 125 const DisplayItemListSettings& display_list_settings,
126 bool retain_individual_display_items);
119 ~DisplayItemList(); 127 ~DisplayItemList();
120 128
121 RTree rtree_; 129 void ProcessAppendedItem(const DisplayItem* item);
122 // For testing purposes only. Whether to keep visual rects across calls to
123 // Finalize().
124 bool retain_visual_rects_ = false;
125 130
126 int approximate_op_count_ = 0; 131 sk_sp<SkPicture> picture_;
132
133 std::unique_ptr<SkPictureRecorder> recorder_;
134
135 bool retain_individual_display_items_;
136 int approximate_op_count_;
137
138 // Memory usage due to the cached SkPicture.
139 size_t picture_memory_usage_;
127 140
128 DiscardableImageMap image_map_; 141 DiscardableImageMap image_map_;
129 142
130 struct Inputs { 143 struct Inputs {
131 explicit Inputs(const DisplayItemListSettings& settings); 144 Inputs(gfx::Rect layer_rect, const DisplayItemListSettings& settings);
132 ~Inputs(); 145 ~Inputs();
133 146
134 ContiguousContainer<DisplayItem> items; 147 ContiguousContainer<DisplayItem> items;
135 // The visual rects associated with each of the display items in the 148 // The visual rects associated with each of the display items in the
136 // display item list. There is one rect per display item, and the 149 // display item list. There is one rect per display item, and the
137 // position in |visual_rects| matches the position of the item in 150 // position in |visual_rects| matches the position of the item in
138 // |items| . These rects are intentionally kept separate 151 // |items| . These rects are intentionally kept separate
139 // because they are not needed while walking the |items| for raster. 152 // because they are not needed while walking the |items| for raster.
140 std::vector<gfx::Rect> visual_rects; 153 std::vector<gfx::Rect> visual_rects;
141 154
142 const DisplayItemListSettings settings; 155 const DisplayItemListSettings settings;
143 bool all_items_are_suitable_for_gpu_rasterization = true; 156 gfx::Rect layer_rect;
157 bool is_suitable_for_gpu_rasterization;
144 }; 158 };
145 159
146 Inputs inputs_; 160 Inputs inputs_;
147 161
148 friend class base::RefCountedThreadSafe<DisplayItemList>; 162 friend class base::RefCountedThreadSafe<DisplayItemList>;
149 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); 163 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage);
150 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); 164 DISALLOW_COPY_AND_ASSIGN(DisplayItemList);
151 }; 165 };
152 166
153 } // namespace cc 167 } // namespace cc
154 168
155 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ 169 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_
OLDNEW
« no previous file with comments | « cc/playback/discardable_image_map_unittest.cc ('k') | cc/playback/display_item_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698