OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrRODrawState.h" | 8 #include "GrRODrawState.h" |
9 | 9 |
10 #include "GrDrawTargetCaps.h" | 10 #include "GrDrawTargetCaps.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 GrBlendCoeff* srcCoeff, | 177 GrBlendCoeff* srcCoeff, |
178 GrBlendCoeff* dstCoeff)
const { | 178 GrBlendCoeff* dstCoeff)
const { |
179 GrBlendCoeff bogusSrcCoeff, bogusDstCoeff; | 179 GrBlendCoeff bogusSrcCoeff, bogusDstCoeff; |
180 if (NULL == srcCoeff) { | 180 if (NULL == srcCoeff) { |
181 srcCoeff = &bogusSrcCoeff; | 181 srcCoeff = &bogusSrcCoeff; |
182 } | 182 } |
183 if (NULL == dstCoeff) { | 183 if (NULL == dstCoeff) { |
184 dstCoeff = &bogusDstCoeff; | 184 dstCoeff = &bogusDstCoeff; |
185 } | 185 } |
186 | 186 |
| 187 if (forceCoverage) { |
| 188 return this->calcBlendOpts(true, srcCoeff, dstCoeff); |
| 189 } |
| 190 |
| 191 if (0 == (fBlendOptFlags & kInvalid_BlendOptFlag)) { |
| 192 *srcCoeff = fOptSrcBlend; |
| 193 *dstCoeff = fOptDstBlend; |
| 194 return fBlendOptFlags; |
| 195 } |
| 196 |
| 197 fBlendOptFlags = this->calcBlendOpts(forceCoverage, srcCoeff, dstCoeff); |
| 198 fOptSrcBlend = *srcCoeff; |
| 199 fOptDstBlend = *dstCoeff; |
| 200 |
| 201 return fBlendOptFlags; |
| 202 } |
| 203 |
| 204 GrRODrawState::BlendOptFlags GrRODrawState::calcBlendOpts(bool forceCoverage, |
| 205 GrBlendCoeff* srcCoeff
, |
| 206 GrBlendCoeff* dstCoeff
) const { |
187 *srcCoeff = this->getSrcBlendCoeff(); | 207 *srcCoeff = this->getSrcBlendCoeff(); |
188 *dstCoeff = this->getDstBlendCoeff(); | 208 *dstCoeff = this->getDstBlendCoeff(); |
189 | 209 |
190 if (this->isColorWriteDisabled()) { | 210 if (this->isColorWriteDisabled()) { |
191 *srcCoeff = kZero_GrBlendCoeff; | 211 *srcCoeff = kZero_GrBlendCoeff; |
192 *dstCoeff = kOne_GrBlendCoeff; | 212 *dstCoeff = kOne_GrBlendCoeff; |
193 } | 213 } |
194 | 214 |
195 bool srcAIsOne = this->srcAlphaWillBeOne(); | 215 bool srcAIsOne = this->srcAlphaWillBeOne(); |
196 bool dstCoeffIsOne = kOne_GrBlendCoeff == *dstCoeff || | 216 bool dstCoeffIsOne = kOne_GrBlendCoeff == *dstCoeff || |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 // Since the shader will multiply coverage and color, the only way the f
inal A==1 is if | 365 // Since the shader will multiply coverage and color, the only way the f
inal A==1 is if |
346 // coverage and color both have A==1. | 366 // coverage and color both have A==1. |
347 return (kA_GrColorComponentFlag & validComponentFlags & coverageComponen
tFlags) && | 367 return (kA_GrColorComponentFlag & validComponentFlags & coverageComponen
tFlags) && |
348 0xFF == GrColorUnpackA(color) && 0xFF == GrColorUnpackA(coverage
); | 368 0xFF == GrColorUnpackA(color) && 0xFF == GrColorUnpackA(coverage
); |
349 | 369 |
350 } | 370 } |
351 | 371 |
352 return (kA_GrColorComponentFlag & validComponentFlags) && 0xFF == GrColorUnp
ackA(color); | 372 return (kA_GrColorComponentFlag & validComponentFlags) && 0xFF == GrColorUnp
ackA(color); |
353 } | 373 } |
354 | 374 |
| 375 //////////////////////////////////////////////////////////////////////////////// |
| 376 |
| 377 bool GrRODrawState::canIgnoreColorAttribute() const { |
| 378 if (fBlendOptFlags & kInvalid_BlendOptFlag) { |
| 379 this->getBlendOpts(); |
| 380 } |
| 381 return SkToBool(fBlendOptFlags & (GrRODrawState::kEmitTransBlack_BlendOptFla
g | |
| 382 GrRODrawState::kEmitCoverage_BlendOptFlag)
); |
| 383 } |
| 384 |
OLD | NEW |