Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
SkRecord Class Reference

#include <SkRecord.h>

Inheritance diagram for SkRecord:
SkRefCnt SkRefCntBase

Public Member Functions

 SkRecord ()=default
 
 ~SkRecord () override
 
int count () const
 
template<typename F >
auto visit (int i, F &&f) const -> decltype(f(SkRecords::NoOp()))
 
template<typename F >
auto mutate (int i, F &&f) -> decltype(f((SkRecords::NoOp *) nullptr))
 
template<typename T >
Talloc (size_t count=1)
 
template<typename T >
Tappend ()
 
template<typename T >
Treplace (int i)
 
size_t bytesUsed () const
 
void defrag ()
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Detailed Description

Definition at line 32 of file SkRecord.h.

Constructor & Destructor Documentation

◆ SkRecord()

SkRecord::SkRecord ( )
default

◆ ~SkRecord()

SkRecord::~SkRecord ( )
override

Definition at line 12 of file SkRecord.cpp.

12 {
13 Destroyer destroyer;
14 for (int i = 0; i < this->count(); i++) {
15 this->mutate(i, destroyer);
16 }
17}
auto mutate(int i, F &&f) -> decltype(f((SkRecords::NoOp *) nullptr))
Definition SkRecord.h:54
int count() const
Definition SkRecord.h:38

Member Function Documentation

◆ alloc()

template<typename T >
T * SkRecord::alloc ( size_t  count = 1)
inline

Definition at line 61 of file SkRecord.h.

61 {
62 struct RawBytes {
63 alignas(T) char data[sizeof(T)];
64 };
65 fApproxBytesAllocated += count * sizeof(T) + alignof(T);
66 return (T*)fAlloc.makeArrayDefault<RawBytes>(count);
67 }
T * makeArrayDefault(size_t count)
#define T

◆ append()

template<typename T >
T * SkRecord::append ( )
inline

Definition at line 72 of file SkRecord.h.

72 {
73 if (fCount == fReserved) {
74 this->grow();
75 }
76 return fRecords[fCount++].set(this->allocCommand<T>());
77 }

◆ bytesUsed()

size_t SkRecord::bytesUsed ( ) const

Definition at line 25 of file SkRecord.cpp.

25 {
26 size_t bytes = fApproxBytesAllocated + sizeof(SkRecord);
27 return bytes;
28}
SkRecord()=default

◆ count()

int SkRecord::count ( ) const
inline

Definition at line 38 of file SkRecord.h.

38{ return fCount; }

◆ defrag()

void SkRecord::defrag ( )

Definition at line 30 of file SkRecord.cpp.

30 {
31 // Remove all the NoOps, preserving the order of other ops, e.g.
32 // Save, ClipRect, NoOp, DrawRect, NoOp, NoOp, Restore
33 // -> Save, ClipRect, DrawRect, Restore
34 Record* noops = std::remove_if(fRecords.get(), fRecords.get() + fCount,
35 [](Record op) { return op.type() == SkRecords::NoOp_Type; });
36 fCount = noops - fRecords.get();
37}

◆ mutate()

template<typename F >
auto SkRecord::mutate ( int  i,
F &&  f 
) -> decltype(f((SkRecords::NoOp*)nullptr))
inline

Definition at line 54 of file SkRecord.h.

54 {
55 return fRecords[i].mutate(f);
56 }

◆ replace()

template<typename T >
T * SkRecord::replace ( int  i)
inline

Definition at line 83 of file SkRecord.h.

83 {
84 SkASSERT(i < this->count());
85
86 Destroyer destroyer;
87 this->mutate(i, destroyer);
88
89 return fRecords[i].set(this->allocCommand<T>());
90 }
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ visit()

template<typename F >
auto SkRecord::visit ( int  i,
F &&  f 
) const -> decltype(f(SkRecords::NoOp()))
inline

Definition at line 45 of file SkRecord.h.

45 {
46 return fRecords[i].visit(f);
47 }

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