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

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

Issue 1349913002: Cache gpu suitability in DisplayItemList, remove SetUnsuitable...ForTesting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup 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
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 all_items_are_suitable_for_gpu_rasterization_(true), 58 is_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
130 if (use_cached_picture_) { 126 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 // than since none of the items might individually trigger a veto even
130 // though they collectively have enough "bad" operations that a
131 // corresponding Picture would get vetoed. See crbug.com/513016.
131 DCHECK(canvas_); 132 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(), NULL);
135 } else {
136 is_suitable_for_gpu_rasterization_ &=
137 item->is_suitable_for_gpu_rasterization();
138 approximate_op_count_ += item->approximate_op_count();
133 } 139 }
134 140
135 if (retain_individual_display_items_) { 141 if (retain_individual_display_items_) {
136 // Warning: this double-counts SkPicture data if use_cached_picture_ is 142 // Warning: this double-counts SkPicture data if use_cached_picture_ is
137 // also true. 143 // also true.
138 external_memory_usage_ += item->external_memory_usage(); 144 external_memory_usage_ += item->external_memory_usage();
139 } 145 }
140 } 146 }
141 147
142 if (!retain_individual_display_items_) 148 if (!retain_individual_display_items_)
143 items_.clear(); 149 items_.clear();
144 } 150 }
145 151
146 void DisplayItemList::RasterIntoCanvas(const DisplayItem& item) { 152 void DisplayItemList::RasterIntoCanvas(const DisplayItem& item) {
147 DCHECK(canvas_); 153 DCHECK(canvas_);
148 DCHECK(!retain_individual_display_items_); 154 DCHECK(!retain_individual_display_items_);
149 all_items_are_suitable_for_gpu_rasterization_ &= 155 is_suitable_for_gpu_rasterization_ &=
danakj 2015/09/17 21:11:32 why do we do this here too? don't we want to compu
pdr. 2015/09/18 22:40:14 This was a mistake. I had refactored this so Proce
150 item.is_suitable_for_gpu_rasterization(); 156 item.is_suitable_for_gpu_rasterization();
151 approximate_op_count_ += item.approximate_op_count(); 157 approximate_op_count_ += item.approximate_op_count();
152 158
153 item.Raster(canvas_.get(), gfx::Rect(), NULL); 159 item.Raster(canvas_.get(), gfx::Rect(), NULL);
154 } 160 }
155 161
156 bool DisplayItemList::RetainsIndividualDisplayItems() const { 162 bool DisplayItemList::RetainsIndividualDisplayItems() const {
157 return retain_individual_display_items_; 163 return retain_individual_display_items_;
158 } 164 }
159 165
(...skipping 12 matching lines...) Expand all
172 if (use_cached_picture_) { 178 if (use_cached_picture_) {
173 // Convert to an SkPicture for faster rasterization. 179 // Convert to an SkPicture for faster rasterization.
174 DCHECK(use_cached_picture_); 180 DCHECK(use_cached_picture_);
175 DCHECK(!picture_); 181 DCHECK(!picture_);
176 picture_ = skia::AdoptRef(recorder_->endRecordingAsPicture()); 182 picture_ = skia::AdoptRef(recorder_->endRecordingAsPicture());
177 DCHECK(picture_); 183 DCHECK(picture_);
178 picture_memory_usage_ = 184 picture_memory_usage_ =
179 SkPictureUtils::ApproximateBytesUsed(picture_.get()); 185 SkPictureUtils::ApproximateBytesUsed(picture_.get());
180 recorder_.reset(); 186 recorder_.reset();
181 canvas_.clear(); 187 canvas_.clear();
188 is_suitable_for_gpu_rasterization_ =
189 picture_->suitableForGpuRasterization(NULL);
danakj 2015/09/17 21:11:32 nullptr
pdr. 2015/09/18 22:40:14 We should make a pass through and remove all the N
182 } 190 }
183 } 191 }
184 192
185 bool DisplayItemList::IsSuitableForGpuRasterization() const { 193 bool DisplayItemList::IsSuitableForGpuRasterization() const {
186 DCHECK(ProcessAppendedItemsCalled()); 194 DCHECK(ProcessAppendedItemsCalled());
187 if (use_cached_picture_) 195 return is_suitable_for_gpu_rasterization_;
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_;
195 } 196 }
196 197
197 int DisplayItemList::ApproximateOpCount() const { 198 int DisplayItemList::ApproximateOpCount() const {
198 DCHECK(ProcessAppendedItemsCalled()); 199 DCHECK(ProcessAppendedItemsCalled());
199 return approximate_op_count_; 200 return approximate_op_count_;
200 } 201 }
201 202
202 size_t DisplayItemList::ApproximateMemoryUsage() const { 203 size_t DisplayItemList::ApproximateMemoryUsage() const {
203 DCHECK(ProcessAppendedItemsCalled()); 204 DCHECK(ProcessAppendedItemsCalled());
204 // We double-count in this case. Produce zero to avoid being misleading. 205 // We double-count in this case. Produce zero to avoid being misleading.
(...skipping 71 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

Powered by Google App Engine
This is Rietveld 408576698