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

Unified Diff: tests/ColorSpaceTest.cpp

Issue 1945693002: Create a single, unique pointer to sRGB color space (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase + Test Created 4 years, 8 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/SkColorSpace.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 5ae5a648a0cc20c81af505cd4a27096fe147685b..7e818caad0f3f0e90299e67b783b01734a4a7247 100644
--- a/tests/ColorSpaceTest.cpp
+++ b/tests/ColorSpaceTest.cpp
@@ -41,13 +41,14 @@ static void test_space(skiatest::Reporter* r, SkColorSpace* space,
}
}
+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
+
DEF_TEST(ColorSpace_sRGB, r) {
- const float srgb_r[] = { 0.4358f, 0.2224f, 0.0139f };
- const float srgb_g[] = { 0.3853f, 0.7170f, 0.0971f };
- const float srgb_b[] = { 0.1430f, 0.0606f, 0.7139f };
const float srgb_gamma[] = { 2.2f, 2.2f, 2.2f };
test_space(r, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).get(),
- srgb_r, srgb_g, srgb_b, srgb_gamma);
+ g_sRGB_XYZ, &g_sRGB_XYZ[3], &g_sRGB_XYZ[6], srgb_gamma);
}
@@ -100,3 +101,21 @@ DEF_TEST(ColorSpaceParseJpegICCProfile, r) {
const float gamma[] = { 2.2f, 2.2f, 2.2f };
test_space(r, colorSpace, red, green, blue, gamma);
}
+
+DEF_TEST(ColorSpaceSRGBCompare, r) {
+ // Create an sRGB color space by name
+ sk_sp<SkColorSpace> namedColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
+
+ // Create an sRGB color space by value
+ SkMatrix44 srgbToxyzD50(SkMatrix44::kUninitialized_Constructor);
+ srgbToxyzD50.set3x3ColMajorf(g_sRGB_XYZ);
+ sk_sp<SkColorSpace> rgbColorSpace = SkColorSpace::NewRGB(
+ SkColorSpace::SkGammas(2.2f, 2.2f, 2.2f), srgbToxyzD50);
+ REPORTER_ASSERT(r, namedColorSpace == namedColorSpace);
+
+ // Change a single value from the sRGB matrix
+ srgbToxyzD50.set(2, 2, 0.5f);
+ sk_sp<SkColorSpace> strangeColorSpace = SkColorSpace::NewRGB(
+ SkColorSpace::SkGammas(2.2f, 2.2f, 2.2f), srgbToxyzD50);
+ REPORTER_ASSERT(r, strangeColorSpace != namedColorSpace);
+}
« no previous file with comments | « src/core/SkColorSpace.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698