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

Unified Diff: tests/CodecTest.cpp

Issue 2247743002: Fix color xform width bug when scaling/subsetting (Closed) Base URL: https://skia.googlesource.com/skia.git@skipstuff
Patch Set: Rebase 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
« no previous file with comments | « src/codec/SkSwizzler.h ('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 a6b44eb9a7506187e5e248f74e2482b8351662da..8023ff219d5873632db3708054a850fe4e8d3025 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -1044,6 +1044,36 @@ DEF_TEST(Codec_jpeg_rewind, r) {
REPORTER_ASSERT(r, SkCodec::kSuccess == result);
}
+static void check_color_xform(skiatest::Reporter* r, const char* path) {
+ SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(resource(path)));
+
+ SkAndroidCodec::AndroidOptions opts;
+ opts.fSampleSize = 3;
+ const int subsetWidth = codec->getInfo().width() / 2;
+ const int subsetHeight = codec->getInfo().height() / 2;
+ SkIRect subset = SkIRect::MakeWH(subsetWidth, subsetHeight);
+ opts.fSubset = &subset;
+
+ const int dstWidth = subsetWidth / opts.fSampleSize;
+ const int dstHeight = subsetHeight / opts.fSampleSize;
+ sk_sp<SkData> data = SkData::MakeFromFileName(
+ GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str());
+ sk_sp<SkColorSpace> colorSpace = SkColorSpace::NewICC(data->data(), data->size());
+ SkImageInfo dstInfo = codec->getInfo().makeWH(dstWidth, dstHeight)
+ .makeColorType(kN32_SkColorType)
+ .makeColorSpace(colorSpace);
+
+ size_t rowBytes = dstInfo.minRowBytes();
+ SkAutoMalloc pixelStorage(dstInfo.getSafeSize(rowBytes));
+ SkCodec::Result result = codec->getAndroidPixels(dstInfo, pixelStorage.get(), rowBytes, &opts);
+ REPORTER_ASSERT(r, SkCodec::kSuccess == result);
+}
+
+DEF_TEST(Codec_ColorXform, r) {
+ check_color_xform(r, "mandrill_512_q075.jpg");
+ check_color_xform(r, "mandrill_512.png");
+}
+
DEF_TEST(Codec_Png565, r) {
// Create an arbitrary 565 bitmap.
const char* path = "mandrill_512_q075.jpg";
« no previous file with comments | « src/codec/SkSwizzler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698