| 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 41ae5bac507e18667b0997203bd662a9ff52499b..b383b7ef58efd725d8740b1d2c768307f03da99b 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());
|
|
|
| sk_sp<SkSurface> source_surface = SkSurface::MakeRasterN32Premul(50, 50);
|
| SkCanvas* source_canvas = source_surface->getCanvas();
|
| @@ -477,9 +479,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)));
|
| @@ -496,7 +497,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();
|
| @@ -525,7 +526,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();
|
| @@ -535,43 +536,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);
|
| @@ -582,55 +576,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
|
|
|