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

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

Issue 1361663003: Revert of Cache gpu suitability in DisplayItemList, remove SetUnsuitable...ForTesting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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/display_item_list.h ('k') | cc/playback/display_list_recording_source.h » ('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 #include "cc/playback/display_item_list.h" 5 #include "cc/playback/display_item_list.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/numerics/safe_conversions.h" 9 #include "base/numerics/safe_conversions.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 !settings.use_cached_picture || DisplayItemsTracingEnabled())); 48 !settings.use_cached_picture || DisplayItemsTracingEnabled()));
49 } 49 }
50 50
51 DisplayItemList::DisplayItemList(gfx::Rect layer_rect, 51 DisplayItemList::DisplayItemList(gfx::Rect layer_rect,
52 const DisplayItemListSettings& settings, 52 const DisplayItemListSettings& settings,
53 bool retain_individual_display_items) 53 bool retain_individual_display_items)
54 : items_(LargestDisplayItemSize(), kDefaultNumDisplayItemsToReserve), 54 : items_(LargestDisplayItemSize(), kDefaultNumDisplayItemsToReserve),
55 use_cached_picture_(settings.use_cached_picture), 55 use_cached_picture_(settings.use_cached_picture),
56 retain_individual_display_items_(retain_individual_display_items), 56 retain_individual_display_items_(retain_individual_display_items),
57 layer_rect_(layer_rect), 57 layer_rect_(layer_rect),
58 is_suitable_for_gpu_rasterization_(true), 58 all_items_are_suitable_for_gpu_rasterization_(true),
59 approximate_op_count_(0), 59 approximate_op_count_(0),
60 picture_memory_usage_(0), 60 picture_memory_usage_(0),
61 external_memory_usage_(0) { 61 external_memory_usage_(0) {
62 #if DCHECK_IS_ON() 62 #if DCHECK_IS_ON()
63 needs_process_ = false; 63 needs_process_ = false;
64 #endif 64 #endif
65 if (use_cached_picture_) { 65 if (use_cached_picture_) {
66 SkRTreeFactory factory; 66 SkRTreeFactory factory;
67 recorder_.reset(new SkPictureRecorder()); 67 recorder_.reset(new SkPictureRecorder());
68 canvas_ = skia::SharePtr(recorder_->beginRecording( 68 canvas_ = skia::SharePtr(recorder_->beginRecording(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // after |items_| grows too large and we process it. 116 // after |items_| grows too large and we process it.
117 DCHECK(items_.empty()); 117 DCHECK(items_.empty());
118 } 118 }
119 } 119 }
120 120
121 void DisplayItemList::ProcessAppendedItems() { 121 void DisplayItemList::ProcessAppendedItems() {
122 #if DCHECK_IS_ON() 122 #if DCHECK_IS_ON()
123 needs_process_ = false; 123 needs_process_ = false;
124 #endif 124 #endif
125 for (const DisplayItem* item : items_) { 125 for (const DisplayItem* item : items_) {
126 all_items_are_suitable_for_gpu_rasterization_ &=
127 item->is_suitable_for_gpu_rasterization();
128 approximate_op_count_ += item->approximate_op_count();
129
126 if (use_cached_picture_) { 130 if (use_cached_picture_) {
127 // When using a cached picture we will calculate gpu suitability on the
128 // entire cached picture instead of the items. This is more permissive
129 // since none of the items might individually trigger a veto even though
130 // they collectively have enough "bad" operations that a corresponding
131 // Picture would get vetoed. See crbug.com/513016.
132 DCHECK(canvas_); 131 DCHECK(canvas_);
133 approximate_op_count_ += item->approximate_op_count(); 132 item->Raster(canvas_.get(), gfx::Rect(), NULL);
134 item->Raster(canvas_.get(), gfx::Rect(), nullptr);
135 } else {
136 is_suitable_for_gpu_rasterization_ &=
137 item->is_suitable_for_gpu_rasterization();
138 approximate_op_count_ += item->approximate_op_count();
139 } 133 }
140 134
141 if (retain_individual_display_items_) { 135 if (retain_individual_display_items_) {
142 // Warning: this double-counts SkPicture data if use_cached_picture_ is 136 // Warning: this double-counts SkPicture data if use_cached_picture_ is
143 // also true. 137 // also true.
144 external_memory_usage_ += item->external_memory_usage(); 138 external_memory_usage_ += item->external_memory_usage();
145 } 139 }
146 } 140 }
147 141
148 if (!retain_individual_display_items_) 142 if (!retain_individual_display_items_)
149 items_.clear(); 143 items_.clear();
150 } 144 }
151 145
152 void DisplayItemList::RasterIntoCanvas(const DisplayItem& item) { 146 void DisplayItemList::RasterIntoCanvas(const DisplayItem& item) {
153 DCHECK(canvas_); 147 DCHECK(canvas_);
154 DCHECK(!retain_individual_display_items_); 148 DCHECK(!retain_individual_display_items_);
149 all_items_are_suitable_for_gpu_rasterization_ &=
150 item.is_suitable_for_gpu_rasterization();
155 approximate_op_count_ += item.approximate_op_count(); 151 approximate_op_count_ += item.approximate_op_count();
156 152
157 item.Raster(canvas_.get(), gfx::Rect(), nullptr); 153 item.Raster(canvas_.get(), gfx::Rect(), NULL);
158 } 154 }
159 155
160 bool DisplayItemList::RetainsIndividualDisplayItems() const { 156 bool DisplayItemList::RetainsIndividualDisplayItems() const {
161 return retain_individual_display_items_; 157 return retain_individual_display_items_;
162 } 158 }
163 159
164 void DisplayItemList::RemoveLast() { 160 void DisplayItemList::RemoveLast() {
165 // We cannot remove the last item if it has been squashed into a picture. 161 // We cannot remove the last item if it has been squashed into a picture.
166 // The last item should not have been handled by ProcessAppendedItems, so we 162 // The last item should not have been handled by ProcessAppendedItems, so we
167 // don't need to remove it from approximate_op_count_, etc. 163 // don't need to remove it from approximate_op_count_, etc.
168 DCHECK(retain_individual_display_items_); 164 DCHECK(retain_individual_display_items_);
169 DCHECK(!use_cached_picture_); 165 DCHECK(!use_cached_picture_);
170 items_.RemoveLast(); 166 items_.RemoveLast();
171 } 167 }
172 168
173 void DisplayItemList::Finalize() { 169 void DisplayItemList::Finalize() {
174 ProcessAppendedItems(); 170 ProcessAppendedItems();
175 171
176 if (use_cached_picture_) { 172 if (use_cached_picture_) {
177 // Convert to an SkPicture for faster rasterization. 173 // Convert to an SkPicture for faster rasterization.
178 DCHECK(use_cached_picture_); 174 DCHECK(use_cached_picture_);
179 DCHECK(!picture_); 175 DCHECK(!picture_);
180 picture_ = skia::AdoptRef(recorder_->endRecordingAsPicture()); 176 picture_ = skia::AdoptRef(recorder_->endRecordingAsPicture());
181 DCHECK(picture_); 177 DCHECK(picture_);
182 picture_memory_usage_ = 178 picture_memory_usage_ =
183 SkPictureUtils::ApproximateBytesUsed(picture_.get()); 179 SkPictureUtils::ApproximateBytesUsed(picture_.get());
184 recorder_.reset(); 180 recorder_.reset();
185 canvas_.clear(); 181 canvas_.clear();
186 is_suitable_for_gpu_rasterization_ =
187 picture_->suitableForGpuRasterization(nullptr);
188 } 182 }
189 } 183 }
190 184
191 bool DisplayItemList::IsSuitableForGpuRasterization() const { 185 bool DisplayItemList::IsSuitableForGpuRasterization() const {
192 DCHECK(ProcessAppendedItemsCalled()); 186 DCHECK(ProcessAppendedItemsCalled());
193 return is_suitable_for_gpu_rasterization_; 187 if (use_cached_picture_)
188 return picture_->suitableForGpuRasterization(NULL);
189
190 // This is more permissive than Picture's implementation, since none of the
191 // items might individually trigger a veto even though they collectively have
192 // enough "bad" operations that a corresponding Picture would get vetoed. See
193 // crbug.com/513016.
194 return all_items_are_suitable_for_gpu_rasterization_;
194 } 195 }
195 196
196 int DisplayItemList::ApproximateOpCount() const { 197 int DisplayItemList::ApproximateOpCount() const {
197 DCHECK(ProcessAppendedItemsCalled()); 198 DCHECK(ProcessAppendedItemsCalled());
198 return approximate_op_count_; 199 return approximate_op_count_;
199 } 200 }
200 201
201 size_t DisplayItemList::ApproximateMemoryUsage() const { 202 size_t DisplayItemList::ApproximateMemoryUsage() const {
202 DCHECK(ProcessAppendedItemsCalled()); 203 DCHECK(ProcessAppendedItemsCalled());
203 // We double-count in this case. Produce zero to avoid being misleading. 204 // We double-count in this case. Produce zero to avoid being misleading.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 DCHECK(picture_); 277 DCHECK(picture_);
277 DCHECK(!images_); 278 DCHECK(!images_);
278 images_ = make_scoped_ptr(new DiscardableImageMap(grid_cell_size)); 279 images_ = make_scoped_ptr(new DiscardableImageMap(grid_cell_size));
279 if (!picture_->willPlayBackBitmaps()) 280 if (!picture_->willPlayBackBitmaps())
280 return; 281 return;
281 282
282 images_->GatherImagesFromPicture(picture_.get(), layer_rect_); 283 images_->GatherImagesFromPicture(picture_.get(), layer_rect_);
283 } 284 }
284 285
285 } // namespace cc 286 } // namespace cc
OLDNEW
« no previous file with comments | « cc/playback/display_item_list.h ('k') | cc/playback/display_list_recording_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698