OLD | NEW |
---|---|
(Empty) | |
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 | |
8 #ifndef SkVertState_DEFINED | |
9 #define SkVertState_DEFINED | |
10 | |
11 #include "SkCanvas.h" | |
12 | |
13 /** \struct VertState | |
14 It chooses an appropriate function to traverse the vertices according to | |
bsalomon
2014/05/29 18:27:04
This is a helper for drawVertices(). It is used to
| |
15 SkCanvas::VertexMode. For example, given vertice indices{0, 1, 2, 3, 4, 5}, | |
16 it returns vertice indices{0, 1, 2; 3, 4, 5} for kTriangles_VertexMode, but | |
17 returns {0, 1, 2; 0, 2, 3; 0, 3, 4; 0, 4, 5} for kTriangleFan_VertexMode. | |
18 | |
19 This struct can help to draw the skeleton for a mesh. | |
20 */ | |
21 | |
22 struct VertState { | |
23 int f0, f1, f2; | |
24 | |
25 /** | |
26 * Pass the indices ptr and index count to construct VertState. Otherwise, | |
bsalomon
2014/05/29 18:27:04
Construct a VertState from a vertex count, index a
| |
27 * Pass the vertex count to the constructor, then the indices will be | |
28 * thought as {0, 1, ..., vertex count - 1}. | |
29 */ | |
30 VertState(int vCount, const uint16_t indices[], int indexCount) | |
31 : fIndices(indices) { | |
32 fCurrIndex = 0; | |
33 if (indices) { | |
34 fCount = indexCount; | |
35 } else { | |
36 fCount = vCount; | |
37 } | |
38 } | |
39 | |
40 typedef bool (*Proc)(VertState*); | |
41 | |
42 /** | |
43 * Choose an appropriate function to traverse the vertices. | |
44 * @param mode Specifies the SkCanvas::VertexMode. | |
45 */ | |
46 Proc chooseProc(SkCanvas::VertexMode mode); | |
47 | |
48 private: | |
49 int fCount; | |
50 int fCurrIndex; | |
51 const uint16_t* fIndices; | |
52 | |
53 static bool Triangles(VertState*); | |
54 static bool TrianglesX(VertState*); | |
55 static bool TriangleStrip(VertState*); | |
56 static bool TriangleStripX(VertState*); | |
57 static bool TriangleFan(VertState*); | |
58 static bool TriangleFanX(VertState*); | |
59 }; | |
60 | |
61 #endif | |
OLD | NEW |