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 13 namespace skottie { 14 namespace internal { 15 16 class Animator; 17 18 class MotionBlurEffect final : public sksg::CustomRenderNode { 19 public: 20 static sk_sp<MotionBlurEffect> Make(sk_sp<Animator> animator, 21 sk_sp<sksg::RenderNode> child, 22 size_t samples_per_frame, 23 float shutter_angle, float shutter_phase); 24 25 SG_ATTRIBUTE(T, float, fT) 26 27 private: 28 class AutoInvalBlocker; 29 30 const RenderNode* onNodeAt(const SkPoint&) const override; 31 32 SkRect onRevalidate(sksg::InvalidationController* ic, const SkMatrix& ctm) override; 33 34 void onRender(SkCanvas* canvas, const RenderContext* ctx) const override; 35 36 void renderToRaster8888Pow2Samples(SkCanvas* canvas, const RenderContext* ctx) const; 37 38 SkRect seekToSample(size_t sample_idx, const SkMatrix& ctm) const; 39 40 MotionBlurEffect(sk_sp<Animator> animator, 41 sk_sp<sksg::RenderNode> child, 42 size_t sample_count, float phase, float dt); 43 44 const sk_sp<Animator> fAnimator; 45 const size_t fSampleCount; 46 const float fPhase, 47 fDT; 48 49 float fT = 0; 50 size_t fVisibleSampleCount = 0; 51 52 using INHERITED = sksg::CustomRenderNode; 53 }; 54 55 } // namespace internal 56 } // namespace skottie 57 58 #endif // SkottieMotionBlurEffect_DEFINED 59