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 "GrBlend.h" | 11 #include "GrBlend.h" |
12 #include "GrProcOptInfo.h" | 12 #include "GrProcOptInfo.h" |
| 13 #include "effects/GrPorterDuffXferProcessor.h" |
13 #include "effects/GrSimpleTextureEffect.h" | 14 #include "effects/GrSimpleTextureEffect.h" |
14 | 15 |
15 void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matri
x) { | 16 void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matri
x) { |
16 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unr
ef(); | 17 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unr
ef(); |
17 } | 18 } |
18 | 19 |
19 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& ma
trix) { | 20 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& ma
trix) { |
20 this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix))->
unref(); | 21 this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix))->
unref(); |
21 } | 22 } |
22 | 23 |
(...skipping 18 matching lines...) Expand all Loading... |
41 uint32_t colorComps = 0; | 42 uint32_t colorComps = 0; |
42 if (this->getOpaqueAndKnownColor(&tempColor, &colorComps)) { | 43 if (this->getOpaqueAndKnownColor(&tempColor, &colorComps)) { |
43 if (kRGBA_GrColorComponentFlags == colorComps) { | 44 if (kRGBA_GrColorComponentFlags == colorComps) { |
44 *color = tempColor; | 45 *color = tempColor; |
45 return true; | 46 return true; |
46 } | 47 } |
47 } | 48 } |
48 return false; | 49 return false; |
49 } | 50 } |
50 | 51 |
| 52 void GrPaint::resetStages() { |
| 53 fColorStages.reset(); |
| 54 fCoverageStages.reset(); |
| 55 fXPFactory.reset(GrPorterDuffXPFactory::Create(kOne_GrBlendCoeff, |
| 56 kZero_GrBlendCoeff)); |
| 57 } |
| 58 |
51 bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor, | 59 bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor, |
52 uint32_t* solidColorKnownComponents) const
{ | 60 uint32_t* solidColorKnownComponents) const
{ |
53 | 61 |
54 // TODO: Share this implementation with GrDrawState | 62 // TODO: Share this implementation with GrDrawState |
55 | 63 |
56 GrProcOptInfo coverageProcInfo; | 64 GrProcOptInfo coverageProcInfo; |
57 coverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), this->numCov
erageStages(), | 65 coverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), this->numCov
erageStages(), |
58 0xFFFFFFFF, kRGBA_GrColorComponentFla
gs, true); | 66 0xFFFFFFFF, kRGBA_GrColorComponentFla
gs, true); |
59 | 67 |
60 if (!coverageProcInfo.isSolidWhite()) { | 68 if (!coverageProcInfo.isSolidWhite()) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 case kIConstA_GrBlendCoeff: | 115 case kIConstA_GrBlendCoeff: |
108 *solidColorKnownComponents = 0; | 116 *solidColorKnownComponents = 0; |
109 break; | 117 break; |
110 } | 118 } |
111 } else { | 119 } else { |
112 solidColorKnownComponents = 0; | 120 solidColorKnownComponents = 0; |
113 } | 121 } |
114 } | 122 } |
115 return opaque; | 123 return opaque; |
116 } | 124 } |
| 125 |
OLD | NEW |