• 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 #include "utils/matrix.h"
17 
18 #include "impl_factory.h"
19 
20 #include "utils/log.h"
21 
22 namespace OHOS {
23 namespace Rosen {
24 namespace Drawing {
Matrix()25 Matrix::Matrix() : matrixImplPtr(ImplFactory::CreateMatrixImpl()) {}
26 
Rotate(scalar degree,scalar px,scalar py)27 void Matrix::Rotate(scalar degree, scalar px, scalar py)
28 {
29     matrixImplPtr->Rotate(degree, px, py);
30 }
31 
Translate(scalar dx,scalar dy)32 void Matrix::Translate(scalar dx, scalar dy)
33 {
34     matrixImplPtr->Translate(dx, dy);
35 }
36 
Scale(scalar sx,scalar sy,scalar px,scalar py)37 void Matrix::Scale(scalar sx, scalar sy, scalar px, scalar py)
38 {
39     matrixImplPtr->Scale(sx, sy, px, py);
40 }
41 
PreRotate(scalar degree)42 void Matrix::PreRotate(scalar degree)
43 {
44     matrixImplPtr->PreRotate(degree);
45 }
46 
PreTranslate(scalar dx,scalar dy)47 void Matrix::PreTranslate(scalar dx, scalar dy)
48 {
49     matrixImplPtr->PreTranslate(dx, dy);
50 }
51 
PreScale(scalar sx,scalar sy)52 void Matrix::PreScale(scalar sx, scalar sy)
53 {
54     matrixImplPtr->PreScale(sx, sy);
55 }
56 
PreConcat(const Matrix & other)57 void Matrix::PreConcat(const Matrix& other)
58 {
59     matrixImplPtr->PreConcat(other);
60 }
61 
Invert(Matrix & inverse) const62 bool Matrix::Invert(Matrix& inverse) const
63 {
64     return matrixImplPtr->Invert(inverse);
65 }
66 
operator *(const Matrix & m)67 Matrix Matrix::operator*(const Matrix& m)
68 {
69     matrixImplPtr->Multiply(*this, m);
70     return *this;
71 }
72 
operator ==(const Matrix & m) const73 bool Matrix::operator==(const Matrix& m) const
74 {
75     return matrixImplPtr->Equals(*this, m);
76 }
77 
SetMatrix(scalar scaleX,scalar skewX,scalar transX,scalar skewY,scalar scaleY,scalar transY,scalar persp0,scalar persp1,scalar persp2)78 void Matrix::SetMatrix(scalar scaleX, scalar skewX, scalar transX, scalar skewY, scalar scaleY, scalar transY,
79     scalar persp0, scalar persp1, scalar persp2)
80 {
81     matrixImplPtr->SetMatrix(scaleX, skewX, transX, skewY, scaleY, transY, persp0, persp1, persp2);
82 }
83 
MapPoints(std::vector<Point> & dst,const std::vector<Point> & src,uint32_t count) const84 void Matrix::MapPoints(std::vector<Point>& dst, const std::vector<Point>& src, uint32_t count) const
85 {
86     matrixImplPtr->MapPoints(dst, src, count);
87 }
88 
MapRect(Rect & dst,const Rect & src) const89 bool Matrix::MapRect(Rect& dst, const Rect& src) const
90 {
91     return matrixImplPtr->MapRect(dst, src);
92 }
93 
Set(Index index,scalar value)94 void Matrix::Set(Index index, scalar value)
95 {
96     matrixImplPtr->Set(index, value);
97 }
98 
Get(int index) const99 scalar Matrix::Get(int index) const
100 {
101     return matrixImplPtr->Get(index);
102 }
103 
GetAll(Buffer & buffer) const104 void Matrix::GetAll(Buffer& buffer) const
105 {
106     matrixImplPtr->GetAll(buffer);
107 }
108 } // namespace Drawing
109 } // namespace Rosen
110 } // namespace OHOS
111