Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
skgpu::graphite::PaintParamsKey Class Reference

#include <PaintParamsKey.h>

Classes

struct  Hash
 

Public Member Functions

constexpr PaintParamsKey (const PaintParamsKey &)=default
 
 ~PaintParamsKey ()=default
 
PaintParamsKeyoperator= (const PaintParamsKey &)=default
 
bool isValid () const
 
PaintParamsKey clone (SkArenaAlloc *) const
 
SkSpan< const ShaderNode * > getRootNodes (const ShaderCodeDictionary *, SkArenaAlloc *) const
 
SkString toString (const ShaderCodeDictionary *dict) const
 
bool operator== (const PaintParamsKey &that) const
 
bool operator!= (const PaintParamsKey &that) const
 

Static Public Member Functions

static constexpr PaintParamsKey Invalid ()
 

Friends

class PaintParamsKeyBuilder
 

Detailed Description

Definition at line 36 of file PaintParamsKey.h.

Constructor & Destructor Documentation

◆ PaintParamsKey()

constexpr skgpu::graphite::PaintParamsKey::PaintParamsKey ( const PaintParamsKey )
constexprdefault

◆ ~PaintParamsKey()

skgpu::graphite::PaintParamsKey::~PaintParamsKey ( )
default

Member Function Documentation

◆ clone()

PaintParamsKey skgpu::graphite::PaintParamsKey::clone ( SkArenaAlloc arena) const

Definition at line 54 of file PaintParamsKey.cpp.

54 {
55 int32_t* newData = arena->makeArrayDefault<int32_t>(fData.size());
56 memcpy(newData, fData.data(), fData.size_bytes());
57 return PaintParamsKey({newData, fData.size()});
58}
T * makeArrayDefault(size_t count)
constexpr T * data() const
Definition SkSpan_impl.h:94
constexpr size_t size_bytes() const
Definition SkSpan_impl.h:97
constexpr size_t size() const
Definition SkSpan_impl.h:95
constexpr PaintParamsKey(const PaintParamsKey &)=default

◆ getRootNodes()

SkSpan< const ShaderNode * > skgpu::graphite::PaintParamsKey::getRootNodes ( const ShaderCodeDictionary dict,
SkArenaAlloc arena 
) const

Definition at line 86 of file PaintParamsKey.cpp.

87 {
88 // TODO: Once the PaintParamsKey creation is organized to represent a single tree starting at
89 // the final blend, there will only be a single root node and this can be simplified.
90 // For now, we don't know how many roots there are, so collect them into a local array before
91 // copying into the arena.
92 const int keySize = SkTo<int>(fData.size());
93
94 // Normal PaintParams creation will have up to 7 roots for the different stages.
96 int currentIndex = 0;
97 while (currentIndex < keySize) {
98 const ShaderNode* root = this->createNode(dict, &currentIndex, arena);
99 if (!root) {
100 return {}; // a bad key
101 }
102 roots.push_back(root);
103 }
104
105 // Copy the accumulated roots into a span stored in the arena
106 const ShaderNode** rootSpan = arena->makeArray<const ShaderNode*>(roots.size());
107 memcpy(rootSpan, roots.data(), roots.size_bytes());
108 return SkSpan(rootSpan, roots.size());
109}
T * makeArray(size_t count)

◆ Invalid()

static constexpr PaintParamsKey skgpu::graphite::PaintParamsKey::Invalid ( )
inlinestaticconstexpr

Definition at line 45 of file PaintParamsKey.h.

◆ isValid()

bool skgpu::graphite::PaintParamsKey::isValid ( ) const
inline

Definition at line 46 of file PaintParamsKey.h.

46{ return !fData.empty(); }
constexpr bool empty() const
Definition SkSpan_impl.h:96

◆ operator!=()

bool skgpu::graphite::PaintParamsKey::operator!= ( const PaintParamsKey that) const
inline

Definition at line 72 of file PaintParamsKey.h.

72{ return !(*this == that); }

◆ operator=()

PaintParamsKey & skgpu::graphite::PaintParamsKey::operator= ( const PaintParamsKey )
default

◆ operator==()

bool skgpu::graphite::PaintParamsKey::operator== ( const PaintParamsKey that) const
inline

Definition at line 68 of file PaintParamsKey.h.

68 {
69 return fData.size() == that.fData.size() &&
70 !memcmp(fData.data(), that.fData.data(), fData.size());
71 }

◆ toString()

SkString skgpu::graphite::PaintParamsKey::toString ( const ShaderCodeDictionary dict) const

Definition at line 144 of file PaintParamsKey.cpp.

144 {
145 SkString str;
146 const int keySize = SkTo<int>(fData.size());
147 for (int currentIndex = 0; currentIndex < keySize; ) {
148 currentIndex = key_to_string(&str, dict, fData, currentIndex);
149 }
150 return str.isEmpty() ? SkString("(empty)") : str;
151}
bool isEmpty() const
Definition SkString.h:130
static int key_to_string(SkString *str, const ShaderCodeDictionary *dict, SkSpan< const int32_t > keyData, int currentIndex)

Friends And Related Symbol Documentation

◆ PaintParamsKeyBuilder

friend class PaintParamsKeyBuilder
friend

Definition at line 81 of file PaintParamsKey.h.


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