Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
CustomXP Class Reference
Inheritance diagram for CustomXP:
GrXferProcessor GrProcessor GrNonAtomicRef< GrXferProcessor > SkNoncopyable

Public Member Functions

 CustomXP (SkBlendMode mode, skgpu::BlendEquation hwBlendEquation)
 
 CustomXP (SkBlendMode mode, GrProcessorAnalysisCoverage coverage)
 
const char * name () const override
 
std::unique_ptr< ProgramImplmakeProgramImpl () const override
 
GrXferBarrierType xferBarrierType (const GrCaps &) const override
 
- Public Member Functions inherited from GrXferProcessor
void addToKey (const GrShaderCaps &, skgpu::KeyBuilder *, const GrSurfaceOrigin *originIfDstTexture, bool usesInputAttachmentForDstRead) const
 
skgpu::BlendInfo getBlendInfo () const
 
bool willReadDstColor () const
 
bool hasSecondaryOutput () const
 
bool isLCD () const
 
bool isEqual (const GrXferProcessor &that) const
 
- Public Member Functions inherited from GrProcessor
virtual ~GrProcessor ()=default
 
void * operator new (size_t size)
 
void * operator new (size_t object_size, size_t footer_size)
 
void operator delete (void *target)
 
void * operator new (size_t size, void *placement)
 
void operator delete (void *target, void *placement)
 
template<typename T >
const Tcast () const
 
ClassID classID () const
 
- Public Member Functions inherited from GrNonAtomicRef< GrXferProcessor >
 GrNonAtomicRef ()
 
bool unique () const
 
int refCnt () const
 
void ref () const
 
void unref () const
 
- Public Member Functions inherited from SkNoncopyable
 SkNoncopyable ()=default
 
 SkNoncopyable (SkNoncopyable &&)=default
 
SkNoncopyableoperator= (SkNoncopyable &&)=default
 

Private Member Functions

void onAddToKey (const GrShaderCaps &, skgpu::KeyBuilder *) const override
 
void onGetBlendInfo (skgpu::BlendInfo *) const override
 
bool onIsEqual (const GrXferProcessor &xpBase) const override
 

Additional Inherited Members

- Public Types inherited from GrProcessor
enum  ClassID {
  kNull_ClassID , kAttributeTestProcessor_ClassID , kBigKeyProcessor_ClassID , kBlendFragmentProcessor_ClassID ,
  kBlockInputFragmentProcessor_ClassID , kButtCapStrokedCircleGeometryProcessor_ClassID , kCircleGeometryProcessor_ClassID , kCircularRRectEffect_ClassID ,
  kClockwiseTestProcessor_ClassID , kColorTableEffect_ClassID , kCoverageSetOpXP_ClassID , kCustomXP_ClassID ,
  kDashingCircleEffect_ClassID , kDashingLineEffect_ClassID , kDefaultGeoProc_ClassID , kDeviceSpace_ClassID ,
  kDIEllipseGeometryProcessor_ClassID , kDisableColorXP_ClassID , kDrawAtlasPathShader_ClassID , kEllipseGeometryProcessor_ClassID ,
  kEllipticalRRectEffect_ClassID , kFwidthSquircleTestProcessor_ClassID , kGP_ClassID , kGrBicubicEffect_ClassID ,
  kGrBitmapTextGeoProc_ClassID , kGrColorSpaceXformEffect_ClassID , kGrConicEffect_ClassID , kGrConvexPolyEffect_ClassID ,
  kGrDiffuseLightingEffect_ClassID , kGrDisplacementMapEffect_ClassID , kGrDistanceFieldA8TextGeoProc_ClassID , kGrDistanceFieldLCDTextGeoProc_ClassID ,
  kGrDistanceFieldPathGeoProc_ClassID , kGrFillRRectOp_Processor_ClassID , kGrGaussianConvolutionFragmentProcessor_ClassID , kGrMatrixConvolutionEffect_ClassID ,
  kGrMatrixEffect_ClassID , kGrMeshTestProcessor_ClassID , kGrMorphologyEffect_ClassID , kGrPerlinNoise2Effect_ClassID ,
  kGrPipelineDynamicStateTestProcessor_ClassID , kGrQuadEffect_ClassID , kGrRRectShadowGeoProc_ClassID , kGrSkSLFP_ClassID ,
  kGrSpecularLightingEffect_ClassID , kGrTextureEffect_ClassID , kGrUnrolledBinaryGradientColorizer_ClassID , kGrYUVtoRGBEffect_ClassID ,
  kHighPrecisionFragmentProcessor_ClassID , kLatticeGP_ClassID , kPDLCDXferProcessor_ClassID , kPorterDuffXferProcessor_ClassID ,
  kPremulFragmentProcessor_ClassID , kQuadEdgeEffect_ClassID , kQuadPerEdgeAAGeometryProcessor_ClassID , kSeriesFragmentProcessor_ClassID ,
  kShaderPDXferProcessor_ClassID , kSurfaceColorProcessor_ClassID , kSwizzleFragmentProcessor_ClassID , kTessellate_BoundingBoxShader_ClassID ,
  kTessellate_GrModulateAtlasCoverageEffect_ClassID , kTessellate_GrStrokeTessellationShader_ClassID , kTessellate_HullShader_ClassID , kTessellate_MiddleOutShader_ClassID ,
  kTessellate_SimpleTriangleShader_ClassID , kTessellationTestTriShader_ClassID , kTestFP_ClassID , kTestRectOp_ClassID ,
  kVertexColorSpaceBenchGP_ClassID , kVerticesGP_ClassID
}
 
- Protected Member Functions inherited from GrXferProcessor
 GrXferProcessor (ClassID classID)
 
 GrXferProcessor (ClassID classID, bool willReadDstColor, GrProcessorAnalysisCoverage)
 
- Protected Member Functions inherited from GrProcessor
 GrProcessor (ClassID classID)
 
 GrProcessor (const GrProcessor &)=delete
 
GrProcessoroperator= (const GrProcessor &)=delete
 
- Protected Attributes inherited from GrProcessor
const ClassID fClassID
 

Detailed Description

Definition at line 82 of file GrCustomXfermode.cpp.

Constructor & Destructor Documentation

◆ CustomXP() [1/2]

CustomXP::CustomXP ( SkBlendMode  mode,
skgpu::BlendEquation  hwBlendEquation 
)
inline

Definition at line 84 of file GrCustomXfermode.cpp.

85 : INHERITED(kCustomXP_ClassID)
86 , fMode(mode)
87 , fHWBlendEquation(hwBlendEquation) {}

◆ CustomXP() [2/2]

CustomXP::CustomXP ( SkBlendMode  mode,
GrProcessorAnalysisCoverage  coverage 
)
inline

Definition at line 89 of file GrCustomXfermode.cpp.

90 : INHERITED(kCustomXP_ClassID, /*willReadDstColor=*/true, coverage)
91 , fMode(mode)
92 , fHWBlendEquation(skgpu::BlendEquation::kIllegal) {
93 }

Member Function Documentation

◆ makeProgramImpl()

std::unique_ptr< GrXferProcessor::ProgramImpl > CustomXP::makeProgramImpl ( ) const
overridevirtual

Returns a new instance of the appropriate GL implementation class for the given GrXferProcessor; caller is responsible for deleting the object.

Implements GrXferProcessor.

Definition at line 127 of file GrCustomXfermode.cpp.

127 {
128 SkASSERT(this->willReadDstColor() != this->hasHWBlendEquation());
129
130 class Impl : public ProgramImpl {
131 private:
132 void emitOutputsForBlendState(const EmitArgs& args) override {
133 const CustomXP& xp = args.fXP.cast<CustomXP>();
134 SkASSERT(xp.hasHWBlendEquation());
135
136 GrGLSLXPFragmentBuilder* fragBuilder = args.fXPFragBuilder;
137 fragBuilder->enableAdvancedBlendEquationIfNeeded(xp.fHWBlendEquation);
138
139 // Apply coverage by multiplying it into the src color before blending. This will "just
140 // work" automatically. (See analysisProperties())
141 fragBuilder->codeAppendf("%s = %s * %s;",
142 args.fOutputPrimary,
143 args.fInputCoverage,
144 args.fInputColor);
145 }
146
147 void emitBlendCodeForDstRead(GrGLSLXPFragmentBuilder* fragBuilder,
148 GrGLSLUniformHandler* uniformHandler,
149 const char* srcColor,
150 const char* srcCoverage,
151 const char* dstColor,
152 const char* outColor,
153 const char* outColorSecondary,
154 const GrXferProcessor& proc) override {
155 const CustomXP& xp = proc.cast<CustomXP>();
156 SkASSERT(!xp.hasHWBlendEquation());
157
158 std::string blendExpr = GrGLSLBlend::BlendExpression(
159 &xp, uniformHandler, &fBlendUniform, srcColor, dstColor, xp.fMode);
160 fragBuilder->codeAppendf("%s = %s;", outColor, blendExpr.c_str());
161
162 // Apply coverage.
163 DefaultCoverageModulation(fragBuilder,
164 srcCoverage,
165 dstColor,
166 outColor,
167 outColorSecondary,
168 xp);
169 }
170
171 void onSetData(const GrGLSLProgramDataManager& pdman,
172 const GrXferProcessor& proc) override {
173 if (fBlendUniform.isValid()) {
174 const CustomXP& xp = proc.cast<CustomXP>();
175 GrGLSLBlend::SetBlendModeUniformData(pdman, fBlendUniform, xp.fMode);
176 }
177 }
178
180 };
181
182 return std::make_unique<Impl>();
183}
#define SkASSERT(cond)
Definition SkAssert.h:116
void codeAppendf(const char format[],...) SK_PRINTF_LIKE(2
GrGLSLProgramDataManager::UniformHandle UniformHandle
virtual void enableAdvancedBlendEquationIfNeeded(skgpu::BlendEquation)=0
const T & cast() const
bool willReadDstColor() const
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
std::string BlendExpression(const GrProcessor *processor, GrGLSLUniformHandler *uniformHandler, GrGLSLProgramDataManager::UniformHandle *blendUniform, const char *srcColor, const char *dstColor, SkBlendMode mode)
void SetBlendModeUniformData(const GrGLSLProgramDataManager &pdman, GrGLSLProgramDataManager::UniformHandle blendUniform, SkBlendMode mode)

◆ name()

const char * CustomXP::name ( ) const
inlineoverridevirtual

Human-meaningful string to identify this processor; may be embedded in generated shader code and must be a legal SkSL identifier prefix.

Implements GrProcessor.

Definition at line 95 of file GrCustomXfermode.cpp.

95{ return "Custom Xfermode"; }

◆ onAddToKey()

void CustomXP::onAddToKey ( const GrShaderCaps ,
skgpu::KeyBuilder  
) const
overrideprivatevirtual

Adds a key on the skgpu::KeyBuilder that reflects any variety in the code that may be emitted by the xfer processor subclass.

Implements GrXferProcessor.

Definition at line 116 of file GrCustomXfermode.cpp.

116 {
117 if (this->hasHWBlendEquation()) {
118 SkASSERT(caps.fAdvBlendEqInteraction > 0); // 0 will mean !xp.hasHWBlendEquation().
119 b->addBool(true, "has hardware blend equation");
120 b->add32(caps.fAdvBlendEqInteraction);
121 } else {
122 b->addBool(false, "has hardware blend equation");
123 b->add32(GrGLSLBlend::BlendKey(fMode));
124 }
125}
static bool b
int BlendKey(SkBlendMode mode)

◆ onGetBlendInfo()

void CustomXP::onGetBlendInfo ( skgpu::BlendInfo ) const
overrideprivatevirtual

If we are not performing a dst read, retrieves the fixed-function blend state required by the subclass. When using dst reads, the base class controls the fixed-function blend state and this method will not be called. The BlendInfo struct comes initialized to "no blending".

Reimplemented from GrXferProcessor.

Definition at line 197 of file GrCustomXfermode.cpp.

197 {
198 if (this->hasHWBlendEquation()) {
199 blendInfo->fEquation = fHWBlendEquation;
200 }
201}

◆ onIsEqual()

bool CustomXP::onIsEqual ( const GrXferProcessor xpBase) const
overrideprivatevirtual

Implements GrXferProcessor.

Definition at line 185 of file GrCustomXfermode.cpp.

185 {
186 const CustomXP& s = other.cast<CustomXP>();
187 return fMode == s.fMode && fHWBlendEquation == s.fHWBlendEquation;
188}
struct MyStruct s

◆ xferBarrierType()

GrXferBarrierType CustomXP::xferBarrierType ( const GrCaps caps) const
overridevirtual

Returns the barrier type, if any, that this XP will require. Note that the possibility that a kTexture type barrier is required is handled by the GrPipeline and need not be considered by subclass overrides of this function.

Reimplemented from GrXferProcessor.

Definition at line 190 of file GrCustomXfermode.cpp.

190 {
191 if (this->hasHWBlendEquation() && !caps.advancedCoherentBlendEquationSupport()) {
193 }
195}
@ kNone_GrXferBarrierType
@ kBlend_GrXferBarrierType
bool advancedCoherentBlendEquationSupport() const
Definition GrCaps.h:166

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