OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrTessellator_DEFINED | 8 #ifndef GrTessellator_DEFINED |
9 #define GrTessellator_DEFINED | 9 #define GrTessellator_DEFINED |
10 | 10 |
11 #include "GrColor.h" | |
12 #include "SkPoint.h" | 11 #include "SkPoint.h" |
13 | 12 |
14 class SkPath; | 13 class SkPath; |
15 struct SkRect; | 14 struct SkRect; |
16 | 15 |
17 /** | 16 /** |
18 * Provides utility functions for converting paths to a collection of triangles. | 17 * Provides utility functions for converting paths to a collection of triangles. |
19 */ | 18 */ |
20 | 19 |
21 #define TESSELLATOR_WIREFRAME 0 | 20 #define TESSELLATOR_WIREFRAME 0 |
22 | 21 |
23 namespace GrTessellator { | 22 namespace GrTessellator { |
24 | 23 |
25 class VertexAllocator { | 24 class VertexAllocator { |
26 public: | 25 public: |
27 VertexAllocator(size_t stride) : fStride(stride) {} | |
28 virtual ~VertexAllocator() {} | 26 virtual ~VertexAllocator() {} |
29 virtual void* lock(int vertexCount) = 0; | 27 virtual SkPoint* lock(int vertexCount) = 0; |
30 virtual void unlock(int actualCount) = 0; | 28 virtual void unlock(int actualCount) = 0; |
31 size_t stride() const { return fStride; } | |
32 private: | |
33 size_t fStride; | |
34 }; | 29 }; |
35 | 30 |
36 struct WindingVertex { | 31 struct WindingVertex { |
37 SkPoint fPos; | 32 SkPoint fPos; |
38 int fWinding; | 33 int fWinding; |
39 }; | 34 }; |
40 | 35 |
41 // Triangulates a path to an array of vertices. Each triangle is represented as
a set of three | 36 // Triangulates a path to an array of vertices. Each triangle is represented as
a set of three |
42 // WindingVertex entries, each of which contains the position and winding count
(which is the same | 37 // WindingVertex entries, each of which contains the position and winding count
(which is the same |
43 // for all three vertices of a triangle). The 'verts' out parameter is set to po
int to the resultant | 38 // for all three vertices of a triangle). The 'verts' out parameter is set to po
int to the resultant |
44 // vertex array. CALLER IS RESPONSIBLE for deleting this buffer to avoid a memor
y leak! | 39 // vertex array. CALLER IS RESPONSIBLE for deleting this buffer to avoid a memor
y leak! |
45 int PathToVertices(const SkPath& path, SkScalar tolerance, const SkRect& clipBou
nds, | 40 int PathToVertices(const SkPath& path, SkScalar tolerance, const SkRect& clipBou
nds, |
46 WindingVertex** verts); | 41 WindingVertex** verts); |
47 | 42 |
48 int PathToTriangles(const SkPath& path, SkScalar tolerance, const SkRect& clipBo
unds, | 43 int PathToTriangles(const SkPath& path, SkScalar tolerance, const SkRect& clipBo
unds, |
49 VertexAllocator*, bool antialias, const GrColor& color, | 44 VertexAllocator*, bool *isLinear); |
50 bool canTweakAlphaForCoverage, bool *isLinear); | |
51 } | 45 } |
52 | 46 |
53 #endif | 47 #endif |
OLD | NEW |