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