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

Unified Diff: cc/paint/paint_op_buffer_unittest.cc

Issue 2842333003: cc: Update discardable image metadata generation to get PaintImages. (Closed)
Patch Set: Created 3 years, 8 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
« cc/paint/paint_op_buffer.cc ('K') | « cc/paint/paint_op_buffer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« cc/paint/paint_op_buffer.cc ('K') | « cc/paint/paint_op_buffer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698