Chromium Code Reviews| Index: include/core/SkVertState.h |
| diff --git a/include/core/SkVertState.h b/include/core/SkVertState.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dc72aa344f3a898489ddaa095a127d78de5b9041 |
| --- /dev/null |
| +++ b/include/core/SkVertState.h |
| @@ -0,0 +1,61 @@ |
| +/* |
| + * Copyright 2014 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#ifndef SkVertState_DEFINED |
| +#define SkVertState_DEFINED |
| + |
| +#include "SkCanvas.h" |
| + |
| +/** \struct VertState |
| + 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
|
| + SkCanvas::VertexMode. For example, given vertice indices{0, 1, 2, 3, 4, 5}, |
| + it returns vertice indices{0, 1, 2; 3, 4, 5} for kTriangles_VertexMode, but |
| + returns {0, 1, 2; 0, 2, 3; 0, 3, 4; 0, 4, 5} for kTriangleFan_VertexMode. |
| + |
| + This struct can help to draw the skeleton for a mesh. |
| +*/ |
| + |
| +struct VertState { |
| + int f0, f1, f2; |
| + |
| + /** |
| + * 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
|
| + * Pass the vertex count to the constructor, then the indices will be |
| + * thought as {0, 1, ..., vertex count - 1}. |
| + */ |
| + VertState(int vCount, const uint16_t indices[], int indexCount) |
| + : fIndices(indices) { |
| + fCurrIndex = 0; |
| + if (indices) { |
| + fCount = indexCount; |
| + } else { |
| + fCount = vCount; |
| + } |
| + } |
| + |
| + typedef bool (*Proc)(VertState*); |
| + |
| + /** |
| + * Choose an appropriate function to traverse the vertices. |
| + * @param mode Specifies the SkCanvas::VertexMode. |
| + */ |
| + Proc chooseProc(SkCanvas::VertexMode mode); |
| + |
| +private: |
| + int fCount; |
| + int fCurrIndex; |
| + const uint16_t* fIndices; |
| + |
| + static bool Triangles(VertState*); |
| + static bool TrianglesX(VertState*); |
| + static bool TriangleStrip(VertState*); |
| + static bool TriangleStripX(VertState*); |
| + static bool TriangleFan(VertState*); |
| + static bool TriangleFanX(VertState*); |
| +}; |
| + |
| +#endif |