• 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 SKIA_MATRIX_H
17 #define SKIA_MATRIX_H
18 
19 #include <memory>
20 
21 #include "include/core/SkMatrix.h"
22 
23 #include "impl_interface/matrix_impl.h"
24 
25 namespace OHOS {
26 namespace Rosen {
27 namespace Drawing {
28 class SkiaMatrix : public MatrixImpl {
29 public:
30     static inline constexpr AdapterType TYPE = AdapterType::SKIA_ADAPTER;
31     SkiaMatrix();
~SkiaMatrix()32     ~SkiaMatrix() override {}
GetType()33     AdapterType GetType() const override
34     {
35         return AdapterType::SKIA_ADAPTER;
36     }
37 
38     void Rotate(scalar degree, scalar px, scalar py) override;
39     void Translate(scalar dx, scalar dy) override;
40     void Scale(scalar sx, scalar sy, scalar px, scalar py) override;
41     const SkMatrix& ExportSkiaMatrix() const;
42 
43     void PreRotate(scalar degree) override;
44     void PreTranslate(scalar dx, scalar dy) override;
45     void PreScale(scalar sx, scalar sy) override;
46     void PreConcat(const Matrix& other) override;
47 
48     bool Invert(Matrix& inverse) const override;
49     void Multiply(const Matrix& a, const Matrix& b) override;
50     bool Equals(const Matrix& a, const Matrix& b) const override;
51     void SetMatrix(scalar scaleX, scalar skewX, scalar transX, scalar skewY, scalar scaleY, scalar transY,
52         scalar persp0, scalar persp1, scalar persp2) override;
53     void MapPoints(std::vector<Point>& dst, const std::vector<Point>& src, uint32_t count) const override;
54     bool MapRect(Rect& dst, const Rect& src) const override;
55     void Set(int index, scalar value) override;
56     scalar Get(int index) const override;
57     void GetAll(std::array<scalar, MatrixImpl::MATRIX_SIZE>& buffer) const override;
58 
59     void ImportMatrix(const SkMatrix& skMatrix);
60 
61 private:
62     SkMatrix skMatrix_;
63 };
64 } // namespace Drawing
65 } // namespace Rosen
66 } // namespace OHOS
67 #endif
68