!15992 支持启动页动画

Merge pull request !15992 from qpzeng/master
This commit is contained in:
openharmony_ci 2023-07-17 14:37:13 +00:00 committed by Gitee
commit d7fc465a02
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 46 additions and 11 deletions

View File

@ -40,7 +40,6 @@ UIExtensionPattern::UIExtensionPattern(const RefPtr<OHOS::Ace::WantWrap>& wantWr
auto container = AceType::DynamicCast<Platform::AceContainer>(Container::Current());
CHECK_NULL_VOID_NOLOG(container);
auto callerToken = container->GetToken();
Rosen::ExtensionSessionManager::GetInstance().Init();
auto want = AceType::DynamicCast<WantWrapOhos>(wantWrap)->GetWant();
if (want.GetElement().GetBundleName() == "AbilityComp") {
return;

View File

@ -31,6 +31,16 @@ namespace OHOS::Ace::NG {
namespace {
constexpr uint32_t COLOR_BLACK = 0xff000000;
constexpr uint32_t COLOR_WHITE = 0xffffffff;
const std::map<std::string, Rosen::RSAnimationTimingCurve> curveMap {
{ "default", Rosen::RSAnimationTimingCurve::DEFAULT },
{ "linear", Rosen::RSAnimationTimingCurve::LINEAR },
{ "ease", Rosen::RSAnimationTimingCurve::EASE },
{ "easeIn", Rosen::RSAnimationTimingCurve::EASE_IN },
{ "easeOut", Rosen::RSAnimationTimingCurve::EASE_OUT },
{ "easeInOut", Rosen::RSAnimationTimingCurve::EASE_IN_OUT },
{ "spring", Rosen::RSAnimationTimingCurve::SPRING },
{ "interactiveSpring", Rosen::RSAnimationTimingCurve::INTERACTIVE_SPRING },
};
} // namespace
class LifecycleListener : public Rosen::ILifecycleListener {
@ -208,9 +218,27 @@ void WindowPattern::BufferAvailableCallback()
{
ContainerScope scope(instanceId_);
const auto& config =
Rosen::SceneSessionManager::GetInstance().GetWindowSceneConfig().startingWindowAnimationConfig_;
if (config.enabled_) {
CHECK_NULL_VOID(startingNode_);
auto context = AceType::DynamicCast<RosenRenderContext>(startingNode_->GetRenderContext());
CHECK_NULL_VOID(context);
auto rsNode = context->GetRSNode();
CHECK_NULL_VOID(rsNode);
auto effect = Rosen::RSTransitionEffect::Create()->Opacity(config.opacityEnd_);
rsNode->SetTransitionEffect(effect);
Rosen::RSAnimationTimingProtocol protocol;
protocol.SetDuration(config.duration_);
auto curve = curveMap.count(config.curve_) ? curveMap.at(config.curve_) :
Rosen::RSAnimationTimingCurve::DEFAULT;
Rosen::RSNode::Animate(protocol, curve, [rsNode, effect] {
rsNode->NotifyTransition(effect, false);
});
}
auto host = GetHost();
CHECK_NULL_VOID(host);
host->RemoveChild(startingNode_);
startingNode_.Reset();
host->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);

View File

@ -46,11 +46,13 @@ void WindowSceneModel::Create(uint64_t persistentId)
auto nodeId = stack->ClaimNodeId();
auto windowNode = WindowNode::GetOrCreateWindowNode(V2::WINDOW_SCENE_ETS_TAG, nodeId,
[sceneSession]() { return AceType::MakeRefPtr<WindowScene>(sceneSession); });
stack->Push(windowNode);
auto windowScene = windowNode->GetPattern<WindowScene>();
windowScene->UpdateSession(sceneSession);
if (windowNode->GetHitTestMode() == HitTestMode::HTMDEFAULT) {
windowNode->SetHitTestMode(HitTestMode::HTMBLOCK);
}
stack->Push(windowNode);
auto windowScene = windowNode->GetPattern<WindowScene>();
windowScene->UpdateSession(sceneSession);
}
} // namespace OHOS::Ace::NG

View File

@ -25,7 +25,7 @@ class ScreenPattern : public StackPattern {
DECLARE_ACE_TYPE(ScreenPattern, StackPattern);
public:
ScreenPattern(const sptr<Rosen::ScreenSession>& screenSession) : screenSession_(screenSession) {}
explicit ScreenPattern(const sptr<Rosen::ScreenSession>& screenSession) : screenSession_(screenSession) {}
~ScreenPattern() override = default;
std::optional<RenderContext::ContextParam> GetContextParam() const override

View File

@ -48,5 +48,10 @@ RefPtr<RenderContext> RenderContext::Create()
return MakeRefPtr<RosenRenderContext>();
}
void RosenRenderContext::SetRSNode(const std::shared_ptr<RSNode>& rsNode) {}
const std::shared_ptr<Rosen::RSNode>& RosenRenderContext::GetRSNode()
{
return nullptr;
}
void RosenRenderContext::SetRSNode(const std::shared_ptr<Rosen::RSNode>& rsNode) {}
} // namespace OHOS::Ace::NG

View File

@ -13,18 +13,19 @@
* limitations under the License.
*/
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_RENDER_CONTEXT_H
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_RENDER_CONTEXT_H
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_RENDER_CONTEXT_H
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_RENDER_CONTEXT_H
#include "core/components_ng/render/render_context.h"
namespace OHOS::Ace::NG {
class RosenRenderContext : public RenderContext {
DECLARE_ACE_TYPE(RosenRenderContext, RenderContext)
DECLARE_ACE_TYPE(RosenRenderContext, RenderContext);
public:
const std::shared_ptr<Rosen::RSNode>& GetRSNode();
void SetRSNode(const std::shared_ptr<Rosen::RSNode>& rsNode);
};
} // namespace OHOS::Ace::NG
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_RENDER_CONTEXT_H
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_RENDER_CONTEXT_H