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

Side by Side Diff: tests/ColorSpaceXformTest.cpp

Issue 2353363008: Add BGRA as input format to SkColorSpaceXform (Closed)
Patch Set: Response to comments 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/core/SkColorSpaceXform.cpp ('k') | no next file » | 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" 10 #include "SkCodecPriv.h"
(...skipping 23 matching lines...) Expand all
34 // Arbitrary set of 10 pixels 34 // Arbitrary set of 10 pixels
35 constexpr int width = 10; 35 constexpr int width = 10;
36 constexpr uint32_t srcPixels[width] = { 36 constexpr uint32_t srcPixels[width] = {
37 0xFFABCDEF, 0xFF146829, 0xFF382759, 0xFF184968, 0xFFDE8271, 37 0xFFABCDEF, 0xFF146829, 0xFF382759, 0xFF184968, 0xFFDE8271,
38 0xFF32AB52, 0xFF0383BC, 0xFF000102, 0xFFFFFFFF, 0xFFDDEEFF, }; 38 0xFF32AB52, 0xFF0383BC, 0xFF000102, 0xFFFFFFFF, 0xFFDDEEFF, };
39 uint32_t dstPixels[width]; 39 uint32_t dstPixels[width];
40 40
41 // Create and perform an identity xform. 41 // Create and perform an identity xform.
42 std::unique_ptr<SkColorSpaceXform> xform = ColorSpaceXformTest::CreateIdenti tyXform(gammas); 42 std::unique_ptr<SkColorSpaceXform> xform = ColorSpaceXformTest::CreateIdenti tyXform(gammas);
43 xform->apply(dstPixels, srcPixels, width, select_xform_format(kN32_SkColorTy pe), 43 xform->apply(dstPixels, srcPixels, width, select_xform_format(kN32_SkColorTy pe),
44 kOpaque_SkAlphaType); 44 SkColorSpaceXform::kBGRA_8888_ColorFormat, kOpaque_SkAlphaType) ;
45 45
46 // 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,
47 // the pixels should be unchanged. 47 // the pixels should be unchanged.
48 for (int i = 0; i < width; i++) { 48 for (int i = 0; i < width; i++) {
49 REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 0) & 0xFF), 49 REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 0) & 0xFF),
50 SkGetPackedR32(dstPixels[i]))); 50 SkGetPackedB32(dstPixels[i])));
51 REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 8) & 0xFF), 51 REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 8) & 0xFF),
52 SkGetPackedG32(dstPixels[i]))); 52 SkGetPackedG32(dstPixels[i])));
53 REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 16) & 0xFF), 53 REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 16) & 0xFF),
54 SkGetPackedB32(dstPixels[i]))); 54 SkGetPackedR32(dstPixels[i])));
55 REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 24) & 0xFF), 55 REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 24) & 0xFF),
56 SkGetPackedA32(dstPixels[i]))); 56 SkGetPackedA32(dstPixels[i])));
57 } 57 }
58 } 58 }
59 59
60 DEF_TEST(ColorSpaceXform_TableGamma, r) { 60 DEF_TEST(ColorSpaceXform_TableGamma, r) {
61 // Lookup-table based gamma curves 61 // Lookup-table based gamma curves
62 constexpr size_t tableSize = 10; 62 constexpr size_t tableSize = 10;
63 void* memory = sk_malloc_throw(sizeof(SkGammas) + sizeof(float) * tableSize) ; 63 void* memory = sk_malloc_throw(sizeof(SkGammas) + sizeof(float) * tableSize) ;
64 sk_sp<SkGammas> gammas = sk_sp<SkGammas>(new (memory) SkGammas()); 64 sk_sp<SkGammas> gammas = sk_sp<SkGammas>(new (memory) SkGammas());
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « src/core/SkColorSpaceXform.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698