blob: 3b63182e1e14eb9e24ee3aee3ff7a8f6d5462e31 [file] [log] [blame]
Florin Malita047ae272017-12-27 11:13:13 -05001/*
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 Malitacd05b192018-04-25 21:43:03 -040012#include "SkRectPriv.h"
Florin Malita047ae272017-12-27 11:13:13 -050013
14namespace sksg {
15
16Path::Path(const SkPath& path) : fPath(path) {}
17
Florin Malita38ea40e2018-01-29 16:31:14 -050018void Path::onClip(SkCanvas* canvas, bool antiAlias) const {
19 canvas->clipPath(fPath, SkClipOp::kIntersect, antiAlias);
20}
21
Florin Malita047ae272017-12-27 11:13:13 -050022void Path::onDraw(SkCanvas* canvas, const SkPaint& paint) const {
23 canvas->drawPath(fPath, paint);
24}
25
Florin Malitaeb46bd82019-02-12 09:33:21 -050026bool Path::onContains(const SkPoint& p) const {
27 return fPath.contains(p.x(), p.y());
28}
29
Florin Malitac14f1442018-01-05 11:32:31 -050030SkRect Path::onRevalidate(InvalidationController*, const SkMatrix&) {
31 SkASSERT(this->hasInval());
Florin Malitac75e2402018-01-03 16:17:29 -050032
Florin Malitacd05b192018-04-25 21:43:03 -040033 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 Malita047ae272017-12-27 11:13:13 -050039}
40
Florin Malitae6345d92018-01-03 23:37:54 -050041SkPath Path::onAsPath() const {
42 return fPath;
43}
44
Florin Malita047ae272017-12-27 11:13:13 -050045} // namespace sksg