Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | List of all members
GrProcessorSet Class Reference

#include <GrProcessorSet.h>

Classes

class  Analysis
 

Public Member Functions

 GrProcessorSet (GrPaint &&)
 
 GrProcessorSet (SkBlendMode)
 
 GrProcessorSet (std::unique_ptr< GrFragmentProcessor > colorFP)
 
 GrProcessorSet (GrProcessorSet &&)
 
 GrProcessorSet (const GrProcessorSet &)=delete
 
GrProcessorSetoperator= (const GrProcessorSet &)=delete
 
 ~GrProcessorSet ()
 
bool hasColorFragmentProcessor () const
 
bool hasCoverageFragmentProcessor () const
 
const GrFragmentProcessorcolorFragmentProcessor () const
 
const GrFragmentProcessorcoverageFragmentProcessor () const
 
const GrXferProcessorxferProcessor () const
 
sk_sp< const GrXferProcessorrefXferProcessor () const
 
std::unique_ptr< GrFragmentProcessordetachColorFragmentProcessor ()
 
std::unique_ptr< GrFragmentProcessordetachCoverageFragmentProcessor ()
 
bool operator== (const GrProcessorSet &that) const
 
bool operator!= (const GrProcessorSet &that) const
 
Analysis finalize (const GrProcessorAnalysisColor &, const GrProcessorAnalysisCoverage, const GrAppliedClip *, const GrUserStencilSettings *, const GrCaps &, GrClampType, SkPMColor4f *inputColorOverride)
 
bool isFinalized () const
 
void visitProxies (const GrVisitProxyFunc &) const
 

Static Public Member Functions

static const GrProcessorSetEmptySet ()
 
static GrProcessorSet MakeEmptySet ()
 
static constexpr Analysis EmptySetAnalysis ()
 

Detailed Description

Definition at line 21 of file GrProcessorSet.h.

Constructor & Destructor Documentation

◆ GrProcessorSet() [1/5]

GrProcessorSet::GrProcessorSet ( GrPaint &&  paint)

Definition at line 25 of file GrProcessorSet.cpp.

25 : fXP(paint.getXPFactory()) {
26 fColorFragmentProcessor = std::move(paint.fColorFragmentProcessor);
27 fCoverageFragmentProcessor = std::move(paint.fCoverageFragmentProcessor);
28
29 SkDEBUGCODE(paint.fAlive = false;)
30}
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
const Paint & paint
Definition: color_source.cc:38

◆ GrProcessorSet() [2/5]

GrProcessorSet::GrProcessorSet ( SkBlendMode  mode)

Definition at line 32 of file GrProcessorSet.cpp.

static const GrXPFactory * FromBlendMode(SkBlendMode)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228

◆ GrProcessorSet() [3/5]

GrProcessorSet::GrProcessorSet ( std::unique_ptr< GrFragmentProcessor colorFP)

Definition at line 34 of file GrProcessorSet.cpp.

35 : fXP((const GrXPFactory*)nullptr) {
36 SkASSERT(colorFP);
37 fColorFragmentProcessor = std::move(colorFP);
38}
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ GrProcessorSet() [4/5]

GrProcessorSet::GrProcessorSet ( GrProcessorSet &&  that)

Definition at line 40 of file GrProcessorSet.cpp.

41 : fColorFragmentProcessor(std::move(that.fColorFragmentProcessor))
42 , fCoverageFragmentProcessor(std::move(that.fCoverageFragmentProcessor))
43 , fXP(std::move(that.fXP))
44 , fFlags(that.fFlags) {}

◆ GrProcessorSet() [5/5]

GrProcessorSet::GrProcessorSet ( const GrProcessorSet )
delete

◆ ~GrProcessorSet()

GrProcessorSet::~GrProcessorSet ( )

Definition at line 46 of file GrProcessorSet.cpp.

46 {
47 if (this->isFinalized() && this->xferProcessor()) {
48 this->xferProcessor()->unref();
49 }
50}
void unref() const
bool isFinalized() const
const GrXferProcessor * xferProcessor() const

Member Function Documentation

◆ colorFragmentProcessor()

const GrFragmentProcessor * GrProcessorSet::colorFragmentProcessor ( ) const
inline

Definition at line 39 of file GrProcessorSet.h.

39 {
40 return fColorFragmentProcessor.get();
41 }

◆ coverageFragmentProcessor()

const GrFragmentProcessor * GrProcessorSet::coverageFragmentProcessor ( ) const
inline

Definition at line 42 of file GrProcessorSet.h.

42 {
43 return fCoverageFragmentProcessor.get();
44 }

◆ detachColorFragmentProcessor()

std::unique_ptr< GrFragmentProcessor > GrProcessorSet::detachColorFragmentProcessor ( )
inline

Definition at line 55 of file GrProcessorSet.h.

55 {
56 return std::move(fColorFragmentProcessor);
57 }

◆ detachCoverageFragmentProcessor()

std::unique_ptr< GrFragmentProcessor > GrProcessorSet::detachCoverageFragmentProcessor ( )
inline

Definition at line 59 of file GrProcessorSet.h.

59 {
60 return std::move(fCoverageFragmentProcessor);
61 }

◆ EmptySet()

const GrProcessorSet & GrProcessorSet::EmptySet ( )
static

These are valid only for non-LCD coverage.

Definition at line 16 of file GrProcessorSet.cpp.

16 {
17 static GrProcessorSet gEmpty(GrProcessorSet::Empty::kEmpty);
18 return gEmpty;
19}
static SkPathRef * gEmpty
Definition: SkPathRef.cpp:75

◆ EmptySetAnalysis()

static constexpr Analysis GrProcessorSet::EmptySetAnalysis ( )
inlinestaticconstexpr

Definition at line 151 of file GrProcessorSet.h.

151{ return Analysis(Empty::kEmpty); }

◆ finalize()

GrProcessorSet::Analysis GrProcessorSet::finalize ( const GrProcessorAnalysisColor colorInput,
const GrProcessorAnalysisCoverage  coverageInput,
const GrAppliedClip clip,
const GrUserStencilSettings userStencil,
const GrCaps caps,
GrClampType  clampType,
SkPMColor4f inputColorOverride 
)

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 must be called before the processor set is used to construct a GrPipeline and may only be called once.

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.

Definition at line 115 of file GrProcessorSet.cpp.

118 {
119 SkASSERT(!this->isFinalized());
120
122 analysis.fCompatibleWithCoverageAsAlpha = GrProcessorAnalysisCoverage::kLCD != coverageInput;
123
124 GrColorFragmentProcessorAnalysis colorAnalysis(colorInput, &fColorFragmentProcessor,
125 this->hasColorFragmentProcessor() ? 1 : 0);
126 bool hasCoverageFP = this->hasCoverageFragmentProcessor();
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;
136 const GrFragmentProcessor* clipFP = clip->coverageFragmentProcessor();
137 analysis.fCompatibleWithCoverageAsAlpha &= clipFP->compatibleWithCoverageAsAlpha();
138 coverageUsesLocalCoords |= clipFP->usesSampleCoords();
139 }
140 int colorFPsToEliminate = colorAnalysis.initialProcessorsToEliminate(overrideInputColor);
141 analysis.fInputColorType = static_cast<Analysis::PackedInputColorType>(
142 colorFPsToEliminate ? Analysis::kOverridden_InputColorType
143 : Analysis::kOriginal_InputColorType);
144
145 GrProcessorAnalysisCoverage outputCoverage;
146 if (GrProcessorAnalysisCoverage::kLCD == coverageInput) {
147 outputCoverage = GrProcessorAnalysisCoverage::kLCD;
148 } else if (hasCoverageFP || GrProcessorAnalysisCoverage::kSingleChannel == coverageInput) {
150 } else {
151 outputCoverage = GrProcessorAnalysisCoverage::kNone;
152 }
153
155 this->xpFactory(), colorAnalysis.outputColor(), outputCoverage, caps, clampType);
156 analysis.fRequiresDstTexture = (props & GrXPFactory::AnalysisProperties::kRequiresDstTexture) ||
157 colorAnalysis.requiresDstTexture(caps);
158 analysis.fCompatibleWithCoverageAsAlpha &=
160 analysis.fRequiresNonOverlappingDraws =
162 analysis.fRequiresDstTexture;
163 analysis.fUsesNonCoherentHWBlending =
165 analysis.fUnaffectedByDstValue =
168 colorFPsToEliminate = this->hasColorFragmentProcessor() ? 1 : 0;
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) {
178 SkASSERT(colorFPsToEliminate == 1);
179 fColorFragmentProcessor = nullptr;
180 }
181 analysis.fHasColorFragmentProcessor = this->hasColorFragmentProcessor();
182
183 auto xp = GrXPFactory::MakeXferProcessor(this->xpFactory(), colorAnalysis.outputColor(),
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 &&
192 GrXferBarrierType::kNone_GrXferBarrierType != fXP.fProcessor->xferBarrierType(caps);
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)
Definition: SkPath.cpp:3892
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
bool compatibleWithCoverageAsAlpha() const
bool hasCoverageFragmentProcessor() const
bool hasColorFragmentProcessor() const
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)

◆ hasColorFragmentProcessor()

bool GrProcessorSet::hasColorFragmentProcessor ( ) const
inline

Definition at line 36 of file GrProcessorSet.h.

36{ return fColorFragmentProcessor != nullptr; }

◆ hasCoverageFragmentProcessor()

bool GrProcessorSet::hasCoverageFragmentProcessor ( ) const
inline

Definition at line 37 of file GrProcessorSet.h.

37{ return fCoverageFragmentProcessor != nullptr; }

◆ isFinalized()

bool GrProcessorSet::isFinalized ( ) const
inline

Definition at line 146 of file GrProcessorSet.h.

146{ return SkToBool(kFinalized_Flag & fFlags); }

◆ MakeEmptySet()

GrProcessorSet GrProcessorSet::MakeEmptySet ( )
static

Definition at line 21 of file GrProcessorSet.cpp.

21 {
22 return GrProcessorSet(GrProcessorSet::Empty::kEmpty);
23}
GrProcessorSet(GrPaint &&)

◆ operator!=()

bool GrProcessorSet::operator!= ( const GrProcessorSet that) const
inline

Definition at line 65 of file GrProcessorSet.h.

65{ return !(*this == that); }

◆ operator=()

GrProcessorSet & GrProcessorSet::operator= ( const GrProcessorSet )
delete

◆ operator==()

bool GrProcessorSet::operator== ( const GrProcessorSet that) const

Comparisons are only legal on finalized processor sets.

Definition at line 81 of file GrProcessorSet.cpp.

81 {
82 SkASSERT(this->isFinalized());
83 SkASSERT(that.isFinalized());
84 if (((fFlags ^ that.fFlags) & ~kFinalized_Flag) ||
85 this->hasColorFragmentProcessor() != that.hasColorFragmentProcessor() ||
86 this->hasCoverageFragmentProcessor() != that.hasCoverageFragmentProcessor()) {
87 return false;
88 }
89
90 if (this->hasColorFragmentProcessor()) {
91 if (!colorFragmentProcessor()->isEqual(*that.colorFragmentProcessor())) {
92 return false;
93 }
94 }
95
96 if (this->hasCoverageFragmentProcessor()) {
98 return false;
99 }
100 }
101
102 // Most of the time both of these are null
103 if (!this->xferProcessor() && !that.xferProcessor()) {
104 return true;
105 }
106 const GrXferProcessor& thisXP = this->xferProcessor()
107 ? *this->xferProcessor()
108 : GrPorterDuffXPFactory::SimpleSrcOverXP();
109 const GrXferProcessor& thatXP = that.xferProcessor()
110 ? *that.xferProcessor()
112 return thisXP.isEqual(thatXP);
113}
static const GrXferProcessor & SimpleSrcOverXP()
const GrFragmentProcessor * coverageFragmentProcessor() const
const GrFragmentProcessor * colorFragmentProcessor() const
bool isEqual(const GrXferProcessor &that) const

◆ refXferProcessor()

sk_sp< const GrXferProcessor > GrProcessorSet::refXferProcessor ( ) const
inline

Definition at line 50 of file GrProcessorSet.h.

50 {
51 SkASSERT(this->isFinalized());
52 return sk_ref_sp(fXP.fProcessor);
53 }
sk_sp< T > sk_ref_sp(T *obj)
Definition: SkRefCnt.h:381

◆ visitProxies()

void GrProcessorSet::visitProxies ( const GrVisitProxyFunc func) const

Definition at line 199 of file GrProcessorSet.cpp.

199 {
200 if (this->hasColorFragmentProcessor()) {
201 fColorFragmentProcessor->visitProxies(func);
202 }
203 if (this->hasCoverageFragmentProcessor()) {
204 fCoverageFragmentProcessor->visitProxies(func);
205 }
206}

◆ xferProcessor()

const GrXferProcessor * GrProcessorSet::xferProcessor ( ) const
inline

Definition at line 46 of file GrProcessorSet.h.

46 {
47 SkASSERT(this->isFinalized());
48 return fXP.fProcessor;
49 }

The documentation for this class was generated from the following files: