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 "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
11 #include "SkColorSpace.h" | 12 #include "SkColorSpace.h" |
12 #include "SkColorSpace_Base.h" | 13 #include "SkColorSpace_Base.h" |
13 #include "SkColorSpaceXform.h" | 14 #include "SkColorSpaceXform.h" |
14 #include "Test.h" | 15 #include "Test.h" |
15 | 16 |
16 class ColorSpaceXformTest { | 17 class ColorSpaceXformTest { |
17 public: | 18 public: |
18 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) { |
19 // 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. |
(...skipping 12 matching lines...) Expand all Loading... |
32 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) { |
33 // Arbitrary set of 10 pixels | 34 // Arbitrary set of 10 pixels |
34 constexpr int width = 10; | 35 constexpr int width = 10; |
35 constexpr uint32_t srcPixels[width] = { | 36 constexpr uint32_t srcPixels[width] = { |
36 0xFFABCDEF, 0xFF146829, 0xFF382759, 0xFF184968, 0xFFDE8271, | 37 0xFFABCDEF, 0xFF146829, 0xFF382759, 0xFF184968, 0xFFDE8271, |
37 0xFF32AB52, 0xFF0383BC, 0xFF000102, 0xFFFFFFFF, 0xFFDDEEFF, }; | 38 0xFF32AB52, 0xFF0383BC, 0xFF000102, 0xFFFFFFFF, 0xFFDDEEFF, }; |
38 uint32_t dstPixels[width]; | 39 uint32_t dstPixels[width]; |
39 | 40 |
40 // Create and perform an identity xform. | 41 // Create and perform an identity xform. |
41 std::unique_ptr<SkColorSpaceXform> xform = ColorSpaceXformTest::CreateIdenti
tyXform(gammas); | 42 std::unique_ptr<SkColorSpaceXform> xform = ColorSpaceXformTest::CreateIdenti
tyXform(gammas); |
42 xform->apply(dstPixels, srcPixels, width, kN32_SkColorType, kOpaque_SkAlphaT
ype); | 43 xform->apply(dstPixels, srcPixels, width, select_xform_format(kN32_SkColorTy
pe), |
| 44 kOpaque_SkAlphaType); |
43 | 45 |
44 // Since the src->dst matrix is the identity, and the gamma curves match, | 46 // Since the src->dst matrix is the identity, and the gamma curves match, |
45 // the pixels should be unchanged. | 47 // the pixels should be unchanged. |
46 for (int i = 0; i < width; i++) { | 48 for (int i = 0; i < width; i++) { |
47 REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 0) & 0xFF), | 49 REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 0) & 0xFF), |
48 SkGetPackedR32(dstPixels[i]))); | 50 SkGetPackedR32(dstPixels[i]))); |
49 REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 8) & 0xFF), | 51 REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 8) & 0xFF), |
50 SkGetPackedG32(dstPixels[i]))); | 52 SkGetPackedG32(dstPixels[i]))); |
51 REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 16) & 0xFF), | 53 REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 16) & 0xFF), |
52 SkGetPackedB32(dstPixels[i]))); | 54 SkGetPackedB32(dstPixels[i]))); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 157 |
156 gammas->fGreenType = SkGammas::Type::kTable_Type; | 158 gammas->fGreenType = SkGammas::Type::kTable_Type; |
157 gammas->fGreenData.fTable.fSize = tableSize; | 159 gammas->fGreenData.fTable.fSize = tableSize; |
158 gammas->fGreenData.fTable.fOffset = 0; | 160 gammas->fGreenData.fTable.fOffset = 0; |
159 | 161 |
160 gammas->fBlueType = SkGammas::Type::kParam_Type; | 162 gammas->fBlueType = SkGammas::Type::kParam_Type; |
161 gammas->fBlueData.fParamOffset = sizeof(float) * tableSize; | 163 gammas->fBlueData.fParamOffset = sizeof(float) * tableSize; |
162 | 164 |
163 test_identity_xform(r, gammas); | 165 test_identity_xform(r, gammas); |
164 } | 166 } |
OLD | NEW |