Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
SkRuntimeEffect Class Reference

#include <SkRuntimeEffect.h>

Inheritance diagram for SkRuntimeEffect:
SkRefCnt SkRefCntBase

Classes

struct  Child
 
class  ChildPtr
 
class  Options
 
struct  Result
 
struct  TracedShader
 
struct  Uniform
 

Public Types

enum class  ChildType { kShader , kColorFilter , kBlender }
 

Public Member Functions

sk_sp< SkShadermakeShader (sk_sp< const SkData > uniforms, sk_sp< SkShader > children[], size_t childCount, const SkMatrix *localMatrix=nullptr) const
 
sk_sp< SkShadermakeShader (sk_sp< const SkData > uniforms, SkSpan< const ChildPtr > children, const SkMatrix *localMatrix=nullptr) const
 
sk_sp< SkColorFiltermakeColorFilter (sk_sp< const SkData > uniforms) const
 
sk_sp< SkColorFiltermakeColorFilter (sk_sp< const SkData > uniforms, sk_sp< SkColorFilter > children[], size_t childCount) const
 
sk_sp< SkColorFiltermakeColorFilter (sk_sp< const SkData > uniforms, SkSpan< const ChildPtr > children) const
 
sk_sp< SkBlendermakeBlender (sk_sp< const SkData > uniforms, SkSpan< const ChildPtr > children={}) const
 
const std::string & source () const
 
size_t uniformSize () const
 
SkSpan< const Uniformuniforms () const
 
SkSpan< const Childchildren () const
 
const UniformfindUniform (std::string_view name) const
 
const ChildfindChild (std::string_view name) const
 
bool allowShader () const
 
bool allowColorFilter () const
 
bool allowBlender () const
 
 ~SkRuntimeEffect () override
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static Result MakeForColorFilter (SkString sksl, const Options &)
 
static Result MakeForColorFilter (SkString sksl)
 
static Result MakeForShader (SkString sksl, const Options &)
 
static Result MakeForShader (SkString sksl)
 
static Result MakeForBlender (SkString sksl, const Options &)
 
static Result MakeForBlender (SkString sksl)
 
static TracedShader MakeTraced (sk_sp< SkShader > shader, const SkIPoint &traceCoord)
 
static void RegisterFlattenables ()
 

Friends

class GrSkSLFP
 
class SkRuntimeShader
 
class SkRuntimeBlender
 
class SkRuntimeColorFilter
 
class SkRuntimeEffectPriv
 

Detailed Description

Definition at line 59 of file SkRuntimeEffect.h.

Member Enumeration Documentation

◆ ChildType

enum class SkRuntimeEffect::ChildType
strong
Enumerator
kShader 
kColorFilter 
kBlender 

Definition at line 111 of file SkRuntimeEffect.h.

111 {
112 kShader,
114 kBlender,
115 };

Constructor & Destructor Documentation

◆ ~SkRuntimeEffect()

SkRuntimeEffect::~SkRuntimeEffect ( )
overridedefault

Member Function Documentation

◆ allowBlender()

bool SkRuntimeEffect::allowBlender ( ) const
inline

Definition at line 265 of file SkRuntimeEffect.h.

265{ return (fFlags & kAllowBlender_Flag); }

◆ allowColorFilter()

bool SkRuntimeEffect::allowColorFilter ( ) const
inline

Definition at line 264 of file SkRuntimeEffect.h.

264{ return (fFlags & kAllowColorFilter_Flag); }

◆ allowShader()

bool SkRuntimeEffect::allowShader ( ) const
inline

Definition at line 263 of file SkRuntimeEffect.h.

263{ return (fFlags & kAllowShader_Flag); }

◆ children()

SkSpan< const Child > SkRuntimeEffect::children ( ) const
inline

Definition at line 254 of file SkRuntimeEffect.h.

254{ return SkSpan(fChildren); }
SkSpan(Container &&) -> SkSpan< std::remove_pointer_t< decltype(std::data(std::declval< Container >()))> >

◆ findChild()

const SkRuntimeEffect::Child * SkRuntimeEffect::findChild ( std::string_view  name) const

Definition at line 791 of file SkRuntimeEffect.cpp.

791 {
792 auto iter = std::find_if(fChildren.begin(), fChildren.end(), [name](const Child& c) {
793 return c.name == name;
794 });
795 return iter == fChildren.end() ? nullptr : &(*iter);
796}
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ findUniform()

const SkRuntimeEffect::Uniform * SkRuntimeEffect::findUniform ( std::string_view  name) const

Definition at line 784 of file SkRuntimeEffect.cpp.

784 {
785 auto iter = std::find_if(fUniforms.begin(), fUniforms.end(), [name](const Uniform& u) {
786 return u.name == name;
787 });
788 return iter == fUniforms.end() ? nullptr : &(*iter);
789}

◆ makeBlender()

sk_sp< SkBlender > SkRuntimeEffect::makeBlender ( sk_sp< const SkData uniforms,
SkSpan< const ChildPtr children = {} 
) const

Definition at line 885 of file SkRuntimeEffect.cpp.

886 {
887 if (!this->allowBlender()) {
888 return nullptr;
889 }
890 if (!verify_child_effects(fChildren, children)) {
891 return nullptr;
892 }
893 if (!uniforms) {
895 }
896 if (uniforms->size() != this->uniformSize()) {
897 return nullptr;
898 }
899 return sk_make_sp<SkRuntimeBlender>(sk_ref_sp(this), std::move(uniforms), children);
900}
sk_sp< T > sk_ref_sp(T *obj)
Definition: SkRefCnt.h:381
static bool verify_child_effects(const std::vector< SkRuntimeEffect::Child > &reflected, SkSpan< const SkRuntimeEffect::ChildPtr > effectPtrs)
static sk_sp< SkData > MakeEmpty()
Definition: SkData.cpp:94
SkSpan< const Child > children() const
bool allowBlender() const
SkSpan< const Uniform > uniforms() const

◆ makeColorFilter() [1/3]

sk_sp< SkColorFilter > SkRuntimeEffect::makeColorFilter ( sk_sp< const SkData uniforms) const

Definition at line 881 of file SkRuntimeEffect.cpp.

881 {
882 return this->makeColorFilter(std::move(uniforms), /*children=*/{});
883}
sk_sp< SkColorFilter > makeColorFilter(sk_sp< const SkData > uniforms) const

◆ makeColorFilter() [2/3]

sk_sp< SkColorFilter > SkRuntimeEffect::makeColorFilter ( sk_sp< const SkData uniforms,
sk_sp< SkColorFilter children[],
size_t  childCount 
) const

Definition at line 854 of file SkRuntimeEffect.cpp.

856 {
857 STArray<4, ChildPtr> children(childCount);
858 for (size_t i = 0; i < childCount; ++i) {
859 children.emplace_back(childColorFilters[i]);
860 }
861 return this->makeColorFilter(std::move(uniforms), SkSpan(children));
862}

◆ makeColorFilter() [3/3]

sk_sp< SkColorFilter > SkRuntimeEffect::makeColorFilter ( sk_sp< const SkData uniforms,
SkSpan< const ChildPtr children 
) const

Definition at line 864 of file SkRuntimeEffect.cpp.

865 {
866 if (!this->allowColorFilter()) {
867 return nullptr;
868 }
869 if (!verify_child_effects(fChildren, children)) {
870 return nullptr;
871 }
872 if (!uniforms) {
874 }
875 if (uniforms->size() != this->uniformSize()) {
876 return nullptr;
877 }
878 return sk_make_sp<SkRuntimeColorFilter>(sk_ref_sp(this), std::move(uniforms), children);
879}
bool allowColorFilter() const

◆ MakeForBlender() [1/2]

static Result SkRuntimeEffect::MakeForBlender ( SkString  sksl)
inlinestatic

Definition at line 180 of file SkRuntimeEffect.h.

180 {
181 return MakeForBlender(std::move(sksl), Options{});
182 }
static Result MakeForBlender(SkString sksl, const Options &)

◆ MakeForBlender() [2/2]

SkRuntimeEffect::Result SkRuntimeEffect::MakeForBlender ( SkString  sksl,
const Options options 
)
static

Definition at line 672 of file SkRuntimeEffect.cpp.

672 {
675 auto result = MakeFromSource(std::move(sksl), options, programKind);
676 SkASSERT(!result.effect || result.effect->allowBlender());
677 return result;
678}
const char * options
#define SkASSERT(cond)
Definition: SkAssert.h:116
GAsyncResult * result
string programKind
Definition: minify_sksl.py:40

◆ MakeForColorFilter() [1/2]

static Result SkRuntimeEffect::MakeForColorFilter ( SkString  sksl)
inlinestatic

Definition at line 166 of file SkRuntimeEffect.h.

166 {
167 return MakeForColorFilter(std::move(sksl), Options{});
168 }
static Result MakeForColorFilter(SkString sksl, const Options &)

◆ MakeForColorFilter() [2/2]

SkRuntimeEffect::Result SkRuntimeEffect::MakeForColorFilter ( SkString  sksl,
const Options options 
)
static

Definition at line 656 of file SkRuntimeEffect.cpp.

656 {
659 auto result = MakeFromSource(std::move(sksl), options, programKind);
660 SkASSERT(!result.effect || result.effect->allowColorFilter());
661 return result;
662}

◆ MakeForShader() [1/2]

static Result SkRuntimeEffect::MakeForShader ( SkString  sksl)
inlinestatic

Definition at line 173 of file SkRuntimeEffect.h.

173 {
174 return MakeForShader(std::move(sksl), Options{});
175 }
static Result MakeForShader(SkString sksl, const Options &)

◆ MakeForShader() [2/2]

SkRuntimeEffect::Result SkRuntimeEffect::MakeForShader ( SkString  sksl,
const Options options 
)
static

Definition at line 664 of file SkRuntimeEffect.cpp.

664 {
667 auto result = MakeFromSource(std::move(sksl), options, programKind);
668 SkASSERT(!result.effect || result.effect->allowShader());
669 return result;
670}

◆ makeShader() [1/2]

sk_sp< SkShader > SkRuntimeEffect::makeShader ( sk_sp< const SkData uniforms,
sk_sp< SkShader children[],
size_t  childCount,
const SkMatrix localMatrix = nullptr 
) const

Definition at line 821 of file SkRuntimeEffect.cpp.

824 {
825 STArray<4, ChildPtr> children(childCount);
826 for (size_t i = 0; i < childCount; ++i) {
827 children.emplace_back(childShaders[i]);
828 }
829 return this->makeShader(std::move(uniforms), SkSpan(children), localMatrix);
830}
sk_sp< SkShader > makeShader(sk_sp< const SkData > uniforms, sk_sp< SkShader > children[], size_t childCount, const SkMatrix *localMatrix=nullptr) const

◆ makeShader() [2/2]

sk_sp< SkShader > SkRuntimeEffect::makeShader ( sk_sp< const SkData uniforms,
SkSpan< const ChildPtr children,
const SkMatrix localMatrix = nullptr 
) const

Definition at line 832 of file SkRuntimeEffect.cpp.

834 {
835 if (!this->allowShader()) {
836 return nullptr;
837 }
838 if (!verify_child_effects(fChildren, children)) {
839 return nullptr;
840 }
841 if (!uniforms) {
843 }
844 if (uniforms->size() != this->uniformSize()) {
845 return nullptr;
846 }
847 return SkLocalMatrixShader::MakeWrapped<SkRuntimeShader>(localMatrix,
848 sk_ref_sp(this),
849 /*debugTrace=*/nullptr,
850 std::move(uniforms),
851 children);
852}
bool allowShader() const

◆ MakeTraced()

SkRuntimeEffect::TracedShader SkRuntimeEffect::MakeTraced ( sk_sp< SkShader shader,
const SkIPoint traceCoord 
)
static

Definition at line 904 of file SkRuntimeEffect.cpp.

905 {
906 SkRuntimeEffect* effect = as_SB(shader)->asRuntimeEffect();
907 if (!effect) {
908 return TracedShader{nullptr, nullptr};
909 }
910 // An SkShader with an attached SkRuntimeEffect must be an SkRuntimeShader.
911 SkRuntimeShader* rtShader = static_cast<SkRuntimeShader*>(shader.get());
912 return rtShader->makeTracedClone(traceCoord);
913}
SkShaderBase * as_SB(SkShader *shader)
Definition: SkShaderBase.h:412
SkRuntimeEffect::TracedShader makeTracedClone(const SkIPoint &coord)
virtual SkRuntimeEffect * asRuntimeEffect() const
Definition: SkShaderBase.h:366
T * get() const
Definition: SkRefCnt.h:303

◆ RegisterFlattenables()

void SkRuntimeEffect::RegisterFlattenables ( )
static

Definition at line 953 of file SkRuntimeEffect.cpp.

953 {
957
958 // Previous name
959 SkFlattenable::Register("SkRTShader", SkRuntimeShader::CreateProc);
960}
#define SK_REGISTER_FLATTENABLE(type)
static void Register(const char name[], Factory)

◆ source()

const std::string & SkRuntimeEffect::source ( ) const

Definition at line 775 of file SkRuntimeEffect.cpp.

775 {
776 return *fBaseProgram->fSource;
777}

◆ uniforms()

SkSpan< const Uniform > SkRuntimeEffect::uniforms ( ) const
inline

Definition at line 253 of file SkRuntimeEffect.h.

253{ return SkSpan(fUniforms); }

◆ uniformSize()

size_t SkRuntimeEffect::uniformSize ( ) const

Definition at line 779 of file SkRuntimeEffect.cpp.

779 {
780 return fUniforms.empty() ? 0
781 : SkAlign4(fUniforms.back().offset + fUniforms.back().sizeInBytes());
782}
static constexpr T SkAlign4(T x)
Definition: SkAlign.h:16

Friends And Related Function Documentation

◆ GrSkSLFP

friend class GrSkSLFP
friend

Definition at line 310 of file SkRuntimeEffect.h.

◆ SkRuntimeBlender

friend class SkRuntimeBlender
friend

Definition at line 312 of file SkRuntimeEffect.h.

◆ SkRuntimeColorFilter

friend class SkRuntimeColorFilter
friend

Definition at line 313 of file SkRuntimeEffect.h.

◆ SkRuntimeEffectPriv

friend class SkRuntimeEffectPriv
friend

Definition at line 315 of file SkRuntimeEffect.h.

◆ SkRuntimeShader

friend class SkRuntimeShader
friend

Definition at line 311 of file SkRuntimeEffect.h.


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