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/GrCoverageSetOpXP.h" | 12 #include "effects/GrCoverageSetOpXP.h" |
13 #include "effects/GrPorterDuffXferProcessor.h" | 13 #include "effects/GrPorterDuffXferProcessor.h" |
14 #include "effects/GrSimpleTextureEffect.h" | 14 #include "effects/GrSimpleTextureEffect.h" |
15 | 15 |
16 GrPaint::GrPaint() | 16 GrPaint::GrPaint() |
17 : fAntiAlias(false) | 17 : fAntiAlias(false) |
18 , fColor(GrColor_WHITE) {} | 18 , fColor(GrColor_WHITE) {} |
19 | 19 |
20 void GrPaint::setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCovera
ge) { | 20 void GrPaint::setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCovera
ge) { |
21 fXPFactory.reset(GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage))
; | 21 fXPFactory.reset(GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage))
; |
22 } | 22 } |
23 | 23 |
24 void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matri
x) { | 24 void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matri
x) { |
25 this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(&fProcDataMana
ger, texture, | 25 this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(texture, matri
x))->unref(); |
26 matrix))->unre
f(); | |
27 } | 26 } |
28 | 27 |
29 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& ma
trix) { | 28 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& ma
trix) { |
30 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(&fProcDataM
anager, texture, | 29 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(texture, ma
trix))->unref(); |
31 matrix))->u
nref(); | |
32 } | 30 } |
33 | 31 |
34 void GrPaint::addColorTextureProcessor(GrTexture* texture, | 32 void GrPaint::addColorTextureProcessor(GrTexture* texture, |
35 const SkMatrix& matrix, | 33 const SkMatrix& matrix, |
36 const GrTextureParams& params) { | 34 const GrTextureParams& params) { |
37 this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(&fProcDataMana
ger, texture, | 35 this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(texture, |
38 matrix, params
))->unref(); | 36 matrix, params
))->unref(); |
39 } | 37 } |
40 | 38 |
41 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, | 39 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, |
42 const SkMatrix& matrix, | 40 const SkMatrix& matrix, |
43 const GrTextureParams& params) { | 41 const GrTextureParams& params) { |
44 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(&fProcDataM
anager, texture, | 42 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(texture, |
45 matrix, par
ams))->unref(); | 43 matrix, par
ams))->unref(); |
46 } | 44 } |
47 | 45 |
48 bool GrPaint::isConstantBlendedColor(GrColor* color) const { | 46 bool GrPaint::isConstantBlendedColor(GrColor* color) const { |
49 GrProcOptInfo colorProcInfo; | 47 GrProcOptInfo colorProcInfo; |
50 colorProcInfo.calcWithInitialValues(fColorFragmentProcessors.begin(), | 48 colorProcInfo.calcWithInitialValues(fColorFragmentProcessors.begin(), |
51 this->numColorFragmentProcessors(), fCol
or, | 49 this->numColorFragmentProcessors(), fCol
or, |
52 kRGBA_GrColorComponentFlags, false); | 50 kRGBA_GrColorComponentFlags, false); |
53 | 51 |
54 GrXPFactory::InvariantBlendedColor blendedColor; | 52 GrXPFactory::InvariantBlendedColor blendedColor; |
55 fXPFactory->getInvariantBlendedColor(colorProcInfo, &blendedColor); | 53 fXPFactory->getInvariantBlendedColor(colorProcInfo, &blendedColor); |
56 | 54 |
57 if (kRGBA_GrColorComponentFlags == blendedColor.fKnownColorFlags) { | 55 if (kRGBA_GrColorComponentFlags == blendedColor.fKnownColorFlags) { |
58 *color = blendedColor.fKnownColor; | 56 *color = blendedColor.fKnownColor; |
59 return true; | 57 return true; |
60 } | 58 } |
61 return false; | 59 return false; |
62 } | 60 } |
OLD | NEW |