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

Unified Diff: third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoderTest.cpp

Issue 1820733004: Propagate the decoder frame premul info to SkBitmap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 9 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 | « third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoderTest.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoderTest.cpp b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoderTest.cpp
index 92d0d5826a12cbc575a8d55bf56a5feefed3322c..9a0d7dc5a67480e39e8406169387b2a65c6c8ce1 100644
--- a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoderTest.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoderTest.cpp
@@ -516,4 +516,50 @@ TEST(GIFImageDecoderTest, verifyRepetitionCount)
EXPECT_EQ(expectedRepetitionCount, decoder->repetitionCount()); // Expected value after decode.
}
+TEST(GIFImageDecoderTest, bitmapAlphaType)
+{
+ RefPtr<SharedBuffer> fullData = readFile(decodersTestingDir, "radient.gif");
+ ASSERT_TRUE(fullData.get());
+
+ // Empirically chosen truncation size:
+ // a) large enough to produce a partial frame &&
+ // b) small enough to not fully decode the frame
+ const size_t kTruncateSize = 800;
+ ASSERT_TRUE(kTruncateSize < fullData->size());
+ RefPtr<SharedBuffer> partialData = SharedBuffer::create(fullData->data(), kTruncateSize);
+
+ OwnPtr<ImageDecoder> premulDecoder = adoptPtr(new GIFImageDecoder(
+ ImageDecoder::AlphaPremultiplied,
+ ImageDecoder::GammaAndColorProfileApplied,
+ ImageDecoder::noDecodedImageByteLimit));
+ OwnPtr<ImageDecoder> unpremulDecoder = adoptPtr(new GIFImageDecoder(
+ ImageDecoder::AlphaNotPremultiplied,
+ ImageDecoder::GammaAndColorProfileApplied,
+ ImageDecoder::noDecodedImageByteLimit));
+
+ // Partially decoded frame => the frame alpha type is unknown and should reflect the requested format.
+ premulDecoder->setData(partialData.get(), false);
+ ASSERT_TRUE(premulDecoder->frameCount());
+ unpremulDecoder->setData(partialData.get(), false);
+ ASSERT_TRUE(unpremulDecoder->frameCount());
+ ImageFrame* premulFrame = premulDecoder->frameBufferAtIndex(0);
+ EXPECT_TRUE(premulFrame && premulFrame->getStatus() != ImageFrame::FrameComplete);
+ EXPECT_EQ(premulFrame->bitmap().alphaType(), kPremul_SkAlphaType);
+ ImageFrame* unpremulFrame = unpremulDecoder->frameBufferAtIndex(0);
+ EXPECT_TRUE(unpremulFrame && unpremulFrame->getStatus() != ImageFrame::FrameComplete);
+ EXPECT_EQ(unpremulFrame->bitmap().alphaType(), kUnpremul_SkAlphaType);
+
+ // Fully decoded frame => the frame alpha type is known (opaque).
+ premulDecoder->setData(fullData.get(), true);
+ ASSERT_TRUE(premulDecoder->frameCount());
+ unpremulDecoder->setData(fullData.get(), true);
+ ASSERT_TRUE(unpremulDecoder->frameCount());
+ premulFrame = premulDecoder->frameBufferAtIndex(0);
+ EXPECT_TRUE(premulFrame && premulFrame->getStatus() == ImageFrame::FrameComplete);
+ EXPECT_EQ(premulFrame->bitmap().alphaType(), kOpaque_SkAlphaType);
+ unpremulFrame = unpremulDecoder->frameBufferAtIndex(0);
+ EXPECT_TRUE(unpremulFrame && unpremulFrame->getStatus() == ImageFrame::FrameComplete);
+ EXPECT_EQ(unpremulFrame->bitmap().alphaType(), kOpaque_SkAlphaType);
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698