1 /*
2  * Copyright (c) 2021-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_PAINTER_ROSEN_SCROLL_BAR_PAINTER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_PAINTER_ROSEN_SCROLL_BAR_PAINTER_H
18 
19 #include "base/memory/ace_type.h"
20 #include "base/utils/utils.h"
21 #include "core/components/common/painter/debug_boundary_painter.h"
22 #include "core/components/common/properties/scroll_bar.h"
23 #include "core/pipeline/base/rosen_render_context.h"
24 
25 namespace OHOS::Ace {
26 
27 class RosenScrollBarPainter : public virtual AceType {
28     DECLARE_ACE_TYPE(RosenScrollBarPainter, AceType);
29 
30 public:
31     RosenScrollBarPainter() = default;
32     ~RosenScrollBarPainter() = default;
33 
34 #ifndef USE_ROSEN_DRAWING
35     void PaintBar(SkCanvas* canvas, const Offset& offset, const Rect& paintRect, const RefPtr<ScrollBar>& scrollBar,
36         const Offset& globalOffset, int32_t alpha);
37 #else
38     void PaintBar(RSCanvas* canvas, const Offset& offset,
39     const Rect& paintRect, const RefPtr<ScrollBar>& scrollBar, const Offset& globalOffset, int32_t alpha);
40 #endif
41 
42 private:
43 #ifndef USE_ROSEN_DRAWING
44     void RenderScrollBarBoundary(SkCanvas* canvas, const Offset& offset, double width, double height);
45     void PaintCircleBar(
46         SkCanvas* canvas, const Offset& offset, const Rect& paintRect, const RefPtr<ScrollBar>& scrollBar);
47     void PaintRectBar(SkCanvas* canvas, const Offset& offset, const RefPtr<ScrollBar>& scrollBar, int32_t alpha);
48 #else
49     void RenderScrollBarBoundary(RSCanvas* canvas, const Offset& offset, double width, double height);
50     void PaintCircleBar(RSCanvas* canvas, const Offset& offset,
51         const Rect& paintRect, const RefPtr<ScrollBar>& scrollBar);
52     void PaintRectBar(RSCanvas* canvas, const Offset& offset,
53         const RefPtr<ScrollBar>& scrollBar, int32_t alpha);
54 #endif
55 };
56 
57 } // namespace OHOS::Ace
58 
59 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_PAINTER_ROSEN_SCROLL_BAR_PAINTER_H
60