| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "GrPaint.h" | 8 #include "GrPaint.h" |
| 9 | 9 |
| 10 #include "GrProcOptInfo.h" | 10 #include "GrProcOptInfo.h" |
| 11 #include "effects/GrCoverageSetOpXP.h" | 11 #include "effects/GrCoverageSetOpXP.h" |
| 12 #include "effects/GrPorterDuffXferProcessor.h" | 12 #include "effects/GrPorterDuffXferProcessor.h" |
| 13 #include "effects/GrSimpleTextureEffect.h" | 13 #include "effects/GrSimpleTextureEffect.h" |
| 14 | 14 |
| 15 GrPaint::GrPaint() | 15 GrPaint::GrPaint() |
| 16 : fAntiAlias(false) | 16 : fAntiAlias(false) |
| 17 , fDisableOutputConversionToSRGB(false) | 17 , fDisableOutputConversionToSRGB(false) |
| 18 , fAllowSRGBInputs(false) | 18 , fAllowSRGBInputs(false) |
| 19 , fColor(GrColor_WHITE) {} | 19 , fColor(GrColor4f::FromGrColor(GrColor_WHITE)) {} |
| 20 | 20 |
| 21 void GrPaint::setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCovera
ge) { | 21 void GrPaint::setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCovera
ge) { |
| 22 fXPFactory = GrCoverageSetOpXPFactory::Make(regionOp, invertCoverage); | 22 fXPFactory = GrCoverageSetOpXPFactory::Make(regionOp, invertCoverage); |
| 23 } | 23 } |
| 24 | 24 |
| 25 void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matri
x) { | 25 void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matri
x) { |
| 26 this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix)
); | 26 this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix)
); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& ma
trix) { | 29 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& ma
trix) { |
| 30 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, matr
ix)); | 30 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, matr
ix)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void GrPaint::addColorTextureProcessor(GrTexture* texture, | 33 void GrPaint::addColorTextureProcessor(GrTexture* texture, |
| 34 const SkMatrix& matrix, | 34 const SkMatrix& matrix, |
| 35 const GrTextureParams& params) { | 35 const GrTextureParams& params) { |
| 36 this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix,
params)); | 36 this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix,
params)); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, | 39 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, |
| 40 const SkMatrix& matrix, | 40 const SkMatrix& matrix, |
| 41 const GrTextureParams& params) { | 41 const GrTextureParams& params) { |
| 42 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, matr
ix, params)); | 42 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, matr
ix, params)); |
| 43 } | 43 } |
| 44 | 44 |
| 45 bool GrPaint::isConstantBlendedColor(GrColor* color) const { | 45 bool GrPaint::isConstantBlendedColor(GrColor* color) const { |
| 46 GrProcOptInfo colorProcInfo; | 46 GrProcOptInfo colorProcInfo; |
| 47 colorProcInfo.calcWithInitialValues( | 47 colorProcInfo.calcWithInitialValues( |
| 48 sk_sp_address_as_pointer_address(fColorFragmentProcessors.begin()), | 48 sk_sp_address_as_pointer_address(fColorFragmentProcessors.begin()), |
| 49 this->numColorFragmentProcessors(), fColor, kRGBA_GrColorComponentFlags,
false); | 49 this->numColorFragmentProcessors(), this->getColor(), kRGBA_GrColorCompo
nentFlags, false); |
| 50 | 50 |
| 51 GrXPFactory::InvariantBlendedColor blendedColor; | 51 GrXPFactory::InvariantBlendedColor blendedColor; |
| 52 if (fXPFactory) { | 52 if (fXPFactory) { |
| 53 fXPFactory->getInvariantBlendedColor(colorProcInfo, &blendedColor); | 53 fXPFactory->getInvariantBlendedColor(colorProcInfo, &blendedColor); |
| 54 } else { | 54 } else { |
| 55 GrPorterDuffXPFactory::SrcOverInvariantBlendedColor(colorProcInfo.color(
), | 55 GrPorterDuffXPFactory::SrcOverInvariantBlendedColor(colorProcInfo.color(
), |
| 56 colorProcInfo.validF
lags(), | 56 colorProcInfo.validF
lags(), |
| 57 colorProcInfo.isOpaq
ue(), | 57 colorProcInfo.isOpaq
ue(), |
| 58 &blendedColor); | 58 &blendedColor); |
| 59 } | 59 } |
| 60 | 60 |
| 61 if (kRGBA_GrColorComponentFlags == blendedColor.fKnownColorFlags) { | 61 if (kRGBA_GrColorComponentFlags == blendedColor.fKnownColorFlags) { |
| 62 *color = blendedColor.fKnownColor; | 62 *color = blendedColor.fKnownColor; |
| 63 return true; | 63 return true; |
| 64 } | 64 } |
| 65 return false; | 65 return false; |
| 66 } | 66 } |
| OLD | NEW |