| 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(GrColor4f::FromGrColor(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, |
| 26 this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix)
); | 26 sk_sp<GrColorSpaceXform> colorSpaceXform, |
| 27 const SkMatrix& matrix) { |
| 28 this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, |
| 29 std::move(colorS
paceXform), |
| 30 matrix)); |
| 27 } | 31 } |
| 28 | 32 |
| 29 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& ma
trix) { | 33 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& ma
trix) { |
| 30 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, matr
ix)); | 34 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, null
ptr, matrix)); |
| 31 } | 35 } |
| 32 | 36 |
| 33 void GrPaint::addColorTextureProcessor(GrTexture* texture, | 37 void GrPaint::addColorTextureProcessor(GrTexture* texture, |
| 38 sk_sp<GrColorSpaceXform> colorSpaceXform, |
| 34 const SkMatrix& matrix, | 39 const SkMatrix& matrix, |
| 35 const GrTextureParams& params) { | 40 const GrTextureParams& params) { |
| 36 this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix,
params)); | 41 this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, |
| 42 std::move(colorS
paceXform), |
| 43 matrix, params))
; |
| 37 } | 44 } |
| 38 | 45 |
| 39 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, | 46 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, |
| 40 const SkMatrix& matrix, | 47 const SkMatrix& matrix, |
| 41 const GrTextureParams& params) { | 48 const GrTextureParams& params) { |
| 42 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, matr
ix, params)); | 49 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, null
ptr, matrix, |
| 50 params)); |
| 43 } | 51 } |
| 44 | 52 |
| 45 bool GrPaint::isConstantBlendedColor(GrColor* color) const { | 53 bool GrPaint::isConstantBlendedColor(GrColor* color) const { |
| 46 GrProcOptInfo colorProcInfo; | 54 GrProcOptInfo colorProcInfo; |
| 47 colorProcInfo.calcWithInitialValues( | 55 colorProcInfo.calcWithInitialValues( |
| 48 sk_sp_address_as_pointer_address(fColorFragmentProcessors.begin()), | 56 sk_sp_address_as_pointer_address(fColorFragmentProcessors.begin()), |
| 49 this->numColorFragmentProcessors(), this->getColor(), kRGBA_GrColorCompo
nentFlags, false); | 57 this->numColorFragmentProcessors(), this->getColor(), kRGBA_GrColorCompo
nentFlags, false); |
| 50 | 58 |
| 51 GrXPFactory::InvariantBlendedColor blendedColor; | 59 GrXPFactory::InvariantBlendedColor blendedColor; |
| 52 if (fXPFactory) { | 60 if (fXPFactory) { |
| 53 fXPFactory->getInvariantBlendedColor(colorProcInfo, &blendedColor); | 61 fXPFactory->getInvariantBlendedColor(colorProcInfo, &blendedColor); |
| 54 } else { | 62 } else { |
| 55 GrPorterDuffXPFactory::SrcOverInvariantBlendedColor(colorProcInfo.color(
), | 63 GrPorterDuffXPFactory::SrcOverInvariantBlendedColor(colorProcInfo.color(
), |
| 56 colorProcInfo.validF
lags(), | 64 colorProcInfo.validF
lags(), |
| 57 colorProcInfo.isOpaq
ue(), | 65 colorProcInfo.isOpaq
ue(), |
| 58 &blendedColor); | 66 &blendedColor); |
| 59 } | 67 } |
| 60 | 68 |
| 61 if (kRGBA_GrColorComponentFlags == blendedColor.fKnownColorFlags) { | 69 if (kRGBA_GrColorComponentFlags == blendedColor.fKnownColorFlags) { |
| 62 *color = blendedColor.fKnownColor; | 70 *color = blendedColor.fKnownColor; |
| 63 return true; | 71 return true; |
| 64 } | 72 } |
| 65 return false; | 73 return false; |
| 66 } | 74 } |
| OLD | NEW |