1 /* 2 * Copyright 2020 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 SkottieExternalLayer_DEFINED 9 #define SkottieExternalLayer_DEFINED 10 11 #include "include/core/SkRefCnt.h" 12 13 class SkCanvas; 14 struct SkSize; 15 16 namespace skottie { 17 18 /** 19 * Interface for externally-rendered layers. 20 */ 21 class ExternalLayer : public SkRefCnt { 22 public: 23 /** Render layer content into the given canvas. 24 * 25 * @param canvas Destination canvas 26 * @param t Time in seconds, relative to the layer in-point (start time) 27 */ 28 virtual void render(SkCanvas* canvas, double t) = 0; 29 }; 30 31 /** 32 * Interface for intercepting pre-composed layer creation. 33 * 34 * Embedders can register interceptors with animation builders, to substitute target layers 35 * with arbitrary/externally-controlled content (see ExternalLayer above). 36 */ 37 class PrecompInterceptor : public SkRefCnt { 38 public: 39 /** 40 * Invoked at animation build time, for each precomp layer. 41 * 42 * @param id The target composition ID (usually assigned automatically by BM: comp_0, ...) 43 * @param name The name of the precomp layer (by default it matches the target comp name, 44 * but can be changed in AE) 45 * @param size Lottie-specified precomp layer size 46 * @return An ExternalLayer implementation (to be used instead of the actual Lottie file 47 * content), or nullptr (to use the Lottie file content). 48 */ 49 virtual sk_sp<ExternalLayer> onLoadPrecomp(const char id[], 50 const char name[], 51 const SkSize& size) = 0; 52 }; 53 54 } // namespace skottie 55 56 #endif // SkottieExternalLayer_DEFINED 57