1 /*
2  * Copyright (c) 2022-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 RENDER_SERVICE_CLIENT_CORE_PIPELINE_OVERDRAW_RS_LISTENED_CANVAS_H
17 #define RENDER_SERVICE_CLIENT_CORE_PIPELINE_OVERDRAW_RS_LISTENED_CANVAS_H
18 
19 #include "pipeline/rs_paint_filter_canvas.h"
20 
21 namespace OHOS {
22 namespace Rosen {
23 class RSCanvasListener;
24 
25 class RSB_EXPORT RSListenedCanvas : public RSPaintFilterCanvas {
26 public:
27     RSListenedCanvas(Drawing::Canvas& canvas);
28     RSListenedCanvas(Drawing::Surface& surface);
29 
30     void SetListener(const std::shared_ptr<RSCanvasListener>& listener);
31     // shapes
32     void DrawPoint(const Drawing::Point& point) override;
33     void DrawLine(const Drawing::Point& startPt, const Drawing::Point& endPt) override;
34     void DrawRect(const Drawing::Rect& rect) override;
35     void DrawRoundRect(const Drawing::RoundRect& roundRect) override;
36     void DrawNestedRoundRect(const Drawing::RoundRect& outer, const Drawing::RoundRect& inner) override;
37     void DrawArc(const Drawing::Rect& oval, Drawing::scalar startAngle, Drawing::scalar sweepAngle) override;
38     void DrawPie(const Drawing::Rect& oval, Drawing::scalar startAngle, Drawing::scalar sweepAngle) override;
39     void DrawOval(const Drawing::Rect& oval) override;
40     void DrawCircle(const Drawing::Point& centerPt, Drawing::scalar radius) override;
41     void DrawPath(const Drawing::Path& path) override;
42     void DrawBackground(const Drawing::Brush& brush) override;
43     void DrawShadow(const Drawing::Path& path, const Drawing::Point3& planeParams,
44         const Drawing::Point3& devLightPos, Drawing::scalar lightRadius,
45         Drawing::Color ambientColor, Drawing::Color spotColor, Drawing::ShadowFlags flag) override;
46     void DrawShadowStyle(const Drawing::Path& path, const Drawing::Point3& planeParams,
47         const Drawing::Point3& devLightPos, Drawing::scalar lightRadius,
48         Drawing::Color ambientColor, Drawing::Color spotColor, Drawing::ShadowFlags flag,
49         bool isLimitElevation) override;
50     void DrawRegion(const Drawing::Region& region) override;
51     void DrawTextBlob(const Drawing::TextBlob* blob, const Drawing::scalar x, const Drawing::scalar y) override;
52 
53     // image
54     void DrawBitmap(const Drawing::Bitmap& bitmap, const Drawing::scalar px, const Drawing::scalar py) override;
55     void DrawImage(const Drawing::Image& image,
56         const Drawing::scalar px, const Drawing::scalar py, const Drawing::SamplingOptions& sampling) override;
57     void DrawImageRect(const Drawing::Image& image,
58         const Drawing::Rect& src, const Drawing::Rect& dst, const Drawing::SamplingOptions& sampling,
59         Drawing::SrcRectConstraint constraint = Drawing::SrcRectConstraint::STRICT_SRC_RECT_CONSTRAINT) override;
60     void DrawImageRect(const Drawing::Image& image,
61         const Drawing::Rect& dst, const Drawing::SamplingOptions& sampling) override;
62     void DrawPicture(const Drawing::Picture& picture) override;
63 
64     void Clear(Drawing::ColorQuad color) override;
65     // paint
66     CoreCanvas& AttachPen(const Drawing::Pen& pen) override;
67     CoreCanvas& AttachBrush(const Drawing::Brush& brush) override;
68     CoreCanvas& DetachPen() override;
69     CoreCanvas& DetachBrush() override;
70 
71 private:
72     std::shared_ptr<RSCanvasListener> listener_ = nullptr;
73 };
74 } // namespace Rosen
75 } // namespace OHOS
76 
77 #endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_OVERDRAW_RS_LISTENED_CANVAS_H
78