Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: src/gpu/GrPaint.cpp

Issue 766653008: Revert of Make all blending up to GrOptDrawState be handled by the xp/xp factory. (Closed) Base URL: https://skia.googlesource.com/skia.git@xferFactorySolo
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrOptDrawState.cpp ('k') | src/gpu/GrProcOptInfo.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "GrProcOptInfo.h" 12 #include "GrProcOptInfo.h"
12 #include "effects/GrPorterDuffXferProcessor.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();
(...skipping 23 matching lines...) Expand all
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
51 void GrPaint::resetStages() { 52 void GrPaint::resetStages() {
52 fColorStages.reset(); 53 fColorStages.reset();
53 fCoverageStages.reset(); 54 fCoverageStages.reset();
54 fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode)); 55 fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrcOver_Mode));
55 } 56 }
56 57
57 bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor, 58 bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor,
58 uint32_t* solidColorKnownComponents) const { 59 uint32_t* solidColorKnownComponents) const {
59 60
61 // TODO: Share this implementation with GrDrawState
62
60 GrProcOptInfo coverageProcInfo; 63 GrProcOptInfo coverageProcInfo;
61 coverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), this->numCov erageStages(), 64 coverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), this->numCov erageStages(),
62 0xFFFFFFFF, kRGBA_GrColorComponentFla gs, true); 65 0xFFFFFFFF, kRGBA_GrColorComponentFla gs, true);
66
67 if (!coverageProcInfo.isSolidWhite()) {
68 return false;
69 }
70
63 GrProcOptInfo colorProcInfo; 71 GrProcOptInfo colorProcInfo;
64 colorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColorStag es(), fColor, 72 colorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColorStag es(), fColor,
65 kRGBA_GrColorComponentFlags, false); 73 kRGBA_GrColorComponentFlags, false);
66 74
67 return fXPFactory->getOpaqueAndKnownColor(colorProcInfo, coverageProcInfo, s olidColor, 75 SkASSERT((NULL == solidColor) == (NULL == solidColorKnownComponents));
68 solidColorKnownComponents); 76
77 GrBlendCoeff srcCoeff = fSrcBlendCoeff;
78 GrBlendCoeff dstCoeff = fDstBlendCoeff;
79 GrSimplifyBlend(&srcCoeff, &dstCoeff, colorProcInfo.color(), colorProcInfo.v alidFlags(),
80 0, 0, 0);
81
82 bool opaque = kZero_GrBlendCoeff == dstCoeff && !GrBlendCoeffRefsDst(srcCoef f);
83 if (solidColor) {
84 if (opaque) {
85 switch (srcCoeff) {
86 case kZero_GrBlendCoeff:
87 *solidColor = 0;
88 *solidColorKnownComponents = kRGBA_GrColorComponentFlags;
89 break;
90
91 case kOne_GrBlendCoeff:
92 *solidColor = colorProcInfo.color();
93 *solidColorKnownComponents = colorProcInfo.validFlags();
94 break;
95
96 // The src coeff should never refer to the src and if it refers to dst then opaque
97 // should have been false.
98 case kSC_GrBlendCoeff:
99 case kISC_GrBlendCoeff:
100 case kDC_GrBlendCoeff:
101 case kIDC_GrBlendCoeff:
102 case kSA_GrBlendCoeff:
103 case kISA_GrBlendCoeff:
104 case kDA_GrBlendCoeff:
105 case kIDA_GrBlendCoeff:
106 default:
107 SkFAIL("srcCoeff should not refer to src or dst.");
108 break;
109
110 // TODO: update this once GrPaint actually has a const color.
111 case kConstC_GrBlendCoeff:
112 case kIConstC_GrBlendCoeff:
113 case kConstA_GrBlendCoeff:
114 case kIConstA_GrBlendCoeff:
115 *solidColorKnownComponents = 0;
116 break;
117 }
118 } else {
119 solidColorKnownComponents = 0;
120 }
121 }
122 return opaque;
69 } 123 }
70 124
OLDNEW
« no previous file with comments | « src/gpu/GrOptDrawState.cpp ('k') | src/gpu/GrProcOptInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698