blob: 4304920fbc024856a9f5d7bc7fc09cf72a9d1a5d [file] [log] [blame]
ethannicholase9709e82016-01-07 13:34:16 -08001/*
2 * Copyright 2015 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 GrTessellator_DEFINED
9#define GrTessellator_DEFINED
10
11#include "SkPath.h"
12#include "GrResourceProvider.h"
13
14/**
15 * Provides utility functions for converting paths to a collection of triangles.
16 */
17
18#define TESSELLATOR_WIREFRAME 0
19
20namespace GrTessellator {
21
22struct WindingVertex {
23 SkPoint fPos;
24 int fWinding;
25};
26
27// Triangulates a path to an array of vertices. Each triangle is represented as a set of three
28// WindingVertex entries, each of which contains the position and winding count (which is the same
29// for all three vertices of a triangle). The 'verts' out parameter is set to point to the resultant
30// vertex array. CALLER IS RESPONSIBLE for deleting this buffer to avoid a memory leak!
31int PathToVertices(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
32 WindingVertex** verts);
33
34int PathToTriangles(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
35 GrResourceProvider* resourceProvider,
36 SkAutoTUnref<GrVertexBuffer>& vertexBuffer, bool canMapVB, bool* isLinear);
37
38}
39
40#endif