SkDashPathPriv.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 SkDashPathPriv_DEFINED
  8. #define SkDashPathPriv_DEFINED
  9. #include "include/core/SkPathEffect.h"
  10. namespace SkDashPath {
  11. /**
  12. * Calculates the initialDashLength, initialDashIndex, and intervalLength based on the
  13. * inputed phase and intervals. If adjustedPhase is passed in, then the phase will be
  14. * adjusted to be between 0 and intervalLength. The result will be stored in adjustedPhase.
  15. * If adjustedPhase is nullptr then it is assumed phase is already between 0 and intervalLength
  16. *
  17. * Caller should have already used ValidDashPath to exclude invalid data.
  18. */
  19. void CalcDashParameters(SkScalar phase, const SkScalar intervals[], int32_t count,
  20. SkScalar* initialDashLength, int32_t* initialDashIndex,
  21. SkScalar* intervalLength, SkScalar* adjustedPhase = nullptr);
  22. bool FilterDashPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*,
  23. const SkPathEffect::DashInfo& info);
  24. const SkScalar kMaxDashCount = 1000000;
  25. /** See comments for InternalFilter */
  26. enum class StrokeRecApplication {
  27. kDisallow,
  28. kAllow,
  29. };
  30. /**
  31. * Caller should have already used ValidDashPath to exclude invalid data. Typically, this leaves
  32. * the strokeRec unmodified. However, for some simple shapes (e.g. a line) it may directly
  33. * evaluate the dash and stroke to produce a stroked output path with a fill strokeRec. Passing
  34. * true for disallowStrokeRecApplication turns this behavior off.
  35. */
  36. bool InternalFilter(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
  37. const SkRect* cullRect, const SkScalar aIntervals[],
  38. int32_t count, SkScalar initialDashLength, int32_t initialDashIndex,
  39. SkScalar intervalLength,
  40. StrokeRecApplication = StrokeRecApplication::kAllow);
  41. bool ValidDashPath(SkScalar phase, const SkScalar intervals[], int32_t count);
  42. }
  43. #endif