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

#include <SkDataTable.h>

Inheritance diagram for SkDataTable:
SkRefCnt SkRefCntBase

Public Types

typedef void(* FreeProc) (void *context)
 

Public Member Functions

bool isEmpty () const
 
int count () const
 
size_t atSize (int index) const
 
const void * at (int index, size_t *size=nullptr) const
 
template<typename T >
const TatT (int index, size_t *size=nullptr) const
 
const char * atStr (int index) const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static sk_sp< SkDataTableMakeEmpty ()
 
static sk_sp< SkDataTableMakeCopyArrays (const void *const *ptrs, const size_t sizes[], int count)
 
static sk_sp< SkDataTableMakeCopyArray (const void *array, size_t elemSize, int count)
 
static sk_sp< SkDataTableMakeArrayProc (const void *array, size_t elemSize, int count, FreeProc proc, void *context)
 

Friends

class SkDataTableBuilder
 

Detailed Description

Like SkData, SkDataTable holds an immutable data buffer. The data buffer is organized into a table of entries, each with a length, so the entries are not required to all be the same size.

Definition at line 23 of file SkDataTable.h.

Member Typedef Documentation

◆ FreeProc

typedef void(* SkDataTable::FreeProc) (void *context)

Definition at line 66 of file SkDataTable.h.

Member Function Documentation

◆ at()

const void * SkDataTable::at ( int  index,
size_t *  size = nullptr 
) const

Return a pointer to the data of the index'th entry in the table. The caller must ensure that index is valid for this table.

Parameters
sizeIf non-null, this returns the byte size of this entry. This will be the same value that atSize(index) would return.

Definition at line 67 of file SkDataTable.cpp.

67 {
68 SkASSERT((unsigned)index < (unsigned)fCount);
69
70 if (fElemSize) {
71 if (size) {
72 *size = fElemSize;
73 }
74 return fU.fElems + index * fElemSize;
75 } else {
76 if (size) {
77 *size = fU.fDir[index].fSize;
78 }
79 return fU.fDir[index].fPtr;
80 }
81}
#define SkASSERT(cond)
Definition: SkAssert.h:116
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

◆ atSize()

size_t SkDataTable::atSize ( int  index) const

Return the size of the index'th entry in the table. The caller must ensure that index is valid for this table.

Definition at line 57 of file SkDataTable.cpp.

57 {
58 SkASSERT((unsigned)index < (unsigned)fCount);
59
60 if (fElemSize) {
61 return fElemSize;
62 } else {
63 return fU.fDir[index].fSize;
64 }
65}

◆ atStr()

const char * SkDataTable::atStr ( int  index) const
inline

Returns the index'th entry as a c-string, and assumes that the trailing null byte had been copied into the table as well.

Definition at line 59 of file SkDataTable.h.

59 {
60 size_t size;
61 const char* str = this->atT<const char>(index, &size);
62 SkASSERT(strlen(str) + 1 == size);
63 return str;
64 }

◆ atT()

template<typename T >
const T * SkDataTable::atT ( int  index,
size_t *  size = nullptr 
) const
inline

Definition at line 51 of file SkDataTable.h.

51 {
52 return reinterpret_cast<const T*>(this->at(index, size));
53 }
const void * at(int index, size_t *size=nullptr) const
Definition: SkDataTable.cpp:67
#define T
Definition: precompiler.cc:65

◆ count()

int SkDataTable::count ( ) const
inline

Return the number of entries in the table. 0 for an empty table

Definition at line 33 of file SkDataTable.h.

33{ return fCount; }

◆ isEmpty()

bool SkDataTable::isEmpty ( ) const
inline

Returns true if the table is empty (i.e. has no entries).

Definition at line 28 of file SkDataTable.h.

28{ return 0 == fCount; }

◆ MakeArrayProc()

sk_sp< SkDataTable > SkDataTable::MakeArrayProc ( const void *  array,
size_t  elemSize,
int  count,
FreeProc  proc,
void *  context 
)
static

Definition at line 130 of file SkDataTable.cpp.

131 {
132 if (count <= 0) {
133 return SkDataTable::MakeEmpty();
134 }
135 return sk_sp<SkDataTable>(new SkDataTable(array, elemSize, count, proc, ctx));
136}
int count() const
Definition: SkDataTable.h:33
static sk_sp< SkDataTable > MakeEmpty()
Definition: SkDataTable.cpp:85

◆ MakeCopyArray()

sk_sp< SkDataTable > SkDataTable::MakeCopyArray ( const void *  array,
size_t  elemSize,
int  count 
)
static

Return a new table that contains a copy of the data in array.

Parameters
arraycontiguous array of data for all elements to be copied.
elemSizebyte-length for a given element.
countthe number of entries to be copied out of array. The number of bytes that will be copied is count * elemSize.

Definition at line 118 of file SkDataTable.cpp.

118 {
119 if (count <= 0) {
120 return SkDataTable::MakeEmpty();
121 }
122
123 size_t bufferSize = elemSize * count;
124 void* buffer = sk_malloc_throw(bufferSize);
125 memcpy(buffer, array, bufferSize);
126
128}
static void malloc_freeproc(void *context)
Definition: SkDataTable.cpp:17
static void * sk_malloc_throw(size_t size)
Definition: SkMalloc.h:67
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

◆ MakeCopyArrays()

sk_sp< SkDataTable > SkDataTable::MakeCopyArrays ( const void *const *  ptrs,
const size_t  sizes[],
int  count 
)
static

Return a new DataTable that contains a copy of the data stored in each "array".

Parameters
ptrsarray of points to each element to be copied into the table.
sizesarray of byte-lengths for each entry in the corresponding ptrs[] array.
countthe number of array elements in ptrs[] and sizes[] to copy.

Definition at line 92 of file SkDataTable.cpp.

93 {
94 if (count <= 0) {
96 }
97
98 size_t dataSize = 0;
99 for (int i = 0; i < count; ++i) {
100 dataSize += sizes[i];
101 }
102
103 size_t bufferSize = count * sizeof(Dir) + dataSize;
104 void* buffer = sk_malloc_throw(bufferSize);
105
106 Dir* dir = (Dir*)buffer;
107 char* elem = (char*)(dir + count);
108 for (int i = 0; i < count; ++i) {
109 dir[i].fPtr = elem;
110 dir[i].fSize = sizes[i];
111 memcpy(elem, ptrs[i], sizes[i]);
112 elem += sizes[i];
113 }
114
116}
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 Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir
Definition: switches.h:145

◆ MakeEmpty()

sk_sp< SkDataTable > SkDataTable::MakeEmpty ( )
static

Definition at line 85 of file SkDataTable.cpp.

85 {
86 static SkDataTable* singleton;
87 static SkOnce once;
88 once([]{ singleton = new SkDataTable(); });
89 return sk_ref_sp(singleton);
90}
sk_sp< T > sk_ref_sp(T *obj)
Definition: SkRefCnt.h:381
Definition: SkOnce.h:22

Friends And Related Function Documentation

◆ SkDataTableBuilder

friend class SkDataTableBuilder
friend

Definition at line 117 of file SkDataTable.h.

Member Data Documentation

◆ fDir

const Dir* SkDataTable::fDir

Definition at line 104 of file SkDataTable.h.

◆ fElems

const char* SkDataTable::fElems

Definition at line 105 of file SkDataTable.h.


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