Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
DirectionalBlur.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2021 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
19
20#include <cstddef>
21#include <utility>
22
23namespace skjson {
24class ArrayValue;
25}
26
27namespace skottie::internal {
28
29namespace {
30
31class DirectionalBlurAdapter final : public DiscardableAdapterBase<DirectionalBlurAdapter,
32 sksg::ExternalImageFilter> {
33 public:
34 DirectionalBlurAdapter(const skjson::ArrayValue& jprops,
35 const AnimationBuilder& abuilder)
36 : INHERITED(sksg::ExternalImageFilter::Make())
37 {
38 enum : size_t {
39 kDirection_Index = 0,
40 kBlurLength_Index = 1,
41 };
42
43
44 EffectBinder(jprops, abuilder, this)
45 .bind( kDirection_Index, fDirection)
46 .bind( kBlurLength_Index, fBlurLength);
47 }
48 private:
49 void onSync() override {
50 const auto rot = fDirection - 90;
51 auto filter =
57 this->node()->setImageFilter(std::move(filter));
58 }
59
60 ScalarValue fDirection = 0;
61 ScalarValue fBlurLength = 0;
62
63 using INHERITED = DiscardableAdapterBase<DirectionalBlurAdapter, sksg::ExternalImageFilter>;
64};
65
66} // namespace
67
68sk_sp<sksg::RenderNode> EffectBuilder::attachDirectionalBlurEffect(const skjson::ArrayValue& jprops,
69 sk_sp<sksg::RenderNode> layer) const {
70 auto imageFilterNode = fBuilder->attachDiscardableAdapter<DirectionalBlurAdapter>(jprops,
71 *fBuilder);
72 return sksg::ImageFilterEffect::Make(std::move(layer), std::move(imageFilterNode));
73}
74
75} // namespace skottie::internal
static std::unique_ptr< SkEncoder > Make(SkWStream *dst, const SkPixmap *src, const SkYUVAPixmaps *srcYUVA, const SkColorSpace *srcYUVAColorSpace, const SkJpegEncoder::Options &options)
#define INHERITED(method,...)
static sk_sp< SkImageFilter > Blur(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > MatrixTransform(const SkMatrix &matrix, const SkSamplingOptions &sampling, sk_sp< SkImageFilter > input)
static SkMatrix RotateDeg(SkScalar deg)
Definition SkMatrix.h:104
void attachDiscardableAdapter(sk_sp< T > adapter) const
static sk_sp< RenderNode > Make(sk_sp< RenderNode > child, sk_sp< ImageFilter > filter)
static constexpr float kBlurSizeToSigma
Definition SkottiePriv.h:47
SkScalar ScalarValue
Definition Skottie.h:32