Chromium Code Reviews| 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 SkTwoPointConicalGradient_DEFINED | 9 #ifndef SkTwoPointConicalGradient_DEFINED |
| 10 #define SkTwoPointConicalGradient_DEFINED | 10 #define SkTwoPointConicalGradient_DEFINED |
| 11 | 11 |
| 12 #include "SkGradientShaderPriv.h" | 12 #include "SkGradientShaderPriv.h" |
| 13 | 13 |
| 14 // TODO(dominikg): Worth making it truly immutable (i.e. set values in construct or)? | |
| 15 // Should only be initialized once via init(). Immutable afterwards. | |
| 14 struct TwoPtRadial { | 16 struct TwoPtRadial { |
| 15 enum { | 17 enum { |
| 16 kDontDrawT = 0x80000000 | 18 kDontDrawT = 0x80000000 |
| 17 }; | 19 }; |
| 18 | 20 |
| 19 float fCenterX, fCenterY; | 21 float fCenterX, fCenterY; |
| 20 float fDCenterX, fDCenterY; | 22 float fDCenterX, fDCenterY; |
| 21 float fRadius; | 23 float fRadius; |
| 22 float fDRadius; | 24 float fDRadius; |
| 23 float fA; | 25 float fA; |
| 24 float fRadius2; | 26 float fRadius2; |
| 25 float fRDR; | 27 float fRDR; |
| 26 | 28 |
| 27 void init(const SkPoint& center0, SkScalar rad0, | 29 void init(const SkPoint& center0, SkScalar rad0, |
| 28 const SkPoint& center1, SkScalar rad1); | 30 const SkPoint& center1, SkScalar rad1); |
| 29 | 31 |
| 30 // used by setup and nextT | |
| 31 float fRelX, fRelY, fIncX, fIncY; | |
| 32 float fB, fDB; | |
| 33 | |
| 34 void setup(SkScalar fx, SkScalar fy, SkScalar dfx, SkScalar dfy); | |
| 35 SkFixed nextT(); | |
| 36 | |
| 37 static bool DontDrawT(SkFixed t) { | 32 static bool DontDrawT(SkFixed t) { |
| 38 return kDontDrawT == (uint32_t)t; | 33 return kDontDrawT == (uint32_t)t; |
| 39 } | 34 } |
| 40 }; | 35 }; |
| 41 | 36 |
| 37 // Mutable part of TwoPtRadial. | |
|
scroggo
2014/04/02 20:16:53
I find this comment confusing, since it's no longe
Dominik Grewe
2014/04/03 12:12:59
Removed.
| |
| 38 struct TwoPtRadialContext { | |
|
scroggo
2014/04/02 20:16:53
This should probably be moved to the cpp file.
Dominik Grewe
2014/04/03 12:12:59
Done.
| |
| 39 float fRelX, fRelY, fIncX, fIncY; | |
| 40 float fB, fDB; | |
|
scroggo
2014/04/02 20:16:53
It appears that fIncX, fIncY, and fDB could be con
Dominik Grewe
2014/04/03 12:12:59
Done.
| |
| 41 const TwoPtRadial& fRec; | |
|
scroggo
2014/04/02 20:16:53
nit: the variable names should be aligned.
Dominik Grewe
2014/04/03 12:12:59
Done.
| |
| 42 | 42 |
| 43 TwoPtRadialContext(const TwoPtRadial& rec, SkScalar fx, SkScalar fy, | |
| 44 SkScalar dfx, SkScalar dfy); | |
| 45 SkFixed nextT(); | |
| 46 }; | |
| 47 | |
| 48 | |
| 43 class SkTwoPointConicalGradient : public SkGradientShaderBase { | 49 class SkTwoPointConicalGradient : public SkGradientShaderBase { |
| 44 TwoPtRadial fRec; | 50 TwoPtRadial fRec; |
| 45 void init(); | 51 void init(); |
| 46 | 52 |
| 47 public: | 53 public: |
| 48 SkTwoPointConicalGradient(const SkPoint& start, SkScalar startRadius, | 54 SkTwoPointConicalGradient(const SkPoint& start, SkScalar startRadius, |
| 49 const SkPoint& end, SkScalar endRadius, | 55 const SkPoint& end, SkScalar endRadius, |
| 50 const Descriptor&); | 56 const Descriptor&); |
| 51 | 57 |
| 52 virtual void shadeSpan(int x, int y, SkPMColor* dstCParam, | 58 |
| 53 int count) SK_OVERRIDE; | 59 virtual SkShader::Context* createContext(const SkBitmap&, const SkPaint&, co nst SkMatrix&, |
| 54 virtual bool setContext(const SkBitmap& device, | 60 void* storage) const SK_OVERRIDE; |
| 55 const SkPaint& paint, | 61 virtual size_t contextSize() const SK_OVERRIDE; |
| 56 const SkMatrix& matrix) SK_OVERRIDE; | 62 |
| 63 class TwoPointConicalGradientContext : public SkGradientShaderBase::Gradient ShaderBaseContext { | |
| 64 public: | |
| 65 TwoPointConicalGradientContext(const SkTwoPointConicalGradient& shader, | |
| 66 const SkBitmap& device, | |
| 67 const SkPaint& paint, | |
| 68 const SkMatrix& matrix); | |
| 69 ~TwoPointConicalGradientContext() {} | |
| 70 | |
| 71 virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVE RRIDE; | |
| 72 | |
| 73 typedef SkGradientShaderBase::GradientShaderBaseContext INHERITED; | |
| 74 }; | |
| 57 | 75 |
| 58 virtual BitmapType asABitmap(SkBitmap* bitmap, | 76 virtual BitmapType asABitmap(SkBitmap* bitmap, |
| 59 SkMatrix* matrix, | 77 SkMatrix* matrix, |
| 60 TileMode* xy) const; | 78 TileMode* xy) const; |
| 61 virtual SkShader::GradientType asAGradient(GradientInfo* info) const SK_OVE RRIDE; | 79 virtual SkShader::GradientType asAGradient(GradientInfo* info) const SK_OVE RRIDE; |
| 62 virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint& paint) c onst SK_OVERRIDE; | 80 virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint& paint) c onst SK_OVERRIDE; |
| 63 virtual bool isOpaque() const SK_OVERRIDE; | 81 virtual bool isOpaque() const SK_OVERRIDE; |
| 64 | 82 |
| 65 SkScalar getCenterX1() const { return SkPoint::Distance(fCenter1, fCenter2); } | 83 SkScalar getCenterX1() const { return SkPoint::Distance(fCenter1, fCenter2); } |
| 66 SkScalar getStartRadius() const { return fRadius1; } | 84 SkScalar getStartRadius() const { return fRadius1; } |
| 67 SkScalar getDiffRadius() const { return fRadius2 - fRadius1; } | 85 SkScalar getDiffRadius() const { return fRadius2 - fRadius1; } |
| 68 | 86 |
| 69 SK_DEVELOPER_TO_STRING() | 87 SK_DEVELOPER_TO_STRING() |
| 70 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTwoPointConicalGradien t) | 88 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTwoPointConicalGradien t) |
| 71 | 89 |
| 72 protected: | 90 protected: |
| 73 SkTwoPointConicalGradient(SkReadBuffer& buffer); | 91 SkTwoPointConicalGradient(SkReadBuffer& buffer); |
| 74 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; | 92 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; |
| 75 | 93 |
| 76 private: | 94 private: |
| 77 typedef SkGradientShaderBase INHERITED; | 95 typedef SkGradientShaderBase INHERITED; |
| 78 const SkPoint fCenter1; | 96 const SkPoint fCenter1; |
| 79 const SkPoint fCenter2; | 97 const SkPoint fCenter2; |
| 80 const SkScalar fRadius1; | 98 const SkScalar fRadius1; |
| 81 const SkScalar fRadius2; | 99 const SkScalar fRadius2; |
| 82 }; | 100 }; |
| 83 | 101 |
| 84 #endif | 102 #endif |
| OLD | NEW |