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

Unified Diff: tests/CodecTest.cpp

Issue 2212563003: Modify SkPngCodec to recognize 565 images from the sBIT chunk (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Clean up test Created 4 years, 4 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
« include/codec/SkEncodedInfo.h ('K') | « src/codec/SkSwizzler.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 a5df7e3b50a9e00291966f1a578b637bef7f7cce..27a6e10b89fe659fdb0db9fab92a7538d3d412b9 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -11,6 +11,7 @@
#include "SkCodec.h"
#include "SkCodecImageGenerator.h"
#include "SkData.h"
+#include "SkImageEncoder.h"
#include "SkFrontBufferedStream.h"
#include "SkMD5.h"
#include "SkRandom.h"
@@ -1042,3 +1043,39 @@ DEF_TEST(Codec_jpeg_rewind, r) {
SkCodec::Result result = codec->getPixels(codec->getInfo(), pixelStorage.get(), rowBytes);
REPORTER_ASSERT(r, SkCodec::kSuccess == result);
}
+
+#if !defined(SK_BUILD_FOR_WIN) && !defined(SK_BUILD_FOR_MAC) && !defined(SK_BUILD_FOR_IOS)
+
+// We need to disable this test on Mac and Windows because CG and WIC do not encode 565 as 565.
mtklein 2016/08/04 17:52:51 encode -> tag? We can't ask them to nicely can we
msarett 2016/08/04 19:04:10 I would be in favor of using our encoder as the de
+DEF_TEST(Codec_Png565, r) {
+ // Create an arbitrary 565 bitmap.
+ const char* path = "mandrill_512_q075.jpg";
+ SkAutoTDelete<SkStream> stream(resource(path));
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
+ SkImageInfo info565 = codec->getInfo().makeColorType(kRGB_565_SkColorType);
+ SkBitmap bm1;
+ bm1.allocPixels(info565);
+ SkCodec::Result result = codec->getPixels(info565, bm1.getPixels(), bm1.rowBytes());
+ REPORTER_ASSERT(r, SkCodec::kSuccess == result);
+
+ // Encode the image to png.
+ sk_sp<SkData> data =
+ sk_sp<SkData>(SkImageEncoder::EncodeData(bm1, SkImageEncoder::kPNG_Type, 100));
+
+ // Prepare to decode. The codec should recognize that the PNG is 565.
+ codec.reset(SkCodec::NewFromData(data.get()));
+ REPORTER_ASSERT(r, kRGB_565_SkColorType == codec->getInfo().colorType());
+ REPORTER_ASSERT(r, kOpaque_SkAlphaType == codec->getInfo().alphaType());
+
+ SkBitmap bm2;
+ bm2.allocPixels(codec->getInfo());
+ result = codec->getPixels(codec->getInfo(), bm2.getPixels(), bm2.rowBytes());
+ REPORTER_ASSERT(r, SkCodec::kSuccess == result);
+
+ SkMD5::Digest d1, d2;
+ md5(bm1, &d1);
+ md5(bm2, &d2);
+ REPORTER_ASSERT(r, d1 == d2);
+}
+
+#endif
« include/codec/SkEncodedInfo.h ('K') | « src/codec/SkSwizzler.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698