Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1311)

Side by Side Diff: src/effects/gradients/SkTwoPointConicalGradient.h

Issue 227623004: Add flipped gradient branch to two point conical gradient (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Cpu flip fix Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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)? 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. 15 // Should only be initialized once via init(). Immutable afterwards.
16 struct TwoPtRadial { 16 struct TwoPtRadial {
17 enum { 17 enum {
18 kDontDrawT = 0x80000000 18 kDontDrawT = 0x80000000
19 }; 19 };
20 20
21 float fCenterX, fCenterY; 21 float fCenterX, fCenterY;
22 float fDCenterX, fDCenterY; 22 float fDCenterX, fDCenterY;
23 float fRadius; 23 float fRadius;
24 float fDRadius; 24 float fDRadius;
25 float fA; 25 float fA;
26 float fRadius2; 26 float fRadius2;
27 float fRDR; 27 float fRDR;
28 bool fFlipped;
28 29
29 void init(const SkPoint& center0, SkScalar rad0, 30 void init(const SkPoint& center0, SkScalar rad0,
30 const SkPoint& center1, SkScalar rad1); 31 const SkPoint& center1, SkScalar rad1,
32 bool flipped);
31 33
32 static bool DontDrawT(SkFixed t) { 34 static bool DontDrawT(SkFixed t) {
33 return kDontDrawT == (uint32_t)t; 35 return kDontDrawT == (uint32_t)t;
34 } 36 }
35 }; 37 };
36 38
37 39
38 class SkTwoPointConicalGradient : public SkGradientShaderBase { 40 class SkTwoPointConicalGradient : public SkGradientShaderBase {
39 TwoPtRadial fRec; 41 TwoPtRadial fRec;
40 void init(); 42 void init();
41 43
42 public: 44 public:
43 SkTwoPointConicalGradient(const SkPoint& start, SkScalar startRadius, 45 SkTwoPointConicalGradient(const SkPoint& start, SkScalar startRadius,
44 const SkPoint& end, SkScalar endRadius, 46 const SkPoint& end, SkScalar endRadius,
45 const Descriptor&); 47 bool flippedGrad, const Descriptor&);
46 48
47 49
48 virtual SkShader::Context* createContext(const SkBitmap&, const SkPaint&, co nst SkMatrix&, 50 virtual SkShader::Context* createContext(const SkBitmap&, const SkPaint&, co nst SkMatrix&,
49 void* storage) const SK_OVERRIDE; 51 void* storage) const SK_OVERRIDE;
50 virtual size_t contextSize() const SK_OVERRIDE; 52 virtual size_t contextSize() const SK_OVERRIDE;
51 53
52 class TwoPointConicalGradientContext : public SkGradientShaderBase::Gradient ShaderBaseContext { 54 class TwoPointConicalGradientContext : public SkGradientShaderBase::Gradient ShaderBaseContext {
53 public: 55 public:
54 TwoPointConicalGradientContext(const SkTwoPointConicalGradient& shader, 56 TwoPointConicalGradientContext(const SkTwoPointConicalGradient& shader,
55 const SkBitmap& device, 57 const SkBitmap& device,
(...skipping 13 matching lines...) Expand all
69 virtual SkShader::GradientType asAGradient(GradientInfo* info) const SK_OVE RRIDE; 71 virtual SkShader::GradientType asAGradient(GradientInfo* info) const SK_OVE RRIDE;
70 virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint& paint) c onst SK_OVERRIDE; 72 virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint& paint) c onst SK_OVERRIDE;
71 virtual bool isOpaque() const SK_OVERRIDE; 73 virtual bool isOpaque() const SK_OVERRIDE;
72 74
73 SkScalar getCenterX1() const { return SkPoint::Distance(fCenter1, fCenter2); } 75 SkScalar getCenterX1() const { return SkPoint::Distance(fCenter1, fCenter2); }
74 SkScalar getStartRadius() const { return fRadius1; } 76 SkScalar getStartRadius() const { return fRadius1; }
75 SkScalar getDiffRadius() const { return fRadius2 - fRadius1; } 77 SkScalar getDiffRadius() const { return fRadius2 - fRadius1; }
76 const SkPoint& getStartCenter() const { return fCenter1; } 78 const SkPoint& getStartCenter() const { return fCenter1; }
77 const SkPoint& getEndCenter() const { return fCenter2; } 79 const SkPoint& getEndCenter() const { return fCenter2; }
78 SkScalar getEndRadius() const { return fRadius2; } 80 SkScalar getEndRadius() const { return fRadius2; }
81 bool isFlippedGrad() const { return fFlippedGrad; }
79 82
80 SK_TO_STRING_OVERRIDE() 83 SK_TO_STRING_OVERRIDE()
81 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTwoPointConicalGradien t) 84 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTwoPointConicalGradien t)
82 85
83 protected: 86 protected:
84 SkTwoPointConicalGradient(SkReadBuffer& buffer); 87 SkTwoPointConicalGradient(SkReadBuffer& buffer);
85 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; 88 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE;
86 89
87 private: 90 private:
88 const SkPoint fCenter1; 91 SkPoint fCenter1;
89 const SkPoint fCenter2; 92 SkPoint fCenter2;
90 const SkScalar fRadius1; 93 SkScalar fRadius1;
91 const SkScalar fRadius2; 94 SkScalar fRadius2;
95 bool fFlippedGrad;
92 96
93 typedef SkGradientShaderBase INHERITED; 97 typedef SkGradientShaderBase INHERITED;
94 }; 98 };
95 99
96 #endif 100 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698