• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 Matrix;
31 class MatrixImpl : public BaseImpl {
32 public:
33     // Matrix is a 3x3 float type matrix.
34     static constexpr int MATRIX_SIZE = 9;
35 
36     static inline constexpr AdapterType TYPE = AdapterType::BASE_INTERFACE;
MatrixImpl()37     MatrixImpl() {}
~MatrixImpl()38     ~MatrixImpl() override {}
GetType()39     AdapterType GetType() const override
40     {
41         return AdapterType::BASE_INTERFACE;
42     }
43 
44     virtual void Rotate(scalar degree, scalar px, scalar py) = 0;
45     virtual void Translate(scalar dx, scalar dy) = 0;
46     virtual void Scale(scalar sx, scalar sy, scalar px, scalar py) = 0;
47 
48     virtual void PreRotate(scalar degree) = 0;
49     virtual void PreTranslate(scalar dx, scalar dy) = 0;
50     virtual void PreScale(scalar sx, scalar sy) = 0;
51     virtual void PreConcat(const Matrix& other) = 0;
52 
53     virtual bool Invert(Matrix& inverse) const = 0;
54     virtual void Multiply(const Matrix& a, const Matrix& b) = 0;
55     virtual bool Equals(const Matrix& a, const Matrix& b) const = 0;
56     virtual void SetMatrix(scalar scaleX, scalar skewX, scalar transX, scalar skewY, scalar scaleY, scalar transY,
57         scalar persp0, scalar persp1, scalar persp2) = 0;
58     virtual void MapPoints(std::vector<Point>& dst, const std::vector<Point>& src, uint32_t count) const;
59     virtual bool MapRect(Rect& dst, const Rect& src) const;
60     virtual void Set(int index, scalar value);
61     virtual scalar Get(int index) const = 0;
62     virtual void GetAll(std::array<scalar, MATRIX_SIZE>& buffer) const = 0;
63 };
64 } // namespace Drawing
65 } // namespace Rosen
66 } // namespace OHOS
67 #endif
68