GrTessellator.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #ifndef GrTessellator_DEFINED
  8. #define GrTessellator_DEFINED
  9. #include "include/core/SkPoint.h"
  10. #include "include/private/SkColorData.h"
  11. #include "src/gpu/GrColor.h"
  12. class SkPath;
  13. struct SkRect;
  14. /**
  15. * Provides utility functions for converting paths to a collection of triangles.
  16. */
  17. #define TESSELLATOR_WIREFRAME 0
  18. namespace GrTessellator {
  19. class VertexAllocator {
  20. public:
  21. VertexAllocator(size_t stride) : fStride(stride) {}
  22. virtual ~VertexAllocator() {}
  23. virtual void* lock(int vertexCount) = 0;
  24. virtual void unlock(int actualCount) = 0;
  25. size_t stride() const { return fStride; }
  26. private:
  27. size_t fStride;
  28. };
  29. struct WindingVertex {
  30. SkPoint fPos;
  31. int fWinding;
  32. };
  33. // Triangulates a path to an array of vertices. Each triangle is represented as a set of three
  34. // WindingVertex entries, each of which contains the position and winding count (which is the same
  35. // for all three vertices of a triangle). The 'verts' out parameter is set to point to the resultant
  36. // vertex array. CALLER IS RESPONSIBLE for deleting this buffer to avoid a memory leak!
  37. int PathToVertices(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
  38. WindingVertex** verts);
  39. int PathToTriangles(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
  40. VertexAllocator*, bool antialias, bool *isLinear);
  41. }
  42. #endif