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