| Index: cc/paint/paint_op_buffer_unittest.cc
|
| diff --git a/cc/paint/paint_op_buffer_unittest.cc b/cc/paint/paint_op_buffer_unittest.cc
|
| index a962ab9d088ac37e69337b3a8330be4127fb82c3..c4bb3fb641989e6a95e6c02794b0e0f73d398221 100644
|
| --- a/cc/paint/paint_op_buffer_unittest.cc
|
| +++ b/cc/paint/paint_op_buffer_unittest.cc
|
| @@ -3,6 +3,8 @@
|
| // found in the LICENSE file.
|
|
|
| #include "cc/paint/paint_op_buffer.h"
|
| +#include "cc/paint/display_item_list.h"
|
| +#include "cc/test/skia_common.h"
|
| #include "cc/test/test_skcanvas.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -329,4 +331,49 @@ TEST(PaintOpBufferTest, SaveDrawRestore_SingleOpRecordWithSingleNonDrawOp) {
|
| EXPECT_EQ(1, canvas.restore_count_);
|
| }
|
|
|
| +TEST(PaintOpBufferTest, GathersDiscardableImagesFromNestedOps) {
|
| + sk_sp<PaintRecord> internal_record = sk_make_sp<PaintRecord>();
|
| + sk_sp<SkImage> discardable_image =
|
| + CreateDiscardableImage(gfx::Size(100, 100));
|
| + internal_record->push<DrawImageOp>(
|
| + PaintImage(discardable_image, PaintImage::AnimationType::STATIC,
|
| + PaintImage::CompletionState::DONE),
|
| + 0, 0, nullptr);
|
| +
|
| + sk_sp<PaintRecord> list_record = sk_make_sp<PaintRecord>();
|
| + sk_sp<SkImage> discardable_image2 =
|
| + CreateDiscardableImage(gfx::Size(100, 100));
|
| + list_record->push<DrawImageOp>(
|
| + PaintImage(discardable_image2, PaintImage::AnimationType::STATIC,
|
| + PaintImage::CompletionState::DONE),
|
| + 100, 100, nullptr);
|
| + scoped_refptr<DisplayItemList> display_list = new DisplayItemList;
|
| + display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>(
|
| + gfx::Rect(100, 100, 100, 100), list_record);
|
| + display_list->Finalize();
|
| +
|
| + PaintOpBuffer buffer;
|
| + buffer.push<DrawRecordOp>(internal_record);
|
| + buffer.push<DrawDisplayItemListOp>(display_list);
|
| + DiscardableImageMap image_map_;
|
| + {
|
| + DiscardableImageMap::ScopedMetadataGenerator generator(&image_map_,
|
| + gfx::Size(200, 200));
|
| + buffer.GatherDiscardableImages(generator.image_store());
|
| + }
|
| +
|
| + gfx::ColorSpace target_color_space;
|
| + std::vector<DrawImage> images;
|
| + image_map_.GetDiscardableImagesInRect(gfx::Rect(0, 0, 5, 95), 1.f,
|
| + target_color_space, &images);
|
| + EXPECT_EQ(1u, images.size());
|
| + EXPECT_TRUE(discardable_image == images[0].image());
|
| +
|
| + images.clear();
|
| + image_map_.GetDiscardableImagesInRect(gfx::Rect(105, 105, 5, 95), 1.f,
|
| + target_color_space, &images);
|
| + EXPECT_EQ(1u, images.size());
|
| + EXPECT_TRUE(discardable_image2 == images[0].image());
|
| +}
|
| +
|
| } // namespace cc
|
|
|