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

Side by Side Diff: tests/ColorSpaceXformTest.cpp

Issue 2060823003: Implement fast, correct gamma conversion for color xforms (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Win test Created 4 years, 6 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/SkOpts_sse41.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 "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 17 matching lines...) Expand all
28 0xFFABCDEF, 0xFF146829, 0xFF382759, 0xFF184968, 0xFFDE8271, 28 0xFFABCDEF, 0xFF146829, 0xFF382759, 0xFF184968, 0xFFDE8271,
29 0xFF32AB52, 0xFF0383BC, 0xFF000000, 0xFFFFFFFF, 0xFFDDEEFF, }; 29 0xFF32AB52, 0xFF0383BC, 0xFF000000, 0xFFFFFFFF, 0xFFDDEEFF, };
30 uint32_t dstPixels[width]; 30 uint32_t dstPixels[width];
31 31
32 // Identity matrix 32 // Identity matrix
33 SkMatrix44 srcToDst = SkMatrix44::I(); 33 SkMatrix44 srcToDst = SkMatrix44::I();
34 34
35 // Create and perform xform 35 // Create and perform xform
36 std::unique_ptr<SkColorSpaceXform> xform( 36 std::unique_ptr<SkColorSpaceXform> xform(
37 ColorSpaceXformTest::CreateDefaultXform(gammas, srcToDst, gammas)); 37 ColorSpaceXformTest::CreateDefaultXform(gammas, srcToDst, gammas));
38 xform->xform_RGBA_8888(dstPixels, srcPixels, width); 38 xform->xform_RGB1_8888(dstPixels, srcPixels, width);
39 39
40 // Since the matrix is the identity, and the gamma curves match, the pixels 40 // Since the matrix is the identity, and the gamma curves match, the pixels
41 // should be unchanged. 41 // should be unchanged.
42 for (int i = 0; i < width; i++) { 42 for (int i = 0; i < width; i++) {
43 // TODO (msarett): 43 // TODO (msarett):
44 // As the implementation changes, we may want to use a tolerance here. 44 // As the implementation changes, we may want to use a tolerance here.
45 REPORTER_ASSERT(r, ((srcPixels[i] >> 0) & 0xFF) == SkGetPackedR32(dstPi xels[i])); 45 REPORTER_ASSERT(r, ((srcPixels[i] >> 0) & 0xFF) == SkGetPackedR32(dstPi xels[i]));
46 REPORTER_ASSERT(r, ((srcPixels[i] >> 8) & 0xFF) == SkGetPackedG32(dstPi xels[i])); 46 REPORTER_ASSERT(r, ((srcPixels[i] >> 8) & 0xFF) == SkGetPackedG32(dstPi xels[i]));
47 REPORTER_ASSERT(r, ((srcPixels[i] >> 16) & 0xFF) == SkGetPackedB32(dstPi xels[i])); 47 REPORTER_ASSERT(r, ((srcPixels[i] >> 16) & 0xFF) == SkGetPackedB32(dstPi xels[i]));
48 REPORTER_ASSERT(r, ((srcPixels[i] >> 24) & 0xFF) == SkGetPackedA32(dstPi xels[i])); 48 REPORTER_ASSERT(r, ((srcPixels[i] >> 24) & 0xFF) == SkGetPackedA32(dstPi xels[i]));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 94 }
95 95
96 DEF_TEST(ColorSpaceXform_ExponentialGamma, r) { 96 DEF_TEST(ColorSpaceXform_ExponentialGamma, r) {
97 // Exponential gamma curves 97 // Exponential gamma curves
98 SkGammaCurve red, green, blue; 98 SkGammaCurve red, green, blue;
99 red.fValue = green.fValue = blue.fValue = 4.0f; 99 red.fValue = green.fValue = blue.fValue = 4.0f;
100 sk_sp<SkGammas> gammas = 100 sk_sp<SkGammas> gammas =
101 sk_make_sp<SkGammas>(std::move(red), std::move(green), std::move(blu e)); 101 sk_make_sp<SkGammas>(std::move(red), std::move(green), std::move(blu e));
102 test_xform(r, gammas); 102 test_xform(r, gammas);
103 } 103 }
OLDNEW
« no previous file with comments | « src/opts/SkOpts_sse41.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698