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"
12 #include "SkRectPriv.h"
13 
14 namespace sksg {
15 
Path(const SkPath & path)16 Path::Path(const SkPath& path) : fPath(path) {}
17 
onClip(SkCanvas * canvas,bool antiAlias) const18 void Path::onClip(SkCanvas* canvas, bool antiAlias) const {
19     canvas->clipPath(fPath, SkClipOp::kIntersect, antiAlias);
20 }
21 
onDraw(SkCanvas * canvas,const SkPaint & paint) const22 void Path::onDraw(SkCanvas* canvas, const SkPaint& paint) const {
23     canvas->drawPath(fPath, paint);
24 }
25 
onRevalidate(InvalidationController *,const SkMatrix &)26 SkRect Path::onRevalidate(InvalidationController*, const SkMatrix&) {
27     SkASSERT(this->hasInval());
28 
29     const auto ft = fPath.getFillType();
30     return (ft == SkPath::kWinding_FillType || ft == SkPath::kEvenOdd_FillType)
31         // "Containing" fills have finite bounds.
32         ? fPath.computeTightBounds()
33         // Inverse fills are "infinite".
34         : SkRectPriv::MakeLargeS32();
35 }
36 
onAsPath() const37 SkPath Path::onAsPath() const {
38     return fPath;
39 }
40 
41 } // namespace sksg
42