mirror of
https://github.com/openharmony/ace_ace_engine.git
synced 2026-07-21 01:45:30 -04:00
@@ -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<void()>& 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::FlutterAceView*>(
|
||||
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<uint32_t>(reason);
|
||||
constexpr uint32_t MAX_REASON_VALUE = 5;
|
||||
if (reasonValue > MAX_REASON_VALUE) {
|
||||
LOGE("AceAbility: unsupported WindowSizeChangeReason");
|
||||
return WindowSizeChangeReason::UNDEFINED;
|
||||
}
|
||||
return static_cast<WindowSizeChangeReason>(reasonValue);
|
||||
}
|
||||
|
||||
} // namespace Ace
|
||||
|
||||
@@ -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_;
|
||||
|
||||
@@ -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
|
||||
@@ -293,14 +293,15 @@ void FlutterAceView::SurfaceCreated(FlutterAceView* view, OHOS::sptr<OHOS::Rosen
|
||||
LOGI("<<< FlutterAceView::SurfaceCreated, end");
|
||||
}
|
||||
|
||||
void FlutterAceView::SurfaceChanged(FlutterAceView* view, int32_t width, int32_t height, int32_t orientation)
|
||||
void FlutterAceView::SurfaceChanged(
|
||||
FlutterAceView* view, int32_t width, int32_t height, int32_t orientation, WindowSizeChangeReason type)
|
||||
{
|
||||
if (view == nullptr) {
|
||||
LOGE("FlutterAceView::SurfaceChanged, view is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
view->NotifySurfaceChanged(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<PlatformWindow> FlutterAceView::GetPlatformWindow()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace::Platform
|
||||
} // namespace OHOS::Ace::Platform
|
||||
@@ -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<void()>;
|
||||
@@ -46,7 +41,8 @@ public:
|
||||
static FlutterAceView* CreateView(
|
||||
int32_t instanceId, bool useCurrentEventRunner = false, bool usePlatfromThread = false);
|
||||
static void SurfaceCreated(FlutterAceView* view, OHOS::sptr<OHOS::Rosen::Window> 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<MMI::PointerEvent>& 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
|
||||
|
||||
@@ -68,7 +68,7 @@ WindowMode GetWindowMode(OHOS::Rosen::Window* window)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static std::atomic<int32_t> 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<Platform::AceContainer>(instanceId_, FrontendType::DECLARATIVE_JS, true,
|
||||
info, std::make_unique<ContentEventCallback>([context = context_] {
|
||||
auto container = AceType::MakeRefPtr<Platform::AceContainer>(instanceId_, FrontendType::DECLARATIVE_JS, true, info,
|
||||
std::make_unique<ContentEventCallback>([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<NativeReference>());
|
||||
} else {
|
||||
container->SetContentStorage(nativeEngine->CreateReference(storage, 1),
|
||||
context->GetBindingObject()->Get<NativeReference>());
|
||||
container->SetContentStorage(
|
||||
nativeEngine->CreateReference(storage, 1), context->GetBindingObject()->Get<NativeReference>());
|
||||
}
|
||||
|
||||
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<void()>& task) {
|
||||
ContainerScope scope(id);
|
||||
taskExecutor->PostTask(task, TaskExecutor::TaskType::UI);
|
||||
});
|
||||
[taskExecutor = container->GetTaskExecutor(), id = instanceId_](const std::function<void()>& 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_ptr<OHOS::AppExecFwk::
|
||||
LOGI("UIContent UpdateConfiguration %{public}s", config->GetName().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<Platform::FlutterAceView*>(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_ptr<OHOS::AppExecFwk::A
|
||||
if (!window) {
|
||||
return false;
|
||||
}
|
||||
return (OHOS::Rosen::WMError::WM_OK ==
|
||||
window->SetWindowMode(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
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
bool ProcessAxisEvent(const std::shared_ptr<OHOS::MMI::AxisEvent>& axisEvent) override;
|
||||
bool ProcessVsyncEvent(uint64_t timeStampNanos) override;
|
||||
void UpdateConfiguration(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& 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);
|
||||
|
||||
@@ -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<void()>& task) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ void ConvertTouchEvent(const std::vector<uint8_t>& data, std::vector<TouchEvent>
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void FlutterAceView::RegisterTouchEventCallback(TouchEventCallback&& callback)
|
||||
{
|
||||
|
||||
@@ -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_;
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
using CardViewAccessibilityParamsCallback = std::function<void(const std::string& key, bool focus)>;
|
||||
virtual void RegisterCardViewAccessibilityParamsCallback(CardViewAccessibilityParamsCallback&& callback) = 0;
|
||||
|
||||
using ViewChangeCallback = std::function<void(int32_t width, int32_t height)>;
|
||||
using ViewChangeCallback = std::function<void(int32_t width, int32_t height, WindowSizeChangeReason type)>;
|
||||
virtual void RegisterViewChangeCallback(ViewChangeCallback&& callback) = 0;
|
||||
|
||||
using DensityChangeCallback = std::function<void(double density)>;
|
||||
|
||||
@@ -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
|
||||
@@ -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<DrawDelegate>& delegate, const Rect& dirty)
|
||||
|
||||
@@ -1631,7 +1631,41 @@ RefPtr<Frontend> 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<RenderRoot>(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<DecelerationCurve>();
|
||||
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.
|
||||
@@ -1662,7 +1696,6 @@ void PipelineContext::OnSurfaceChanged(int32_t width, int32_t height)
|
||||
}
|
||||
}
|
||||
GridSystemManager::GetInstance().OnSurfaceChanged(width);
|
||||
|
||||
auto frontend = weakFrontend_.Upgrade();
|
||||
if (frontend) {
|
||||
frontend->OnSurfaceChanged(width, height);
|
||||
@@ -1676,7 +1709,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;
|
||||
}
|
||||
@@ -2798,20 +2835,20 @@ void PipelineContext::ForceLayoutForImplicitAnimation()
|
||||
}
|
||||
|
||||
bool PipelineContext::Animate(const AnimationOption& option, const RefPtr<Curve>& curve,
|
||||
const std::function<void()>& propertyCallback, const std::function<void()>& finishCallBack)
|
||||
const std::function<void()>& propertyCallback, const std::function<void()>& 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>& curve, const std::function<void()>& finishCallBack)
|
||||
const AnimationOption& option, const RefPtr<Curve>& curve, const std::function<void()>& finishCallback)
|
||||
{
|
||||
#ifdef ENABLE_ROSEN_BACKEND
|
||||
if (!SystemProperties::GetRosenBackendEnabled()) {
|
||||
@@ -2832,7 +2869,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
|
||||
}
|
||||
|
||||
|
||||
@@ -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<RRect> coords_;
|
||||
};
|
||||
|
||||
|
||||
using OnRouterChangeCallback = bool (*)(const std::string currentRouterPath);
|
||||
using SubscribeCtrlACallback = std::function<void()>;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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<OHOS::MMI::AxisEvent>& axisEvent) = 0;
|
||||
virtual bool ProcessVsyncEvent(uint64_t timeStampNanos) = 0;
|
||||
virtual void UpdateConfiguration(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config) = 0;
|
||||
virtual void UpdateViewportConfig(const ViewportConfig& config) = 0;
|
||||
virtual void UpdateViewportConfig(const ViewportConfig& config, OHOS::Rosen::WindowSizeChangeReason reason) = 0;
|
||||
};
|
||||
|
||||
} // namespace OHOS::Ace
|
||||
|
||||
Reference in New Issue
Block a user