ethannicholas | e9709e8 | 2016-01-07 13:34:16 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
senorblanco | 6599eff | 2016-03-10 08:38:45 -0800 | [diff] [blame] | 11 | #include "SkPoint.h" |
| 12 | |
| 13 | class SkPath; |
| 14 | struct SkRect; |
ethannicholas | e9709e8 | 2016-01-07 13:34:16 -0800 | [diff] [blame] | 15 | |
| 16 | /** |
| 17 | * Provides utility functions for converting paths to a collection of triangles. |
| 18 | */ |
| 19 | |
| 20 | #define TESSELLATOR_WIREFRAME 0 |
| 21 | |
| 22 | namespace GrTessellator { |
| 23 | |
senorblanco | 6599eff | 2016-03-10 08:38:45 -0800 | [diff] [blame] | 24 | class VertexAllocator { |
| 25 | public: |
| 26 | virtual ~VertexAllocator() {} |
| 27 | virtual SkPoint* lock(int vertexCount) = 0; |
| 28 | virtual void unlock(int actualCount) = 0; |
| 29 | }; |
| 30 | |
ethannicholas | e9709e8 | 2016-01-07 13:34:16 -0800 | [diff] [blame] | 31 | struct WindingVertex { |
| 32 | SkPoint fPos; |
| 33 | int fWinding; |
| 34 | }; |
| 35 | |
| 36 | // Triangulates a path to an array of vertices. Each triangle is represented as a set of three |
| 37 | // WindingVertex entries, each of which contains the position and winding count (which is the same |
| 38 | // for all three vertices of a triangle). The 'verts' out parameter is set to point to the resultant |
| 39 | // vertex array. CALLER IS RESPONSIBLE for deleting this buffer to avoid a memory leak! |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame^] | 40 | int PathToVertices(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds, |
ethannicholas | e9709e8 | 2016-01-07 13:34:16 -0800 | [diff] [blame] | 41 | WindingVertex** verts); |
| 42 | |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame^] | 43 | int PathToTriangles(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds, |
senorblanco | 6599eff | 2016-03-10 08:38:45 -0800 | [diff] [blame] | 44 | VertexAllocator*, bool *isLinear); |
ethannicholas | e9709e8 | 2016-01-07 13:34:16 -0800 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | #endif |