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

Unified Diff: cc/playback/display_item_list_unittest.cc

Issue 1835843002: WIP: Fix foreignObject cullrect Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months 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_list_raster_source.cc » ('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 f75d12d9c0a12004e8400dc572dae27a8e451e5b..3eea7f1f36b73703c1f95f0e1144711a0ef4b83d 100644
--- a/cc/playback/display_item_list_unittest.cc
+++ b/cc/playback/display_item_list_unittest.cc
@@ -120,8 +120,9 @@ TEST(DisplayItemListTest, SerializeSingleDrawingItem) {
gfx::Size layer_size(10, 10);
DisplayItemListSettings settings;
- scoped_refptr<DisplayItemList> list =
- DisplayItemList::Create(gfx::Rect(layer_size), settings);
+ settings.use_cached_picture = true;
+ scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
+ list->SetRetainVisualRectsForTesting(true);
// Build the DrawingDisplayItem.
AppendFirstSerializationTestPicture(list, layer_size);
@@ -133,8 +134,9 @@ TEST(DisplayItemListTest, SerializeClipItem) {
gfx::Size layer_size(10, 10);
DisplayItemListSettings settings;
- scoped_refptr<DisplayItemList> list =
- DisplayItemList::Create(gfx::Rect(layer_size), settings);
+ settings.use_cached_picture = true;
+ scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
+ list->SetRetainVisualRectsForTesting(true);
// Build the DrawingDisplayItem.
AppendFirstSerializationTestPicture(list, layer_size);
@@ -158,8 +160,9 @@ TEST(DisplayItemListTest, SerializeClipPathItem) {
gfx::Size layer_size(10, 10);
DisplayItemListSettings settings;
- scoped_refptr<DisplayItemList> list =
- DisplayItemList::Create(gfx::Rect(layer_size), settings);
+ settings.use_cached_picture = true;
+ scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
+ list->SetRetainVisualRectsForTesting(true);
// Build the DrawingDisplayItem.
AppendFirstSerializationTestPicture(list, layer_size);
@@ -183,8 +186,9 @@ TEST(DisplayItemListTest, SerializeCompositingItem) {
gfx::Size layer_size(10, 10);
DisplayItemListSettings settings;
- scoped_refptr<DisplayItemList> list =
- DisplayItemList::Create(gfx::Rect(layer_size), settings);
+ settings.use_cached_picture = true;
+ scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
+ list->SetRetainVisualRectsForTesting(true);
// Build the DrawingDisplayItem.
AppendFirstSerializationTestPicture(list, layer_size);
@@ -208,8 +212,9 @@ TEST(DisplayItemListTest, SerializeFloatClipItem) {
gfx::Size layer_size(10, 10);
DisplayItemListSettings settings;
- scoped_refptr<DisplayItemList> list =
- DisplayItemList::Create(gfx::Rect(layer_size), settings);
+ settings.use_cached_picture = true;
+ scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
+ list->SetRetainVisualRectsForTesting(true);
// Build the DrawingDisplayItem.
AppendFirstSerializationTestPicture(list, layer_size);
@@ -231,8 +236,9 @@ TEST(DisplayItemListTest, SerializeTransformItem) {
gfx::Size layer_size(10, 10);
DisplayItemListSettings settings;
- scoped_refptr<DisplayItemList> list =
- DisplayItemList::Create(gfx::Rect(layer_size), settings);
+ settings.use_cached_picture = true;
+ scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
+ list->SetRetainVisualRectsForTesting(true);
// Build the DrawingDisplayItem.
AppendFirstSerializationTestPicture(list, layer_size);
@@ -262,8 +268,8 @@ TEST(DisplayItemListTest, SingleDrawingItem) {
red_paint.setColor(SK_ColorRED);
unsigned char pixels[4 * 100 * 100] = {0};
DisplayItemListSettings settings;
- scoped_refptr<DisplayItemList> list =
- DisplayItemList::Create(layer_rect, settings);
+ settings.use_cached_picture = true;
+ scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
gfx::PointF offset(8.f, 9.f);
gfx::RectF recording_rect(offset, gfx::SizeF(layer_rect.size()));
@@ -305,8 +311,7 @@ TEST(DisplayItemListTest, ClipItem) {
unsigned char pixels[4 * 100 * 100] = {0};
DisplayItemListSettings settings;
settings.use_cached_picture = true;
- scoped_refptr<DisplayItemList> list =
- DisplayItemList::Create(layer_rect, settings);
+ scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
gfx::PointF first_offset(8.f, 9.f);
gfx::RectF first_recording_rect(first_offset, gfx::SizeF(layer_rect.size()));
@@ -365,8 +370,7 @@ TEST(DisplayItemListTest, TransformItem) {
unsigned char pixels[4 * 100 * 100] = {0};
DisplayItemListSettings settings;
settings.use_cached_picture = true;
- scoped_refptr<DisplayItemList> list =
- DisplayItemList::Create(layer_rect, settings);
+ scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
gfx::PointF first_offset(8.f, 9.f);
gfx::RectF first_recording_rect(first_offset, gfx::SizeF(layer_rect.size()));
@@ -418,10 +422,8 @@ TEST(DisplayItemListTest, FilterItem) {
gfx::Rect layer_rect(100, 100);
FilterOperations filters;
unsigned char pixels[4 * 100 * 100] = {0};
- DisplayItemListSettings settings;
- settings.use_cached_picture = true;
scoped_refptr<DisplayItemList> list =
- DisplayItemList::Create(layer_rect, settings);
+ DisplayItemList::Create(DisplayItemListSettings());
skia::RefPtr<SkSurface> source_surface =
skia::AdoptRef(SkSurface::NewRasterN32Premul(50, 50));
@@ -480,9 +482,8 @@ TEST(DisplayItemListTest, CompactingItems) {
gfx::RectF recording_rect(offset, gfx::SizeF(layer_rect.size()));
DisplayItemListSettings no_caching_settings;
- no_caching_settings.use_cached_picture = false;
scoped_refptr<DisplayItemList> list_without_caching =
- DisplayItemList::Create(layer_rect, no_caching_settings);
+ DisplayItemList::Create(no_caching_settings);
canvas = skia::SharePtr(
recorder.beginRecording(gfx::RectFToSkRect(recording_rect)));
@@ -499,7 +500,7 @@ TEST(DisplayItemListTest, CompactingItems) {
DisplayItemListSettings caching_settings;
caching_settings.use_cached_picture = true;
scoped_refptr<DisplayItemList> list_with_caching =
- DisplayItemList::Create(layer_rect, caching_settings);
+ DisplayItemList::Create(caching_settings);
list_with_caching->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
picture);
list_with_caching->Finalize();
@@ -508,67 +509,6 @@ TEST(DisplayItemListTest, CompactingItems) {
EXPECT_EQ(0, memcmp(pixels, expected_pixels, 4 * 100 * 100));
}
-TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithCachedPicture) {
- gfx::Rect layer_rect(1000, 1000);
- SkPictureRecorder recorder;
- skia::RefPtr<SkCanvas> canvas;
-
- DisplayItemListSettings settings;
- settings.use_cached_picture = true;
- scoped_refptr<DisplayItemList> list =
- DisplayItemList::Create(layer_rect, settings);
- canvas =
- skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(layer_rect)));
-
- SkPath path;
- path.moveTo(0, 0);
- path.lineTo(0, 100);
- path.lineTo(50, 50);
- path.lineTo(100, 100);
- path.lineTo(100, 0);
- path.close();
-
- SkPaint paint;
- paint.setAntiAlias(true);
- canvas->drawPath(path, paint);
-
- sk_sp<SkPicture> suitable_picture = recorder.finishRecordingAsPicture();
- list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect, suitable_picture);
- list->Finalize();
-
- // A single DrawingDisplayItem with a large AA concave path shouldn't trigger
- // a veto.
- EXPECT_TRUE(list->IsSuitableForGpuRasterization());
-
- // Now check the RasterIntoCanvas path.
- list = DisplayItemList::Create(layer_rect, settings);
- DrawingDisplayItem suitable_item(suitable_picture);
- list->RasterIntoCanvas(suitable_item);
- list->Finalize();
- EXPECT_TRUE(list->IsSuitableForGpuRasterization());
-
- list = DisplayItemList::Create(layer_rect, settings);
- canvas =
- skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(layer_rect)));
- for (int i = 0; i < 10; ++i)
- canvas->drawPath(path, paint);
- sk_sp<SkPicture> unsuitable_picture = recorder.finishRecordingAsPicture();
- list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
- unsuitable_picture);
- list->Finalize();
-
- // A single DrawingDisplayItem with several large AA concave paths should
- // trigger a veto.
- EXPECT_FALSE(list->IsSuitableForGpuRasterization());
-
- // Now check the RasterIntoCanvas path.
- list = DisplayItemList::Create(layer_rect, settings);
- DrawingDisplayItem unsuitable_item(unsuitable_picture);
- list->RasterIntoCanvas(unsuitable_item);
- list->Finalize();
- EXPECT_FALSE(list->IsSuitableForGpuRasterization());
-}
-
TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithoutCachedPicture) {
gfx::Rect layer_rect(1000, 1000);
SkPictureRecorder recorder;
@@ -577,8 +517,7 @@ TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithoutCachedPicture) {
DisplayItemListSettings settings;
settings.use_cached_picture = false;
- scoped_refptr<DisplayItemList> list =
- DisplayItemList::Create(layer_rect, settings);
+ scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
canvas =
skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(layer_rect)));
@@ -602,7 +541,7 @@ TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithoutCachedPicture) {
// a veto.
EXPECT_TRUE(list->IsSuitableForGpuRasterization());
- list = DisplayItemList::Create(layer_rect, settings);
+ list = DisplayItemList::Create(settings);
canvas =
skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(layer_rect)));
for (int i = 0; i < 10; ++i)
@@ -615,7 +554,7 @@ TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithoutCachedPicture) {
// trigger a veto.
EXPECT_FALSE(list->IsSuitableForGpuRasterization());
- list = DisplayItemList::Create(layer_rect, settings);
+ list = DisplayItemList::Create(settings);
for (int i = 0; i < 10; ++i) {
canvas =
skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(layer_rect)));
@@ -651,7 +590,7 @@ TEST(DisplayItemListTest, ApproximateMemoryUsage) {
// Using a cached picture, we should get about the right size.
DisplayItemListSettings caching_settings;
caching_settings.use_cached_picture = true;
- list = DisplayItemList::Create(layer_rect, caching_settings);
+ list = DisplayItemList::Create(caching_settings);
list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect, picture);
list->Finalize();
memory_usage = list->ApproximateMemoryUsage();
@@ -661,43 +600,36 @@ TEST(DisplayItemListTest, ApproximateMemoryUsage) {
// Using no cached picture, we should still get the right size.
DisplayItemListSettings no_caching_settings;
no_caching_settings.use_cached_picture = false;
- list = DisplayItemList::Create(layer_rect, no_caching_settings);
+ list = DisplayItemList::Create(no_caching_settings);
list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect, picture);
list->Finalize();
memory_usage = list->ApproximateMemoryUsage();
EXPECT_GE(memory_usage, picture_size);
EXPECT_LE(memory_usage, 2 * picture_size);
-
- // To avoid double counting, we expect zero size to be computed if both the
- // 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);
- list->Finalize();
- memory_usage = list->ApproximateMemoryUsage();
- EXPECT_EQ(static_cast<size_t>(0), memory_usage);
}
-TEST(DisplayItemListTest, AsValueWithRectAndNoItems) {
+TEST(DisplayItemListTest, AsValueWithNoItems) {
scoped_refptr<DisplayItemList> list =
- DisplayItemList::Create(gfx::Rect(1, 2, 8, 9), DisplayItemListSettings());
+ DisplayItemList::Create(DisplayItemListSettings());
+ list->SetRetainVisualRectsForTesting(true);
list->Finalize();
std::string value = list->AsValue(true)->ToString();
EXPECT_NE(value.find("\"items\":[]"), std::string::npos);
- EXPECT_NE(value.find("\"layer_rect\":[1,2,8,9]"), std::string::npos);
+ EXPECT_EQ(value.find("visualRect: [0,0 42x42]"), std::string::npos);
EXPECT_NE(value.find("\"skp64\":"), std::string::npos);
value = list->AsValue(false)->ToString();
EXPECT_EQ(value.find("\"items\":"), std::string::npos);
- EXPECT_NE(value.find("\"layer_rect\":[1,2,8,9]"), std::string::npos);
+ EXPECT_EQ(value.find("visualRect: [0,0 42x42]"), std::string::npos);
EXPECT_NE(value.find("\"skp64\":"), std::string::npos);
}
-TEST(DisplayItemListTest, AsValueWithRectAndItems) {
+TEST(DisplayItemListTest, AsValueWithItems) {
gfx::Rect layer_rect = gfx::Rect(1, 2, 8, 9);
scoped_refptr<DisplayItemList> list =
- DisplayItemList::Create(layer_rect, DisplayItemListSettings());
+ DisplayItemList::Create(DisplayItemListSettings());
+ list->SetRetainVisualRectsForTesting(true);
gfx::Transform transform;
transform.Translate(6.f, 7.f);
list->CreateAndAppendItem<TransformDisplayItem>(kVisualRect, transform);
@@ -708,55 +640,14 @@ TEST(DisplayItemListTest, AsValueWithRectAndItems) {
std::string value = list->AsValue(true)->ToString();
EXPECT_NE(value.find("{\"items\":[\"TransformDisplayItem"),
std::string::npos);
- EXPECT_NE(value.find("\"layer_rect\":[1,2,8,9]"), std::string::npos);
+ EXPECT_NE(value.find("visualRect: [0,0 42x42]"), std::string::npos);
EXPECT_NE(value.find("\"skp64\":"), std::string::npos);
value = list->AsValue(false)->ToString();
EXPECT_EQ(value.find("{\"items\":[\"TransformDisplayItem"),
std::string::npos);
- EXPECT_NE(value.find("\"layer_rect\":[1,2,8,9]"), std::string::npos);
- EXPECT_NE(value.find("\"skp64\":"), std::string::npos);
-}
-
-TEST(DisplayItemListTest, AsValueWithEmptyRectAndNoItems) {
- scoped_refptr<DisplayItemList> list =
- DisplayItemList::Create(gfx::Rect(), DisplayItemListSettings());
- list->Finalize();
-
- std::string value = list->AsValue(true)->ToString();
- EXPECT_NE(value.find("\"items\":[]"), std::string::npos);
- EXPECT_NE(value.find("\"layer_rect\":[0,0,0,0]"), std::string::npos);
- EXPECT_EQ(value.find("\"skp64\":"), std::string::npos);
-
- value = list->AsValue(false)->ToString();
- EXPECT_EQ(value.find("\"items\":"), std::string::npos);
- EXPECT_NE(value.find("\"layer_rect\":[0,0,0,0]"), std::string::npos);
- EXPECT_EQ(value.find("\"skp64\":"), std::string::npos);
-}
-
-TEST(DisplayItemListTest, AsValueWithEmptyRectAndItems) {
- scoped_refptr<DisplayItemList> list =
- DisplayItemList::Create(gfx::Rect(), DisplayItemListSettings());
- gfx::Transform transform;
- transform.Translate(6.f, 7.f);
- list->CreateAndAppendItem<TransformDisplayItem>(kVisualRect, transform);
- AppendFirstSerializationTestPicture(list, gfx::Size());
- list->CreateAndAppendItem<EndTransformDisplayItem>(kVisualRect);
- list->Finalize();
-
- std::string value = list->AsValue(true)->ToString();
- EXPECT_NE(value.find("\"items\":[\"TransformDisplayItem"), std::string::npos);
- EXPECT_NE(value.find("\"layer_rect\":[0,0,0,0]"), std::string::npos);
- // There should be one skp64 entry present associated with the test picture
- // item, though the overall list has no skp64 as the layer rect is empty.
+ EXPECT_EQ(value.find("visualRect: [0,0 42x42]"), std::string::npos);
EXPECT_NE(value.find("\"skp64\":"), std::string::npos);
-
- value = list->AsValue(false)->ToString();
- EXPECT_EQ(value.find("\"items\":"), std::string::npos);
- EXPECT_NE(value.find("\"layer_rect\":[0,0,0,0]"), std::string::npos);
- // There should be no skp64 entry present as the items aren't included and the
- // layer rect is empty.
- EXPECT_EQ(value.find("\"skp64\":"), std::string::npos);
}
} // namespace cc
« no previous file with comments | « cc/playback/display_item_list.cc ('k') | cc/playback/display_list_raster_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698