2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30 enum class Axis { X, Y, Z };
31 enum class MatrixType: unsigned char {
40 bool isAffine() const;
41 bool isIdentity() const;
42 bool isInvertible() const;
43 bool isScaling() const;
44 bool isRotating() const;
45 bool isTranslating() const;
46 MatrixType type() const;
47 inline float determinant() const;
49 VMatrix &translate(VPointF pos) { return translate(pos.x(), pos.y()); };
50 VMatrix &translate(float dx, float dy);
51 VMatrix &scale(VPointF s) { return scale(s.x(), s.y()); };
52 VMatrix &scale(float sx, float sy);
53 VMatrix &shear(float sh, float sv);
54 VMatrix &rotate(float a, Axis axis = VMatrix::Axis::Z);
55 VMatrix &rotateRadians(float a, Axis axis = VMatrix::Axis::Z);
57 VPointF map(const VPointF &p) const;
58 inline VPointF map(float x, float y) const;
59 VRect map(const VRect &r) const;
60 VRegion map(const VRegion &r) const;
62 V_REQUIRED_RESULT VMatrix inverted(bool *invertible = nullptr) const;
63 V_REQUIRED_RESULT VMatrix adjoint() const;
65 VMatrix operator*(const VMatrix &o) const;
66 VMatrix & operator*=(const VMatrix &);
67 VMatrix & operator*=(float mul);
68 VMatrix & operator/=(float div);
69 bool operator==(const VMatrix &) const;
70 bool operator!=(const VMatrix &) const;
71 bool fuzzyCompare(const VMatrix &) const;
72 friend std::ostream &operator<<(std::ostream &os, const VMatrix &o);
75 friend struct VSpanData;
76 float m11{1}, m12{0}, m13{0};
77 float m21{0}, m22{1}, m23{0};
78 float mtx{0}, mty{0}, m33{1};
79 mutable MatrixType mType{MatrixType::None};
80 mutable MatrixType dirty{MatrixType::None};
83 inline VPointF VMatrix::map(float x, float y) const
85 return map(VPointF(x, y));