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

Side by Side Diff: src/opts/Sk4px_none.h

Issue 1284333002: Revert of Refactor to put SkXfermode_opts inside SK_OPTS_NS. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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/Sk4px_SSE2.h ('k') | src/opts/SkNx_neon.h » ('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 #include "SkUtils.h" 8 #include "SkUtils.h"
9 9
10 namespace { // See Sk4px.h
11
10 static_assert(sizeof(Sk4px) == 16, "This file uses memcpy / sk_memset32, so exac t size matters."); 12 static_assert(sizeof(Sk4px) == 16, "This file uses memcpy / sk_memset32, so exac t size matters.");
11 13
12 SK_ALWAYS_INLINE Sk4px Sk4px::DupPMColor(SkPMColor px) { 14 inline Sk4px Sk4px::DupPMColor(SkPMColor px) {
13 Sk4px px4 = Sk16b(); 15 Sk4px px4 = Sk16b();
14 sk_memset32((uint32_t*)&px4, px, 4); 16 sk_memset32((uint32_t*)&px4, px, 4);
15 return px4; 17 return px4;
16 } 18 }
17 19
18 SK_ALWAYS_INLINE Sk4px Sk4px::Load4(const SkPMColor px[4]) { 20 inline Sk4px Sk4px::Load4(const SkPMColor px[4]) {
19 Sk4px px4 = Sk16b(); 21 Sk4px px4 = Sk16b();
20 memcpy(&px4, px, 16); 22 memcpy(&px4, px, 16);
21 return px4; 23 return px4;
22 } 24 }
23 25
24 SK_ALWAYS_INLINE Sk4px Sk4px::Load2(const SkPMColor px[2]) { 26 inline Sk4px Sk4px::Load2(const SkPMColor px[2]) {
25 Sk4px px2 = Sk16b(); 27 Sk4px px2 = Sk16b();
26 memcpy(&px2, px, 8); 28 memcpy(&px2, px, 8);
27 return px2; 29 return px2;
28 } 30 }
29 31
30 SK_ALWAYS_INLINE Sk4px Sk4px::Load1(const SkPMColor px[1]) { 32 inline Sk4px Sk4px::Load1(const SkPMColor px[1]) {
31 Sk4px px1 = Sk16b(); 33 Sk4px px1 = Sk16b();
32 memcpy(&px1, px, 4); 34 memcpy(&px1, px, 4);
33 return px1; 35 return px1;
34 } 36 }
35 37
36 SK_ALWAYS_INLINE void Sk4px::store4(SkPMColor px[4]) const { memcpy(px, this, 16 ); } 38 inline void Sk4px::store4(SkPMColor px[4]) const { memcpy(px, this, 16); }
37 SK_ALWAYS_INLINE void Sk4px::store2(SkPMColor px[2]) const { memcpy(px, this, 8 ); } 39 inline void Sk4px::store2(SkPMColor px[2]) const { memcpy(px, this, 8); }
38 SK_ALWAYS_INLINE void Sk4px::store1(SkPMColor px[1]) const { memcpy(px, this, 4 ); } 40 inline void Sk4px::store1(SkPMColor px[1]) const { memcpy(px, this, 4); }
39 41
40 SK_ALWAYS_INLINE Sk4px::Wide Sk4px::widenLo() const { 42 inline Sk4px::Wide Sk4px::widenLo() const {
41 return Sk16h(this->kth< 0>(), this->kth< 1>(), this->kth< 2>(), this->kth< 3 >(), 43 return Sk16h(this->kth< 0>(), this->kth< 1>(), this->kth< 2>(), this->kth< 3 >(),
42 this->kth< 4>(), this->kth< 5>(), this->kth< 6>(), this->kth< 7 >(), 44 this->kth< 4>(), this->kth< 5>(), this->kth< 6>(), this->kth< 7 >(),
43 this->kth< 8>(), this->kth< 9>(), this->kth<10>(), this->kth<11 >(), 45 this->kth< 8>(), this->kth< 9>(), this->kth<10>(), this->kth<11 >(),
44 this->kth<12>(), this->kth<13>(), this->kth<14>(), this->kth<15 >()); 46 this->kth<12>(), this->kth<13>(), this->kth<14>(), this->kth<15 >());
45 } 47 }
46 48
47 SK_ALWAYS_INLINE Sk4px::Wide Sk4px::widenHi() const { return this->widenLo() << 8; } 49 inline Sk4px::Wide Sk4px::widenHi() const { return this->widenLo() << 8; }
48 50
49 SK_ALWAYS_INLINE Sk4px::Wide Sk4px::widenLoHi() const { return this->widenLo() + this->widenHi(); } 51 inline Sk4px::Wide Sk4px::widenLoHi() const { return this->widenLo() + this->wid enHi(); }
50 52
51 SK_ALWAYS_INLINE Sk4px::Wide Sk4px::mulWiden(const Sk16b& other) const { 53 inline Sk4px::Wide Sk4px::mulWiden(const Sk16b& other) const {
52 return this->widenLo() * Sk4px(other).widenLo(); 54 return this->widenLo() * Sk4px(other).widenLo();
53 } 55 }
54 56
55 SK_ALWAYS_INLINE Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const { 57 inline Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const {
56 Sk4px::Wide r = (*this + other) >> 8; 58 Sk4px::Wide r = (*this + other) >> 8;
57 return Sk16b(r.kth< 0>(), r.kth< 1>(), r.kth< 2>(), r.kth< 3>(), 59 return Sk16b(r.kth< 0>(), r.kth< 1>(), r.kth< 2>(), r.kth< 3>(),
58 r.kth< 4>(), r.kth< 5>(), r.kth< 6>(), r.kth< 7>(), 60 r.kth< 4>(), r.kth< 5>(), r.kth< 6>(), r.kth< 7>(),
59 r.kth< 8>(), r.kth< 9>(), r.kth<10>(), r.kth<11>(), 61 r.kth< 8>(), r.kth< 9>(), r.kth<10>(), r.kth<11>(),
60 r.kth<12>(), r.kth<13>(), r.kth<14>(), r.kth<15>()); 62 r.kth<12>(), r.kth<13>(), r.kth<14>(), r.kth<15>());
61 } 63 }
62 64
63 SK_ALWAYS_INLINE Sk4px Sk4px::alphas() const { 65 inline Sk4px Sk4px::alphas() const {
64 static_assert(SK_A32_SHIFT == 24, "This method assumes little-endian."); 66 static_assert(SK_A32_SHIFT == 24, "This method assumes little-endian.");
65 return Sk16b(this->kth< 3>(), this->kth< 3>(), this->kth< 3>(), this->kth< 3 >(), 67 return Sk16b(this->kth< 3>(), this->kth< 3>(), this->kth< 3>(), this->kth< 3 >(),
66 this->kth< 7>(), this->kth< 7>(), this->kth< 7>(), this->kth< 7 >(), 68 this->kth< 7>(), this->kth< 7>(), this->kth< 7>(), this->kth< 7 >(),
67 this->kth<11>(), this->kth<11>(), this->kth<11>(), this->kth<11 >(), 69 this->kth<11>(), this->kth<11>(), this->kth<11>(), this->kth<11 >(),
68 this->kth<15>(), this->kth<15>(), this->kth<15>(), this->kth<15 >()); 70 this->kth<15>(), this->kth<15>(), this->kth<15>(), this->kth<15 >());
69 } 71 }
70 72
71 SK_ALWAYS_INLINE Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) { 73 inline Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) {
72 return Sk16b(a[0], a[0], a[0], a[0], 74 return Sk16b(a[0], a[0], a[0], a[0],
73 a[1], a[1], a[1], a[1], 75 a[1], a[1], a[1], a[1],
74 a[2], a[2], a[2], a[2], 76 a[2], a[2], a[2], a[2],
75 a[3], a[3], a[3], a[3]); 77 a[3], a[3], a[3], a[3]);
76 } 78 }
77 79
78 SK_ALWAYS_INLINE Sk4px Sk4px::Load2Alphas(const SkAlpha a[2]) { 80 inline Sk4px Sk4px::Load2Alphas(const SkAlpha a[2]) {
79 return Sk16b(a[0], a[0], a[0], a[0], 81 return Sk16b(a[0], a[0], a[0], a[0],
80 a[1], a[1], a[1], a[1], 82 a[1], a[1], a[1], a[1],
81 0,0,0,0, 83 0,0,0,0,
82 0,0,0,0); 84 0,0,0,0);
83 } 85 }
84 86
85 SK_ALWAYS_INLINE Sk4px Sk4px::zeroAlphas() const { 87 inline Sk4px Sk4px::zeroAlphas() const {
86 static_assert(SK_A32_SHIFT == 24, "This method assumes little-endian."); 88 static_assert(SK_A32_SHIFT == 24, "This method assumes little-endian.");
87 return Sk16b(this->kth< 0>(), this->kth< 1>(), this->kth< 2>(), 0, 89 return Sk16b(this->kth< 0>(), this->kth< 1>(), this->kth< 2>(), 0,
88 this->kth< 4>(), this->kth< 5>(), this->kth< 6>(), 0, 90 this->kth< 4>(), this->kth< 5>(), this->kth< 6>(), 0,
89 this->kth< 8>(), this->kth< 9>(), this->kth<10>(), 0, 91 this->kth< 8>(), this->kth< 9>(), this->kth<10>(), 0,
90 this->kth<12>(), this->kth<13>(), this->kth<14>(), 0); 92 this->kth<12>(), this->kth<13>(), this->kth<14>(), 0);
91 } 93 }
92 94
93 SK_ALWAYS_INLINE Sk4px Sk4px::zeroColors() const { 95 inline Sk4px Sk4px::zeroColors() const {
94 static_assert(SK_A32_SHIFT == 24, "This method assumes little-endian."); 96 static_assert(SK_A32_SHIFT == 24, "This method assumes little-endian.");
95 return Sk16b(0,0,0, this->kth< 3>(), 97 return Sk16b(0,0,0, this->kth< 3>(),
96 0,0,0, this->kth< 7>(), 98 0,0,0, this->kth< 7>(),
97 0,0,0, this->kth<11>(), 99 0,0,0, this->kth<11>(),
98 0,0,0, this->kth<15>()); 100 0,0,0, this->kth<15>());
99 } 101 }
100 102
101 SK_ALWAYS_INLINE Sk4px Sk4px::Load4(const SkPMColor16 src[4]) { 103 inline Sk4px Sk4px::Load4(const SkPMColor16 src[4]) {
102 SkPMColor src32[4]; 104 SkPMColor src32[4];
103 for (int i = 0; i < 4; i++) { src32[i] = SkPixel16ToPixel32(src[i]); } 105 for (int i = 0; i < 4; i++) { src32[i] = SkPixel16ToPixel32(src[i]); }
104 return Load4(src32); 106 return Load4(src32);
105 } 107 }
106 SK_ALWAYS_INLINE Sk4px Sk4px::Load2(const SkPMColor16 src[2]) { 108 inline Sk4px Sk4px::Load2(const SkPMColor16 src[2]) {
107 SkPMColor src32[2]; 109 SkPMColor src32[2];
108 for (int i = 0; i < 2; i++) { src32[i] = SkPixel16ToPixel32(src[i]); } 110 for (int i = 0; i < 2; i++) { src32[i] = SkPixel16ToPixel32(src[i]); }
109 return Load2(src32); 111 return Load2(src32);
110 } 112 }
111 SK_ALWAYS_INLINE Sk4px Sk4px::Load1(const SkPMColor16 src[1]) { 113 inline Sk4px Sk4px::Load1(const SkPMColor16 src[1]) {
112 SkPMColor src32 = SkPixel16ToPixel32(src[0]); 114 SkPMColor src32 = SkPixel16ToPixel32(src[0]);
113 return Load1(&src32); 115 return Load1(&src32);
114 } 116 }
115 117
116 SK_ALWAYS_INLINE void Sk4px::store4(SkPMColor16 dst[4]) const { 118 inline void Sk4px::store4(SkPMColor16 dst[4]) const {
117 SkPMColor dst32[4]; 119 SkPMColor dst32[4];
118 this->store4(dst32); 120 this->store4(dst32);
119 for (int i = 0; i < 4; i++) { dst[i] = SkPixel32ToPixel16(dst32[i]); } 121 for (int i = 0; i < 4; i++) { dst[i] = SkPixel32ToPixel16(dst32[i]); }
120 } 122 }
121 SK_ALWAYS_INLINE void Sk4px::store2(SkPMColor16 dst[2]) const { 123 inline void Sk4px::store2(SkPMColor16 dst[2]) const {
122 SkPMColor dst32[2]; 124 SkPMColor dst32[2];
123 this->store2(dst32); 125 this->store2(dst32);
124 for (int i = 0; i < 2; i++) { dst[i] = SkPixel32ToPixel16(dst32[i]); } 126 for (int i = 0; i < 2; i++) { dst[i] = SkPixel32ToPixel16(dst32[i]); }
125 } 127 }
126 SK_ALWAYS_INLINE void Sk4px::store1(SkPMColor16 dst[1]) const { 128 inline void Sk4px::store1(SkPMColor16 dst[1]) const {
127 SkPMColor dst32; 129 SkPMColor dst32;
128 this->store1(&dst32); 130 this->store1(&dst32);
129 dst[0] = SkPixel32ToPixel16(dst32); 131 dst[0] = SkPixel32ToPixel16(dst32);
130 } 132 }
133
134 } // namespace
OLDNEW
« no previous file with comments | « src/opts/Sk4px_SSE2.h ('k') | src/opts/SkNx_neon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698