GrProcessorSet.cpp revision 5f970fe6bed7a40ba95365bfe3220f18699a9176
1bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon/* 2bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon * Copyright 2017 Google Inc. 3bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon * 4bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon * Use of this source code is governed by a BSD-style license that can be 5bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon * found in the LICENSE file. 6bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon */ 7bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 8bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon#include "GrProcessorSet.h" 9bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon#include "GrAppliedClip.h" 10bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon#include "GrCaps.h" 11bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon#include "GrXferProcessor.h" 12bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon#include "effects/GrPorterDuffXferProcessor.h" 13bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 14bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomonconst GrProcessorSet& GrProcessorSet::EmptySet() { 15bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon static const GrProcessorSet gEmpty(GrProcessorSet::Empty::kEmpty); 16bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon return gEmpty; 17bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon} 1807792b218e1cf31c42611276d597fcc99677d391Brian Osman 1907792b218e1cf31c42611276d597fcc99677d391Brian OsmanGrProcessorSet::GrProcessorSet(GrPaint&& paint) : fXP(paint.getXPFactory()) { 20bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon fFlags = 0; 21bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (paint.numColorFragmentProcessors() <= kMaxColorProcessors) { 22bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon fColorFragmentProcessorCnt = paint.numColorFragmentProcessors(); 23bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon fFragmentProcessors.reset(paint.numTotalFragmentProcessors()); 24bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon int i = 0; 2507792b218e1cf31c42611276d597fcc99677d391Brian Osman for (auto& fp : paint.fColorFragmentProcessors) { 2607792b218e1cf31c42611276d597fcc99677d391Brian Osman SkASSERT(fp.get()); 27bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon fFragmentProcessors[i++] = fp.release(); 28bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 29bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon for (auto& fp : paint.fCoverageFragmentProcessors) { 30bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon SkASSERT(fp.get()); 31bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon fFragmentProcessors[i++] = fp.release(); 32bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 33bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } else { 34bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon SkDebugf("Insane number of color fragment processors in paint. Dropping all processors."); 35bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon fColorFragmentProcessorCnt = 0; 36bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 37bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon} 38bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 39bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian SalomonGrProcessorSet::~GrProcessorSet() { 40bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon for (int i = fFragmentProcessorOffset; i < fFragmentProcessors.count(); ++i) { 41bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (this->isFinalized()) { 42bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon fFragmentProcessors[i]->completedExecution(); 43bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } else { 44bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon fFragmentProcessors[i]->unref(); 45bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 46bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 47bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (this->isFinalized() && this->xferProcessor()) { 48bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon this->xferProcessor()->unref(); 49bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 50bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon} 51bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 52bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian SalomonSkString dump_fragment_processor_tree(const GrFragmentProcessor* fp, int indentCnt) { 53bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon SkString result; 54bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon SkString indentString; 55bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon for (int i = 0; i < indentCnt; ++i) { 56bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon indentString.append(" "); 57bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 58bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon result.appendf("%s%s %s \n", indentString.c_str(), fp->name(), fp->dumpInfo().c_str()); 59bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (fp->numChildProcessors()) { 60bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon for (int i = 0; i < fp->numChildProcessors(); ++i) { 61bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon result += dump_fragment_processor_tree(&fp->childProcessor(i), indentCnt + 1); 62bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 63bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 64bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon return result; 65bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon} 66bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 67bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian SalomonSkString GrProcessorSet::dumpProcessors() const { 68bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon SkString result; 69bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (this->numFragmentProcessors()) { 70bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (this->numColorFragmentProcessors()) { 71bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon result.append("Color Fragment Processors:\n"); 72bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon for (int i = 0; i < this->numColorFragmentProcessors(); ++i) { 73bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon result += dump_fragment_processor_tree(this->colorFragmentProcessor(i), 1); 74bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 75bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } else { 76bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon result.append("No color fragment processors.\n"); 77bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 78bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (this->numCoverageFragmentProcessors()) { 79bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon result.append("Coverage Fragment Processors:\n"); 80bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon for (int i = 0; i < this->numColorFragmentProcessors(); ++i) { 81bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon result += dump_fragment_processor_tree(this->coverageFragmentProcessor(i), 1); 82bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 83bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } else { 84bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon result.append("No coverage fragment processors.\n"); 85bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 86bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } else { 87bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon result.append("No color or coverage fragment processors.\n"); 88bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 89bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (this->isFinalized()) { 9007792b218e1cf31c42611276d597fcc99677d391Brian Osman result.append("Xfer Processor: "); 91bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (this->xferProcessor()) { 92bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon result.appendf("%s\n", this->xferProcessor()->name()); 93bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } else { 94bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon result.append("SrcOver\n"); 95bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 96bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } else { 97bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon result.append("XP Factory dumping not implemented.\n"); 98bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 99e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips return result; 100e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips} 101e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips 102e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillipsbool GrProcessorSet::operator==(const GrProcessorSet& that) const { 103e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips SkASSERT(this->isFinalized()); 104e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips SkASSERT(that.isFinalized()); 105e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips int fpCount = this->numFragmentProcessors(); 106e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips if (((fFlags ^ that.fFlags) & ~kFinalized_Flag) || fpCount != that.numFragmentProcessors() || 107e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips fColorFragmentProcessorCnt != that.fColorFragmentProcessorCnt) { 108e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips return false; 109e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips } 110e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips 111e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips for (int i = 0; i < fpCount; ++i) { 112e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips int a = i + fFragmentProcessorOffset; 113e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips int b = i + that.fFragmentProcessorOffset; 114e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips if (!fFragmentProcessors[a]->isEqual(*that.fFragmentProcessors[b])) { 115e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips return false; 116e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips } 117e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips } 11807792b218e1cf31c42611276d597fcc99677d391Brian Osman // Most of the time both of these are null 119e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips if (!this->xferProcessor() && !that.xferProcessor()) { 120293d696fcfb9f1c83019c4b15c4864cd6649ed78Robert Phillips return true; 121398487a850431cf495330d4023607df5305a311fRobert Phillips } 122e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips const GrXferProcessor& thisXP = this->xferProcessor() 123e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips ? *this->xferProcessor() 124e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips : GrPorterDuffXPFactory::SimpleSrcOverXP(); 125e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips const GrXferProcessor& thatXP = that.xferProcessor() 126e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips ? *that.xferProcessor() 127e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips : GrPorterDuffXPFactory::SimpleSrcOverXP(); 128e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips return thisXP.isEqual(thatXP); 129e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips} 130e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips 131d316e77c1e1967b439a9a6c11146c54e367bff71Robert PhillipsGrProcessorSet::Analysis GrProcessorSet::finalize(const GrProcessorAnalysisColor& colorInput, 132e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips const GrProcessorAnalysisCoverage coverageInput, 133e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips const GrAppliedClip* clip, bool isMixedSamples, 134e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips const GrCaps& caps, GrColor* overrideInputColor) { 135e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips SkASSERT(!this->isFinalized()); 136e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips SkASSERT(!fFragmentProcessorOffset); 137e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips 138e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips GrProcessorSet::Analysis analysis; 139e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips 140e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0bRobert Phillips const GrFragmentProcessor* clipFP = clip ? clip->clipCoverageFragmentProcessor() : nullptr; 141bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon GrColorFragmentProcessorAnalysis colorAnalysis(colorInput); 142bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon analysis.fCompatibleWithCoverageAsAlpha = GrProcessorAnalysisCoverage::kLCD != coverageInput; 143bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 144bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon const GrFragmentProcessor* const* fps = fFragmentProcessors.get() + fFragmentProcessorOffset; 145bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon colorAnalysis.analyzeProcessors(fps, fColorFragmentProcessorCnt); 146bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon analysis.fCompatibleWithCoverageAsAlpha &= 147bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon colorAnalysis.allProcessorsCompatibleWithCoverageAsAlpha(); 148bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon fps += fColorFragmentProcessorCnt; 149bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon int n = this->numCoverageFragmentProcessors(); 150bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon bool hasCoverageFP = n > 0; 151bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon bool coverageUsesLocalCoords = false; 152bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon for (int i = 0; i < n; ++i) { 153bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (!fps[i]->compatibleWithCoverageAsAlpha()) { 154bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon analysis.fCompatibleWithCoverageAsAlpha = false; 155bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon // Other than tests that exercise atypical behavior we expect all coverage FPs to be 156bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon // compatible with the coverage-as-alpha optimization. 157bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon GrCapsDebugf(&caps, "Coverage FP is not compatible with coverage as alpha.\n"); 158bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 159bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon coverageUsesLocalCoords |= fps[i]->usesLocalCoords(); 160bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 161bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 162bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (clipFP) { 163bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon analysis.fCompatibleWithCoverageAsAlpha &= clipFP->compatibleWithCoverageAsAlpha(); 164bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon coverageUsesLocalCoords |= clipFP->usesLocalCoords(); 165bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon hasCoverageFP = true; 166bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 167bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon int colorFPsToEliminate = colorAnalysis.initialProcessorsToEliminate(overrideInputColor); 168bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon analysis.fInputColorType = static_cast<Analysis::PackedInputColorType>( 169bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon colorFPsToEliminate ? Analysis::kOverridden_InputColorType 170bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon : Analysis::kOriginal_InputColorType); 171bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 172bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon GrProcessorAnalysisCoverage outputCoverage; 173bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (GrProcessorAnalysisCoverage::kLCD == coverageInput) { 174bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon outputCoverage = GrProcessorAnalysisCoverage::kLCD; 175bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } else if (hasCoverageFP || GrProcessorAnalysisCoverage::kSingleChannel == coverageInput) { 176bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon outputCoverage = GrProcessorAnalysisCoverage::kSingleChannel; 177bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } else { 178bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon outputCoverage = GrProcessorAnalysisCoverage::kNone; 179bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 18007792b218e1cf31c42611276d597fcc99677d391Brian Osman 181bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon GrXPFactory::AnalysisProperties props = GrXPFactory::GetAnalysisProperties( 182bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon this->xpFactory(), colorAnalysis.outputColor(), outputCoverage, caps); 183bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (!this->numCoverageFragmentProcessors() && 184bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon GrProcessorAnalysisCoverage::kNone == coverageInput) { 185bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon analysis.fCanCombineOverlappedStencilAndCover = SkToBool( 186bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon props & GrXPFactory::AnalysisProperties::kCanCombineOverlappedStencilAndCover); 187bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } else { 188bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon // If we have non-clipping coverage processors we don't try to merge stencil steps as its 189bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon // unclear whether it will be correct. We don't expect this to happen in practice. 190bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon analysis.fCanCombineOverlappedStencilAndCover = false; 191bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 192bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon analysis.fRequiresDstTexture = 193bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon SkToBool(props & GrXPFactory::AnalysisProperties::kRequiresDstTexture); 194bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon analysis.fCompatibleWithCoverageAsAlpha &= 195bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon SkToBool(props & GrXPFactory::AnalysisProperties::kCompatibleWithAlphaAsCoverage); 196bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon analysis.fRequiresBarrierBetweenOverlappingDraws = SkToBool( 197bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon props & GrXPFactory::AnalysisProperties::kRequiresBarrierBetweenOverlappingDraws); 198bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (props & GrXPFactory::AnalysisProperties::kIgnoresInputColor) { 199bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon colorFPsToEliminate = this->numColorFragmentProcessors(); 20007792b218e1cf31c42611276d597fcc99677d391Brian Osman analysis.fInputColorType = 20107792b218e1cf31c42611276d597fcc99677d391Brian Osman static_cast<Analysis::PackedInputColorType>(Analysis::kIgnored_InputColorType); 20207792b218e1cf31c42611276d597fcc99677d391Brian Osman analysis.fUsesLocalCoords = coverageUsesLocalCoords; 20307792b218e1cf31c42611276d597fcc99677d391Brian Osman } else { 20407792b218e1cf31c42611276d597fcc99677d391Brian Osman analysis.fUsesLocalCoords = coverageUsesLocalCoords | colorAnalysis.usesLocalCoords(); 20507792b218e1cf31c42611276d597fcc99677d391Brian Osman } 20607792b218e1cf31c42611276d597fcc99677d391Brian Osman for (int i = 0; i < colorFPsToEliminate; ++i) { 20707792b218e1cf31c42611276d597fcc99677d391Brian Osman fFragmentProcessors[i]->unref(); 20807792b218e1cf31c42611276d597fcc99677d391Brian Osman fFragmentProcessors[i] = nullptr; 20907792b218e1cf31c42611276d597fcc99677d391Brian Osman } 21067c18d6b5188a0497f6912a73d964c763d2f8f84Robert Phillips for (int i = colorFPsToEliminate; i < fFragmentProcessors.count(); ++i) { 21167c18d6b5188a0497f6912a73d964c763d2f8f84Robert Phillips fFragmentProcessors[i]->addPendingExecution(); 21207792b218e1cf31c42611276d597fcc99677d391Brian Osman fFragmentProcessors[i]->unref(); 213bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 214bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon fFragmentProcessorOffset = colorFPsToEliminate; 215bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon fColorFragmentProcessorCnt -= colorFPsToEliminate; 216bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 217bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon auto xp = GrXPFactory::MakeXferProcessor(this->xpFactory(), colorAnalysis.outputColor(), 218bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon outputCoverage, isMixedSamples, caps); 219bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon fXP.fProcessor = xp.release(); 220bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 22182f44319159bb98dcacdbbec7ea643dde5ed024bBrian Salomon fFlags |= kFinalized_Flag; 222bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon analysis.fIsInitialized = true; 223bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon return analysis; 224bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon} 22507792b218e1cf31c42611276d597fcc99677d391Brian Osman