Flutter Engine
The Flutter Engine
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, bool includeData) 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 41 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 55 of file PaintParamsKey.cpp.

55 {
56 uint32_t* newData = arena->makeArrayDefault<uint32_t>(fData.size());
57 memcpy(newData, fData.data(), fData.size_bytes());
58 return PaintParamsKey({newData, fData.size()});
59}
T * makeArrayDefault(size_t count)
Definition: SkArenaAlloc.h:171
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 108 of file PaintParamsKey.cpp.

109 {
110 // TODO: Once the PaintParamsKey creation is organized to represent a single tree starting at
111 // the final blend, there will only be a single root node and this can be simplified.
112 // For now, we don't know how many roots there are, so collect them into a local array before
113 // copying into the arena.
114 const int keySize = SkTo<int>(fData.size());
115
116 // Normal PaintParams creation will have up to 7 roots for the different stages.
118 int currentIndex = 0;
119 while (currentIndex < keySize) {
120 const ShaderNode* root = this->createNode(dict, &currentIndex, arena);
121 if (!root) {
122 return {}; // a bad key
123 }
124 roots.push_back(root);
125 }
126
127 // Copy the accumulated roots into a span stored in the arena
128 const ShaderNode** rootSpan = arena->makeArray<const ShaderNode*>(roots.size());
129 memcpy(rootSpan, roots.data(), roots.size_bytes());
130 return SkSpan(rootSpan, roots.size());
131}
SkSpan(Container &&) -> SkSpan< std::remove_pointer_t< decltype(std::data(std::declval< Container >()))> >
T * makeArray(size_t count)
Definition: SkArenaAlloc.h:181
string root
Definition: scale_cpu.py:20

◆ Invalid()

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

◆ isValid()

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

Definition at line 51 of file PaintParamsKey.h.

51{ 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 78 of file PaintParamsKey.h.

78{ 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 74 of file PaintParamsKey.h.

74 {
75 return fData.size() == that.fData.size() &&
76 !memcmp(fData.data(), that.fData.data(), fData.size());
77 }

◆ toString()

SkString skgpu::graphite::PaintParamsKey::toString ( const ShaderCodeDictionary dict,
bool  includeData 
) const

Definition at line 188 of file PaintParamsKey.cpp.

188 {
189 SkString str;
190 const int keySize = SkTo<int>(fData.size());
191 for (int currentIndex = 0; currentIndex < keySize;) {
192 currentIndex = key_to_string(&str, dict, fData, currentIndex, includeData);
193 }
194 return str.isEmpty() ? SkString("(empty)") : str;
195}
bool isEmpty() const
Definition: SkString.h:130
static int key_to_string(SkString *str, const ShaderCodeDictionary *dict, SkSpan< const uint32_t > keyData, int currentIndex, bool includeData)

Friends And Related Function Documentation

◆ PaintParamsKeyBuilder

friend class PaintParamsKeyBuilder
friend

Definition at line 87 of file PaintParamsKey.h.


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