• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 SkottieCamera_DEFINED
9 #define SkottieCamera_DEFINED
10 
11 #include "modules/skottie/src/Transform.h"
12 
13 namespace skottie {
14 namespace internal {
15 
16 class CameraAdaper final : public TransformAdapter3D {
17 public:
18     CameraAdaper(const skjson::ObjectValue& jlayer,
19                  const skjson::ObjectValue& jtransform,
20                  const AnimationBuilder& abuilder,
21                  const SkSize& viewport_size);
22     ~CameraAdaper() override;
23 
24     // Used in the absence of an explicit camera layer.
25     static sk_sp<sksg::Transform> DefaultCameraTransform(const SkSize& viewport_size);
26 
27     SkM44 totalMatrix() const override;
28 
29 private:
30     enum class CameraType {
31         kOneNode, // implicitly facing forward (decreasing z), does not auto-orient
32         kTwoNode, // explicitly facing a POI (the anchor point), auto-orients
33     };
34 
35     SkV3 poi(const SkV3& pos) const;
36 
37     const SkSize     fViewportSize;
38     const CameraType fType;
39 
40     ScalarValue fZoom = 0;
41 
42     using INHERITED = TransformAdapter3D;
43 };
44 
45 } // namespace internal
46 } // namespace skottie
47 
48 #endif // SkottieCamera_DEFINED
49