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

Side by Side Diff: bench/SkBlend_optsBench.cpp

Issue 2163683002: Correct sRGB <-> linear everywhere. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: back to brute 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
« no previous file with comments | « no previous file | src/core/SkColor.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 <tuple> 8 #include <tuple>
9 9
10 #include "Benchmark.h" 10 #include "Benchmark.h"
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 "SkNx.h" 15 #include "SkNx.h"
16 #include "SkOpts.h" 16 #include "SkOpts.h"
17 #include "SkPM4fPriv.h" 17 #include "SkPM4fPriv.h"
18 #include "SkString.h" 18 #include "SkString.h"
19 19
20 #define INNER_LOOPS 10 20 #define INNER_LOOPS 10
21 21
22 static inline void brute_srcover_srgb_srgb_1(uint32_t* dst, uint32_t src) {
23 auto d = Sk4f_fromS32(*dst),
24 s = Sk4f_fromS32( src);
25 *dst = Sk4f_toS32(s + d * (1.0f - s[3]));
26 }
27
28 static inline void srcover_srgb_srgb_1(uint32_t* dst, uint32_t src) {
29 if (src >= 0xFF000000) {
30 *dst = src;
31 return;
32 }
33 brute_srcover_srgb_srgb_1(dst, src);
34 }
35
22 static void brute_force_srcover_srgb_srgb( 36 static void brute_force_srcover_srgb_srgb(
23 uint32_t* dst, const uint32_t* const src, int ndst, const int nsrc) { 37 uint32_t* dst, const uint32_t* const src, int ndst, const int nsrc) {
24 while (ndst > 0) { 38 while (ndst > 0) {
25 int n = SkTMin(ndst, nsrc); 39 int n = SkTMin(ndst, nsrc);
26 40
27 for (int i = 0; i < n; i++) { 41 for (int i = 0; i < n; i++) {
28 srcover_blend_srgb8888_srgb_1(dst++, srgb_to_linear(to_4f(src[i]))); 42 brute_srcover_srgb_srgb_1(dst++, src[i]);
29 } 43 }
30 ndst -= n; 44 ndst -= n;
31 } 45 }
46 }
47
48 static void trivial_srcover_srgb_srgb(
49 uint32_t* dst, const uint32_t* const src, int ndst, const int nsrc) {
50 while (ndst > 0) {
51 int n = SkTMin(ndst, nsrc);
52
53 for (int i = 0; i < n; i++) {
54 srcover_srgb_srgb_1(dst++, src[i]);
55 }
56 ndst -= n;
57 }
32 } 58 }
33 59
34 static void best_non_simd_srcover_srgb_srgb( 60 static void best_non_simd_srcover_srgb_srgb(
35 uint32_t* dst, const uint32_t* const src, int ndst, const int nsrc) { 61 uint32_t* dst, const uint32_t* const src, int ndst, const int nsrc) {
36 uint64_t* ddst = reinterpret_cast<uint64_t*>(dst); 62 uint64_t* ddst = reinterpret_cast<uint64_t*>(dst);
37 63
38 auto srcover_srgb_srgb_2 = [](uint32_t* dst, const uint32_t* src) { 64 auto srcover_srgb_srgb_2 = [](uint32_t* dst, const uint32_t* src) {
39 srcover_srgb8888_srgb_1(dst++, *src++); 65 srcover_srgb_srgb_1(dst++, *src++);
40 srcover_srgb8888_srgb_1(dst, *src); 66 srcover_srgb_srgb_1(dst, *src);
41 }; 67 };
42 68
43 while (ndst >0) { 69 while (ndst >0) {
44 int count = SkTMin(ndst, nsrc); 70 int count = SkTMin(ndst, nsrc);
45 ndst -= count; 71 ndst -= count;
46 const uint64_t* dsrc = reinterpret_cast<const uint64_t*>(src); 72 const uint64_t* dsrc = reinterpret_cast<const uint64_t*>(src);
47 const uint64_t* end = dsrc + (count >> 1); 73 const uint64_t* end = dsrc + (count >> 1);
48 do { 74 do {
49 if ((~*dsrc & 0xFF000000FF000000) == 0) { 75 if ((~*dsrc & 0xFF000000FF000000) == 0) {
50 do { 76 do {
51 *ddst++ = *dsrc++; 77 *ddst++ = *dsrc++;
52 } while (dsrc < end && (~*dsrc & 0xFF000000FF000000) == 0); 78 } while (dsrc < end && (~*dsrc & 0xFF000000FF000000) == 0);
53 } else if ((*dsrc & 0xFF000000FF000000) == 0) { 79 } else if ((*dsrc & 0xFF000000FF000000) == 0) {
54 do { 80 do {
55 dsrc++; 81 dsrc++;
56 ddst++; 82 ddst++;
57 } while (dsrc < end && (*dsrc & 0xFF000000FF000000) == 0); 83 } while (dsrc < end && (*dsrc & 0xFF000000FF000000) == 0);
58 } else { 84 } else {
59 srcover_srgb_srgb_2(reinterpret_cast<uint32_t*>(ddst++), 85 srcover_srgb_srgb_2(reinterpret_cast<uint32_t*>(ddst++),
60 reinterpret_cast<const uint32_t*>(dsrc++)); 86 reinterpret_cast<const uint32_t*>(dsrc++));
61 } 87 }
62 } while (dsrc < end); 88 } while (dsrc < end);
63 89
64 if ((count & 1) != 0) { 90 if ((count & 1) != 0) {
65 srcover_srgb8888_srgb_1(reinterpret_cast<uint32_t*>(ddst), 91 srcover_srgb_srgb_1(reinterpret_cast<uint32_t*>(ddst),
66 *reinterpret_cast<const uint32_t*>(dsrc)); 92 *reinterpret_cast<const uint32_t*>(dsrc));
67 } 93 }
68 } 94 }
69 } 95 }
70 96
71 static void trivial_srcover_srgb_srgb(
72 uint32_t* dst, const uint32_t* const src, int ndst, const int nsrc) {
73 while (ndst > 0) {
74 int n = SkTMin(ndst, nsrc);
75
76 for (int i = 0; i < n; i++) {
77 srcover_srgb8888_srgb_1(dst++, src[i]);
78 }
79 ndst -= n;
80 }
81 }
82
83 class SrcOverVSkOptsBruteForce { 97 class SrcOverVSkOptsBruteForce {
84 public: 98 public:
85 static SkString Name() { return SkString{"VSkOptsBruteForce"}; } 99 static SkString Name() { return SkString{"VSkOptsBruteForce"}; }
86 static void BlendN(uint32_t* dst, const uint32_t* src, int count) { 100 static void BlendN(uint32_t* dst, const uint32_t* src, int count) {
87 brute_force_srcover_srgb_srgb(dst, src, count, count); 101 brute_force_srcover_srgb_srgb(dst, src, count, count);
88 } 102 }
89 }; 103 };
90 104
91 class SrcOverVSkOptsTrivial { 105 class SrcOverVSkOptsTrivial {
92 public: 106 public:
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsBruteForce>(fileName) ; ) \ 191 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsBruteForce>(fileName) ; ) \
178 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsTrivial>(fileName); ) \ 192 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsTrivial>(fileName); ) \
179 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsNonSimdCore>(fileName ); ) \ 193 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsNonSimdCore>(fileName ); ) \
180 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsDefault>(fileName); ) 194 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsDefault>(fileName); )
181 195
182 BENCHES("yellow_rose.png") 196 BENCHES("yellow_rose.png")
183 BENCHES("baby_tux.png") 197 BENCHES("baby_tux.png")
184 BENCHES("plane.png") 198 BENCHES("plane.png")
185 BENCHES("mandrill_512.png") 199 BENCHES("mandrill_512.png")
186 BENCHES("iconstrip.png") 200 BENCHES("iconstrip.png")
OLDNEW
« no previous file with comments | « no previous file | src/core/SkColor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698