From 8268108731f4e98ce253e25e502f8c9f24e50cc8 Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Wed, 24 Jun 2020 02:08:58 +0000 Subject: [PATCH] Reland "[skottie] skottie_tool updates" This reverts commit d424d6a3bd07241565bedb5a62eebf12bf81a87c. Reason for revert: ready to reland Original change's description: > Revert "[skottie] skottie_tool updates" > > This reverts commit 6499e7fb4c6d05afdce3172e3d7ef39018700ae9. > > Reason for revert: G3 roll > > Original change's description: > > [skottie] skottie_tool updates > > > > 1) plumb a precomp interceptor to support nested animations, following > > the same naming pattern as viewer and dm > > > > 2) clear background with white instead of transparent, to match other > > tools > > > > TBR= > > Change-Id: Ic1d1f8c6493a3ca98a9b75f5e2aa2230a46f54d9 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298139 > > Reviewed-by: Florin Malita > > Commit-Queue: Florin Malita > > TBR=fmalita@chromium.org,fmalita@google.com > > Change-Id: Ibd320e9f7f30004e80ff4d2b2012a18703910842 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298337 > Reviewed-by: Florin Malita > Commit-Queue: Florin Malita TBR=fmalita@chromium.org,fmalita@google.com # Not skipping CQ checks because this is a reland. Change-Id: Id20c88771caf580519e1e92dc293933041522f7a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298561 Reviewed-by: Florin Malita Commit-Queue: Florin Malita --- modules/skottie/src/SkottieTool.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/skottie/src/SkottieTool.cpp b/modules/skottie/src/SkottieTool.cpp index e546c593b8..9ce6288e4c 100644 --- a/modules/skottie/src/SkottieTool.cpp +++ b/modules/skottie/src/SkottieTool.cpp @@ -12,6 +12,7 @@ #include "include/core/SkSurface.h" #include "include/encode/SkPngEncoder.h" #include "modules/skottie/include/Skottie.h" +#include "modules/skottie/utils/SkottieUtils.h" #include "modules/skresources/include/SkResources.h" #include "src/core/SkOSFile.h" #include "src/core/SkTaskGroup.h" @@ -45,6 +46,8 @@ static DEFINE_int(threads, 0, "Number of worker threads (0 -> cores count)."); namespace { +static constexpr SkColor kClearColor = SK_ColorWHITE; + std::unique_ptr MakeFrameStream(size_t idx, const char* ext) { const auto frame_file = SkStringPrintf("0%06zu.%s", idx, ext); auto stream = std::make_unique(SkOSPath::Join(FLAGS_writePath[0], @@ -87,7 +90,7 @@ private: SkCanvas* beginFrame(size_t) override { auto* canvas = fSurface->getCanvas(); - canvas->clear(SK_ColorTRANSPARENT); + canvas->clear(kClearColor); return canvas; } @@ -161,7 +164,7 @@ private: SkCanvas* beginFrame(size_t) override { auto* canvas = fSurface->getCanvas(); - canvas->clear(SK_ColorTRANSPARENT); + canvas->clear(kClearColor); return canvas; } @@ -182,7 +185,7 @@ struct MP4Sink final : public Sink { SkCanvas* beginFrame(size_t) override { SkCanvas* canvas = fSurface->getCanvas(); - canvas->clear(SK_ColorTRANSPARENT); + canvas->clear(kClearColor); return canvas; } @@ -265,6 +268,8 @@ int main(int argc, char** argv) { /*predecode=*/true), /*predecode=*/true)); auto data = SkData::MakeFromFileName(FLAGS_input[0]); + auto precomp_interceptor = + sk_make_sp(rp, "__"); if (!data) { SkDebugf("Could not load %s.\n", FLAGS_input[0]); @@ -334,12 +339,14 @@ int main(int argc, char** argv) { // iOS doesn't support thread_local on versions less than 9.0. auto anim = skottie::Animation::Builder() .setResourceProvider(rp) + .setPrecompInterceptor(precomp_interceptor) .make(static_cast(data->data()), data->size()); auto sink = MakeSink(FLAGS_format[0], scale_matrix); #else thread_local static auto* anim = skottie::Animation::Builder() .setResourceProvider(rp) + .setPrecompInterceptor(precomp_interceptor) .make(static_cast(data->data()), data->size()) .release(); thread_local static auto* sink = MakeSink(FLAGS_format[0], scale_matrix).release();