Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
GrPathTessellationShader::Impl Class Referenceabstract

#include <GrPathTessellationShader.h>

Inheritance diagram for GrPathTessellationShader::Impl:
GrFragmentProcessor::ProgramImpl

Public Member Functions

void onEmitCode (EmitArgs &, GrGPArgs *) final
 
void setData (const GrGLSLProgramDataManager &, const GrShaderCaps &, const GrGeometryProcessor &) override
 
- Public Member Functions inherited from GrFragmentProcessor::ProgramImpl
 ProgramImpl ()=default
 
virtual ~ProgramImpl ()=default
 
virtual void emitCode (EmitArgs &)=0
 
void setData (const GrGLSLProgramDataManager &pdman, const GrFragmentProcessor &processor)
 
int numChildProcessors () const
 
ProgramImplchildProcessor (int index) const
 
void setFunctionName (SkString name)
 
const char * functionName () const
 
SkString invokeChild (int childIndex, EmitArgs &parentArgs, std::string_view skslCoords={})
 
SkString invokeChildWithMatrix (int childIndex, EmitArgs &parentArgs)
 
SkString invokeChild (int childIndex, const char *inputColor, EmitArgs &parentArgs, std::string_view skslCoords={})
 
SkString invokeChildWithMatrix (int childIndex, const char *inputColor, EmitArgs &parentArgs)
 
SkString invokeChild (int childIndex, const char *inputColor, const char *destColor, EmitArgs &parentArgs, std::string_view skslCoords={})
 
SkString invokeChildWithMatrix (int childIndex, const char *inputColor, const char *destColor, EmitArgs &parentArgs)
 

Protected Member Functions

virtual void emitVertexCode (const GrShaderCaps &, const GrPathTessellationShader &, GrGLSLVertexBuilder *, GrGLSLVaryingHandler *, GrGPArgs *)=0
 

Protected Attributes

GrGLSLUniformHandler::UniformHandle fAffineMatrixUniform
 
GrGLSLUniformHandler::UniformHandle fTranslateUniform
 
GrGLSLUniformHandler::UniformHandle fColorUniform
 
SkString fVaryingColorName
 

Static Protected Attributes

static const char * kEvalRationalCubicFn
 

Additional Inherited Members

- Public Types inherited from GrFragmentProcessor::ProgramImpl
using UniformHandle = GrGLSLUniformHandler::UniformHandle
 
using SamplerHandle = GrGLSLUniformHandler::SamplerHandle
 

Detailed Description

Definition at line 120 of file GrPathTessellationShader.h.

Member Function Documentation

◆ emitVertexCode()

virtual void GrPathTessellationShader::Impl::emitVertexCode ( const GrShaderCaps ,
const GrPathTessellationShader ,
GrGLSLVertexBuilder ,
GrGLSLVaryingHandler ,
GrGPArgs *   
)
protectedpure virtual

◆ onEmitCode()

void GrPathTessellationShader::Impl::onEmitCode ( EmitArgs args,
GrGPArgs *  gpArgs 
)
final

Definition at line 303 of file GrPathTessellationShader.cpp.

303 {
304 const auto& shader = args.fGeomProc.cast<GrPathTessellationShader>();
305 args.fVaryingHandler->emitAttributes(shader);
306
307 // Vertex shader.
308 const char* affineMatrix, *translate;
309 fAffineMatrixUniform = args.fUniformHandler->addUniform(nullptr, kVertex_GrShaderFlag,
310 SkSLType::kFloat4, "affineMatrix",
311 &affineMatrix);
312 fTranslateUniform = args.fUniformHandler->addUniform(nullptr, kVertex_GrShaderFlag,
313 SkSLType::kFloat2, "translate", &translate);
314 args.fVertBuilder->codeAppendf("float2x2 AFFINE_MATRIX = float2x2(%s.xy, %s.zw);",
315 affineMatrix, affineMatrix);
316 args.fVertBuilder->codeAppendf("float2 TRANSLATE = %s;", translate);
317 this->emitVertexCode(*args.fShaderCaps,
318 shader,
319 args.fVertBuilder,
320 args.fVaryingHandler,
321 gpArgs);
322
323 // Fragment shader.
324 if (!(shader.fAttribs & PatchAttribs::kColor)) {
325 const char* color;
326 fColorUniform = args.fUniformHandler->addUniform(nullptr, kFragment_GrShaderFlag,
327 SkSLType::kHalf4, "color", &color);
328 args.fFragBuilder->codeAppendf("half4 %s = %s;", args.fOutputColor, color);
329 } else {
330 args.fFragBuilder->codeAppendf("half4 %s = %s;",
331 args.fOutputColor, fVaryingColorName.c_str());
332 }
333 args.fFragBuilder->codeAppendf("const half4 %s = half4(1);", args.fOutputCoverage);
334}
@ kVertex_GrShaderFlag
Definition: GrTypesPriv.h:286
@ kFragment_GrShaderFlag
Definition: GrTypesPriv.h:287
GrGLSLUniformHandler::UniformHandle fTranslateUniform
GrGLSLUniformHandler::UniformHandle fAffineMatrixUniform
virtual void emitVertexCode(const GrShaderCaps &, const GrPathTessellationShader &, GrGLSLVertexBuilder *, GrGLSLVaryingHandler *, GrGPArgs *)=0
GrGLSLUniformHandler::UniformHandle fColorUniform
const SkPMColor4f & color() const
const char * c_str() const
Definition: SkString.h:133
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args

◆ setData()

void GrPathTessellationShader::Impl::setData ( const GrGLSLProgramDataManager pdman,
const GrShaderCaps ,
const GrGeometryProcessor geomProc 
)
override

Definition at line 336 of file GrPathTessellationShader.cpp.

337 {
338 const auto& shader = geomProc.cast<GrPathTessellationShader>();
339 const SkMatrix& m = shader.viewMatrix();
340 pdman.set4f(fAffineMatrixUniform, m.getScaleX(), m.getSkewY(), m.getSkewX(), m.getScaleY());
341 pdman.set2f(fTranslateUniform, m.getTranslateX(), m.getTranslateY());
342
343 if (!(shader.fAttribs & PatchAttribs::kColor)) {
344 const SkPMColor4f& color = shader.color();
346 }
347}
virtual void set2f(UniformHandle, float, float) const =0
virtual void set4f(UniformHandle, float, float, float, float) const =0
const T & cast() const
Definition: GrProcessor.h:127
float fB
blue component
Definition: SkColor.h:265
float fR
red component
Definition: SkColor.h:263
float fG
green component
Definition: SkColor.h:264
float fA
alpha component
Definition: SkColor.h:266

Member Data Documentation

◆ fAffineMatrixUniform

GrGLSLUniformHandler::UniformHandle GrPathTessellationShader::Impl::fAffineMatrixUniform
protected

Definition at line 141 of file GrPathTessellationShader.h.

◆ fColorUniform

GrGLSLUniformHandler::UniformHandle GrPathTessellationShader::Impl::fColorUniform
protected

Definition at line 143 of file GrPathTessellationShader.h.

◆ fTranslateUniform

GrGLSLUniformHandler::UniformHandle GrPathTessellationShader::Impl::fTranslateUniform
protected

Definition at line 142 of file GrPathTessellationShader.h.

◆ fVaryingColorName

SkString GrPathTessellationShader::Impl::fVaryingColorName
protected

Definition at line 144 of file GrPathTessellationShader.h.

◆ kEvalRationalCubicFn

const char * GrPathTessellationShader::Impl::kEvalRationalCubicFn
staticprotected
Initial value:
=
"float3 safe_mix(float3 a, float3 b, float T, float one_minus_T) {"
"return a*one_minus_T + b*T;"
"}"
"float2 eval_rational_cubic(float4x3 P, float T) {"
"float one_minus_T = 1.0 - T;"
"float3 ab = safe_mix(P[0], P[1], T, one_minus_T);"
"float3 bc = safe_mix(P[1], P[2], T, one_minus_T);"
"float3 cd = safe_mix(P[2], P[3], T, one_minus_T);"
"float3 abc = safe_mix(ab, bc, T, one_minus_T);"
"float3 bcd = safe_mix(bc, cd, T, one_minus_T);"
"float3 abcd = safe_mix(abc, bcd, T, one_minus_T);"
"return abcd.xy / abcd.z;"
"}"

Definition at line 133 of file GrPathTessellationShader.h.


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