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

Unified Diff: tests/ColorSpaceTest.cpp

Issue 1985903002: Prepare SkColorSpace to be a public API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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
« src/core/SkColorSpacePriv.h ('K') | « src/core/SkColorSpacePriv.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 17332d720d5d9ec6d28cf7379e76a83436de8482..698c3e9c61d30e0b891ee657ded836a8d20d00bb 100644
--- a/tests/ColorSpaceTest.cpp
+++ b/tests/ColorSpaceTest.cpp
@@ -8,6 +8,7 @@
#include "Resources.h"
#include "SkCodec.h"
#include "SkColorSpace.h"
+#include "SkColorSpacePriv.h"
#include "Test.h"
#include "png.h"
@@ -19,12 +20,12 @@ 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[]) {
-#ifdef SK_DEBUG
- const SkColorSpace::SkGammas& gammas = space->gammas();
- REPORTER_ASSERT(r, almost_equal(expectedGammas[0], gammas.red()));
- REPORTER_ASSERT(r, almost_equal(expectedGammas[1], gammas.green()));
- REPORTER_ASSERT(r, almost_equal(expectedGammas[2], gammas.blue()));
-#endif
+
+ SkGammas* gammas = 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));
+
SkMatrix44 mat = space->xyz();
const float src[] = {
@@ -106,16 +107,16 @@ 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);
+ float sRGBGammas[3] = { 2.2f, 2.2f, 2.2f };
srgbToxyzD50.set3x3ColMajorf(g_sRGB_XYZ);
- sk_sp<SkColorSpace> rgbColorSpace = SkColorSpace::NewRGB(
- SkColorSpace::SkGammas(2.2f, 2.2f, 2.2f), srgbToxyzD50);
+ sk_sp<SkColorSpace> rgbColorSpace = SkColorSpace::NewRGB(sRGBGammas, 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);
+ sk_sp<SkColorSpace> strangeColorSpace = SkColorSpace::NewRGB(sRGBGammas, srgbToxyzD50);
REPORTER_ASSERT(r, strangeColorSpace != namedColorSpace);
}
« src/core/SkColorSpacePriv.h ('K') | « src/core/SkColorSpacePriv.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698