aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2018-04-25 21:43:03 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-26 02:35:10 +0000
commitcd05b196099492da8f4badd3d47a906395fc0b79 (patch)
treeb75c7b86c278d31f438ae2d3733f5c1bafd1cadb /experimental
parent1366282bc2f2c9566e1ffa77bafb2ec4d8f190df (diff)
[skottie] Add support for inverse mask paths
TBR= Change-Id: I442033b2e82777c90ee497d8a5b2310af1d2e631 Reviewed-on: https://skia-review.googlesource.com/123840 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'experimental')
-rw-r--r--experimental/skottie/Skottie.cpp11
-rw-r--r--experimental/sksg/SkSGNode.h10
-rw-r--r--experimental/sksg/geometry/SkSGPath.cpp8
-rw-r--r--experimental/sksg/geometry/SkSGPath.h1
4 files changed, 21 insertions, 9 deletions
diff --git a/experimental/skottie/Skottie.cpp b/experimental/skottie/Skottie.cpp
index 7486502f2e..194efe70c4 100644
--- a/experimental/skottie/Skottie.cpp
+++ b/experimental/skottie/Skottie.cpp
@@ -949,19 +949,16 @@ sk_sp<sksg::RenderNode> AttachMask(const Json::Value& jmask,
if (!m.isObject())
continue;
- const auto inverted = ParseDefault(m["inv"], false);
- // TODO
- if (inverted) {
- LogFail(m, "Unsupported inverse mask");
- continue;
- }
-
auto mask_path = AttachPath(m["pt"], ctx);
if (!mask_path) {
LogFail(m, "Could not parse mask path");
continue;
}
+ mask_path->setFillType(ParseDefault(m["inv"], false)
+ ? SkPath::kInverseWinding_FillType
+ : SkPath::kWinding_FillType);
+
SkString mode;
if (!Parse(m["mode"], &mode) ||
mode.size() != 1 ||
diff --git a/experimental/sksg/SkSGNode.h b/experimental/sksg/SkSGNode.h
index 6396e4d33e..17619de485 100644
--- a/experimental/sksg/SkSGNode.h
+++ b/experimental/sksg/SkSGNode.h
@@ -92,7 +92,15 @@ private:
if (attr_container == v) return; \
attr_container = v; \
this->invalidate(); \
- }
+ }
+
+#define SG_MAPPED_ATTRIBUTE(attr_name, attr_type, attr_container) \
+ attr_type get##attr_name() const { return attr_container.get##attr_name(); } \
+ void set##attr_name(const attr_type& v) { \
+ if (attr_container.get##attr_name() == v) return; \
+ attr_container.set##attr_name(v); \
+ this->invalidate(); \
+ }
} // namespace sksg
diff --git a/experimental/sksg/geometry/SkSGPath.cpp b/experimental/sksg/geometry/SkSGPath.cpp
index 8d5a25373a..230442d409 100644
--- a/experimental/sksg/geometry/SkSGPath.cpp
+++ b/experimental/sksg/geometry/SkSGPath.cpp
@@ -9,6 +9,7 @@
#include "SkCanvas.h"
#include "SkPaint.h"
+#include "SkRectPriv.h"
namespace sksg {
@@ -25,7 +26,12 @@ void Path::onDraw(SkCanvas* canvas, const SkPaint& paint) const {
SkRect Path::onRevalidate(InvalidationController*, const SkMatrix&) {
SkASSERT(this->hasInval());
- return fPath.computeTightBounds();
+ const auto ft = fPath.getFillType();
+ return (ft == SkPath::kWinding_FillType || ft == SkPath::kEvenOdd_FillType)
+ // "Containing" fills have finite bounds.
+ ? fPath.computeTightBounds()
+ // Inverse fills are "infinite".
+ : SkRectPriv::MakeLargeS32();
}
SkPath Path::onAsPath() const {
diff --git a/experimental/sksg/geometry/SkSGPath.h b/experimental/sksg/geometry/SkSGPath.h
index a398e2f0a4..1a8718868d 100644
--- a/experimental/sksg/geometry/SkSGPath.h
+++ b/experimental/sksg/geometry/SkSGPath.h
@@ -26,6 +26,7 @@ public:
static sk_sp<Path> Make(const SkPath& r) { return sk_sp<Path>(new Path(r)); }
SG_ATTRIBUTE(Path, SkPath, fPath)
+ SG_MAPPED_ATTRIBUTE(FillType, SkPath::FillType, fPath)
protected:
void onClip(SkCanvas*, bool antiAlias) const override;