1 /* 2 * Copyright (c) 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_ADAPTER_IMAGE_PAINTER_UTILS_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_ADAPTER_IMAGE_PAINTER_UTILS_H 18 19 #ifndef USE_ROSEN_DRAWING 20 #include "include/core/SkPaint.h" 21 #include "include/core/SkPoint.h" 22 #include "include/core/SkSamplingOptions.h" 23 #endif 24 25 #include "core/components_ng/render/canvas_image.h" 26 #ifdef USE_ROSEN_DRAWING 27 #include "core/components_ng/render/drawing.h" 28 #endif 29 30 namespace OHOS::Ace::NG { 31 class ImagePainterUtils { 32 public: 33 static constexpr uint8_t RADIUS_POINTS_SIZE = 4; 34 #ifndef USE_ROSEN_DRAWING 35 static std::unique_ptr<SkVector[]> ToSkRadius(const BorderRadiusArray& radiusXY); 36 static void ClipRRect(RSCanvas& canvas, const RSRect& dstRect, const BorderRadiusArray& radiusXY); 37 38 static void AddFilter(SkPaint& paint, SkSamplingOptions& options, const ImagePaintConfig& config); 39 #else 40 static std::unique_ptr<RSPoint[]> ToRSRadius(const BorderRadiusArray& radiusXY); 41 static void ClipRRect(RSCanvas& canvas, const RSRect& dstRect, const BorderRadiusArray& radiusXY); 42 static void AddFilter(RSBrush& brush, RSSamplingOptions& options, const ImagePaintConfig& config); 43 #endif 44 }; 45 } // namespace OHOS::Ace::NG 46 47 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_ADAPTER_IMAGE_PAINTER_UTILS_H 48