From 6ba8c7ea84882a4d6d1f34b133a063317143775f Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Mon, 3 Dec 2018 09:55:52 -0500 Subject: [PATCH] [skottie] Surface composition markers in CK Change-Id: Ie53c81f4dbe981327469d8a9990d27f8a41d8b4c Reviewed-on: https://skia-review.googlesource.com/c/173983 Reviewed-by: Kevin Lubick Commit-Queue: Florin Malita --- experimental/canvaskit/canvaskit_bindings.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/experimental/canvaskit/canvaskit_bindings.cpp b/experimental/canvaskit/canvaskit_bindings.cpp index 83f8fb7930..2a71d2e7d0 100644 --- a/experimental/canvaskit/canvaskit_bindings.cpp +++ b/experimental/canvaskit/canvaskit_bindings.cpp @@ -169,6 +169,7 @@ public: static sk_sp Make(const std::string& json) { auto mgr = skstd::make_unique(); auto animation = skottie::Animation::Builder() + .setMarkerObserver(mgr->getMarkerObserver()) .setPropertyObserver(mgr->getPropertyObserver()) .make(json.c_str(), json.size()); @@ -220,6 +221,18 @@ public: return fPropMgr->setOpacity(key, o); } + JSArray getMarkers() const { + JSArray markers = emscripten::val::array(); + for (const auto& m : fPropMgr->markers()) { + JSObject marker = emscripten::val::object(); + marker.set("name", m.name); + marker.set("t0" , m.t0); + marker.set("t1" , m.t1); + markers.call("push", marker); + } + return markers; + } + private: ManagedAnimation(sk_sp animation, std::unique_ptr propMgr) @@ -977,6 +990,7 @@ EMSCRIPTEN_BINDINGS(Skia) { (&ManagedAnimation::render), allow_raw_pointers()) .function("setColor" , &ManagedAnimation::setColor) .function("setOpacity", &ManagedAnimation::setOpacity) + .function("getMarkers", &ManagedAnimation::getMarkers) .function("getColorProps" , &ManagedAnimation::getColorProps) .function("getOpacityProps", &ManagedAnimation::getOpacityProps);