[sksg] Initial Path support

TBR=

Change-Id: I594634d339b5e1ad9181dc5303af1a1c754d0fe3
Reviewed-on: https://skia-review.googlesource.com/89540
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
This commit is contained in:
Florin Malita 2017-12-27 11:13:13 -05:00 committed by Skia Commit-Bot
parent 68c8156cdf
commit 047ae27431
3 changed files with 69 additions and 0 deletions

View File

@ -1369,6 +1369,7 @@ if (skia_enable_tools) {
"experimental/sksg/SkSGPaintNode.cpp",
"experimental/sksg/SkSGRenderNode.cpp",
"experimental/sksg/effects/SkSGTransform.cpp",
"experimental/sksg/geometry/SkSGPath.cpp",
"experimental/sksg/geometry/SkSGRect.cpp",
"experimental/sksg/paint/SkSGColor.cpp",
]

View File

@ -0,0 +1,25 @@
/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkSGPath.h"
#include "SkCanvas.h"
#include "SkPaint.h"
namespace sksg {
Path::Path(const SkPath& path) : fPath(path) {}
void Path::onDraw(SkCanvas* canvas, const SkPaint& paint) const {
canvas->drawPath(fPath, paint);
}
SkRect Path::onComputeBounds() const {
return fPath.computeTightBounds();
}
} // namespace sksg

View File

@ -0,0 +1,43 @@
/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkSGPath_DEFINED
#define SkSGPath_DEFINED
#include "SkSGGeometryNode.h"
#include "SkPath.h"
class SkCanvas;
class SkPaint;
namespace sksg {
/**
* Concrete Geometry node, wrapping an SkPath.
*/
class Path : public GeometryNode {
public:
static sk_sp<Path> Make() { return sk_sp<Path>(new Path(SkPath())); }
static sk_sp<Path> Make(const SkPath& r) { return sk_sp<Path>(new Path(r)); }
SG_ATTRIBUTE(Path, SkPath, fPath)
protected:
void onDraw(SkCanvas*, const SkPaint&) const override;
SkRect onComputeBounds() const override;
private:
explicit Path(const SkPath&);
SkPath fPath;
};
} // namespace sksg
#endif // SkSGPath_DEFINED