1 /* 2 * Copyright (c) 2024-2025 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_ITERATOR_H 17 #define PATH_ITERATOR_H 18 19 #include <memory> 20 #include <vector> 21 22 #include "common/rs_macros.h" 23 #include "draw/path.h" 24 #include "drawing/engine_adapter/impl_interface/path_iterator_impl.h" 25 #include "utils/scalar.h" 26 27 namespace OHOS { 28 namespace Rosen { 29 namespace Drawing { 30 enum class PathVerb { 31 UNINIT = -1, 32 MOVE, 33 LINE, 34 QUAD, 35 CONIC, 36 CUBIC, 37 CLOSE, 38 DONE = CLOSE + 1 39 }; 40 41 class DRAWING_API PathIterator { 42 public: 43 PathIterator(const Path &path) noexcept; 44 virtual ~PathIterator(); 45 scalar ConicWeight() const; 46 PathVerb Next(Point* points); 47 PathVerb Peek(); 48 49 template<typename T> GetImpl()50 T* GetImpl() const 51 { 52 return impl_->DowncastingTo<T>(); 53 } 54 private: 55 std::shared_ptr<PathIteratorImpl> impl_; 56 }; 57 58 class DRAWING_API PathIter { 59 public: 60 PathIter(const Path& path, bool forceClose) noexcept; 61 virtual ~PathIter(); 62 scalar ConicWeight() const; 63 PathVerb Next(Point* points); 64 65 template<typename T> GetImpl()66 T* GetImpl() const 67 { 68 return impl_->DowncastingTo<T>(); 69 } 70 71 private: 72 std::shared_ptr<PathIterImpl> impl_; 73 }; 74 } // namespace Drawing 75 } // namespace Rosen 76 } // namespace OHOS 77 #endif 78