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

#include <SkDescriptor.h>

Inheritance diagram for SkDescriptor:
SkNoncopyable

Classes

struct  Entry
 

Public Member Functions

void operator delete (void *p)
 
void * operator new (size_t)
 
void * operator new (size_t, void *p)
 
void flatten (SkWriteBuffer &buffer) const
 
uint32_t getLength () const
 
void * addEntry (uint32_t tag, size_t length, const void *data=nullptr)
 
void computeChecksum ()
 
bool isValid () const
 
const void * findEntry (uint32_t tag, uint32_t *length) const
 
std::unique_ptr< SkDescriptorcopy () const
 
bool operator== (const SkDescriptor &other) const
 
bool operator!= (const SkDescriptor &other) const
 
uint32_t getChecksum () const
 
uint32_t getCount () const
 
SkString dumpRec () const
 

Static Public Member Functions

static size_t ComputeOverhead (int entryCount)
 
static std::unique_ptr< SkDescriptorAlloc (size_t length)
 

Friends

class SkDescriptorTestHelper
 
class SkAutoDescriptor
 

Detailed Description

Definition at line 25 of file SkDescriptor.h.

Member Function Documentation

◆ addEntry()

void * SkDescriptor::addEntry ( uint32_t  tag,
size_t  length,
const void *  data = nullptr 
)

Definition at line 35 of file SkDescriptor.cpp.

35 {
36 SkASSERT(tag);
38 SkASSERT(this->findEntry(tag, nullptr) == nullptr);
39
40 Entry* entry = (Entry*)((char*)this + fLength);
41 entry->fTag = tag;
42 entry->fLen = SkToU32(length);
43 if (data) {
44 memcpy(entry + 1, data, length);
45 }
46
47 fCount += 1;
48 fLength = SkToU32(fLength + sizeof(Entry) + length);
49 return (entry + 1); // return its data
50}
static constexpr T SkAlign4(T x)
Definition: SkAlign.h:16
#define SkASSERT(cond)
Definition: SkAssert.h:116
constexpr uint32_t SkToU32(S x)
Definition: SkTo.h:26
const void * findEntry(uint32_t tag, uint32_t *length) const
size_t length
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ Alloc()

std::unique_ptr< SkDescriptor > SkDescriptor::Alloc ( size_t  length)
static

Definition at line 20 of file SkDescriptor.cpp.

20 {
22 void* allocation = ::operator new(length);
23 return std::unique_ptr<SkDescriptor>(new (allocation) SkDescriptor{});
24}

◆ computeChecksum()

void SkDescriptor::computeChecksum ( )

Definition at line 52 of file SkDescriptor.cpp.

52 {
53 fChecksum = SkDescriptor::ComputeChecksum(this);
54}

◆ ComputeOverhead()

static size_t SkDescriptor::ComputeOverhead ( int  entryCount)
inlinestatic

Definition at line 27 of file SkDescriptor.h.

27 {
28 SkASSERT(entryCount >= 0);
29 return sizeof(SkDescriptor) + entryCount * sizeof(Entry);
30 }

◆ copy()

std::unique_ptr< SkDescriptor > SkDescriptor::copy ( ) const

Definition at line 72 of file SkDescriptor.cpp.

72 {
73 std::unique_ptr<SkDescriptor> desc = SkDescriptor::Alloc(fLength);
74 memcpy(desc.get(), this, fLength);
75 return desc;
76}
static std::unique_ptr< SkDescriptor > Alloc(size_t length)

◆ dumpRec()

SkString SkDescriptor::dumpRec ( ) const

Definition at line 93 of file SkDescriptor.cpp.

93 {
94 const SkScalerContextRec* rec = static_cast<const SkScalerContextRec*>(
95 this->findEntry(kRec_SkDescriptorTag, nullptr));
96
98 result.appendf(" Checksum: %x\n", fChecksum);
99 if (rec != nullptr) {
100 result.append(rec->dump());
101 }
102 return result;
103}
#define kRec_SkDescriptorTag
GAsyncResult * result
SkString dump() const

◆ findEntry()

const void * SkDescriptor::findEntry ( uint32_t  tag,
uint32_t *  length 
) const

Definition at line 56 of file SkDescriptor.cpp.

56 {
57 const Entry* entry = (const Entry*)(this + 1);
58 int count = fCount;
59
60 while (--count >= 0) {
61 if (entry->fTag == tag) {
62 if (length) {
63 *length = entry->fLen;
64 }
65 return entry + 1;
66 }
67 entry = (const Entry*)((const char*)(entry + 1) + entry->fLen);
68 }
69 return nullptr;
70}
int count
Definition: FontMgrTest.cpp:50

◆ flatten()

void SkDescriptor::flatten ( SkWriteBuffer buffer) const

Definition at line 31 of file SkDescriptor.cpp.

31 {
32 buffer.writePad32(static_cast<const void*>(this), this->fLength);
33}
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

◆ getChecksum()

uint32_t SkDescriptor::getChecksum ( ) const
inline

Definition at line 64 of file SkDescriptor.h.

64{ return fChecksum; }

◆ getCount()

uint32_t SkDescriptor::getCount ( ) const
inline

Definition at line 71 of file SkDescriptor.h.

71{ return fCount; }

◆ getLength()

uint32_t SkDescriptor::getLength ( ) const
inline

Definition at line 42 of file SkDescriptor.h.

42{ return fLength; }

◆ isValid()

bool SkDescriptor::isValid ( ) const

Definition at line 111 of file SkDescriptor.cpp.

111 {
112 uint32_t count = fCount;
113 size_t lengthRemaining = this->fLength;
114 if (lengthRemaining < sizeof(SkDescriptor)) {
115 return false;
116 }
117 lengthRemaining -= sizeof(SkDescriptor);
118 size_t offset = sizeof(SkDescriptor);
119
120 while (lengthRemaining > 0 && count > 0) {
121 if (lengthRemaining < sizeof(Entry)) {
122 return false;
123 }
124 lengthRemaining -= sizeof(Entry);
125
126 const Entry* entry = (const Entry*)(reinterpret_cast<const char*>(this) + offset);
127
128 if (lengthRemaining < entry->fLen) {
129 return false;
130 }
131 lengthRemaining -= entry->fLen;
132
133 // rec tags are always a known size.
134 if (entry->fTag == kRec_SkDescriptorTag && entry->fLen != sizeof(SkScalerContextRec)) {
135 return false;
136 }
137
138 offset += sizeof(Entry) + entry->fLen;
139 count--;
140 }
141 return lengthRemaining == 0 && count == 0;
142}
SeparatedVector2 offset

◆ operator delete()

void SkDescriptor::operator delete ( void *  p)

Definition at line 26 of file SkDescriptor.cpp.

26{ ::operator delete(p); }

◆ operator new() [1/2]

void * SkDescriptor::operator new ( size_t  )

Definition at line 27 of file SkDescriptor.cpp.

27 {
28 SK_ABORT("Descriptors are created with placement new.");
29}
#define SK_ABORT(message,...)
Definition: SkAssert.h:70

◆ operator new() [2/2]

void * SkDescriptor::operator new ( size_t  ,
void *  p 
)
inline

Definition at line 38 of file SkDescriptor.h.

38{ return p; }

◆ operator!=()

bool SkDescriptor::operator!= ( const SkDescriptor other) const
inline

Definition at line 62 of file SkDescriptor.h.

62{ return !(*this == other); }

◆ operator==()

bool SkDescriptor::operator== ( const SkDescriptor other) const

Definition at line 78 of file SkDescriptor.cpp.

78 {
79 // the first value we should look at is the checksum, so this loop
80 // should terminate early if they descriptors are different.
81 // NOTE: if we wrote a sentinel value at the end of each, we could
82 // remove the aa < stop test in the loop...
83 const uint32_t* aa = (const uint32_t*)this;
84 const uint32_t* bb = (const uint32_t*)&other;
85 const uint32_t* stop = (const uint32_t*)((const char*)aa + fLength);
86 do {
87 if (*aa++ != *bb++)
88 return false;
89 } while (aa < stop);
90 return true;
91}

Friends And Related Function Documentation

◆ SkAutoDescriptor

friend class SkAutoDescriptor
friend

Definition at line 78 of file SkDescriptor.h.

◆ SkDescriptorTestHelper

friend class SkDescriptorTestHelper
friend

Definition at line 77 of file SkDescriptor.h.


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