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 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 void Multiply(const Matrix& a, const Matrix& b) override; 43 bool Equals(const Matrix& a, const Matrix& b) const override; 44 void SetMatrix(scalar scaleX, scalar skewX, scalar transX, scalar skewY, scalar scaleY, scalar transY, 45 scalar persp0, scalar persp1, scalar persp2) override; 46 void MapPoints(std::vector<Point>& dst, const std::vector<Point>& src, uint32_t count) const override; 47 scalar Get(int index) const override; 48 49 private: 50 SkMatrix skMatrix_; 51 }; 52 } // namespace Drawing 53 } // namespace Rosen 54 } // namespace OHOS 55 #endif