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

Unified Diff: Source/platform/graphics/ImageFrameGeneratorTest.cpp

Issue 688423004: Remove multi-frame image decoder when the image is completely decoded (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix DeferredImageDecoderTest crash Created 6 years, 1 month 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 | « Source/platform/graphics/ImageFrameGenerator.cpp ('k') | Source/platform/graphics/test/MockImageDecoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/ImageFrameGeneratorTest.cpp
diff --git a/Source/platform/graphics/ImageFrameGeneratorTest.cpp b/Source/platform/graphics/ImageFrameGeneratorTest.cpp
index e49be9b60581d1cf76f96d6f1e1251709b8e6013..129dfd67b79fe0b3fc7545cf0abe28600a5a1a41 100644
--- a/Source/platform/graphics/ImageFrameGeneratorTest.cpp
+++ b/Source/platform/graphics/ImageFrameGeneratorTest.cpp
@@ -59,6 +59,7 @@ public:
m_decodersDestroyed = 0;
m_frameBufferRequestCount = 0;
m_status = ImageFrame::FrameEmpty;
+ m_frameCount = 1;
}
virtual void TearDown() override
@@ -83,8 +84,8 @@ public:
return currentStatus;
}
- virtual size_t frameCount() override { return 1; }
- virtual int repetitionCount() const override { return cAnimationNone; }
+ virtual size_t frameCount() override { return m_frameCount; }
+ virtual int repetitionCount() const override { return m_frameCount == 1 ? cAnimationNone:cAnimationLoopOnce; }
virtual float frameDuration() const override { return 0; }
protected:
@@ -101,6 +102,15 @@ protected:
void setFrameStatus(ImageFrame::Status status) { m_status = m_nextFrameStatus = status; }
void setNextFrameStatus(ImageFrame::Status status) { m_nextFrameStatus = status; }
+ void setFrameCount(size_t count)
+ {
+ m_frameCount = count;
+ if (count > 1) {
+ m_generator.clear();
+ m_generator = ImageFrameGenerator::create(fullSize(), m_data, true, true);
+ useMockImageDecoderFactory();
+ }
+ }
RefPtr<SharedBuffer> m_data;
RefPtr<ImageFrameGenerator> m_generator;
@@ -108,6 +118,7 @@ protected:
int m_frameBufferRequestCount;
ImageFrame::Status m_status;
ImageFrame::Status m_nextFrameStatus;
+ size_t m_frameCount;
};
TEST_F(ImageFrameGeneratorTest, incompleteDecode)
@@ -179,8 +190,8 @@ TEST_F(ImageFrameGeneratorTest, frameHasAlpha)
setFrameStatus(ImageFrame::FramePartial);
char buffer[100 * 100 * 4];
- m_generator->decodeAndScale(imageInfo(), 1, buffer, 100 * 4);
- EXPECT_TRUE(m_generator->hasAlpha(1));
+ m_generator->decodeAndScale(imageInfo(), 0, buffer, 100 * 4);
+ EXPECT_TRUE(m_generator->hasAlpha(0));
EXPECT_EQ(1, m_frameBufferRequestCount);
ImageDecoder* tempDecoder = 0;
@@ -190,9 +201,33 @@ TEST_F(ImageFrameGeneratorTest, frameHasAlpha)
ImageDecodingStore::instance()->unlockDecoder(m_generator.get(), tempDecoder);
setFrameStatus(ImageFrame::FrameComplete);
+ m_generator->decodeAndScale(imageInfo(), 0, buffer, 100 * 4);
+ EXPECT_EQ(2, m_frameBufferRequestCount);
+ EXPECT_FALSE(m_generator->hasAlpha(0));
+}
+
+TEST_F(ImageFrameGeneratorTest, removeMultiFrameDecoder)
+{
+ setFrameCount(3);
+ setFrameStatus(ImageFrame::FrameComplete);
+
+ char buffer[100 * 100 * 4];
+ m_generator->decodeAndScale(imageInfo(), 0, buffer, 100 * 4);
+ EXPECT_EQ(1, m_frameBufferRequestCount);
+ EXPECT_EQ(0, m_decodersDestroyed);
+
+ setFrameStatus(ImageFrame::FrameComplete);
+
m_generator->decodeAndScale(imageInfo(), 1, buffer, 100 * 4);
EXPECT_EQ(2, m_frameBufferRequestCount);
- EXPECT_FALSE(m_generator->hasAlpha(1));
+ EXPECT_EQ(0, m_decodersDestroyed);
+
+ setFrameStatus(ImageFrame::FrameComplete);
+
+ // Multi frame decoder should be removed.
+ m_generator->decodeAndScale(imageInfo(), 2, buffer, 100 * 4);
+ EXPECT_EQ(3, m_frameBufferRequestCount);
+ EXPECT_EQ(1, m_decodersDestroyed);
}
} // namespace blink
« no previous file with comments | « Source/platform/graphics/ImageFrameGenerator.cpp ('k') | Source/platform/graphics/test/MockImageDecoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698