Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
SkShaderBase Class Referenceabstract

#include <SkShaderBase.h>

Inheritance diagram for SkShaderBase:
SkShader SkFlattenable SkRefCnt SkRefCntBase SkBitmapProcLegacyShader SkBlendShader SkCTMShader SkColor4Shader SkColorFilterShader SkColorShader SkCoordClampShader SkEmptyShader SkGradientBaseShader SkImageShader SkLocalMatrixShader SkPerlinNoiseShader SkPictureShader SkRuntimeShader SkTransformShader SkTriColorShader SkWorkingColorSpaceShader

Classes

class  Context
 
struct  ContextRec
 
struct  GradientInfo
 

Public Types

enum class  ShaderType { M }
 
enum class  GradientType { kNone , M }
 
enum  Flags { kOpaqueAlpha_Flag = 1 << 0 }
 
- Public Types inherited from SkFlattenable
enum  Type {
  kSkColorFilter_Type , kSkBlender_Type , kSkDrawable_Type , kSkDrawLooper_Type ,
  kSkImageFilter_Type , kSkMaskFilter_Type , kSkPathEffect_Type , kSkShader_Type
}
 
typedef sk_sp< SkFlattenable >(* Factory) (SkReadBuffer &)
 

Public Member Functions

 ~SkShaderBase () override
 
sk_sp< SkShadermakeInvertAlpha () const
 
sk_sp< SkShadermakeWithCTM (const SkMatrix &) const
 
virtual bool isConstant () const
 
virtual ShaderType type () const =0
 
virtual GradientType asGradient (GradientInfo *info=nullptr, SkMatrix *localMatrix=nullptr) const
 
ContextmakeContext (const ContextRec &, SkArenaAlloc *) const
 
bool asLuminanceColor (SkColor4f *) const
 
bool appendRootStages (const SkStageRec &rec, const SkMatrix &ctm) const
 
virtual bool appendStages (const SkStageRec &, const SkShaders::MatrixRec &) const =0
 
virtual SkImageonIsAImage (SkMatrix *, SkTileMode[2]) const
 
virtual SkRuntimeEffectasRuntimeEffect () const
 
Type getFlattenableType () const override
 
virtual sk_sp< SkShadermakeAsALocalMatrixShader (SkMatrix *localMatrix) const
 
- Public Member Functions inherited from SkShader
virtual bool isOpaque () const
 
SkImageisAImage (SkMatrix *localMatrix, SkTileMode xy[2]) const
 
bool isAImage () const
 
sk_sp< SkShadermakeWithLocalMatrix (const SkMatrix &) const
 
sk_sp< SkShadermakeWithColorFilter (sk_sp< SkColorFilter >) const
 
sk_sp< SkShadermakeWithWorkingColorSpace (sk_sp< SkColorSpace >) const
 
- Public Member Functions inherited from SkFlattenable
 SkFlattenable ()
 
virtual Factory getFactory () const =0
 
virtual const char * getTypeName () const =0
 
virtual void flatten (SkWriteBuffer &) const
 
virtual Type getFlattenableType () const =0
 
sk_sp< SkDataserialize (const SkSerialProcs *=nullptr) const
 
size_t serialize (void *memory, size_t memory_size, const SkSerialProcs *=nullptr) const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static Type GetFlattenableType ()
 
static sk_sp< SkShaderBaseDeserialize (const void *data, size_t size, const SkDeserialProcs *procs=nullptr)
 
static void RegisterFlattenables ()
 
static SkMatrix ConcatLocalMatrices (const SkMatrix &parentLM, const SkMatrix &childLM)
 
- Static Public Member Functions inherited from SkFlattenable
static Factory NameToFactory (const char name[])
 
static const char * FactoryToName (Factory)
 
static void Register (const char name[], Factory)
 
static sk_sp< SkFlattenableDeserialize (Type, const void *data, size_t length, const SkDeserialProcs *procs=nullptr)
 

Protected Member Functions

 SkShaderBase ()
 
void flatten (SkWriteBuffer &) const override
 
virtual bool onAsLuminanceColor (SkColor4f *) const
 

Friends

class SkShaders::MatrixRec
 

Detailed Description

Definition at line 186 of file SkShaderBase.h.

Member Enumeration Documentation

◆ Flags

Enumerator
kOpaqueAlpha_Flag 

set if all of the colors will be opaque

Definition at line 260 of file SkShaderBase.h.

260 {
261 //!< set if all of the colors will be opaque
262 kOpaqueAlpha_Flag = 1 << 0,
263 };
@ kOpaqueAlpha_Flag
set if all of the colors will be opaque
Definition: SkShaderBase.h:262

◆ GradientType

enum class SkShaderBase::GradientType
strong
Enumerator
kNone 

Definition at line 207 of file SkShaderBase.h.

207 {
208 kNone,
209#define M(type) k##type,
211#undef M
212 };
#define SK_ALL_GRADIENTS(M)
Definition: SkShaderBase.h:180
@ kNone
Definition: layer.h:53

◆ ShaderType

enum class SkShaderBase::ShaderType
strong
Enumerator

Definition at line 199 of file SkShaderBase.h.

199 {
200#define M(type) k##type,
202#undef M
203 };
#define SK_ALL_SHADERS(M)
Definition: SkShaderBase.h:162

Constructor & Destructor Documentation

◆ ~SkShaderBase()

SkShaderBase::~SkShaderBase ( )
overridedefault

◆ SkShaderBase()

SkShaderBase::SkShaderBase ( )
protecteddefault

Member Function Documentation

◆ appendRootStages()

bool SkShaderBase::appendRootStages ( const SkStageRec rec,
const SkMatrix ctm 
) const

If this returns false, then we draw nothing (do not fall back to shader context). This should only be called on a root-level effect. It assumes that the initial device coordinates have not yet been seeded.

Definition at line 132 of file SkShaderBase.cpp.

132 {
133 return this->appendStages(rec, SkShaders::MatrixRec(ctm));
134}
virtual bool appendStages(const SkStageRec &, const SkShaders::MatrixRec &) const =0

◆ appendStages()

virtual bool SkShaderBase::appendStages ( const SkStageRec ,
const SkShaders::MatrixRec  
) const
pure virtual

Adds stages to implement this shader. To ensure that the correct input coords are present in r,g MatrixRec::apply() must be called (unless the shader doesn't require it's input coords). The default impl creates shadercontext and calls that (not very efficient).

Implemented in SkGradientBaseShader, SkBlendShader, SkCoordClampShader, SkEmptyShader, SkLocalMatrixShader, SkPictureShader, SkCTMShader, SkTransformShader, SkTriColorShader, SkPerlinNoiseShader, and SkRuntimeShader.

◆ asGradient()

virtual GradientType SkShaderBase::asGradient ( GradientInfo info = nullptr,
SkMatrix localMatrix = nullptr 
) const
inlinevirtual

◆ asLuminanceColor()

bool SkShaderBase::asLuminanceColor ( SkColor4f colorPtr) const

If the shader can represent its "average" luminance in a single color, return true and if color is not NULL, return that color. If it cannot, return false and ignore the color parameter.

Note: if this returns true, the returned color will always be opaque, as only the RGB components are used to compute luminance.

Definition at line 82 of file SkShaderBase.cpp.

82 {
83 SkColor4f storage;
84 if (nullptr == colorPtr) {
85 colorPtr = &storage;
86 }
87 if (this->onAsLuminanceColor(colorPtr)) {
88 colorPtr->fA = 1.0f; // we only return opaque
89 return true;
90 }
91 return false;
92}
virtual bool onAsLuminanceColor(SkColor4f *) const
Definition: SkShaderBase.h:406

◆ asRuntimeEffect()

virtual SkRuntimeEffect * SkShaderBase::asRuntimeEffect ( ) const
inlinevirtual

Reimplemented in SkRuntimeShader.

Definition at line 366 of file SkShaderBase.h.

366{ return nullptr; }

◆ ConcatLocalMatrices()

static SkMatrix SkShaderBase::ConcatLocalMatrices ( const SkMatrix parentLM,
const SkMatrix childLM 
)
inlinestatic

Definition at line 384 of file SkShaderBase.h.

384 {
385#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) // b/256873449
386 return SkMatrix::Concat(childLM, parentLM);
387#endif
388 return SkMatrix::Concat(parentLM, childLM);
389 }
static SkMatrix Concat(const SkMatrix &a, const SkMatrix &b)
Definition: SkMatrix.h:1775

◆ Deserialize()

static sk_sp< SkShaderBase > SkShaderBase::Deserialize ( const void *  data,
size_t  size,
const SkDeserialProcs procs = nullptr 
)
inlinestatic

Definition at line 371 of file SkShaderBase.h.

372 {
373 return sk_sp<SkShaderBase>(static_cast<SkShaderBase*>(
375 }
static sk_sp< SkFlattenable > Deserialize(Type, const void *data, size_t length, const SkDeserialProcs *procs=nullptr)
static Type GetFlattenableType()
Definition: SkShaderBase.h:368
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 keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ flatten()

void SkShaderBase::flatten ( SkWriteBuffer ) const
overrideprotectedvirtual

Override this if your subclass needs to record data that it will need to recreate itself from its CreateProc (returned by getFactory()).

DEPRECATED public : will move to protected ... use serialize() instead

Reimplemented from SkFlattenable.

Definition at line 80 of file SkShaderBase.cpp.

80{ this->INHERITED::flatten(buffer); }
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ GetFlattenableType()

static Type SkShaderBase::GetFlattenableType ( )
inlinestatic

Definition at line 368 of file SkShaderBase.h.

368{ return kSkShader_Type; }

◆ getFlattenableType()

Type SkShaderBase::getFlattenableType ( ) const
inlineoverridevirtual

Implements SkFlattenable.

Definition at line 369 of file SkShaderBase.h.

369{ return GetFlattenableType(); }

◆ isConstant()

virtual bool SkShaderBase::isConstant ( ) const
inlinevirtual

Returns true if the shader is guaranteed to produce only a single color. Subclasses can override this to allow loop-hoisting optimization.

Reimplemented in SkColorShader, SkColor4Shader, SkLocalMatrixShader, and SkCTMShader.

Definition at line 197 of file SkShaderBase.h.

197{ return false; }

◆ makeAsALocalMatrixShader()

sk_sp< SkShader > SkShaderBase::makeAsALocalMatrixShader ( SkMatrix localMatrix) const
virtual

DEPRECATED. skbug.com/8941 If this shader can be represented by another shader + a localMatrix, return that shader and the localMatrix. If not, return nullptr and ignore the localMatrix parameter.

Reimplemented in SkLocalMatrixShader.

Definition at line 130 of file SkShaderBase.cpp.

130{ return nullptr; }

◆ makeContext()

SkShaderBase::Context * SkShaderBase::makeContext ( const ContextRec rec,
SkArenaAlloc alloc 
) const

Make a context using the memory provided by the arena.

Returns
pointer to context or nullptr if can't be created

Definition at line 94 of file SkShaderBase.cpp.

94 {
95#ifdef SK_ENABLE_LEGACY_SHADERCONTEXT
96 // We always fall back to raster pipeline when perspective is present.
97 auto totalMatrix = rec.fMatrixRec.totalMatrix();
98 if (totalMatrix.hasPerspective() || !totalMatrix.invert(nullptr)) {
99 return nullptr;
100 }
101
102 return this->onMakeContext(rec, alloc);
103#else
104 return nullptr;
105#endif
106}

◆ makeInvertAlpha()

sk_sp< SkShader > SkShaderBase::makeInvertAlpha ( ) const

Definition at line 141 of file SkShaderBase.cpp.

141 {
143}
@ kSrcOut
r = s * (1-da)
static sk_sp< SkColorFilter > Blend(const SkColor4f &c, sk_sp< SkColorSpace >, SkBlendMode mode)
sk_sp< SkShader > makeWithColorFilter(sk_sp< SkColorFilter >) const
Definition: SkShader.cpp:43

◆ makeWithCTM()

sk_sp< SkShader > SkShaderBase::makeWithCTM ( const SkMatrix postM) const

Definition at line 136 of file SkShaderBase.cpp.

136 {
137 return sk_sp<SkShader>(new SkCTMShader(sk_ref_sp(this), postM));
138}
sk_sp< T > sk_ref_sp(T *obj)
Definition: SkRefCnt.h:381

◆ onAsLuminanceColor()

virtual bool SkShaderBase::onAsLuminanceColor ( SkColor4f ) const
inlineprotectedvirtual

Reimplemented in SkGradientBaseShader, and SkLocalMatrixShader.

Definition at line 406 of file SkShaderBase.h.

406 {
407 return false;
408 }

◆ onIsAImage()

virtual SkImage * SkShaderBase::onIsAImage ( SkMatrix ,
SkTileMode  [2] 
) const
inlinevirtual

Definition at line 362 of file SkShaderBase.h.

362 {
363 return nullptr;
364 }

◆ RegisterFlattenables()

void SkShaderBase::RegisterFlattenables ( )
static

Definition at line 425 of file SkImageShader.cpp.

#define SK_REGISTER_FLATTENABLE(type)

◆ type()

virtual ShaderType SkShaderBase::type ( ) const
pure virtual

Friends And Related Function Documentation

◆ SkShaders::MatrixRec

friend class SkShaders::MatrixRec
friend

Definition at line 410 of file SkShaderBase.h.


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