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_PLUGIN_RENDER_PLUGIN_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_PLUGIN_RENDER_PLUGIN_H 18 19 #include "core/components/plugin/plugin_component.h" 20 #include "core/components/plugin/plugin_sub_container.h" 21 #include "core/pipeline/base/render_sub_container.h" 22 23 namespace OHOS::Ace { 24 class RenderPlugin : public RenderSubContainer { 25 DECLARE_ACE_TYPE(RenderPlugin, RenderSubContainer); 26 27 public: 28 static RefPtr<RenderNode> Create(); 29 30 ~RenderPlugin() override = default; 31 32 void Update(const RefPtr<Component>& component) override; 33 void PerformLayout() override; 34 GetDrawDelegate()35 virtual std::unique_ptr<DrawDelegate> GetDrawDelegate() 36 { 37 return nullptr; 38 } RemoveChildren()39 virtual void RemoveChildren() {} 40 SetPluginSubContainer(const WeakPtr<PluginSubContainer> & container)41 void SetPluginSubContainer(const WeakPtr<PluginSubContainer>& container) 42 { 43 pluginContainer_ = container; 44 } 45 GetSubPipelineContext()46 RefPtr<PipelineBase> GetSubPipelineContext() override 47 { 48 auto context = pluginContainer_.Upgrade(); 49 if (context) { 50 return context->GetPipelineContext(); 51 } 52 return nullptr; 53 } 54 55 bool TouchTest(const Point& globalPoint, const Point& parentLocalPoint, const TouchRestrict& touchRestrict, 56 TouchTestResult& result) override; 57 58 private: 59 Dimension rootWidth_ = 0.0_vp; 60 Dimension rootHeight_ = 0.0_vp; 61 Size drawSize_; 62 WeakPtr<PluginSubContainer> pluginContainer_; 63 }; 64 } // namespace OHOS::Ace 65 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_PLUGIN_RENDER_PLUGIN_H 66