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

Unified Diff: cc/playback/display_item_list_unittest.cc

Issue 2217263003: Revert "Raster display item lists via a visual rect RTree." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restore NeedsRebaseline entries. 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
« no previous file with comments | « cc/playback/display_item_list.cc ('k') | cc/playback/recording_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 bbdd5e799a7c14a63e660e6f4ce9f3daf65b1732..1bb6d3da481a11a42862b1302af358bf0ef20e85 100644
--- a/cc/playback/display_item_list_unittest.cc
+++ b/cc/playback/display_item_list_unittest.cc
@@ -137,9 +137,8 @@ TEST(DisplayItemListTest, SerializeSingleDrawingItem) {
gfx::Size layer_size(10, 10);
DisplayItemListSettings settings;
- settings.use_cached_picture = true;
- scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
- list->SetRetainVisualRectsForTesting(true);
+ scoped_refptr<DisplayItemList> list =
+ DisplayItemList::Create(gfx::Rect(layer_size), settings);
// Build the DrawingDisplayItem.
AppendFirstSerializationTestPicture(list, layer_size);
@@ -151,9 +150,8 @@ TEST(DisplayItemListTest, SerializeClipItem) {
gfx::Size layer_size(10, 10);
DisplayItemListSettings settings;
- settings.use_cached_picture = true;
- scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
- list->SetRetainVisualRectsForTesting(true);
+ scoped_refptr<DisplayItemList> list =
+ DisplayItemList::Create(gfx::Rect(layer_size), settings);
// Build the DrawingDisplayItem.
AppendFirstSerializationTestPicture(list, layer_size);
@@ -178,9 +176,8 @@ TEST(DisplayItemListTest, SerializeClipPathItem) {
gfx::Size layer_size(10, 10);
DisplayItemListSettings settings;
- settings.use_cached_picture = true;
- scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
- list->SetRetainVisualRectsForTesting(true);
+ scoped_refptr<DisplayItemList> list =
+ DisplayItemList::Create(gfx::Rect(layer_size), settings);
// Build the DrawingDisplayItem.
AppendFirstSerializationTestPicture(list, layer_size);
@@ -204,9 +201,8 @@ TEST(DisplayItemListTest, SerializeCompositingItem) {
gfx::Size layer_size(10, 10);
DisplayItemListSettings settings;
- settings.use_cached_picture = true;
- scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
- list->SetRetainVisualRectsForTesting(true);
+ scoped_refptr<DisplayItemList> list =
+ DisplayItemList::Create(gfx::Rect(layer_size), settings);
// Build the DrawingDisplayItem.
AppendFirstSerializationTestPicture(list, layer_size);
@@ -230,9 +226,8 @@ TEST(DisplayItemListTest, SerializeFloatClipItem) {
gfx::Size layer_size(10, 10);
DisplayItemListSettings settings;
- settings.use_cached_picture = true;
- scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
- list->SetRetainVisualRectsForTesting(true);
+ scoped_refptr<DisplayItemList> list =
+ DisplayItemList::Create(gfx::Rect(layer_size), settings);
// Build the DrawingDisplayItem.
AppendFirstSerializationTestPicture(list, layer_size);
@@ -254,9 +249,8 @@ TEST(DisplayItemListTest, SerializeTransformItem) {
gfx::Size layer_size(10, 10);
DisplayItemListSettings settings;
- settings.use_cached_picture = true;
- scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
- list->SetRetainVisualRectsForTesting(true);
+ scoped_refptr<DisplayItemList> list =
+ DisplayItemList::Create(gfx::Rect(layer_size), settings);
// Build the DrawingDisplayItem.
AppendFirstSerializationTestPicture(list, layer_size);
@@ -286,8 +280,8 @@ TEST(DisplayItemListTest, SingleDrawingItem) {
red_paint.setColor(SK_ColorRED);
unsigned char pixels[4 * 100 * 100] = {0};
DisplayItemListSettings settings;
- settings.use_cached_picture = true;
- scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
+ scoped_refptr<DisplayItemList> list =
+ DisplayItemList::Create(layer_rect, settings);
gfx::PointF offset(8.f, 9.f);
gfx::RectF recording_rect(offset, gfx::SizeF(layer_rect.size()));
@@ -329,7 +323,8 @@ TEST(DisplayItemListTest, ClipItem) {
unsigned char pixels[4 * 100 * 100] = {0};
DisplayItemListSettings settings;
settings.use_cached_picture = true;
- scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
+ scoped_refptr<DisplayItemList> list =
+ DisplayItemList::Create(layer_rect, settings);
gfx::PointF first_offset(8.f, 9.f);
gfx::RectF first_recording_rect(first_offset, gfx::SizeF(layer_rect.size()));
@@ -388,7 +383,8 @@ TEST(DisplayItemListTest, TransformItem) {
unsigned char pixels[4 * 100 * 100] = {0};
DisplayItemListSettings settings;
settings.use_cached_picture = true;
- scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
+ scoped_refptr<DisplayItemList> list =
+ DisplayItemList::Create(layer_rect, settings);
gfx::PointF first_offset(8.f, 9.f);
gfx::RectF first_recording_rect(first_offset, gfx::SizeF(layer_rect.size()));
@@ -440,8 +436,10 @@ 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(DisplayItemListSettings());
+ DisplayItemList::Create(layer_rect, settings);
sk_sp<SkSurface> source_surface = SkSurface::MakeRasterN32Premul(50, 50);
SkCanvas* source_canvas = source_surface->getCanvas();
@@ -497,8 +495,9 @@ 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(no_caching_settings);
+ DisplayItemList::Create(layer_rect, no_caching_settings);
canvas =
sk_ref_sp(recorder.beginRecording(gfx::RectFToSkRect(recording_rect)));
@@ -515,7 +514,7 @@ TEST(DisplayItemListTest, CompactingItems) {
DisplayItemListSettings caching_settings;
caching_settings.use_cached_picture = true;
scoped_refptr<DisplayItemList> list_with_caching =
- DisplayItemList::Create(caching_settings);
+ DisplayItemList::Create(layer_rect, caching_settings);
list_with_caching->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
picture);
list_with_caching->Finalize();
@@ -544,7 +543,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(caching_settings);
+ list = DisplayItemList::Create(layer_rect, caching_settings);
list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect, picture);
list->Finalize();
memory_usage = list->ApproximateMemoryUsage();
@@ -554,36 +553,43 @@ 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(no_caching_settings);
+ list = DisplayItemList::Create(layer_rect, 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, AsValueWithNoItems) {
+TEST(DisplayItemListTest, AsValueWithRectAndNoItems) {
scoped_refptr<DisplayItemList> list =
- DisplayItemList::Create(DisplayItemListSettings());
- list->SetRetainVisualRectsForTesting(true);
+ DisplayItemList::Create(gfx::Rect(1, 2, 8, 9), DisplayItemListSettings());
list->Finalize();
std::string value = list->AsValue(true)->ToString();
EXPECT_NE(value.find("\"items\":[]"), std::string::npos);
- EXPECT_EQ(value.find("visualRect: [0,0 42x42]"), std::string::npos);
+ EXPECT_NE(value.find("\"layer_rect\":[1,2,8,9]"), 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_EQ(value.find("visualRect: [0,0 42x42]"), 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, AsValueWithItems) {
+TEST(DisplayItemListTest, AsValueWithRectAndItems) {
gfx::Rect layer_rect = gfx::Rect(1, 2, 8, 9);
scoped_refptr<DisplayItemList> list =
- DisplayItemList::Create(DisplayItemListSettings());
- list->SetRetainVisualRectsForTesting(true);
+ DisplayItemList::Create(layer_rect, DisplayItemListSettings());
gfx::Transform transform;
transform.Translate(6.f, 7.f);
list->CreateAndAppendItem<TransformDisplayItem>(kVisualRect, transform);
@@ -594,14 +600,55 @@ TEST(DisplayItemListTest, AsValueWithItems) {
std::string value = list->AsValue(true)->ToString();
EXPECT_NE(value.find("{\"items\":[\"TransformDisplayItem"),
std::string::npos);
- EXPECT_NE(value.find("visualRect: [0,0 42x42]"), std::string::npos);
+ EXPECT_NE(value.find("\"layer_rect\":[1,2,8,9]"), 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_EQ(value.find("visualRect: [0,0 42x42]"), 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_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/recording_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698