OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrPipelineBuilder.h" | 8 #include "GrPipelineBuilder.h" |
9 | 9 |
10 #include "GrBlend.h" | 10 #include "GrBlend.h" |
11 #include "GrPaint.h" | 11 #include "GrPaint.h" |
12 #include "GrPipeline.h" | 12 #include "GrPipeline.h" |
13 #include "GrProcOptInfo.h" | 13 #include "GrProcOptInfo.h" |
14 #include "GrXferProcessor.h" | 14 #include "GrXferProcessor.h" |
15 #include "effects/GrPorterDuffXferProcessor.h" | 15 #include "effects/GrPorterDuffXferProcessor.h" |
16 | 16 |
17 GrPipelineBuilder::GrPipelineBuilder() | 17 GrPipelineBuilder::GrPipelineBuilder() |
18 : fFlagBits(0x0) | 18 : fFlagBits(0x0) |
19 , fDrawFace(kBoth_DrawFace) | 19 , fDrawFace(kBoth_DrawFace) |
20 , fColorProcInfoValid(false) | 20 , fColorProcInfoValid(false) |
21 , fCoverageProcInfoValid(false) | 21 , fCoverageProcInfoValid(false) |
22 , fColorCache(GrColor_ILLEGAL) | 22 , fColorCache(GrColor_ILLEGAL) |
23 , fCoverageCache(GrColor_ILLEGAL) { | 23 , fCoverageCache(GrColor_ILLEGAL) |
| 24 , fColorPrimProc(NULL) |
| 25 , fCoveragePrimProc(NULL) { |
24 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) | 26 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) |
25 } | 27 } |
26 | 28 |
27 GrPipelineBuilder& GrPipelineBuilder::operator=(const GrPipelineBuilder& that) { | 29 GrPipelineBuilder& GrPipelineBuilder::operator=(const GrPipelineBuilder& that) { |
28 fRenderTarget.reset(SkSafeRef(that.fRenderTarget.get())); | 30 fRenderTarget.reset(SkSafeRef(that.fRenderTarget.get())); |
29 fFlagBits = that.fFlagBits; | 31 fFlagBits = that.fFlagBits; |
30 fStencilSettings = that.fStencilSettings; | 32 fStencilSettings = that.fStencilSettings; |
31 fDrawFace = that.fDrawFace; | 33 fDrawFace = that.fDrawFace; |
32 fXPFactory.reset(SkRef(that.getXPFactory())); | 34 fXPFactory.reset(SkRef(that.getXPFactory())); |
33 fColorStages = that.fColorStages; | 35 fColorStages = that.fColorStages; |
34 fCoverageStages = that.fCoverageStages; | 36 fCoverageStages = that.fCoverageStages; |
35 | 37 |
36 fColorProcInfoValid = that.fColorProcInfoValid; | 38 fColorProcInfoValid = that.fColorProcInfoValid; |
37 fCoverageProcInfoValid = that.fCoverageProcInfoValid; | 39 fCoverageProcInfoValid = that.fCoverageProcInfoValid; |
38 fColorCache = that.fColorCache; | 40 fColorCache = that.fColorCache; |
39 fCoverageCache = that.fCoverageCache; | 41 fCoverageCache = that.fCoverageCache; |
| 42 fColorPrimProc = that.fColorPrimProc; |
| 43 fCoveragePrimProc = that.fCoveragePrimProc; |
40 if (fColorProcInfoValid) { | 44 if (fColorProcInfoValid) { |
41 fColorProcInfo = that.fColorProcInfo; | 45 fColorProcInfo = that.fColorProcInfo; |
42 } | 46 } |
43 if (fCoverageProcInfoValid) { | 47 if (fCoverageProcInfoValid) { |
44 fCoverageProcInfo = that.fCoverageProcInfo; | 48 fCoverageProcInfo = that.fCoverageProcInfo; |
45 } | 49 } |
46 return *this; | 50 return *this; |
47 } | 51 } |
48 | 52 |
49 void GrPipelineBuilder::setFromPaint(const GrPaint& paint, GrRenderTarget* rt) { | 53 void GrPipelineBuilder::setFromPaint(const GrPaint& paint, GrRenderTarget* rt) { |
(...skipping 23 matching lines...) Expand all Loading... |
73 this->enableState(GrPipelineBuilder::kClip_StateBit); | 77 this->enableState(GrPipelineBuilder::kClip_StateBit); |
74 | 78 |
75 this->setState(GrPipelineBuilder::kDither_StateBit, paint.isDither()); | 79 this->setState(GrPipelineBuilder::kDither_StateBit, paint.isDither()); |
76 this->setState(GrPipelineBuilder::kHWAntialias_StateBit, paint.isAntiAlias()
); | 80 this->setState(GrPipelineBuilder::kHWAntialias_StateBit, paint.isAntiAlias()
); |
77 | 81 |
78 fColorProcInfoValid = false; | 82 fColorProcInfoValid = false; |
79 fCoverageProcInfoValid = false; | 83 fCoverageProcInfoValid = false; |
80 | 84 |
81 fColorCache = GrColor_ILLEGAL; | 85 fColorCache = GrColor_ILLEGAL; |
82 fCoverageCache = GrColor_ILLEGAL; | 86 fCoverageCache = GrColor_ILLEGAL; |
| 87 |
| 88 fColorPrimProc = NULL; |
| 89 fCoveragePrimProc = NULL; |
83 } | 90 } |
84 | 91 |
85 //////////////////////////////////////////////////////////////////////////////// | 92 //////////////////////////////////////////////////////////////////////////////// |
86 | 93 |
87 bool GrPipelineBuilder::canUseFracCoveragePrimProc(GrColor color, | 94 bool GrPipelineBuilder::canUseFracCoveragePrimProc(GrColor color, |
88 const GrDrawTargetCaps& caps)
const { | 95 const GrDrawTargetCaps& caps)
const { |
89 if (caps.dualSourceBlendingSupport()) { | 96 if (caps.dualSourceBlendingSupport()) { |
90 return true; | 97 return true; |
91 } | 98 } |
92 | 99 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 bool GrPipelineBuilder::willBlendWithDst(const GrPrimitiveProcessor* pp) const { | 154 bool GrPipelineBuilder::willBlendWithDst(const GrPrimitiveProcessor* pp) const { |
148 this->calcColorInvariantOutput(pp); | 155 this->calcColorInvariantOutput(pp); |
149 this->calcCoverageInvariantOutput(pp); | 156 this->calcCoverageInvariantOutput(pp); |
150 | 157 |
151 GrXPFactory::InvariantOutput output; | 158 GrXPFactory::InvariantOutput output; |
152 fXPFactory->getInvariantOutput(fColorProcInfo, fCoverageProcInfo, &output); | 159 fXPFactory->getInvariantOutput(fColorProcInfo, fCoverageProcInfo, &output); |
153 return output.fWillBlendWithDst; | 160 return output.fWillBlendWithDst; |
154 } | 161 } |
155 | 162 |
156 void GrPipelineBuilder::calcColorInvariantOutput(const GrPrimitiveProcessor* pp)
const { | 163 void GrPipelineBuilder::calcColorInvariantOutput(const GrPrimitiveProcessor* pp)
const { |
157 fColorProcInfo.calcColorWithPrimProc(pp, fColorStages.begin(), this->numColo
rStages()); | 164 if (!fColorProcInfoValid || fColorPrimProc != pp) { |
158 fColorProcInfoValid = false; | 165 fColorProcInfo.calcColorWithPrimProc(pp, fColorStages.begin(), this->num
ColorStages()); |
159 | 166 fColorProcInfoValid = true; |
| 167 fColorPrimProc = pp; |
| 168 } |
160 } | 169 } |
161 | 170 |
162 void GrPipelineBuilder::calcCoverageInvariantOutput(const GrPrimitiveProcessor*
pp) const { | 171 void GrPipelineBuilder::calcCoverageInvariantOutput(const GrPrimitiveProcessor*
pp) const { |
163 fCoverageProcInfo.calcCoverageWithPrimProc(pp, fCoverageStages.begin(), | 172 if (!fCoverageProcInfoValid || fCoveragePrimProc != pp) { |
164 this->numCoverageStages()); | 173 fCoverageProcInfo.calcCoverageWithPrimProc(pp, fCoverageStages.begin(), |
165 fCoverageProcInfoValid = false; | 174 this->numCoverageStages()); |
| 175 fCoverageProcInfoValid = true; |
| 176 fCoveragePrimProc = pp; |
| 177 } |
166 } | 178 } |
167 | 179 |
168 void GrPipelineBuilder::calcColorInvariantOutput(const GrBatch* batch) const { | |
169 fColorProcInfo.calcColorWithBatch(batch, fColorStages.begin(), this->numColo
rStages()); | |
170 fColorProcInfoValid = false; | |
171 } | |
172 | |
173 void GrPipelineBuilder::calcCoverageInvariantOutput(const GrBatch* batch) const
{ | |
174 fCoverageProcInfo.calcCoverageWithBatch(batch, fCoverageStages.begin(), | |
175 this->numCoverageStages()); | |
176 fCoverageProcInfoValid = false; | |
177 } | |
178 | |
179 | |
180 void GrPipelineBuilder::calcColorInvariantOutput(GrColor color) const { | 180 void GrPipelineBuilder::calcColorInvariantOutput(GrColor color) const { |
181 if (!fColorProcInfoValid || color != fColorCache) { | 181 if (!fColorProcInfoValid || color != fColorCache) { |
182 GrColorComponentFlags flags = kRGBA_GrColorComponentFlags; | 182 GrColorComponentFlags flags = kRGBA_GrColorComponentFlags; |
183 fColorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColo
rStages(), color, | 183 fColorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColo
rStages(), color, |
184 flags, false); | 184 flags, false); |
185 fColorProcInfoValid = true; | 185 fColorProcInfoValid = true; |
186 fColorCache = color; | 186 fColorCache = color; |
187 } | 187 } |
188 } | 188 } |
189 | 189 |
190 void GrPipelineBuilder::calcCoverageInvariantOutput(GrColor coverage) const { | 190 void GrPipelineBuilder::calcCoverageInvariantOutput(GrColor coverage) const { |
191 if (!fCoverageProcInfoValid || coverage != fCoverageCache) { | 191 if (!fCoverageProcInfoValid || coverage != fCoverageCache) { |
192 GrColorComponentFlags flags = kRGBA_GrColorComponentFlags; | 192 GrColorComponentFlags flags = kRGBA_GrColorComponentFlags; |
193 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), | 193 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), |
194 this->numCoverageStages(), cover
age, flags, | 194 this->numCoverageStages(), cover
age, flags, |
195 true); | 195 true); |
196 fCoverageProcInfoValid = true; | 196 fCoverageProcInfoValid = true; |
197 fCoverageCache = coverage; | 197 fCoverageCache = coverage; |
198 } | 198 } |
199 } | 199 } |
OLD | NEW |