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, Drawing::Color ambientColor, 48 Drawing::Color spotColor, Drawing::ShadowFlags flag, bool isLimitElevation) override; 49 void DrawRegion(const Drawing::Region& region) override; 50 void DrawTextBlob(const Drawing::TextBlob* blob, const Drawing::scalar x, const Drawing::scalar y) override; 51 52 // image 53 void DrawBitmap(const Drawing::Bitmap& bitmap, const Drawing::scalar px, const Drawing::scalar py) override; 54 void DrawImage(const Drawing::Image& image, 55 const Drawing::scalar px, const Drawing::scalar py, const Drawing::SamplingOptions& sampling) override; 56 void DrawImageRect(const Drawing::Image& image, 57 const Drawing::Rect& src, const Drawing::Rect& dst, const Drawing::SamplingOptions& sampling, 58 Drawing::SrcRectConstraint constraint = Drawing::SrcRectConstraint::STRICT_SRC_RECT_CONSTRAINT) override; 59 void DrawImageRect(const Drawing::Image& image, 60 const Drawing::Rect& dst, const Drawing::SamplingOptions& sampling) override; 61 void DrawPicture(const Drawing::Picture& picture) override; 62 63 void Clear(Drawing::ColorQuad color) override; 64 // paint 65 CoreCanvas& AttachPen(const Drawing::Pen& pen) override; 66 CoreCanvas& AttachBrush(const Drawing::Brush& brush) override; 67 CoreCanvas& DetachPen() override; 68 CoreCanvas& DetachBrush() override; 69 70 private: 71 std::shared_ptr<RSCanvasListener> listener_ = nullptr; 72 }; 73 } // namespace Rosen 74 } // namespace OHOS 75 76 #endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_OVERDRAW_RS_LISTENED_CANVAS_H 77