1 /* 2 * Copyright (c) 2025 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 CJ_MATRIX_H 17 #define CJ_MATRIX_H 18 19 #include "cj_common_ffi.h" 20 #include "cj_drawing_util.h" 21 #include "ffi_remote_data.h" 22 #include "utils/matrix.h" 23 24 namespace OHOS { 25 namespace CJDrawing { 26 27 class CjMatrix : public OHOS::FFI::FFIData { DECL_TYPE(CjMatrix,OHOS::FFI::FFIData)28 DECL_TYPE(CjMatrix, OHOS::FFI::FFIData) 29 public: 30 explicit CjMatrix(std::shared_ptr<Rosen::Drawing::Matrix> ptr) : m_matrix(ptr) {}; 31 virtual ~CjMatrix(); 32 int32_t SetRotation(scalar degree, scalar px, scalar py); 33 int32_t SetScale(scalar sx, scalar sy, scalar px, scalar py); 34 int32_t SetTranslation(scalar dx, scalar dy); 35 int32_t SetSkew(scalar kx, scalar ky, scalar px, scalar py); 36 int32_t SetConcat(CjMatrix& matrix1, CjMatrix& matrix2); 37 int32_t SetSinCos(scalar sinValue, scalar cosValue, scalar px, scalar py); 38 int32_t SetMatrix(const CArrFloat& values); 39 int32_t SetMatrixByMatrix(CjMatrix& matrix); 40 int32_t PostRotate(scalar degree, scalar px, scalar py); 41 int32_t PostScale(scalar sx, scalar sy, scalar px, scalar py); 42 int32_t PostTranslate(scalar dx, scalar dy); 43 int32_t PostSkew(scalar kx, scalar ky, scalar px, scalar py); 44 int32_t PostConcat(CjMatrix& matrix); 45 int32_t PreRotate(scalar degree, scalar px, scalar py); 46 int32_t PreScale(scalar sx, scalar sy, scalar px, scalar py); 47 int32_t PreTranslate(scalar dx, scalar dy); 48 int32_t PreSkew(scalar kx, scalar ky, scalar px, scalar py); 49 int32_t PreConcat(CjMatrix& matrix); 50 RetDataBool Invert(CjMatrix& matrix); 51 int32_t Reset(); 52 RetDataBool IsEqual(CjMatrix& matrix); 53 RetDataBool IsIdentity(); 54 RetDataBool IsAffine(); 55 RetDataBool RectStaysRect(); 56 RetDataScalar GetValue(int64_t index); 57 int32_t GetAll(const CArrFloat& arr); 58 RetDataScalar MapRadius(scalar radius); 59 int32_t MapPoints(const CArrPoint& src, const CArrPoint& dst); 60 RetDataBool MapRect(CRect& dst, const CRect& src); 61 RetDataBool SetRectToRect(const CRect& src, const CRect& dst, int32_t scaleToFit); 62 RetDataBool SetPolyToPoly(const CArrPoint& src, const CArrPoint& dst, int64_t count); 63 64 std::shared_ptr<Rosen::Drawing::Matrix> GetMatrix(); 65 static int64_t CreateCjMatrix(int64_t id); 66 67 private: 68 std::shared_ptr<Rosen::Drawing::Matrix> m_matrix = nullptr; 69 }; 70 71 } // CJDrawing 72 } // OHOS 73 #endif // CJ_MATRIX_H 74