Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkVertState.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
9
10bool VertState::Triangles(VertState* state) {
11 int index = state->fCurrIndex;
12 if (index + 3 > state->fCount) {
13 return false;
14 }
15 state->f0 = index + 0;
16 state->f1 = index + 1;
17 state->f2 = index + 2;
18 state->fCurrIndex = index + 3;
19 return true;
20}
21
22bool VertState::TrianglesX(VertState* state) {
23 const uint16_t* indices = state->fIndices;
24 int index = state->fCurrIndex;
25 if (index + 3 > state->fCount) {
26 return false;
27 }
28 state->f0 = indices[index + 0];
29 state->f1 = indices[index + 1];
30 state->f2 = indices[index + 2];
31 state->fCurrIndex = index + 3;
32 return true;
33}
34
35bool VertState::TriangleStrip(VertState* state) {
36 int index = state->fCurrIndex;
37 if (index + 3 > state->fCount) {
38 return false;
39 }
40 state->f2 = index + 2;
41 if (index & 1) {
42 state->f0 = index + 1;
43 state->f1 = index + 0;
44 } else {
45 state->f0 = index + 0;
46 state->f1 = index + 1;
47 }
48 state->fCurrIndex = index + 1;
49 return true;
50}
51
52bool VertState::TriangleStripX(VertState* state) {
53 const uint16_t* indices = state->fIndices;
54 int index = state->fCurrIndex;
55 if (index + 3 > state->fCount) {
56 return false;
57 }
58 state->f2 = indices[index + 2];
59 if (index & 1) {
60 state->f0 = indices[index + 1];
61 state->f1 = indices[index + 0];
62 } else {
63 state->f0 = indices[index + 0];
64 state->f1 = indices[index + 1];
65 }
66 state->fCurrIndex = index + 1;
67 return true;
68}
69
70bool VertState::TriangleFan(VertState* state) {
71 int index = state->fCurrIndex;
72 if (index + 3 > state->fCount) {
73 return false;
74 }
75 state->f0 = 0;
76 state->f1 = index + 1;
77 state->f2 = index + 2;
78 state->fCurrIndex = index + 1;
79 return true;
80}
81
82bool VertState::TriangleFanX(VertState* state) {
83 const uint16_t* indices = state->fIndices;
84 int index = state->fCurrIndex;
85 if (index + 3 > state->fCount) {
86 return false;
87 }
88 state->f0 = indices[0];
89 state->f1 = indices[index + 1];
90 state->f2 = indices[index + 2];
91 state->fCurrIndex = index + 1;
92 return true;
93}
94
96 switch (mode) {
98 return fIndices ? TrianglesX : Triangles;
100 return fIndices ? TriangleStripX : TriangleStrip;
102 return fIndices ? TriangleFanX : TriangleFan;
103 default:
104 return nullptr;
105 }
106}
@ kTriangleStrip_VertexMode
Definition SkVertices.h:32
@ kTriangleFan_VertexMode
Definition SkVertices.h:33
@ kTriangles_VertexMode
Definition SkVertices.h:31
AtkStateType state
Proc chooseProc(SkVertices::VertexMode mode)
bool(* Proc)(VertState *)
Definition SkVertState.h:39