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

Unified Diff: tests/CodecTest.cpp

Issue 2319293003: Checking for valid colorType, alphaType, colorSpace in SkCodec (Closed)
Patch Set: Fix nanobench Created 4 years, 3 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 | « src/codec/SkWebpCodec.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/CodecTest.cpp
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp
index 9c60be4b6bf8ac8313297ccf9bf6939fb3c380a9..b01750d41074a42b7b4d4e9139f9bc42b741e1b5 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -1120,3 +1120,33 @@ DEF_TEST(Codec_PngRoundTrip, r) {
REPORTER_ASSERT(r, SkCodec::kSuccess == result);
check_round_trip(r, bm2);
}
+
+static void test_conversion_possible(skiatest::Reporter* r, const char* path,
+ bool testScanlineDecoder) {
+ SkAutoTDelete<SkStream> stream(resource(path));
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
+ SkImageInfo infoF16 = codec->getInfo().makeColorType(kRGBA_F16_SkColorType);
+
+ SkBitmap bm;
+ bm.allocPixels(infoF16);
+ SkCodec::Result result = codec->getPixels(infoF16, bm.getPixels(), bm.rowBytes());
+ REPORTER_ASSERT(r, SkCodec::kInvalidConversion == result);
+ if (testScanlineDecoder) {
+ result = codec->startScanlineDecode(infoF16);
+ REPORTER_ASSERT(r, SkCodec::kInvalidConversion == result);
+ }
+
+ infoF16 = infoF16.makeColorSpace(infoF16.colorSpace()->makeLinearGamma());
+ result = codec->getPixels(infoF16, bm.getPixels(), bm.rowBytes());
+ REPORTER_ASSERT(r, SkCodec::kSuccess == result);
+ if (testScanlineDecoder) {
+ result = codec->startScanlineDecode(infoF16);
+ REPORTER_ASSERT(r, SkCodec::kSuccess == result);
+ }
+}
+
+DEF_TEST(Codec_F16ConversionPossible, r) {
+ test_conversion_possible(r, "color_wheel.webp", false);
+ test_conversion_possible(r, "mandrill_512_q075.jpg", true);
+ test_conversion_possible(r, "yellow_rose.png", true);
+}
« no previous file with comments | « src/codec/SkWebpCodec.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698