Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Member Functions | List of all members
GrXferProcessor::ProgramImpl Class Reference

#include <GrXferProcessor.h>

Classes

struct  EmitArgs
 

Public Types

using SamplerHandle = GrGLSLUniformHandler::SamplerHandle
 

Public Member Functions

virtual ~ProgramImpl ()=default
 
void emitCode (const EmitArgs &)
 
void setData (const GrGLSLProgramDataManager &pdm, const GrXferProcessor &xp)
 

Protected Member Functions

 ProgramImpl ()=default
 

Static Protected Member Functions

static void DefaultCoverageModulation (GrGLSLXPFragmentBuilder *fragBuilder, const char *srcCoverage, const char *dstColor, const char *outColor, const char *outColorSecondary, const GrXferProcessor &proc)
 

Private Member Functions

virtual void emitOutputsForBlendState (const EmitArgs &)
 
virtual void emitBlendCodeForDstRead (GrGLSLXPFragmentBuilder *, GrGLSLUniformHandler *, const char *srcColor, const char *srcCoverage, const char *dstColor, const char *outColor, const char *outColorSecondary, const GrXferProcessor &)
 
virtual void emitWriteSwizzle (GrGLSLXPFragmentBuilder *, const skgpu::Swizzle &, const char *outColor, const char *outColorSecondary) const
 
virtual void onSetData (const GrGLSLProgramDataManager &, const GrXferProcessor &)
 

Detailed Description

Definition at line 282 of file GrXferProcessor.h.

Member Typedef Documentation

◆ SamplerHandle

using GrXferProcessor::ProgramImpl::SamplerHandle = GrGLSLUniformHandler::SamplerHandle

Definition at line 286 of file GrXferProcessor.h.

Constructor & Destructor Documentation

◆ ~ProgramImpl()

virtual GrXferProcessor::ProgramImpl::~ProgramImpl ( )
virtualdefault

◆ ProgramImpl()

GrXferProcessor::ProgramImpl::ProgramImpl ( )
protecteddefault

Member Function Documentation

◆ DefaultCoverageModulation()

void ProgramImpl::DefaultCoverageModulation ( GrGLSLXPFragmentBuilder fragBuilder,
const char *  srcCoverage,
const char *  dstColor,
const char *  outColor,
const char *  outColorSecondary,
const GrXferProcessor proc 
)
staticprotected

Definition at line 209 of file GrXferProcessor.cpp.

214 {
215 if (srcCoverage) {
216 if (proc.isLCD()) {
217 fragBuilder->codeAppendf("half3 lerpRGB = mix(%s.aaa, %s.aaa, %s.rgb);",
218 dstColor,
219 outColor,
220 srcCoverage);
221 }
222 fragBuilder->codeAppendf("%s = %s * %s + (half4(1.0) - %s) * %s;",
223 outColor,
224 srcCoverage,
225 outColor,
226 srcCoverage,
227 dstColor);
228 if (proc.isLCD()) {
229 fragBuilder->codeAppendf("%s.a = max(max(lerpRGB.r, lerpRGB.b), lerpRGB.g);", outColor);
230 }
231 }
232}
void codeAppendf(const char format[],...) SK_PRINTF_LIKE(2
bool isLCD() const

◆ emitBlendCodeForDstRead()

virtual void GrXferProcessor::ProgramImpl::emitBlendCodeForDstRead ( GrGLSLXPFragmentBuilder ,
GrGLSLUniformHandler ,
const char *  srcColor,
const char *  srcCoverage,
const char *  dstColor,
const char *  outColor,
const char *  outColorSecondary,
const GrXferProcessor  
)
inlineprivatevirtual

Called by emitCode() when the XP will perform a dst read. This method only needs to supply the blending logic. The base class applies coverage. A subclass only needs to implement this method if it can construct a GrXferProcessor that reads the dst color.

Definition at line 363 of file GrXferProcessor.h.

370 {
371 SK_ABORT("emitBlendCodeForDstRead not implemented.");
372 }
#define SK_ABORT(message,...)
Definition: SkAssert.h:70

◆ emitCode()

void GrXferProcessor::ProgramImpl::emitCode ( const EmitArgs )

This is similar to emitCode() in the base class, except it takes a full shader builder. This allows the effect subclass to emit vertex code.

◆ emitOutputsForBlendState()

virtual void GrXferProcessor::ProgramImpl::emitOutputsForBlendState ( const EmitArgs )
inlineprivatevirtual

Called by emitCode() when the XP will not be performing a dst read. This method is responsible for both blending and coverage. A subclass only needs to implement this method if it can construct a GrXferProcessor that will not read the dst color.

Definition at line 354 of file GrXferProcessor.h.

354 {
355 SK_ABORT("emitOutputsForBlendState not implemented.");
356 }

◆ emitWriteSwizzle()

void ProgramImpl::emitWriteSwizzle ( GrGLSLXPFragmentBuilder x,
const skgpu::Swizzle swizzle,
const char *  outColor,
const char *  outColorSecondary 
) const
privatevirtual

Definition at line 190 of file GrXferProcessor.cpp.

193 {
194 if (skgpu::Swizzle::RGBA() != swizzle) {
195 x->codeAppendf("%s = %s.%s;", outColor, outColor, swizzle.asString().c_str());
196 if (outColorSecondary) {
197 x->codeAppendf("%s = %s.%s;",
198 outColorSecondary,
199 outColorSecondary,
200 swizzle.asString().c_str());
201 }
202 }
203}
const char * c_str() const
Definition: SkString.h:133
SkString asString() const
Definition: Swizzle.cpp:46
static constexpr Swizzle RGBA()
Definition: Swizzle.h:66
double x

◆ onSetData()

virtual void GrXferProcessor::ProgramImpl::onSetData ( const GrGLSLProgramDataManager ,
const GrXferProcessor  
)
inlineprivatevirtual

Definition at line 379 of file GrXferProcessor.h.

379{}

◆ setData()

void ProgramImpl::setData ( const GrGLSLProgramDataManager pdm,
const GrXferProcessor xp 
)

A ProgramImpl instance can be reused with any GrXferProcessor that produces the same key. This function reads data from a GrXferProcessor and uploads any uniform variables required by the shaders created in emitCode(). The GrXferProcessor parameter is guaranteed to be of the same type that created this ProgramImpl and to have an identical processor key as the one that created this ProgramImpl. This function calls onSetData on the subclass of ProgramImpl.

Definition at line 205 of file GrXferProcessor.cpp.

205 {
206 this->onSetData(pdm, xp);
207}
virtual void onSetData(const GrGLSLProgramDataManager &, const GrXferProcessor &)

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