Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | List of all members
Sk4px Class Reference

#include <Sk4px.h>

Classes

class  Wide
 

Public Member Functions

 Sk4px (const skvx::byte16 &v)
 
Sk4px alphas () const
 
Sk4px inv () const
 
void store4 (SkPMColor px[4]) const
 
void store2 (SkPMColor px[2]) const
 
void store1 (SkPMColor px[1]) const
 
Wide widen () const
 
Wide mulWiden (const skvx::byte16 &o) const
 
Wide operator* (const Sk4px &o) const
 
Sk4px operator+ (const Sk4px &o) const
 
Sk4px operator- (const Sk4px &o) const
 
Sk4px operator< (const Sk4px &o) const
 
Sk4px operator& (const Sk4px &o) const
 
Sk4px thenElse (const Sk4px &t, const Sk4px &e) const
 
Sk4px approxMulDiv255 (const Sk4px &o) const
 
Sk4px saturatedAdd (const Sk4px &o) const
 

Static Public Member Functions

static Sk4px DupPMColor (SkPMColor c)
 
static Sk4px Load4 (const SkPMColor px[4])
 
static Sk4px Load2 (const SkPMColor px[2])
 
static Sk4px Load1 (const SkPMColor px[1])
 
static Sk4px Load4Alphas (const SkAlpha alphas[4])
 
static Sk4px Load2Alphas (const SkAlpha alphas[2])
 
template<typename Fn >
static void MapSrc (int n, SkPMColor *dst, const SkPMColor *src, const Fn &fn)
 
template<typename Fn >
static void MapDstSrc (int n, SkPMColor *dst, const SkPMColor *src, const Fn &fn)
 
template<typename Fn >
static void MapDstAlpha (int n, SkPMColor *dst, const SkAlpha *a, const Fn &fn)
 
template<typename Fn >
static void MapDstSrcAlpha (int n, SkPMColor *dst, const SkPMColor *src, const SkAlpha *a, const Fn &fn)
 

Detailed Description

Definition at line 16 of file Sk4px.h.

Constructor & Destructor Documentation

◆ Sk4px()

Sk4px::Sk4px ( const skvx::byte16 v)
inline

Definition at line 18 of file Sk4px.h.

18: fV(v) {}

Member Function Documentation

◆ alphas()

Sk4px Sk4px::alphas ( ) const
inline

Definition at line 29 of file Sk4px.h.

29 {
30 static_assert(SK_A32_SHIFT == 24, "This method assumes little-endian.");
31 return Sk4px(skvx::shuffle<3,3,3,3, 7,7,7,7, 11,11,11,11, 15,15,15,15>(fV));
32 }
#define SK_A32_SHIFT
Definition SkTypes.h:54
Definition Sk4px.h:16

◆ approxMulDiv255()

Sk4px Sk4px::approxMulDiv255 ( const Sk4px o) const
inline

Definition at line 105 of file Sk4px.h.

105 {
106 return Sk4px(approx_scale(fV, o.fV));
107 }
SIN Vec< N, uint8_t > approx_scale(const Vec< N, uint8_t > &x, const Vec< N, uint8_t > &y)
Definition SkVx.h:824

◆ DupPMColor()

static Sk4px Sk4px::DupPMColor ( SkPMColor  c)
inlinestatic

Definition at line 20 of file Sk4px.h.

20 {
21 skvx::uint4 splat(c);
22
23 Sk4px v;
24 memcpy((void*)&v, &splat, 16);
25 return v;
26 }

◆ inv()

Sk4px Sk4px::inv ( ) const
inline

Definition at line 33 of file Sk4px.h.

33{ return Sk4px(skvx::byte16(255) - fV); }

◆ Load1()

static Sk4px Sk4px::Load1 ( const SkPMColor  px[1])
inlinestatic

Definition at line 46 of file Sk4px.h.

46 {
47 Sk4px v;
48 memcpy((void*)&v, px, 4);
49 return v;
50 }

◆ Load2()

static Sk4px Sk4px::Load2 ( const SkPMColor  px[2])
inlinestatic

Definition at line 41 of file Sk4px.h.

41 {
42 Sk4px v;
43 memcpy((void*)&v, px, 8);
44 return v;
45 }

◆ Load2Alphas()

static Sk4px Sk4px::Load2Alphas ( const SkAlpha  alphas[2])
inlinestatic

Definition at line 59 of file Sk4px.h.

59 {
61 return Sk4px(join(skvx::shuffle<0,0,0,0, 1,1,1,1>(a), skvx::byte8()));
62 }
Sk4px alphas() const
Definition Sk4px.h:29
struct MyStruct a[10]
SINT Vec< 2 *N, T > join(const Vec< N, T > &lo, const Vec< N, T > &hi)
Definition SkVx.h:242
static SKVX_ALWAYS_INLINE Vec Load(const void *ptr)
Definition SkVx.h:109

◆ Load4()

static Sk4px Sk4px::Load4 ( const SkPMColor  px[4])
inlinestatic

Definition at line 36 of file Sk4px.h.

36 {
37 Sk4px v;
38 memcpy((void*)&v, px, 16);
39 return v;
40 }

◆ Load4Alphas()

static Sk4px Sk4px::Load4Alphas ( const SkAlpha  alphas[4])
inlinestatic

Definition at line 54 of file Sk4px.h.

54 {
56 return Sk4px(skvx::shuffle<0,0,0,0, 1,1,1,1, 2,2,2,2, 3,3,3,3>(a));
57 }

◆ MapDstAlpha()

template<typename Fn >
static void Sk4px::MapDstAlpha ( int  n,
SkPMColor dst,
const SkAlpha a,
const Fn &  fn 
)
inlinestatic

Definition at line 179 of file Sk4px.h.

180 {
181 SkASSERT(dst);
182 SkASSERT(a);
183 while (n > 0) {
184 if (n >= 8) {
185 Sk4px dst0 = fn(Load4(dst+0), Load4Alphas(a+0)),
186 dst4 = fn(Load4(dst+4), Load4Alphas(a+4));
187 dst0.store4(dst+0);
188 dst4.store4(dst+4);
189 dst += 8; a += 8; n -= 8;
190 continue; // Keep our stride at 8 pixels as long as possible.
191 }
192 SkASSERT(n <= 7);
193 if (n >= 4) {
194 fn(Load4(dst), Load4Alphas(a)).store4(dst);
195 dst += 4; a += 4; n -= 4;
196 }
197 if (n >= 2) {
198 fn(Load2(dst), Load2Alphas(a)).store2(dst);
199 dst += 2; a += 2; n -= 2;
200 }
201 if (n >= 1) {
202 fn(Load1(dst), skvx::byte16(*a)).store1(dst);
203 }
204 break;
205 }
206 }
#define SkASSERT(cond)
Definition SkAssert.h:116
static Sk4px Load2Alphas(const SkAlpha alphas[2])
Definition Sk4px.h:59
static Sk4px Load4Alphas(const SkAlpha alphas[4])
Definition Sk4px.h:54
static Sk4px Load2(const SkPMColor px[2])
Definition Sk4px.h:41
void store4(SkPMColor px[4]) const
Definition Sk4px.h:64
static Sk4px Load1(const SkPMColor px[1])
Definition Sk4px.h:46
static Sk4px Load4(const SkPMColor px[4])
Definition Sk4px.h:36
dst
Definition cp.py:12

◆ MapDstSrc()

template<typename Fn >
static void Sk4px::MapDstSrc ( int  n,
SkPMColor dst,
const SkPMColor src,
const Fn &  fn 
)
inlinestatic

Definition at line 148 of file Sk4px.h.

149 {
150 SkASSERT(dst);
151 SkASSERT(src);
152 while (n > 0) {
153 if (n >= 8) {
154 Sk4px dst0 = fn(Load4(dst+0), Load4(src+0)),
155 dst4 = fn(Load4(dst+4), Load4(src+4));
156 dst0.store4(dst+0);
157 dst4.store4(dst+4);
158 dst += 8; src += 8; n -= 8;
159 continue; // Keep our stride at 8 pixels as long as possible.
160 }
161 SkASSERT(n <= 7);
162 if (n >= 4) {
163 fn(Load4(dst), Load4(src)).store4(dst);
164 dst += 4; src += 4; n -= 4;
165 }
166 if (n >= 2) {
167 fn(Load2(dst), Load2(src)).store2(dst);
168 dst += 2; src += 2; n -= 2;
169 }
170 if (n >= 1) {
171 fn(Load1(dst), Load1(src)).store1(dst);
172 }
173 break;
174 }
175 }

◆ MapDstSrcAlpha()

template<typename Fn >
static void Sk4px::MapDstSrcAlpha ( int  n,
SkPMColor dst,
const SkPMColor src,
const SkAlpha a,
const Fn &  fn 
)
inlinestatic

Definition at line 210 of file Sk4px.h.

211 {
212 SkASSERT(dst);
213 SkASSERT(src);
214 SkASSERT(a);
215 while (n > 0) {
216 if (n >= 8) {
217 Sk4px dst0 = fn(Load4(dst+0), Load4(src+0), Load4Alphas(a+0)),
218 dst4 = fn(Load4(dst+4), Load4(src+4), Load4Alphas(a+4));
219 dst0.store4(dst+0);
220 dst4.store4(dst+4);
221 dst += 8; src += 8; a += 8; n -= 8;
222 continue; // Keep our stride at 8 pixels as long as possible.
223 }
224 SkASSERT(n <= 7);
225 if (n >= 4) {
226 fn(Load4(dst), Load4(src), Load4Alphas(a)).store4(dst);
227 dst += 4; src += 4; a += 4; n -= 4;
228 }
229 if (n >= 2) {
230 fn(Load2(dst), Load2(src), Load2Alphas(a)).store2(dst);
231 dst += 2; src += 2; a += 2; n -= 2;
232 }
233 if (n >= 1) {
234 fn(Load1(dst), Load1(src), skvx::byte16(*a)).store1(dst);
235 }
236 break;
237 }
238 }

◆ MapSrc()

template<typename Fn >
static void Sk4px::MapSrc ( int  n,
SkPMColor dst,
const SkPMColor src,
const Fn &  fn 
)
inlinestatic

Definition at line 116 of file Sk4px.h.

116 {
117 SkASSERT(dst);
118 SkASSERT(src);
119 // This looks a bit odd, but it helps loop-invariant hoisting across different calls to fn.
120 // Basically, we need to make sure we keep things inside a single loop.
121 while (n > 0) {
122 if (n >= 8) {
123 Sk4px dst0 = fn(Load4(src+0)),
124 dst4 = fn(Load4(src+4));
125 dst0.store4(dst+0);
126 dst4.store4(dst+4);
127 dst += 8; src += 8; n -= 8;
128 continue; // Keep our stride at 8 pixels as long as possible.
129 }
130 SkASSERT(n <= 7);
131 if (n >= 4) {
132 fn(Load4(src)).store4(dst);
133 dst += 4; src += 4; n -= 4;
134 }
135 if (n >= 2) {
136 fn(Load2(src)).store2(dst);
137 dst += 2; src += 2; n -= 2;
138 }
139 if (n >= 1) {
140 fn(Load1(src)).store1(dst);
141 }
142 break;
143 }
144 }

◆ mulWiden()

Wide Sk4px::mulWiden ( const skvx::byte16 o) const
inline

Definition at line 90 of file Sk4px.h.

90{ return Wide(mull(fV, o)); }
SIN Vec< N, uint16_t > mull(const Vec< N, uint8_t > &x, const Vec< N, uint8_t > &y)
Definition SkVx.h:906

◆ operator&()

Sk4px Sk4px::operator& ( const Sk4px o) const
inline

Definition at line 98 of file Sk4px.h.

98{ return Sk4px(fV & o.fV); }

◆ operator*()

Wide Sk4px::operator* ( const Sk4px o) const
inline

Definition at line 93 of file Sk4px.h.

93{ return this->mulWiden(o.fV); }
Wide mulWiden(const skvx::byte16 &o) const
Definition Sk4px.h:90

◆ operator+()

Sk4px Sk4px::operator+ ( const Sk4px o) const
inline

Definition at line 95 of file Sk4px.h.

95{ return Sk4px(fV + o.fV); }

◆ operator-()

Sk4px Sk4px::operator- ( const Sk4px o) const
inline

Definition at line 96 of file Sk4px.h.

96{ return Sk4px(fV - o.fV); }

◆ operator<()

Sk4px Sk4px::operator< ( const Sk4px o) const
inline

Definition at line 97 of file Sk4px.h.

97{ return Sk4px(fV < o.fV); }

◆ saturatedAdd()

Sk4px Sk4px::saturatedAdd ( const Sk4px o) const
inline

Definition at line 109 of file Sk4px.h.

109 {
110 return Sk4px(saturated_add(fV, o.fV));
111 }
SINT std::enable_if_t< std::is_unsigned_v< T >, Vec< N, T > > saturated_add(const Vec< N, T > &x, const Vec< N, T > &y)
Definition SkVx.h:833

◆ store1()

void Sk4px::store1 ( SkPMColor  px[1]) const
inline

Definition at line 66 of file Sk4px.h.

66{ memcpy(px, this, 4); }

◆ store2()

void Sk4px::store2 ( SkPMColor  px[2]) const
inline

Definition at line 65 of file Sk4px.h.

65{ memcpy(px, this, 8); }

◆ store4()

void Sk4px::store4 ( SkPMColor  px[4]) const
inline

Definition at line 64 of file Sk4px.h.

64{ memcpy(px, this, 16); }

◆ thenElse()

Sk4px Sk4px::thenElse ( const Sk4px t,
const Sk4px e 
) const
inline

Definition at line 99 of file Sk4px.h.

99 {
100 return Sk4px(if_then_else(fV, t.fV, e.fV));
101 }
SI T if_then_else(C cond, T t, T e)

◆ widen()

Wide Sk4px::widen ( ) const
inline

Definition at line 88 of file Sk4px.h.

88{ return Wide(skvx::cast<uint16_t>(fV)); }

The documentation for this class was generated from the following file: