From f475aca28da6b0f3130d6a4ef30f162fd99ead36 Mon Sep 17 00:00:00 2001 From: wangmiaoliang Date: Mon, 11 Aug 2025 20:05:23 +0800 Subject: [PATCH 1/2] RenderNode add rsUIContext Signed-off-by: wangmiaoliang Change-Id: I7ce349d1f7d4488aef4f37e14a058e68d943a40a --- .../render/adapter/rosen_render_context.cpp | 6 ++++++ .../render/adapter/rosen_render_context.h | 1 + .../core/rosen/rosen_render_context_test_new.cpp | 16 ++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/frameworks/core/components_ng/render/adapter/rosen_render_context.cpp b/frameworks/core/components_ng/render/adapter/rosen_render_context.cpp index ee0542f6b8d..9a39ba39709 100755 --- a/frameworks/core/components_ng/render/adapter/rosen_render_context.cpp +++ b/frameworks/core/components_ng/render/adapter/rosen_render_context.cpp @@ -502,6 +502,12 @@ void RosenRenderContext::InitContext(bool isRoot, const std::optionalInit(true, true); + rsContext = rsUIDirector_->GetRSUIContext(); + } } auto isTextureExportNode = ViewStackProcessor::GetInstance()->IsExportTexture(); if (isRoot) { diff --git a/frameworks/core/components_ng/render/adapter/rosen_render_context.h b/frameworks/core/components_ng/render/adapter/rosen_render_context.h index 960fd334d24..5b805dfa096 100755 --- a/frameworks/core/components_ng/render/adapter/rosen_render_context.h +++ b/frameworks/core/components_ng/render/adapter/rosen_render_context.h @@ -894,6 +894,7 @@ protected: bool useContentRectForRSFrame_; bool adjustRSFrameByContentRect_ = false; bool isFocusBoxGlow_ = false; + std::shared_ptr rsUIDirector_; RectF paintRect_; // offset generated by layout node diff --git a/test/unittest/core/rosen/rosen_render_context_test_new.cpp b/test/unittest/core/rosen/rosen_render_context_test_new.cpp index 7a6964012cd..d195bb29bff 100644 --- a/test/unittest/core/rosen/rosen_render_context_test_new.cpp +++ b/test/unittest/core/rosen/rosen_render_context_test_new.cpp @@ -1129,6 +1129,22 @@ HWTEST_F(RosenRenderContextTest, RosenRenderContextTestNew040, TestSize.Level1) EXPECT_NEAR(borderDashWidth[0], 1.0f, 0.01f); } +/** + * @tc.name: RSUIContext002 + * @tc.desc: Test RSUIContext001 Func. + * @tc.type: FUNC + */ +HWTEST_F(RosenRenderContextTest, RSUIContext002, TestSize.Level1) +{ + auto frameNode = FrameNode::GetOrCreateFrameNode("frame", -1, []() { return AceType::MakeRefPtr(); }); + ASSERT_NE(frameNode, nullptr); + ComponentSnapshot snapshot; + snapshot.SetRSUIContext(frameNode, nullptr); + auto pipeline = MockPipelineContext::GetCurrentContext(); + auto rsUIContext = snapshot.GetRSUIContext(pipeline); + EXPECT_EQ(rsUIContext, nullptr); +} + /** * @tc.name: RosenRenderContextTestNew041 * @tc.desc: GetClipToFrame(). -- Gitee From 49109ef2592f76830e610b1ee84efd400caa6650 Mon Sep 17 00:00:00 2001 From: wangmiaoliang Date: Tue, 12 Aug 2025 02:01:54 +0000 Subject: [PATCH 2/2] update test/unittest/core/rosen/rosen_render_context_test_new.cpp. Signed-off-by: wangmiaoliang --- .../core/rosen/rosen_render_context_test_new.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/test/unittest/core/rosen/rosen_render_context_test_new.cpp b/test/unittest/core/rosen/rosen_render_context_test_new.cpp index d195bb29bff..7a6964012cd 100644 --- a/test/unittest/core/rosen/rosen_render_context_test_new.cpp +++ b/test/unittest/core/rosen/rosen_render_context_test_new.cpp @@ -1129,22 +1129,6 @@ HWTEST_F(RosenRenderContextTest, RosenRenderContextTestNew040, TestSize.Level1) EXPECT_NEAR(borderDashWidth[0], 1.0f, 0.01f); } -/** - * @tc.name: RSUIContext002 - * @tc.desc: Test RSUIContext001 Func. - * @tc.type: FUNC - */ -HWTEST_F(RosenRenderContextTest, RSUIContext002, TestSize.Level1) -{ - auto frameNode = FrameNode::GetOrCreateFrameNode("frame", -1, []() { return AceType::MakeRefPtr(); }); - ASSERT_NE(frameNode, nullptr); - ComponentSnapshot snapshot; - snapshot.SetRSUIContext(frameNode, nullptr); - auto pipeline = MockPipelineContext::GetCurrentContext(); - auto rsUIContext = snapshot.GetRSUIContext(pipeline); - EXPECT_EQ(rsUIContext, nullptr); -} - /** * @tc.name: RosenRenderContextTestNew041 * @tc.desc: GetClipToFrame(). -- Gitee