Florin Malita | 047ae27 | 2017-12-27 11:13:13 -0500 | [diff] [blame] | 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 | |
| 8 | #include "SkSGPath.h" |
| 9 | |
| 10 | #include "SkCanvas.h" |
| 11 | #include "SkPaint.h" |
Florin Malita | cd05b19 | 2018-04-25 21:43:03 -0400 | [diff] [blame] | 12 | #include "SkRectPriv.h" |
Florin Malita | 047ae27 | 2017-12-27 11:13:13 -0500 | [diff] [blame] | 13 | |
| 14 | namespace sksg { |
| 15 | |
| 16 | Path::Path(const SkPath& path) : fPath(path) {} |
| 17 | |
Florin Malita | 38ea40e | 2018-01-29 16:31:14 -0500 | [diff] [blame] | 18 | void Path::onClip(SkCanvas* canvas, bool antiAlias) const { |
| 19 | canvas->clipPath(fPath, SkClipOp::kIntersect, antiAlias); |
| 20 | } |
| 21 | |
Florin Malita | 047ae27 | 2017-12-27 11:13:13 -0500 | [diff] [blame] | 22 | void Path::onDraw(SkCanvas* canvas, const SkPaint& paint) const { |
| 23 | canvas->drawPath(fPath, paint); |
| 24 | } |
| 25 | |
Florin Malita | eb46bd8 | 2019-02-12 09:33:21 -0500 | [diff] [blame] | 26 | bool Path::onContains(const SkPoint& p) const { |
| 27 | return fPath.contains(p.x(), p.y()); |
| 28 | } |
| 29 | |
Florin Malita | c14f144 | 2018-01-05 11:32:31 -0500 | [diff] [blame] | 30 | SkRect Path::onRevalidate(InvalidationController*, const SkMatrix&) { |
| 31 | SkASSERT(this->hasInval()); |
Florin Malita | c75e240 | 2018-01-03 16:17:29 -0500 | [diff] [blame] | 32 | |
Florin Malita | cd05b19 | 2018-04-25 21:43:03 -0400 | [diff] [blame] | 33 | const auto ft = fPath.getFillType(); |
| 34 | return (ft == SkPath::kWinding_FillType || ft == SkPath::kEvenOdd_FillType) |
| 35 | // "Containing" fills have finite bounds. |
| 36 | ? fPath.computeTightBounds() |
| 37 | // Inverse fills are "infinite". |
| 38 | : SkRectPriv::MakeLargeS32(); |
Florin Malita | 047ae27 | 2017-12-27 11:13:13 -0500 | [diff] [blame] | 39 | } |
| 40 | |
Florin Malita | e6345d9 | 2018-01-03 23:37:54 -0500 | [diff] [blame] | 41 | SkPath Path::onAsPath() const { |
| 42 | return fPath; |
| 43 | } |
| 44 | |
Florin Malita | 047ae27 | 2017-12-27 11:13:13 -0500 | [diff] [blame] | 45 | } // namespace sksg |