add split mode support for router

Signed-off-by: tsj_2020 <tongshijia@huawei.com>
Change-Id: I2e01e52e9af4fabf01a1f7a2bcedfacc9c495c62
This commit is contained in:
tsj_2020 2024-06-27 14:24:29 +08:00
parent 5fa34a36b5
commit ad63ff6ee1
14 changed files with 135 additions and 11 deletions

View File

@ -55,6 +55,9 @@ declare_args() {
# Don't use currentIdSafely in some function
use_origin_scope = false
# Enable split_mode support
enable_split_mode = false
}
enable_dump_drawcmd = false

View File

@ -13,6 +13,7 @@
import("//build/ohos.gni")
import("//foundation/arkui/ace_engine/ace_config.gni")
import("//foundation/arkui/ace_engine/build/ace_ext.gni")
config("container_scope_config") {
visibility = [ ":*" ]
@ -57,6 +58,10 @@ template("ace_core_source_set") {
platform = invoker.platform
include_dirs = []
if (enable_split_mode && defined(vendor_configs.ace_advanced_split_mode)) {
include_dirs += vendor_configs.ace_advanced_split_mode_dirs
}
# add common source file needed by all product platform here
sources = [
# accessibility

View File

@ -31,6 +31,11 @@ build_component_ng("base_ng") {
"view_partial_update_model_ng.cpp",
"view_stack_processor.cpp",
]
if (enable_split_mode && defined(vendor_configs.ace_advanced_split_mode)) {
sources += vendor_configs.ace_engine_advanced_split_mode
} else {
sources += [ "view_advanced_register.cpp" ]
}
if (!use_mingw_win && !use_mac && !use_linux) {
external_deps = [ "window_manager:scene_session" ]
}

View File

@ -0,0 +1,41 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "frameworks/core/components_ng/base/view_advanced_register.h"
namespace OHOS::Ace::NG {
thread_local ViewAdvancedRegister* ViewAdvancedRegister::instance_ = nullptr;
ViewAdvancedRegister* ViewAdvancedRegister::GetInstance()
{
if (ViewAdvancedRegister::instance_ == nullptr) {
ViewAdvancedRegister::instance_ = new ViewAdvancedRegister();
}
return ViewAdvancedRegister::instance_;
}
RefPtr<Pattern> ViewAdvancedRegister::GeneratePattern(const std::string& patternName)
{
if (patternName == V2::STAGE_ETS_TAG) {
return AceType::MakeRefPtr<StagePattern>();
}
return nullptr;
}
RefPtr<StageManager> ViewAdvancedRegister::GenerateStageManager(const RefPtr<FrameNode>& stage)
{
return AceType::MakeRefPtr<StageManager>(stage);
}
} // namespace OHOS::Ace::NG

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_BASE_VIEW_ADVANCED_REGISTER_H
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_BASE_VIEW_ADVANCED_REGISTER_H
#include "frameworks/core/components_ng/pattern/pattern.h"
#include "frameworks/core/components_ng/pattern/stage/stage_manager.h"
namespace OHOS::Ace::NG {
class ACE_EXPORT ViewAdvancedRegister : public AceType {
public:
ACE_FORCE_EXPORT static ViewAdvancedRegister* GetInstance();
RefPtr<Pattern> GeneratePattern(const std::string& patternName);
RefPtr<StageManager> GenerateStageManager(const RefPtr<FrameNode>& stage);
private:
// Singleton instance
static thread_local ViewAdvancedRegister* instance_;
ViewAdvancedRegister() = default;
ACE_DISALLOW_COPY_AND_MOVE(ViewAdvancedRegister);
};
} // namespace OHOS::Ace::NG
#endif

View File

@ -564,6 +564,10 @@ build_component_ng("pattern_ng") {
external_deps += vendor_configs.ace_engine_ext_extra_deps
}
if (enable_split_mode && defined(vendor_configs.ace_advanced_split_mode)) {
sources += vendor_configs.ace_advanced_split_mode
}
if (is_ohos_standard_system) {
external_deps += [
"graphic_2d:librender_service_client",

View File

@ -37,14 +37,14 @@ public:
explicit StageManager(const RefPtr<FrameNode>& stage);
~StageManager() override = default;
bool PushPage(const RefPtr<FrameNode>& node, bool needHideLast = true, bool needTransition = true);
bool InsertPage(const RefPtr<FrameNode>& node, bool bellowTopOrBottom);
bool PopPage(bool needShowNext = true, bool needTransition = true);
bool PopPageToIndex(int32_t index, bool needShowNext = true, bool needTransition = true);
bool CleanPageStack();
bool MovePageToFront(const RefPtr<FrameNode>& node, bool needHideLast = true, bool needTransition = true);
virtual bool PushPage(const RefPtr<FrameNode>& node, bool needHideLast = true, bool needTransition = true);
virtual bool InsertPage(const RefPtr<FrameNode>& node, bool bellowTopOrBottom);
virtual bool PopPage(bool needShowNext = true, bool needTransition = true);
virtual bool PopPageToIndex(int32_t index, bool needShowNext = true, bool needTransition = true);
virtual bool CleanPageStack();
virtual bool MovePageToFront(const RefPtr<FrameNode>& node, bool needHideLast = true, bool needTransition = true);
void StartTransition(const RefPtr<FrameNode>& srcPage, const RefPtr<FrameNode>& destPage, RouteType type);
virtual void StartTransition(const RefPtr<FrameNode>& srcPage, const RefPtr<FrameNode>& destPage, RouteType type);
void PageChangeCloseKeyboard();

View File

@ -54,6 +54,8 @@ public:
onRebuildFrameCallback_ = std::move(callback);
}
virtual void SetPrimaryPage(const RefPtr<FrameNode>& primaryPage) {}
private:
std::function<void()> onRebuildFrameCallback_;
int32_t currentPageIndex_ = 0;

View File

@ -57,6 +57,7 @@
#include "core/components/common/layout/screen_system_manager.h"
#include "core/components_ng/base/frame_node.h"
#include "core/components_ng/base/ui_node.h"
#include "core/components_ng/base/view_advanced_register.h"
#include "core/components_ng/event/focus_hub.h"
#include "core/components_ng/pattern/app_bar/app_bar_view.h"
#include "core/components_ng/pattern/container_modal/container_modal_pattern.h"
@ -919,9 +920,12 @@ void PipelineContext::SetupRootElement()
rootFocusHub->SetFocusable(true);
window_->SetRootFrameNode(rootNode_);
rootNode_->AttachToMainTree(false, this);
auto stagePattern = ViewAdvancedRegister::GetInstance()->GeneratePattern(V2::STAGE_ETS_TAG);
if (!stagePattern) {
stagePattern = MakeRefPtr<StagePattern>();
}
auto stageNode = FrameNode::CreateFrameNode(
V2::STAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), MakeRefPtr<StagePattern>());
V2::STAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), stagePattern);
RefPtr<AppBarView> appBar = AceType::MakeRefPtr<AppBarView>();
auto atomicService = installationFree_ ? appBar->Create(stageNode) : nullptr;
auto container = Container::Current();
@ -950,7 +954,10 @@ void PipelineContext::SetupRootElement()
uiExtensionManager_ = MakeRefPtr<UIExtensionManager>();
#endif
accessibilityManagerNG_ = MakeRefPtr<AccessibilityManagerNG>();
stageManager_ = MakeRefPtr<StageManager>(stageNode);
stageManager_ = ViewAdvancedRegister::GetInstance()->GenerateStageManager(stageNode);
if (!stageManager_) {
stageManager_ = MakeRefPtr<StageManager>(stageNode);
}
overlayManager_ = MakeRefPtr<OverlayManager>(
DynamicCast<FrameNode>(installationFree_ ? stageNode->GetParent()->GetParent() : stageNode->GetParent()));
fullScreenManager_ = MakeRefPtr<FullScreenManager>(rootNode_);
@ -1016,7 +1023,10 @@ void PipelineContext::SetupSubRootElement()
#endif
accessibilityManagerNG_ = MakeRefPtr<AccessibilityManagerNG>();
// the subwindow for overlay not need stage
stageManager_ = MakeRefPtr<StageManager>(nullptr);
stageManager_ = ViewAdvancedRegister::GetInstance()->GenerateStageManager(nullptr);
if (!stageManager_) {
stageManager_ = MakeRefPtr<StageManager>(nullptr);
}
overlayManager_ = MakeRefPtr<OverlayManager>(rootNode_);
fullScreenManager_ = MakeRefPtr<FullScreenManager>(rootNode_);
selectOverlayManager_ = MakeRefPtr<SelectOverlayManager>(rootNode_);

View File

@ -838,6 +838,11 @@ protected:
void DoKeyboardAvoidAnimate(const KeyboardAnimationConfig& keyboardAnimationConfig, float keyboardHeight,
const std::function<void()>& func);
bool GetForceSplitEnable() const
{
return isForceSplit_;
}
private:
void ExecuteSurfaceChangedCallbacks(int32_t newWidth, int32_t newHeight, WindowSizeChangeReason type);
@ -1042,6 +1047,7 @@ private:
bool isShowTitle_ = false;
bool lastAnimationStatus_ = true;
bool isDoKeyboardAvoidAnimate_ = true;
bool isForceSplit_ = false;
std::list<FrameCallbackFunc> frameCallbackFuncs_;
uint32_t transform_ = 0;

View File

@ -132,6 +132,7 @@ ohos_source_set("ace_components_base") {
"$ace_root/frameworks/core/components_ng/base/ui_node.cpp",
"$ace_root/frameworks/core/components_ng/base/view_abstract.cpp",
"$ace_root/frameworks/core/components_ng/base/view_abstract_model_ng.cpp",
"$ace_root/frameworks/core/components_ng/base/view_advanced_register.cpp",
"$ace_root/frameworks/core/components_ng/base/view_full_update_model_ng.cpp",
"$ace_root/frameworks/core/components_ng/base/view_partial_update_model_ng.cpp",
"$ace_root/frameworks/core/components_ng/base/view_stack_processor.cpp",

View File

@ -31,6 +31,7 @@ ohos_unittest("image_provider_test_ng") {
"$ace_root/test/mock/base/mock_download_manager.cpp",
"$ace_root/test/mock/base/mock_engine_helper.cpp",
"$ace_root/test/mock/base/mock_frame_trace_adapter.cpp",
"$ace_root/test/mock/base/mock_jank_frame_report.cpp",
"$ace_root/test/mock/base/mock_localization.cpp",
"$ace_root/test/mock/base/mock_ressched_report.cpp",
"$ace_root/test/mock/base/mock_socperf_client_impl.cpp",
@ -39,6 +40,7 @@ ohos_unittest("image_provider_test_ng") {
"$ace_root/test/mock/core/common/mock_container.cpp",
"$ace_root/test/mock/core/common/mock_frame_report.cpp",
"$ace_root/test/mock/core/common/mock_layout_inspector.cpp",
"$ace_root/test/mock/core/common/mock_motion_path_evaluator.cpp",
"$ace_root/test/mock/core/common/mock_raw_recognizer.cpp",
"$ace_root/test/mock/core/event/mock_touch_event.cpp",
"$ace_root/test/mock/core/image_provider/mock_image_cache.cpp",

View File

@ -69,6 +69,7 @@ ace_unittest("pipeline_context_test_ng") {
"$ace_root/test/mock/core/common/mock_image_analyzer_mgr.cpp",
"$ace_root/test/mock/core/common/mock_interaction.cpp",
"$ace_root/test/mock/core/common/mock_layout_inspector.cpp",
"$ace_root/test/mock/core/common/mock_motion_path_evaluator.cpp",
"$ace_root/test/mock/core/common/mock_raw_recognizer.cpp",
"$ace_root/test/mock/core/common/mock_stylus_detector_default.cpp",
"$ace_root/test/mock/core/common/mock_stylus_detector_mgr.cpp",

View File

@ -71,11 +71,13 @@ ohos_unittest("form_render_test") {
"$ace_root/test/mock/base/mock_ace_performance_monitor.cpp",
"$ace_root/test/mock/base/mock_engine_helper.cpp",
"$ace_root/test/mock/base/mock_frame_trace_adapter.cpp",
"$ace_root/test/mock/base/mock_jank_frame_report.cpp",
"$ace_root/test/mock/base/mock_ressched_report.cpp",
"$ace_root/test/mock/base/mock_system_properties.cpp",
"$ace_root/test/mock/core/common/mock_ace_application_info.cpp",
"$ace_root/test/mock/core/common/mock_container.cpp",
"$ace_root/test/mock/core/common/mock_frame_report.cpp",
"$ace_root/test/mock/core/common/mock_motion_path_evaluator.cpp",
"$ace_root/test/mock/core/common/mock_raw_recognizer.cpp",
"$ace_root/test/mock/core/event/mock_touch_event.cpp",
"$ace_root/test/mock/core/image_provider/mock_image_source_info.cpp",
@ -316,6 +318,8 @@ ohos_unittest("ui_event_test") {
sources = [
"$ace_root/frameworks/core/components_ng/manager/frame_rate/frame_rate_manager.cpp",
"$ace_root/frameworks/core/components_ng/manager/safe_area/safe_area_manager.cpp",
"$ace_root/frameworks/core/components_ng/manager/shared_overlay/shared_overlay_manager.cpp",
"$ace_root/frameworks/core/components_ng/manager/shared_overlay/shared_transition_effect.cpp",
"$ace_root/interfaces/inner_api/ace/ui_event.cpp",
"$ace_root/interfaces/inner_api/ace/ui_event_func.cpp",
"ui_event_test.cpp",