559a8833f0
If both textures and vertex-colors are NULL, drawVertices should stroke hairlines with the paint's color. This behavior is a useful debugging mode to visualize the mesh. BUG=skia:2266 R=bsalomon@google.com, reed@google.com Author: yunchao.he@intel.com Review URL: https://codereview.chromium.org/189963004 git-svn-id: http://skia.googlecode.com/svn/trunk@14985 2bbb7eff-a529-9590-31e7-b0007b416f81
59 lines
1.5 KiB
C++
59 lines
1.5 KiB
C++
/*
|
|
* 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
|
|
This is a helper for drawVertices(). It is used to iterate over the triangles
|
|
that are to be rendered based on an SkCanvas::VertexMode and (optionally) an
|
|
index array. It does not copy the index array and the client must ensure it
|
|
remains valid for the lifetime of the VertState object.
|
|
*/
|
|
|
|
struct VertState {
|
|
int f0, f1, f2;
|
|
|
|
/**
|
|
* Construct a VertState from a vertex count, index array, and index count.
|
|
* If the vertices are unindexed pass NULL for indices.
|
|
*/
|
|
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
|