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