SkPatchUtils.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright 2014 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 SkPatchUtils_DEFINED
  8. #define SkPatchUtils_DEFINED
  9. #include "include/core/SkMatrix.h"
  10. #include "include/core/SkVertices.h"
  11. #include "include/private/SkColorData.h"
  12. class SkColorSpace;
  13. class SK_API SkPatchUtils {
  14. public:
  15. // Enums for control points based on the order specified in the constructor (clockwise).
  16. enum {
  17. kNumCtrlPts = 12,
  18. kNumCorners = 4,
  19. kNumPtsCubic = 4
  20. };
  21. /**
  22. * Get the points corresponding to the top cubic of cubics.
  23. */
  24. static void GetTopCubic(const SkPoint cubics[12], SkPoint points[4]);
  25. /**
  26. * Get the points corresponding to the bottom cubic of cubics.
  27. */
  28. static void GetBottomCubic(const SkPoint cubics[12], SkPoint points[4]);
  29. /**
  30. * Get the points corresponding to the left cubic of cubics.
  31. */
  32. static void GetLeftCubic(const SkPoint cubics[12], SkPoint points[4]);
  33. /**
  34. * Get the points corresponding to the right cubic of cubics.
  35. */
  36. static void GetRightCubic(const SkPoint cubics[12], SkPoint points[4]);
  37. /**
  38. * Method that calculates a level of detail (number of subdivisions) for a patch in both axis.
  39. */
  40. static SkISize GetLevelOfDetail(const SkPoint cubics[12], const SkMatrix* matrix);
  41. static sk_sp<SkVertices> MakeVertices(const SkPoint cubics[12], const SkColor colors[4],
  42. const SkPoint texCoords[4], int lodX, int lodY,
  43. SkColorSpace* colorSpace = nullptr);
  44. };
  45. #endif