• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_H
17 #define MATRIX_H
18 
19 #include <iostream>
20 
21 #include "drawing/engine_adapter/impl_interface/matrix_impl.h"
22 #include "utils/scalar.h"
23 
24 namespace OHOS {
25 namespace Rosen {
26 namespace Drawing {
27 class Matrix {
28 public:
29     Matrix();
~Matrix()30     virtual ~Matrix() {}
31     void Rotate(scalar degree, scalar px, scalar py);
32     void Translate(scalar dx, scalar dy);
33     void Scale(scalar sx, scalar sy, scalar px, scalar py);
34     Matrix operator*(const Matrix& other);
35     bool operator==(const Matrix& other);
36     void SetMatrix(scalar scaleX, scalar skewX, scalar transX, scalar skewY, scalar scaleY, scalar transY,
37         scalar persp0, scalar persp1, scalar persp2);
38     void MapPoints(std::vector<Point>& dst, const std::vector<Point>& src, uint32_t count) const;
39     scalar Get(int index) const;
40     template<typename T>
GetImpl()41     const std::shared_ptr<T> GetImpl() const
42     {
43         return matrixImplPtr->DowncastingTo<T>();
44     }
45 
46 private:
47     std::shared_ptr<MatrixImpl> matrixImplPtr;
48 };
49 } // namespace Drawing
50 } // namespace Rosen
51 } // namespace OHOS
52 #endif
53