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

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

Issue 2722163003: Restore swap to clear display item list visual rects. (Closed)
Patch Set: Created 3 years, 9 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 | « no previous file | no next file » | 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 inputs_.visual_rects[inputs_.begin_item_indices.back()].Union(visual_rect); 111 inputs_.visual_rects[inputs_.begin_item_indices.back()].Union(visual_rect);
112 } 112 }
113 113
114 void DisplayItemList::Finalize() { 114 void DisplayItemList::Finalize() {
115 TRACE_EVENT0("cc", "DisplayItemList::Finalize"); 115 TRACE_EVENT0("cc", "DisplayItemList::Finalize");
116 DCHECK(inputs_.items.size() == inputs_.visual_rects.size()) 116 DCHECK(inputs_.items.size() == inputs_.visual_rects.size())
117 << "items.size() " << inputs_.items.size() << " visual_rects.size() " 117 << "items.size() " << inputs_.items.size() << " visual_rects.size() "
118 << inputs_.visual_rects.size(); 118 << inputs_.visual_rects.size();
119 rtree_.Build(inputs_.visual_rects); 119 rtree_.Build(inputs_.visual_rects);
120 120
121 // TODO(wkorman): Restore the below, potentially with a switch to allow 121 if (!retain_visual_rects_)
122 // clearing visual rects except for Blimp engine. http://crbug.com/633750 122 // This clears both the vector and the vector's capacity, since
123 // if (!retain_visual_rects_) 123 // visual_rects won't be used anymore.
124 // // This clears both the vector and the vector's capacity, since 124 std::vector<gfx::Rect>().swap(inputs_.visual_rects);
125 // // visual_rects won't be used anymore.
126 // std::vector<gfx::Rect>().swap(inputs_.visual_rects);
127 } 125 }
128 126
129 bool DisplayItemList::IsSuitableForGpuRasterization() const { 127 bool DisplayItemList::IsSuitableForGpuRasterization() const {
130 // TODO(wkorman): This is more permissive than Picture's implementation, since 128 // TODO(wkorman): This is more permissive than Picture's implementation, since
131 // none of the items might individually trigger a veto even though they 129 // none of the items might individually trigger a veto even though they
132 // collectively have enough "bad" operations that a corresponding Picture 130 // collectively have enough "bad" operations that a corresponding Picture
133 // would get vetoed. See crbug.com/513016. 131 // would get vetoed. See crbug.com/513016.
134 return inputs_.all_items_are_suitable_for_gpu_rasterization; 132 return inputs_.all_items_are_suitable_for_gpu_rasterization;
135 } 133 }
136 134
137 int DisplayItemList::ApproximateOpCount() const { 135 int DisplayItemList::ApproximateOpCount() const {
138 return approximate_op_count_; 136 return approximate_op_count_;
139 } 137 }
140 138
141 size_t DisplayItemList::ApproximateMemoryUsage() const { 139 size_t DisplayItemList::ApproximateMemoryUsage() const {
142 size_t memory_usage = sizeof(*this); 140 size_t memory_usage = sizeof(*this);
143 141
144 size_t external_memory_usage = 0; 142 size_t external_memory_usage = 0;
145 // Warning: this double-counts SkPicture data if use_cached_picture is
146 // also true.
147 for (const auto& item : inputs_.items) { 143 for (const auto& item : inputs_.items) {
148 size_t bytes = 0; 144 size_t bytes = 0;
149 switch (item.type()) { 145 switch (item.type()) {
150 case DisplayItem::CLIP: 146 case DisplayItem::CLIP:
151 bytes = static_cast<const ClipDisplayItem&>(item).ExternalMemoryUsage(); 147 bytes = static_cast<const ClipDisplayItem&>(item).ExternalMemoryUsage();
152 break; 148 break;
153 case DisplayItem::CLIP_PATH: 149 case DisplayItem::CLIP_PATH:
154 bytes = 150 bytes =
155 static_cast<const ClipPathDisplayItem&>(item).ExternalMemoryUsage(); 151 static_cast<const ClipPathDisplayItem&>(item).ExternalMemoryUsage();
156 break; 152 break;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( 235 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
240 TRACE_DISABLED_BY_DEFAULT("cc.debug.display_items") "," 236 TRACE_DISABLED_BY_DEFAULT("cc.debug.display_items") ","
241 TRACE_DISABLED_BY_DEFAULT("cc.debug.picture") "," 237 TRACE_DISABLED_BY_DEFAULT("cc.debug.picture") ","
242 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.picture"), 238 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.picture"),
243 "cc::DisplayItemList", this, 239 "cc::DisplayItemList", this,
244 TracedDisplayItemList::AsTraceableDisplayItemList(this, 240 TracedDisplayItemList::AsTraceableDisplayItemList(this,
245 DisplayItemsTracingEnabled())); 241 DisplayItemsTracingEnabled()));
246 } 242 }
247 243
248 void DisplayItemList::GenerateDiscardableImagesMetadata() { 244 void DisplayItemList::GenerateDiscardableImagesMetadata() {
249 // This should be only called once, and only after CreateAndCacheSkPicture. 245 // This should be only called once.
250 DCHECK(image_map_.empty()); 246 DCHECK(image_map_.empty());
251 247
252 gfx::Rect bounds = rtree_.GetBounds(); 248 gfx::Rect bounds = rtree_.GetBounds();
253 DiscardableImageMap::ScopedMetadataGenerator generator( 249 DiscardableImageMap::ScopedMetadataGenerator generator(
254 &image_map_, gfx::Size(bounds.right(), bounds.bottom())); 250 &image_map_, gfx::Size(bounds.right(), bounds.bottom()));
255 Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f); 251 Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f);
256 } 252 }
257 253
258 void DisplayItemList::GetDiscardableImagesInRect( 254 void DisplayItemList::GetDiscardableImagesInRect(
259 const gfx::Rect& rect, 255 const gfx::Rect& rect,
260 float contents_scale, 256 float contents_scale,
261 std::vector<DrawImage>* images) { 257 std::vector<DrawImage>* images) {
262 image_map_.GetDiscardableImagesInRect(rect, contents_scale, images); 258 image_map_.GetDiscardableImagesInRect(rect, contents_scale, images);
263 } 259 }
264 260
265 gfx::Rect DisplayItemList::GetRectForImage(ImageId image_id) const { 261 gfx::Rect DisplayItemList::GetRectForImage(ImageId image_id) const {
266 return image_map_.GetRectForImage(image_id); 262 return image_map_.GetRectForImage(image_id);
267 } 263 }
268 264
269 } // namespace cc 265 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698