aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/skottie/Skottie.cpp
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2018-01-29 16:31:14 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-29 21:57:44 +0000
commit38ea40eb750596c75b8ffb5c8f94bcb84b94a7c3 (patch)
tree966c9416f99c784dd84dcc31d91fe3bf790bfd11 /experimental/skottie/Skottie.cpp
parenteed48b66eb083f01638d1a2126a2b49f1e2ddc8f (diff)
[skottie] Layer clip support
TBR= Change-Id: Ibf65efc69031f8f6e19f4f28cccab29c357e704d Reviewed-on: https://skia-review.googlesource.com/101540 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'experimental/skottie/Skottie.cpp')
-rw-r--r--experimental/skottie/Skottie.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/experimental/skottie/Skottie.cpp b/experimental/skottie/Skottie.cpp
index 532cc8d36d..1ac8f7de3d 100644
--- a/experimental/skottie/Skottie.cpp
+++ b/experimental/skottie/Skottie.cpp
@@ -19,6 +19,7 @@
#include "SkPaint.h"
#include "SkParse.h"
#include "SkPoint.h"
+#include "SkSGClipEffect.h"
#include "SkSGColor.h"
#include "SkSGDraw.h"
#include "SkSGGeometryTransform.h"
@@ -944,12 +945,23 @@ sk_sp<sksg::RenderNode> AttachLayer(const Json::Value& jlayer,
// Layer content.
auto layer = gLayerAttachers[type](jlayer, &local_ctx, &time_bias, &time_scale);
+
+ // Clip layers with explicit dimensions.
+ float w, h;
+ if (Parse(jlayer["w"], &w) && Parse(jlayer["h"], &h)) {
+ layer = sksg::ClipEffect::Make(std::move(layer),
+ sksg::Rect::Make(SkRect::MakeWH(w, h)),
+ true);
+ }
+
// Optional layer mask.
layer = AttachMask(jlayer["masksProperties"], &local_ctx, std::move(layer));
+
// Optional layer transform.
if (auto layerMatrix = layerCtx->AttachLayerMatrix(jlayer)) {
layer = sksg::Transform::Make(std::move(layer), std::move(layerMatrix));
}
+
// Optional layer opacity.
layer = AttachOpacity(jlayer["ks"], &local_ctx, std::move(layer));