OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 SkLinearGradient_DEFINED | 8 #ifndef SkLinearGradient_DEFINED |
9 #define SkLinearGradient_DEFINED | 9 #define SkLinearGradient_DEFINED |
10 | 10 |
11 #include "SkGradientShaderPriv.h" | 11 #include "SkGradientShaderPriv.h" |
12 #include "SkNx.h" | 12 #include "SkNx.h" |
13 | 13 |
14 struct Sk4fStorage { | 14 struct Sk4fStorage { |
15 float fArray[4]; | 15 float fArray[4]; |
16 | 16 |
17 operator Sk4f() const { | 17 operator Sk4f() const { |
18 return Sk4f::Load(fArray); | 18 return Sk4f::Load(fArray); |
19 } | 19 } |
20 | 20 |
21 Sk4fStorage& operator=(const Sk4f& src) { | 21 Sk4fStorage& operator=(const Sk4f& src) { |
22 src.store(fArray); | 22 src.store(fArray); |
23 return *this; | 23 return *this; |
24 } | 24 } |
25 }; | 25 }; |
26 | 26 |
27 class SkLinearGradient : public SkGradientShaderBase { | 27 class SkLinearGradient : public SkGradientShaderBase { |
28 public: | 28 public: |
| 29 enum { |
| 30 // Temp flag for testing the 4f impl. |
| 31 kForce4fContext_PrivateFlag = 1 << 7, |
| 32 }; |
| 33 |
29 SkLinearGradient(const SkPoint pts[2], const Descriptor&); | 34 SkLinearGradient(const SkPoint pts[2], const Descriptor&); |
30 | 35 |
31 size_t contextSize() const override; | 36 size_t contextSize() const override; |
32 | 37 |
33 class LinearGradientContext : public SkGradientShaderBase::GradientShaderBas
eContext { | 38 class LinearGradientContext : public SkGradientShaderBase::GradientShaderBas
eContext { |
34 public: | 39 public: |
35 LinearGradientContext(const SkLinearGradient&, const ContextRec&); | 40 LinearGradientContext(const SkLinearGradient&, const ContextRec&); |
36 | 41 |
37 void shadeSpan(int x, int y, SkPMColor dstC[], int count) override; | 42 void shadeSpan(int x, int y, SkPMColor dstC[], int count) override; |
38 | 43 |
(...skipping 23 matching lines...) Expand all Loading... |
62 | 67 |
63 SK_TO_STRING_OVERRIDE() | 68 SK_TO_STRING_OVERRIDE() |
64 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLinearGradient) | 69 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLinearGradient) |
65 | 70 |
66 protected: | 71 protected: |
67 SkLinearGradient(SkReadBuffer& buffer); | 72 SkLinearGradient(SkReadBuffer& buffer); |
68 void flatten(SkWriteBuffer& buffer) const override; | 73 void flatten(SkWriteBuffer& buffer) const override; |
69 Context* onCreateContext(const ContextRec&, void* storage) const override; | 74 Context* onCreateContext(const ContextRec&, void* storage) const override; |
70 | 75 |
71 private: | 76 private: |
| 77 class LinearGradient4fContext; |
| 78 |
72 friend class SkGradientShader; | 79 friend class SkGradientShader; |
73 typedef SkGradientShaderBase INHERITED; | 80 typedef SkGradientShaderBase INHERITED; |
74 const SkPoint fStart; | 81 const SkPoint fStart; |
75 const SkPoint fEnd; | 82 const SkPoint fEnd; |
76 }; | 83 }; |
77 | 84 |
78 #endif | 85 #endif |
OLD | NEW |