OLD | NEW |
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 SkPM_DEFINED | 8 #ifndef SkPM_DEFINED |
9 #define SkPM_DEFINED | 9 #define SkPM_DEFINED |
10 | 10 |
11 #include "SkTypes.h" | 11 #include "SkTypes.h" |
12 #include "SkColor.h" | 12 #include "SkColor.h" |
13 #include "SkColorPriv.h" | 13 #include "SkColorPriv.h" |
14 #include "SkNx.h" | 14 #include "SkNx.h" |
15 | 15 |
16 // This file may be included multiple times by .cpp files with different flags,
leading | |
17 // to different definitions. Usually that doesn't matter because it's all inlin
ed, but | |
18 // in Debug modes the compilers may not inline everything. So wrap everything i
n an | |
19 // anonymous namespace to give each includer their own silo of this code (or the
linker | |
20 // will probably pick one randomly for us, which is rarely correct). | |
21 namespace { | |
22 | |
23 // A pre-multiplied color storing each component in the same order as SkPMColor, | 16 // A pre-multiplied color storing each component in the same order as SkPMColor, |
24 // but as a float in the range [0, 1]. | 17 // but as a float in the range [0, 1]. |
25 class SkPMFloat : public Sk4f { | 18 class SkPMFloat : public Sk4f { |
26 public: | 19 public: |
27 static SkPMFloat FromPMColor(SkPMColor c) { return SkPMFloat(c); } | 20 static SkPMFloat FromPMColor(SkPMColor c) { return SkPMFloat(c); } |
28 static SkPMFloat FromARGB(float a, float r, float g, float b) { return SkPMF
loat(a,r,g,b); } | 21 static SkPMFloat FromARGB(float a, float r, float g, float b) { return SkPMF
loat(a,r,g,b); } |
29 | 22 |
30 Sk4f alphas() const; // argb -> aaaa, generally faster than the equivalent
Sk4f(this->a()). | 23 Sk4f alphas() const; // argb -> aaaa, generally faster than the equivalent
Sk4f(this->a()). |
31 | 24 |
32 // Uninitialized. | 25 // Uninitialized. |
(...skipping 19 matching lines...) Expand all Loading... |
52 return this->a() >= 0 && this->a() <= 1 | 45 return this->a() >= 0 && this->a() <= 1 |
53 && this->r() >= 0 && this->r() <= this->a() | 46 && this->r() >= 0 && this->r() <= this->a() |
54 && this->g() >= 0 && this->g() <= this->a() | 47 && this->g() >= 0 && this->g() <= this->a() |
55 && this->b() >= 0 && this->b() <= this->a(); | 48 && this->b() >= 0 && this->b() <= this->a(); |
56 } | 49 } |
57 | 50 |
58 private: | 51 private: |
59 typedef Sk4f INHERITED; | 52 typedef Sk4f INHERITED; |
60 }; | 53 }; |
61 | 54 |
62 } // namespace | |
63 | |
64 #ifdef SKNX_NO_SIMD | 55 #ifdef SKNX_NO_SIMD |
65 // Platform implementations of SkPMFloat assume Sk4f uses SSE or NEON. _non
e is generic. | 56 // Platform implementations of SkPMFloat assume Sk4f uses SSE or NEON. _non
e is generic. |
66 #include "../opts/SkPMFloat_none.h" | 57 #include "../opts/SkPMFloat_none.h" |
67 #else | 58 #else |
68 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 | 59 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 |
69 #include "../opts/SkPMFloat_sse.h" | 60 #include "../opts/SkPMFloat_sse.h" |
70 #elif defined(SK_ARM_HAS_NEON) | 61 #elif defined(SK_ARM_HAS_NEON) |
71 #include "../opts/SkPMFloat_neon.h" | 62 #include "../opts/SkPMFloat_neon.h" |
72 #else | 63 #else |
73 #include "../opts/SkPMFloat_none.h" | 64 #include "../opts/SkPMFloat_none.h" |
74 #endif | 65 #endif |
75 #endif | 66 #endif |
76 | 67 |
77 #endif//SkPM_DEFINED | 68 #endif//SkPM_DEFINED |
OLD | NEW |