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

Side by Side Diff: tests/SkBlend_optsTest.cpp

Issue 2163683002: Correct sRGB <-> linear everywhere. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix! Created 4 years, 5 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
« src/opts/SkBlend_opts.h ('K') | « src/opts/SkBlend_opts.h ('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 <string> 8 #include <string>
9 #include <tuple> 9 #include <tuple>
10 #include <vector> 10 #include <vector>
11 #include "Resources.h" 11 #include "Resources.h"
12 #include "SkCpu.h" 12 #include "SkCpu.h"
13 #include "SkImage.h" 13 #include "SkImage.h"
14 #include "SkImage_Base.h" 14 #include "SkImage_Base.h"
15 #include "SkOpts.h" 15 #include "SkOpts.h"
16 #include "SkPM4fPriv.h" 16 #include "SkPM4fPriv.h"
17 #include "SkNx.h" 17 #include "SkNx.h"
18 #include "Test.h" 18 #include "Test.h"
19 19
20 typedef void (*Blender)(uint32_t* dst, const uint32_t* const srcStart, int ndst, const int nsrc); 20 typedef void (*Blender)(uint32_t* dst, const uint32_t* const srcStart, int ndst, const int nsrc);
21 21
22 static inline void srcover_srgb_srgb_1(uint32_t* dst, uint32_t src) {
23 // TODO: switch back to pure brute force if we can get Sk4f_toS32(Sk4f_fromS 32(...)) to
24 // roundtrip perfectly.
25 if (src >= 0xFF000000) {
26 *dst = src;
27 return;
28 }
29 auto d = Sk4f_fromS32(*dst),
30 s = Sk4f_fromS32( src);
31 *dst = Sk4f_toS32(s + d * (1.0f - s[3]));
32 }
33
22 static void brute_force_srcover_srgb_srgb( 34 static void brute_force_srcover_srgb_srgb(
23 uint32_t* dst, const uint32_t* const src, int ndst, const int nsrc) { 35 uint32_t* dst, const uint32_t* const src, int ndst, const int nsrc) {
24 while (ndst > 0) { 36 while (ndst > 0) {
25 int n = SkTMin(ndst, nsrc); 37 int n = SkTMin(ndst, nsrc);
26 38
27 for (int i = 0; i < n; i++) { 39 for (int i = 0; i < n; i++) {
28 srcover_blend_srgb8888_srgb_1(dst++, srgb_to_linear(to_4f(src[i]))); 40 srcover_srgb_srgb_1(dst++, src[i]);
29 } 41 }
30 ndst -= n; 42 ndst -= n;
31 } 43 }
32 } 44 }
33 45
34 static SkString mismatch_message(std::string resourceName, int x, int y, 46 static SkString mismatch_message(std::string resourceName, int x, int y,
35 uint32_t src, uint32_t good, uint32_t bad) { 47 uint32_t src, uint32_t good, uint32_t bad) {
36 return SkStringPrintf( 48 return SkStringPrintf(
37 "%s - missmatch at %d, %d src: %08x good: %08x bad: %08x", 49 "%s - missmatch at %d, %d src: %08x good: %08x bad: %08x",
38 resourceName.c_str(), x, y, src, good, bad); 50 resourceName.c_str(), x, y, src, good, bad);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 DEF_TEST(SkBlend_optsSqrtCheck, reporter) { 102 DEF_TEST(SkBlend_optsSqrtCheck, reporter) {
91 for (int c = 0; c < 256; c++) { 103 for (int c = 0; c < 256; c++) {
92 Sk4f i{(float)c}; 104 Sk4f i{(float)c};
93 Sk4f ii = i * i; 105 Sk4f ii = i * i;
94 Sk4f s = ii.sqrt() + 0.5f; 106 Sk4f s = ii.sqrt() + 0.5f;
95 Sk4f sf = s.floor(); 107 Sk4f sf = s.floor();
96 REPORTER_ASSERT_MESSAGE( 108 REPORTER_ASSERT_MESSAGE(
97 reporter, i[0] == sf[0], SkStringPrintf("i: %f, s: %f", i[0], sf[0]) ); 109 reporter, i[0] == sf[0], SkStringPrintf("i: %f, s: %f", i[0], sf[0]) );
98 } 110 }
99 } 111 }
OLDNEW
« src/opts/SkBlend_opts.h ('K') | « src/opts/SkBlend_opts.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698