This analyzes the processors given an op's input color and coverage as well as a clip. The state of the processor set may change to an equivalent but more optimal set of processors. This new state requires that the caller respect the returned 'inputColorOverride'. This is indicated by the returned Analysis's inputColorIsOverridden(). 'inputColorOverride' will not be written if the analysis does not override the input color.
This also puts the processors in "pending execution" state and must be called when an op that owns a processor set is recorded to ensure pending and writes are propagated to resources referred to by the processors. Otherwise, data hazards may occur.
118 {
120
123
127 bool coverageUsesLocalCoords = false;
128 if (hasCoverageFP) {
129 if (!fCoverageFragmentProcessor->compatibleWithCoverageAsAlpha()) {
130 analysis.fCompatibleWithCoverageAsAlpha = false;
131 }
132 coverageUsesLocalCoords |= fCoverageFragmentProcessor->usesSampleCoords();
133 }
134 if (
clip &&
clip->hasCoverageFragmentProcessor()) {
135 hasCoverageFP = true;
139 }
140 int colorFPsToEliminate = colorAnalysis.initialProcessorsToEliminate(overrideInputColor);
141 analysis.fInputColorType = static_cast<Analysis::PackedInputColorType>(
142 colorFPsToEliminate ? Analysis::kOverridden_InputColorType
143 : Analysis::kOriginal_InputColorType);
144
150 } else {
152 }
153
155 this->xpFactory(), colorAnalysis.outputColor(), outputCoverage, caps, clampType);
157 colorAnalysis.requiresDstTexture(caps);
158 analysis.fCompatibleWithCoverageAsAlpha &=
160 analysis.fRequiresNonOverlappingDraws =
162 analysis.fRequiresDstTexture;
163 analysis.fUsesNonCoherentHWBlending =
165 analysis.fUnaffectedByDstValue =
169 analysis.fInputColorType =
170 static_cast<Analysis::PackedInputColorType>(Analysis::kIgnored_InputColorType);
171 analysis.fUsesLocalCoords = coverageUsesLocalCoords;
172 } else {
173 analysis.fCompatibleWithCoverageAsAlpha &=
174 colorAnalysis.allProcessorsCompatibleWithCoverageAsAlpha();
175 analysis.fUsesLocalCoords = coverageUsesLocalCoords || colorAnalysis.usesLocalCoords();
176 }
177 if (colorFPsToEliminate) {
179 fColorFragmentProcessor = nullptr;
180 }
182
184 outputCoverage, caps, clampType);
185 fXP.fProcessor = xp.release();
186
187 fFlags |= kFinalized_Flag;
188 analysis.fIsInitialized = true;
189#ifdef SK_DEBUG
190 bool hasXferBarrier =
191 fXP.fProcessor &&
193 bool needsNonOverlappingDraws = analysis.fRequiresDstTexture || hasXferBarrier;
194 SkASSERT(analysis.fRequiresNonOverlappingDraws == needsNonOverlappingDraws);
195#endif
196 return analysis;
197}
GrProcessorAnalysisCoverage
@ kNone_GrXferBarrierType
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
static constexpr bool SkToBool(const T &x)
bool usesSampleCoords() const
bool compatibleWithCoverageAsAlpha() const
bool hasCoverageFragmentProcessor() const
bool hasColorFragmentProcessor() const
@ kCompatibleWithCoverageAsAlpha
@ kUsesNonCoherentHWBlending
@ kRequiresNonOverlappingDraws
static sk_sp< const GrXferProcessor > MakeXferProcessor(const GrXPFactory *, const GrProcessorAnalysisColor &, GrProcessorAnalysisCoverage, const GrCaps &caps, GrClampType)
static AnalysisProperties GetAnalysisProperties(const GrXPFactory *, const GrProcessorAnalysisColor &, const GrProcessorAnalysisCoverage &, const GrCaps &, GrClampType)