SkSGPath.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright 2017 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. #include "modules/sksg/include/SkSGPath.h"
  8. #include "include/core/SkCanvas.h"
  9. #include "include/core/SkPaint.h"
  10. #include "src/core/SkRectPriv.h"
  11. namespace sksg {
  12. Path::Path(const SkPath& path) : fPath(path) {}
  13. void Path::onClip(SkCanvas* canvas, bool antiAlias) const {
  14. canvas->clipPath(fPath, SkClipOp::kIntersect, antiAlias);
  15. }
  16. void Path::onDraw(SkCanvas* canvas, const SkPaint& paint) const {
  17. canvas->drawPath(fPath, paint);
  18. }
  19. bool Path::onContains(const SkPoint& p) const {
  20. return fPath.contains(p.x(), p.y());
  21. }
  22. SkRect Path::onRevalidate(InvalidationController*, const SkMatrix&) {
  23. SkASSERT(this->hasInval());
  24. const auto ft = fPath.getFillType();
  25. return (ft == SkPath::kWinding_FillType || ft == SkPath::kEvenOdd_FillType)
  26. // "Containing" fills have finite bounds.
  27. ? fPath.computeTightBounds()
  28. // Inverse fills are "infinite".
  29. : SkRectPriv::MakeLargeS32();
  30. }
  31. SkPath Path::onAsPath() const {
  32. return fPath;
  33. }
  34. } // namespace sksg