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

Unified Diff: tests/ColorSpaceTest.cpp

Issue 2221983002: Fix Equals and serialization for rare pngs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Response to comments 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/core/SkColorSpace_Base.h ('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 66860da590d12dd4838ce0a714514b3cb18f8d50..abc02b74d89880c7e34979015f66a1ac07dc4af2 100644
--- a/tests/ColorSpaceTest.cpp
+++ b/tests/ColorSpaceTest.cpp
@@ -173,25 +173,6 @@ DEF_TEST(ColorSpace_Named, r) {
REPORTER_ASSERT(r, info.gammaCloseToSRGB());
}
-static void matrix_equals(skiatest::Reporter* r, SkColorSpace* space1, SkColorSpace* space2) {
- REPORTER_ASSERT(r, space1->xyz().getFloat(0, 0) == space2->xyz().getFloat(0, 0));
- REPORTER_ASSERT(r, space1->xyz().getFloat(0, 1) == space2->xyz().getFloat(0, 1));
- REPORTER_ASSERT(r, space1->xyz().getFloat(0, 2) == space2->xyz().getFloat(0, 2));
- REPORTER_ASSERT(r, space1->xyz().getFloat(0, 3) == space2->xyz().getFloat(0, 3));
- REPORTER_ASSERT(r, space1->xyz().getFloat(1, 0) == space2->xyz().getFloat(1, 0));
- REPORTER_ASSERT(r, space1->xyz().getFloat(1, 1) == space2->xyz().getFloat(1, 1));
- REPORTER_ASSERT(r, space1->xyz().getFloat(1, 2) == space2->xyz().getFloat(1, 2));
- REPORTER_ASSERT(r, space1->xyz().getFloat(1, 3) == space2->xyz().getFloat(1, 3));
- REPORTER_ASSERT(r, space1->xyz().getFloat(2, 0) == space2->xyz().getFloat(2, 0));
- REPORTER_ASSERT(r, space1->xyz().getFloat(2, 1) == space2->xyz().getFloat(2, 1));
- REPORTER_ASSERT(r, space1->xyz().getFloat(2, 2) == space2->xyz().getFloat(2, 2));
- REPORTER_ASSERT(r, space1->xyz().getFloat(2, 3) == space2->xyz().getFloat(2, 3));
- REPORTER_ASSERT(r, space1->xyz().getFloat(3, 0) == space2->xyz().getFloat(3, 0));
- REPORTER_ASSERT(r, space1->xyz().getFloat(3, 1) == space2->xyz().getFloat(3, 1));
- REPORTER_ASSERT(r, space1->xyz().getFloat(3, 2) == space2->xyz().getFloat(3, 2));
- REPORTER_ASSERT(r, space1->xyz().getFloat(3, 3) == space2->xyz().getFloat(3, 3));
-}
-
static void test_serialize(skiatest::Reporter* r, SkColorSpace* space, bool isNamed) {
sk_sp<SkData> data1 = space->serialize();
@@ -206,10 +187,8 @@ static void test_serialize(skiatest::Reporter* r, SkColorSpace* space, bool isNa
REPORTER_ASSERT(r, space == newSpace1.get());
REPORTER_ASSERT(r, space == newSpace2.get());
} else {
- REPORTER_ASSERT(r, space->gammaNamed() == newSpace1->gammaNamed());
- REPORTER_ASSERT(r, space->gammaNamed() == newSpace2->gammaNamed());
- matrix_equals(r, space, newSpace1.get());
- matrix_equals(r, space, newSpace2.get());
+ REPORTER_ASSERT(r, SkColorSpace::Equals(space, newSpace1.get()));
+ REPORTER_ASSERT(r, SkColorSpace::Equals(space, newSpace2.get()));
}
}
@@ -226,6 +205,10 @@ DEF_TEST(ColorSpace_Serialize, r) {
test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->size()).get(), false);
monitorData = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperRight.icc").c_str());
test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->size()).get(), false);
+
+ const float gammas[] = { 1.1f, 1.2f, 1.7f, };
+ SkMatrix44 toXYZ(SkMatrix44::kIdentity_Constructor);
+ test_serialize(r, SkColorSpace_Base::NewRGB(gammas, toXYZ).get(), false);
}
DEF_TEST(ColorSpace_Equals, r) {
@@ -240,6 +223,12 @@ DEF_TEST(ColorSpace_Equals, r) {
sk_sp<SkColorSpace> upperLeft = SkColorSpace::NewICC(data->data(), data->size());
data = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperRight.icc").c_str());
sk_sp<SkColorSpace> upperRight = SkColorSpace::NewICC(data->data(), data->size());
+ const float gammas1[] = { 1.1f, 1.2f, 1.3f, };
+ const float gammas2[] = { 1.1f, 1.2f, 1.7f, };
+ SkMatrix44 toXYZ(SkMatrix44::kIdentity_Constructor);
+ sk_sp<SkColorSpace> rgb1 = SkColorSpace_Base::NewRGB(gammas1, toXYZ);
+ sk_sp<SkColorSpace> rgb2 = SkColorSpace_Base::NewRGB(gammas2, toXYZ);
+ sk_sp<SkColorSpace> rgb3 = SkColorSpace_Base::NewRGB(gammas1, toXYZ);
REPORTER_ASSERT(r, SkColorSpace::Equals(nullptr, nullptr));
REPORTER_ASSERT(r, SkColorSpace::Equals(srgb.get(), srgb.get()));
@@ -248,6 +237,8 @@ DEF_TEST(ColorSpace_Equals, r) {
REPORTER_ASSERT(r, SkColorSpace::Equals(z32.get(), z32.get()));
REPORTER_ASSERT(r, SkColorSpace::Equals(upperLeft.get(), upperLeft.get()));
REPORTER_ASSERT(r, SkColorSpace::Equals(upperRight.get(), upperRight.get()));
+ REPORTER_ASSERT(r, SkColorSpace::Equals(rgb1.get(), rgb1.get()));
+ REPORTER_ASSERT(r, SkColorSpace::Equals(rgb1.get(), rgb3.get()));
REPORTER_ASSERT(r, !SkColorSpace::Equals(nullptr, srgb.get()));
REPORTER_ASSERT(r, !SkColorSpace::Equals(srgb.get(), nullptr));
@@ -258,4 +249,5 @@ DEF_TEST(ColorSpace_Equals, r) {
REPORTER_ASSERT(r, !SkColorSpace::Equals(upperLeft.get(), upperRight.get()));
REPORTER_ASSERT(r, !SkColorSpace::Equals(z30.get(), upperRight.get()));
REPORTER_ASSERT(r, !SkColorSpace::Equals(upperRight.get(), adobe.get()));
+ REPORTER_ASSERT(r, !SkColorSpace::Equals(rgb1.get(), rgb2.get()));
}
« no previous file with comments | « src/core/SkColorSpace_Base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698