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

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

Issue 1317233005: SkPx: new approach to fixed-point SIMD (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: shl,shr Created 5 years, 1 month 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/opts/SkBlitMask_opts.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkPx_DEFINED
9 #define SkPx_DEFINED
10
11 #include "SkTypes.h"
12 #include "SkColorPriv.h"
13
14 // We'll include one of src/opts/SkPx_{sse,neon,none}.h to define a type SkPx.
15 //
16 // SkPx represents up to SkPx::N 8888 pixels. It's agnostic to whether these
17 // are SkColors or SkPMColors; it only assumes that alpha is the high byte.
18 static_assert(SK_A32_SHIFT == 24, "For both SkColor and SkPMColor, alpha is alwa ys the high byte.");
19 //
20 // SkPx::Alpha represents up to SkPx::N 8-bit values, usually coverage or alpha.
21 // SkPx::Wide represents up to SkPx::N pixels with 16 bits per component.
22 //
23 // SkPx supports the following methods:
24 // static SkPx Dup(uint32_t);
25 // static SkPx Load(const uint32_t*);
26 // static SkPx Load(const uint32_t*, int n); // where 0<n<SkPx::N
27 // void store(uint32_t*) const;
28 // void store(uint32_t*, int n) const; // where 0<n<SkPx::N
29 //
30 // Alpha alpha() const; // argb -> a
31 // Wide widenLo() const; // argb -> 0a0r0g0b
32 // Wide widenHi() const; // argb -> a0r0g0b0
33 // Wide widenLoHi() const; // argb -> aarrggbb
34 //
35 // SkPx operator+(const SkPx&) const;
36 // SkPx operator-(const SkPx&) const;
37 // SkPx saturatedAdd(const SkPx&) const;
38 //
39 // Wide operator*(const Alpha&) const; // argb * A -> (a*A)(r*A)(g*A)(b*A)
40 //
41 // // Fast approximate (px*a+127)/255.
42 // // Never off by more than 1, and always correct when px or a is 0 or 255.
43 // // We use the approximation (px*a+px)/256.
44 // SkPx approxMulDiv255(const Alpha&) const;
45 //
46 // SkPx addAlpha(const Alpha&) const; // argb + A -> (a+A)rgb
47 //
48 // SkPx::Alpha supports the following methods:
49 // static Alpha Dup(uint8_t);
50 // static Alpha Load(const uint8_t*);
51 // static Alpha Load(const uint8_t*, int n); // where 0<n<SkPx::N
52 //
53 // Alpha inv() const; // a -> 255-a
54 //
55 // SkPx::Wide supports the following methods:
56 // Wide operator+(const Wide&);
57 // Wide operator-(const Wide&);
58 // Wide shl<int bits>();
59 // Wide shr<int bits>();
60 //
61 // // Return the high byte of each component of (*this + o.widenLo()).
62 // SkPx addNarrowHi(const SkPx& o);
63 //
64 // Methods left unwritten, but certainly to come:
65 // SkPx SkPx::operator<(const SkPx&) const;
66 // SkPx SkPx::thenElse(const SkPx& then, const SkPx& else) const;
67 // Wide Wide::operator<(const Wide&) const;
68 // Wide Wide::thenElse(const Wide& then, const Wide& else) const;
69 //
70 // SkPx Wide::div255() const; // Rounds, think (*this + 127) / 255.
71 //
72 // The different implementations of SkPx have complete freedom to choose
73 // SkPx::N and how they represent SkPx, SkPx::Alpha, and SkPx::Wide.
74 //
75 // All observable math must remain identical.
76
77 #if defined(SKNX_NO_SIMD)
78 #include "../opts/SkPx_none.h"
79 #else
80 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
81 #include "../opts/SkPx_sse.h"
82 #elif defined(SK_ARM_HAS_NEON)
83 #include "../opts/SkPx_neon.h"
84 #else
85 #include "../opts/SkPx_none.h"
86 #endif
87 #endif
88
89 #endif//SkPx_DEFINED
OLDNEW
« no previous file with comments | « no previous file | src/opts/SkBlitMask_opts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698