• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_SKIA_PAINT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_ADAPTER_SKIA_PAINT_H
18 
19 #include "third_party/skia/include/core/SkPaint.h"
20 
21 #ifdef NG_BUILD
22 #include "third_party/skia/include/core/SkSamplingOptions.h"
23 #endif
24 
25 #include "core/components/common/properties/color.h"
26 #include "core/components_ng/render/paint.h"
27 
28 namespace OHOS::Ace::NG {
29 
30 // Paint is interface for drawing styles.
31 class SkiaPaint : public Paint {
32     DECLARE_ACE_TYPE(NG::SkiaPaint, NG::Paint)
33 
34 public:
35     static RefPtr<Paint> Create();
36     SkiaPaint() = default;
37     ~SkiaPaint() = default;
38 
39     void Reset() override;
40 
41     void EnableAntiAlias() override;
42     void SetFilterQuality(FilterQuality quality) override;
43 
44     void SetStyle(PaintStyle style) override;
45     void SetColor(const Color& color) override;
46     void SetStrokeWidth(float width) override;
47     void SetAlphaf(float alpha) override;
48     void SetBlendMode(BlendMode blendMode) override;
49     void SetStrokeCap(LineCap lineCap) override;
50     void SetColorFilter(const RefPtr<ColorFilter>& colorFilter) override;
51 
GetRawPaint()52     const SkPaint& GetRawPaint()
53     {
54         return rawPaint_;
55     }
56 
57 #ifdef NG_BUILD
GetSamplingOptions()58     const SkSamplingOptions& GetSamplingOptions()
59     {
60         return options_;
61     }
62 #endif
63 
64 private:
65     SkPaint rawPaint_;
66 #ifdef NG_BUILD
67     SkSamplingOptions options_;
68 #endif
69 };
70 
71 } // namespace OHOS::Ace::NG
72 
73 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_ADAPTER_SKIA_PAINT_H
74