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

Side by Side Diff: src/core/Sk4px.h

Issue 1141953004: sk4px the rest of the easy xfermodes. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: unify Created 5 years, 7 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/SkXfermode.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 2015 Google Inc. 2 * Copyright 2015 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 #ifndef Sk4px_DEFINED 8 #ifndef Sk4px_DEFINED
9 #define Sk4px_DEFINED 9 #define Sk4px_DEFINED
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 }; 58 };
59 59
60 Wide widenLo() const; // ARGB -> 0A 0R 0G 0B 60 Wide widenLo() const; // ARGB -> 0A 0R 0G 0B
61 Wide widenHi() const; // ARGB -> A0 R0 G0 B0 61 Wide widenHi() const; // ARGB -> A0 R0 G0 B0
62 Wide mulWiden(const Sk16b&) const; // 8-bit x 8-bit -> 16-bit components. 62 Wide mulWiden(const Sk16b&) const; // 8-bit x 8-bit -> 16-bit components.
63 Wide mul255Widen() const { 63 Wide mul255Widen() const {
64 // TODO: x*255 = x*256-x, so something like this->widenHi() - this->wide nLo()? 64 // TODO: x*255 = x*256-x, so something like this->widenHi() - this->wide nLo()?
65 return this->mulWiden(Sk16b(255)); 65 return this->mulWiden(Sk16b(255));
66 } 66 }
67 67
68 // Generally faster than this->mulWiden(other).div255RoundNarrow().
69 // May be incorrect by +-1, but is always exactly correct when *this or othe r is 0 or 255.
70 Sk4px fastMulDiv255Round(const Sk16b& other) const {
71 // (x*y + x) / 256 meets these criteria. (As of course does (x*y + y) / 256 by symmetry.)
72 Sk4px::Wide x = this->widenLo(),
73 xy = this->mulWiden(other);
74 return x.addNarrowHi(xy);
75 }
76
68 // A generic driver that maps fn over a src array into a dst array. 77 // A generic driver that maps fn over a src array into a dst array.
69 // fn should take an Sk4px (4 src pixels) and return an Sk4px (4 dst pixels) . 78 // fn should take an Sk4px (4 src pixels) and return an Sk4px (4 dst pixels) .
70 template <typename Fn> 79 template <typename Fn>
71 static void MapSrc(int count, SkPMColor* dst, const SkPMColor* src, Fn fn) { 80 static void MapSrc(int count, SkPMColor* dst, const SkPMColor* src, Fn fn) {
72 // This looks a bit odd, but it helps loop-invariant hoisting across dif ferent calls to fn. 81 // This looks a bit odd, but it helps loop-invariant hoisting across dif ferent calls to fn.
73 // Basically, we need to make sure we keep things inside a single loop. 82 // Basically, we need to make sure we keep things inside a single loop.
74 while (count > 0) { 83 while (count > 0) {
75 if (count >= 8) { 84 if (count >= 8) {
76 Sk4px dst0 = fn(Load4(src+0)), 85 Sk4px dst0 = fn(Load4(src+0)),
77 dst4 = fn(Load4(src+4)); 86 dst4 = fn(Load4(src+4));
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 177 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
169 #include "../opts/Sk4px_SSE2.h" 178 #include "../opts/Sk4px_SSE2.h"
170 #elif defined(SK_ARM_HAS_NEON) 179 #elif defined(SK_ARM_HAS_NEON)
171 #include "../opts/Sk4px_NEON.h" 180 #include "../opts/Sk4px_NEON.h"
172 #else 181 #else
173 #include "../opts/Sk4px_none.h" 182 #include "../opts/Sk4px_none.h"
174 #endif 183 #endif
175 #endif 184 #endif
176 185
177 #endif//Sk4px_DEFINED 186 #endif//Sk4px_DEFINED
OLDNEW
« no previous file with comments | « no previous file | src/core/SkXfermode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698