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 "SkCodecPriv.h" | 10 #include "SkCodecPriv.h" |
11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
12 #include "SkColorSpace.h" | 12 #include "SkColorSpace.h" |
13 #include "SkColorSpace_Base.h" | 13 #include "SkColorSpace_Base.h" |
14 #include "SkColorSpaceXform.h" | 14 #include "SkColorSpaceXform.h" |
15 #include "Test.h" | 15 #include "Test.h" |
16 | 16 |
17 class ColorSpaceXformTest { | 17 class ColorSpaceXformTest { |
18 public: | 18 public: |
19 static std::unique_ptr<SkColorSpaceXform> CreateIdentityXform(const sk_sp<Sk
Gammas>& gammas) { | 19 static std::unique_ptr<SkColorSpaceXform> CreateIdentityXform(const sk_sp<Sk
Gammas>& gammas) { |
20 // Logically we can pass any matrix here. For simplicty, pass I(), i.e.
D50 XYZ gamut. | 20 // Logically we can pass any matrix here. For simplicty, pass I(), i.e.
D50 XYZ gamut. |
21 sk_sp<SkColorSpace> space(new SkColorSpace_Base( | 21 sk_sp<SkColorSpace> space(new SkColorSpace_Base( |
22 nullptr, kNonStandard_SkGammaNamed, gammas, SkMatrix::I(), nullp
tr)); | 22 nullptr, kNonStandard_SkGammaNamed, gammas, SkMatrix::I(), nullp
tr)); |
23 | 23 |
24 // Use special testing entry point, so we don't skip the xform, even tho
ugh src == dst. | 24 // Use special testing entry point, so we don't skip the xform, even tho
ugh src == dst. |
25 return SlowIdentityXform(space); | 25 return SlowIdentityXform(space.get()); |
26 } | 26 } |
27 }; | 27 }; |
28 | 28 |
29 static bool almost_equal(int x, int y) { | 29 static bool almost_equal(int x, int y) { |
30 return SkTAbs(x - y) <= 1; | 30 return SkTAbs(x - y) <= 1; |
31 } | 31 } |
32 | 32 |
33 static void test_identity_xform(skiatest::Reporter* r, const sk_sp<SkGammas>& ga
mmas) { | 33 static void test_identity_xform(skiatest::Reporter* r, const sk_sp<SkGammas>& ga
mmas) { |
34 // Arbitrary set of 10 pixels | 34 // Arbitrary set of 10 pixels |
35 constexpr int width = 10; | 35 constexpr int width = 10; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 157 |
158 gammas->fGreenType = SkGammas::Type::kTable_Type; | 158 gammas->fGreenType = SkGammas::Type::kTable_Type; |
159 gammas->fGreenData.fTable.fSize = tableSize; | 159 gammas->fGreenData.fTable.fSize = tableSize; |
160 gammas->fGreenData.fTable.fOffset = 0; | 160 gammas->fGreenData.fTable.fOffset = 0; |
161 | 161 |
162 gammas->fBlueType = SkGammas::Type::kParam_Type; | 162 gammas->fBlueType = SkGammas::Type::kParam_Type; |
163 gammas->fBlueData.fParamOffset = sizeof(float) * tableSize; | 163 gammas->fBlueData.fParamOffset = sizeof(float) * tableSize; |
164 | 164 |
165 test_identity_xform(r, gammas); | 165 test_identity_xform(r, gammas); |
166 } | 166 } |
OLD | NEW |