OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Resources.h" | 8 #include "Resources.h" |
9 #include "SkCodec.h" | 9 #include "SkCodec.h" |
10 #include "SkColorSpace.h" | 10 #include "SkColorSpace.h" |
11 #include "SkColorSpace_Base.h" | 11 #include "SkColorSpace_Base.h" |
12 #include "Test.h" | 12 #include "Test.h" |
13 | 13 |
14 #include "png.h" | 14 #include "png.h" |
15 | 15 |
16 static bool almost_equal(float a, float b) { | 16 static bool almost_equal(float a, float b) { |
17 return SkTAbs(a - b) < 0.001f; | 17 return SkTAbs(a - b) < 0.001f; |
18 } | 18 } |
19 | 19 |
20 static void test_space(skiatest::Reporter* r, SkColorSpace* space, | 20 static void test_space(skiatest::Reporter* r, SkColorSpace* space, |
21 const float red[], const float green[], const float blue[
], | 21 const float red[], const float green[], const float blue[
], |
22 const float expectedGammas[]) { | 22 const float expectedGammas[]) { |
23 | 23 |
24 SkGammas* gammas = as_CSB(space)->gammas(); | 24 const sk_sp<SkGammas>& gammas = as_CSB(space)->gammas(); |
25 REPORTER_ASSERT(r, almost_equal(expectedGammas[0], gammas->fRed.fValue)); | 25 REPORTER_ASSERT(r, almost_equal(expectedGammas[0], gammas->fRed.fValue)); |
26 REPORTER_ASSERT(r, almost_equal(expectedGammas[1], gammas->fGreen.fValue)); | 26 REPORTER_ASSERT(r, almost_equal(expectedGammas[1], gammas->fGreen.fValue)); |
27 REPORTER_ASSERT(r, almost_equal(expectedGammas[2], gammas->fBlue.fValue)); | 27 REPORTER_ASSERT(r, almost_equal(expectedGammas[2], gammas->fBlue.fValue)); |
28 | 28 |
29 | 29 |
30 SkMatrix44 mat = space->xyz(); | 30 SkMatrix44 mat = space->xyz(); |
31 const float src[] = { | 31 const float src[] = { |
32 1, 0, 0, 1, | 32 1, 0, 0, 1, |
33 0, 1, 0, 1, | 33 0, 1, 0, 1, |
34 0, 0, 1, 1, | 34 0, 0, 1, 1, |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 float sRGBGammas[3] = { 2.2f, 2.2f, 2.2f }; | 113 float sRGBGammas[3] = { 2.2f, 2.2f, 2.2f }; |
114 srgbToxyzD50.set3x3ColMajorf(g_sRGB_XYZ); | 114 srgbToxyzD50.set3x3ColMajorf(g_sRGB_XYZ); |
115 sk_sp<SkColorSpace> rgbColorSpace = SkColorSpace::NewRGB(sRGBGammas, srgbTox
yzD50); | 115 sk_sp<SkColorSpace> rgbColorSpace = SkColorSpace::NewRGB(sRGBGammas, srgbTox
yzD50); |
116 REPORTER_ASSERT(r, namedColorSpace == namedColorSpace); | 116 REPORTER_ASSERT(r, namedColorSpace == namedColorSpace); |
117 | 117 |
118 // Change a single value from the sRGB matrix | 118 // Change a single value from the sRGB matrix |
119 srgbToxyzD50.set(2, 2, 0.5f); | 119 srgbToxyzD50.set(2, 2, 0.5f); |
120 sk_sp<SkColorSpace> strangeColorSpace = SkColorSpace::NewRGB(sRGBGammas, srg
bToxyzD50); | 120 sk_sp<SkColorSpace> strangeColorSpace = SkColorSpace::NewRGB(sRGBGammas, srg
bToxyzD50); |
121 REPORTER_ASSERT(r, strangeColorSpace != namedColorSpace); | 121 REPORTER_ASSERT(r, strangeColorSpace != namedColorSpace); |
122 } | 122 } |
OLD | NEW |