From 71c31415cdc0285a25707617c427949e2ef6971d Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Thu, 7 May 2020 16:44:18 -0400 Subject: [PATCH] [skottie] Cleanup: rename ImageLayer -> FootageLayer ...since it's used for both image and video Lottie layers. TBR= Change-Id: I52e85d70d4adbda61dfa3b33acdf4eb17ddbf332 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/288616 Reviewed-by: Florin Malita Commit-Queue: Florin Malita --- modules/skottie/skottie.gni | 2 +- modules/skottie/src/Layer.cpp | 4 +- modules/skottie/src/SkottiePriv.h | 16 ++++---- .../{ImageLayer.cpp => FootageLayer.cpp} | 40 +++++++++---------- 4 files changed, 31 insertions(+), 31 deletions(-) rename modules/skottie/src/layers/{ImageLayer.cpp => FootageLayer.cpp} (81%) diff --git a/modules/skottie/skottie.gni b/modules/skottie/skottie.gni index 80baba409e..3b64e1dac6 100644 --- a/modules/skottie/skottie.gni +++ b/modules/skottie/skottie.gni @@ -63,7 +63,7 @@ skia_skottie_sources = [ "$_src/effects/TransformEffect.cpp", "$_src/effects/TritoneEffect.cpp", "$_src/effects/VenetianBlindsEffect.cpp", - "$_src/layers/ImageLayer.cpp", + "$_src/layers/FootageLayer.cpp", "$_src/layers/NullLayer.cpp", "$_src/layers/PrecompLayer.cpp", "$_src/layers/SolidLayer.cpp", diff --git a/modules/skottie/src/Layer.cpp b/modules/skottie/src/Layer.cpp index b493c3d5d3..3a7e163017 100644 --- a/modules/skottie/src/Layer.cpp +++ b/modules/skottie/src/Layer.cpp @@ -410,14 +410,14 @@ sk_sp LayerBuilder::buildRenderTree(const AnimationBuilder& ab } gLayerBuildInfo[] = { { &AnimationBuilder::attachPrecompLayer, kTransformEffects }, // 'ty': 0 -> precomp { &AnimationBuilder::attachSolidLayer , kTransformEffects }, // 'ty': 1 -> solid - { &AnimationBuilder::attachImageLayer , kTransformEffects }, // 'ty': 2 -> image + { &AnimationBuilder::attachFootageLayer, kTransformEffects }, // 'ty': 2 -> image { &AnimationBuilder::attachNullLayer , 0 }, // 'ty': 3 -> null { &AnimationBuilder::attachShapeLayer , 0 }, // 'ty': 4 -> shape { &AnimationBuilder::attachTextLayer , 0 }, // 'ty': 5 -> text { nullptr , 0 }, // 'ty': 6 -> audio { nullptr , 0 }, // 'ty': 7 -> pholderVideo { nullptr , 0 }, // 'ty': 8 -> imageSeq - { &AnimationBuilder::attachImageLayer , 0 }, // 'ty': 9 -> video + { &AnimationBuilder::attachFootageLayer, kTransformEffects }, // 'ty': 9 -> video { nullptr , 0 }, // 'ty': 10 -> pholderStill { nullptr , 0 }, // 'ty': 11 -> guide { nullptr , 0 }, // 'ty': 12 -> adjustment diff --git a/modules/skottie/src/SkottiePriv.h b/modules/skottie/src/SkottiePriv.h index 7711777e47..bea40c0aa1 100644 --- a/modules/skottie/src/SkottiePriv.h +++ b/modules/skottie/src/SkottiePriv.h @@ -176,7 +176,7 @@ private: struct AttachLayerContext; struct AttachShapeContext; - struct ImageAssetInfo; + struct FootageAssetInfo; struct LayerInfo; void parseAssets(const skjson::ArrayValue*); @@ -191,13 +191,13 @@ private: sk_sp attachShape(const skjson::ArrayValue*, AttachShapeContext*) const; sk_sp attachAssetRef(const skjson::ObjectValue&, const std::function(const skjson::ObjectValue&)>&) const; - const ImageAssetInfo* loadImageAsset(const skjson::ObjectValue&) const; - sk_sp attachImageAsset(const skjson::ObjectValue&, LayerInfo*) const; + const FootageAssetInfo* loadFootageAsset(const skjson::ObjectValue&) const; + sk_sp attachFootageAsset(const skjson::ObjectValue&, LayerInfo*) const; sk_sp attachExternalPrecompLayer(const skjson::ObjectValue&, const LayerInfo&) const; - sk_sp attachImageLayer (const skjson::ObjectValue&, LayerInfo*) const; + sk_sp attachFootageLayer(const skjson::ObjectValue&, LayerInfo*) const; sk_sp attachNullLayer (const skjson::ObjectValue&, LayerInfo*) const; sk_sp attachPrecompLayer(const skjson::ObjectValue&, LayerInfo*) const; sk_sp attachShapeLayer (const skjson::ObjectValue&, LayerInfo*) const; @@ -248,14 +248,14 @@ private: mutable bool fIsAttaching; // Used for cycle detection }; - struct ImageAssetInfo { + struct FootageAssetInfo { sk_sp fAsset; SkISize fSize; }; - SkTHashMap fAssets; - SkTHashMap fFonts; - mutable SkTHashMap fImageAssetCache; + SkTHashMap fAssets; + SkTHashMap fFonts; + mutable SkTHashMap fImageAssetCache; using INHERITED = SkNoncopyable; }; diff --git a/modules/skottie/src/layers/ImageLayer.cpp b/modules/skottie/src/layers/FootageLayer.cpp similarity index 81% rename from modules/skottie/src/layers/ImageLayer.cpp rename to modules/skottie/src/layers/FootageLayer.cpp index 3aad6df2c1..0a10c33497 100644 --- a/modules/skottie/src/layers/ImageLayer.cpp +++ b/modules/skottie/src/layers/FootageLayer.cpp @@ -24,13 +24,13 @@ SkMatrix image_matrix(const sk_sp& image, const SkISize& dest_size) { : SkMatrix::I(); } -class ImageAnimator final : public Animator { +class FootageAnimator final : public Animator { public: - ImageAnimator(sk_sp asset, - sk_sp image_node, - sk_sp> image_transform_node, - const SkISize& asset_size, - float time_bias, float time_scale) + FootageAnimator(sk_sp asset, + sk_sp image_node, + sk_sp> image_transform_node, + const SkISize& asset_size, + float time_bias, float time_scale) : fAsset(std::move(asset)) , fImageNode(std::move(image_node)) , fImageTransformNode(std::move(image_transform_node)) @@ -67,8 +67,8 @@ private: } // namespace -const AnimationBuilder::ImageAssetInfo* -AnimationBuilder::loadImageAsset(const skjson::ObjectValue& jimage) const { +const AnimationBuilder::FootageAssetInfo* +AnimationBuilder::loadFootageAsset(const skjson::ObjectValue& jimage) const { const skjson::StringValue* name = jimage["p"]; const skjson::StringValue* path = jimage["u"]; const skjson::StringValue* id = jimage["id"]; @@ -93,9 +93,9 @@ AnimationBuilder::loadImageAsset(const skjson::ObjectValue& jimage) const { return fImageAssetCache.set(res_id, { std::move(asset), size }); } -sk_sp AnimationBuilder::attachImageAsset(const skjson::ObjectValue& jimage, - LayerInfo* layer_info) const { - const auto* asset_info = this->loadImageAsset(jimage); +sk_sp AnimationBuilder::attachFootageAsset(const skjson::ObjectValue& jimage, + LayerInfo* layer_info) const { + const auto* asset_info = this->loadFootageAsset(jimage); if (!asset_info) { return nullptr; } @@ -113,12 +113,12 @@ sk_sp AnimationBuilder::attachImageAsset(const skjson::ObjectV // We don't know the intrinsic image size yet (plus, in the general case, // the size may change from frame to frame) -> we always prepare a scaling transform. image_transform = sksg::Matrix::Make(SkMatrix::I()); - fCurrentAnimatorScope->push_back(sk_make_sp(asset_info->fAsset, - image_node, - image_transform, - asset_info->fSize, - -layer_info->fInPoint, - 1 / fFrameRate)); + fCurrentAnimatorScope->push_back(sk_make_sp(asset_info->fAsset, + image_node, + image_transform, + asset_info->fSize, + -layer_info->fInPoint, + 1 / fFrameRate)); } else { // No animator needed, resolve the (only) frame upfront. auto frame = asset_info->fAsset->getFrame(0); @@ -145,11 +145,11 @@ sk_sp AnimationBuilder::attachImageAsset(const skjson::ObjectV return sksg::TransformEffect::Make(std::move(image_node), std::move(image_transform)); } -sk_sp AnimationBuilder::attachImageLayer(const skjson::ObjectValue& jlayer, - LayerInfo* layer_info) const { +sk_sp AnimationBuilder::attachFootageLayer(const skjson::ObjectValue& jlayer, + LayerInfo* layer_info) const { return this->attachAssetRef(jlayer, [this, &layer_info] (const skjson::ObjectValue& jimage) { - return this->attachImageAsset(jimage, layer_info); + return this->attachFootageAsset(jimage, layer_info); }); }