Revert of Revert of Add gamma/sRGB tag to SkImageInfo (patchset #1 id:1 of https://codereview.chromium.org/525113005/)
Reason for revert:
Experiment to see resulting failures
Original issue's description:
> Revert of Add gamma/sRGB tag to SkImageInfo (patchset #1 id:1 of https://codereview.chromium.org/522813002/)
>
> Reason for revert:
> seems to be breaking layout tests in roll
>
> Original issue's description:
> > Add gamma/sRGB tag to SkImageInfo
> >
> > This reverts commit 64ba5fa1ff428858f803523257cd862f8b33423b.
> >
> > BUG=skia:
> >
> > Committed: https://skia.googlesource.com/skia/+/c89aa509d6a094bc1b18d73135343819903a9cfb
>
> TBR=reed@google.com
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/b44c1895afae516cb851cd1a0cea83343c354ee4
R=reed@google.com
TBR=reed@google.com
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Author: reed@chromium.org
Review URL: https://codereview.chromium.org/532583002
diff --git a/tests/ImageInfoTest.cpp b/tests/ImageInfoTest.cpp
new file mode 100644
index 0000000..679b302
--- /dev/null
+++ b/tests/ImageInfoTest.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkImageInfo.h"
+
+#include "Test.h"
+
+struct ImageInfoRec {
+ int fWidth;
+ int fHeight;
+ SkColorType fColorType;
+ SkAlphaType fAlphaType;
+ float fGamma;
+ bool fIsSRGB;
+};
+
+static void check_info(skiatest::Reporter* reporter,
+ const ImageInfoRec& expected, const SkImageInfo& info) {
+ REPORTER_ASSERT(reporter, info.width() == expected.fWidth);
+ REPORTER_ASSERT(reporter, info.height() == expected.fHeight);
+ REPORTER_ASSERT(reporter, info.colorType() == expected.fColorType);
+ REPORTER_ASSERT(reporter, info.alphaType() == expected.fAlphaType);
+ REPORTER_ASSERT(reporter, info.gamma() == expected.fGamma);
+ REPORTER_ASSERT(reporter, info.isSRGB() == expected.fIsSRGB);
+}
+
+DEF_TEST(ImageInfo, reporter) {
+ const float nan = SK_ScalarNaN;
+ const float nice_gamma = 1.5f;
+ const int W = 100;
+ const int H = 200;
+ SkImageInfo info;
+
+ const ImageInfoRec rec[] = {
+ { 0, 0, kUnknown_SkColorType, kIgnore_SkAlphaType, 0, false }, // MakeUnknown()
+ { W, H, kUnknown_SkColorType, kIgnore_SkAlphaType, 0, false }, // MakeUnknown(...)
+ { W, H, kN32_SkColorType, kPremul_SkAlphaType, 1, false }, // MakeN32Premul(...)
+ { W, H, kN32_SkColorType, kOpaque_SkAlphaType, 1, false }, // MakeN32(...)
+ { W, H, kAlpha_8_SkColorType, kPremul_SkAlphaType, 0, false }, // MakeA8()
+ { W, H, kRGBA_8888_SkColorType, kUnpremul_SkAlphaType, 1, false }, // Make()
+ { W, H, kBGRA_8888_SkColorType, kPremul_SkAlphaType, 1, false }, // Make()
+ { W, H, kBGRA_8888_SkColorType, kPremul_SkAlphaType, 0, true }, // MakeSRGB()
+ { W, H, kN32_SkColorType, kPremul_SkAlphaType, 1, false }, // MakeWithGamma() NaN
+ { W, H, kAlpha_8_SkColorType, kPremul_SkAlphaType, 0, false }, // MakeWithGamma() bad ct for gamma
+ { W, H, kN32_SkColorType, kPremul_SkAlphaType, nice_gamma, false }, // MakeWithGamma() good
+ };
+
+ check_info(reporter, rec[ 0], SkImageInfo::MakeUnknown());
+ check_info(reporter, rec[ 1], SkImageInfo::MakeUnknown(W, H));
+ check_info(reporter, rec[ 2], SkImageInfo::MakeN32Premul(W, H));
+ check_info(reporter, rec[ 3], SkImageInfo::MakeN32(W, H, rec[3].fAlphaType));
+ check_info(reporter, rec[ 4], SkImageInfo::MakeA8(W, H));
+ check_info(reporter, rec[ 5], SkImageInfo::Make(W, H, rec[5].fColorType, rec[5].fAlphaType));
+ check_info(reporter, rec[ 6], SkImageInfo::Make(W, H, rec[6].fColorType, rec[6].fAlphaType));
+ check_info(reporter, rec[ 7], SkImageInfo::MakeSRGB(W, H, rec[7].fColorType, rec[7].fAlphaType));
+ check_info(reporter, rec[ 8], SkImageInfo::MakeWithGamma(W, H, rec[8].fColorType, rec[8].fAlphaType, nan));
+ check_info(reporter, rec[ 9], SkImageInfo::MakeWithGamma(W, H, rec[9].fColorType, rec[9].fAlphaType, nice_gamma));
+ check_info(reporter, rec[10], SkImageInfo::MakeWithGamma(W, H, rec[10].fColorType, rec[10].fAlphaType, rec[10].fGamma));
+}
+