OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #ifndef SkTwoPointRadialGradient_DEFINED | 9 #ifndef SkTwoPointRadialGradient_DEFINED |
10 #define SkTwoPointRadialGradient_DEFINED | 10 #define SkTwoPointRadialGradient_DEFINED |
11 | 11 |
12 #include "SkGradientShaderPriv.h" | 12 #include "SkGradientShaderPriv.h" |
13 | 13 |
14 class SkTwoPointRadialGradient : public SkGradientShaderBase { | 14 class SkTwoPointRadialGradient : public SkGradientShaderBase { |
15 public: | 15 public: |
16 SkTwoPointRadialGradient(const SkPoint& start, SkScalar startRadius, | 16 SkTwoPointRadialGradient(const SkPoint& start, SkScalar startRadius, |
17 const SkPoint& end, SkScalar endRadius, | 17 const SkPoint& end, SkScalar endRadius, |
18 const Descriptor&); | 18 const Descriptor&); |
19 | 19 |
20 virtual BitmapType asABitmap(SkBitmap* bitmap, | 20 virtual BitmapType asABitmap(SkBitmap* bitmap, |
21 SkMatrix* matrix, | 21 SkMatrix* matrix, |
22 TileMode* xy) const SK_OVERRIDE; | 22 TileMode* xy) const SK_OVERRIDE; |
23 virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE; | 23 GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE; |
24 virtual bool asFragmentProcessor(GrContext* context, const SkPaint&, const S
kMatrix& viewM, | 24 virtual bool asFragmentProcessor(GrContext* context, const SkPaint&, const S
kMatrix& viewM, |
25 const SkMatrix*, GrColor*, | 25 const SkMatrix*, GrColor*, |
26 GrFragmentProcessor**) const SK_OVERRIDE; | 26 GrFragmentProcessor**) const SK_OVERRIDE; |
27 | 27 |
28 virtual size_t contextSize() const SK_OVERRIDE; | 28 size_t contextSize() const SK_OVERRIDE; |
29 | 29 |
30 class TwoPointRadialGradientContext : public SkGradientShaderBase::GradientS
haderBaseContext { | 30 class TwoPointRadialGradientContext : public SkGradientShaderBase::GradientS
haderBaseContext { |
31 public: | 31 public: |
32 TwoPointRadialGradientContext(const SkTwoPointRadialGradient&, const Con
textRec&); | 32 TwoPointRadialGradientContext(const SkTwoPointRadialGradient&, const Con
textRec&); |
33 | 33 |
34 virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVE
RRIDE; | 34 void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVERRIDE; |
35 | 35 |
36 private: | 36 private: |
37 typedef SkGradientShaderBase::GradientShaderBaseContext INHERITED; | 37 typedef SkGradientShaderBase::GradientShaderBaseContext INHERITED; |
38 }; | 38 }; |
39 | 39 |
40 SkScalar getCenterX1() const { return fDiff.length(); } | 40 SkScalar getCenterX1() const { return fDiff.length(); } |
41 SkScalar getStartRadius() const { return fStartRadius; } | 41 SkScalar getStartRadius() const { return fStartRadius; } |
42 SkScalar getDiffRadius() const { return fDiffRadius; } | 42 SkScalar getDiffRadius() const { return fDiffRadius; } |
43 | 43 |
44 SK_TO_STRING_OVERRIDE() | 44 SK_TO_STRING_OVERRIDE() |
45 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTwoPointRadialGradient
) | 45 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTwoPointRadialGradient
) |
46 | 46 |
47 protected: | 47 protected: |
48 SkTwoPointRadialGradient(SkReadBuffer& buffer); | 48 SkTwoPointRadialGradient(SkReadBuffer& buffer); |
49 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; | 49 void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; |
50 virtual Context* onCreateContext(const ContextRec&, void* storage) const SK_
OVERRIDE; | 50 Context* onCreateContext(const ContextRec&, void* storage) const SK_OVERRIDE
; |
51 | 51 |
52 private: | 52 private: |
53 const SkPoint fCenter1; | 53 const SkPoint fCenter1; |
54 const SkPoint fCenter2; | 54 const SkPoint fCenter2; |
55 const SkScalar fRadius1; | 55 const SkScalar fRadius1; |
56 const SkScalar fRadius2; | 56 const SkScalar fRadius2; |
57 SkPoint fDiff; | 57 SkPoint fDiff; |
58 SkScalar fStartRadius, fDiffRadius, fSr2D2, fA, fOneOverTwoA; | 58 SkScalar fStartRadius, fDiffRadius, fSr2D2, fA, fOneOverTwoA; |
59 | 59 |
60 friend class SkGradientShader; | 60 friend class SkGradientShader; |
61 typedef SkGradientShaderBase INHERITED; | 61 typedef SkGradientShaderBase INHERITED; |
62 }; | 62 }; |
63 | 63 |
64 #endif | 64 #endif |
OLD | NEW |