1 /* 2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef MATRIX_IMPL_H 17 #define MATRIX_IMPL_H 18 19 #include <vector> 20 21 #include "base_impl.h" 22 23 #include "utils/point.h" 24 #include "utils/rect.h" 25 #include "utils/scalar.h" 26 27 namespace OHOS { 28 namespace Rosen { 29 namespace Drawing { 30 class DRAWING_API Matrix; 31 class DRAWING_API Matrix44; 32 class MatrixImpl : public BaseImpl { 33 public: 34 // Matrix is a 3x3 float type matrix. 35 static constexpr int MATRIX_SIZE = 9; 36 MatrixImpl()37 MatrixImpl() {} ~MatrixImpl()38 ~MatrixImpl() override {} 39 40 virtual void Rotate(scalar degree, scalar px, scalar py) = 0; 41 virtual void Translate(scalar dx, scalar dy) = 0; 42 virtual void Scale(scalar sx, scalar sy, scalar px, scalar py) = 0; 43 virtual void SetScale(scalar sx, scalar sy) = 0; 44 virtual void SetScaleTranslate(scalar sx, scalar sy, scalar dx, scalar dy) = 0; 45 46 virtual void PreRotate(scalar degree) = 0; 47 virtual void PostRotate(scalar degree) = 0; 48 virtual void PostRotate(scalar degree, scalar px, scalar py) = 0; 49 virtual void PreTranslate(scalar dx, scalar dy) = 0; 50 virtual void PostTranslate(scalar dx, scalar dy) = 0; 51 virtual void PreScale(scalar sx, scalar sy) = 0; 52 virtual void PostScale(scalar sx, scalar sy) = 0; 53 virtual void PostScale(scalar sx, scalar sy, scalar px, scalar py) = 0; 54 virtual void PreConcat(const Matrix& other) = 0; 55 virtual void PreConcat(const Matrix44& other) = 0; 56 virtual void PostConcat(const Matrix& other) = 0; 57 virtual void PostConcat(const Matrix44& other) = 0; 58 59 virtual bool Invert(Matrix& inverse) const = 0; 60 virtual void Multiply(const Matrix& a, const Matrix& b) = 0; 61 virtual bool Equals(const Matrix& a, const Matrix& b) const = 0; 62 virtual void SetMatrix(scalar scaleX, scalar skewX, scalar transX, scalar skewY, scalar scaleY, scalar transY, 63 scalar persp0, scalar persp1, scalar persp2) = 0; 64 virtual void MapPoints(std::vector<Point>& dst, const std::vector<Point>& src, uint32_t count) const; 65 virtual bool MapRect(Rect& dst, const Rect& src) const; 66 virtual void Set(int index, scalar value); 67 virtual scalar Get(int index) const = 0; 68 virtual void GetAll(std::array<scalar, MATRIX_SIZE>& buffer) const = 0; 69 virtual void SetAll(std::array<scalar, MATRIX_SIZE>& buffer) = 0; 70 virtual bool IsIdentity() const = 0; 71 virtual void Clone(const Matrix&) = 0; 72 virtual void PreRotate(scalar degree, scalar px, scalar py) = 0; 73 virtual void PreScale(scalar sx, scalar sy, scalar px, scalar py) = 0; 74 virtual void Reset() = 0; 75 76 virtual bool GetMinMaxScales(scalar scaleFactors[2]) = 0; 77 virtual bool HasPerspective() const = 0; 78 }; 79 } // namespace Drawing 80 } // namespace Rosen 81 } // namespace OHOS 82 #endif 83