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