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

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

Issue 845103005: GrBatchPrototype (Closed) Base URL: https://skia.googlesource.com/skia.git@lc2
Patch Set: update devrect Created 5 years, 11 months 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
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "GrDrawState.h" 8 #include "GrDrawState.h"
9 9
10 #include "GrBlend.h" 10 #include "GrBlend.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 fXPFactory.reset(SkRef(that.getXPFactory())); 52 fXPFactory.reset(SkRef(that.getXPFactory()));
53 fColorStages = that.fColorStages; 53 fColorStages = that.fColorStages;
54 fCoverageStages = that.fCoverageStages; 54 fCoverageStages = that.fCoverageStages;
55 55
56 fColorProcInfoValid = that.fColorProcInfoValid; 56 fColorProcInfoValid = that.fColorProcInfoValid;
57 fCoverageProcInfoValid = that.fCoverageProcInfoValid; 57 fCoverageProcInfoValid = that.fCoverageProcInfoValid;
58 fColorCache = that.fColorCache; 58 fColorCache = that.fColorCache;
59 fCoverageCache = that.fCoverageCache; 59 fCoverageCache = that.fCoverageCache;
60 fColorPrimProc = that.fColorPrimProc; 60 fColorPrimProc = that.fColorPrimProc;
61 fCoveragePrimProc = that.fCoveragePrimProc; 61 fCoveragePrimProc = that.fCoveragePrimProc;
62 fColorBatch = that.fColorBatch;
63 fCoverageBatch = that.fCoverageBatch;
62 if (fColorProcInfoValid) { 64 if (fColorProcInfoValid) {
63 fColorProcInfo = that.fColorProcInfo; 65 fColorProcInfo = that.fColorProcInfo;
64 } 66 }
65 if (fCoverageProcInfoValid) { 67 if (fCoverageProcInfoValid) {
66 fCoverageProcInfo = that.fCoverageProcInfo; 68 fCoverageProcInfo = that.fCoverageProcInfo;
67 } 69 }
68 return *this; 70 return *this;
69 } 71 }
70 72
71 void GrDrawState::onReset() { 73 void GrDrawState::onReset() {
72 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numFragmentStages()); 74 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numFragmentStages());
73 fRenderTarget.reset(NULL); 75 fRenderTarget.reset(NULL);
74 76
75 fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode)); 77 fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode));
76 fColorStages.reset(); 78 fColorStages.reset();
77 fCoverageStages.reset(); 79 fCoverageStages.reset();
78 80
79 fFlagBits = 0x0; 81 fFlagBits = 0x0;
80 fStencilSettings.setDisabled(); 82 fStencilSettings.setDisabled();
81 fDrawFace = kBoth_DrawFace; 83 fDrawFace = kBoth_DrawFace;
82 84
83 fColorProcInfoValid = false; 85 fColorProcInfoValid = false;
84 fCoverageProcInfoValid = false; 86 fCoverageProcInfoValid = false;
85 87
86 fColorCache = GrColor_ILLEGAL; 88 fColorCache = GrColor_ILLEGAL;
87 fCoverageCache = GrColor_ILLEGAL; 89 fCoverageCache = GrColor_ILLEGAL;
88 90
89 fColorPrimProc = NULL; 91 fColorPrimProc = NULL;
90 fCoveragePrimProc = NULL; 92 fCoveragePrimProc = NULL;
93
94 fColorBatch = NULL;
95 fCoverageBatch = NULL;
91 } 96 }
92 97
93 void GrDrawState::setFromPaint(const GrPaint& paint, GrRenderTarget* rt) { 98 void GrDrawState::setFromPaint(const GrPaint& paint, GrRenderTarget* rt) {
94 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numFragmentStages()); 99 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numFragmentStages());
95 100
96 fColorStages.reset(); 101 fColorStages.reset();
97 fCoverageStages.reset(); 102 fCoverageStages.reset();
98 103
99 for (int i = 0; i < paint.numColorStages(); ++i) { 104 for (int i = 0; i < paint.numColorStages(); ++i) {
100 fColorStages.push_back(paint.getColorStage(i)); 105 fColorStages.push_back(paint.getColorStage(i));
(...skipping 19 matching lines...) Expand all
120 this->setState(GrDrawState::kHWAntialias_StateBit, paint.isAntiAlias()); 125 this->setState(GrDrawState::kHWAntialias_StateBit, paint.isAntiAlias());
121 126
122 fColorProcInfoValid = false; 127 fColorProcInfoValid = false;
123 fCoverageProcInfoValid = false; 128 fCoverageProcInfoValid = false;
124 129
125 fColorCache = GrColor_ILLEGAL; 130 fColorCache = GrColor_ILLEGAL;
126 fCoverageCache = GrColor_ILLEGAL; 131 fCoverageCache = GrColor_ILLEGAL;
127 132
128 fColorPrimProc = NULL; 133 fColorPrimProc = NULL;
129 fCoveragePrimProc = NULL; 134 fCoveragePrimProc = NULL;
135
136 fColorBatch = NULL;
137 fCoverageBatch = NULL;
130 } 138 }
131 139
132 //////////////////////////////////////////////////////////////////////////////// 140 ////////////////////////////////////////////////////////////////////////////////
133 141
134 bool GrDrawState::canUseFracCoveragePrimProc(GrColor color, const GrDrawTargetCa ps& caps) const { 142 bool GrDrawState::canUseFracCoveragePrimProc(GrColor color, const GrDrawTargetCa ps& caps) const {
135 if (caps.dualSourceBlendingSupport()) { 143 if (caps.dualSourceBlendingSupport()) {
136 return true; 144 return true;
137 } 145 }
138 146
139 this->calcColorInvariantOutput(color); 147 this->calcColorInvariantOutput(color);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 217
210 void GrDrawState::calcCoverageInvariantOutput(const GrPrimitiveProcessor* pp) co nst { 218 void GrDrawState::calcCoverageInvariantOutput(const GrPrimitiveProcessor* pp) co nst {
211 if (!fCoverageProcInfoValid || fCoveragePrimProc != pp) { 219 if (!fCoverageProcInfoValid || fCoveragePrimProc != pp) {
212 fCoverageProcInfo.calcCoverageWithPrimProc(pp, fCoverageStages.begin(), 220 fCoverageProcInfo.calcCoverageWithPrimProc(pp, fCoverageStages.begin(),
213 this->numCoverageStages()); 221 this->numCoverageStages());
214 fCoverageProcInfoValid = true; 222 fCoverageProcInfoValid = true;
215 fCoveragePrimProc = pp; 223 fCoveragePrimProc = pp;
216 } 224 }
217 } 225 }
218 226
227 void GrDrawState::calcColorInvariantOutput(const GrBatch* batch) const {
228 if (!fColorProcInfoValid || fColorBatch != batch) {
229 GrBatchOpt batchOpt;
230 batchOpt.fCanTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
231 fColorProcInfo.calcColorWithBatch(batch, batchOpt, fColorStages.begin(),
232 this->numColorStages());
233 fColorProcInfoValid = true;
234 fColorBatch = batch;
235 }
236 }
237
238 void GrDrawState::calcCoverageInvariantOutput(const GrBatch* batch) const {
239 if (!fCoverageProcInfoValid || fCoverageBatch != batch) {
240 GrBatchOpt batchOpt;
241 batchOpt.fCanTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
242 fCoverageProcInfo.calcCoverageWithBatch(batch, batchOpt, fCoverageStages .begin(),
243 this->numCoverageStages());
244 fCoverageProcInfoValid = true;
245 fCoverageBatch = batch;
246 }
247 }
248
249
219 void GrDrawState::calcColorInvariantOutput(GrColor color) const { 250 void GrDrawState::calcColorInvariantOutput(GrColor color) const {
220 if (!fColorProcInfoValid || color != fColorCache) { 251 if (!fColorProcInfoValid || color != fColorCache) {
221 GrColorComponentFlags flags = kRGBA_GrColorComponentFlags; 252 GrColorComponentFlags flags = kRGBA_GrColorComponentFlags;
222 fColorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColo rStages(), color, 253 fColorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColo rStages(), color,
223 flags, false); 254 flags, false);
224 fColorProcInfoValid = true; 255 fColorProcInfoValid = true;
225 fColorCache = color; 256 fColorCache = color;
226 } 257 }
227 } 258 }
228 259
229 void GrDrawState::calcCoverageInvariantOutput(GrColor coverage) const { 260 void GrDrawState::calcCoverageInvariantOutput(GrColor coverage) const {
230 if (!fCoverageProcInfoValid || coverage != fCoverageCache) { 261 if (!fCoverageProcInfoValid || coverage != fCoverageCache) {
231 GrColorComponentFlags flags = kRGBA_GrColorComponentFlags; 262 GrColorComponentFlags flags = kRGBA_GrColorComponentFlags;
232 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), 263 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(),
233 this->numCoverageStages(), cover age, flags, 264 this->numCoverageStages(), cover age, flags,
234 true); 265 true);
235 fCoverageProcInfoValid = true; 266 fCoverageProcInfoValid = true;
236 fCoverageCache = coverage; 267 fCoverageCache = coverage;
237 } 268 }
238 } 269 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698