Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
GrColorFragmentProcessorAnalysis Class Reference

#include <GrProcessorAnalysis.h>

Public Member Functions

 GrColorFragmentProcessorAnalysis ()=delete
 
 GrColorFragmentProcessorAnalysis (const GrProcessorAnalysisColor &input, std::unique_ptr< GrFragmentProcessor > const fps[], int count)
 
bool isOpaque () const
 
bool allProcessorsCompatibleWithCoverageAsAlpha () const
 
bool usesLocalCoords () const
 
bool willReadDstColor () const
 
bool requiresDstTexture (const GrCaps &caps) const
 
int initialProcessorsToEliminate (SkPMColor4f *newPipelineInputColor) const
 
GrProcessorAnalysisColor outputColor () const
 

Detailed Description

GrColorFragmentProcessorAnalysis gathers invariant data from a set of color fragment processors. It is used to recognize optimizations that can simplify the generated shader or make blending more effecient.

Definition at line 96 of file GrProcessorAnalysis.h.

Constructor & Destructor Documentation

◆ GrColorFragmentProcessorAnalysis() [1/2]

GrColorFragmentProcessorAnalysis::GrColorFragmentProcessorAnalysis ( )
delete

◆ GrColorFragmentProcessorAnalysis() [2/2]

GrColorFragmentProcessorAnalysis::GrColorFragmentProcessorAnalysis ( const GrProcessorAnalysisColor input,
std::unique_ptr< GrFragmentProcessor > const  fps[],
int  count 
)

Definition at line 13 of file GrProcessorAnalysis.cpp.

16 {
17 fCompatibleWithCoverageAsAlpha = true;
18 fIsOpaque = input.isOpaque();
19 fUsesLocalCoords = false;
20 fWillReadDstColor = false;
21 fProcessorsToEliminate = 0;
22 fOutputColorKnown = input.isConstant(&fLastKnownOutputColor);
23 for (int i = 0; i < count; ++i) {
24 const GrFragmentProcessor* fp = fps[i].get();
25 if (fOutputColorKnown && fp->hasConstantOutputForConstantInput(fLastKnownOutputColor,
26 &fLastKnownOutputColor)) {
27 ++fProcessorsToEliminate;
28 fIsOpaque = fLastKnownOutputColor.isOpaque();
29 // We reset these flags since the earlier fragment processors are being eliminated.
30 fCompatibleWithCoverageAsAlpha = true;
31 fUsesLocalCoords = false;
32 fWillReadDstColor = false;
33 continue;
34 }
35
36 fOutputColorKnown = false;
37 if (fIsOpaque && !fp->preservesOpaqueInput()) {
38 fIsOpaque = false;
39 }
40 if (fCompatibleWithCoverageAsAlpha && !fp->compatibleWithCoverageAsAlpha()) {
41 fCompatibleWithCoverageAsAlpha = false;
42 }
43 if (fp->usesSampleCoords()) {
44 fUsesLocalCoords = true;
45 }
46 if (fp->willReadDstColor()) {
47 fWillReadDstColor = true;
48 }
49 }
50}
int count
bool isConstant(SkPMColor4f *color=nullptr) const
const uint32_t fp
bool isOpaque() const
Definition SkColor.h:344

Member Function Documentation

◆ allProcessorsCompatibleWithCoverageAsAlpha()

bool GrColorFragmentProcessorAnalysis::allProcessorsCompatibleWithCoverageAsAlpha ( ) const
inline

Are all the fragment processors compatible with conflating coverage with color prior to the the first fragment processor. This result assumes that processors that should be eliminated as indicated by initialProcessorsToEliminate() are in fact eliminated.

Definition at line 111 of file GrProcessorAnalysis.h.

111 {
112 return fCompatibleWithCoverageAsAlpha;
113 }

◆ initialProcessorsToEliminate()

int GrColorFragmentProcessorAnalysis::initialProcessorsToEliminate ( SkPMColor4f newPipelineInputColor) const
inline

If we detected that the result after the first N processors is a known color then we eliminate those N processors and replace the GrDrawOp's color input to the GrPipeline with the known output of the Nth processor, so that the Nth+1 fragment processor (or the XP if there are only N processors) sees its expected input. If this returns 0 then there are no processors to eliminate.

Definition at line 139 of file GrProcessorAnalysis.h.

139 {
140 if (fProcessorsToEliminate > 0) {
141 *newPipelineInputColor = fLastKnownOutputColor;
142 }
143 return fProcessorsToEliminate;
144 }

◆ isOpaque()

bool GrColorFragmentProcessorAnalysis::isOpaque ( ) const
inline

Definition at line 104 of file GrProcessorAnalysis.h.

104{ return fIsOpaque; }

◆ outputColor()

GrProcessorAnalysisColor GrColorFragmentProcessorAnalysis::outputColor ( ) const
inline

Provides known information about the last processor's output color.

Definition at line 149 of file GrProcessorAnalysis.h.

149 {
150 if (fOutputColorKnown) {
151 return fLastKnownOutputColor;
152 }
155 }

◆ requiresDstTexture()

bool GrColorFragmentProcessorAnalysis::requiresDstTexture ( const GrCaps caps) const

Will we require a destination-surface texture?

Definition at line 52 of file GrProcessorAnalysis.cpp.

52 {
53 return this->willReadDstColor() && !caps.shaderCaps()->fDstReadInShaderSupport;
54}
const GrShaderCaps * shaderCaps() const
Definition GrCaps.h:63
bool fDstReadInShaderSupport

◆ usesLocalCoords()

bool GrColorFragmentProcessorAnalysis::usesLocalCoords ( ) const
inline

Do any of the fragment processors require local coords. This result assumes that processors that should be eliminated as indicated by initialProcessorsToEliminate() are in fact eliminated.

Definition at line 120 of file GrProcessorAnalysis.h.

120{ return fUsesLocalCoords; }

◆ willReadDstColor()

bool GrColorFragmentProcessorAnalysis::willReadDstColor ( ) const
inline

Do any of the fragment processors read back the destination color?

Definition at line 125 of file GrProcessorAnalysis.h.

125{ return fWillReadDstColor; }

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