• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_FLOW_MATRIX_DECOMPOSITION_H_
6 #define FLUTTER_FLOW_MATRIX_DECOMPOSITION_H_
7 
8 #include "flutter/fml/macros.h"
9 #include "third_party/skia/include/core/SkMatrix.h"
10 #include "third_party/skia/include/core/SkMatrix44.h"
11 #include "third_party/skia/include/core/SkPoint3.h"
12 
13 namespace flutter {
14 
15 /// Decomposes a given non-degenerate transformation matrix into a sequence of
16 /// operations that produced it. The validity of the decomposition must always
17 /// be checked before attempting to access any of the decomposed elements.
18 class MatrixDecomposition {
19  public:
20   MatrixDecomposition(const SkMatrix& matrix);
21 
22   MatrixDecomposition(SkMatrix44 matrix);
23 
24   ~MatrixDecomposition();
25 
26   bool IsValid() const;
27 
translation()28   const SkVector3& translation() const { return translation_; }
29 
scale()30   const SkVector3& scale() const { return scale_; }
31 
shear()32   const SkVector3& shear() const { return shear_; }
33 
perspective()34   const SkVector4& perspective() const { return perspective_; }
35 
rotation()36   const SkVector4& rotation() const { return rotation_; }
37 
38  private:
39   bool valid_;
40   SkVector3 translation_;
41   SkVector3 scale_;
42   SkVector3 shear_;
43   SkVector4 perspective_;
44   SkVector4 rotation_;
45 
46   FML_DISALLOW_COPY_AND_ASSIGN(MatrixDecomposition);
47 };
48 
49 }  // namespace flutter
50 
51 #endif  // FLUTTER_FLOW_MATRIX_DECOMPOSITION_H_
52