Flutter Engine
The Flutter Engine
Functions
GrGLSLBlend Namespace Reference

Functions

std::string BlendExpression (const GrProcessor *processor, GrGLSLUniformHandler *uniformHandler, GrGLSLProgramDataManager::UniformHandle *blendUniform, const char *srcColor, const char *dstColor, SkBlendMode mode)
 
int BlendKey (SkBlendMode mode)
 
void SetBlendModeUniformData (const GrGLSLProgramDataManager &pdman, GrGLSLProgramDataManager::UniformHandle blendUniform, SkBlendMode mode)
 

Function Documentation

◆ BlendExpression()

std::string GrGLSLBlend::BlendExpression ( const GrProcessor processor,
GrGLSLUniformHandler uniformHandler,
GrGLSLProgramDataManager::UniformHandle *  uniform,
const char *  srcColor,
const char *  dstColor,
SkBlendMode  mode 
)

Returns an SkSL expression that blends the passed-in srcColor and dstColor values. Matching calls to SetBlendModeUniformData and BlendKey must be made from your GrProcessor.

Definition at line 20 of file GrGLSLBlend.cpp.

25 {
27 if (info.fUniformData.empty()) {
28 return SkSL::String::printf("%s(%s, %s)", info.fFunction, srcColor, dstColor);
29 }
30
31 SkSLType skslType = (SkSLType)((int)SkSLType::kHalf + info.fUniformData.size() - 1);
32 SkASSERT(skslType >= SkSLType::kHalf && skslType <= SkSLType::kHalf4);
33
34 const char* blendUniName;
35 *blendUniform = uniformHandler->addUniform(processor, kFragment_GrShaderFlag,
36 skslType, "blend", &blendUniName);
37 return SkSL::String::printf("%s(%s, %s, %s)", info.fFunction, blendUniName, srcColor, dstColor);
38}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
@ kFragment_GrShaderFlag
Definition: GrTypesPriv.h:287
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkSLType
UniformHandle addUniform(const GrProcessor *owner, uint32_t visibility, SkSLType type, const char *name, const char **outName=nullptr)
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: SkSLString.cpp:83
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
ReducedBlendModeInfo GetReducedBlendModeInfo(SkBlendMode mode)
Definition: Blend.cpp:86

◆ BlendKey()

int GrGLSLBlend::BlendKey ( SkBlendMode  mode)

Returns a key, for use in onAddToKey from any GrProcessor. You must pass the same blend mode that was passed to BlendExpression

Definition at line 40 of file GrGLSLBlend.cpp.

40 {
41 switch (mode) {
52 return -1;
53
58 return -2;
59
62 return -3;
63
66 return -4;
67
68 default:
69 return (int)mode;
70 }
71}
@ kSrcOut
r = s * (1-da)
@ kSaturation
saturation of source with hue and luminosity of destination
@ kPlus
r = min(s + d, 1)
@ kLighten
rc = s + d - min(s*da, d*sa), ra = kSrcOver
@ kHue
hue of source with saturation and luminosity of destination
@ kDstIn
r = d * sa
@ kSrcOver
r = s + (1-sa)*d
@ kXor
r = s*(1-da) + d*(1-sa)
@ kLuminosity
luminosity of source with hue and saturation of destination
@ kOverlay
multiply or screen, depending on destination
@ kSrcATop
r = s*da + d*(1-sa)
@ kDstATop
r = d*sa + s*(1-da)
@ kDstOver
r = d + (1-da)*s
@ kColor
hue and saturation of source with luminosity of destination
@ kHardLight
multiply or screen, depending on source
@ kDstOut
r = d * (1-sa)
@ kDarken
rc = s + d - max(s*da, d*sa), ra = kSrcOver
@ kSrcIn
r = s * da

◆ SetBlendModeUniformData()

void GrGLSLBlend::SetBlendModeUniformData ( const GrGLSLProgramDataManager pdman,
GrGLSLProgramDataManager::UniformHandle  uniform,
SkBlendMode  mode 
)

Sets up uniforms, for use in onSetData from any GrProcessor. You must pass the same uniform and blend mode that were passed to BlendExpression.

Definition at line 73 of file GrGLSLBlend.cpp.

75 {
77 switch (info.fUniformData.size()) {
78 case 0:
79 /* no uniform data necessary */
80 break;
81 case 1:
82 pdman.set1f(blendUniform, info.fUniformData[0]);
83 break;
84 case 2:
85 pdman.set2f(blendUniform, info.fUniformData[0], info.fUniformData[1]);
86 break;
87 case 3:
88 pdman.set3f(blendUniform, info.fUniformData[0], info.fUniformData[1],
89 info.fUniformData[2]);
90 break;
91 case 4:
92 pdman.set4f(blendUniform, info.fUniformData[0], info.fUniformData[1],
93 info.fUniformData[2], info.fUniformData[3]);
94 break;
95 }
96}
virtual void set2f(UniformHandle, float, float) const =0
virtual void set4f(UniformHandle, float, float, float, float) const =0
virtual void set3f(UniformHandle, float, float, float) const =0
virtual void set1f(UniformHandle, float v0) const =0