Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
SkVertices::Sizes Struct Reference

Public Member Functions

 Sizes (const Desc &desc)
 
bool isValid () const
 

Public Attributes

size_t fTotal = 0
 
size_t fArrays
 
size_t fVSize
 
size_t fTSize
 
size_t fCSize
 
size_t fISize
 
size_t fBuilderTriFanISize
 

Detailed Description

Definition at line 41 of file SkVertices.cpp.

Constructor & Destructor Documentation

◆ Sizes()

SkVertices::Sizes::Sizes ( const Desc desc)
inline

Definition at line 42 of file SkVertices.cpp.

42 {
43 SkSafeMath safe;
44
45 fVSize = safe.mul(desc.fVertexCount, sizeof(SkPoint));
46 fTSize = desc.fHasTexs ? safe.mul(desc.fVertexCount, sizeof(SkPoint)) : 0;
47 fCSize = desc.fHasColors ? safe.mul(desc.fVertexCount, sizeof(SkColor)) : 0;
48
50 fISize = safe.mul(desc.fIndexCount, sizeof(uint16_t));
51 if (kTriangleFan_VertexMode == desc.fMode) {
52 int numFanTris = 0;
53 if (desc.fIndexCount) {
55 numFanTris = desc.fIndexCount - 2;
56 } else {
57 numFanTris = desc.fVertexCount - 2;
58 // By forcing this to become indexed we are adding a constraint to the maximum
59 // number of vertices.
60 if (desc.fVertexCount > (SkTo<int>(UINT16_MAX) + 1)) {
61 sk_bzero(this, sizeof(*this));
62 return;
63 }
64 }
65 if (numFanTris <= 0) {
66 sk_bzero(this, sizeof(*this));
67 return;
68 }
69 fISize = safe.mul(numFanTris, 3 * sizeof(uint16_t));
70 }
71
72 fTotal = safe.add(sizeof(SkVertices),
73 safe.add(fVSize,
74 safe.add(fTSize,
75 safe.add(fCSize,
76 fISize))));
77
78 if (safe.ok()) {
79 fArrays = fVSize + fTSize + fCSize + fISize; // just the sum of the arrays
80 } else {
81 sk_bzero(this, sizeof(*this));
82 }
83 }
uint32_t SkColor
Definition SkColor.h:37
static void sk_bzero(void *buffer, size_t size)
Definition SkMalloc.h:105
size_t add(size_t x, size_t y)
Definition SkSafeMath.h:33
bool ok() const
Definition SkSafeMath.h:26
size_t mul(size_t x, size_t y)
Definition SkSafeMath.h:29
@ kTriangleFan_VertexMode
Definition SkVertices.h:33
size_t fBuilderTriFanISize

Member Function Documentation

◆ isValid()

bool SkVertices::Sizes::isValid ( ) const
inline

Definition at line 85 of file SkVertices.cpp.

85{ return fTotal != 0; }

Member Data Documentation

◆ fArrays

size_t SkVertices::Sizes::fArrays

Definition at line 88 of file SkVertices.cpp.

◆ fBuilderTriFanISize

size_t SkVertices::Sizes::fBuilderTriFanISize

Definition at line 96 of file SkVertices.cpp.

◆ fCSize

size_t SkVertices::Sizes::fCSize

Definition at line 91 of file SkVertices.cpp.

◆ fISize

size_t SkVertices::Sizes::fISize

Definition at line 92 of file SkVertices.cpp.

◆ fTotal

size_t SkVertices::Sizes::fTotal = 0

Definition at line 87 of file SkVertices.cpp.

◆ fTSize

size_t SkVertices::Sizes::fTSize

Definition at line 90 of file SkVertices.cpp.

◆ fVSize

size_t SkVertices::Sizes::fVSize

Definition at line 89 of file SkVertices.cpp.


The documentation for this struct was generated from the following file: