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; | 33 GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_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 & optFlags)) { |
| 46 overrideColor = GrColor_ILLEGAL; |
| 47 } |
| 48 |
44 // When path rendering the stencil settings are not always set on the GrPipe
lineBuilder | 49 // 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 | 50 // so we must check the draw type. In cases where we will skip drawing we si
mply return a |
46 // null GrPipeline. | 51 // null GrPipeline. |
47 if (!xferProcessor || (GrXferProcessor::kSkipDraw_OptFlag & optFlags)) { | 52 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 | 53 // 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. | 54 // indicate that this can be skipped. |
50 fFlags = 0; | 55 fFlags = 0; |
51 fDrawFace = GrPipelineBuilder::kInvalid_DrawFace; | 56 fDrawFace = GrPipelineBuilder::kInvalid_DrawFace; |
52 return; | 57 return; |
53 } | 58 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 96 |
92 fNumColorStages = fFragmentStages.count(); | 97 fNumColorStages = fFragmentStages.count(); |
93 for (int i = firstCoverageStageIdx; i < pipelineBuilder.numCoverageFragmentS
tages(); ++i) { | 98 for (int i = firstCoverageStageIdx; i < pipelineBuilder.numCoverageFragmentS
tages(); ++i) { |
94 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, | 99 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, |
95 GrPendingFragmentStage, | 100 GrPendingFragmentStage, |
96 (pipelineBuilder.fCoverageStages[i])); | 101 (pipelineBuilder.fCoverageStages[i])); |
97 usesLocalCoords = usesLocalCoords || | 102 usesLocalCoords = usesLocalCoords || |
98 pipelineBuilder.fCoverageStages[i].processor()->usesLo
calCoords(); | 103 pipelineBuilder.fCoverageStages[i].processor()->usesLo
calCoords(); |
99 } | 104 } |
100 | 105 |
101 // let the GP init the batch tracker | 106 // Setup info we need to pass to GrPrimitiveProcessors that are used with th
is GrPipeline. |
102 fInitBT.fColorIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreColor_Op
tFlag); | 107 fInfoForPrimitiveProcessor.fFlags = 0; |
103 fInitBT.fOverrideColor = fInitBT.fColorIgnored ? GrColor_ILLEGAL : overrideC
olor; | 108 if (!SkToBool(optFlags & GrXferProcessor::kIgnoreColor_OptFlag)) { |
104 fInitBT.fCoverageIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreCover
age_OptFlag); | 109 fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kReadsColor_GrPipel
ineInfoFlag; |
105 fInitBT.fUsesLocalCoords = usesLocalCoords; | 110 } |
106 fInitBT.fCanTweakAlphaForCoverage = | 111 if (GrColor_ILLEGAL != overrideColor) { |
107 SkToBool(optFlags & GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag); | 112 fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kUseOverrideColor_G
rPipelineInfoFlag; |
| 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 } |
108 } | 125 } |
109 | 126 |
110 void GrPipeline::adjustProgramFromOptimizations(const GrPipelineBuilder& pipelin
eBuilder, | 127 void GrPipeline::adjustProgramFromOptimizations(const GrPipelineBuilder& pipelin
eBuilder, |
111 GrXferProcessor::OptFlags flags, | 128 GrXferProcessor::OptFlags flags, |
112 const GrProcOptInfo& colorPOI, | 129 const GrProcOptInfo& colorPOI, |
113 const GrProcOptInfo& coveragePOI
, | 130 const GrProcOptInfo& coveragePOI
, |
114 int* firstColorStageIdx, | 131 int* firstColorStageIdx, |
115 int* firstCoverageStageIdx) { | 132 int* firstCoverageStageIdx) { |
116 fReadsFragPosition = fXferProcessor->willReadFragmentPosition(); | 133 fReadsFragPosition = fXferProcessor->willReadFragmentPosition(); |
117 | 134 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 SkASSERT(this->numFragmentStages() == that.numFragmentStages()); | 171 SkASSERT(this->numFragmentStages() == that.numFragmentStages()); |
155 for (int i = 0; i < this->numFragmentStages(); i++) { | 172 for (int i = 0; i < this->numFragmentStages(); i++) { |
156 | 173 |
157 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { | 174 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { |
158 return false; | 175 return false; |
159 } | 176 } |
160 } | 177 } |
161 return true; | 178 return true; |
162 } | 179 } |
163 | 180 |
OLD | NEW |