From 4b80c174d1f08c651130b8026fd22c042a6e2e25 Mon Sep 17 00:00:00 2001 From: muxlz Date: Fri, 11 Feb 2022 16:51:13 +0800 Subject: [PATCH] window size change animation Signed-off-by: muxlz Change-Id: If08450538c21fe084a770d53aa0648a63144814a --- adapter/ohos/entrance/ace_ability.cpp | 29 +++++------ adapter/ohos/entrance/ace_ability.h | 2 + adapter/ohos/entrance/ace_container.cpp | 8 +-- adapter/ohos/entrance/flutter_ace_view.cpp | 7 +-- adapter/ohos/entrance/flutter_ace_view.h | 14 ++---- adapter/ohos/entrance/ui_content_impl.cpp | 47 ++++++------------ adapter/ohos/entrance/ui_content_impl.h | 2 +- .../services/uiservice/src/ui_mgr_service.cpp | 2 - adapter/preview/entrance/ace_container.cpp | 5 +- adapter/preview/entrance/flutter_ace_view.cpp | 2 +- adapter/preview/entrance/flutter_ace_view.h | 13 ++--- frameworks/core/common/ace_view.h | 2 +- .../core/common/window_animation_config.h | 30 ++++++++++++ .../components/root/rosen_render_root.cpp | 6 ++- frameworks/core/pipeline/pipeline_context.cpp | 49 ++++++++++++++++--- frameworks/core/pipeline/pipeline_context.h | 7 ++- interfaces/innerkits/ace/ui_content.h | 3 +- 17 files changed, 141 insertions(+), 87 deletions(-) create mode 100644 frameworks/core/common/window_animation_config.h diff --git a/adapter/ohos/entrance/ace_ability.cpp b/adapter/ohos/entrance/ace_ability.cpp index 122e5c52..963d597d 100755 --- a/adapter/ohos/entrance/ace_ability.cpp +++ b/adapter/ohos/entrance/ace_ability.cpp @@ -323,7 +323,6 @@ void AceAbility::OnStart(const Want& want) // todo regist on size change() window->RegisterWindowChangeListener(thisAbility); - rsUiDirector->SetSurfaceNodeSize(width, height); rsUiDirector->SetUITaskRunner( [taskExecutor = Platform::AceContainer::GetContainer(abilityId_)->GetTaskExecutor(), id = abilityId_] (const std::function& task) { @@ -570,22 +569,7 @@ void AceAbility::OnSizeChange(OHOS::Rosen::Rect rect, OHOS::Rosen::WindowSizeCha uint32_t width = rect.width_; uint32_t height = rect.height_; LOGI("AceAbility::OnSizeChange width: %{public}u, height: %{public}u", width, height); -#ifdef ENABLE_ROSEN_BACKEND - auto context = Platform::AceContainer::GetContainer(abilityId_)->GetPipelineContext(); - if (context) { - auto rsUIDirector = context->GetRSUIDirector(); - if (rsUIDirector) { - rsUIDirector->SetSurfaceNodeSize(width, height); - } else { - LOGE("ceAbility::OnSizeChange rsUIDirector is null."); - } - } else { - LOGE("ceAbility::OnSizeChange pipline context is null."); - } - -#endif SystemProperties::SetDeviceOrientation(height >= width ? 0 : 1); - auto flutterAceView = static_cast( Platform::AceContainer::GetContainer(abilityId_)->GetView()); @@ -599,7 +583,18 @@ void AceAbility::OnSizeChange(OHOS::Rosen::Rect rect, OHOS::Rosen::WindowSizeCha metrics.physical_height = height; metrics.device_pixel_ratio = density_; Platform::FlutterAceView::SetViewportMetrics(flutterAceView, metrics); - Platform::FlutterAceView::SurfaceChanged(flutterAceView, width, height, 0); + Platform::FlutterAceView::SurfaceChanged(flutterAceView, width, height, 0, Convert2WindowSizeChangeReason(reason)); +} + +WindowSizeChangeReason AceAbility::Convert2WindowSizeChangeReason(OHOS::Rosen::WindowSizeChangeReason reason) +{ + auto reasonValue = static_cast(reason); + constexpr uint32_t MAX_REASON_VALUE = 5; + if (reasonValue > MAX_REASON_VALUE) { + LOGE("AceAbility: unsupported WindowSizeChangeReason"); + return WindowSizeChangeReason::UNDEFINED; + } + return static_cast(reasonValue); } } // namespace Ace diff --git a/adapter/ohos/entrance/ace_ability.h b/adapter/ohos/entrance/ace_ability.h index 1db7dc27..e2f672b3 100644 --- a/adapter/ohos/entrance/ace_ability.h +++ b/adapter/ohos/entrance/ace_ability.h @@ -21,6 +21,7 @@ #include "ability.h" #include "ability_loader.h" +#include "core/common/window_animation_config.h" #include "core/event/touch_event.h" #include "want.h" #include "wm/window.h" @@ -62,6 +63,7 @@ public: // override Rosen::IWindowChangeListener virtual callback function void OnSizeChange(OHOS::Rosen::Rect rect, OHOS::Rosen::WindowSizeChangeReason reason) override; + static WindowSizeChangeReason Convert2WindowSizeChangeReason(OHOS::Rosen::WindowSizeChangeReason reason); private: static int32_t instanceId_; diff --git a/adapter/ohos/entrance/ace_container.cpp b/adapter/ohos/entrance/ace_container.cpp index 5843bae9..d16660d8 100644 --- a/adapter/ohos/entrance/ace_container.cpp +++ b/adapter/ohos/entrance/ace_container.cpp @@ -466,11 +466,13 @@ void AceContainer::InitializeCallback() }; aceView_->RegisterRotationEventCallback(rotationEventCallback); - auto&& viewChangeCallback = [context = pipelineContext_, id = instanceId_](int32_t width, int32_t height) { + auto&& viewChangeCallback = [context = pipelineContext_, id = instanceId_](int32_t width, int32_t height, + WindowSizeChangeReason type) { ContainerScope scope(id); ACE_SCOPED_TRACE("ViewChangeCallback(%d, %d)", width, height); context->GetTaskExecutor()->PostTask( - [context, width, height]() { context->OnSurfaceChanged(width, height); }, TaskExecutor::TaskType::UI); + [context, width, height, type]() { context->OnSurfaceChanged(width, height, type); }, + TaskExecutor::TaskType::UI); }; aceView_->RegisterViewChangeCallback(viewChangeCallback); @@ -935,4 +937,4 @@ std::string AceContainer::GetContentInfo(int32_t instanceId) } } -} // namespace OHOS::Ace::Platform +} // namespace OHOS::Ace::Platform \ No newline at end of file diff --git a/adapter/ohos/entrance/flutter_ace_view.cpp b/adapter/ohos/entrance/flutter_ace_view.cpp index 36266a75..a8d617c4 100644 --- a/adapter/ohos/entrance/flutter_ace_view.cpp +++ b/adapter/ohos/entrance/flutter_ace_view.cpp @@ -293,14 +293,15 @@ void FlutterAceView::SurfaceCreated(FlutterAceView* view, OHOS::sptrNotifySurfaceChanged(width, height); + view->NotifySurfaceChanged(width, height, type); auto platformView = view->GetShellHolder()->GetPlatformView(); LOGI("FlutterAceView::SurfaceChanged, GetPlatformView"); if (platformView) { @@ -624,4 +625,4 @@ std::unique_ptr FlutterAceView::GetPlatformWindow() return nullptr; } -} // namespace OHOS::Ace::Platform +} // namespace OHOS::Ace::Platform \ No newline at end of file diff --git a/adapter/ohos/entrance/flutter_ace_view.h b/adapter/ohos/entrance/flutter_ace_view.h index 9b3aa78b..fcee6b0a 100755 --- a/adapter/ohos/entrance/flutter_ace_view.h +++ b/adapter/ohos/entrance/flutter_ace_view.h @@ -29,11 +29,6 @@ #include "core/event/key_event_recognizer.h" #include "core/event/key_event_transfer.h" -#include "mouse_event.h" -#include "touch_event.h" -#include "window.h" -#include "window_manager.h" - namespace OHOS::Ace::Platform { using ReleaseCallback = std::function; @@ -46,7 +41,8 @@ public: static FlutterAceView* CreateView( int32_t instanceId, bool useCurrentEventRunner = false, bool usePlatfromThread = false); static void SurfaceCreated(FlutterAceView* view, OHOS::sptr window); - static void SurfaceChanged(FlutterAceView* view, int32_t width, int32_t height, int32_t orientation); + static void SurfaceChanged(FlutterAceView* view, int32_t width, int32_t height, int32_t orientation, + WindowSizeChangeReason type = WindowSizeChangeReason::UNDEFINED); static void SetViewportMetrics(FlutterAceView* view, const flutter::ViewportMetrics& metrics); static void DispatchTouchEvent(FlutterAceView* view, const std::shared_ptr& pointerEvent); @@ -136,13 +132,13 @@ public: const void* GetNativeWindowById(uint64_t textureId) override; private: - void NotifySurfaceChanged(int width, int height) + void NotifySurfaceChanged(int width, int height, WindowSizeChangeReason type) { if (viewChangeCallback_) { - viewChangeCallback_(width, height); + viewChangeCallback_(width, height, type); } width_ = width; - height_ =height; + height_ = height; } void NotifyDensityChanged(double density) const diff --git a/adapter/ohos/entrance/ui_content_impl.cpp b/adapter/ohos/entrance/ui_content_impl.cpp index cfa09e1e6..07f7459f 100644 --- a/adapter/ohos/entrance/ui_content_impl.cpp +++ b/adapter/ohos/entrance/ui_content_impl.cpp @@ -68,7 +68,7 @@ WindowMode GetWindowMode(OHOS::Rosen::Window* window) } } -} +} // namespace static std::atomic gInstanceId = 0; @@ -295,8 +295,8 @@ void UIContentImpl::CommonInitialize(OHOS::Rosen::Window* window, const std::str PluginManager::GetInstance().SetAceAbility(nullptr, pluginUtils); // create container instanceId_ = gInstanceId.fetch_add(1, std::memory_order_relaxed); - auto container = AceType::MakeRefPtr(instanceId_, FrontendType::DECLARATIVE_JS, true, - info, std::make_unique([context = context_] { + auto container = AceType::MakeRefPtr(instanceId_, FrontendType::DECLARATIVE_JS, true, info, + std::make_unique([context = context_] { auto sharedContext = context.lock(); if (!sharedContext) { return; @@ -343,8 +343,8 @@ void UIContentImpl::CommonInitialize(OHOS::Rosen::Window* window, const std::str if (!storage) { container->SetContentStorage(nullptr, context->GetBindingObject()->Get()); } else { - container->SetContentStorage(nativeEngine->CreateReference(storage, 1), - context->GetBindingObject()->Get()); + container->SetContentStorage( + nativeEngine->CreateReference(storage, 1), context->GetBindingObject()->Get()); } InitWindowCallback(info); @@ -354,13 +354,11 @@ void UIContentImpl::CommonInitialize(OHOS::Rosen::Window* window, const std::str auto rsUiDirector = OHOS::Rosen::RSUIDirector::Create(); if (rsUiDirector != nullptr) { rsUiDirector->SetRSSurfaceNode(window->GetSurfaceNode()); - rsUiDirector->SetSurfaceNodeSize(width, height); rsUiDirector->SetUITaskRunner( - [taskExecutor = container->GetTaskExecutor(), id = instanceId_] - (const std::function& task) { - ContainerScope scope(id); - taskExecutor->PostTask(task, TaskExecutor::TaskType::UI); - }); + [taskExecutor = container->GetTaskExecutor(), id = instanceId_](const std::function& task) { + ContainerScope scope(id); + taskExecutor->PostTask(task, TaskExecutor::TaskType::UI); + }); auto context = container->GetPipelineContext(); if (context != nullptr) { context->SetRSUIDirector(rsUiDirector); @@ -457,7 +455,7 @@ void UIContentImpl::UpdateConfiguration(const std::shared_ptrGetName().c_str()); } -void UIContentImpl::UpdateViewportConfig(const ViewportConfig& config) +void UIContentImpl::UpdateViewportConfig(const ViewportConfig& config, OHOS::Rosen::WindowSizeChangeReason reason) { LOGI("UIContent UpdateViewportConfig %{public}s", config.ToString().c_str()); SystemProperties::SetResolution(config.Density()); @@ -466,27 +464,14 @@ void UIContentImpl::UpdateViewportConfig(const ViewportConfig& config) SystemProperties::SetDeviceOrientation(config.Height() >= config.Width() ? 0 : 1); auto container = Platform::AceContainer::GetContainer(instanceId_); if (container) { -#ifdef ENABLE_ROSEN_BACKEND - auto context = container->GetPipelineContext(); - if (context) { - auto rsUIDirector = context->GetRSUIDirector(); - if (rsUIDirector) { - rsUIDirector->SetSurfaceNodeSize(config.Width(), config.Height()); - } else { - LOGE("UpdateViewportConfig rsUIDirector is null."); - } - } else { - LOGE("UpdateViewportConfig pipline context is null."); - } -#endif - auto aceView = static_cast(container->GetAceView()); flutter::ViewportMetrics metrics; metrics.physical_width = config.Width(); metrics.physical_height = config.Height(); metrics.device_pixel_ratio = config.Density(); Platform::FlutterAceView::SetViewportMetrics(aceView, metrics); - Platform::FlutterAceView::SurfaceChanged(aceView, config.Width(), config.Height(), config.Orientation()); + Platform::FlutterAceView::SurfaceChanged(aceView, config.Width(), config.Height(), config.Orientation(), + AceAbility::Convert2WindowSizeChangeReason(reason)); } config_ = config; updateConfig_ = true; @@ -550,13 +535,11 @@ void UIContentImpl::InitWindowCallback(const std::shared_ptrSetWindowMode(OHOS::Rosen::WindowMode::WINDOW_MODE_SPLIT_PRIMARY)); + return ( + OHOS::Rosen::WMError::WM_OK == window->SetWindowMode(OHOS::Rosen::WindowMode::WINDOW_MODE_SPLIT_PRIMARY)); }); - pipelineContext->SetWindowGetModeCallBack([&window]() -> WindowMode { - return GetWindowMode(window); - }); + pipelineContext->SetWindowGetModeCallBack([&window]() -> WindowMode { return GetWindowMode(window); }); } } // namespace OHOS::Ace diff --git a/adapter/ohos/entrance/ui_content_impl.h b/adapter/ohos/entrance/ui_content_impl.h index df3f7787..1e777893 100644 --- a/adapter/ohos/entrance/ui_content_impl.h +++ b/adapter/ohos/entrance/ui_content_impl.h @@ -58,7 +58,7 @@ public: bool ProcessAxisEvent(const std::shared_ptr& axisEvent) override; bool ProcessVsyncEvent(uint64_t timeStampNanos) override; void UpdateConfiguration(const std::shared_ptr& config) override; - void UpdateViewportConfig(const ViewportConfig& config) override; + void UpdateViewportConfig(const ViewportConfig& config, OHOS::Rosen::WindowSizeChangeReason reason) override; private: void CommonInitialize(OHOS::Rosen::Window* window, const std::string& contentInfo, NativeValue* storage); diff --git a/adapter/ohos/services/uiservice/src/ui_mgr_service.cpp b/adapter/ohos/services/uiservice/src/ui_mgr_service.cpp index d075f0a2..d276bbf7 100644 --- a/adapter/ohos/services/uiservice/src/ui_mgr_service.cpp +++ b/adapter/ohos/services/uiservice/src/ui_mgr_service.cpp @@ -261,8 +261,6 @@ int UIMgrService::ShowDialog(const std::string& name, rsUiDirector->SetRSSurfaceNode(dialogWindow->GetSurfaceNode()); dialogWindow->RegisterWindowChangeListener(listener); - - rsUiDirector->SetSurfaceNodeSize(windowWidth, windowHeight); rsUiDirector->SetUITaskRunner( [taskExecutor = Ace::Platform::AceContainer::GetContainer(dialogId)->GetTaskExecutor()] (const std::function& task) { diff --git a/adapter/preview/entrance/ace_container.cpp b/adapter/preview/entrance/ace_container.cpp index f6ebc7ef..345369d6 100644 --- a/adapter/preview/entrance/ace_container.cpp +++ b/adapter/preview/entrance/ace_container.cpp @@ -265,7 +265,7 @@ void AceContainer::InitializeCallback() }; aceView_->RegisterCardViewAccessibilityParamsCallback(cardViewParamsCallback); - auto&& viewChangeCallback = [weak, id = instanceId_](int32_t width, int32_t height) { + auto&& viewChangeCallback = [weak, id = instanceId_](int32_t width, int32_t height, WindowSizeChangeReason type) { ContainerScope scope(id); auto context = weak.Upgrade(); if (context == nullptr) { @@ -274,7 +274,8 @@ void AceContainer::InitializeCallback() } ACE_SCOPED_TRACE("ViewChangeCallback(%d, %d)", width, height); context->GetTaskExecutor()->PostTask( - [context, width, height]() { context->OnSurfaceChanged(width, height); }, TaskExecutor::TaskType::UI); + [context, width, height, type]() { context->OnSurfaceChanged(width, height, type); }, + TaskExecutor::TaskType::UI); }; aceView_->RegisterViewChangeCallback(viewChangeCallback); diff --git a/adapter/preview/entrance/flutter_ace_view.cpp b/adapter/preview/entrance/flutter_ace_view.cpp index 93e2f11d..37e4a88e 100644 --- a/adapter/preview/entrance/flutter_ace_view.cpp +++ b/adapter/preview/entrance/flutter_ace_view.cpp @@ -86,7 +86,7 @@ void ConvertTouchEvent(const std::vector& data, std::vector } } -} +} // namespace void FlutterAceView::RegisterTouchEventCallback(TouchEventCallback&& callback) { diff --git a/adapter/preview/entrance/flutter_ace_view.h b/adapter/preview/entrance/flutter_ace_view.h index ccad337c..3ecf0b33 100644 --- a/adapter/preview/entrance/flutter_ace_view.h +++ b/adapter/preview/entrance/flutter_ace_view.h @@ -77,7 +77,7 @@ public: void RegisterSystemBarHeightChangeCallback(SystemBarHeightChangeCallbak&& callback) override { if (callback) { - systemBarHeightChangeCallbak_ = std::move(callback); + systemBarHeightChangeCallback_ = std::move(callback); } } @@ -104,12 +104,13 @@ public: void ProcessIdleEvent(int64_t deadline); - void NotifySurfaceChanged(int32_t width, int32_t height) + void NotifySurfaceChanged( + int32_t width, int32_t height, WindowSizeChangeReason type = WindowSizeChangeReason::UNDEFINED) { width_ = width; height_ = height; if (viewChangeCallback_) { - viewChangeCallback_(width, height); + viewChangeCallback_(width, height, type); } } @@ -122,8 +123,8 @@ public: void NotifySystemBarHeightChanged(double statusBar, double navigationBar) const { - if (systemBarHeightChangeCallbak_) { - systemBarHeightChangeCallbak_(statusBar, navigationBar); + if (systemBarHeightChangeCallback_) { + systemBarHeightChangeCallback_(statusBar, navigationBar); } } @@ -161,7 +162,7 @@ private: CardViewAccessibilityParamsCallback cardViewAccessibilityParamsCallback_; ViewChangeCallback viewChangeCallback_; DensityChangeCallback densityChangeCallback_; - SystemBarHeightChangeCallbak systemBarHeightChangeCallbak_; + SystemBarHeightChangeCallbak systemBarHeightChangeCallback_; SurfaceDestroyCallback surfaceDestroyCallback_; IdleCallback idleCallback_; KeyEventCallback keyEventCallback_; diff --git a/frameworks/core/common/ace_view.h b/frameworks/core/common/ace_view.h index 573319ed..0b7fb5bd 100644 --- a/frameworks/core/common/ace_view.h +++ b/frameworks/core/common/ace_view.h @@ -56,7 +56,7 @@ public: using CardViewAccessibilityParamsCallback = std::function; virtual void RegisterCardViewAccessibilityParamsCallback(CardViewAccessibilityParamsCallback&& callback) = 0; - using ViewChangeCallback = std::function; + using ViewChangeCallback = std::function; virtual void RegisterViewChangeCallback(ViewChangeCallback&& callback) = 0; using DensityChangeCallback = std::function; diff --git a/frameworks/core/common/window_animation_config.h b/frameworks/core/common/window_animation_config.h new file mode 100644 index 00000000..8055f34d --- /dev/null +++ b/frameworks/core/common/window_animation_config.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2021 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_COMMON_WINDOW_ANIMATION_CONFIG_H +#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_WINDOW_ANIMATION_CONFIG_H + +namespace OHOS::Ace { +enum class WindowSizeChangeReason : uint32_t { + UNDEFINED = 0, + MAXIMIZE, + RECOVER, + ROTATION, + DRAG, + RESIZE, +}; +} // namespace OHOS::Ace + +#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_WINDOW_ANIMATION_CONFIG_H \ No newline at end of file diff --git a/frameworks/core/components/root/rosen_render_root.cpp b/frameworks/core/components/root/rosen_render_root.cpp index 1127d78b..ca49daf8 100644 --- a/frameworks/core/components/root/rosen_render_root.cpp +++ b/frameworks/core/components/root/rosen_render_root.cpp @@ -48,8 +48,10 @@ void RosenRenderRoot::SyncGeometryProperties() } Offset paintOffset = GetPaintOffset(); Size paintSize = GetLayoutSize(); - rsNode->SetBounds(paintOffset.GetX(), paintOffset.GetY(), paintSize.Width(), paintSize.Height()); - rsNode->SetFrame(paintOffset.GetX(), paintOffset.GetY(), paintSize.Width(), paintSize.Height()); + rsNode->SetBounds(paintOffset.GetX() * scale_, paintOffset.GetY() * scale_, paintSize.Width() * scale_, + paintSize.Height() * scale_); + rsNode->SetFrame(paintOffset.GetX() * scale_, paintOffset.GetY() * scale_, paintSize.Width() * scale_, + paintSize.Height() * scale_); } void RosenRenderRoot::FinishRender(const std::unique_ptr& delegate, const Rect& dirty) diff --git a/frameworks/core/pipeline/pipeline_context.cpp b/frameworks/core/pipeline/pipeline_context.cpp index 3968fb21..0da591ab 100644 --- a/frameworks/core/pipeline/pipeline_context.cpp +++ b/frameworks/core/pipeline/pipeline_context.cpp @@ -1630,7 +1630,41 @@ RefPtr PipelineContext::GetFrontend() const return weakFrontend_.Upgrade(); } -void PipelineContext::OnSurfaceChanged(int32_t width, int32_t height) +void PipelineContext::WindowSizeChangeAnimate(int32_t width, int32_t height, WindowSizeChangeReason type) +{ + if (!rootElement_ || !rootElement_->GetRenderNode()) { + LOGE("RootNodeAnimation: no rootelement found, no animation configured"); + SetRootSizeWithWidthHeight(width, height); + return; + } + auto rootNode = AceType::DynamicCast(rootElement_->GetRenderNode()); + switch (type) { + case WindowSizeChangeReason::RECOVER: + case WindowSizeChangeReason::MAXIMIZE: { + LOGD("PipelineContext::Rootnodeanimation, width = %{private}d, height = %{private}d", width, height); + AnimationOption option; + constexpr int32_t duration = 400; + option.SetDuration(duration); + auto curve = MakeRefPtr(); + option.SetCurve(curve); + Animate(option, curve, [width, height, this]() { + SetRootSizeWithWidthHeight(width, height); + FlushLayout(); + }); + break; + } + case WindowSizeChangeReason::ROTATION: + case WindowSizeChangeReason::RESIZE: + case WindowSizeChangeReason::DRAG: + case WindowSizeChangeReason::UNDEFINED: + default: { + LOGD("PipelineContext::RootNodeAnimation : unsupported type, no animation added"); + SetRootSizeWithWidthHeight(width, height); + } + } +} + +void PipelineContext::OnSurfaceChanged(int32_t width, int32_t height, WindowSizeChangeReason type) { CHECK_RUN_ON(UI); // Refresh the screen when developers customize the resolution and screen density on the PC preview. @@ -1661,7 +1695,6 @@ void PipelineContext::OnSurfaceChanged(int32_t width, int32_t height) } } GridSystemManager::GetInstance().OnSurfaceChanged(width); - auto frontend = weakFrontend_.Upgrade(); if (frontend) { frontend->OnSurfaceChanged(width, height); @@ -1675,7 +1708,11 @@ void PipelineContext::OnSurfaceChanged(int32_t width, int32_t height) transitionElement->InitTransitionClip(); } } +#ifdef ENABLE_ROSEN_BACKEND + WindowSizeChangeAnimate(width, height, type); +#else SetRootSizeWithWidthHeight(width, height); +#endif if (isSurfaceReady_) { return; } @@ -2797,20 +2834,20 @@ void PipelineContext::ForceLayoutForImplicitAnimation() } bool PipelineContext::Animate(const AnimationOption& option, const RefPtr& curve, - const std::function& propertyCallback, const std::function& finishCallBack) + const std::function& propertyCallback, const std::function& finishCallback) { if (!propertyCallback) { LOGE("failed to create animation, property callback is null!"); return false; } - OpenImplicitAnimation(option, curve, finishCallBack); + OpenImplicitAnimation(option, curve, finishCallback); propertyCallback(); return CloseImplicitAnimation(); } void PipelineContext::OpenImplicitAnimation( - const AnimationOption& option, const RefPtr& curve, const std::function& finishCallBack) + const AnimationOption& option, const RefPtr& curve, const std::function& finishCallback) { #ifdef ENABLE_ROSEN_BACKEND if (!SystemProperties::GetRosenBackendEnabled()) { @@ -2831,7 +2868,7 @@ void PipelineContext::OpenImplicitAnimation( option.GetAnimationDirection() == AnimationDirection::ALTERNATE); timingProtocol.SetAutoReverse(option.GetAnimationDirection() == AnimationDirection::ALTERNATE || option.GetAnimationDirection() == AnimationDirection::ALTERNATE_REVERSE); - RSNode::OpenImplicitAnimation(timingProtocol, NativeCurveHelper::ToNativeCurve(curve), finishCallBack); + RSNode::OpenImplicitAnimation(timingProtocol, NativeCurveHelper::ToNativeCurve(curve), finishCallback); #endif } diff --git a/frameworks/core/pipeline/pipeline_context.h b/frameworks/core/pipeline/pipeline_context.h index 2e13d185..e7739afc 100644 --- a/frameworks/core/pipeline/pipeline_context.h +++ b/frameworks/core/pipeline/pipeline_context.h @@ -43,6 +43,7 @@ #include "core/common/focus_animation_manager.h" #include "core/common/platform_bridge.h" #include "core/common/platform_res_register.h" +#include "core/common/window_animation_config.h" #include "core/components/common/properties/color.h" #include "core/components/dialog/dialog_properties.h" #include "core/components/page/page_component.h" @@ -92,6 +93,7 @@ struct WindowBlurInfo { std::vector coords_; }; + using OnRouterChangeCallback = bool (*)(const std::string currentRouterPath); using SubscribeCtrlACallback = std::function; @@ -258,7 +260,10 @@ public: void PostAsyncEvent(const TaskExecutor::Task& task); - void OnSurfaceChanged(int32_t width, int32_t height); + void OnSurfaceChanged( + int32_t width, int32_t height, WindowSizeChangeReason type = WindowSizeChangeReason::UNDEFINED); + + void WindowSizeChangeAnimate(int32_t width, int32_t height, WindowSizeChangeReason type); void OnSurfaceDensityChanged(double density); diff --git a/interfaces/innerkits/ace/ui_content.h b/interfaces/innerkits/ace/ui_content.h index 62a40dbf..ed62db74 100644 --- a/interfaces/innerkits/ace/ui_content.h +++ b/interfaces/innerkits/ace/ui_content.h @@ -33,6 +33,7 @@ class Configuration; namespace Rosen { class Window; +enum class WindowSizeChangeReason : uint32_t; } namespace MMI { @@ -75,7 +76,7 @@ public: virtual bool ProcessAxisEvent(const std::shared_ptr& axisEvent) = 0; virtual bool ProcessVsyncEvent(uint64_t timeStampNanos) = 0; virtual void UpdateConfiguration(const std::shared_ptr& config) = 0; - virtual void UpdateViewportConfig(const ViewportConfig& config) = 0; + virtual void UpdateViewportConfig(const ViewportConfig& config, OHOS::Rosen::WindowSizeChangeReason reason) = 0; }; } // namespace OHOS::Ace