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 SkottieComposition_DEFINED
9 #define SkottieComposition_DEFINED
10 
11 #include "modules/skottie/src/SkottiePriv.h"
12 
13 #include "include/private/SkTHash.h"
14 #include "modules/skottie/src/Layer.h"
15 
16 #include <vector>
17 
18 namespace skottie {
19 namespace internal {
20 
21 class CompositionBuilder final : SkNoncopyable {
22 public:
23     CompositionBuilder(const AnimationBuilder&, const SkSize&, const skjson::ObjectValue&);
24     ~CompositionBuilder();
25 
26     sk_sp<sksg::RenderNode> build(const AnimationBuilder&);
27 
28     LayerBuilder* layerBuilder(int layer_index);
29 
30 private:
getCameraTransform()31     const sk_sp<sksg::Transform>& getCameraTransform() const { return fCameraTransform; }
32 
33     friend class LayerBuilder;
34 
35     const SkSize              fSize;
36 
37     std::vector<LayerBuilder> fLayerBuilders;
38     SkTHashMap<int, size_t>   fLayerIndexMap; // Maps layer "ind" to layer builder index.
39 
40     sk_sp<sksg::Transform>    fCameraTransform;
41 
42     size_t                    fMotionBlurSamples = 1;
43     float                     fMotionBlurAngle   = 0,
44                               fMotionBlurPhase   = 0;
45 };
46 
47 } // namespace internal
48 } // namespace skottie
49 
50 #endif // SkottieComposition_DEFINED
51