blob: 8d67c25268bf0a152ee1e54ba194c92de8102747 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrGradientEffects_DEFINED
#define GrGradientEffects_DEFINED
#include "GrCustomStage.h"
#include "GrTypes.h"
#include "GrScalar.h"
class GrGLRadialGradient;
class GrRadialGradient : public GrCustomStage {
public:
GrRadialGradient();
virtual ~GrRadialGradient();
static const char* Name() { return "Radial Gradient"; }
virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE;
virtual bool isEqual(const GrCustomStage&) const SK_OVERRIDE;
typedef GrGLRadialGradient GLProgramStage;
private:
typedef GrCustomStage INHERITED;
};
class GrGLRadial2Gradient;
class GrRadial2Gradient : public GrCustomStage {
public:
GrRadial2Gradient(GrScalar center, GrScalar radius, bool posRoot);
virtual ~GrRadial2Gradient();
static const char* Name() { return "Two-Point Radial Gradient"; }
virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE;
virtual bool isEqual(const GrCustomStage&) const SK_OVERRIDE;
// The radial gradient parameters can collapse to a linear (instead
// of quadratic) equation.
bool isDegenerate() const { return GR_Scalar1 == fCenterX1; }
GrScalar center() const { return fCenterX1; }
GrScalar radius() const { return fRadius0; }
bool isPosRoot() const { return SkToBool(fPosRoot); }
typedef GrGLRadial2Gradient GLProgramStage;
private:
// @{
// Cache of values - these can change arbitrarily, EXCEPT
// we shouldn't change between degenerate and non-degenerate?!
GrScalar fCenterX1;
GrScalar fRadius0;
SkBool8 fPosRoot;
// @}
typedef GrCustomStage INHERITED;
};
class GrGLSweepGradient;
class GrSweepGradient : public GrCustomStage {
public:
GrSweepGradient();
virtual ~GrSweepGradient();
static const char* Name() { return "Sweep Gradient"; }
virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE;
virtual bool isEqual(const GrCustomStage&) const SK_OVERRIDE;
typedef GrGLSweepGradient GLProgramStage;
protected:
typedef GrCustomStage INHERITED;
};
#endif
|