1559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org/* 2559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org * Copyright 2014 Google Inc. 3559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org * 4559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org * Use of this source code is governed by a BSD-style license that can be 5559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org * found in the LICENSE file. 6559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org */ 7559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org 8559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org#ifndef SkVertState_DEFINED 9559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org#define SkVertState_DEFINED 10559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org 11559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org#include "SkCanvas.h" 12559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org 13559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org/** \struct VertState 14559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org This is a helper for drawVertices(). It is used to iterate over the triangles 15559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org that are to be rendered based on an SkCanvas::VertexMode and (optionally) an 16559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org index array. It does not copy the index array and the client must ensure it 17559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org remains valid for the lifetime of the VertState object. 18559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org*/ 19559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org 20559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.orgstruct VertState { 21559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org int f0, f1, f2; 22559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org 23559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org /** 24559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org * Construct a VertState from a vertex count, index array, and index count. 25559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org * If the vertices are unindexed pass NULL for indices. 26559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org */ 27559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org VertState(int vCount, const uint16_t indices[], int indexCount) 28559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org : fIndices(indices) { 29559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org fCurrIndex = 0; 30559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org if (indices) { 31559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org fCount = indexCount; 32559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org } else { 33559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org fCount = vCount; 34559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org } 35559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org } 36559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org 37559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org typedef bool (*Proc)(VertState*); 38559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org 39559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org /** 40559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org * Choose an appropriate function to traverse the vertices. 41559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org * @param mode Specifies the SkCanvas::VertexMode. 42559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org */ 43559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org Proc chooseProc(SkCanvas::VertexMode mode); 44559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org 45559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.orgprivate: 46559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org int fCount; 47559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org int fCurrIndex; 48559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org const uint16_t* fIndices; 49559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org 50559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org static bool Triangles(VertState*); 51559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org static bool TrianglesX(VertState*); 52559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org static bool TriangleStrip(VertState*); 53559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org static bool TriangleStripX(VertState*); 54559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org static bool TriangleFan(VertState*); 55559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org static bool TriangleFanX(VertState*); 56559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org}; 57559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org 58559a8833f0eae4af37dc0ffc3ee97e1fb14817b1commit-bot@chromium.org#endif 59