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

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

Issue 1512823002: Serialize DisplayListRecordingSource to protos. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comments Created 5 years 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/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 DisplayItemListSettings(proto.settings())); 60 DisplayItemListSettings(proto.settings()));
61 61
62 for (int i = 0; i < proto.items_size(); i++) { 62 for (int i = 0; i < proto.items_size(); i++) {
63 const proto::DisplayItem& item_proto = proto.items(i); 63 const proto::DisplayItem& item_proto = proto.items(i);
64 DisplayItem* item = DisplayItemProtoFactory::AllocateAndConstruct( 64 DisplayItem* item = DisplayItemProtoFactory::AllocateAndConstruct(
65 layer_rect, list.get(), item_proto); 65 layer_rect, list.get(), item_proto);
66 if (item) 66 if (item)
67 item->FromProtobuf(item_proto); 67 item->FromProtobuf(item_proto);
68 } 68 }
69 69
70 list->Finalize();
71
70 return list; 72 return list;
71 } 73 }
72 74
73 DisplayItemList::DisplayItemList(gfx::Rect layer_rect, 75 DisplayItemList::DisplayItemList(gfx::Rect layer_rect,
74 const DisplayItemListSettings& settings, 76 const DisplayItemListSettings& settings,
75 bool retain_individual_display_items) 77 bool retain_individual_display_items)
76 : items_(LargestDisplayItemSize(), 78 : items_(LargestDisplayItemSize(),
77 LargestDisplayItemSize() * kDefaultNumDisplayItemsToReserve), 79 LargestDisplayItemSize() * kDefaultNumDisplayItemsToReserve),
78 settings_(settings), 80 settings_(settings),
79 retain_individual_display_items_(retain_individual_display_items), 81 retain_individual_display_items_(retain_individual_display_items),
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // The last item should not have been handled by ProcessAppendedItems, so we 204 // The last item should not have been handled by ProcessAppendedItems, so we
203 // don't need to remove it from approximate_op_count_, etc. 205 // don't need to remove it from approximate_op_count_, etc.
204 DCHECK(retain_individual_display_items_); 206 DCHECK(retain_individual_display_items_);
205 DCHECK(!settings_.use_cached_picture); 207 DCHECK(!settings_.use_cached_picture);
206 items_.RemoveLast(); 208 items_.RemoveLast();
207 } 209 }
208 210
209 void DisplayItemList::Finalize() { 211 void DisplayItemList::Finalize() {
210 // TODO(wkorman): Uncomment the assert below once we've investigated 212 // TODO(wkorman): Uncomment the assert below once we've investigated
211 // and resolved issues. http://crbug.com/557905 213 // and resolved issues. http://crbug.com/557905
212 // DCHECK_EQ(items_.size(), visual_rects_.size()); 214 // DCHECK_EQ(items_.size(), visual_rects_.size());
vmpstr 2015/12/10 01:12:18 FYI, when this DCHECK gets uncommented, then this
David Trainor- moved to gerrit 2015/12/10 17:10:09 We protobuf it during the commit phase and don't a
vmpstr 2015/12/10 18:55:44 We need both the display list and visual rects on
213 215
214 // TODO(vmpstr): Build and make use of an RTree from the visual 216 // TODO(vmpstr): Build and make use of an RTree from the visual
215 // rects. For now we just clear them out since we won't ever need 217 // rects. For now we just clear them out since we won't ever need
216 // them to stick around post-Finalize. http://crbug.com/527245 218 // them to stick around post-Finalize. http://crbug.com/527245
217 visual_rects_.clear(); 219 visual_rects_.clear();
218 220
219 ProcessAppendedItems(); 221 ProcessAppendedItems();
220 222
221 if (settings_.use_cached_picture) { 223 if (settings_.use_cached_picture) {
222 // Convert to an SkPicture for faster rasterization. 224 // Convert to an SkPicture for faster rasterization.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 DisplayItemsTracingEnabled())); 322 DisplayItemsTracingEnabled()));
321 } 323 }
322 324
323 void DisplayItemList::GenerateDiscardableImagesMetadata() { 325 void DisplayItemList::GenerateDiscardableImagesMetadata() {
324 DCHECK(ProcessAppendedItemsCalled()); 326 DCHECK(ProcessAppendedItemsCalled());
325 // This should be only called once, and only after CreateAndCacheSkPicture. 327 // This should be only called once, and only after CreateAndCacheSkPicture.
326 DCHECK(image_map_.empty()); 328 DCHECK(image_map_.empty());
327 DCHECK(!settings_.use_cached_picture || picture_); 329 DCHECK(!settings_.use_cached_picture || picture_);
328 if (settings_.use_cached_picture && !picture_->willPlayBackBitmaps()) 330 if (settings_.use_cached_picture && !picture_->willPlayBackBitmaps())
329 return; 331 return;
330
vmpstr 2015/12/10 01:12:18 Undo this change please :)
David Trainor- moved to gerrit 2015/12/10 17:10:09 Oops.
331 // The cached picture is translated by -layer_rect_.origin during record, 332 // The cached picture is translated by -layer_rect_.origin during record,
332 // so we need to offset that back in order to get right positioning for 333 // so we need to offset that back in order to get right positioning for
333 // images. 334 // images.
334 DiscardableImageMap::ScopedMetadataGenerator generator( 335 DiscardableImageMap::ScopedMetadataGenerator generator(
335 &image_map_, gfx::Size(layer_rect_.right(), layer_rect_.bottom())); 336 &image_map_, gfx::Size(layer_rect_.right(), layer_rect_.bottom()));
336 Raster(generator.canvas(), nullptr, 337 Raster(generator.canvas(), nullptr,
337 gfx::Rect(layer_rect_.right(), layer_rect_.bottom()), 1.f); 338 gfx::Rect(layer_rect_.right(), layer_rect_.bottom()), 1.f);
338 } 339 }
339 340
340 void DisplayItemList::GetDiscardableImagesInRect( 341 void DisplayItemList::GetDiscardableImagesInRect(
341 const gfx::Rect& rect, 342 const gfx::Rect& rect,
342 float raster_scale, 343 float raster_scale,
343 std::vector<DrawImage>* images) { 344 std::vector<DrawImage>* images) {
344 image_map_.GetDiscardableImagesInRect(rect, raster_scale, images); 345 image_map_.GetDiscardableImagesInRect(rect, raster_scale, images);
345 } 346 }
346 347
347 } // namespace cc 348 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/playback/display_item_list_unittest.cc » ('j') | cc/playback/display_list_recording_source.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698