• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifdef NEW_SKIA
23 #include "include/core/SkSamplingOptions.h"
24 #endif
25 #endif
26 
27 #include "core/components_ng/render/canvas_image.h"
28 #ifdef USE_ROSEN_DRAWING
29 #include "core/components_ng/render/drawing.h"
30 #endif
31 
32 namespace OHOS::Ace::NG {
33 class ImagePainterUtils {
34 public:
35     static constexpr uint8_t RADIUS_POINTS_SIZE = 4;
36 #ifndef USE_ROSEN_DRAWING
37     static std::unique_ptr<SkVector[]> ToSkRadius(const BorderRadiusArray& radiusXY);
38     static void ClipRRect(RSCanvas& canvas, const RSRect& dstRect, const BorderRadiusArray& radiusXY);
39 #ifndef NEW_SKIA
40     static void AddFilter(SkPaint& paint, const ImagePaintConfig& config);
41 #else
42     static void AddFilter(SkPaint& paint, SkSamplingOptions& options, const ImagePaintConfig& config);
43  #endif
44 #else
45     static std::unique_ptr<RSPoint[]> ToRSRadius(const BorderRadiusArray& radiusXY);
46     static void ClipRRect(RSCanvas& canvas, const RSRect& dstRect, const BorderRadiusArray& radiusXY);
47     static void AddFilter(RSBrush& brush, RSSamplingOptions& options, const ImagePaintConfig& config);
48  #endif
49 };
50 } // namespace OHOS::Ace::NG
51 
52 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_ADAPTER_IMAGE_PAINTER_UTILS_H
53