1 /* 2 * Copyright (c) 2024 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_SVG_SVG_IMAGE_FIT_CONVERTOR_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_SVG_SVG_IMAGE_FIT_CONVERTOR_H 18 19 #include "core/components_ng/render/drawing.h" 20 #include "core/components/common/properties/alignment.h" 21 #include "core/components/common/layout/constants.h" 22 23 namespace OHOS::Ace::NG { 24 class SvgFitConvertor { 25 public: 26 SvgFitConvertor(); 27 ~SvgFitConvertor(); 28 29 static void ApplyFit(ImageFit imageFit, RSCanvas& canvas, const Size& layoutSize, const Size& svgSize); 30 static void ApplyFill(RSCanvas& canvas, const Size& layoutSize, const Size& svgSize); 31 static void ApplyContain(RSCanvas& canvas, const Size& layoutSize, const Size& svgSize); 32 static void ApplyCover(RSCanvas& canvas, const Size& layoutSize, const Size& svgSize); 33 static void ApplyWidth(RSCanvas& canvas, const Size& layoutSize, const Size& svgSize); 34 static void ApplyHeight(RSCanvas& canvas, const Size& layoutSize, const Size& svgSize); 35 static void ApplyNone(RSCanvas& canvas, const Size& layoutSize, const Size& svgSize); 36 static void ApplyScaleDown(RSCanvas& canvas, const Size& layoutSize, const Size& svgSize); 37 static void ApplyAlignmentTopLeft(RSCanvas& canvas, const Size& layoutSize, const Size& svgSize); 38 static void ApplyAlignmentTop(RSCanvas& canvas, const Size& layoutSize, const Size& svgSize); 39 static void ApplyAlignmentTopRight(RSCanvas& canvas, const Size& layoutSize, const Size& svgSize); 40 static void ApplyAlignmentCenterLeft(RSCanvas& canvas, const Size& layoutSize, const Size& svgSize); 41 static void ApplyAlignmentCenter(RSCanvas& canvas, const Size& layoutSize, const Size& svgSize); 42 static void ApplyAlignmentCenterRight(RSCanvas& canvas, const Size& layoutSize, const Size& svgSize); 43 static void ApplyAlignmentBottomLeft(RSCanvas& canvas, const Size& layoutSize, const Size& svgSize); 44 static void ApplyAlignmentBottom(RSCanvas& canvas, const Size& layoutSize, const Size& svgSize); 45 static void ApplyAlignmentBottomRight(RSCanvas& canvas, const Size& layoutSize, const Size& svgSize); 46 static void AdjustContentFit(RSCanvas& canvas, const Size& layoutSize, const Size& svgSize, 47 float svgScale, Alignment alignMent); 48 static void DrawNothing(RSCanvas& canvas); 49 static const std::vector<void (*)(RSCanvas& canvas, const Size& layoutSize, const Size& svgSize)> FIT_OPERATIONS; 50 }; 51 } 52 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_SVG_SVG_IMAGE_FIT_CONVERTOR_H