expose directional blur to skottie
Change-Id: I759e4fff7a6d9cd1aae6ece060d570d05c1af94a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/461236 Commit-Queue: Jorge Betancourt <jmbetancourt@google.com> Reviewed-by: Florin Malita <fmalita@google.com>
This commit is contained in:
parent
ebe2d82384
commit
aaa70658c2
@ -44,6 +44,7 @@ skia_skottie_sources = [
|
|||||||
"$_src/effects/BrightnessContrastEffect.cpp",
|
"$_src/effects/BrightnessContrastEffect.cpp",
|
||||||
"$_src/effects/CCToner.cpp",
|
"$_src/effects/CCToner.cpp",
|
||||||
"$_src/effects/CornerPinEffect.cpp",
|
"$_src/effects/CornerPinEffect.cpp",
|
||||||
|
"$_src/effects/DirectionalBlur.cpp",
|
||||||
"$_src/effects/DisplacementMapEffect.cpp",
|
"$_src/effects/DisplacementMapEffect.cpp",
|
||||||
"$_src/effects/DropShadowEffect.cpp",
|
"$_src/effects/DropShadowEffect.cpp",
|
||||||
"$_src/effects/Effects.cpp",
|
"$_src/effects/Effects.cpp",
|
||||||
|
64
modules/skottie/src/effects/DirectionalBlur.cpp
Normal file
64
modules/skottie/src/effects/DirectionalBlur.cpp
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021 Google Inc.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "modules/skottie/src/effects/Effects.h"
|
||||||
|
|
||||||
|
#include "modules/skottie/src/Adapter.h"
|
||||||
|
#include "modules/skottie/src/SkottieValue.h"
|
||||||
|
#include "modules/sksg/include/SkSGPaint.h"
|
||||||
|
#include "modules/sksg/include/SkSGRenderEffect.h"
|
||||||
|
#include "src/utils/SkJSON.h"
|
||||||
|
|
||||||
|
namespace skottie::internal {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class DirectionalBlurAdapter final : public DiscardableAdapterBase<DirectionalBlurAdapter,
|
||||||
|
sksg::ExternalImageFilter> {
|
||||||
|
public:
|
||||||
|
DirectionalBlurAdapter(const skjson::ArrayValue& jprops,
|
||||||
|
const AnimationBuilder& abuilder)
|
||||||
|
: INHERITED(sksg::ExternalImageFilter::Make())
|
||||||
|
{
|
||||||
|
enum : size_t {
|
||||||
|
kDirection_Index = 0,
|
||||||
|
kBlurLength_Index = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
EffectBinder(jprops, abuilder, this)
|
||||||
|
.bind( kDirection_Index, fDirection)
|
||||||
|
.bind( kBlurLength_Index, fBlurLength);
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
void onSync() override {
|
||||||
|
const auto rot = fDirection - 90;
|
||||||
|
auto filter =
|
||||||
|
SkImageFilters::MatrixTransform(SkMatrix::RotateDeg(rot),
|
||||||
|
SkSamplingOptions(SkFilterMode::kLinear),
|
||||||
|
SkImageFilters::Blur(fBlurLength * kBlurSizeToSigma, 0,
|
||||||
|
SkImageFilters::MatrixTransform(SkMatrix::RotateDeg(-rot),
|
||||||
|
SkSamplingOptions(SkFilterMode::kLinear), nullptr)));
|
||||||
|
this->node()->setImageFilter(std::move(filter));
|
||||||
|
}
|
||||||
|
|
||||||
|
ScalarValue fDirection = 0;
|
||||||
|
ScalarValue fBlurLength = 0;
|
||||||
|
|
||||||
|
using INHERITED = DiscardableAdapterBase<DirectionalBlurAdapter, sksg::ExternalImageFilter>;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
sk_sp<sksg::RenderNode> EffectBuilder::attachDirectionalBlurEffect(const skjson::ArrayValue& jprops,
|
||||||
|
sk_sp<sksg::RenderNode> layer) const {
|
||||||
|
auto imageFilterNode = fBuilder->attachDiscardableAdapter<DirectionalBlurAdapter>(jprops,
|
||||||
|
*fBuilder);
|
||||||
|
return sksg::ImageFilterEffect::Make(std::move(layer), std::move(imageFilterNode));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace skottie::internal
|
@ -31,6 +31,7 @@ EffectBuilder::EffectBuilderT EffectBuilder::findBuilder(const skjson::ObjectVal
|
|||||||
const char* fName;
|
const char* fName;
|
||||||
EffectBuilderT fBuilder;
|
EffectBuilderT fBuilder;
|
||||||
} gBuilderInfo[] = {
|
} gBuilderInfo[] = {
|
||||||
|
// alphabetized for binary search lookup
|
||||||
{ "ADBE Black&White" , &EffectBuilder::attachBlackAndWhiteEffect },
|
{ "ADBE Black&White" , &EffectBuilder::attachBlackAndWhiteEffect },
|
||||||
{ "ADBE Brightness & Contrast 2", &EffectBuilder::attachBrightnessContrastEffect },
|
{ "ADBE Brightness & Contrast 2", &EffectBuilder::attachBrightnessContrastEffect },
|
||||||
{ "ADBE Corner Pin" , &EffectBuilder::attachCornerPinEffect },
|
{ "ADBE Corner Pin" , &EffectBuilder::attachCornerPinEffect },
|
||||||
@ -44,6 +45,7 @@ EffectBuilder::EffectBuilderT EffectBuilder::findBuilder(const skjson::ObjectVal
|
|||||||
{ "ADBE HUE SATURATION" , &EffectBuilder::attachHueSaturationEffect },
|
{ "ADBE HUE SATURATION" , &EffectBuilder::attachHueSaturationEffect },
|
||||||
{ "ADBE Invert" , &EffectBuilder::attachInvertEffect },
|
{ "ADBE Invert" , &EffectBuilder::attachInvertEffect },
|
||||||
{ "ADBE Linear Wipe" , &EffectBuilder::attachLinearWipeEffect },
|
{ "ADBE Linear Wipe" , &EffectBuilder::attachLinearWipeEffect },
|
||||||
|
{ "ADBE Motion Blur" , &EffectBuilder::attachDirectionalBlurEffect },
|
||||||
{ "ADBE Pro Levels2" , &EffectBuilder::attachProLevelsEffect },
|
{ "ADBE Pro Levels2" , &EffectBuilder::attachProLevelsEffect },
|
||||||
{ "ADBE Radial Wipe" , &EffectBuilder::attachRadialWipeEffect },
|
{ "ADBE Radial Wipe" , &EffectBuilder::attachRadialWipeEffect },
|
||||||
{ "ADBE Ramp" , &EffectBuilder::attachGradientEffect },
|
{ "ADBE Ramp" , &EffectBuilder::attachGradientEffect },
|
||||||
|
@ -49,6 +49,8 @@ private:
|
|||||||
sk_sp<sksg::RenderNode>) const;
|
sk_sp<sksg::RenderNode>) const;
|
||||||
sk_sp<sksg::RenderNode> attachCCTonerEffect (const skjson::ArrayValue&,
|
sk_sp<sksg::RenderNode> attachCCTonerEffect (const skjson::ArrayValue&,
|
||||||
sk_sp<sksg::RenderNode>) const;
|
sk_sp<sksg::RenderNode>) const;
|
||||||
|
sk_sp<sksg::RenderNode> attachDirectionalBlurEffect (const skjson::ArrayValue&,
|
||||||
|
sk_sp<sksg::RenderNode>) const;
|
||||||
sk_sp<sksg::RenderNode> attachDisplacementMapEffect (const skjson::ArrayValue&,
|
sk_sp<sksg::RenderNode> attachDisplacementMapEffect (const skjson::ArrayValue&,
|
||||||
sk_sp<sksg::RenderNode>) const;
|
sk_sp<sksg::RenderNode>) const;
|
||||||
sk_sp<sksg::RenderNode> attachDropShadowEffect (const skjson::ArrayValue&,
|
sk_sp<sksg::RenderNode> attachDropShadowEffect (const skjson::ArrayValue&,
|
||||||
|
1
resources/skottie/skottie-directional-blur.json
Normal file
1
resources/skottie/skottie-directional-blur.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"assets":[],"ddd":0,"fr":60,"h":500,"ip":0,"layers":[{"ao":0,"bm":0,"ddd":0,"ef":[{"ef":[{"ix":1,"mn":"ADBE Motion Blur-0001","nm":"Direction","ty":0,"v":{"a":1,"ix":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"s":[0],"t":0},{"s":[360],"t":299}]}},{"ix":2,"mn":"ADBE Motion Blur-0002","nm":"Blur Length","ty":0,"v":{"a":1,"ix":2,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"s":[9.963],"t":0},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"s":[30],"t":38},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"s":[9.963],"t":75},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"s":[30],"t":114},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"s":[9.963],"t":150},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"s":[30],"t":189},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"s":[9.963],"t":225},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"s":[30],"t":264},{"s":[9.963],"t":299}]}}],"en":1,"ix":1,"mn":"ADBE Motion Blur","nm":"Directional Blur","np":4,"ty":5}],"ind":1,"ip":0,"ks":{"a":{"a":0,"ix":1,"k":[0,0,0],"l":2},"o":{"a":0,"ix":11,"k":100},"p":{"a":0,"ix":2,"k":[250,250,0],"l":2},"r":{"a":0,"ix":10,"k":0},"s":{"a":0,"ix":6,"k":[100,100,100],"l":2}},"nm":"Shape Layer 1","op":300,"shapes":[{"bm":0,"cix":2,"hd":false,"it":[{"d":1,"hd":false,"mn":"ADBE Vector Shape - Ellipse","nm":"Ellipse Path 1","p":{"a":0,"ix":3,"k":[0,0]},"s":{"a":0,"ix":2,"k":[350,350]},"ty":"el"},{"d":1,"hd":false,"mn":"ADBE Vector Shape - Rect","nm":"Rectangle Path 2","p":{"a":0,"ix":3,"k":[0,0]},"r":{"a":0,"ix":4,"k":0},"s":{"a":0,"ix":2,"k":[0,344]},"ty":"rc"},{"d":1,"hd":false,"mn":"ADBE Vector Shape - Rect","nm":"Rectangle Path 1","p":{"a":0,"ix":3,"k":[0,0]},"r":{"a":0,"ix":4,"k":0},"s":{"a":0,"ix":2,"k":[344,0]},"ty":"rc"},{"bm":0,"c":{"a":0,"ix":3,"k":[0,0.309803932905,0,1]},"hd":false,"lc":1,"lj":1,"ml":4,"mn":"ADBE Vector Graphic - Stroke","nm":"Stroke 1","o":{"a":0,"ix":4,"k":100},"ty":"st","w":{"a":0,"ix":5,"k":50}},{"a":{"a":0,"ix":1,"k":[0,0]},"nm":"Transform","o":{"a":0,"ix":7,"k":100},"p":{"a":0,"ix":2,"k":[0,0]},"r":{"a":0,"ix":6,"k":0},"s":{"a":0,"ix":3,"k":[100,100]},"sa":{"a":0,"ix":5,"k":0},"sk":{"a":0,"ix":4,"k":0},"ty":"tr"}],"ix":1,"mn":"ADBE Vector Group","nm":"Group 1","np":4,"ty":"gr"}],"sr":1,"st":0,"ty":4},{"ao":0,"bm":0,"ddd":0,"ind":2,"ip":0,"ks":{"a":{"a":0,"ix":1,"k":[250,250,0],"l":2},"o":{"a":0,"ix":11,"k":100},"p":{"a":0,"ix":2,"k":[250,250,0],"l":2},"r":{"a":0,"ix":10,"k":0},"s":{"a":0,"ix":6,"k":[100,100,100],"l":2}},"nm":"White Solid 3","op":300,"sc":"#ffffff","sh":500,"sr":1,"st":0,"sw":500,"ty":1}],"markers":[],"nm":"Directional Blur","op":300,"v":"5.7.14","w":500}
|
Loading…
Reference in New Issue
Block a user