Home | History | Annotate | Download | only in gpu
      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 
     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 
     20 namespace GrTessellator {
     21 
     22 struct 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!
     31 int PathToVertices(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
     32                    WindingVertex** verts);
     33 
     34 int 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
     41