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

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 SetNew private 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..d61a48dc8dc6dadd990dce2a7ae6c83668d7dd59 100644
--- a/cc/playback/display_item_list_unittest.cc
+++ b/cc/playback/display_item_list_unittest.cc
@@ -43,7 +43,6 @@ void AppendFirstSerializationTestPicture(scoped_refptr<DisplayItemList> list,
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);
@@ -52,8 +51,8 @@ void AppendFirstSerializationTestPicture(scoped_refptr<DisplayItemList> list,
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);
- picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect)->SetNew(picture);
+ list->CreateAndAppendItem<DrawingDisplayItem>(
+ kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
}
void AppendSecondSerializationTestPicture(scoped_refptr<DisplayItemList> list,
@@ -61,7 +60,6 @@ void AppendSecondSerializationTestPicture(scoped_refptr<DisplayItemList> list,
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);
@@ -70,8 +68,8 @@ void AppendSecondSerializationTestPicture(scoped_refptr<DisplayItemList> list,
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);
- picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect)->SetNew(picture);
+ list->CreateAndAppendItem<DrawingDisplayItem>(
+ kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
}
void ValidateDisplayItemListSerialization(const gfx::Size& layer_size,
@@ -151,8 +149,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 +173,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 +198,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 +222,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 +247,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 +280,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);
@@ -311,7 +306,6 @@ TEST(DisplayItemListTest, ClipItem) {
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;
@@ -328,13 +322,12 @@ TEST(DisplayItemListTest, ClipItem) {
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);
- picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- auto* item1 = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item1->SetNew(std::move(picture));
+ list->CreateAndAppendItem<DrawingDisplayItem>(
+ kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
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,
@@ -343,9 +336,8 @@ TEST(DisplayItemListTest, ClipItem) {
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);
- picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- auto* item3 = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item3->SetNew(std::move(picture));
+ list->CreateAndAppendItem<DrawingDisplayItem>(
+ kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
list->CreateAndAppendItem<EndClipDisplayItem>(kVisualRect);
list->Finalize();
@@ -374,7 +366,6 @@ TEST(DisplayItemListTest, TransformItem) {
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;
@@ -391,14 +382,12 @@ TEST(DisplayItemListTest, TransformItem) {
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);
- picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- auto* item1 = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item1->SetNew(picture);
+ list->CreateAndAppendItem<DrawingDisplayItem>(
+ kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
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,
@@ -407,9 +396,8 @@ TEST(DisplayItemListTest, TransformItem) {
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);
- picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- auto* item3 = list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item3->SetNew(picture);
+ list->CreateAndAppendItem<DrawingDisplayItem>(
+ kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
list->CreateAndAppendItem<EndTransformDisplayItem>(kVisualRect);
list->Finalize();
@@ -466,8 +454,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 +499,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 +509,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);
@@ -535,7 +521,6 @@ TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithCachedPicture) {
gfx::Rect layer_rect(1000, 1000);
SkPictureRecorder recorder;
skia::RefPtr<SkCanvas> canvas;
- skia::RefPtr<SkPicture> picture;
DisplayItemListSettings settings;
settings.use_cached_picture = true;
@@ -556,10 +541,8 @@ TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithCachedPicture) {
paint.setAntiAlias(true);
canvas->drawPath(path, paint);
- picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- DrawingDisplayItem* item =
- list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item->SetNew(picture);
+ list->CreateAndAppendItem<DrawingDisplayItem>(
+ kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
list->Finalize();
// A single DrawingDisplayItem with a large AA concave path shouldn't trigger
@@ -571,29 +554,13 @@ TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithCachedPicture) {
skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(layer_rect)));
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, skia::AdoptRef(recorder.endRecordingAsPicture()));
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);
danakj 2015/12/08 19:18:16 Where'd this case go?
enne (OOO) 2015/12/08 19:47:27 This patch changes the behavior of DisplayItemList
- 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) {
@@ -621,10 +588,8 @@ TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithoutCachedPicture) {
paint.setAntiAlias(true);
canvas->drawPath(path, paint);
- picture = skia::AdoptRef(recorder.endRecordingAsPicture());
- DrawingDisplayItem* item =
- list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect);
- item->SetNew(picture);
+ list->CreateAndAppendItem<DrawingDisplayItem>(
+ kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
list->Finalize();
// A single DrawingDisplayItem with a large AA concave path shouldn't trigger
@@ -636,9 +601,8 @@ TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithoutCachedPicture) {
skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(layer_rect)));
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, skia::AdoptRef(recorder.endRecordingAsPicture()));
list->Finalize();
// A single DrawingDisplayItem with several large AA concave paths should
@@ -650,9 +614,8 @@ TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithoutCachedPicture) {
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->CreateAndAppendItem<DrawingDisplayItem>(
+ kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
}
list->Finalize();
@@ -684,8 +647,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 +657,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 +667,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