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 This is a helper for drawVertices(). It is used to iterate over the triangle
s |
| 15 that are to be rendered based on an SkCanvas::VertexMode and (optionally) an |
| 16 index array. It does not copy the index array and the client must ensure it |
| 17 remains valid for the lifetime of the VertState object. |
| 18 */ |
| 19 |
| 20 struct VertState { |
| 21 int f0, f1, f2; |
| 22 |
| 23 /** |
| 24 * Construct a VertState from a vertex count, index array, and index count. |
| 25 * If the vertices are unindexed pass NULL for indices. |
| 26 */ |
| 27 VertState(int vCount, const uint16_t indices[], int indexCount) |
| 28 : fIndices(indices) { |
| 29 fCurrIndex = 0; |
| 30 if (indices) { |
| 31 fCount = indexCount; |
| 32 } else { |
| 33 fCount = vCount; |
| 34 } |
| 35 } |
| 36 |
| 37 typedef bool (*Proc)(VertState*); |
| 38 |
| 39 /** |
| 40 * Choose an appropriate function to traverse the vertices. |
| 41 * @param mode Specifies the SkCanvas::VertexMode. |
| 42 */ |
| 43 Proc chooseProc(SkCanvas::VertexMode mode); |
| 44 |
| 45 private: |
| 46 int fCount; |
| 47 int fCurrIndex; |
| 48 const uint16_t* fIndices; |
| 49 |
| 50 static bool Triangles(VertState*); |
| 51 static bool TrianglesX(VertState*); |
| 52 static bool TriangleStrip(VertState*); |
| 53 static bool TriangleStripX(VertState*); |
| 54 static bool TriangleFan(VertState*); |
| 55 static bool TriangleFanX(VertState*); |
| 56 }; |
| 57 |
| 58 #endif |
OLD | NEW |