summaryrefslogtreecommitdiffstats
path: root/cc/playback
diff options
context:
space:
mode:
authorenne <enne@chromium.org>2015-11-30 17:34:58 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-01 01:36:01 +0000
commit797d82330d43b61de90fb814fc4dd6fa09d6e403 (patch)
treeeca0092b31985d3e05385a3ad1adb5f007785b77 /cc/playback
parent20c5d7aefdd46dfc6a9e82c625de2d666edf5537 (diff)
downloadchromium_src-797d82330d43b61de90fb814fc4dd6fa09d6e403.zip
chromium_src-797d82330d43b61de90fb814fc4dd6fa09d6e403.tar.gz
chromium_src-797d82330d43b61de90fb814fc4dd6fa09d6e403.tar.bz2
cc: Use contiguous container for display list
Along with future patches, this will help reduce sizes of display lists and minorly improve raster performance. This is a Chromium restyled version of Blink's ContiguousContainer. CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1479593003 Cr-Commit-Position: refs/heads/master@{#362308}
Diffstat (limited to 'cc/playback')
-rw-r--r--cc/playback/display_item_list.cc35
-rw-r--r--cc/playback/display_item_list.h6
2 files changed, 21 insertions, 20 deletions
diff --git a/cc/playback/display_item_list.cc b/cc/playback/display_item_list.cc
index e997a2e..5b0009a 100644
--- a/cc/playback/display_item_list.cc
+++ b/cc/playback/display_item_list.cc
@@ -73,7 +73,8 @@ scoped_refptr<DisplayItemList> DisplayItemList::CreateFromProto(
DisplayItemList::DisplayItemList(gfx::Rect layer_rect,
const DisplayItemListSettings& settings,
bool retain_individual_display_items)
- : items_(LargestDisplayItemSize(), kDefaultNumDisplayItemsToReserve),
+ : items_(LargestDisplayItemSize(),
+ LargestDisplayItemSize() * kDefaultNumDisplayItemsToReserve),
settings_(settings),
retain_individual_display_items_(retain_individual_display_items),
layer_rect_(layer_rect),
@@ -102,8 +103,8 @@ void DisplayItemList::ToProtobuf(proto::DisplayItemList* proto) {
settings_.ToProtobuf(proto->mutable_settings());
DCHECK_EQ(0, proto->items_size());
- for (auto* item : items_)
- item->ToProtobuf(proto->add_items());
+ for (const auto& item : items_)
+ item.ToProtobuf(proto->add_items());
}
void DisplayItemList::Raster(SkCanvas* canvas,
@@ -114,8 +115,8 @@ void DisplayItemList::Raster(SkCanvas* canvas,
if (!settings_.use_cached_picture) {
canvas->save();
canvas->scale(contents_scale, contents_scale);
- for (auto* item : items_)
- item->Raster(canvas, canvas_target_playback_rect, callback);
+ for (const auto& item : items_)
+ item.Raster(canvas, canvas_target_playback_rect, callback);
canvas->restore();
} else {
DCHECK(picture_);
@@ -153,7 +154,7 @@ void DisplayItemList::ProcessAppendedItems() {
#if DCHECK_IS_ON()
needs_process_ = false;
#endif
- for (const DisplayItem* item : items_) {
+ for (const DisplayItem& item : items_) {
if (settings_.use_cached_picture) {
// When using a cached picture we will calculate gpu suitability on the
// entire cached picture instead of the items. This is more permissive
@@ -161,23 +162,23 @@ void DisplayItemList::ProcessAppendedItems() {
// they collectively have enough "bad" operations that a corresponding
// Picture would get vetoed. See crbug.com/513016.
DCHECK(canvas_);
- approximate_op_count_ += item->approximate_op_count();
- item->Raster(canvas_.get(), gfx::Rect(), nullptr);
+ approximate_op_count_ += item.approximate_op_count();
+ item.Raster(canvas_.get(), gfx::Rect(), nullptr);
} else {
is_suitable_for_gpu_rasterization_ &=
- item->is_suitable_for_gpu_rasterization();
- approximate_op_count_ += item->approximate_op_count();
+ item.is_suitable_for_gpu_rasterization();
+ approximate_op_count_ += item.approximate_op_count();
}
if (retain_individual_display_items_) {
// Warning: this double-counts SkPicture data if use_cached_picture is
// also true.
- external_memory_usage_ += item->external_memory_usage();
+ external_memory_usage_ += item.external_memory_usage();
}
}
if (!retain_individual_display_items_)
- items_.clear();
+ items_.Clear();
}
void DisplayItemList::RasterIntoCanvas(const DisplayItem& item) {
@@ -274,11 +275,11 @@ DisplayItemList::AsValue(bool include_items) const {
if (include_items) {
state->BeginArray("items");
size_t item_index = 0;
- for (const DisplayItem* item : items_) {
- item->AsValueInto(visual_rects_.size() >= item_index
- ? visual_rects_[item_index]
- : gfx::Rect(),
- state.get());
+ for (const DisplayItem& item : items_) {
+ item.AsValueInto(visual_rects_.size() >= item_index
+ ? visual_rects_[item_index]
+ : gfx::Rect(),
+ state.get());
item_index++;
}
state->EndArray(); // "items".
diff --git a/cc/playback/display_item_list.h b/cc/playback/display_item_list.h
index a988e9e..4d24538 100644
--- a/cc/playback/display_item_list.h
+++ b/cc/playback/display_item_list.h
@@ -10,7 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/trace_event/trace_event.h"
#include "cc/base/cc_export.h"
-#include "cc/base/list_container.h"
+#include "cc/base/contiguous_container.h"
#include "cc/playback/discardable_image_map.h"
#include "cc/playback/display_item.h"
#include "cc/playback/display_item_list_settings.h"
@@ -67,7 +67,7 @@ class CC_EXPORT DisplayItemList
#endif
visual_rects_.push_back(visual_rect);
ProcessAppendedItemsOnTheFly();
- return items_.AllocateAndConstruct<DisplayItemType>();
+ return &items_.AllocateAndConstruct<DisplayItemType>();
}
// Removes the last item. This cannot be called on lists with cached pictures
@@ -115,7 +115,7 @@ class CC_EXPORT DisplayItemList
bool ProcessAppendedItemsCalled() const { return true; }
#endif
- ListContainer<DisplayItem> items_;
+ ContiguousContainer<DisplayItem> items_;
// The visual rects associated with each of the display items in the
// display item list. There is one rect per display item, and the
// position in |visual_rects_| matches the position of the item in