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