| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 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 #include "GrPaint.h" | 9 #include "GrPaint.h" |
| 10 | 10 |
| 11 #include "GrProcOptInfo.h" | 11 #include "GrProcOptInfo.h" |
| 12 #include "effects/GrPorterDuffXferProcessor.h" | 12 #include "effects/GrPorterDuffXferProcessor.h" |
| 13 #include "effects/GrSimpleTextureEffect.h" | 13 #include "effects/GrSimpleTextureEffect.h" |
| 14 | 14 |
| 15 void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matri
x) { | 15 void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matri
x) { |
| 16 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unr
ef(); | 16 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unr
ef(); |
| 17 } | 17 } |
| 18 | 18 |
| 19 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& ma
trix) { | 19 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& ma
trix) { |
| 20 this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix))->
unref(); | 20 this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix))->
unref(); |
| 21 } | 21 } |
| 22 | 22 |
| 23 void GrPaint::addColorTextureProcessor(GrTexture* texture, | 23 void GrPaint::addColorTextureProcessor(GrTexture* texture, |
| 24 const SkMatrix& matrix, | 24 const SkMatrix& matrix, |
| 25 const GrTextureParams& params) { | 25 const GrTextureParams& params) { |
| 26 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix, param
s))->unref(); | 26 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix, param
s))->unref(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, | 29 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, |
| 30 const SkMatrix& matrix, | 30 const SkMatrix& matrix, |
| 31 const GrTextureParams& params) { | 31 const GrTextureParams& params) { |
| 32 this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix, pa
rams))->unref(); | 32 this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix, pa
rams))->unref(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 bool GrPaint::isOpaqueAndConstantColor(GrColor* color) const { | 35 bool GrPaint::isOpaqueAndConstantColor(GrColor* color) const { |
| 36 GrProcOptInfo coverageProcInfo; | 36 GrProcOptInfo coverageProcInfo; |
| 37 coverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), this->numCov
erageStages(), | 37 coverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), this->numCov
erageStages(), |
| 38 0xFFFFFFFF, kRGBA_GrColorComponentFla
gs, true); | 38 0xFFFFFFFF, kRGBA_GrColorComponentFla
gs, true); |
| 39 GrProcOptInfo colorProcInfo; | 39 GrProcOptInfo colorProcInfo; |
| 40 colorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColorStag
es(), fColor, | 40 colorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColorStag
es(), fColor, |
| 41 kRGBA_GrColorComponentFlags, false); | 41 kRGBA_GrColorComponentFlags, false); |
| 42 | 42 |
| 43 GrXPFactory::InvariantOutput output; | 43 GrXPFactory::InvariantOutput output; |
| 44 fXPFactory->getInvariantOutput(colorProcInfo, coverageProcInfo, &output); | 44 fXPFactory->getInvariantOutput(colorProcInfo, coverageProcInfo, &output); |
| 45 | 45 |
| 46 if (kRGBA_GrColorComponentFlags == output.fBlendedColorFlags && | 46 if (kRGBA_GrColorComponentFlags == output.fBlendedColorFlags && |
| 47 0xFF == GrColorUnpackA(output.fBlendedColor)) { | 47 0xFF == GrColorUnpackA(output.fBlendedColor)) { |
| 48 *color = output.fBlendedColor; | 48 *color = output.fBlendedColor; |
| 49 return true; | 49 return true; |
| 50 } | 50 } |
| 51 return false; | 51 return false; |
| 52 } | 52 } |
| 53 | 53 |
| 54 void GrPaint::resetStages() { | 54 void GrPaint::resetStages() { |
| 55 fColorStages.reset(); | 55 fColorStages.reset(); |
| 56 fCoverageStages.reset(); | 56 fCoverageStages.reset(); |
| 57 fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode)); | 57 fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode)); |
| 58 } | 58 } |
| 59 | 59 |
| OLD | NEW |