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

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

Issue 2225563002: Reland "Raster display item lists via a visual rect RTree." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync to head. 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/display_item_list.h ('k') | cc/playback/display_item_list_unittest.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 #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
11 #include "base/numerics/safe_conversions.h" 11 #include "base/numerics/safe_conversions.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/trace_event/trace_event.h" 13 #include "base/trace_event/trace_event.h"
14 #include "base/trace_event/trace_event_argument.h" 14 #include "base/trace_event/trace_event_argument.h"
15 #include "cc/base/math_util.h" 15 #include "cc/base/math_util.h"
16 #include "cc/debug/picture_debug_util.h" 16 #include "cc/debug/picture_debug_util.h"
17 #include "cc/debug/traced_display_item_list.h" 17 #include "cc/debug/traced_display_item_list.h"
18 #include "cc/debug/traced_value.h" 18 #include "cc/debug/traced_value.h"
19 #include "cc/playback/display_item_list_settings.h" 19 #include "cc/playback/display_item_list_settings.h"
20 #include "cc/playback/display_item_proto_factory.h" 20 #include "cc/playback/display_item_proto_factory.h"
21 #include "cc/playback/drawing_display_item.h" 21 #include "cc/playback/drawing_display_item.h"
22 #include "cc/playback/largest_display_item.h" 22 #include "cc/playback/largest_display_item.h"
23 #include "cc/proto/display_item.pb.h" 23 #include "cc/proto/display_item.pb.h"
24 #include "cc/proto/gfx_conversions.h" 24 #include "cc/proto/gfx_conversions.h"
25 #include "third_party/skia/include/core/SkCanvas.h" 25 #include "third_party/skia/include/core/SkCanvas.h"
26 #include "third_party/skia/include/core/SkPictureRecorder.h" 26 #include "third_party/skia/include/core/SkPictureRecorder.h"
27 #include "third_party/skia/include/utils/SkPictureUtils.h" 27 #include "third_party/skia/include/utils/SkPictureUtils.h"
28 #include "ui/gfx/geometry/rect.h" 28 #include "ui/gfx/geometry/rect.h"
29 #include "ui/gfx/geometry/rect_conversions.h"
29 #include "ui/gfx/skia_util.h" 30 #include "ui/gfx/skia_util.h"
30 31
31 namespace cc { 32 namespace cc {
32 33
33 namespace { 34 namespace {
34 35
35 // We don't perform per-layer solid color analysis when there are too many skia 36 // We don't perform per-layer solid color analysis when there are too many skia
36 // operations. 37 // operations.
37 const int kOpCountThatIsOkToAnalyze = 10; 38 const int kOpCountThatIsOkToAnalyze = 10;
38 39
39 bool DisplayItemsTracingEnabled() { 40 bool DisplayItemsTracingEnabled() {
40 bool tracing_enabled; 41 bool tracing_enabled;
41 TRACE_EVENT_CATEGORY_GROUP_ENABLED( 42 TRACE_EVENT_CATEGORY_GROUP_ENABLED(
42 TRACE_DISABLED_BY_DEFAULT("cc.debug.display_items"), &tracing_enabled); 43 TRACE_DISABLED_BY_DEFAULT("cc.debug.display_items"), &tracing_enabled);
43 return tracing_enabled; 44 return tracing_enabled;
44 } 45 }
45 46
47 bool GetCanvasClipBounds(SkCanvas* canvas, gfx::Rect* clip_bounds) {
48 SkRect canvas_clip_bounds;
49 if (!canvas->getClipBounds(&canvas_clip_bounds))
50 return false;
51 *clip_bounds = ToEnclosingRect(gfx::SkRectToRectF(canvas_clip_bounds));
52 return true;
53 }
54
46 const int kDefaultNumDisplayItemsToReserve = 100; 55 const int kDefaultNumDisplayItemsToReserve = 100;
47 56
48 } // namespace 57 } // namespace
49 58
50 DisplayItemList::Inputs::Inputs(gfx::Rect layer_rect, 59 DisplayItemList::Inputs::Inputs(const DisplayItemListSettings& settings)
51 const DisplayItemListSettings& settings)
52 : items(LargestDisplayItemSize(), 60 : items(LargestDisplayItemSize(),
53 LargestDisplayItemSize() * kDefaultNumDisplayItemsToReserve), 61 LargestDisplayItemSize() * kDefaultNumDisplayItemsToReserve),
54 settings(settings), 62 settings(settings) {}
55 layer_rect(layer_rect),
56 is_suitable_for_gpu_rasterization(true) {}
57 63
58 DisplayItemList::Inputs::~Inputs() {} 64 DisplayItemList::Inputs::~Inputs() {}
59 65
60 scoped_refptr<DisplayItemList> DisplayItemList::Create( 66 scoped_refptr<DisplayItemList> DisplayItemList::Create(
61 const gfx::Rect& layer_rect,
62 const DisplayItemListSettings& settings) { 67 const DisplayItemListSettings& settings) {
63 return make_scoped_refptr(new DisplayItemList( 68 return make_scoped_refptr(new DisplayItemList(settings));
64 layer_rect, settings,
65 !settings.use_cached_picture || DisplayItemsTracingEnabled()));
66 } 69 }
67 70
68 scoped_refptr<DisplayItemList> DisplayItemList::CreateFromProto( 71 scoped_refptr<DisplayItemList> DisplayItemList::CreateFromProto(
69 const proto::DisplayItemList& proto, 72 const proto::DisplayItemList& proto,
70 ClientPictureCache* client_picture_cache, 73 ClientPictureCache* client_picture_cache,
71 std::vector<uint32_t>* used_engine_picture_ids) { 74 std::vector<uint32_t>* used_engine_picture_ids) {
72 gfx::Rect layer_rect = ProtoToRect(proto.layer_rect());
73 scoped_refptr<DisplayItemList> list = 75 scoped_refptr<DisplayItemList> list =
74 DisplayItemList::Create(ProtoToRect(proto.layer_rect()), 76 DisplayItemList::Create(DisplayItemListSettings(proto.settings()));
75 DisplayItemListSettings(proto.settings()));
76 77
77 for (int i = 0; i < proto.items_size(); i++) { 78 for (int i = 0; i < proto.items_size(); i++) {
78 const proto::DisplayItem& item_proto = proto.items(i); 79 const proto::DisplayItem& item_proto = proto.items(i);
80 const gfx::Rect visual_rect = ProtoToRect(proto.visual_rects(i));
79 DisplayItemProtoFactory::AllocateAndConstruct( 81 DisplayItemProtoFactory::AllocateAndConstruct(
80 layer_rect, list.get(), item_proto, client_picture_cache, 82 visual_rect, list.get(), item_proto, client_picture_cache,
81 used_engine_picture_ids); 83 used_engine_picture_ids);
82 } 84 }
83 85
84 list->Finalize(); 86 list->Finalize();
85 87
86 return list; 88 return list;
87 } 89 }
88 90
89 DisplayItemList::DisplayItemList(gfx::Rect layer_rect, 91 DisplayItemList::DisplayItemList(const DisplayItemListSettings& settings)
90 const DisplayItemListSettings& settings, 92 : inputs_(settings) {}
91 bool retain_individual_display_items)
92 : retain_individual_display_items_(retain_individual_display_items),
93 approximate_op_count_(0),
94 picture_memory_usage_(0),
95 inputs_(layer_rect, settings) {
96 if (inputs_.settings.use_cached_picture) {
97 SkRTreeFactory factory;
98 recorder_.reset(new SkPictureRecorder());
99
100 SkCanvas* canvas = recorder_->beginRecording(
101 inputs_.layer_rect.width(), inputs_.layer_rect.height(), &factory);
102 canvas->translate(-inputs_.layer_rect.x(), -inputs_.layer_rect.y());
103 canvas->clipRect(gfx::RectToSkRect(inputs_.layer_rect));
104 }
105 }
106 93
107 DisplayItemList::~DisplayItemList() { 94 DisplayItemList::~DisplayItemList() {
108 } 95 }
109 96
110 void DisplayItemList::ToProtobuf(proto::DisplayItemList* proto) { 97 void DisplayItemList::ToProtobuf(proto::DisplayItemList* proto) {
111 // The flattened SkPicture approach is going away, and the proto 98 // The flattened SkPicture approach is going away, and the proto
112 // doesn't currently support serializing that flattened picture. 99 // doesn't currently support serializing that flattened picture.
113 DCHECK(retain_individual_display_items_);
114
115 RectToProto(inputs_.layer_rect, proto->mutable_layer_rect());
116 inputs_.settings.ToProtobuf(proto->mutable_settings()); 100 inputs_.settings.ToProtobuf(proto->mutable_settings());
117 101
118 DCHECK_EQ(0, proto->items_size()); 102 DCHECK_EQ(0, proto->items_size());
119 for (const auto& item : inputs_.items) 103 DCHECK_EQ(0, proto->visual_rects_size());
104 DCHECK(inputs_.items.size() == inputs_.visual_rects.size())
105 << "items.size() " << inputs_.items.size() << " visual_rects.size() "
106 << inputs_.visual_rects.size();
107 int i = 0;
108 for (const auto& item : inputs_.items) {
109 RectToProto(inputs_.visual_rects[i++], proto->add_visual_rects());
120 item.ToProtobuf(proto->add_items()); 110 item.ToProtobuf(proto->add_items());
111 }
121 } 112 }
122 113
123 void DisplayItemList::Raster(SkCanvas* canvas, 114 void DisplayItemList::Raster(SkCanvas* canvas,
124 SkPicture::AbortCallback* callback, 115 SkPicture::AbortCallback* callback,
125 const gfx::Rect& canvas_target_playback_rect, 116 const gfx::Rect& canvas_target_playback_rect,
126 float contents_scale) const { 117 float contents_scale) const {
127 canvas->save(); 118 canvas->save();
128
129 if (!canvas_target_playback_rect.IsEmpty()) { 119 if (!canvas_target_playback_rect.IsEmpty()) {
130 // canvas_target_playback_rect is specified in device space. We can't 120 // canvas_target_playback_rect is specified in device space. We can't
131 // use clipRect because canvas CTM will be applied on it. Use clipRegion 121 // use clipRect because canvas CTM will be applied on it. Use clipRegion
132 // instead because it ignores canvas CTM. 122 // instead because it ignores canvas CTM.
133 SkRegion device_clip; 123 SkRegion device_clip;
134 device_clip.setRect(gfx::RectToSkIRect(canvas_target_playback_rect)); 124 device_clip.setRect(gfx::RectToSkIRect(canvas_target_playback_rect));
135 canvas->clipRegion(device_clip); 125 canvas->clipRegion(device_clip);
136 } 126 }
137
138 canvas->scale(contents_scale, contents_scale); 127 canvas->scale(contents_scale, contents_scale);
139 Raster(canvas, callback); 128 Raster(canvas, callback);
140 canvas->restore(); 129 canvas->restore();
141 } 130 }
142 131
143 void DisplayItemList::Raster(SkCanvas* canvas, 132 void DisplayItemList::Raster(SkCanvas* canvas,
144 SkPicture::AbortCallback* callback) const { 133 SkPicture::AbortCallback* callback) const {
145 if (!inputs_.settings.use_cached_picture) { 134 gfx::Rect canvas_playback_rect;
146 for (const auto& item : inputs_.items) 135 if (!GetCanvasClipBounds(canvas, &canvas_playback_rect))
147 item.Raster(canvas, callback); 136 return;
148 } else {
149 DCHECK(picture_);
150 137
151 canvas->save(); 138 std::vector<size_t> indices;
152 canvas->translate(inputs_.layer_rect.x(), inputs_.layer_rect.y()); 139 rtree_.Search(canvas_playback_rect, &indices);
153 if (callback) { 140 for (size_t index : indices) {
154 // If we have a callback, we need to call |draw()|, |drawPicture()| 141 inputs_.items[index].Raster(canvas, callback);
155 // doesn't take a callback. This is used by |AnalysisCanvas| to early 142 // We use a callback during solid color analysis on the compositor thread to
156 // out. 143 // break out early. Since we're handling a sequence of pictures via rtree
157 picture_->playback(canvas, callback); 144 // query results ourselves, we have to respect the callback and early out.
158 } else { 145 if (callback && callback->abort())
159 // Prefer to call |drawPicture()| on the canvas since it could place the 146 break;
160 // entire picture on the canvas instead of parsing the skia operations.
161 canvas->drawPicture(picture_.get());
162 }
163 canvas->restore();
164 } 147 }
165 } 148 }
166 149
167 void DisplayItemList::GrowCurrentBeginItemVisualRect( 150 void DisplayItemList::GrowCurrentBeginItemVisualRect(
168 const gfx::Rect& visual_rect) { 151 const gfx::Rect& visual_rect) {
169 if (!inputs_.begin_item_indices.empty()) 152 if (!inputs_.begin_item_indices.empty())
170 inputs_.visual_rects[inputs_.begin_item_indices.back()].Union(visual_rect); 153 inputs_.visual_rects[inputs_.begin_item_indices.back()].Union(visual_rect);
171 } 154 }
172 155
173 void DisplayItemList::ProcessAppendedItem(const DisplayItem* item) {
174 if (inputs_.settings.use_cached_picture) {
175 DCHECK(recorder_);
176 item->Raster(recorder_->getRecordingCanvas(), nullptr);
177 }
178 if (!retain_individual_display_items_) {
179 inputs_.items.Clear();
180 }
181 }
182
183 void DisplayItemList::RasterIntoCanvas(const DisplayItem& item) {
184 DCHECK(recorder_);
185 DCHECK(!retain_individual_display_items_);
186
187 item.Raster(recorder_->getRecordingCanvas(), nullptr);
188 }
189
190 bool DisplayItemList::RetainsIndividualDisplayItems() const {
191 return retain_individual_display_items_;
192 }
193
194 void DisplayItemList::Finalize() { 156 void DisplayItemList::Finalize() {
195 TRACE_EVENT0("cc", "DisplayItemList::Finalize"); 157 TRACE_EVENT0("cc", "DisplayItemList::Finalize");
196 // TODO(dtrainor): Need to deal with serializing visual_rects_. 158 // TODO(dtrainor): Need to deal with serializing inputs_.visual_rects.
197 // http://crbug.com/568757. 159 // http://crbug.com/568757.
198 DCHECK(!retain_individual_display_items_ || 160 DCHECK(inputs_.items.size() == inputs_.visual_rects.size())
199 inputs_.items.size() == inputs_.visual_rects.size())
200 << "items.size() " << inputs_.items.size() << " visual_rects.size() " 161 << "items.size() " << inputs_.items.size() << " visual_rects.size() "
201 << inputs_.visual_rects.size(); 162 << inputs_.visual_rects.size();
163 rtree_.Build(inputs_.visual_rects);
202 164
203 // TODO(vmpstr): Build and make use of an RTree from the visual 165 // TODO(wkorman): Restore the below, potentially with a switch to allow
204 // rects. For now we just clear them out since we won't ever need 166 // clearing visual rects except for Blimp engine. http://crbug.com/633750
205 // them to stick around post-Finalize. http://crbug.com/527245 167 // if (!retain_visual_rects_)
206 // This clears both the vector and the vector's capacity, since visual_rects_ 168 // // This clears both the vector and the vector's capacity, since
207 // won't be used anymore. 169 // // visual_rects won't be used anymore.
208 std::vector<gfx::Rect>().swap(inputs_.visual_rects); 170 // std::vector<gfx::Rect>().swap(inputs_.visual_rects);
209
210 if (inputs_.settings.use_cached_picture) {
211 // Convert to an SkPicture for faster rasterization.
212 DCHECK(inputs_.settings.use_cached_picture);
213 DCHECK(!picture_);
214 picture_ = recorder_->finishRecordingAsPicture();
215 DCHECK(picture_);
216 picture_memory_usage_ =
217 SkPictureUtils::ApproximateBytesUsed(picture_.get());
218 recorder_.reset();
219 }
220 } 171 }
221 172
222 bool DisplayItemList::IsSuitableForGpuRasterization() const { 173 bool DisplayItemList::IsSuitableForGpuRasterization() const {
223 return inputs_.is_suitable_for_gpu_rasterization; 174 // TODO(wkorman): This is more permissive than Picture's implementation, since
175 // none of the items might individually trigger a veto even though they
176 // collectively have enough "bad" operations that a corresponding Picture
177 // would get vetoed. See crbug.com/513016.
178 return inputs_.all_items_are_suitable_for_gpu_rasterization;
224 } 179 }
225 180
226 int DisplayItemList::ApproximateOpCount() const { 181 int DisplayItemList::ApproximateOpCount() const {
227 if (retain_individual_display_items_) 182 return approximate_op_count_;
228 return approximate_op_count_;
229 return picture_ ? picture_->approximateOpCount() : 0;
230 } 183 }
231 184
232 size_t DisplayItemList::ApproximateMemoryUsage() const { 185 size_t DisplayItemList::ApproximateMemoryUsage() const {
233 // We double-count in this case. Produce zero to avoid being misleading.
234 if (inputs_.settings.use_cached_picture && retain_individual_display_items_)
235 return 0;
236
237 DCHECK(!inputs_.settings.use_cached_picture || picture_);
238
239 size_t memory_usage = sizeof(*this); 186 size_t memory_usage = sizeof(*this);
240 187
241 size_t external_memory_usage = 0; 188 size_t external_memory_usage = 0;
242 if (retain_individual_display_items_) { 189 // Warning: this double-counts SkPicture data if use_cached_picture is
243 // Warning: this double-counts SkPicture data if use_cached_picture is 190 // also true.
244 // also true. 191 for (const auto& item : inputs_.items) {
245 for (const auto& item : inputs_.items) { 192 external_memory_usage += item.ExternalMemoryUsage();
246 external_memory_usage += item.ExternalMemoryUsage();
247 }
248 } 193 }
249 194
250 // Memory outside this class due to |items_|. 195 // Memory outside this class due to |items_|.
251 memory_usage += inputs_.items.GetCapacityInBytes() + external_memory_usage; 196 memory_usage += inputs_.items.GetCapacityInBytes() + external_memory_usage;
252 197
253 // Memory outside this class due to |picture|.
254 memory_usage += picture_memory_usage_;
255
256 // TODO(jbroman): Does anything else owned by this class substantially 198 // TODO(jbroman): Does anything else owned by this class substantially
257 // contribute to memory usage? 199 // contribute to memory usage?
200 // TODO(vmpstr): Probably DiscardableImageMap is worth counting here.
258 201
259 return memory_usage; 202 return memory_usage;
260 } 203 }
261 204
262 bool DisplayItemList::ShouldBeAnalyzedForSolidColor() const { 205 bool DisplayItemList::ShouldBeAnalyzedForSolidColor() const {
263 return ApproximateOpCount() <= kOpCountThatIsOkToAnalyze; 206 return ApproximateOpCount() <= kOpCountThatIsOkToAnalyze;
264 } 207 }
265 208
266 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 209 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
267 DisplayItemList::AsValue(bool include_items) const { 210 DisplayItemList::AsValue(bool include_items) const {
268 std::unique_ptr<base::trace_event::TracedValue> state( 211 std::unique_ptr<base::trace_event::TracedValue> state(
269 new base::trace_event::TracedValue()); 212 new base::trace_event::TracedValue());
270 213
271 state->BeginDictionary("params"); 214 state->BeginDictionary("params");
272 if (include_items) { 215 if (include_items) {
273 state->BeginArray("items"); 216 state->BeginArray("items");
274 size_t item_index = 0; 217 size_t item_index = 0;
275 for (const DisplayItem& item : inputs_.items) { 218 for (const DisplayItem& item : inputs_.items) {
276 item.AsValueInto(item_index < inputs_.visual_rects.size() 219 item.AsValueInto(item_index < inputs_.visual_rects.size()
277 ? inputs_.visual_rects[item_index] 220 ? inputs_.visual_rects[item_index]
278 : gfx::Rect(), 221 : gfx::Rect(),
279 state.get()); 222 state.get());
280 item_index++; 223 item_index++;
281 } 224 }
282 state->EndArray(); // "items". 225 state->EndArray(); // "items".
283 } 226 }
284 state->SetValue("layer_rect", MathUtil::AsValue(inputs_.layer_rect)); 227 state->SetValue("layer_rect", MathUtil::AsValue(rtree_.GetBounds()));
285 state->EndDictionary(); // "params". 228 state->EndDictionary(); // "params".
286 229
287 if (!inputs_.layer_rect.IsEmpty()) { 230 SkPictureRecorder recorder;
288 SkPictureRecorder recorder; 231 gfx::Rect bounds = rtree_.GetBounds();
289 SkCanvas* canvas = recorder.beginRecording(inputs_.layer_rect.width(), 232 SkCanvas* canvas = recorder.beginRecording(bounds.width(), bounds.height());
290 inputs_.layer_rect.height()); 233 canvas->translate(-bounds.x(), -bounds.y());
291 canvas->translate(-inputs_.layer_rect.x(), -inputs_.layer_rect.y()); 234 canvas->clipRect(gfx::RectToSkRect(bounds));
292 canvas->clipRect(gfx::RectToSkRect(inputs_.layer_rect)); 235 Raster(canvas, nullptr, gfx::Rect(), 1.f);
293 Raster(canvas, NULL, gfx::Rect(), 1.f); 236 sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture();
294 sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture();
295 237
296 std::string b64_picture; 238 std::string b64_picture;
297 PictureDebugUtil::SerializeAsBase64(picture.get(), &b64_picture); 239 PictureDebugUtil::SerializeAsBase64(picture.get(), &b64_picture);
298 state->SetString("skp64", b64_picture); 240 state->SetString("skp64", b64_picture);
299 }
300 241
301 return std::move(state); 242 return std::move(state);
302 } 243 }
303 244
304 void DisplayItemList::EmitTraceSnapshot() const { 245 void DisplayItemList::EmitTraceSnapshot() const {
305 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( 246 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
306 TRACE_DISABLED_BY_DEFAULT("cc.debug.display_items") "," 247 TRACE_DISABLED_BY_DEFAULT("cc.debug.display_items") ","
307 TRACE_DISABLED_BY_DEFAULT("cc.debug.picture") "," 248 TRACE_DISABLED_BY_DEFAULT("cc.debug.picture") ","
308 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.picture"), 249 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.picture"),
309 "cc::DisplayItemList", this, 250 "cc::DisplayItemList", this,
310 TracedDisplayItemList::AsTraceableDisplayItemList(this, 251 TracedDisplayItemList::AsTraceableDisplayItemList(this,
311 DisplayItemsTracingEnabled())); 252 DisplayItemsTracingEnabled()));
312 } 253 }
313 254
314 void DisplayItemList::GenerateDiscardableImagesMetadata() { 255 void DisplayItemList::GenerateDiscardableImagesMetadata() {
315 // This should be only called once, and only after CreateAndCacheSkPicture. 256 // This should be only called once, and only after CreateAndCacheSkPicture.
316 DCHECK(image_map_.empty()); 257 DCHECK(image_map_.empty());
317 DCHECK(!inputs_.settings.use_cached_picture || picture_);
318 if (inputs_.settings.use_cached_picture && !picture_->willPlayBackBitmaps())
319 return;
320 258
321 // The cached picture is translated by -layer_rect_.origin during record, 259 gfx::Rect bounds = rtree_.GetBounds();
322 // so we need to offset that back in order to get right positioning for
323 // images.
324 DiscardableImageMap::ScopedMetadataGenerator generator( 260 DiscardableImageMap::ScopedMetadataGenerator generator(
325 &image_map_, 261 &image_map_, gfx::Size(bounds.right(), bounds.bottom()));
326 gfx::Size(inputs_.layer_rect.right(), inputs_.layer_rect.bottom())); 262 Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f);
327 Raster(generator.canvas(), nullptr,
328 gfx::Rect(inputs_.layer_rect.right(), inputs_.layer_rect.bottom()),
329 1.f);
330 } 263 }
331 264
332 void DisplayItemList::GetDiscardableImagesInRect( 265 void DisplayItemList::GetDiscardableImagesInRect(
333 const gfx::Rect& rect, 266 const gfx::Rect& rect,
334 float raster_scale, 267 float raster_scale,
335 std::vector<DrawImage>* images) { 268 std::vector<DrawImage>* images) {
336 image_map_.GetDiscardableImagesInRect(rect, raster_scale, images); 269 image_map_.GetDiscardableImagesInRect(rect, raster_scale, images);
337 } 270 }
338 271
339 } // namespace cc 272 } // namespace cc
OLDNEW
« no previous file with comments | « cc/playback/display_item_list.h ('k') | cc/playback/display_item_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698