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 "GrPipeline.h" | 8 #include "GrPipeline.h" |
9 | 9 |
10 #include "GrCaps.h" | 10 #include "GrCaps.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // Create XferProcessor from DS's XPFactory | 23 // Create XferProcessor from DS's XPFactory |
24 SkAutoTUnref<GrXferProcessor> xferProcessor( | 24 SkAutoTUnref<GrXferProcessor> xferProcessor( |
25 pipelineBuilder.getXPFactory()->createXferProcessor( | 25 pipelineBuilder.getXPFactory()->createXferProcessor( |
26 colorPOI, coveragePOI, pipelineBuilder.hasMixedSamples(), dstTexture
, caps)); | 26 colorPOI, coveragePOI, pipelineBuilder.hasMixedSamples(), dstTexture
, caps)); |
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 = GrXferProcessor::kNone_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 pipelineBuilder.getStencil().
doesWrite(), | 39 pipelineBuilder.getStencil().
doesWrite(), |
40 &overrideColor, | 40 &overrideColor, |
41 caps); | 41 caps); |
42 } | 42 } |
43 | 43 |
44 // No need to have an override color if it isn't even going to be used. | |
45 if (SkToBool(GrXferProcessor::kIgnoreColor_OptFlag)) { | |
46 overrideColor = GrColor_ILLEGAL; | |
47 } | |
48 | |
49 // When path rendering the stencil settings are not always set on the GrPipe
lineBuilder | 44 // When path rendering the stencil settings are not always set on the GrPipe
lineBuilder |
50 // 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 |
51 // null GrPipeline. | 46 // null GrPipeline. |
52 if (!xferProcessor || (GrXferProcessor::kSkipDraw_OptFlag & optFlags)) { | 47 if (!xferProcessor || (GrXferProcessor::kSkipDraw_OptFlag & optFlags)) { |
53 // 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 |
54 // indicate that this can be skipped. | 49 // indicate that this can be skipped. |
55 fFlags = 0; | 50 fFlags = 0; |
56 fDrawFace = GrPipelineBuilder::kInvalid_DrawFace; | 51 fDrawFace = GrPipelineBuilder::kInvalid_DrawFace; |
57 return; | 52 return; |
58 } | 53 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 91 |
97 fNumColorStages = fFragmentStages.count(); | 92 fNumColorStages = fFragmentStages.count(); |
98 for (int i = firstCoverageStageIdx; i < pipelineBuilder.numCoverageFragmentS
tages(); ++i) { | 93 for (int i = firstCoverageStageIdx; i < pipelineBuilder.numCoverageFragmentS
tages(); ++i) { |
99 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, | 94 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, |
100 GrPendingFragmentStage, | 95 GrPendingFragmentStage, |
101 (pipelineBuilder.fCoverageStages[i])); | 96 (pipelineBuilder.fCoverageStages[i])); |
102 usesLocalCoords = usesLocalCoords || | 97 usesLocalCoords = usesLocalCoords || |
103 pipelineBuilder.fCoverageStages[i].processor()->usesLo
calCoords(); | 98 pipelineBuilder.fCoverageStages[i].processor()->usesLo
calCoords(); |
104 } | 99 } |
105 | 100 |
106 // Setup info we need to pass to GrPrimitiveProcessors that are used with th
is GrPipeline. | 101 // let the GP init the batch tracker |
107 fInfoForPrimitiveProcessor.fFlags = 0; | 102 fInitBT.fColorIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreColor_Op
tFlag); |
108 if (!SkToBool(optFlags & GrXferProcessor::kIgnoreColor_OptFlag)) { | 103 fInitBT.fOverrideColor = fInitBT.fColorIgnored ? GrColor_ILLEGAL : overrideC
olor; |
109 fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kReadsColor_GrPipel
ineInfoFlag; | 104 fInitBT.fCoverageIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreCover
age_OptFlag); |
110 } | 105 fInitBT.fUsesLocalCoords = usesLocalCoords; |
111 if (GrColor_ILLEGAL != overrideColor) { | 106 fInitBT.fCanTweakAlphaForCoverage = |
112 fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kUseOverrideColor_G
rPipelineInfoFlag; | 107 SkToBool(optFlags & GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag); |
113 fInfoForPrimitiveProcessor.fOverrideColor = overrideColor; | |
114 } | |
115 if (!SkToBool(optFlags & GrXferProcessor::kIgnoreCoverage_OptFlag)) { | |
116 fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kReadsCoverage_GrPi
pelineInfoFlag; | |
117 } | |
118 if (usesLocalCoords) { | |
119 fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kReadsLocalCoords_G
rPipelineInfoFlag; | |
120 } | |
121 if (SkToBool(optFlags & GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag))
{ | |
122 fInfoForPrimitiveProcessor.fFlags |= | |
123 GrPipelineInfo::kCanTweakAlphaForCoverage_GrPipelineInfoFlag; | |
124 } | |
125 } | 108 } |
126 | 109 |
127 void GrPipeline::adjustProgramFromOptimizations(const GrPipelineBuilder& pipelin
eBuilder, | 110 void GrPipeline::adjustProgramFromOptimizations(const GrPipelineBuilder& pipelin
eBuilder, |
128 GrXferProcessor::OptFlags flags, | 111 GrXferProcessor::OptFlags flags, |
129 const GrProcOptInfo& colorPOI, | 112 const GrProcOptInfo& colorPOI, |
130 const GrProcOptInfo& coveragePOI
, | 113 const GrProcOptInfo& coveragePOI
, |
131 int* firstColorStageIdx, | 114 int* firstColorStageIdx, |
132 int* firstCoverageStageIdx) { | 115 int* firstCoverageStageIdx) { |
133 fReadsFragPosition = fXferProcessor->willReadFragmentPosition(); | 116 fReadsFragPosition = fXferProcessor->willReadFragmentPosition(); |
134 | 117 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 SkASSERT(this->numFragmentStages() == that.numFragmentStages()); | 154 SkASSERT(this->numFragmentStages() == that.numFragmentStages()); |
172 for (int i = 0; i < this->numFragmentStages(); i++) { | 155 for (int i = 0; i < this->numFragmentStages(); i++) { |
173 | 156 |
174 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { | 157 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { |
175 return false; | 158 return false; |
176 } | 159 } |
177 } | 160 } |
178 return true; | 161 return true; |
179 } | 162 } |
180 | 163 |
OLD | NEW |