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

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

Issue 759713002: 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: rebase 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"
12 #include "GrProcOptInfo.h" 11 #include "GrProcOptInfo.h"
13 #include "effects/GrPorterDuffXferProcessor.h" 12 #include "effects/GrPorterDuffXferProcessor.h"
14 #include "effects/GrSimpleTextureEffect.h" 13 #include "effects/GrSimpleTextureEffect.h"
15 14
16 void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matri x) { 15 void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matri x) {
17 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unr ef(); 16 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unr ef();
18 } 17 }
19 18
20 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& ma trix) { 19 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& ma trix) {
21 this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix))-> unref(); 20 this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix))-> unref();
(...skipping 23 matching lines...) Expand all
45 *color = tempColor; 44 *color = tempColor;
46 return true; 45 return true;
47 } 46 }
48 } 47 }
49 return false; 48 return false;
50 } 49 }
51 50
52 void GrPaint::resetStages() { 51 void GrPaint::resetStages() {
53 fColorStages.reset(); 52 fColorStages.reset();
54 fCoverageStages.reset(); 53 fCoverageStages.reset();
55 fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrcOver_Mode)); 54 fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode));
56 } 55 }
57 56
58 bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor, 57 bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor,
59 uint32_t* solidColorKnownComponents) const { 58 uint32_t* solidColorKnownComponents) const {
60 59
61 // TODO: Share this implementation with GrDrawState
62
63 GrProcOptInfo coverageProcInfo; 60 GrProcOptInfo coverageProcInfo;
64 coverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), this->numCov erageStages(), 61 coverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), this->numCov erageStages(),
65 0xFFFFFFFF, kRGBA_GrColorComponentFla gs, true); 62 0xFFFFFFFF, kRGBA_GrColorComponentFla gs, true);
66
67 if (!coverageProcInfo.isSolidWhite()) {
68 return false;
69 }
70
71 GrProcOptInfo colorProcInfo; 63 GrProcOptInfo colorProcInfo;
72 colorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColorStag es(), fColor, 64 colorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColorStag es(), fColor,
73 kRGBA_GrColorComponentFlags, false); 65 kRGBA_GrColorComponentFlags, false);
74 66
75 SkASSERT((NULL == solidColor) == (NULL == solidColorKnownComponents)); 67 return fXPFactory->getOpaqueAndKnownColor(colorProcInfo, coverageProcInfo, s olidColor,
76 68 solidColorKnownComponents);
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;
123 } 69 }
124 70
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