Skia
2D Graphics Library
SkRuntimeShaderBuilder Class Reference

SkRuntimeShaderBuilder is a utility to simplify creating SkShader objects from SkRuntimeEffects. More...

#include <SkRuntimeEffect.h>

Inheritance diagram for SkRuntimeShaderBuilder:

Public Member Functions

 SkRuntimeShaderBuilder (sk_sp< SkRuntimeEffect >)
 
 SkRuntimeShaderBuilder (const SkRuntimeShaderBuilder &)=default
 
 ~SkRuntimeShaderBuilder ()
 
sk_sp< SkShadermakeShader (const SkMatrix *localMatrix=nullptr) const
 
const SkRuntimeEffecteffect () const
 
BuilderUniform uniform (std::string_view name)
 
BuilderChild child (std::string_view name)
 
sk_sp< const SkDatauniforms () const
 
SkSpan< const SkRuntimeEffect::ChildPtrchildren () const
 

Friends

class SkRuntimeImageFilter
 

Detailed Description

SkRuntimeShaderBuilder is a utility to simplify creating SkShader objects from SkRuntimeEffects.

NOTE: Like SkRuntimeEffect, this API is experimental and subject to change!

Given an SkRuntimeEffect, the SkRuntimeShaderBuilder manages creating an input data block and provides named access to the 'uniform' variables in that block, as well as named access to a list of child shader slots. Usage:

sk_sp<SkRuntimeEffect> effect = ...; SkRuntimeShaderBuilder builder(effect); builder.uniform("some_uniform_float") = 3.14f; builder.uniform("some_uniform_matrix") = SkM44::Rotate(...); builder.child("some_child_effect") = mySkImage->makeShader(...); ... sk_sp<SkShader> shader = builder.makeShader(nullptr, false);

Note that SkRuntimeShaderBuilder is built entirely on the public API of SkRuntimeEffect, so can be used as-is or serve as inspiration for other interfaces or binding techniques.

Constructor & Destructor Documentation

◆ SkRuntimeShaderBuilder() [1/2]

SkRuntimeShaderBuilder::SkRuntimeShaderBuilder ( sk_sp< SkRuntimeEffect )
explicit

◆ SkRuntimeShaderBuilder() [2/2]

SkRuntimeShaderBuilder::SkRuntimeShaderBuilder ( const SkRuntimeShaderBuilder )
default

◆ ~SkRuntimeShaderBuilder()

SkRuntimeShaderBuilder::~SkRuntimeShaderBuilder ( )

Member Function Documentation

◆ child()

BuilderChild SkRuntimeEffectBuilder::child ( std::string_view  name)
inlineinherited

◆ children()

SkSpan<const SkRuntimeEffect::ChildPtr> SkRuntimeEffectBuilder::children ( ) const
inlineinherited

◆ effect()

const SkRuntimeEffect* SkRuntimeEffectBuilder::effect ( ) const
inlineinherited

◆ makeShader()

sk_sp<SkShader> SkRuntimeShaderBuilder::makeShader ( const SkMatrix localMatrix = nullptr) const

◆ uniform()

BuilderUniform SkRuntimeEffectBuilder::uniform ( std::string_view  name)
inlineinherited

◆ uniforms()

sk_sp<const SkData> SkRuntimeEffectBuilder::uniforms ( ) const
inlineinherited

Friends And Related Function Documentation

◆ SkRuntimeImageFilter

friend class SkRuntimeImageFilter
friend

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