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

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

Issue 815643005: Move program descriptor and primitive processor off of optstate (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: small cleanup 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 2014 Google Inc. 2 * Copyright 2014 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 "GrOptDrawState.h" 8 #include "GrOptDrawState.h"
9 9
10 #include "GrDrawState.h" 10 #include "GrDrawState.h"
11 #include "GrDrawTargetCaps.h" 11 #include "GrDrawTargetCaps.h"
12 #include "GrGpu.h" 12 #include "GrGpu.h"
13 #include "GrProcOptInfo.h" 13 #include "GrProcOptInfo.h"
14 #include "GrXferProcessor.h" 14 #include "GrXferProcessor.h"
15 15
16 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, 16 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
17 const GrPrimitiveProcessor* primProc, 17 const GrPrimitiveProcessor* primProc,
18 const GrDrawTargetCaps& caps, 18 const GrDrawTargetCaps& caps,
19 const GrScissorState& scissorState, 19 const GrScissorState& scissorState,
20 const GrDeviceCoordTexture* dstCopy, 20 const GrDeviceCoordTexture* dstCopy,
21 GrGpu::DrawType drawType) 21 GrGpu::DrawType drawType) {
22 : fFinalized(false) {
23 fDrawType = drawType; 22 fDrawType = drawType;
24 23
25 fPrimitiveProcessor.reset(primProc); 24 const GrProcOptInfo& colorPOI = drawState.colorProcInfo(primProc);
26 25 const GrProcOptInfo& coveragePOI = drawState.coverageProcInfo(primProc);
27
28 const GrProcOptInfo& colorPOI = drawState.colorProcInfo(fPrimitiveProcessor) ;
29 const GrProcOptInfo& coveragePOI = drawState.coverageProcInfo(fPrimitiveProc essor);
30 26
31 // Create XferProcessor from DS's XPFactory 27 // Create XferProcessor from DS's XPFactory
32 SkAutoTUnref<GrXferProcessor> xferProcessor( 28 SkAutoTUnref<GrXferProcessor> xferProcessor(
33 drawState.getXPFactory()->createXferProcessor(colorPOI, coveragePOI)); 29 drawState.getXPFactory()->createXferProcessor(colorPOI, coveragePOI));
34 30
35 GrColor overrideColor = GrColor_ILLEGAL; 31 GrColor overrideColor = GrColor_ILLEGAL;
36 if (colorPOI.firstEffectiveStageIndex() != 0) { 32 if (colorPOI.firstEffectiveStageIndex() != 0) {
37 overrideColor = colorPOI.inputColorToEffectiveStage(); 33 overrideColor = colorPOI.inputColorToEffectiveStage();
38 } 34 }
39 35
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 fNumColorStages = fFragmentStages.count(); 99 fNumColorStages = fFragmentStages.count();
104 for (int i = firstCoverageStageIdx; i < drawState.numCoverageStages(); ++i) { 100 for (int i = firstCoverageStageIdx; i < drawState.numCoverageStages(); ++i) {
105 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, 101 SkNEW_APPEND_TO_TARRAY(&fFragmentStages,
106 GrPendingFragmentStage, 102 GrPendingFragmentStage,
107 (drawState.fCoverageStages[i])); 103 (drawState.fCoverageStages[i]));
108 usesLocalCoords = usesLocalCoords || 104 usesLocalCoords = usesLocalCoords ||
109 drawState.fCoverageStages[i].processor()->usesLocalCoo rds(); 105 drawState.fCoverageStages[i].processor()->usesLocalCoo rds();
110 } 106 }
111 107
112 // let the GP init the batch tracker 108 // let the GP init the batch tracker
113 GrGeometryProcessor::InitBT init; 109 fInitBT.fColorIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreColor_Op tFlag);
114 init.fColorIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreColor_OptFl ag); 110 fInitBT.fOverrideColor = fInitBT.fColorIgnored ? GrColor_ILLEGAL : overrideC olor;
115 init.fOverrideColor = init.fColorIgnored ? GrColor_ILLEGAL : overrideColor; 111 fInitBT.fCoverageIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreCover age_OptFlag);
116 init.fCoverageIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreCoverage _OptFlag); 112 fInitBT.fUsesLocalCoords = usesLocalCoords;
117 init.fUsesLocalCoords = usesLocalCoords;
118 fPrimitiveProcessor->initBatchTracker(&fBatchTracker, init);
119 } 113 }
120 114
121 void GrOptDrawState::adjustProgramFromOptimizations(const GrDrawState& ds, 115 void GrOptDrawState::adjustProgramFromOptimizations(const GrDrawState& ds,
122 GrXferProcessor::OptFlags fl ags, 116 GrXferProcessor::OptFlags fl ags,
123 const GrProcOptInfo& colorPO I, 117 const GrProcOptInfo& colorPO I,
124 const GrProcOptInfo& coverag ePOI, 118 const GrProcOptInfo& coverag ePOI,
125 int* firstColorStageIdx, 119 int* firstColorStageIdx,
126 int* firstCoverageStageIdx) { 120 int* firstCoverageStageIdx) {
127 fDescInfo.fReadsDst = false; 121 fDescInfo.fReadsDst = false;
128 fDescInfo.fReadsFragPosition = false; 122 fDescInfo.fReadsFragPosition = false;
(...skipping 15 matching lines...) Expand all
144 if (coveragePOI.readsFragPosition()) { 138 if (coveragePOI.readsFragPosition()) {
145 fDescInfo.fReadsFragPosition = true; 139 fDescInfo.fReadsFragPosition = true;
146 } 140 }
147 } 141 }
148 142
149 if (fXferProcessor->willReadDstColor()) { 143 if (fXferProcessor->willReadDstColor()) {
150 fDescInfo.fReadsDst = true; 144 fDescInfo.fReadsDst = true;
151 } 145 }
152 } 146 }
153 147
154 void GrOptDrawState::finalize(GrGpu* gpu) {
155 gpu->buildProgramDesc(*this, fDescInfo, fDrawType, &fDesc);
156 fFinalized = true;
157 }
158
159 //////////////////////////////////////////////////////////////////////////////// 148 ////////////////////////////////////////////////////////////////////////////////
160 149
161 bool GrOptDrawState::combineIfPossible(const GrOptDrawState& that) { 150 bool GrOptDrawState::isEqual(const GrOptDrawState& that) const {
162 if (fDescInfo != that.fDescInfo) {
163 return false;
164 }
165
166 if (this->getRenderTarget() != that.getRenderTarget() || 151 if (this->getRenderTarget() != that.getRenderTarget() ||
167 this->fFragmentStages.count() != that.fFragmentStages.count() || 152 this->fFragmentStages.count() != that.fFragmentStages.count() ||
168 this->fNumColorStages != that.fNumColorStages || 153 this->fNumColorStages != that.fNumColorStages ||
169 this->fScissorState != that.fScissorState || 154 this->fScissorState != that.fScissorState ||
170 this->fDrawType != that.fDrawType || 155 this->fDrawType != that.fDrawType ||
171 this->fFlags != that.fFlags || 156 this->fFlags != that.fFlags ||
172 this->fStencilSettings != that.fStencilSettings || 157 this->fStencilSettings != that.fStencilSettings ||
173 this->fDrawFace != that.fDrawFace || 158 this->fDrawFace != that.fDrawFace ||
174 this->fDstCopy.texture() != that.fDstCopy.texture()) { 159 this->fDstCopy.texture() != that.fDstCopy.texture()) {
175 return false; 160 return false;
176 } 161 }
177 162
178 if (!this->getPrimitiveProcessor()->canMakeEqual(fBatchTracker,
179 *that.getPrimitiveProcessor (),
180 that.getBatchTracker())) {
181 return false;
182 }
183
184 if (!this->getXferProcessor()->isEqual(*that.getXferProcessor())) { 163 if (!this->getXferProcessor()->isEqual(*that.getXferProcessor())) {
185 return false; 164 return false;
186 } 165 }
187 166
188 // The program desc comparison should have already assured that the stage co unts match. 167 // The program desc comparison should have already assured that the stage co unts match.
189 SkASSERT(this->numFragmentStages() == that.numFragmentStages()); 168 SkASSERT(this->numFragmentStages() == that.numFragmentStages());
190 for (int i = 0; i < this->numFragmentStages(); i++) { 169 for (int i = 0; i < this->numFragmentStages(); i++) {
191 170
192 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { 171 if (this->getFragmentStage(i) != that.getFragmentStage(i)) {
193 return false; 172 return false;
194 } 173 }
195 } 174 }
196
197 // Now update the GrPrimitiveProcessor's batch tracker
198 fPrimitiveProcessor->makeEqual(&fBatchTracker, that.getBatchTracker());
199 return true; 175 return true;
200 } 176 }
201 177
OLDNEW
« src/gpu/GrGpu.h ('K') | « src/gpu/GrOptDrawState.h ('k') | src/gpu/GrTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698