epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 10 | #ifndef GrPaint_DEFINED |
| 11 | #define GrPaint_DEFINED |
| 12 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 13 | #include "GrColor.h" |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 14 | #include "GrEffectStage.h" |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 15 | |
Scroggo | 97c88c2 | 2011-05-11 14:05:25 +0000 | [diff] [blame] | 16 | #include "SkXfermode.h" |
| 17 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 18 | /** |
bsalomon@google.com | c7448ce | 2012-10-05 19:04:13 +0000 | [diff] [blame] | 19 | * The paint describes how color and coverage are computed at each pixel by GrContext draw |
| 20 | * functions and the how color is blended with the destination pixel. |
| 21 | * |
| 22 | * The paint allows installation of custom color and coverage stages. New types of stages are |
bsalomon@google.com | a469c28 | 2012-10-24 18:28:34 +0000 | [diff] [blame] | 23 | * created by subclassing GrEffect. |
bsalomon@google.com | c7448ce | 2012-10-05 19:04:13 +0000 | [diff] [blame] | 24 | * |
| 25 | * The primitive color computation starts with the color specified by setColor(). This color is the |
| 26 | * input to the first color stage. Each color stage feeds its output to the next color stage. The |
| 27 | * final color stage's output color is input to the color filter specified by |
bsalomon@google.com | 67e78c9 | 2012-10-17 13:36:14 +0000 | [diff] [blame] | 28 | * setXfermodeColorFilter which produces the final source color, S. |
bsalomon@google.com | c7448ce | 2012-10-05 19:04:13 +0000 | [diff] [blame] | 29 | * |
| 30 | * Fractional pixel coverage follows a similar flow. The coverage is initially the value specified |
| 31 | * by setCoverage(). This is input to the first coverage stage. Coverage stages are chained |
| 32 | * together in the same manner as color stages. The output of the last stage is modulated by any |
| 33 | * fractional coverage produced by anti-aliasing. This last step produces the final coverage, C. |
| 34 | * |
| 35 | * setBlendFunc() specifies blending coefficients for S (described above) and D, the initial value |
| 36 | * of the destination pixel, labeled Bs and Bd respectively. The final value of the destination |
| 37 | * pixel is then D' = (1-C)*D + C*(Bd*D + Bs*S). |
| 38 | * |
| 39 | * Note that the coverage is applied after the blend. This is why they are computed as distinct |
| 40 | * values. |
| 41 | * |
bsalomon@google.com | a469c28 | 2012-10-24 18:28:34 +0000 | [diff] [blame] | 42 | * TODO: Encapsulate setXfermodeColorFilter in a GrEffect and remove from GrPaint. |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 43 | */ |
| 44 | class GrPaint { |
| 45 | public: |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 46 | enum { |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 47 | kMaxColorStages = 2, |
| 48 | kMaxCoverageStages = 1, |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 49 | }; |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 50 | |
bsalomon@google.com | c7448ce | 2012-10-05 19:04:13 +0000 | [diff] [blame] | 51 | GrPaint() { this->reset(); } |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 52 | |
bsalomon@google.com | c7448ce | 2012-10-05 19:04:13 +0000 | [diff] [blame] | 53 | GrPaint(const GrPaint& paint) { *this = paint; } |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 54 | |
bsalomon@google.com | c7448ce | 2012-10-05 19:04:13 +0000 | [diff] [blame] | 55 | ~GrPaint() {} |
Scroggo | 97c88c2 | 2011-05-11 14:05:25 +0000 | [diff] [blame] | 56 | |
bsalomon@google.com | c7448ce | 2012-10-05 19:04:13 +0000 | [diff] [blame] | 57 | /** |
| 58 | * Sets the blending coefficients to use to blend the final primitive color with the |
| 59 | * destination color. Defaults to kOne for src and kZero for dst (i.e. src mode). |
| 60 | */ |
| 61 | void setBlendFunc(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) { |
| 62 | fSrcBlendCoeff = srcCoeff; |
| 63 | fDstBlendCoeff = dstCoeff; |
| 64 | } |
| 65 | GrBlendCoeff getSrcBlendCoeff() const { return fSrcBlendCoeff; } |
| 66 | GrBlendCoeff getDstBlendCoeff() const { return fDstBlendCoeff; } |
| 67 | |
| 68 | /** |
| 69 | * The initial color of the drawn primitive. Defaults to solid white. |
| 70 | */ |
| 71 | void setColor(GrColor color) { fColor = color; } |
| 72 | GrColor getColor() const { return fColor; } |
| 73 | |
| 74 | /** |
| 75 | * Applies fractional coverage to the entire drawn primitive. Defaults to 0xff. |
| 76 | */ |
| 77 | void setCoverage(uint8_t coverage) { fCoverage = coverage; } |
| 78 | uint8_t getCoverage() const { return fCoverage; } |
| 79 | |
| 80 | /** |
| 81 | * Should primitives be anti-aliased or not. Defaults to false. |
| 82 | */ |
| 83 | void setAntiAlias(bool aa) { fAntiAlias = aa; } |
| 84 | bool isAntiAlias() const { return fAntiAlias; } |
| 85 | |
| 86 | /** |
| 87 | * Should dithering be applied. Defaults to false. |
| 88 | */ |
| 89 | void setDither(bool dither) { fDither = dither; } |
| 90 | bool isDither() const { return fDither; } |
| 91 | |
| 92 | /** |
| 93 | * Enables a SkXfermode::Mode-based color filter applied to the primitive color. The constant |
| 94 | * color passed to this function is considered the "src" color and the primitive's color is |
| 95 | * considered the "dst" color. Defaults to kDst_Mode which equates to simply passing through |
| 96 | * the primitive color unmodified. |
| 97 | */ |
| 98 | void setXfermodeColorFilter(SkXfermode::Mode mode, GrColor color) { |
| 99 | fColorFilterColor = color; |
| 100 | fColorFilterXfermode = mode; |
| 101 | } |
| 102 | SkXfermode::Mode getColorFilterMode() const { return fColorFilterXfermode; } |
| 103 | GrColor getColorFilterColor() const { return fColorFilterColor; } |
| 104 | |
| 105 | /** |
bsalomon@google.com | 67e78c9 | 2012-10-17 13:36:14 +0000 | [diff] [blame] | 106 | * Disables the SkXfermode::Mode color filter. |
bsalomon@google.com | c7448ce | 2012-10-05 19:04:13 +0000 | [diff] [blame] | 107 | */ |
| 108 | void resetColorFilter() { |
| 109 | fColorFilterXfermode = SkXfermode::kDst_Mode; |
| 110 | fColorFilterColor = GrColorPackRGBA(0xff, 0xff, 0xff, 0xff); |
bsalomon@google.com | c7448ce | 2012-10-05 19:04:13 +0000 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | /** |
| 114 | * Specifies a stage of the color pipeline. Usually the texture matrices of color stages apply |
| 115 | * to the primitive's positions. Some GrContext calls take explicit coords as an array or a |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 116 | * rect. In this case these are the pre-matrix coords to colorStage(0). |
bsalomon@google.com | c7448ce | 2012-10-05 19:04:13 +0000 | [diff] [blame] | 117 | */ |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 118 | GrEffectStage* colorStage(int i) { |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 119 | GrAssert((unsigned)i < kMaxColorStages); |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 120 | return fColorStages + i; |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 121 | } |
| 122 | |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 123 | const GrEffectStage& getColorStage(int i) const { |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 124 | GrAssert((unsigned)i < kMaxColorStages); |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 125 | return fColorStages[i]; |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 126 | } |
| 127 | |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 128 | bool isColorStageEnabled(int i) const { |
| 129 | GrAssert((unsigned)i < kMaxColorStages); |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 130 | return (NULL != fColorStages[i].getEffect()); |
tomhudson@google.com | f13f588 | 2012-06-25 17:27:28 +0000 | [diff] [blame] | 131 | } |
| 132 | |
bsalomon@google.com | c7448ce | 2012-10-05 19:04:13 +0000 | [diff] [blame] | 133 | /** |
| 134 | * Specifies a stage of the coverage pipeline. Coverage stages' texture matrices are always |
| 135 | * applied to the primitive's position, never to explicit texture coords. |
| 136 | */ |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 137 | GrEffectStage* coverageStage(int i) { |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 138 | GrAssert((unsigned)i < kMaxCoverageStages); |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 139 | return fCoverageStages + i; |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 140 | } |
| 141 | |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 142 | const GrEffectStage& getCoverageStage(int i) const { |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 143 | GrAssert((unsigned)i < kMaxCoverageStages); |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 144 | return fCoverageStages[i]; |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 145 | } |
| 146 | |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 147 | bool isCoverageStageEnabled(int i) const { |
| 148 | GrAssert((unsigned)i < kMaxCoverageStages); |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 149 | return (NULL != fCoverageStages[i].getEffect()); |
tomhudson@google.com | f13f588 | 2012-06-25 17:27:28 +0000 | [diff] [blame] | 150 | } |
| 151 | |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 152 | bool hasCoverageStage() const { |
| 153 | for (int i = 0; i < kMaxCoverageStages; ++i) { |
| 154 | if (this->isCoverageStageEnabled(i)) { |
bsalomon@google.com | e3d3216 | 2012-07-20 13:37:06 +0000 | [diff] [blame] | 155 | return true; |
| 156 | } |
| 157 | } |
| 158 | return false; |
| 159 | } |
| 160 | |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 161 | bool hasColorStage() const { |
| 162 | for (int i = 0; i < kMaxColorStages; ++i) { |
| 163 | if (this->isColorStageEnabled(i)) { |
bsalomon@google.com | e3d3216 | 2012-07-20 13:37:06 +0000 | [diff] [blame] | 164 | return true; |
| 165 | } |
| 166 | } |
| 167 | return false; |
| 168 | } |
| 169 | |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 170 | bool hasStage() const { return this->hasColorStage() || this->hasCoverageStage(); } |
bsalomon@google.com | e3d3216 | 2012-07-20 13:37:06 +0000 | [diff] [blame] | 171 | |
| 172 | /** |
bsalomon@google.com | 288d954 | 2012-10-17 12:53:54 +0000 | [diff] [blame] | 173 | * Called when the source coord system is changing. preConcatInverse is the inverse of the |
| 174 | * transformation from the old coord system to the new coord system. Returns false if the matrix |
| 175 | * cannot be inverted. |
bsalomon@google.com | e3d3216 | 2012-07-20 13:37:06 +0000 | [diff] [blame] | 176 | */ |
bsalomon@google.com | 288d954 | 2012-10-17 12:53:54 +0000 | [diff] [blame] | 177 | bool sourceCoordChangeByInverse(const GrMatrix& preConcatInverse) { |
bsalomon@google.com | e3d3216 | 2012-07-20 13:37:06 +0000 | [diff] [blame] | 178 | GrMatrix inv; |
| 179 | bool computed = false; |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 180 | for (int i = 0; i < kMaxColorStages; ++i) { |
| 181 | if (this->isColorStageEnabled(i)) { |
bsalomon@google.com | 288d954 | 2012-10-17 12:53:54 +0000 | [diff] [blame] | 182 | if (!computed && !preConcatInverse.invert(&inv)) { |
bsalomon@google.com | e3d3216 | 2012-07-20 13:37:06 +0000 | [diff] [blame] | 183 | return false; |
| 184 | } else { |
| 185 | computed = true; |
| 186 | } |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 187 | fColorStages[i].preConcatCoordChange(inv); |
bsalomon@google.com | e3d3216 | 2012-07-20 13:37:06 +0000 | [diff] [blame] | 188 | } |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 189 | } |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 190 | for (int i = 0; i < kMaxCoverageStages; ++i) { |
| 191 | if (this->isCoverageStageEnabled(i)) { |
bsalomon@google.com | 288d954 | 2012-10-17 12:53:54 +0000 | [diff] [blame] | 192 | if (!computed && !preConcatInverse.invert(&inv)) { |
bsalomon@google.com | e3d3216 | 2012-07-20 13:37:06 +0000 | [diff] [blame] | 193 | return false; |
| 194 | } else { |
| 195 | computed = true; |
| 196 | } |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 197 | fCoverageStages[i].preConcatCoordChange(inv); |
bsalomon@google.com | e3d3216 | 2012-07-20 13:37:06 +0000 | [diff] [blame] | 198 | } |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 199 | } |
bsalomon@google.com | e3d3216 | 2012-07-20 13:37:06 +0000 | [diff] [blame] | 200 | return true; |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 201 | } |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 202 | |
bsalomon@google.com | 3cbaa2d | 2012-10-12 14:51:52 +0000 | [diff] [blame] | 203 | /** |
bsalomon@google.com | 288d954 | 2012-10-17 12:53:54 +0000 | [diff] [blame] | 204 | * Called when the source coord system is changing. preConcat gives the transformation from the |
| 205 | * old coord system to the new coord system. |
bsalomon@google.com | 3cbaa2d | 2012-10-12 14:51:52 +0000 | [diff] [blame] | 206 | */ |
bsalomon@google.com | 288d954 | 2012-10-17 12:53:54 +0000 | [diff] [blame] | 207 | void sourceCoordChange(const GrMatrix& preConcat) { |
bsalomon@google.com | 3cbaa2d | 2012-10-12 14:51:52 +0000 | [diff] [blame] | 208 | for (int i = 0; i < kMaxColorStages; ++i) { |
| 209 | if (this->isColorStageEnabled(i)) { |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 210 | fColorStages[i].preConcatCoordChange(preConcat); |
bsalomon@google.com | 3cbaa2d | 2012-10-12 14:51:52 +0000 | [diff] [blame] | 211 | } |
| 212 | } |
| 213 | for (int i = 0; i < kMaxCoverageStages; ++i) { |
| 214 | if (this->isCoverageStageEnabled(i)) { |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 215 | fCoverageStages[i].preConcatCoordChange(preConcat); |
bsalomon@google.com | 3cbaa2d | 2012-10-12 14:51:52 +0000 | [diff] [blame] | 216 | } |
| 217 | } |
| 218 | } |
| 219 | |
bsalomon@google.com | 27c9b6d | 2011-09-12 14:30:27 +0000 | [diff] [blame] | 220 | GrPaint& operator=(const GrPaint& paint) { |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 221 | fSrcBlendCoeff = paint.fSrcBlendCoeff; |
| 222 | fDstBlendCoeff = paint.fDstBlendCoeff; |
| 223 | fAntiAlias = paint.fAntiAlias; |
| 224 | fDither = paint.fDither; |
| 225 | |
| 226 | fColor = paint.fColor; |
bsalomon@google.com | dd1be60 | 2012-01-18 20:34:00 +0000 | [diff] [blame] | 227 | fCoverage = paint.fCoverage; |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 228 | |
Scroggo | 97c88c2 | 2011-05-11 14:05:25 +0000 | [diff] [blame] | 229 | fColorFilterColor = paint.fColorFilterColor; |
| 230 | fColorFilterXfermode = paint.fColorFilterXfermode; |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 231 | |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 232 | for (int i = 0; i < kMaxColorStages; ++i) { |
| 233 | if (paint.isColorStageEnabled(i)) { |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 234 | fColorStages[i] = paint.fColorStages[i]; |
bsalomon@google.com | dddf6f6 | 2012-03-16 17:50:37 +0000 | [diff] [blame] | 235 | } |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 236 | } |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 237 | for (int i = 0; i < kMaxCoverageStages; ++i) { |
| 238 | if (paint.isCoverageStageEnabled(i)) { |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 239 | fCoverageStages[i] = paint.fCoverageStages[i]; |
bsalomon@google.com | dddf6f6 | 2012-03-16 17:50:37 +0000 | [diff] [blame] | 240 | } |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 241 | } |
bsalomon@google.com | 27c9b6d | 2011-09-12 14:30:27 +0000 | [diff] [blame] | 242 | return *this; |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 243 | } |
| 244 | |
bsalomon@google.com | c7448ce | 2012-10-05 19:04:13 +0000 | [diff] [blame] | 245 | /** |
| 246 | * Resets the paint to the defaults. |
| 247 | */ |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 248 | void reset() { |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 249 | this->resetBlend(); |
| 250 | this->resetOptions(); |
| 251 | this->resetColor(); |
bsalomon@google.com | dd1be60 | 2012-01-18 20:34:00 +0000 | [diff] [blame] | 252 | this->resetCoverage(); |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 253 | this->resetStages(); |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 254 | this->resetColorFilter(); |
Scroggo | 97c88c2 | 2011-05-11 14:05:25 +0000 | [diff] [blame] | 255 | } |
| 256 | |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 257 | // internal use |
| 258 | // GrPaint's textures and masks map to the first N stages |
| 259 | // of GrDrawTarget in that order (textures followed by masks) |
| 260 | enum { |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 261 | kFirstColorStage = 0, |
| 262 | kFirstCoverageStage = kMaxColorStages, |
| 263 | kTotalStages = kFirstColorStage + kMaxColorStages + kMaxCoverageStages, |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 264 | }; |
| 265 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 266 | private: |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 267 | |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 268 | GrEffectStage fColorStages[kMaxColorStages]; |
| 269 | GrEffectStage fCoverageStages[kMaxCoverageStages]; |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 270 | |
bsalomon@google.com | c7448ce | 2012-10-05 19:04:13 +0000 | [diff] [blame] | 271 | GrBlendCoeff fSrcBlendCoeff; |
| 272 | GrBlendCoeff fDstBlendCoeff; |
| 273 | bool fAntiAlias; |
| 274 | bool fDither; |
bsalomon@google.com | c7448ce | 2012-10-05 19:04:13 +0000 | [diff] [blame] | 275 | |
| 276 | GrColor fColor; |
| 277 | uint8_t fCoverage; |
| 278 | |
| 279 | GrColor fColorFilterColor; |
| 280 | SkXfermode::Mode fColorFilterXfermode; |
bsalomon@google.com | c7448ce | 2012-10-05 19:04:13 +0000 | [diff] [blame] | 281 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 282 | void resetBlend() { |
bsalomon@google.com | 4705954 | 2012-06-06 20:51:20 +0000 | [diff] [blame] | 283 | fSrcBlendCoeff = kOne_GrBlendCoeff; |
| 284 | fDstBlendCoeff = kZero_GrBlendCoeff; |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | void resetOptions() { |
| 288 | fAntiAlias = false; |
| 289 | fDither = false; |
| 290 | } |
| 291 | |
| 292 | void resetColor() { |
| 293 | fColor = GrColorPackRGBA(0xff, 0xff, 0xff, 0xff); |
| 294 | } |
| 295 | |
bsalomon@google.com | dd1be60 | 2012-01-18 20:34:00 +0000 | [diff] [blame] | 296 | void resetCoverage() { |
| 297 | fCoverage = 0xff; |
| 298 | } |
| 299 | |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 300 | void resetStages() { |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 301 | for (int i = 0; i < kMaxColorStages; ++i) { |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 302 | fColorStages[i].reset(); |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 303 | } |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 304 | for (int i = 0; i < kMaxCoverageStages; ++i) { |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame^] | 305 | fCoverageStages[i].reset(); |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 306 | } |
| 307 | } |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 308 | }; |
| 309 | |
| 310 | #endif |