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 |
16 // A pre-multiplied color storing each component in the same order as SkPMColor, | 23 // A pre-multiplied color storing each component in the same order as SkPMColor, |
17 // but as a float in the range [0, 1]. | 24 // but as a float in the range [0, 1]. |
18 class SkPMFloat : public Sk4f { | 25 class SkPMFloat : public Sk4f { |
19 public: | 26 public: |
20 static SkPMFloat FromPMColor(SkPMColor c) { return SkPMFloat(c); } | 27 static SkPMFloat FromPMColor(SkPMColor c) { return SkPMFloat(c); } |
21 static SkPMFloat FromARGB(float a, float r, float g, float b) { return SkPMF
loat(a,r,g,b); } | 28 static SkPMFloat FromARGB(float a, float r, float g, float b) { return SkPMF
loat(a,r,g,b); } |
22 | 29 |
23 Sk4f alphas() const; // argb -> aaaa, generally faster than the equivalent
Sk4f(this->a()). | 30 Sk4f alphas() const; // argb -> aaaa, generally faster than the equivalent
Sk4f(this->a()). |
24 | 31 |
25 // Uninitialized. | 32 // Uninitialized. |
(...skipping 19 matching lines...) Expand all Loading... |
45 return this->a() >= 0 && this->a() <= 1 | 52 return this->a() >= 0 && this->a() <= 1 |
46 && this->r() >= 0 && this->r() <= this->a() | 53 && this->r() >= 0 && this->r() <= this->a() |
47 && this->g() >= 0 && this->g() <= this->a() | 54 && this->g() >= 0 && this->g() <= this->a() |
48 && this->b() >= 0 && this->b() <= this->a(); | 55 && this->b() >= 0 && this->b() <= this->a(); |
49 } | 56 } |
50 | 57 |
51 private: | 58 private: |
52 typedef Sk4f INHERITED; | 59 typedef Sk4f INHERITED; |
53 }; | 60 }; |
54 | 61 |
| 62 } // namespace |
| 63 |
55 #ifdef SKNX_NO_SIMD | 64 #ifdef SKNX_NO_SIMD |
56 // Platform implementations of SkPMFloat assume Sk4f uses SSE or NEON. _non
e is generic. | 65 // Platform implementations of SkPMFloat assume Sk4f uses SSE or NEON. _non
e is generic. |
57 #include "../opts/SkPMFloat_none.h" | 66 #include "../opts/SkPMFloat_none.h" |
58 #else | 67 #else |
59 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 | 68 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 |
60 #include "../opts/SkPMFloat_sse.h" | 69 #include "../opts/SkPMFloat_sse.h" |
61 #elif defined(SK_ARM_HAS_NEON) | 70 #elif defined(SK_ARM_HAS_NEON) |
62 #include "../opts/SkPMFloat_neon.h" | 71 #include "../opts/SkPMFloat_neon.h" |
63 #else | 72 #else |
64 #include "../opts/SkPMFloat_none.h" | 73 #include "../opts/SkPMFloat_none.h" |
65 #endif | 74 #endif |
66 #endif | 75 #endif |
67 | 76 |
68 #endif//SkPM_DEFINED | 77 #endif//SkPM_DEFINED |
OLD | NEW |