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

Unified Diff: cc/paint/paint_op_buffer_unittest.cc

Issue 2830243002: cc: Don't perform image analysis if the DisplayItemList has no images. (Closed)
Patch Set: rebase Created 3 years, 7 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/paint/paint_op_buffer.cc ('k') | cc/paint/transform_display_item.cc » ('j') | 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 9f77775e509b6e2de840dcfa6440b24a4406299a..6c0de66a73c3bd6716f40f881b1986218931bbe8 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"
@@ -417,4 +419,60 @@ TEST(PaintOpBufferTest, SaveDrawRestore_SingleOpRecordWithSingleNonDrawOp) {
EXPECT_EQ(1, canvas.restore_count_);
}
+TEST(PaintOpBufferTest, DiscardableImagesTracking_EmptyBuffer) {
+ PaintOpBuffer buffer;
+ EXPECT_FALSE(buffer.HasDiscardableImages());
+}
+
+TEST(PaintOpBufferTest, DiscardableImagesTracking_NoImageOp) {
+ PaintOpBuffer buffer;
+ PaintFlags flags;
+ buffer.push<DrawRectOp>(SkRect::MakeWH(100, 100), flags);
+ EXPECT_FALSE(buffer.HasDiscardableImages());
+}
+
+TEST(PaintOpBufferTest, DiscardableImagesTracking_DrawImage) {
+ PaintOpBuffer buffer;
+ PaintImage image = PaintImage(CreateDiscardableImage(gfx::Size(100, 100)));
+ buffer.push<DrawImageOp>(image, SkIntToScalar(0), SkIntToScalar(0), nullptr);
+ EXPECT_TRUE(buffer.HasDiscardableImages());
+}
+
+TEST(PaintOpBufferTest, DiscardableImagesTracking_DrawImageRect) {
+ PaintOpBuffer buffer;
+ PaintImage image = PaintImage(CreateDiscardableImage(gfx::Size(100, 100)));
+ buffer.push<DrawImageRectOp>(
+ image, SkRect::MakeWH(100, 100), SkRect::MakeWH(100, 100), nullptr,
+ PaintCanvas::SrcRectConstraint::kFast_SrcRectConstraint);
+ EXPECT_TRUE(buffer.HasDiscardableImages());
+}
+
+TEST(PaintOpBufferTest, DiscardableImagesTracking_NestedDrawOp) {
+ sk_sp<PaintRecord> record = sk_make_sp<PaintRecord>();
+ PaintImage image = PaintImage(CreateDiscardableImage(gfx::Size(100, 100)));
+ record->push<DrawImageOp>(image, SkIntToScalar(0), SkIntToScalar(0), nullptr);
+
+ PaintOpBuffer buffer;
+ buffer.push<DrawRecordOp>(record);
+ EXPECT_TRUE(buffer.HasDiscardableImages());
+
+ scoped_refptr<DisplayItemList> list = new DisplayItemList;
+ list->CreateAndAppendDrawingItem<DrawingDisplayItem>(
+ gfx::Rect(0, 0, 100, 100), record);
+ list->Finalize();
+ PaintOpBuffer new_buffer;
+ new_buffer.push<DrawDisplayItemListOp>(list);
+ EXPECT_TRUE(new_buffer.HasDiscardableImages());
+}
+
+TEST(PaintOpBufferTest, DiscardableImagesTracking_OpWithFlags) {
+ PaintOpBuffer buffer;
+ PaintFlags flags;
+ sk_sp<SkImage> image = CreateDiscardableImage(gfx::Size(100, 100));
+ flags.setShader(
+ image->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode));
+ buffer.push<DrawRectOp>(SkRect::MakeWH(100, 100), flags);
+ EXPECT_TRUE(buffer.HasDiscardableImages());
+}
+
} // namespace cc
« no previous file with comments | « cc/paint/paint_op_buffer.cc ('k') | cc/paint/transform_display_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698