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

Unified Diff: tests/ColorSpaceTest.cpp

Issue 2067833003: Differentiate between sRGBGamma and 2Dot2Gamma (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix DefaultXform Created 4 years, 6 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/core/SkMipMap.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ColorSpaceTest.cpp
diff --git a/tests/ColorSpaceTest.cpp b/tests/ColorSpaceTest.cpp
index 6dd4789a8e5f9b5da0e1ca87da141a878f59b455..b06dc642fb5cd57974ec7c8ed133c1dfccb56113 100644
--- a/tests/ColorSpaceTest.cpp
+++ b/tests/ColorSpaceTest.cpp
@@ -19,12 +19,9 @@ static bool almost_equal(float a, float b) {
static void test_space(skiatest::Reporter* r, SkColorSpace* space,
const float red[], const float green[], const float blue[],
- const float expectedGammas[]) {
+ const SkColorSpace::GammaNamed expectedGamma) {
- const sk_sp<SkGammas>& gammas = as_CSB(space)->gammas();
- REPORTER_ASSERT(r, almost_equal(expectedGammas[0], gammas->fRed.fValue));
- REPORTER_ASSERT(r, almost_equal(expectedGammas[1], gammas->fGreen.fValue));
- REPORTER_ASSERT(r, almost_equal(expectedGammas[2], gammas->fBlue.fValue));
+ REPORTER_ASSERT(r, expectedGamma == space->gammaNamed());
SkMatrix44 mat = space->xyz();
@@ -46,11 +43,9 @@ const float g_sRGB_XYZ[] = { 0.4358f, 0.2224f, 0.0139f, // R
0.3853f, 0.7170f, 0.0971f, // G
0.1430f, 0.0606f, 0.7139f }; // B
-const float g_sRGB_gamma[] = { 2.2f, 2.2f, 2.2f };
-
DEF_TEST(ColorSpace_sRGB, r) {
test_space(r, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).get(),
- g_sRGB_XYZ, &g_sRGB_XYZ[3], &g_sRGB_XYZ[6], g_sRGB_gamma);
+ g_sRGB_XYZ, &g_sRGB_XYZ[3], &g_sRGB_XYZ[6], SkColorSpace::kSRGB_GammaNamed);
}
@@ -73,7 +68,8 @@ DEF_TEST(ColorSpaceParsePngICCProfile, r) {
SkColorSpace* colorSpace = codec->getColorSpace();
REPORTER_ASSERT(r, nullptr != colorSpace);
- test_space(r, colorSpace, &g_sRGB_XYZ[0], &g_sRGB_XYZ[3], &g_sRGB_XYZ[6], g_sRGB_gamma);
+ test_space(r, colorSpace, &g_sRGB_XYZ[0], &g_sRGB_XYZ[3], &g_sRGB_XYZ[6],
+ SkColorSpace::kSRGB_GammaNamed);
#endif
}
@@ -96,7 +92,7 @@ DEF_TEST(ColorSpaceParseJpegICCProfile, r) {
const float red[] = { 0.385117f, 0.716904f, 0.0970612f };
const float green[] = { 0.143051f, 0.0606079f, 0.713913f };
const float blue[] = { 0.436035f, 0.222488f, 0.013916f };
- test_space(r, colorSpace, red, green, blue, g_sRGB_gamma);
+ test_space(r, colorSpace, red, green, blue, SkColorSpace::k2Dot2Curve_GammaNamed);
}
DEF_TEST(ColorSpaceSRGBCompare, r) {
@@ -106,12 +102,14 @@ DEF_TEST(ColorSpaceSRGBCompare, r) {
// Create an sRGB color space by value
SkMatrix44 srgbToxyzD50(SkMatrix44::kUninitialized_Constructor);
srgbToxyzD50.set3x3ColMajorf(g_sRGB_XYZ);
- sk_sp<SkColorSpace> rgbColorSpace = SkColorSpace::NewRGB(g_sRGB_gamma, srgbToxyzD50);
+ sk_sp<SkColorSpace> rgbColorSpace = SkColorSpace::NewRGB(SkColorSpace::kSRGB_GammaNamed,
+ srgbToxyzD50);
REPORTER_ASSERT(r, rgbColorSpace == namedColorSpace);
// Change a single value from the sRGB matrix
srgbToxyzD50.set(2, 2, 0.5f);
- sk_sp<SkColorSpace> strangeColorSpace = SkColorSpace::NewRGB(g_sRGB_gamma, srgbToxyzD50);
+ sk_sp<SkColorSpace> strangeColorSpace = SkColorSpace::NewRGB(SkColorSpace::kSRGB_GammaNamed,
+ srgbToxyzD50);
REPORTER_ASSERT(r, strangeColorSpace != namedColorSpace);
}
@@ -120,8 +118,10 @@ DEF_TEST(ColorSpaceWriteICC, r) {
sk_sp<SkColorSpace> namedColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
sk_sp<SkData> namedData = as_CSB(namedColorSpace)->writeToICC();
sk_sp<SkColorSpace> iccColorSpace = SkColorSpace::NewICC(namedData->data(), namedData->size());
- test_space(r, iccColorSpace.get(), g_sRGB_XYZ, &g_sRGB_XYZ[3], &g_sRGB_XYZ[6], g_sRGB_gamma);
- REPORTER_ASSERT(r, iccColorSpace == namedColorSpace);
+ test_space(r, iccColorSpace.get(), g_sRGB_XYZ, &g_sRGB_XYZ[3], &g_sRGB_XYZ[6],
+ SkColorSpace::k2Dot2Curve_GammaNamed);
+ // FIXME (msarett): Test disabled. sRGB profiles are written approximately as 2.2f curves.
+ // REPORTER_ASSERT(r, iccColorSpace == namedColorSpace);
// Test saving the original ICC data
sk_sp<SkData> monitorData = SkData::MakeFromFileName(
@@ -136,28 +136,33 @@ DEF_TEST(ColorSpaceWriteICC, r) {
sk_sp<SkColorSpace> newMonitorSpace = SkColorSpace::NewICC(newMonitorData->data(),
newMonitorData->size());
REPORTER_ASSERT(r, monitorSpace->xyz() == newMonitorSpace->xyz());
- REPORTER_ASSERT(r, as_CSB(monitorSpace)->gammas() == as_CSB(newMonitorSpace)->gammas());
+ REPORTER_ASSERT(r, monitorSpace->gammaNamed() == newMonitorSpace->gammaNamed());
}
DEF_TEST(ColorSpace_Named, r) {
const struct {
SkColorSpace::Named fNamed;
bool fExpectedToSucceed;
+ bool fIsSRGB;
} recs[] {
- { SkColorSpace::kUnknown_Named, false },
- { SkColorSpace::kSRGB_Named, true },
- { SkColorSpace::kAdobeRGB_Named, true },
+ { SkColorSpace::kUnknown_Named, false, false },
+ { SkColorSpace::kSRGB_Named, true, true },
+ { SkColorSpace::kAdobeRGB_Named, true, false },
};
for (auto rec : recs) {
auto cs = SkColorSpace::NewNamed(rec.fNamed);
REPORTER_ASSERT(r, !cs == !rec.fExpectedToSucceed);
if (cs) {
- REPORTER_ASSERT(r, SkColorSpace::k2Dot2Curve_GammaNamed == cs->gammaNamed());
+ if (rec.fIsSRGB) {
+ REPORTER_ASSERT(r, SkColorSpace::kSRGB_GammaNamed == cs->gammaNamed());
+ } else {
+ REPORTER_ASSERT(r, SkColorSpace::k2Dot2Curve_GammaNamed == cs->gammaNamed());
+ }
}
}
SkImageInfo info = SkImageInfo::MakeS32(10, 10, kPremul_SkAlphaType);
REPORTER_ASSERT(r, kSRGB_SkColorProfileType == info.profileType());
- REPORTER_ASSERT(r, SkColorSpace::k2Dot2Curve_GammaNamed == info.colorSpace()->gammaNamed());
+ REPORTER_ASSERT(r, SkColorSpace::kSRGB_GammaNamed == info.colorSpace()->gammaNamed());
}
« no previous file with comments | « src/core/SkMipMap.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698