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

Unified Diff: tests/ColorSpaceXformTest.cpp

Issue 2158033002: Tweak a couple things I found confusing in ColorSpaceXform unit tests. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ColorSpaceXformTest.cpp
diff --git a/tests/ColorSpaceXformTest.cpp b/tests/ColorSpaceXformTest.cpp
index 2b5db2bbe48bf41f549391486e5f32357bc21b07..7091946bbb75d3325737a9f0485e049e87440156 100644
--- a/tests/ColorSpaceXformTest.cpp
+++ b/tests/ColorSpaceXformTest.cpp
@@ -15,15 +15,10 @@
class ColorSpaceXformTest {
public:
- static std::unique_ptr<SkColorSpaceXform> CreateDefaultXform(const sk_sp<SkGammas>& srcGamma,
- const SkMatrix44& srcToDst, const sk_sp<SkGammas>& dstGamma) {
-
- sk_sp<SkColorSpace> srcSpace(
- new SkColorSpace_Base(nullptr, srcGamma, SkMatrix::I(), nullptr));
- sk_sp<SkColorSpace> dstSpace(
- new SkColorSpace_Base(nullptr, dstGamma, SkMatrix::I(), nullptr));
-
- return SkColorSpaceXform::New(srcSpace, dstSpace);
+ static std::unique_ptr<SkColorSpaceXform> CreateIdentityXform(const sk_sp<SkGammas>& gammas) {
+ // Logically we can pass any matrix here. For simplicty, pass I(), i.e. D50 XYZ gamut.
+ sk_sp<SkColorSpace> space(new SkColorSpace_Base(nullptr, gammas, SkMatrix::I(), nullptr));
+ return SkColorSpaceXform::New(space, space);
}
};
@@ -31,7 +26,7 @@ static bool almost_equal(int x, int y) {
return SkTAbs(x - y) <= 1;
}
-static void test_xform(skiatest::Reporter* r, const sk_sp<SkGammas>& gammas) {
+static void test_identity_xform(skiatest::Reporter* r, const sk_sp<SkGammas>& gammas) {
// Arbitrary set of 10 pixels
constexpr int width = 10;
constexpr uint32_t srcPixels[width] = {
@@ -39,16 +34,12 @@ static void test_xform(skiatest::Reporter* r, const sk_sp<SkGammas>& gammas) {
0xFF32AB52, 0xFF0383BC, 0xFF000102, 0xFFFFFFFF, 0xFFDDEEFF, };
uint32_t dstPixels[width];
- // Identity matrix
- SkMatrix44 srcToDst = SkMatrix44::I();
-
- // Create and perform xform
- std::unique_ptr<SkColorSpaceXform> xform =
- ColorSpaceXformTest::CreateDefaultXform(gammas, srcToDst, gammas);
+ // Create and perform an identity xform.
+ std::unique_ptr<SkColorSpaceXform> xform = ColorSpaceXformTest::CreateIdentityXform(gammas);
xform->applyTo8888(dstPixels, srcPixels, width);
- // Since the matrix is the identity, and the gamma curves match, the pixels
- // should be unchanged.
+ // Since the src->dst matrix is the identity, and the gamma curves match,
+ // the pixels should be unchanged.
for (int i = 0; i < width; i++) {
REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 0) & 0xFF),
SkGetPackedR32(dstPixels[i])));
@@ -81,7 +72,7 @@ DEF_TEST(ColorSpaceXform_TableGamma, r) {
red.fTable[9] = green.fTable[9] = blue.fTable[9] = 1.00f;
sk_sp<SkGammas> gammas =
sk_make_sp<SkGammas>(std::move(red), std::move(green), std::move(blue));
- test_xform(r, gammas);
+ test_identity_xform(r, gammas);
}
DEF_TEST(ColorSpaceXform_ParametricGamma, r) {
@@ -102,7 +93,7 @@ DEF_TEST(ColorSpaceXform_ParametricGamma, r) {
red.fG = green.fG = blue.fG = 2.4f;
sk_sp<SkGammas> gammas =
sk_make_sp<SkGammas>(std::move(red), std::move(green), std::move(blue));
- test_xform(r, gammas);
+ test_identity_xform(r, gammas);
}
DEF_TEST(ColorSpaceXform_ExponentialGamma, r) {
@@ -111,5 +102,5 @@ DEF_TEST(ColorSpaceXform_ExponentialGamma, r) {
red.fValue = green.fValue = blue.fValue = 1.4f;
sk_sp<SkGammas> gammas =
sk_make_sp<SkGammas>(std::move(red), std::move(green), std::move(blue));
- test_xform(r, gammas);
+ test_identity_xform(r, gammas);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698