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

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

Issue 858343002: Rename GrOptDrawState to GrPipeline and GrDrawState to GrPipelineBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more nits 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
« no previous file with comments | « src/gpu/GrPipeline.h ('k') | src/gpu/GrPipelineBuilder.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 * Copyright 2014 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 "GrOptDrawState.h" 8 #include "GrPipeline.h"
9 9
10 #include "GrDrawState.h"
11 #include "GrDrawTargetCaps.h" 10 #include "GrDrawTargetCaps.h"
12 #include "GrGpu.h" 11 #include "GrGpu.h"
12 #include "GrPipelineBuilder.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 GrPipeline::GrPipeline(const GrPipelineBuilder& pipelineBuilder,
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 const GrProcOptInfo& colorPOI = drawState.colorProcInfo(primProc); 21 const GrProcOptInfo& colorPOI = pipelineBuilder.colorProcInfo(primProc);
22 const GrProcOptInfo& coveragePOI = drawState.coverageProcInfo(primProc); 22 const GrProcOptInfo& coveragePOI = pipelineBuilder.coverageProcInfo(primProc );
23 23
24 // Create XferProcessor from DS's XPFactory 24 // Create XferProcessor from DS's XPFactory
25 SkAutoTUnref<GrXferProcessor> xferProcessor( 25 SkAutoTUnref<GrXferProcessor> xferProcessor(
26 drawState.getXPFactory()->createXferProcessor(colorPOI, coveragePOI)); 26 pipelineBuilder.getXPFactory()->createXferProcessor(colorPOI, coveragePO I));
27 27
28 GrColor overrideColor = GrColor_ILLEGAL; 28 GrColor overrideColor = GrColor_ILLEGAL;
29 if (colorPOI.firstEffectiveStageIndex() != 0) { 29 if (colorPOI.firstEffectiveStageIndex() != 0) {
30 overrideColor = colorPOI.inputColorToEffectiveStage(); 30 overrideColor = colorPOI.inputColorToEffectiveStage();
31 } 31 }
32 32
33 GrXferProcessor::OptFlags optFlags; 33 GrXferProcessor::OptFlags optFlags;
34 if (xferProcessor) { 34 if (xferProcessor) {
35 fXferProcessor.reset(xferProcessor.get()); 35 fXferProcessor.reset(xferProcessor.get());
36 36
37 optFlags = xferProcessor->getOptimizations(colorPOI, 37 optFlags = xferProcessor->getOptimizations(colorPOI,
38 coveragePOI, 38 coveragePOI,
39 drawState.getStencil().doesWr ite(), 39 pipelineBuilder.getStencil(). doesWrite(),
40 &overrideColor, 40 &overrideColor,
41 caps); 41 caps);
42 } 42 }
43 43
44 // When path rendering the stencil settings are not always set on the draw s tate 44 // When path rendering the stencil settings are not always set on the GrPipe lineBuilder
45 // so we must check the draw type. In cases where we will skip drawing we si mply return a 45 // so we must check the draw type. In cases where we will skip drawing we si mply return a
46 // null GrOptDrawState. 46 // null GrPipeline.
47 if (!xferProcessor || (GrXferProcessor::kSkipDraw_OptFlag & optFlags)) { 47 if (!xferProcessor || (GrXferProcessor::kSkipDraw_OptFlag & optFlags)) {
48 // Set the fields that don't default init and return. The lack of a rend er target will 48 // Set the fields that don't default init and return. The lack of a rend er target will
49 // indicate that this can be skipped. 49 // indicate that this can be skipped.
50 fFlags = 0; 50 fFlags = 0;
51 fDrawFace = GrDrawState::kInvalid_DrawFace; 51 fDrawFace = GrPipelineBuilder::kInvalid_DrawFace;
52 return; 52 return;
53 } 53 }
54 54
55 fRenderTarget.reset(drawState.fRenderTarget.get()); 55 fRenderTarget.reset(pipelineBuilder.fRenderTarget.get());
56 SkASSERT(fRenderTarget); 56 SkASSERT(fRenderTarget);
57 fScissorState = scissorState; 57 fScissorState = scissorState;
58 fStencilSettings = drawState.getStencil(); 58 fStencilSettings = pipelineBuilder.getStencil();
59 fDrawFace = drawState.getDrawFace(); 59 fDrawFace = pipelineBuilder.getDrawFace();
60 // TODO move this out of optDrawState 60 // TODO move this out of GrPipeline
61 if (dstCopy) { 61 if (dstCopy) {
62 fDstCopy = *dstCopy; 62 fDstCopy = *dstCopy;
63 } 63 }
64 64
65 fFlags = 0; 65 fFlags = 0;
66 if (drawState.isHWAntialias()) { 66 if (pipelineBuilder.isHWAntialias()) {
67 fFlags |= kHWAA_Flag; 67 fFlags |= kHWAA_Flag;
68 } 68 }
69 if (drawState.isDither()) { 69 if (pipelineBuilder.isDither()) {
70 fFlags |= kDither_Flag; 70 fFlags |= kDither_Flag;
71 } 71 }
72 72
73 int firstColorStageIdx = colorPOI.firstEffectiveStageIndex(); 73 int firstColorStageIdx = colorPOI.firstEffectiveStageIndex();
74 74
75 // TODO: Once we can handle single or four channel input into coverage stage s then we can use 75 // TODO: Once we can handle single or four channel input into coverage stage s then we can use
76 // drawState's coverageProcInfo (like color above) to set this initial infor mation. 76 // GrPipelineBuilder's coverageProcInfo (like color above) to set this initi al information.
77 int firstCoverageStageIdx = 0; 77 int firstCoverageStageIdx = 0;
78 78
79 GrXferProcessor::BlendInfo blendInfo; 79 GrXferProcessor::BlendInfo blendInfo;
80 fXferProcessor->getBlendInfo(&blendInfo); 80 fXferProcessor->getBlendInfo(&blendInfo);
81 81
82 this->adjustProgramFromOptimizations(drawState, optFlags, colorPOI, coverage POI, 82 this->adjustProgramFromOptimizations(pipelineBuilder, optFlags, colorPOI, co veragePOI,
83 &firstColorStageIdx, &firstCoverageStag eIdx); 83 &firstColorStageIdx, &firstCoverageStag eIdx);
84 84
85 fDescInfo.fReadsDst = fXferProcessor->willReadDstColor(); 85 fDescInfo.fReadsDst = fXferProcessor->willReadDstColor();
86 86
87 bool usesLocalCoords = false; 87 bool usesLocalCoords = false;
88 88
89 // Copy Stages from DS to ODS 89 // Copy Stages from PipelineBuilder to Pipeline
90 for (int i = firstColorStageIdx; i < drawState.numColorStages(); ++i) { 90 for (int i = firstColorStageIdx; i < pipelineBuilder.numColorStages(); ++i) {
91 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, 91 SkNEW_APPEND_TO_TARRAY(&fFragmentStages,
92 GrPendingFragmentStage, 92 GrPendingFragmentStage,
93 (drawState.fColorStages[i])); 93 (pipelineBuilder.fColorStages[i]));
94 usesLocalCoords = usesLocalCoords || 94 usesLocalCoords = usesLocalCoords ||
95 drawState.fColorStages[i].processor()->usesLocalCoords (); 95 pipelineBuilder.fColorStages[i].processor()->usesLocal Coords();
96 } 96 }
97 97
98 fNumColorStages = fFragmentStages.count(); 98 fNumColorStages = fFragmentStages.count();
99 for (int i = firstCoverageStageIdx; i < drawState.numCoverageStages(); ++i) { 99 for (int i = firstCoverageStageIdx; i < pipelineBuilder.numCoverageStages(); ++i) {
100 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, 100 SkNEW_APPEND_TO_TARRAY(&fFragmentStages,
101 GrPendingFragmentStage, 101 GrPendingFragmentStage,
102 (drawState.fCoverageStages[i])); 102 (pipelineBuilder.fCoverageStages[i]));
103 usesLocalCoords = usesLocalCoords || 103 usesLocalCoords = usesLocalCoords ||
104 drawState.fCoverageStages[i].processor()->usesLocalCoo rds(); 104 pipelineBuilder.fCoverageStages[i].processor()->usesLo calCoords();
105 } 105 }
106 106
107 // let the GP init the batch tracker 107 // let the GP init the batch tracker
108 fInitBT.fColorIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreColor_Op tFlag); 108 fInitBT.fColorIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreColor_Op tFlag);
109 fInitBT.fOverrideColor = fInitBT.fColorIgnored ? GrColor_ILLEGAL : overrideC olor; 109 fInitBT.fOverrideColor = fInitBT.fColorIgnored ? GrColor_ILLEGAL : overrideC olor;
110 fInitBT.fCoverageIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreCover age_OptFlag); 110 fInitBT.fCoverageIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreCover age_OptFlag);
111 fInitBT.fUsesLocalCoords = usesLocalCoords; 111 fInitBT.fUsesLocalCoords = usesLocalCoords;
112 } 112 }
113 113
114 void GrOptDrawState::adjustProgramFromOptimizations(const GrDrawState& ds, 114 void GrPipeline::adjustProgramFromOptimizations(const GrPipelineBuilder& pipelin eBuilder,
115 GrXferProcessor::OptFlags fl ags, 115 GrXferProcessor::OptFlags flags,
116 const GrProcOptInfo& colorPO I, 116 const GrProcOptInfo& colorPOI,
117 const GrProcOptInfo& coverag ePOI, 117 const GrProcOptInfo& coveragePOI ,
118 int* firstColorStageIdx, 118 int* firstColorStageIdx,
119 int* firstCoverageStageIdx) { 119 int* firstCoverageStageIdx) {
120 fDescInfo.fReadsFragPosition = false; 120 fDescInfo.fReadsFragPosition = false;
121 121
122 if ((flags & GrXferProcessor::kIgnoreColor_OptFlag) || 122 if ((flags & GrXferProcessor::kIgnoreColor_OptFlag) ||
123 (flags & GrXferProcessor::kOverrideColor_OptFlag)) { 123 (flags & GrXferProcessor::kOverrideColor_OptFlag)) {
124 *firstColorStageIdx = ds.numColorStages(); 124 *firstColorStageIdx = pipelineBuilder.numColorStages();
125 } else { 125 } else {
126 fDescInfo.fReadsFragPosition = colorPOI.readsFragPosition(); 126 fDescInfo.fReadsFragPosition = colorPOI.readsFragPosition();
127 } 127 }
128 128
129 if (flags & GrXferProcessor::kIgnoreCoverage_OptFlag) { 129 if (flags & GrXferProcessor::kIgnoreCoverage_OptFlag) {
130 *firstCoverageStageIdx = ds.numCoverageStages(); 130 *firstCoverageStageIdx = pipelineBuilder.numCoverageStages();
131 } else { 131 } else {
132 if (coveragePOI.readsFragPosition()) { 132 if (coveragePOI.readsFragPosition()) {
133 fDescInfo.fReadsFragPosition = true; 133 fDescInfo.fReadsFragPosition = true;
134 } 134 }
135 } 135 }
136 } 136 }
137 137
138 //////////////////////////////////////////////////////////////////////////////// 138 ////////////////////////////////////////////////////////////////////////////////
139 139
140 bool GrOptDrawState::isEqual(const GrOptDrawState& that) const { 140 bool GrPipeline::isEqual(const GrPipeline& that) const {
141 if (this->getRenderTarget() != that.getRenderTarget() || 141 if (this->getRenderTarget() != that.getRenderTarget() ||
142 this->fFragmentStages.count() != that.fFragmentStages.count() || 142 this->fFragmentStages.count() != that.fFragmentStages.count() ||
143 this->fNumColorStages != that.fNumColorStages || 143 this->fNumColorStages != that.fNumColorStages ||
144 this->fScissorState != that.fScissorState || 144 this->fScissorState != that.fScissorState ||
145 this->fFlags != that.fFlags || 145 this->fFlags != that.fFlags ||
146 this->fStencilSettings != that.fStencilSettings || 146 this->fStencilSettings != that.fStencilSettings ||
147 this->fDrawFace != that.fDrawFace || 147 this->fDrawFace != that.fDrawFace ||
148 this->fDstCopy.texture() != that.fDstCopy.texture()) { 148 this->fDstCopy.texture() != that.fDstCopy.texture()) {
149 return false; 149 return false;
150 } 150 }
151 151
152 if (!this->getXferProcessor()->isEqual(*that.getXferProcessor())) { 152 if (!this->getXferProcessor()->isEqual(*that.getXferProcessor())) {
153 return false; 153 return false;
154 } 154 }
155 155
156 // The program desc comparison should have already assured that the stage co unts match. 156 // The program desc comparison should have already assured that the stage co unts match.
157 SkASSERT(this->numFragmentStages() == that.numFragmentStages()); 157 SkASSERT(this->numFragmentStages() == that.numFragmentStages());
158 for (int i = 0; i < this->numFragmentStages(); i++) { 158 for (int i = 0; i < this->numFragmentStages(); i++) {
159 159
160 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { 160 if (this->getFragmentStage(i) != that.getFragmentStage(i)) {
161 return false; 161 return false;
162 } 162 }
163 } 163 }
164 return true; 164 return true;
165 } 165 }
166 166
OLDNEW
« no previous file with comments | « src/gpu/GrPipeline.h ('k') | src/gpu/GrPipelineBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698