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