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

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

Issue 249643002: Revert of Extract most of the mutable state of SkShader into a separate Context object. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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)?
15 // Should only be initialized once via init(). Immutable afterwards.
16 struct TwoPtRadial { 14 struct TwoPtRadial {
17 enum { 15 enum {
18 kDontDrawT = 0x80000000 16 kDontDrawT = 0x80000000
19 }; 17 };
20 18
21 float fCenterX, fCenterY; 19 float fCenterX, fCenterY;
22 float fDCenterX, fDCenterY; 20 float fDCenterX, fDCenterY;
23 float fRadius; 21 float fRadius;
24 float fDRadius; 22 float fDRadius;
25 float fA; 23 float fA;
26 float fRadius2; 24 float fRadius2;
27 float fRDR; 25 float fRDR;
28 bool fFlipped; 26 bool fFlipped;
29 27
30 void init(const SkPoint& center0, SkScalar rad0, 28 void init(const SkPoint& center0, SkScalar rad0,
31 const SkPoint& center1, SkScalar rad1, 29 const SkPoint& center1, SkScalar rad1,
32 bool flipped); 30 bool flipped);
33 31
32 // used by setup and nextT
33 float fRelX, fRelY, fIncX, fIncY;
34 float fB, fDB;
35
36 void setup(SkScalar fx, SkScalar fy, SkScalar dfx, SkScalar dfy);
37 SkFixed nextT();
38
34 static bool DontDrawT(SkFixed t) { 39 static bool DontDrawT(SkFixed t) {
35 return kDontDrawT == (uint32_t)t; 40 return kDontDrawT == (uint32_t)t;
36 } 41 }
37 }; 42 };
38 43
39 44
40 class SkTwoPointConicalGradient : public SkGradientShaderBase { 45 class SkTwoPointConicalGradient : public SkGradientShaderBase {
41 TwoPtRadial fRec; 46 TwoPtRadial fRec;
42 void init(); 47 void init();
43 48
44 public: 49 public:
45 SkTwoPointConicalGradient(const SkPoint& start, SkScalar startRadius, 50 SkTwoPointConicalGradient(const SkPoint& start, SkScalar startRadius,
46 const SkPoint& end, SkScalar endRadius, 51 const SkPoint& end, SkScalar endRadius,
47 bool flippedGrad, const Descriptor&); 52 bool flippedGrad, const Descriptor&);
48 53
49 54 virtual void shadeSpan(int x, int y, SkPMColor* dstCParam,
50 virtual SkShader::Context* createContext(const SkBitmap&, const SkPaint&, co nst SkMatrix&, 55 int count) SK_OVERRIDE;
51 void* storage) const SK_OVERRIDE; 56 virtual bool setContext(const SkBitmap& device,
52 virtual size_t contextSize() const SK_OVERRIDE; 57 const SkPaint& paint,
53 58 const SkMatrix& matrix) SK_OVERRIDE;
54 class TwoPointConicalGradientContext : public SkGradientShaderBase::Gradient ShaderBaseContext {
55 public:
56 TwoPointConicalGradientContext(const SkTwoPointConicalGradient& shader,
57 const SkBitmap& device,
58 const SkPaint& paint,
59 const SkMatrix& matrix);
60 ~TwoPointConicalGradientContext() {}
61
62 virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVE RRIDE;
63
64 private:
65 typedef SkGradientShaderBase::GradientShaderBaseContext INHERITED;
66 };
67 59
68 virtual BitmapType asABitmap(SkBitmap* bitmap, 60 virtual BitmapType asABitmap(SkBitmap* bitmap,
69 SkMatrix* matrix, 61 SkMatrix* matrix,
70 TileMode* xy) const; 62 TileMode* xy) const;
71 virtual SkShader::GradientType asAGradient(GradientInfo* info) const SK_OVE RRIDE; 63 virtual SkShader::GradientType asAGradient(GradientInfo* info) const SK_OVE RRIDE;
72 virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint& paint) c onst SK_OVERRIDE; 64 virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint& paint) c onst SK_OVERRIDE;
73 virtual bool isOpaque() const SK_OVERRIDE; 65 virtual bool isOpaque() const SK_OVERRIDE;
74 66
75 SkScalar getCenterX1() const { return SkPoint::Distance(fCenter1, fCenter2); } 67 SkScalar getCenterX1() const { return SkPoint::Distance(fCenter1, fCenter2); }
76 SkScalar getStartRadius() const { return fRadius1; } 68 SkScalar getStartRadius() const { return fRadius1; }
(...skipping 14 matching lines...) Expand all
91 SkPoint fCenter1; 83 SkPoint fCenter1;
92 SkPoint fCenter2; 84 SkPoint fCenter2;
93 SkScalar fRadius1; 85 SkScalar fRadius1;
94 SkScalar fRadius2; 86 SkScalar fRadius2;
95 bool fFlippedGrad; 87 bool fFlippedGrad;
96 88
97 typedef SkGradientShaderBase INHERITED; 89 typedef SkGradientShaderBase INHERITED;
98 }; 90 };
99 91
100 #endif 92 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkSweepGradient.cpp ('k') | src/effects/gradients/SkTwoPointConicalGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698