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

Unified Diff: cc/playback/display_item_list_unittest.cc

Issue 1494223003: cc: Shrink size of display item (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make ui compile too oops 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 side-by-side diff with in-line comments
Download patch
Index: cc/playback/display_item_list_unittest.cc
diff --git a/cc/playback/display_item_list_unittest.cc b/cc/playback/display_item_list_unittest.cc
index b29baa3735e8a44ba233f87950fbd10792b77723..f44c854741af5edb14459e9b5dc19b248e7c6ab4 100644
--- a/cc/playback/display_item_list_unittest.cc
+++ b/cc/playback/display_item_list_unittest.cc
@@ -53,7 +53,7 @@ void AppendFirstSerializationTestPicture(scoped_refptr<DisplayItemList> list,
canvas->translate(offset.x(), offset.y());
canvas->drawRectCoords(0.f, 0.f, 4.f, 4.f, red_paint);
picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect)->SetNew(picture);
+ list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect, picture);
}
void AppendSecondSerializationTestPicture(scoped_refptr<DisplayItemList> list,
@@ -71,7 +71,7 @@ void AppendSecondSerializationTestPicture(scoped_refptr<DisplayItemList> list,
canvas->translate(offset.x(), offset.y());
canvas->drawRectCoords(3.f, 3.f, 7.f, 7.f, blue_paint);
picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect)->SetNew(picture);
+ list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect, picture);
}
void ValidateDisplayItemListSerialization(const gfx::Size& layer_size,
@@ -151,8 +151,7 @@ TEST(DisplayItemListTest, SerializeClipItem) {
gfx::Rect clip_rect(6, 6, 1, 1);
std::vector<SkRRect> rrects;
rrects.push_back(SkRRect::MakeOval(SkRect::MakeXYWH(5.f, 5.f, 4.f, 4.f)));
- auto* item = list->CreateAndAppendItem<ClipDisplayItem>(kVisualRect);
- item->SetNew(clip_rect, rrects);
+ list->CreateAndAppendItem<ClipDisplayItem>(kVisualRect, clip_rect, rrects);
// Build the second DrawingDisplayItem.
AppendSecondSerializationTestPicture(list, layer_size);
@@ -176,8 +175,8 @@ TEST(DisplayItemListTest, SerializeClipPathItem) {
// Build the ClipPathDisplayItem.
SkPath path;
path.addCircle(5.f, 5.f, 2.f, SkPath::Direction::kCW_Direction);
- auto* item = list->CreateAndAppendItem<ClipPathDisplayItem>(kVisualRect);
- item->SetNew(path, SkRegion::Op::kReplace_Op, false);
+ list->CreateAndAppendItem<ClipPathDisplayItem>(
+ kVisualRect, path, SkRegion::Op::kReplace_Op, false);
// Build the second DrawingDisplayItem.
AppendSecondSerializationTestPicture(list, layer_size);
@@ -201,8 +200,8 @@ TEST(DisplayItemListTest, SerializeCompositingItem) {
// Build the CompositingDisplayItem.
skia::RefPtr<SkColorFilter> filter = skia::AdoptRef(
SkColorFilter::CreateLightingFilter(SK_ColorRED, SK_ColorGREEN));
- auto* item = list->CreateAndAppendItem<CompositingDisplayItem>(kVisualRect);
- item->SetNew(150, SkXfermode::Mode::kDst_Mode, nullptr, filter);
+ list->CreateAndAppendItem<CompositingDisplayItem>(
+ kVisualRect, 150, SkXfermode::Mode::kDst_Mode, nullptr, filter);
// Build the second DrawingDisplayItem.
AppendSecondSerializationTestPicture(list, layer_size);
@@ -225,8 +224,7 @@ TEST(DisplayItemListTest, SerializeFloatClipItem) {
// Build the FloatClipDisplayItem.
gfx::RectF clip_rect(6.f, 6.f, 1.f, 1.f);
- auto* item2 = list->CreateAndAppendItem<FloatClipDisplayItem>(kVisualRect);
- item2->SetNew(clip_rect);
+ list->CreateAndAppendItem<FloatClipDisplayItem>(kVisualRect, clip_rect);
// Build the second DrawingDisplayItem.
AppendSecondSerializationTestPicture(list, layer_size);
@@ -251,8 +249,7 @@ TEST(DisplayItemListTest, SerializeTransformItem) {
gfx::Transform transform;
transform.Scale(1.25f, 1.25f);
transform.Translate(-1.f, -1.f);
- auto* item2 = list->CreateAndAppendItem<TransformDisplayItem>(kVisualRect);
- item2->SetNew(transform);
+ list->CreateAndAppendItem<TransformDisplayItem>(kVisualRect, transform);
// Build the second DrawingDisplayItem.
AppendSecondSerializationTestPicture(list, layer_size);
@@ -285,8 +282,8 @@ TEST(DisplayItemListTest, SingleDrawingItem) {
canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint);
canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint);
picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- auto* item = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item->SetNew(picture);
+ list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
+ std::move(picture));
list->Finalize();
DrawDisplayList(pixels, layer_rect, list);
@@ -329,12 +326,12 @@ TEST(DisplayItemListTest, ClipItem) {
canvas->translate(first_offset.x(), first_offset.y());
canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint);
picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- auto* item1 = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item1->SetNew(std::move(picture));
+ list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
+ std::move(picture));
gfx::Rect clip_rect(60, 60, 10, 10);
- auto* item2 = list->CreateAndAppendItem<ClipDisplayItem>(kVisualRect);
- item2->SetNew(clip_rect, std::vector<SkRRect>());
+ list->CreateAndAppendItem<ClipDisplayItem>(kVisualRect, clip_rect,
+ std::vector<SkRRect>());
gfx::PointF second_offset(2.f, 3.f);
gfx::RectF second_recording_rect(second_offset,
@@ -344,8 +341,8 @@ TEST(DisplayItemListTest, ClipItem) {
canvas->translate(second_offset.x(), second_offset.y());
canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint);
picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- auto* item3 = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item3->SetNew(std::move(picture));
+ list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
+ std::move(picture));
list->CreateAndAppendItem<EndClipDisplayItem>(kVisualRect);
list->Finalize();
@@ -392,13 +389,12 @@ TEST(DisplayItemListTest, TransformItem) {
canvas->translate(first_offset.x(), first_offset.y());
canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint);
picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- auto* item1 = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item1->SetNew(picture);
+ list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
+ std::move(picture));
gfx::Transform transform;
transform.Rotate(45.0);
- auto* item2 = list->CreateAndAppendItem<TransformDisplayItem>(kVisualRect);
- item2->SetNew(transform);
+ list->CreateAndAppendItem<TransformDisplayItem>(kVisualRect, transform);
gfx::PointF second_offset(2.f, 3.f);
gfx::RectF second_recording_rect(second_offset,
@@ -408,8 +404,8 @@ TEST(DisplayItemListTest, TransformItem) {
canvas->translate(second_offset.x(), second_offset.y());
canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint);
picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- auto* item3 = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item3->SetNew(picture);
+ list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
+ std::move(picture));
list->CreateAndAppendItem<EndTransformDisplayItem>(kVisualRect);
list->Finalize();
@@ -466,8 +462,8 @@ TEST(DisplayItemListTest, FilterItem) {
filters.Append(FilterOperation::CreateReferenceFilter(image_filter));
filters.Append(FilterOperation::CreateBrightnessFilter(0.5f));
gfx::RectF filter_bounds(10.f, 10.f, 50.f, 50.f);
- auto* item = list->CreateAndAppendItem<FilterDisplayItem>(kVisualRect);
- item->SetNew(filters, filter_bounds);
+ list->CreateAndAppendItem<FilterDisplayItem>(kVisualRect, filters,
+ filter_bounds);
list->CreateAndAppendItem<EndFilterDisplayItem>(kVisualRect);
list->Finalize();
@@ -511,9 +507,8 @@ TEST(DisplayItemListTest, CompactingItems) {
canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint);
canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint);
picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- auto* item1 = list_without_caching->CreateAndAppendItem<DrawingDisplayItem>(
- kVisualRect);
- item1->SetNew(picture);
+ list_without_caching->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
+ picture);
list_without_caching->Finalize();
DrawDisplayList(pixels, layer_rect, list_without_caching);
@@ -522,9 +517,8 @@ TEST(DisplayItemListTest, CompactingItems) {
caching_settings.use_cached_picture = true;
scoped_refptr<DisplayItemList> list_with_caching =
DisplayItemList::Create(layer_rect, caching_settings);
- auto* item2 =
- list_with_caching->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item2->SetNew(picture);
+ list_with_caching->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
+ picture);
list_with_caching->Finalize();
DrawDisplayList(expected_pixels, layer_rect, list_with_caching);
@@ -557,9 +551,8 @@ TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithCachedPicture) {
canvas->drawPath(path, paint);
picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- DrawingDisplayItem* item =
- list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item->SetNew(picture);
+ list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
+ std::move(picture));
list->Finalize();
// A single DrawingDisplayItem with a large AA concave path shouldn't trigger
@@ -572,28 +565,13 @@ TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithCachedPicture) {
for (int i = 0; i < 10; ++i)
canvas->drawPath(path, paint);
picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- item = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item->SetNew(picture);
+ list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
+ std::move(picture));
list->Finalize();
// A single DrawingDisplayItem with several large AA concave paths should
// trigger a veto.
EXPECT_FALSE(list->IsSuitableForGpuRasterization());
-
- list = DisplayItemList::Create(layer_rect, settings);
- for (int i = 0; i < 10; ++i) {
- canvas =
- skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(layer_rect)));
- canvas->drawPath(path, paint);
- picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- item = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item->SetNew(picture);
- }
- list->Finalize();
-
- // Having several DrawingDisplayItems that each contain a large AA concave
- // path should trigger a veto.
- EXPECT_FALSE(list->IsSuitableForGpuRasterization());
}
TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithoutCachedPicture) {
@@ -622,9 +600,8 @@ TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithoutCachedPicture) {
canvas->drawPath(path, paint);
picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- DrawingDisplayItem* item =
- list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item->SetNew(picture);
+ list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
+ std::move(picture));
list->Finalize();
// A single DrawingDisplayItem with a large AA concave path shouldn't trigger
@@ -637,8 +614,8 @@ TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithoutCachedPicture) {
for (int i = 0; i < 10; ++i)
canvas->drawPath(path, paint);
picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- item = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item->SetNew(picture);
+ list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
+ std::move(picture));
list->Finalize();
// A single DrawingDisplayItem with several large AA concave paths should
@@ -651,8 +628,8 @@ TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithoutCachedPicture) {
skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(layer_rect)));
canvas->drawPath(path, paint);
picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- item = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item->SetNew(picture);
+ list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
+ std::move(picture));
}
list->Finalize();
@@ -684,8 +661,7 @@ TEST(DisplayItemListTest, ApproximateMemoryUsage) {
DisplayItemListSettings caching_settings;
caching_settings.use_cached_picture = true;
list = DisplayItemList::Create(layer_rect, caching_settings);
- auto* item = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item->SetNew(picture);
+ list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect, picture);
list->Finalize();
memory_usage = list->ApproximateMemoryUsage();
EXPECT_GE(memory_usage, picture_size);
@@ -695,8 +671,7 @@ TEST(DisplayItemListTest, ApproximateMemoryUsage) {
DisplayItemListSettings no_caching_settings;
no_caching_settings.use_cached_picture = false;
list = DisplayItemList::Create(layer_rect, no_caching_settings);
- item = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item->SetNew(picture);
+ list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect, picture);
list->Finalize();
memory_usage = list->ApproximateMemoryUsage();
EXPECT_GE(memory_usage, picture_size);
@@ -706,8 +681,7 @@ TEST(DisplayItemListTest, ApproximateMemoryUsage) {
// picture and items are retained (currently this only happens due to certain
// categories being traced).
list = new DisplayItemList(layer_rect, caching_settings, true);
- item = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item->SetNew(picture);
+ list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect, picture);
list->Finalize();
memory_usage = list->ApproximateMemoryUsage();
EXPECT_EQ(static_cast<size_t>(0), memory_usage);

Powered by Google App Engine
This is Rietveld 408576698