1 /* 2 * Copyright (c) 2021-2022 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SHAPE_RENDER_SHAPE_CONTAINER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SHAPE_RENDER_SHAPE_CONTAINER_H 18 19 #include "frameworks/core/components/shape/shape_container_component.h" 20 #include "frameworks/core/pipeline/base/render_node.h" 21 22 namespace OHOS::Ace { 23 24 class RenderShapeContainer : public RenderNode { 25 DECLARE_ACE_TYPE(RenderShapeContainer, RenderNode); 26 27 public: 28 static RefPtr<RenderNode> Create(); 29 ~RenderShapeContainer() override = default; 30 31 void Update(const RefPtr<Component>& component) override; 32 void PerformLayout() override; 33 OnAttachContext()34 void OnAttachContext() override 35 { 36 const std::function<void()> callback = [weak = WeakClaim(this)] { 37 auto renderShapeContainer = weak.Upgrade(); 38 if (renderShapeContainer) { 39 renderShapeContainer->MarkNeedLayout(); 40 } 41 }; 42 viewBox_.SetContextAndCallback(context_, callback); 43 } 44 GetFillState()45 FillState GetFillState() const 46 { 47 return fillState_; 48 } 49 GetStrokeState()50 StrokeState GetStrokeState() const 51 { 52 return strokeState_; 53 } 54 GetAntiAlias()55 bool GetAntiAlias() const 56 { 57 return antiAlias_.first && antiAlias_.second; 58 } 59 GetShapeViewBox()60 ShapeViewBox GetShapeViewBox() const 61 { 62 return viewBox_; 63 } 64 GetMesh()65 std::vector<double> GetMesh() const 66 { 67 return mesh_; 68 } 69 GetRow()70 int32_t GetRow() const 71 { 72 return row_; 73 } 74 GetColumn()75 int32_t GetColumn() const 76 { 77 return column_; 78 } 79 protected: 80 ShapeViewBox viewBox_; 81 bool hasDefineWidth_ = false; 82 bool hasDefineHeight_ = false; 83 FillState fillState_; 84 StrokeState strokeState_; 85 std::pair<bool, bool> antiAlias_ = std::make_pair(false, true); 86 int32_t row_ = 0; 87 int32_t column_ = 0; 88 std::vector<double> mesh_; 89 }; 90 91 } // namespace OHOS::Ace 92 93 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SHAPE_RENDER_SHAPE_CONTAINER_H 94