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 
13 namespace sksg {
14 
Path(const SkPath & path)15 Path::Path(const SkPath& path) : fPath(path) {}
16 
onClip(SkCanvas * canvas,bool antiAlias) const17 void Path::onClip(SkCanvas* canvas, bool antiAlias) const {
18     canvas->clipPath(fPath, SkClipOp::kIntersect, antiAlias);
19 }
20 
onDraw(SkCanvas * canvas,const SkPaint & paint) const21 void Path::onDraw(SkCanvas* canvas, const SkPaint& paint) const {
22     canvas->drawPath(fPath, paint);
23 }
24 
onRevalidate(InvalidationController *,const SkMatrix &)25 SkRect Path::onRevalidate(InvalidationController*, const SkMatrix&) {
26     SkASSERT(this->hasInval());
27 
28     return fPath.computeTightBounds();
29 }
30 
onAsPath() const31 SkPath Path::onAsPath() const {
32     return fPath;
33 }
34 
35 } // namespace sksg
36