1 /* 2 * Copyright 2019 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 8 #ifndef SkottieMotionBlurEffect_DEFINED 9 #define SkottieMotionBlurEffect_DEFINED 10 11 #include "modules/sksg/include/SkSGRenderNode.h" 12 #include "modules/sksg/include/SkSGScene.h" 13 14 namespace skottie { 15 namespace internal { 16 17 class MotionBlurEffect final : public sksg::CustomRenderNode { 18 public: 19 static sk_sp<MotionBlurEffect> Make(sk_sp<sksg::Animator> animator, 20 sk_sp<sksg::RenderNode> child, 21 size_t samples_per_frame, 22 float shutter_angle, float shutter_phase); 23 24 SG_ATTRIBUTE(T, float, fT) 25 26 protected: 27 const RenderNode* onNodeAt(const SkPoint&) const override; 28 29 SkRect onRevalidate(sksg::InvalidationController* ic, const SkMatrix& ctm) override; 30 31 void onRender(SkCanvas* canvas, const RenderContext* ctx) const override; 32 33 private: 34 MotionBlurEffect(sk_sp<sksg::Animator> animator, 35 sk_sp<sksg::RenderNode> child, 36 size_t sample_count, float phase, float dt); 37 38 const sk_sp<sksg::Animator> fAnimator; 39 const size_t fSampleCount; 40 const float fPhase, 41 fDT; 42 43 float fT = 0; 44 45 using INHERITED = sksg::CustomRenderNode; 46 }; 47 48 } // namespace internal 49 } // namespace skottie 50 51 #endif // SkottieMotionBlurEffect_DEFINED 52