[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 <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
This commit is contained in:
parent
08cb4bfa80
commit
71c31415cd
@ -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",
|
||||
|
@ -410,14 +410,14 @@ sk_sp<sksg::RenderNode> 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
|
||||
|
@ -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<sksg::RenderNode> attachShape(const skjson::ArrayValue*, AttachShapeContext*) const;
|
||||
sk_sp<sksg::RenderNode> attachAssetRef(const skjson::ObjectValue&,
|
||||
const std::function<sk_sp<sksg::RenderNode>(const skjson::ObjectValue&)>&) const;
|
||||
const ImageAssetInfo* loadImageAsset(const skjson::ObjectValue&) const;
|
||||
sk_sp<sksg::RenderNode> attachImageAsset(const skjson::ObjectValue&, LayerInfo*) const;
|
||||
const FootageAssetInfo* loadFootageAsset(const skjson::ObjectValue&) const;
|
||||
sk_sp<sksg::RenderNode> attachFootageAsset(const skjson::ObjectValue&, LayerInfo*) const;
|
||||
|
||||
sk_sp<sksg::RenderNode> attachExternalPrecompLayer(const skjson::ObjectValue&,
|
||||
const LayerInfo&) const;
|
||||
|
||||
sk_sp<sksg::RenderNode> attachImageLayer (const skjson::ObjectValue&, LayerInfo*) const;
|
||||
sk_sp<sksg::RenderNode> attachFootageLayer(const skjson::ObjectValue&, LayerInfo*) const;
|
||||
sk_sp<sksg::RenderNode> attachNullLayer (const skjson::ObjectValue&, LayerInfo*) const;
|
||||
sk_sp<sksg::RenderNode> attachPrecompLayer(const skjson::ObjectValue&, LayerInfo*) const;
|
||||
sk_sp<sksg::RenderNode> attachShapeLayer (const skjson::ObjectValue&, LayerInfo*) const;
|
||||
@ -248,14 +248,14 @@ private:
|
||||
mutable bool fIsAttaching; // Used for cycle detection
|
||||
};
|
||||
|
||||
struct ImageAssetInfo {
|
||||
struct FootageAssetInfo {
|
||||
sk_sp<ImageAsset> fAsset;
|
||||
SkISize fSize;
|
||||
};
|
||||
|
||||
SkTHashMap<SkString, AssetInfo> fAssets;
|
||||
SkTHashMap<SkString, FontInfo> fFonts;
|
||||
mutable SkTHashMap<SkString, ImageAssetInfo> fImageAssetCache;
|
||||
SkTHashMap<SkString, AssetInfo> fAssets;
|
||||
SkTHashMap<SkString, FontInfo> fFonts;
|
||||
mutable SkTHashMap<SkString, FootageAssetInfo> fImageAssetCache;
|
||||
|
||||
using INHERITED = SkNoncopyable;
|
||||
};
|
||||
|
@ -24,13 +24,13 @@ SkMatrix image_matrix(const sk_sp<SkImage>& image, const SkISize& dest_size) {
|
||||
: SkMatrix::I();
|
||||
}
|
||||
|
||||
class ImageAnimator final : public Animator {
|
||||
class FootageAnimator final : public Animator {
|
||||
public:
|
||||
ImageAnimator(sk_sp<ImageAsset> asset,
|
||||
sk_sp<sksg::Image> image_node,
|
||||
sk_sp<sksg::Matrix<SkMatrix>> image_transform_node,
|
||||
const SkISize& asset_size,
|
||||
float time_bias, float time_scale)
|
||||
FootageAnimator(sk_sp<ImageAsset> asset,
|
||||
sk_sp<sksg::Image> image_node,
|
||||
sk_sp<sksg::Matrix<SkMatrix>> 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<sksg::RenderNode> AnimationBuilder::attachImageAsset(const skjson::ObjectValue& jimage,
|
||||
LayerInfo* layer_info) const {
|
||||
const auto* asset_info = this->loadImageAsset(jimage);
|
||||
sk_sp<sksg::RenderNode> 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<sksg::RenderNode> 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<SkMatrix>::Make(SkMatrix::I());
|
||||
fCurrentAnimatorScope->push_back(sk_make_sp<ImageAnimator>(asset_info->fAsset,
|
||||
image_node,
|
||||
image_transform,
|
||||
asset_info->fSize,
|
||||
-layer_info->fInPoint,
|
||||
1 / fFrameRate));
|
||||
fCurrentAnimatorScope->push_back(sk_make_sp<FootageAnimator>(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<sksg::RenderNode> AnimationBuilder::attachImageAsset(const skjson::ObjectV
|
||||
return sksg::TransformEffect::Make(std::move(image_node), std::move(image_transform));
|
||||
}
|
||||
|
||||
sk_sp<sksg::RenderNode> AnimationBuilder::attachImageLayer(const skjson::ObjectValue& jlayer,
|
||||
LayerInfo* layer_info) const {
|
||||
sk_sp<sksg::RenderNode> 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);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user