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(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.reset(GrCoverageSetOpXPFactory::Create(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::Create(texture, matri
x))->unref(); | 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::Create(texture, ma
trix))->unref(); | 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::Create(texture, | 36 this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix,
params)); |
37 matrix, params
))->unref(); | |
38 } | 37 } |
39 | 38 |
40 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, | 39 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, |
41 const SkMatrix& matrix, | 40 const SkMatrix& matrix, |
42 const GrTextureParams& params) { | 41 const GrTextureParams& params) { |
43 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(texture, | 42 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, matr
ix, params)); |
44 matrix, par
ams))->unref(); | |
45 } | 43 } |
46 | 44 |
47 bool GrPaint::isConstantBlendedColor(GrColor* color) const { | 45 bool GrPaint::isConstantBlendedColor(GrColor* color) const { |
48 GrProcOptInfo colorProcInfo; | 46 GrProcOptInfo colorProcInfo; |
49 colorProcInfo.calcWithInitialValues(fColorFragmentProcessors.begin(), | 47 colorProcInfo.calcWithInitialValues( |
50 this->numColorFragmentProcessors(), fCol
or, | 48 sk_sp_address_as_pointer_address(fColorFragmentProcessors.begin()), |
51 kRGBA_GrColorComponentFlags, false); | 49 this->numColorFragmentProcessors(), fColor, kRGBA_GrColorComponentFlags,
false); |
52 | 50 |
53 GrXPFactory::InvariantBlendedColor blendedColor; | 51 GrXPFactory::InvariantBlendedColor blendedColor; |
54 if (fXPFactory) { | 52 if (fXPFactory) { |
55 fXPFactory->getInvariantBlendedColor(colorProcInfo, &blendedColor); | 53 fXPFactory->getInvariantBlendedColor(colorProcInfo, &blendedColor); |
56 } else { | 54 } else { |
57 GrPorterDuffXPFactory::SrcOverInvariantBlendedColor(colorProcInfo.color(
), | 55 GrPorterDuffXPFactory::SrcOverInvariantBlendedColor(colorProcInfo.color(
), |
58 colorProcInfo.validF
lags(), | 56 colorProcInfo.validF
lags(), |
59 colorProcInfo.isOpaq
ue(), | 57 colorProcInfo.isOpaq
ue(), |
60 &blendedColor); | 58 &blendedColor); |
61 } | 59 } |
62 | 60 |
63 if (kRGBA_GrColorComponentFlags == blendedColor.fKnownColorFlags) { | 61 if (kRGBA_GrColorComponentFlags == blendedColor.fKnownColorFlags) { |
64 *color = blendedColor.fKnownColor; | 62 *color = blendedColor.fKnownColor; |
65 return true; | 63 return true; |
66 } | 64 } |
67 return false; | 65 return false; |
68 } | 66 } |
OLD | NEW |