1e9709e831954c3427d5cb839e84221a177bfedebethannicholas/*
2e9709e831954c3427d5cb839e84221a177bfedebethannicholas * Copyright 2015 Google Inc.
3e9709e831954c3427d5cb839e84221a177bfedebethannicholas *
4e9709e831954c3427d5cb839e84221a177bfedebethannicholas * Use of this source code is governed by a BSD-style license that can be
5e9709e831954c3427d5cb839e84221a177bfedebethannicholas * found in the LICENSE file.
6e9709e831954c3427d5cb839e84221a177bfedebethannicholas */
7e9709e831954c3427d5cb839e84221a177bfedebethannicholas
8e9709e831954c3427d5cb839e84221a177bfedebethannicholas#ifndef GrTessellator_DEFINED
9e9709e831954c3427d5cb839e84221a177bfedebethannicholas#define GrTessellator_DEFINED
10e9709e831954c3427d5cb839e84221a177bfedebethannicholas
11e9709e831954c3427d5cb839e84221a177bfedebethannicholas#include "SkPath.h"
12e9709e831954c3427d5cb839e84221a177bfedebethannicholas#include "GrResourceProvider.h"
13e9709e831954c3427d5cb839e84221a177bfedebethannicholas
14e9709e831954c3427d5cb839e84221a177bfedebethannicholas/**
15e9709e831954c3427d5cb839e84221a177bfedebethannicholas * Provides utility functions for converting paths to a collection of triangles.
16e9709e831954c3427d5cb839e84221a177bfedebethannicholas */
17e9709e831954c3427d5cb839e84221a177bfedebethannicholas
18e9709e831954c3427d5cb839e84221a177bfedebethannicholas#define TESSELLATOR_WIREFRAME 0
19e9709e831954c3427d5cb839e84221a177bfedebethannicholas
20e9709e831954c3427d5cb839e84221a177bfedebethannicholasnamespace GrTessellator {
21e9709e831954c3427d5cb839e84221a177bfedebethannicholas
22e9709e831954c3427d5cb839e84221a177bfedebethannicholasstruct WindingVertex {
23e9709e831954c3427d5cb839e84221a177bfedebethannicholas    SkPoint fPos;
24e9709e831954c3427d5cb839e84221a177bfedebethannicholas    int fWinding;
25e9709e831954c3427d5cb839e84221a177bfedebethannicholas};
26e9709e831954c3427d5cb839e84221a177bfedebethannicholas
27e9709e831954c3427d5cb839e84221a177bfedebethannicholas// Triangulates a path to an array of vertices. Each triangle is represented as a set of three
28e9709e831954c3427d5cb839e84221a177bfedebethannicholas// WindingVertex entries, each of which contains the position and winding count (which is the same
29e9709e831954c3427d5cb839e84221a177bfedebethannicholas// for all three vertices of a triangle). The 'verts' out parameter is set to point to the resultant
30e9709e831954c3427d5cb839e84221a177bfedebethannicholas// vertex array. CALLER IS RESPONSIBLE for deleting this buffer to avoid a memory leak!
31e9709e831954c3427d5cb839e84221a177bfedebethannicholasint PathToVertices(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
32e9709e831954c3427d5cb839e84221a177bfedebethannicholas                   WindingVertex** verts);
33e9709e831954c3427d5cb839e84221a177bfedebethannicholas
34e9709e831954c3427d5cb839e84221a177bfedebethannicholasint PathToTriangles(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
35e9709e831954c3427d5cb839e84221a177bfedebethannicholas                    GrResourceProvider* resourceProvider,
36e9709e831954c3427d5cb839e84221a177bfedebethannicholas                    SkAutoTUnref<GrVertexBuffer>& vertexBuffer, bool canMapVB, bool* isLinear);
37e9709e831954c3427d5cb839e84221a177bfedebethannicholas
38e9709e831954c3427d5cb839e84221a177bfedebethannicholas}
39e9709e831954c3427d5cb839e84221a177bfedebethannicholas
40e9709e831954c3427d5cb839e84221a177bfedebethannicholas#endif
41