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

Side by Side Diff: tests/ColorSpaceXformTest.cpp

Issue 2347473007: Revert of Support Float32 output from SkColorSpaceXform (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « src/opts/SkNx_sse.h ('k') | tests/SkNxTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
12 #include "SkColorSpace.h" 11 #include "SkColorSpace.h"
13 #include "SkColorSpace_Base.h" 12 #include "SkColorSpace_Base.h"
14 #include "SkColorSpaceXform.h" 13 #include "SkColorSpaceXform.h"
15 #include "Test.h" 14 #include "Test.h"
16 15
17 class ColorSpaceXformTest { 16 class ColorSpaceXformTest {
18 public: 17 public:
19 static std::unique_ptr<SkColorSpaceXform> CreateIdentityXform(const sk_sp<Sk Gammas>& gammas) { 18 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. 19 // Logically we can pass any matrix here. For simplicty, pass I(), i.e. D50 XYZ gamut.
(...skipping 12 matching lines...) Expand all
33 static void test_identity_xform(skiatest::Reporter* r, const sk_sp<SkGammas>& ga mmas) { 32 static void test_identity_xform(skiatest::Reporter* r, const sk_sp<SkGammas>& ga mmas) {
34 // Arbitrary set of 10 pixels 33 // Arbitrary set of 10 pixels
35 constexpr int width = 10; 34 constexpr int width = 10;
36 constexpr uint32_t srcPixels[width] = { 35 constexpr uint32_t srcPixels[width] = {
37 0xFFABCDEF, 0xFF146829, 0xFF382759, 0xFF184968, 0xFFDE8271, 36 0xFFABCDEF, 0xFF146829, 0xFF382759, 0xFF184968, 0xFFDE8271,
38 0xFF32AB52, 0xFF0383BC, 0xFF000102, 0xFFFFFFFF, 0xFFDDEEFF, }; 37 0xFF32AB52, 0xFF0383BC, 0xFF000102, 0xFFFFFFFF, 0xFFDDEEFF, };
39 uint32_t dstPixels[width]; 38 uint32_t dstPixels[width];
40 39
41 // Create and perform an identity xform. 40 // Create and perform an identity xform.
42 std::unique_ptr<SkColorSpaceXform> xform = ColorSpaceXformTest::CreateIdenti tyXform(gammas); 41 std::unique_ptr<SkColorSpaceXform> xform = ColorSpaceXformTest::CreateIdenti tyXform(gammas);
43 xform->apply(dstPixels, srcPixels, width, select_xform_format(kN32_SkColorTy pe), 42 xform->apply(dstPixels, srcPixels, width, kN32_SkColorType, kOpaque_SkAlphaT ype);
44 kOpaque_SkAlphaType);
45 43
46 // Since the src->dst matrix is the identity, and the gamma curves match, 44 // Since the src->dst matrix is the identity, and the gamma curves match,
47 // the pixels should be unchanged. 45 // the pixels should be unchanged.
48 for (int i = 0; i < width; i++) { 46 for (int i = 0; i < width; i++) {
49 REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 0) & 0xFF), 47 REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 0) & 0xFF),
50 SkGetPackedR32(dstPixels[i]))); 48 SkGetPackedR32(dstPixels[i])));
51 REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 8) & 0xFF), 49 REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 8) & 0xFF),
52 SkGetPackedG32(dstPixels[i]))); 50 SkGetPackedG32(dstPixels[i])));
53 REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 16) & 0xFF), 51 REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 16) & 0xFF),
54 SkGetPackedB32(dstPixels[i]))); 52 SkGetPackedB32(dstPixels[i])));
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 155
158 gammas->fGreenType = SkGammas::Type::kTable_Type; 156 gammas->fGreenType = SkGammas::Type::kTable_Type;
159 gammas->fGreenData.fTable.fSize = tableSize; 157 gammas->fGreenData.fTable.fSize = tableSize;
160 gammas->fGreenData.fTable.fOffset = 0; 158 gammas->fGreenData.fTable.fOffset = 0;
161 159
162 gammas->fBlueType = SkGammas::Type::kParam_Type; 160 gammas->fBlueType = SkGammas::Type::kParam_Type;
163 gammas->fBlueData.fParamOffset = sizeof(float) * tableSize; 161 gammas->fBlueData.fParamOffset = sizeof(float) * tableSize;
164 162
165 test_identity_xform(r, gammas); 163 test_identity_xform(r, gammas);
166 } 164 }
OLDNEW
« no previous file with comments | « src/opts/SkNx_sse.h ('k') | tests/SkNxTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698