1 /* 2 * Copyright (c) 2021 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 SKIA_PATH_H 17 #define SKIA_PATH_H 18 19 #include "include/core/SkPath.h" 20 21 #include "impl_interface/path_impl.h" 22 23 namespace OHOS { 24 namespace Rosen { 25 namespace Drawing { 26 class SkiaPath : public PathImpl { 27 public: 28 static inline constexpr AdapterType TYPE = AdapterType::SKIA_ADAPTER; 29 SkiaPath() noexcept; ~SkiaPath()30 ~SkiaPath() override {}; 31 SkiaPath(const SkiaPath& p) noexcept; 32 SkiaPath &operator=(const SkiaPath& p) noexcept; GetType()33 AdapterType GetType() const override 34 { 35 return AdapterType::SKIA_ADAPTER; 36 } 37 PathImpl* Clone() override; 38 void MoveTo(scalar x, scalar y) override; 39 void LineTo(scalar x, scalar y) override; 40 void ArcTo(scalar pt1X, scalar pt1Y, scalar pt2X, scalar pt2Y, scalar startAngle, scalar sweepAngle) override; 41 void ArcTo(scalar rx, scalar ry, scalar angle, PathDirection direction, scalar endX, scalar endY) override; 42 void CubicTo( 43 scalar ctrlPt1X, scalar ctrlPt1Y, scalar ctrlPt2X, scalar ctrlPt2Y, scalar endPtX, scalar endPtY) override; 44 void QuadTo(scalar ctrlPtX, scalar ctrlPtY, scalar endPtX, scalar endPtY) override; 45 46 void AddRect(scalar left, scalar top, scalar right, scalar bottom, PathDirection dir) override; 47 void AddOval(scalar left, scalar top, scalar right, scalar bottom, PathDirection dir) override; 48 void AddArc(scalar left, scalar top, scalar right, scalar bottom, scalar startAngle, scalar sweepAngle) override; 49 void AddPoly(const std::vector<Point>& points, int count, bool close) override; 50 void AddCircle(scalar x, scalar y, scalar radius, PathDirection dir) override; 51 void AddRoundRect(scalar left, scalar top, scalar right, scalar bottom, scalar xRadius, scalar yRadius, 52 PathDirection dir) override; 53 54 void AddPath(const Path& src, scalar dx, scalar dy) override; 55 void AddPath(const Path& src) override; 56 void AddPathWithMatrix(const Path& src, const Matrix& matrix) override; 57 58 Rect GetBounds() const override; 59 void SetFillStyle(PathFillType fillstyle) override; 60 61 bool Interpolate(const Path& ending, scalar weight, Path& out) override; 62 void Transform(const Matrix& matrix) override; 63 void Offset(scalar dx, scalar dy) override; 64 bool OpWith(const Path& path1, const Path& path2, PathOp op) override; 65 66 void Reset() override; 67 68 void Close() override; 69 70 void SetPath(const SkPath& path); 71 72 const SkPath& GetPath() const; 73 74 private: 75 SkPath path_; 76 }; 77 } // namespace Drawing 78 } // namespace Rosen 79 } // namespace OHOS 80 #endif