| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 | 9 |
| 10 #ifndef GrPaint_DEFINED | 10 #ifndef GrPaint_DEFINED |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 GrBlendCoeff getSrcBlendCoeff() const { return fSrcBlendCoeff; } | 60 GrBlendCoeff getSrcBlendCoeff() const { return fSrcBlendCoeff; } |
| 61 GrBlendCoeff getDstBlendCoeff() const { return fDstBlendCoeff; } | 61 GrBlendCoeff getDstBlendCoeff() const { return fDstBlendCoeff; } |
| 62 | 62 |
| 63 /** | 63 /** |
| 64 * The initial color of the drawn primitive. Defaults to solid white. | 64 * The initial color of the drawn primitive. Defaults to solid white. |
| 65 */ | 65 */ |
| 66 void setColor(GrColor color) { fColor = color; } | 66 void setColor(GrColor color) { fColor = color; } |
| 67 GrColor getColor() const { return fColor; } | 67 GrColor getColor() const { return fColor; } |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * Applies fractional coverage to the entire drawn primitive. Defaults to 0x
ff. | |
| 71 */ | |
| 72 void setCoverage(uint8_t coverage) { fCoverage = coverage; } | |
| 73 uint8_t getCoverage() const { return fCoverage; } | |
| 74 | |
| 75 /** | |
| 76 * Should primitives be anti-aliased or not. Defaults to false. | 70 * Should primitives be anti-aliased or not. Defaults to false. |
| 77 */ | 71 */ |
| 78 void setAntiAlias(bool aa) { fAntiAlias = aa; } | 72 void setAntiAlias(bool aa) { fAntiAlias = aa; } |
| 79 bool isAntiAlias() const { return fAntiAlias; } | 73 bool isAntiAlias() const { return fAntiAlias; } |
| 80 | 74 |
| 81 /** | 75 /** |
| 82 * Should dithering be applied. Defaults to false. | 76 * Should dithering be applied. Defaults to false. |
| 83 */ | 77 */ |
| 84 void setDither(bool dither) { fDither = dither; } | 78 void setDither(bool dither) { fDither = dither; } |
| 85 bool isDither() const { return fDither; } | 79 bool isDither() const { return fDither; } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 const GrFragmentStage& getColorStage(int s) const { return fColorStages[s];
} | 112 const GrFragmentStage& getColorStage(int s) const { return fColorStages[s];
} |
| 119 const GrFragmentStage& getCoverageStage(int s) const { return fCoverageStage
s[s]; } | 113 const GrFragmentStage& getCoverageStage(int s) const { return fCoverageStage
s[s]; } |
| 120 | 114 |
| 121 GrPaint& operator=(const GrPaint& paint) { | 115 GrPaint& operator=(const GrPaint& paint) { |
| 122 fSrcBlendCoeff = paint.fSrcBlendCoeff; | 116 fSrcBlendCoeff = paint.fSrcBlendCoeff; |
| 123 fDstBlendCoeff = paint.fDstBlendCoeff; | 117 fDstBlendCoeff = paint.fDstBlendCoeff; |
| 124 fAntiAlias = paint.fAntiAlias; | 118 fAntiAlias = paint.fAntiAlias; |
| 125 fDither = paint.fDither; | 119 fDither = paint.fDither; |
| 126 | 120 |
| 127 fColor = paint.fColor; | 121 fColor = paint.fColor; |
| 128 fCoverage = paint.fCoverage; | |
| 129 | 122 |
| 130 fColorStages = paint.fColorStages; | 123 fColorStages = paint.fColorStages; |
| 131 fCoverageStages = paint.fCoverageStages; | 124 fCoverageStages = paint.fCoverageStages; |
| 132 | 125 |
| 133 return *this; | 126 return *this; |
| 134 } | 127 } |
| 135 | 128 |
| 136 /** | 129 /** |
| 137 * Resets the paint to the defaults. | 130 * Resets the paint to the defaults. |
| 138 */ | 131 */ |
| 139 void reset() { | 132 void reset() { |
| 140 this->resetBlend(); | 133 this->resetBlend(); |
| 141 this->resetOptions(); | 134 this->resetOptions(); |
| 142 this->resetColor(); | 135 this->resetColor(); |
| 143 this->resetCoverage(); | |
| 144 this->resetStages(); | 136 this->resetStages(); |
| 145 } | 137 } |
| 146 | 138 |
| 147 /** | 139 /** |
| 148 * Determines whether the drawing with this paint is opaque with respect to
both color blending | 140 * Determines whether the drawing with this paint is opaque with respect to
both color blending |
| 149 * and fractional coverage. It does not consider whether AA has been enabled
on the paint or | 141 * and fractional coverage. It does not consider whether AA has been enabled
on the paint or |
| 150 * not. Depending upon whether multisampling or coverage-based AA is in use,
AA may make the | 142 * not. Depending upon whether multisampling or coverage-based AA is in use,
AA may make the |
| 151 * result only apply to the interior of primitives. | 143 * result only apply to the interior of primitives. |
| 152 * | 144 * |
| 153 */ | 145 */ |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 199 |
| 208 SkSTArray<4, GrFragmentStage> fColorStages; | 200 SkSTArray<4, GrFragmentStage> fColorStages; |
| 209 SkSTArray<2, GrFragmentStage> fCoverageStages; | 201 SkSTArray<2, GrFragmentStage> fCoverageStages; |
| 210 | 202 |
| 211 GrBlendCoeff fSrcBlendCoeff; | 203 GrBlendCoeff fSrcBlendCoeff; |
| 212 GrBlendCoeff fDstBlendCoeff; | 204 GrBlendCoeff fDstBlendCoeff; |
| 213 bool fAntiAlias; | 205 bool fAntiAlias; |
| 214 bool fDither; | 206 bool fDither; |
| 215 | 207 |
| 216 GrColor fColor; | 208 GrColor fColor; |
| 217 uint8_t fCoverage; | |
| 218 | 209 |
| 219 void resetBlend() { | 210 void resetBlend() { |
| 220 fSrcBlendCoeff = kOne_GrBlendCoeff; | 211 fSrcBlendCoeff = kOne_GrBlendCoeff; |
| 221 fDstBlendCoeff = kZero_GrBlendCoeff; | 212 fDstBlendCoeff = kZero_GrBlendCoeff; |
| 222 } | 213 } |
| 223 | 214 |
| 224 void resetOptions() { | 215 void resetOptions() { |
| 225 fAntiAlias = false; | 216 fAntiAlias = false; |
| 226 fDither = false; | 217 fDither = false; |
| 227 } | 218 } |
| 228 | 219 |
| 229 void resetColor() { | 220 void resetColor() { |
| 230 fColor = GrColorPackRGBA(0xff, 0xff, 0xff, 0xff); | 221 fColor = GrColorPackRGBA(0xff, 0xff, 0xff, 0xff); |
| 231 } | 222 } |
| 232 | 223 |
| 233 void resetCoverage() { | |
| 234 fCoverage = 0xff; | |
| 235 } | |
| 236 | |
| 237 void resetStages() { | 224 void resetStages() { |
| 238 fColorStages.reset(); | 225 fColorStages.reset(); |
| 239 fCoverageStages.reset(); | 226 fCoverageStages.reset(); |
| 240 } | 227 } |
| 241 }; | 228 }; |
| 242 | 229 |
| 243 #endif | 230 #endif |
| OLD | NEW |