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 |
(...skipping 14 matching lines...) Expand all Loading... |
25 const GrTextureParams& params) { | 25 const GrTextureParams& params) { |
26 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix, param
s))->unref(); | 26 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix, param
s))->unref(); |
27 } | 27 } |
28 | 28 |
29 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, | 29 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, |
30 const SkMatrix& matrix, | 30 const SkMatrix& matrix, |
31 const GrTextureParams& params) { | 31 const GrTextureParams& params) { |
32 this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix, pa
rams))->unref(); | 32 this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix, pa
rams))->unref(); |
33 } | 33 } |
34 | 34 |
35 bool GrPaint::isOpaque() const { | 35 bool GrPaint::isOpaqueAndConstantColor(GrColor* color) const { |
36 return this->getOpaqueAndKnownColor(NULL, NULL); | 36 GrProcOptInfo coverageProcInfo; |
37 } | 37 coverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), this->numCov
erageStages(), |
| 38 0xFFFFFFFF, kRGBA_GrColorComponentFla
gs, true); |
| 39 GrProcOptInfo colorProcInfo; |
| 40 colorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColorStag
es(), fColor, |
| 41 kRGBA_GrColorComponentFlags, false); |
38 | 42 |
39 bool GrPaint::isOpaqueAndConstantColor(GrColor* color) const { | 43 GrXPFactory::InvariantOutput output; |
40 GrColor tempColor = 0; | 44 fXPFactory->getInvariantOutput(colorProcInfo, coverageProcInfo, true, &outpu
t); |
41 uint32_t colorComps = 0; | 45 |
42 if (this->getOpaqueAndKnownColor(&tempColor, &colorComps)) { | 46 if (kRGBA_GrColorComponentFlags == output.fBlendedColorFlags && |
43 if (kRGBA_GrColorComponentFlags == colorComps) { | 47 0xFF == GrColorUnpackA(output.fBlendedColor)) { |
44 *color = tempColor; | 48 *color = output.fBlendedColor; |
45 return true; | 49 return true; |
46 } | |
47 } | 50 } |
48 return false; | 51 return false; |
49 } | 52 } |
50 | 53 |
51 void GrPaint::resetStages() { | 54 void GrPaint::resetStages() { |
52 fColorStages.reset(); | 55 fColorStages.reset(); |
53 fCoverageStages.reset(); | 56 fCoverageStages.reset(); |
54 fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode)); | 57 fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode)); |
55 } | 58 } |
56 | 59 |
57 bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor, | |
58 uint32_t* solidColorKnownComponents) const
{ | |
59 | |
60 GrProcOptInfo coverageProcInfo; | |
61 coverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), this->numCov
erageStages(), | |
62 0xFFFFFFFF, kRGBA_GrColorComponentFla
gs, true); | |
63 GrProcOptInfo colorProcInfo; | |
64 colorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColorStag
es(), fColor, | |
65 kRGBA_GrColorComponentFlags, false); | |
66 | |
67 return fXPFactory->getOpaqueAndKnownColor(colorProcInfo, coverageProcInfo, s
olidColor, | |
68 solidColorKnownComponents); | |
69 } | |
70 | |
OLD | NEW |