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

Unified Diff: cc/playback/display_item_list_unittest.cc

Issue 1521373005: Revert of cc: Shrink size of display item (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « cc/playback/display_item_list.cc ('k') | cc/playback/display_item_proto_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d61a48dc8dc6dadd990dce2a7ae6c83668d7dd59..b29baa3735e8a44ba233f87950fbd10792b77723 100644
--- a/cc/playback/display_item_list_unittest.cc
+++ b/cc/playback/display_item_list_unittest.cc
@@ -43,6 +43,7 @@
gfx::PointF offset(2.f, 3.f);
SkPictureRecorder recorder;
skia::RefPtr<SkCanvas> canvas;
+ skia::RefPtr<SkPicture> picture;
SkPaint red_paint;
red_paint.setColor(SK_ColorRED);
@@ -51,8 +52,8 @@
offset.x(), offset.y(), layer_size.width(), layer_size.height())));
canvas->translate(offset.x(), offset.y());
canvas->drawRectCoords(0.f, 0.f, 4.f, 4.f, red_paint);
- list->CreateAndAppendItem<DrawingDisplayItem>(
- kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
+ picture = skia::AdoptRef(recorder.endRecordingAsPicture());
+ list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect)->SetNew(picture);
}
void AppendSecondSerializationTestPicture(scoped_refptr<DisplayItemList> list,
@@ -60,6 +61,7 @@
gfx::PointF offset(2.f, 2.f);
SkPictureRecorder recorder;
skia::RefPtr<SkCanvas> canvas;
+ skia::RefPtr<SkPicture> picture;
SkPaint blue_paint;
blue_paint.setColor(SK_ColorBLUE);
@@ -68,8 +70,8 @@
offset.x(), offset.y(), layer_size.width(), layer_size.height())));
canvas->translate(offset.x(), offset.y());
canvas->drawRectCoords(3.f, 3.f, 7.f, 7.f, blue_paint);
- list->CreateAndAppendItem<DrawingDisplayItem>(
- kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
+ picture = skia::AdoptRef(recorder.endRecordingAsPicture());
+ list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect)->SetNew(picture);
}
void ValidateDisplayItemListSerialization(const gfx::Size& layer_size,
@@ -149,7 +151,8 @@
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)));
- list->CreateAndAppendItem<ClipDisplayItem>(kVisualRect, clip_rect, rrects);
+ auto* item = list->CreateAndAppendItem<ClipDisplayItem>(kVisualRect);
+ item->SetNew(clip_rect, rrects);
// Build the second DrawingDisplayItem.
AppendSecondSerializationTestPicture(list, layer_size);
@@ -173,8 +176,8 @@
// Build the ClipPathDisplayItem.
SkPath path;
path.addCircle(5.f, 5.f, 2.f, SkPath::Direction::kCW_Direction);
- list->CreateAndAppendItem<ClipPathDisplayItem>(
- kVisualRect, path, SkRegion::Op::kReplace_Op, false);
+ auto* item = list->CreateAndAppendItem<ClipPathDisplayItem>(kVisualRect);
+ item->SetNew(path, SkRegion::Op::kReplace_Op, false);
// Build the second DrawingDisplayItem.
AppendSecondSerializationTestPicture(list, layer_size);
@@ -198,8 +201,8 @@
// Build the CompositingDisplayItem.
skia::RefPtr<SkColorFilter> filter = skia::AdoptRef(
SkColorFilter::CreateLightingFilter(SK_ColorRED, SK_ColorGREEN));
- list->CreateAndAppendItem<CompositingDisplayItem>(
- kVisualRect, 150, SkXfermode::Mode::kDst_Mode, nullptr, filter);
+ auto* item = list->CreateAndAppendItem<CompositingDisplayItem>(kVisualRect);
+ item->SetNew(150, SkXfermode::Mode::kDst_Mode, nullptr, filter);
// Build the second DrawingDisplayItem.
AppendSecondSerializationTestPicture(list, layer_size);
@@ -222,7 +225,8 @@
// Build the FloatClipDisplayItem.
gfx::RectF clip_rect(6.f, 6.f, 1.f, 1.f);
- list->CreateAndAppendItem<FloatClipDisplayItem>(kVisualRect, clip_rect);
+ auto* item2 = list->CreateAndAppendItem<FloatClipDisplayItem>(kVisualRect);
+ item2->SetNew(clip_rect);
// Build the second DrawingDisplayItem.
AppendSecondSerializationTestPicture(list, layer_size);
@@ -247,7 +251,8 @@
gfx::Transform transform;
transform.Scale(1.25f, 1.25f);
transform.Translate(-1.f, -1.f);
- list->CreateAndAppendItem<TransformDisplayItem>(kVisualRect, transform);
+ auto* item2 = list->CreateAndAppendItem<TransformDisplayItem>(kVisualRect);
+ item2->SetNew(transform);
// Build the second DrawingDisplayItem.
AppendSecondSerializationTestPicture(list, layer_size);
@@ -280,8 +285,8 @@
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());
- list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
- std::move(picture));
+ auto* item = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
+ item->SetNew(picture);
list->Finalize();
DrawDisplayList(pixels, layer_rect, list);
@@ -306,6 +311,7 @@
gfx::Rect layer_rect(100, 100);
SkPictureRecorder recorder;
skia::RefPtr<SkCanvas> canvas;
+ skia::RefPtr<SkPicture> picture;
SkPaint blue_paint;
blue_paint.setColor(SK_ColorBLUE);
SkPaint red_paint;
@@ -322,12 +328,13 @@
recorder.beginRecording(gfx::RectFToSkRect(first_recording_rect)));
canvas->translate(first_offset.x(), first_offset.y());
canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint);
- list->CreateAndAppendItem<DrawingDisplayItem>(
- kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
+ picture = skia::AdoptRef(recorder.endRecordingAsPicture());
+ auto* item1 = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
+ item1->SetNew(std::move(picture));
gfx::Rect clip_rect(60, 60, 10, 10);
- list->CreateAndAppendItem<ClipDisplayItem>(kVisualRect, clip_rect,
- std::vector<SkRRect>());
+ auto* item2 = list->CreateAndAppendItem<ClipDisplayItem>(kVisualRect);
+ item2->SetNew(clip_rect, std::vector<SkRRect>());
gfx::PointF second_offset(2.f, 3.f);
gfx::RectF second_recording_rect(second_offset,
@@ -336,8 +343,9 @@
recorder.beginRecording(gfx::RectFToSkRect(second_recording_rect)));
canvas->translate(second_offset.x(), second_offset.y());
canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint);
- list->CreateAndAppendItem<DrawingDisplayItem>(
- kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
+ picture = skia::AdoptRef(recorder.endRecordingAsPicture());
+ auto* item3 = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
+ item3->SetNew(std::move(picture));
list->CreateAndAppendItem<EndClipDisplayItem>(kVisualRect);
list->Finalize();
@@ -366,6 +374,7 @@
gfx::Rect layer_rect(100, 100);
SkPictureRecorder recorder;
skia::RefPtr<SkCanvas> canvas;
+ skia::RefPtr<SkPicture> picture;
SkPaint blue_paint;
blue_paint.setColor(SK_ColorBLUE);
SkPaint red_paint;
@@ -382,12 +391,14 @@
recorder.beginRecording(gfx::RectFToSkRect(first_recording_rect)));
canvas->translate(first_offset.x(), first_offset.y());
canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint);
- list->CreateAndAppendItem<DrawingDisplayItem>(
- kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
+ picture = skia::AdoptRef(recorder.endRecordingAsPicture());
+ auto* item1 = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
+ item1->SetNew(picture);
gfx::Transform transform;
transform.Rotate(45.0);
- list->CreateAndAppendItem<TransformDisplayItem>(kVisualRect, transform);
+ auto* item2 = list->CreateAndAppendItem<TransformDisplayItem>(kVisualRect);
+ item2->SetNew(transform);
gfx::PointF second_offset(2.f, 3.f);
gfx::RectF second_recording_rect(second_offset,
@@ -396,8 +407,9 @@
recorder.beginRecording(gfx::RectFToSkRect(second_recording_rect)));
canvas->translate(second_offset.x(), second_offset.y());
canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint);
- list->CreateAndAppendItem<DrawingDisplayItem>(
- kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
+ picture = skia::AdoptRef(recorder.endRecordingAsPicture());
+ auto* item3 = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
+ item3->SetNew(picture);
list->CreateAndAppendItem<EndTransformDisplayItem>(kVisualRect);
list->Finalize();
@@ -454,8 +466,8 @@
filters.Append(FilterOperation::CreateReferenceFilter(image_filter));
filters.Append(FilterOperation::CreateBrightnessFilter(0.5f));
gfx::RectF filter_bounds(10.f, 10.f, 50.f, 50.f);
- list->CreateAndAppendItem<FilterDisplayItem>(kVisualRect, filters,
- filter_bounds);
+ auto* item = list->CreateAndAppendItem<FilterDisplayItem>(kVisualRect);
+ item->SetNew(filters, filter_bounds);
list->CreateAndAppendItem<EndFilterDisplayItem>(kVisualRect);
list->Finalize();
@@ -499,8 +511,9 @@
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());
- list_without_caching->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
- picture);
+ auto* item1 = list_without_caching->CreateAndAppendItem<DrawingDisplayItem>(
+ kVisualRect);
+ item1->SetNew(picture);
list_without_caching->Finalize();
DrawDisplayList(pixels, layer_rect, list_without_caching);
@@ -509,8 +522,9 @@
caching_settings.use_cached_picture = true;
scoped_refptr<DisplayItemList> list_with_caching =
DisplayItemList::Create(layer_rect, caching_settings);
- list_with_caching->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
- picture);
+ auto* item2 =
+ list_with_caching->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
+ item2->SetNew(picture);
list_with_caching->Finalize();
DrawDisplayList(expected_pixels, layer_rect, list_with_caching);
@@ -521,6 +535,7 @@
gfx::Rect layer_rect(1000, 1000);
SkPictureRecorder recorder;
skia::RefPtr<SkCanvas> canvas;
+ skia::RefPtr<SkPicture> picture;
DisplayItemListSettings settings;
settings.use_cached_picture = true;
@@ -541,8 +556,10 @@
paint.setAntiAlias(true);
canvas->drawPath(path, paint);
- list->CreateAndAppendItem<DrawingDisplayItem>(
- kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
+ picture = skia::AdoptRef(recorder.endRecordingAsPicture());
+ DrawingDisplayItem* item =
+ list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
+ item->SetNew(picture);
list->Finalize();
// A single DrawingDisplayItem with a large AA concave path shouldn't trigger
@@ -554,12 +571,28 @@
skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(layer_rect)));
for (int i = 0; i < 10; ++i)
canvas->drawPath(path, paint);
- list->CreateAndAppendItem<DrawingDisplayItem>(
- kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
+ picture = skia::AdoptRef(recorder.endRecordingAsPicture());
+ item = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
+ item->SetNew(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());
}
@@ -588,8 +621,10 @@
paint.setAntiAlias(true);
canvas->drawPath(path, paint);
- list->CreateAndAppendItem<DrawingDisplayItem>(
- kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
+ picture = skia::AdoptRef(recorder.endRecordingAsPicture());
+ DrawingDisplayItem* item =
+ list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
+ item->SetNew(picture);
list->Finalize();
// A single DrawingDisplayItem with a large AA concave path shouldn't trigger
@@ -601,8 +636,9 @@
skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(layer_rect)));
for (int i = 0; i < 10; ++i)
canvas->drawPath(path, paint);
- list->CreateAndAppendItem<DrawingDisplayItem>(
- kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
+ picture = skia::AdoptRef(recorder.endRecordingAsPicture());
+ item = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
+ item->SetNew(picture);
list->Finalize();
// A single DrawingDisplayItem with several large AA concave paths should
@@ -614,8 +650,9 @@
canvas =
skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(layer_rect)));
canvas->drawPath(path, paint);
- list->CreateAndAppendItem<DrawingDisplayItem>(
- kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
+ picture = skia::AdoptRef(recorder.endRecordingAsPicture());
+ item = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
+ item->SetNew(picture);
}
list->Finalize();
@@ -647,7 +684,8 @@
DisplayItemListSettings caching_settings;
caching_settings.use_cached_picture = true;
list = DisplayItemList::Create(layer_rect, caching_settings);
- list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect, picture);
+ auto* item = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
+ item->SetNew(picture);
list->Finalize();
memory_usage = list->ApproximateMemoryUsage();
EXPECT_GE(memory_usage, picture_size);
@@ -657,7 +695,8 @@
DisplayItemListSettings no_caching_settings;
no_caching_settings.use_cached_picture = false;
list = DisplayItemList::Create(layer_rect, no_caching_settings);
- list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect, picture);
+ item = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
+ item->SetNew(picture);
list->Finalize();
memory_usage = list->ApproximateMemoryUsage();
EXPECT_GE(memory_usage, picture_size);
@@ -667,7 +706,8 @@
// picture and items are retained (currently this only happens due to certain
// categories being traced).
list = new DisplayItemList(layer_rect, caching_settings, true);
- list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect, picture);
+ item = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
+ item->SetNew(picture);
list->Finalize();
memory_usage = list->ApproximateMemoryUsage();
EXPECT_EQ(static_cast<size_t>(0), memory_usage);
« no previous file with comments | « cc/playback/display_item_list.cc ('k') | cc/playback/display_item_proto_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698