• 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 #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 
operator *(const Matrix & m)42 Matrix Matrix::operator*(const Matrix& m)
43 {
44     matrixImplPtr->Multiply(*this, m);
45     return *this;
46 }
47 
operator ==(const Matrix & m)48 bool Matrix::operator==(const Matrix& m)
49 {
50     return matrixImplPtr->Equals(*this, m);
51 }
52 
SetMatrix(scalar scaleX,scalar skewX,scalar transX,scalar skewY,scalar scaleY,scalar transY,scalar persp0,scalar persp1,scalar persp2)53 void Matrix::SetMatrix(scalar scaleX, scalar skewX, scalar transX, scalar skewY, scalar scaleY, scalar transY,
54     scalar persp0, scalar persp1, scalar persp2)
55 {
56     matrixImplPtr->SetMatrix(scaleX, skewX, transX, skewY, scaleY, transY, persp0, persp1, persp2);
57 }
58 
MapPoints(std::vector<Point> & dst,const std::vector<Point> & src,uint32_t count) const59 void Matrix::MapPoints(std::vector<Point>& dst, const std::vector<Point>& src, uint32_t count) const
60 {
61     matrixImplPtr->MapPoints(dst, src, count);
62 }
63 
Get(int index) const64 scalar Matrix::Get(int index) const
65 {
66     return matrixImplPtr->Get(index);
67 }
68 } // namespace Drawing
69 } // namespace Rosen
70 } // namespace OHOS
71