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

Unified Diff: cc/playback/display_item_list_unittest.cc

Issue 1484163002: Raster display item lists via a visual rect RTree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review feedback. Created 4 years, 4 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
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 1bb6d3da481a11a42862b1302af358bf0ef20e85..bbdd5e799a7c14a63e660e6f4ce9f3daf65b1732 100644
--- a/cc/playback/display_item_list_unittest.cc
+++ b/cc/playback/display_item_list_unittest.cc
@@ -137,8 +137,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);
@@ -150,8 +151,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);
@@ -176,8 +178,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);
@@ -201,8 +204,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);
@@ -226,8 +230,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);
@@ -249,8 +254,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);
@@ -280,8 +286,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()));
@@ -323,8 +329,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()));
@@ -383,8 +388,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()));
@@ -436,10 +440,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());
sk_sp<SkSurface> source_surface = SkSurface::MakeRasterN32Premul(50, 50);
SkCanvas* source_canvas = source_surface->getCanvas();
@@ -495,9 +497,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 =
sk_ref_sp(recorder.beginRecording(gfx::RectFToSkRect(recording_rect)));
@@ -514,7 +515,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();
@@ -543,7 +544,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();
@@ -553,43 +554,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);
@@ -600,55 +594,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_EQ(value.find("visualRect: [0,0 42x42]"), 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_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

Powered by Google App Engine
This is Rietveld 408576698