Flutter Engine
The Flutter Engine
Public Member Functions | Friends | List of all members
SkVertices::Builder Class Reference

#include <SkVertices.h>

Public Member Functions

 Builder (VertexMode mode, int vertexCount, int indexCount, uint32_t flags)
 
bool isValid () const
 
SkPointpositions ()
 
uint16_t * indices ()
 
SkPointtexCoords ()
 
SkColorcolors ()
 
sk_sp< SkVerticesdetach ()
 

Friends

class SkVertices
 
class SkVerticesPriv
 

Detailed Description

Definition at line 66 of file SkVertices.h.

Constructor & Destructor Documentation

◆ Builder()

SkVertices::Builder::Builder ( VertexMode  mode,
int  vertexCount,
int  indexCount,
uint32_t  flags 
)

Definition at line 99 of file SkVertices.cpp.

100 {
101 bool hasTexs = SkToBool(builderFlags & SkVertices::kHasTexCoords_BuilderFlag);
102 bool hasColors = SkToBool(builderFlags & SkVertices::kHasColors_BuilderFlag);
103 this->init({mode, vertexCount, indexCount, hasTexs, hasColors});
104}
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
@ kHasTexCoords_BuilderFlag
Definition: SkVertices.h:63
@ kHasColors_BuilderFlag
Definition: SkVertices.h:64
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 mode
Definition: switches.h:228

Member Function Documentation

◆ colors()

SkColor * SkVertices::Builder::colors ( )

Definition at line 184 of file SkVertices.cpp.

184 {
185 return fVertices ? const_cast<SkColor*>(fVertices->fColors) : nullptr;
186}
uint32_t SkColor
Definition: SkColor.h:37

◆ detach()

sk_sp< SkVertices > SkVertices::Builder::detach ( )

Definition at line 146 of file SkVertices.cpp.

146 {
147 if (fVertices) {
148 fVertices->fBounds.setBounds(fVertices->fPositions, fVertices->fVertexCount);
149 if (fVertices->fMode == kTriangleFan_VertexMode) {
150 if (fIntermediateFanIndices) {
151 SkASSERT(fVertices->fIndexCount);
152 auto tempIndices = this->indices();
153 for (int t = 0; t < fVertices->fIndexCount - 2; ++t) {
154 fVertices->fIndices[3 * t + 0] = tempIndices[0];
155 fVertices->fIndices[3 * t + 1] = tempIndices[t + 1];
156 fVertices->fIndices[3 * t + 2] = tempIndices[t + 2];
157 }
158 fVertices->fIndexCount = 3 * (fVertices->fIndexCount - 2);
159 } else {
160 SkASSERT(!fVertices->fIndexCount);
161 for (int t = 0; t < fVertices->fVertexCount - 2; ++t) {
162 fVertices->fIndices[3 * t + 0] = 0;
163 fVertices->fIndices[3 * t + 1] = SkToU16(t + 1);
164 fVertices->fIndices[3 * t + 2] = SkToU16(t + 2);
165 }
166 fVertices->fIndexCount = 3 * (fVertices->fVertexCount - 2);
167 }
168 fVertices->fMode = kTriangles_VertexMode;
169 }
170 fVertices->fUniqueID = next_id();
171 return std::move(fVertices); // this will null fVertices after the return
172 }
173 return nullptr;
174}
#define SkASSERT(cond)
Definition: SkAssert.h:116
constexpr uint16_t SkToU16(S x)
Definition: SkTo.h:24
static uint32_t next_id()
Definition: SkVertices.cpp:23
uint16_t * indices()
Definition: SkVertices.cpp:188
@ kTriangleFan_VertexMode
Definition: SkVertices.h:33
@ kTriangles_VertexMode
Definition: SkVertices.h:31
void setBounds(const SkPoint pts[], int count)
Definition: SkRect.h:881

◆ indices()

uint16_t * SkVertices::Builder::indices ( )

Definition at line 188 of file SkVertices.cpp.

188 {
189 if (!fVertices) {
190 return nullptr;
191 }
192 if (fIntermediateFanIndices) {
193 return reinterpret_cast<uint16_t*>(fIntermediateFanIndices.get());
194 }
195 return const_cast<uint16_t*>(fVertices->fIndices);
196}

◆ isValid()

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

Definition at line 70 of file SkVertices.h.

70{ return fVertices != nullptr; }

◆ positions()

SkPoint * SkVertices::Builder::positions ( )

Definition at line 176 of file SkVertices.cpp.

176 {
177 return fVertices ? const_cast<SkPoint*>(fVertices->fPositions) : nullptr;
178}

◆ texCoords()

SkPoint * SkVertices::Builder::texCoords ( )

Definition at line 180 of file SkVertices.cpp.

180 {
181 return fVertices ? const_cast<SkPoint*>(fVertices->fTexs) : nullptr;
182}

Friends And Related Function Documentation

◆ SkVertices

friend class SkVertices
friend

Definition at line 93 of file SkVertices.h.

◆ SkVerticesPriv

friend class SkVerticesPriv
friend

Definition at line 94 of file SkVertices.h.


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