From 711043f24ea6abbd779ce03f9a9f5dee1934fccb Mon Sep 17 00:00:00 2001 From: sunqizhen Date: Thu, 13 Jun 2024 01:54:37 +0000 Subject: [PATCH 001/247] =?UTF-8?q?=E7=81=AD=E5=B1=8F=E4=B8=8D=E7=BB=98?= =?UTF-8?q?=E5=88=B6=E5=BC=80=E5=85=B3=E9=BB=98=E8=AE=A4=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: sunqizhen --- .../src/platform/ohos/rs_system_properties.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_system_properties.cpp b/rosen/modules/render_service_base/src/platform/ohos/rs_system_properties.cpp index b0279d8656..6323dd08f6 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_system_properties.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_system_properties.cpp @@ -1001,7 +1001,7 @@ bool RSSystemProperties::GetGpuOverDrawBufferOptimizeEnabled() bool RSSystemProperties::GetSkipDisplayIfScreenOffEnabled() { - static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.screenoffskipdisplayenabled", "0"); + static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.screenoffskipdisplayenabled", "1"); int changed = 0; const char *num = CachedParameterGetChanged(g_Handle, &changed); return ConvertToInt(num, 1) != 0; From f1ec9817ad057233e70d1bc5839729c8c0cde28f Mon Sep 17 00:00:00 2001 From: sunqizhen Date: Mon, 17 Jun 2024 22:07:57 +0800 Subject: [PATCH 002/247] fix RemoveModifier Signed-off-by: sunqizhen --- .../src/pipeline/rs_render_node.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp b/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp index 625fed2bfa..e6aa6020ea 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp @@ -2104,14 +2104,12 @@ void RSRenderNode::RemoveModifier(const PropertyId& id) return; } for (auto& [type, modifiers] : renderContent_->drawCmdModifiers_) { - auto it = std::find_if(modifiers.begin(), modifiers.end(), - [id](const auto& modifier) -> bool { return modifier->GetPropertyId() == id; }); - if (it == modifiers.end()) { - continue; + bool found = EraseIf(modifiers, + [id](const auto& modifier) -> bool { return modifier == nullptr || modifier->GetPropertyId() == id; }); + if (found) { + AddDirtyType(type); + return; } - AddDirtyType(type); - modifiers.erase(it); - return; } } From 7e19dc56779550bab930aa66a8d3b22ffd502d7c Mon Sep 17 00:00:00 2001 From: "DESKTOP-OGBJOTA\\user" Date: Thu, 20 Jun 2024 16:03:13 +0300 Subject: [PATCH 003/247] Refactor frame_analyzer dep Signed-off-by: DESKTOP-OGBJOTA\user --- bundle.json | 9 +++++++++ rosen/modules/render_service_client/BUILD.gn | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bundle.json b/bundle.json index 1f6d02cacd..a1c6b04e55 100644 --- a/bundle.json +++ b/bundle.json @@ -213,6 +213,15 @@ ] } }, + { + "type": "so", + "name": "//foundation/graphic/graphic_2d/rosen/modules/frame_analyzer:libframe_analyzer", + "header": { + "header_files": [ + ], + "header_base": "//foundation/graphic/graphic_2d/rosen/modules/frame_analyzer/export" + } + }, { "type": "so", "name": "//foundation/graphic/graphic_2d/utils:libgraphic_utils", diff --git a/rosen/modules/render_service_client/BUILD.gn b/rosen/modules/render_service_client/BUILD.gn index 7d8a41f6c5..51225fb9b6 100644 --- a/rosen/modules/render_service_client/BUILD.gn +++ b/rosen/modules/render_service_client/BUILD.gn @@ -198,7 +198,7 @@ template("render_service_client_source_set") { } } if (rosen_is_ohos) { - public_deps += [ + deps += [ "$graphic_2d_root/rosen/modules/frame_analyzer:libframe_analyzer", "$graphic_2d_root/utils/color_manager:color_manager", ] From 3be51ef691f7dc42a49ea51f89a18169a6e2c8f4 Mon Sep 17 00:00:00 2001 From: "DESKTOP-OGBJOTA\\user" Date: Fri, 21 Jun 2024 07:44:52 +0300 Subject: [PATCH 004/247] Fix test build Signed-off-by: DESKTOP-OGBJOTA\user --- .../fuzztest/rsdisplayrendernode_fuzzer/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/rosen/test/render_service/render_service_base/fuzztest/rsdisplayrendernode_fuzzer/BUILD.gn b/rosen/test/render_service/render_service_base/fuzztest/rsdisplayrendernode_fuzzer/BUILD.gn index 90ad7124ee..bf47e9af13 100755 --- a/rosen/test/render_service/render_service_base/fuzztest/rsdisplayrendernode_fuzzer/BUILD.gn +++ b/rosen/test/render_service/render_service_base/fuzztest/rsdisplayrendernode_fuzzer/BUILD.gn @@ -27,6 +27,7 @@ ohos_fuzztest("RSDisplayRenderNodeFuzzTest") { ] deps = [ "../../../../../modules/2d_graphics:2d_graphics", + "../../../../../modules/frame_analyzer:libframe_analyzer", "../../../../../modules/render_service:librender_service", "../../../../../modules/render_service_base:librender_service_base", "../../../../../modules/render_service_client:librender_service_client", From 72be13831316a675bdb39c5e23fbab815a81802a Mon Sep 17 00:00:00 2001 From: "DESKTOP-OGBJOTA\\user" Date: Fri, 21 Jun 2024 08:00:41 +0300 Subject: [PATCH 005/247] Fix tdd build Signed-off-by: DESKTOP-OGBJOTA\user --- .../render_service/render_service_base/unittest/render/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/rosen/test/render_service/render_service_base/unittest/render/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/render/BUILD.gn index 76021310aa..8abd4aee28 100644 --- a/rosen/test/render_service/render_service_base/unittest/render/BUILD.gn +++ b/rosen/test/render_service/render_service_base/unittest/render/BUILD.gn @@ -78,6 +78,7 @@ ohos_unittest("RSRenderServiceBaseRenderTest") { external_deps = [ "c_utils:utils", "graphic_surface:surface", + "hitrace:hitrace_meter", "image_framework:image_native", "init:libbegetutil", "skia:skia_canvaskit", From d58f0c4457dd9594bb04db11ef93e828175a8c39 Mon Sep 17 00:00:00 2001 From: sunqizhen Date: Fri, 31 May 2024 14:22:19 +0800 Subject: [PATCH 006/247] Add UT cases Signed-off-by: sunqizhen --- .../rs_display_render_node_drawable_test.cpp | 74 +++++ .../pipeline/rs_hardware_thread_test.cpp | 14 +- .../rs_physical_screen_processor_test.cpp | 4 - .../pipeline/rs_uifirst_manager_test.cpp | 301 ++++++++++++++++++ .../screen_manager/rs_screen_manager_test.cpp | 38 +++ .../modifier/rs_extended_modifier_test.cpp | 2 +- 6 files changed, 424 insertions(+), 9 deletions(-) diff --git a/rosen/test/render_service/render_service/unittest/drawable/rs_display_render_node_drawable_test.cpp b/rosen/test/render_service/render_service/unittest/drawable/rs_display_render_node_drawable_test.cpp index fd37ba3e26..06e59541a0 100644 --- a/rosen/test/render_service/render_service/unittest/drawable/rs_display_render_node_drawable_test.cpp +++ b/rosen/test/render_service/render_service/unittest/drawable/rs_display_render_node_drawable_test.cpp @@ -254,4 +254,78 @@ HWTEST_F(RSDisplayRenderNodeDrawableTest, ScaleMirrorIfNeed002, TestSize.Level1) displayDrawable_->exFoldScreen_ = false; displayDrawable_->ScaleMirrorIfNeed(*renderNode_, processor); } + +/** + * @tc.name: SkipDisplayIfScreenOff + * @tc.desc: Test SkipDisplayIfScreenOff, corner case (node is nullptr), return false + * @tc.type: FUNC + * @tc.require: #I9UNQP + */ +HWTEST_F(RSDisplayRenderNodeDrawableTest, SkipDisplayIfScreenOff001, TestSize.Level1) +{ + if (!RSSystemProperties::GetSkipDisplayIfScreenOffEnabled() || !RSSystemProperties::IsPhoneType()) { + return; + } + drawable_->renderNode_.reset(); + ASSERT_FALSE(displayDrawable_->SkipDisplayIfScreenOff()); +} + +/** + * @tc.name: SkipDisplayIfScreenOff + * @tc.desc: Test SkipDisplayIfScreenOff, if power off, return true + * @tc.type: FUNC + * @tc.require: #I9UNQP + */ +HWTEST_F(RSDisplayRenderNodeDrawableTest, SkipDisplayIfScreenOff002, TestSize.Level1) +{ + if (!RSSystemProperties::GetSkipDisplayIfScreenOffEnabled() || !RSSystemProperties::IsPhoneType()) { + return; + } + + ScreenId screenId = 1; + renderNode_->SetScreenId(screenId); + + auto screenManager = CreateOrGetScreenManager(); + OHOS::Rosen::impl::RSScreenManager& screenManagerImpl = + static_cast(*screenManager); + screenManagerImpl.screenPowerStatus_[screenId] = ScreenPowerStatus::POWER_STATUS_ON; + ASSERT_FALSE(displayDrawable_->SkipDisplayIfScreenOff()); + screenManagerImpl.screenPowerStatus_[screenId] = ScreenPowerStatus::POWER_STATUS_OFF; + ASSERT_TRUE(displayDrawable_->SkipDisplayIfScreenOff()); + screenManagerImpl.screenPowerStatus_[screenId] = ScreenPowerStatus::POWER_STATUS_SUSPEND; + ASSERT_TRUE(displayDrawable_->SkipDisplayIfScreenOff()); +} + +/** + * @tc.name: SkipDisplayIfScreenOff + * @tc.desc: Test SkipDisplayIfScreenOff, if power off and render one more frame, return true + * @tc.type: FUNC + * @tc.require: #I9UNQP + */ +HWTEST_F(RSDisplayRenderNodeDrawableTest, SkipDisplayIfScreenOff003, TestSize.Level1) +{ + if (!RSSystemProperties::GetSkipDisplayIfScreenOffEnabled() || !RSSystemProperties::IsPhoneType()) { + return; + } + + ScreenId screenId = 1; + renderNode_->SetScreenId(screenId); + + auto screenManager = CreateOrGetScreenManager(); + OHOS::Rosen::impl::RSScreenManager& screenManagerImpl = + static_cast(*screenManager); + screenManager->MarkPowerOffNeedProcessOneFrame(); + screenManagerImpl.screenPowerStatus_[screenId] = ScreenPowerStatus::POWER_STATUS_OFF; + ASSERT_FALSE(displayDrawable_->SkipDisplayIfScreenOff()); + screenManager->MarkPowerOffNeedProcessOneFrame(); + screenManagerImpl.screenPowerStatus_[screenId] = ScreenPowerStatus::POWER_STATUS_SUSPEND; + ASSERT_FALSE(displayDrawable_->SkipDisplayIfScreenOff()); + + screenManager->ResetPowerOffNeedProcessOneFrame(); + screenManagerImpl.screenPowerStatus_[screenId] = ScreenPowerStatus::POWER_STATUS_OFF; + ASSERT_TRUE(displayDrawable_->SkipDisplayIfScreenOff()); + screenManager->ResetPowerOffNeedProcessOneFrame(); + screenManagerImpl.screenPowerStatus_[screenId] = ScreenPowerStatus::POWER_STATUS_SUSPEND; + ASSERT_TRUE(displayDrawable_->SkipDisplayIfScreenOff()); +} } diff --git a/rosen/test/render_service/render_service/unittest/pipeline/rs_hardware_thread_test.cpp b/rosen/test/render_service/render_service/unittest/pipeline/rs_hardware_thread_test.cpp index 19afd0ee60..b3f286abdf 100644 --- a/rosen/test/render_service/render_service/unittest/pipeline/rs_hardware_thread_test.cpp +++ b/rosen/test/render_service/render_service/unittest/pipeline/rs_hardware_thread_test.cpp @@ -125,8 +125,11 @@ void RSHardwareThreadTest::CreateComposerAdapterWithScreenInfo(uint32_t width, u HWTEST_F(RSHardwareThreadTest, ClearFrameBuffers001, TestSize.Level1) { auto& hardwareThread = RSHardwareThread::Instance(); - GSError ret = hardwareThread.ClearFrameBuffers(HdiOutput::CreateHdiOutput(screenId_)); - ASSERT_EQ(ret, GSERROR_OK); + auto hdiOutput = HdiOutput::CreateHdiOutput(screenId_); + if (hdiOutput->GetFrameBufferSurface()) { + GSError ret = hardwareThread.ClearFrameBuffers(hdiOutput); + ASSERT_EQ(ret, GSERROR_OK); + } } /** @@ -232,7 +235,10 @@ HWTEST_F(RSHardwareThreadTest, ClearFrameBuffers002, TestSize.Level1) auto& hardwareThread = RSHardwareThread::Instance(); GSError ret = hardwareThread.ClearFrameBuffers(nullptr); ASSERT_EQ(ret, GSERROR_INVALID_ARGUMENTS); - ret = hardwareThread.ClearFrameBuffers(HdiOutput::CreateHdiOutput(screenId_)); - ASSERT_EQ(ret, GSERROR_OK); + auto hdiOutput = HdiOutput::CreateHdiOutput(screenId_); + if (hdiOutput->GetFrameBufferSurface()) { + GSError ret = hardwareThread.ClearFrameBuffers(hdiOutput); + ASSERT_EQ(ret, GSERROR_OK); + } } } // namespace OHOS::Rosen \ No newline at end of file diff --git a/rosen/test/render_service/render_service/unittest/pipeline/rs_physical_screen_processor_test.cpp b/rosen/test/render_service/render_service/unittest/pipeline/rs_physical_screen_processor_test.cpp index 2153bf6fb9..ccd73377c5 100644 --- a/rosen/test/render_service/render_service/unittest/pipeline/rs_physical_screen_processor_test.cpp +++ b/rosen/test/render_service/render_service/unittest/pipeline/rs_physical_screen_processor_test.cpp @@ -85,10 +85,6 @@ HWTEST_F(RSPhysicalScreenProcessorTest, Init, TestSize.Level1) ASSERT_NE(nullptr, rsHardwareProcessor); ASSERT_EQ(uniRenderThread.uniRenderEngine_, renderEngine); ASSERT_EQ(false, rsHardwareProcessor->Init(rsDisplayRenderNode, offsetX, offsetY, INVALID_SCREEN_ID, renderEngine)); - RSUniRenderThread::Instance().InitGrContext(); - renderEngine = RSUniRenderThread::Instance().GetRenderEngine(); - ASSERT_NE(nullptr, renderEngine); - ASSERT_EQ(false, rsHardwareProcessor->Init(rsDisplayRenderNode, offsetX, offsetY, INVALID_SCREEN_ID, renderEngine)); } /** diff --git a/rosen/test/render_service/render_service/unittest/pipeline/rs_uifirst_manager_test.cpp b/rosen/test/render_service/render_service/unittest/pipeline/rs_uifirst_manager_test.cpp index f1850ba9eb..892e7203c4 100644 --- a/rosen/test/render_service/render_service/unittest/pipeline/rs_uifirst_manager_test.cpp +++ b/rosen/test/render_service/render_service/unittest/pipeline/rs_uifirst_manager_test.cpp @@ -34,6 +34,9 @@ public: static inline NodeId INVALID_NODEID = 0xFFFF; static inline RSMainThread* mainThread_; static inline RSUifirstManager& uifirstManager_ = RSUifirstManager::Instance(); + static inline Occlusion::Region DEFAULT_VISIBLE_REGION = Occlusion::Rect(0, 0, 10, 10); + static inline RectI VISIBLE_DIRTY_REGION = {0, 0, 10, 10}; + static inline RectI INVISIBLE_DIRTY_REGION = {20, 20, 10, 10}; }; void RSUifirstManagerTest::SetUpTestCase() @@ -266,4 +269,302 @@ HWTEST_F(RSUifirstManagerTest, ProcessDoneNode, TestSize.Level1) uifirstManager_.ProcessDoneNode(); ASSERT_TRUE(uifirstManager_.subthreadProcessDoneNode_.empty()); } + +/** + * @tc.name: CheckVisibleDirtyRegionIsEmpty + * @tc.desc: Test CheckVisibleDirtyRegionIsEmpty, node has no child + * @tc.type: FUNC + * @tc.require: #I9UNQP + */ +HWTEST_F(RSUifirstManagerTest, CheckVisibleDirtyRegionIsEmpty001, TestSize.Level1) +{ + auto surfaceNode = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(surfaceNode, nullptr); + ASSERT_FALSE(uifirstManager_.CheckVisibleDirtyRegionIsEmpty(surfaceNode)); +} + +/** + * @tc.name: CheckVisibleDirtyRegionIsEmpty + * @tc.desc: Test CheckVisibleDirtyRegionIsEmpty, child has empty dirty region + * @tc.type: FUNC + * @tc.require: #I9UNQP + */ +HWTEST_F(RSUifirstManagerTest, CheckVisibleDirtyRegionIsEmpty002, TestSize.Level1) +{ + auto surfaceNode = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(surfaceNode, nullptr); + auto childNode = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(childNode, nullptr); + surfaceNode->AddChild(childNode); + surfaceNode->GenerateFullChildrenList(); + + ASSERT_TRUE(uifirstManager_.CheckVisibleDirtyRegionIsEmpty(surfaceNode)); +} + +/** + * @tc.name: CheckVisibleDirtyRegionIsEmpty + * @tc.desc: Test CheckVisibleDirtyRegionIsEmpty, child has visible/invisible dirty region + * @tc.type: FUNC + * @tc.require: #I9UNQP + */ +HWTEST_F(RSUifirstManagerTest, CheckVisibleDirtyRegionIsEmpty003, TestSize.Level1) +{ + auto surfaceNode = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(surfaceNode, nullptr); + auto childNode = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(childNode, nullptr); + surfaceNode->AddChild(childNode); + surfaceNode->GenerateFullChildrenList(); + // set visible region in both node and param + childNode->SetVisibleRegion(DEFAULT_VISIBLE_REGION); + auto surfaceParams = static_cast(childNode->GetRenderParams().get()); + ASSERT_NE(surfaceParams, nullptr); + surfaceParams->SetVisibleRegion(DEFAULT_VISIBLE_REGION); + + ASSERT_NE(childNode->GetDirtyManager(), nullptr); + childNode->GetDirtyManager()->SetCurrentFrameDirtyRect(VISIBLE_DIRTY_REGION); + ASSERT_FALSE(uifirstManager_.CheckVisibleDirtyRegionIsEmpty(surfaceNode)); + childNode->GetDirtyManager()->SetCurrentFrameDirtyRect(INVISIBLE_DIRTY_REGION); + ASSERT_TRUE(uifirstManager_.CheckVisibleDirtyRegionIsEmpty(surfaceNode)); +} + +/** + * @tc.name: ProcessTreeStateChange + * @tc.desc: Test ProcessTreeStateChange, early return case + * @tc.type: FUNC + * @tc.require: #I9UNQP + */ +HWTEST_F(RSUifirstManagerTest, ProcessTreeStateChange, TestSize.Level1) +{ + auto surfaceNode1 = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(surfaceNode1, nullptr); + surfaceNode1->SetIsOnTheTree(true); + uifirstManager_.ProcessTreeStateChange(*surfaceNode1); + + auto surfaceNode2 = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(surfaceNode2, nullptr); + surfaceNode1->SetIsOnTheTree(false); + surfaceNode1->SetIsNodeToBeCaptured(true); + uifirstManager_.ProcessTreeStateChange(*surfaceNode2); +} + +/** + * @tc.name: UpdateChildrenDirtyRect + * @tc.desc: Test UpdateChildrenDirtyRect if node is not leash window, return early. + * @tc.type: FUNC + * @tc.require: #I9UNQP + */ +HWTEST_F(RSUifirstManagerTest, UpdateChildrenDirtyRect001, TestSize.Level1) +{ + auto surfaceNode = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(surfaceNode, nullptr); + surfaceNode->SetSurfaceNodeType(RSSurfaceNodeType::STARTING_WINDOW_NODE); + uifirstManager_.UpdateChildrenDirtyRect(*surfaceNode); + + auto param = static_cast(surfaceNode->stagingRenderParams_.get()); + ASSERT_TRUE(param->GetUifirstChildrenDirtyRectParam().IsEmpty()); +} + +/** + * @tc.name: UpdateChildrenDirtyRect + * @tc.desc: Test UpdateChildrenDirtyRect if node is not leash window, return early. + * @tc.type: FUNC + * @tc.require: #I9UNQP + */ +HWTEST_F(RSUifirstManagerTest, UpdateChildrenDirtyRect002, TestSize.Level1) +{ + auto surfaceNode = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(surfaceNode, nullptr); + surfaceNode->SetSurfaceNodeType(RSSurfaceNodeType::LEASH_WINDOW_NODE); + auto child1 = RSTestUtil::CreateSurfaceNode(); + child1->SetSurfaceNodeType(RSSurfaceNodeType::FOREGROUND_SURFACE); + auto child2 = RSTestUtil::CreateSurfaceNode(); + child2->SetSurfaceNodeType(RSSurfaceNodeType::APP_WINDOW_NODE); + child2->oldDirtyInSurface_ = DEFAULT_RECT; + surfaceNode->AddChild(child1); + surfaceNode->AddChild(child2); + surfaceNode->GenerateFullChildrenList(); + uifirstManager_.UpdateChildrenDirtyRect(*surfaceNode); + + auto param = static_cast(surfaceNode->stagingRenderParams_.get()); + ASSERT_EQ(param->GetUifirstChildrenDirtyRectParam(), DEFAULT_RECT); +} + +/** + * @tc.name: UifirstStateChange + * @tc.desc: Test UifirstStateChange, not enabled case. + * @tc.type: FUNC + * @tc.require: #I9UNQP + */ +HWTEST_F(RSUifirstManagerTest, UifirstStateChange, TestSize.Level1) +{ + auto surfaceNode = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(surfaceNode, nullptr); + // not support cache type switch, just disable multithread cache + surfaceNode->SetLastFrameUifirstFlag(MultiThreadCacheType::LEASH_WINDOW); + auto currentFrameCacheType = MultiThreadCacheType::NONFOCUS_WINDOW; + uifirstManager_.UifirstStateChange(*surfaceNode, currentFrameCacheType); + ASSERT_EQ(surfaceNode->GetLastFrameUifirstFlag(), MultiThreadCacheType::NONE); +} + +/** + * @tc.name: UifirstStateChange + * @tc.desc: Test UifirstStateChange, last frame not enabled, this frame enabled + * @tc.type: FUNC + * @tc.require: #I9UNQP + */ +HWTEST_F(RSUifirstManagerTest, UifirstStateChange002, TestSize.Level1) +{ + auto surfaceNode = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(surfaceNode, nullptr); + // not support cache type switch, just disable multithread cache + surfaceNode->SetLastFrameUifirstFlag(MultiThreadCacheType::NONE); + auto currentFrameCacheType = MultiThreadCacheType::LEASH_WINDOW; + uifirstManager_.UifirstStateChange(*surfaceNode, currentFrameCacheType); + ASSERT_EQ(surfaceNode->GetLastFrameUifirstFlag(), MultiThreadCacheType::LEASH_WINDOW); +} + +/** + * @tc.name: UifirstStateChange + * @tc.desc: Test UifirstStateChange, last frame enabled, this frame enabled + * @tc.type: FUNC + * @tc.require: #I9UNQP + */ +HWTEST_F(RSUifirstManagerTest, UifirstStateChange003, TestSize.Level1) +{ + auto surfaceNode = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(surfaceNode, nullptr); + + surfaceNode->SetLastFrameUifirstFlag(MultiThreadCacheType::LEASH_WINDOW); + auto currentFrameCacheType = MultiThreadCacheType::LEASH_WINDOW; + uifirstManager_.UifirstStateChange(*surfaceNode, currentFrameCacheType); + ASSERT_EQ(surfaceNode->GetLastFrameUifirstFlag(), MultiThreadCacheType::LEASH_WINDOW); +} + +/** + * @tc.name: UifirstStateChange + * @tc.desc: Test UifirstStateChange, last frame enabled, this frame disabled + * @tc.type: FUNC + * @tc.require: #I9UNQP + */ +HWTEST_F(RSUifirstManagerTest, UifirstStateChange004, TestSize.Level1) +{ + auto surfaceNode = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(surfaceNode, nullptr); + + surfaceNode->SetLastFrameUifirstFlag(MultiThreadCacheType::LEASH_WINDOW); + auto currentFrameCacheType = MultiThreadCacheType::NONE; + uifirstManager_.UifirstStateChange(*surfaceNode, currentFrameCacheType); + ASSERT_EQ(surfaceNode->GetLastFrameUifirstFlag(), MultiThreadCacheType::NONE); +} + +/** + * @tc.name: CheckIfAppWindowHasAnimation + * @tc.desc: Test CheckIfAppWindowHasAnimation + * @tc.type: FUNC + * @tc.require: #I9UNQP + */ +HWTEST_F(RSUifirstManagerTest, CheckIfAppWindowHasAnimation, TestSize.Level1) +{ + auto surfaceNode = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(surfaceNode, nullptr); + + surfaceNode->SetSurfaceNodeType(RSSurfaceNodeType::ABILITY_COMPONENT_NODE); + ASSERT_FALSE(uifirstManager_.CheckIfAppWindowHasAnimation(*surfaceNode)); +} + +/** + * @tc.name: CheckIfAppWindowHasAnimation + * @tc.desc: Test CheckIfAppWindowHasAnimation, currentFrameEvent_ is empty or node is not leash/app window + * @tc.type: FUNC + * @tc.require: #I9UNQP + */ +HWTEST_F(RSUifirstManagerTest, CheckIfAppWindowHasAnimation001, TestSize.Level1) +{ + auto surfaceNode = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(surfaceNode, nullptr); + ASSERT_FALSE(uifirstManager_.CheckIfAppWindowHasAnimation(*surfaceNode)); + + RSUifirstManager::EventInfo event; + uifirstManager_.currentFrameEvent_.push_back(event); + surfaceNode->SetSurfaceNodeType(RSSurfaceNodeType::ABILITY_COMPONENT_NODE); + ASSERT_FALSE(uifirstManager_.CheckIfAppWindowHasAnimation(*surfaceNode)); + uifirstManager_.currentFrameEvent_.clear(); +} + +/** + * @tc.name: CheckIfAppWindowHasAnimation + * @tc.desc: Test CheckIfAppWindowHasAnimation, app window + * @tc.type: FUNC + * @tc.require: #I9UNQP + */ +HWTEST_F(RSUifirstManagerTest, CheckIfAppWindowHasAnimation002, TestSize.Level1) +{ + auto surfaceNode = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(surfaceNode, nullptr); + + surfaceNode->SetSurfaceNodeType(RSSurfaceNodeType::APP_WINDOW_NODE); + RSUifirstManager::EventInfo event; + event.disableNodes.emplace(surfaceNode->GetId()); + uifirstManager_.currentFrameEvent_.push_back(event); + ASSERT_TRUE(uifirstManager_.CheckIfAppWindowHasAnimation(*surfaceNode)); + uifirstManager_.currentFrameEvent_.clear(); +} + +/** + * @tc.name: CheckIfAppWindowHasAnimation + * @tc.desc: Test CheckIfAppWindowHasAnimation, leash window + * @tc.type: FUNC + * @tc.require: #I9UNQP + */ +HWTEST_F(RSUifirstManagerTest, CheckIfAppWindowHasAnimation003, TestSize.Level1) +{ + auto surfaceNode = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(surfaceNode, nullptr); + auto childNode = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(childNode, nullptr); + surfaceNode->AddChild(childNode); + surfaceNode->GenerateFullChildrenList(); + + surfaceNode->SetSurfaceNodeType(RSSurfaceNodeType::LEASH_WINDOW_NODE); + childNode->SetSurfaceNodeType(RSSurfaceNodeType::APP_WINDOW_NODE); + RSUifirstManager::EventInfo event; + event.disableNodes.emplace(surfaceNode->GetId()); + uifirstManager_.currentFrameEvent_.push_back(event); + ASSERT_TRUE(uifirstManager_.CheckIfAppWindowHasAnimation(*surfaceNode)); + uifirstManager_.currentFrameEvent_.clear(); +} + +/** + * @tc.name: UpdateUifirstNodes + * @tc.desc: Test UpdateUifirstNodes, with different nodes + * @tc.type: FUNC + * @tc.require: #I9UNQP + */ +HWTEST_F(RSUifirstManagerTest, UpdateUifirstNodes, TestSize.Level1) +{ + auto surfaceNode1 = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(surfaceNode1, nullptr); + surfaceNode1->SetSurfaceNodeType(RSSurfaceNodeType::LEASH_WINDOW_NODE); + surfaceNode1->isChildSupportUifirst_ = true; + uifirstManager_.UpdateUifirstNodes(*surfaceNode1, true); + + auto surfaceNode2 = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(surfaceNode2, nullptr); + surfaceNode2->SetSurfaceNodeType(RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE); + surfaceNode2->isChildSupportUifirst_ = true; + uifirstManager_.UpdateUifirstNodes(*surfaceNode2, true); + + auto surfaceNode3 = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(surfaceNode3, nullptr); + surfaceNode3->SetSurfaceNodeType(RSSurfaceNodeType::ABILITY_COMPONENT_NODE); + surfaceNode3->isChildSupportUifirst_ = true; + uifirstManager_.UpdateUifirstNodes(*surfaceNode3, true); + + auto surfaceNode4 = RSTestUtil::CreateSurfaceNode(); + ASSERT_NE(surfaceNode4, nullptr); + surfaceNode4->SetSurfaceNodeType(RSSurfaceNodeType::SCB_SCREEN_NODE); + surfaceNode4->isChildSupportUifirst_ = true; + uifirstManager_.UpdateUifirstNodes(*surfaceNode4, true); +} } \ No newline at end of file diff --git a/rosen/test/render_service/render_service/unittest/screen_manager/rs_screen_manager_test.cpp b/rosen/test/render_service/render_service/unittest/screen_manager/rs_screen_manager_test.cpp index 6d7e2ec99b..988395c1ee 100644 --- a/rosen/test/render_service/render_service/unittest/screen_manager/rs_screen_manager_test.cpp +++ b/rosen/test/render_service/render_service/unittest/screen_manager/rs_screen_manager_test.cpp @@ -1825,4 +1825,42 @@ HWTEST_F(RSScreenManagerTest, SetVirtualMirrorScreenScaleMode_002, TestSize.Leve screenManager->RemoveVirtualScreen(id); sleep(1); } + +/* + * @tc.name: IsScreenPowerOffTest001 + * @tc.desc: Test IsScreenPowerOff, input invalid id, expect false. + * @tc.type: FUNC + * @tc.require: #I9UNQP + */ +HWTEST_F(RSScreenManagerTest, IsScreenPowerOffTest001, TestSize.Level1) +{ + auto screenManager = CreateOrGetScreenManager(); + ASSERT_NE(nullptr, screenManager); + ScreenId id = INVALID_SCREEN_ID; + ASSERT_FALSE(screenManager->IsScreenPowerOff(id)); +} + +/* + * @tc.name: IsScreenPowerOffTest002 + * @tc.desc: Test IsScreenPowerOff, input invalid id, expect false. + * @tc.type: FUNC + * @tc.require: #I9UNQP + */ +HWTEST_F(RSScreenManagerTest, IsScreenPowerOffTest002, TestSize.Level1) +{ + auto screenManager = CreateOrGetScreenManager(); + ASSERT_NE(nullptr, screenManager); + OHOS::Rosen::impl::RSScreenManager& screenManagerImpl = + static_cast(*screenManager); + + ScreenId id = 1; + screenManagerImpl.screenPowerStatus_[id] = GraphicDispPowerStatus::GRAPHIC_POWER_STATUS_ON; + ASSERT_FALSE(screenManager->IsScreenPowerOff(id)); + screenManagerImpl.screenPowerStatus_[id] = GraphicDispPowerStatus::GRAPHIC_POWER_STATUS_ON_ADVANCED; + ASSERT_FALSE(screenManager->IsScreenPowerOff(id)); + screenManagerImpl.screenPowerStatus_[id] = GraphicDispPowerStatus::GRAPHIC_POWER_STATUS_OFF; + ASSERT_TRUE(screenManager->IsScreenPowerOff(id)); + screenManagerImpl.screenPowerStatus_[id] = GraphicDispPowerStatus::GRAPHIC_POWER_STATUS_SUSPEND; + ASSERT_TRUE(screenManager->IsScreenPowerOff(id)); +} } // namespace OHOS::Rosen diff --git a/rosen/test/render_service/render_service_client/unittest/modifier/rs_extended_modifier_test.cpp b/rosen/test/render_service/render_service_client/unittest/modifier/rs_extended_modifier_test.cpp index 3d7f505912..e8863eb478 100644 --- a/rosen/test/render_service/render_service_client/unittest/modifier/rs_extended_modifier_test.cpp +++ b/rosen/test/render_service/render_service_client/unittest/modifier/rs_extended_modifier_test.cpp @@ -168,7 +168,7 @@ HWTEST_F(RSExtendedModifierTest, FinishDrawingTest1, TestSize.Level1) } RSDrawingContext ctx = { recordingCanvas, 1000, 3000 }; std::shared_ptr cmdList = RSExtendedModifierHelper::FinishDrawing(ctx); - ASSERT_EQ(cmdList, nullptr); + ASSERT_NE(cmdList, nullptr); } /** From a0ea7243e2c59866351f2b0bf79eb78043992c01 Mon Sep 17 00:00:00 2001 From: Korobkov Dmitry Date: Mon, 17 Jun 2024 10:36:41 +0300 Subject: [PATCH 007/247] Frame number feature and refactoring Signed-off-by: Korobkov Dmitry --- .../core/pipeline/rs_draw_frame.cpp | 11 ++++- .../render_service_profiler/rs_profiler.cpp | 49 ++++++++++++++++++- .../render_service_profiler/rs_profiler.h | 14 ++++++ .../rs_profiler_beta_recorder.cpp | 3 +- .../rs_profiler_capturedata.h | 5 ++ .../rs_profiler_network.cpp | 2 +- .../rs_profiler_packet.h | 1 + 7 files changed, 80 insertions(+), 5 deletions(-) diff --git a/rosen/modules/render_service/core/pipeline/rs_draw_frame.cpp b/rosen/modules/render_service/core/pipeline/rs_draw_frame.cpp index f16fe1b166..02a276cbf5 100644 --- a/rosen/modules/render_service/core/pipeline/rs_draw_frame.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_draw_frame.cpp @@ -27,6 +27,8 @@ #include "property/rs_filter_cache_manager.h" #include "rs_frame_report.h" +#include "rs_profiler.h" + namespace OHOS { namespace Rosen { RSDrawFrame::RSDrawFrame() @@ -89,13 +91,16 @@ void RSDrawFrame::ReleaseSelfDrawingNodeBuffer() void RSDrawFrame::PostAndWait() { RS_TRACE_NAME_FMT("PostAndWait, parallel type %d", static_cast(rsParallelType_)); + uint32_t renderFrameNumber = RS_PROFILER_GET_FRAME_NUMBER(); switch (rsParallelType_) { case RsParallelType::RS_PARALLEL_TYPE_SYNC: { // wait until render finish in render thread - unirenderInstance_.PostSyncTask([this]() { + unirenderInstance_.PostSyncTask([this, renderFrameNumber]() { + RS_PROFILER_ON_PARALLEL_RENDER_BEGIN(); unirenderInstance_.SetMainLooping(true); RenderFrame(); unirenderInstance_.RunImageReleaseTask(); unirenderInstance_.SetMainLooping(false); + RS_PROFILER_ON_PARALLEL_RENDER_END(renderFrameNumber); }); break; } @@ -108,11 +113,13 @@ void RSDrawFrame::PostAndWait() default: { std::unique_lock frameLock(frameMutex_); canUnblockMainThread = false; - unirenderInstance_.PostTask([this]() { + unirenderInstance_.PostTask([this, renderFrameNumber]() { + RS_PROFILER_ON_PARALLEL_RENDER_BEGIN(); unirenderInstance_.SetMainLooping(true); RenderFrame(); unirenderInstance_.RunImageReleaseTask(); unirenderInstance_.SetMainLooping(false); + RS_PROFILER_ON_PARALLEL_RENDER_END(renderFrameNumber); }); frameCV_.wait(frameLock, [this] { return canUnblockMainThread; }); diff --git a/rosen/modules/render_service_profiler/rs_profiler.cpp b/rosen/modules/render_service_profiler/rs_profiler.cpp index 679c396022..638733ed19 100644 --- a/rosen/modules/render_service_profiler/rs_profiler.cpp +++ b/rosen/modules/render_service_profiler/rs_profiler.cpp @@ -26,6 +26,7 @@ #include "rs_profiler_settings.h" #include "rs_profiler_telemetry.h" #include "rs_profiler_utils.h" +#include "rs_profiler_packet.h" #include "params/rs_display_render_params.h" #include "pipeline/rs_main_thread.h" @@ -40,6 +41,7 @@ static std::atomic g_renderServiceCpuId = 0; static RSMainThread* g_mainThread = nullptr; static RSContext* g_context = nullptr; static uint64_t g_frameBeginTimestamp = 0u; +static uint64_t g_frameRenderBeginTimestamp = 0u; static double g_dirtyRegionPercentage = 0.0; static bool g_rdcSent = true; @@ -47,6 +49,7 @@ static std::atomic g_lastCacheImageCount = 0; static RSFile g_recordFile {}; static double g_recordStartTime = 0.0; +static uint32_t g_frameNumber = 0; static RSFile g_playbackFile {}; static double g_playbackStartTime = 0.0; @@ -350,6 +353,42 @@ void RSProfiler::OnRenderEnd() g_renderServiceCpuId = Utils::GetCpuId(); } +void RSProfiler::OnParallelRenderBegin() +{ + if (!IsEnabled()) { + return; + } + g_frameRenderBeginTimestamp = RawNowNano(); +} + +void RSProfiler::OnParallelRenderEnd(uint32_t frameNumber) +{ + if (!IsRecording() || (g_recordStartTime <= 0.0)) { + return; + } + + const uint64_t frameLengthNanosecs = RawNowNano() - g_frameRenderBeginTimestamp; + + const double currentTime = g_frameRenderBeginTimestamp * 1e-9; // Now(); + const double timeSinceRecordStart = currentTime - g_recordStartTime; + + if (timeSinceRecordStart > 0.0) { + RSCaptureData captureData; + captureData.SetTime(timeSinceRecordStart); + captureData.SetProperty(RSCaptureData::KEY_RENDER_FRAME_NUMBER, frameNumber); + captureData.SetProperty(RSCaptureData::KEY_RENDER_FRAME_LEN, frameLengthNanosecs); + + std::vector out; + captureData.Serialize(out); + + const char headerType = static_cast(PackageID::RS_PROFILER_RENDER_METRICS); + out.insert(out.begin(), headerType); + + Network::SendBinary(out.data(), out.size()); + g_recordFile.WriteRSMetrics(0, timeSinceRecordStart, out.data(), out.size()); + } +} + void RSProfiler::OnFrameBegin() { if (!IsEnabled()) { @@ -358,6 +397,7 @@ void RSProfiler::OnFrameBegin() g_frameBeginTimestamp = RawNowNano(); g_renderServiceCpuId = Utils::GetCpuId(); + g_frameNumber++; StartBetaRecord(); } @@ -680,6 +720,7 @@ void RSProfiler::RecordUpdate() if (timeSinceRecordStart > 0.0) { RSCaptureData captureData; captureData.SetTime(timeSinceRecordStart); + captureData.SetProperty(RSCaptureData::KEY_RS_FRAME_NUMBER, g_frameNumber); captureData.SetProperty(RSCaptureData::KEY_RS_FRAME_LEN, frameLengthNanosecs); captureData.SetProperty(RSCaptureData::KEY_RS_CMD_COUNT, GetCommandCount()); captureData.SetProperty(RSCaptureData::KEY_RS_CMD_EXECUTE_COUNT, GetCommandExecuteCount()); @@ -691,7 +732,7 @@ void RSProfiler::RecordUpdate() std::vector out; captureData.Serialize(out); - const char headerType = 2; // TYPE: RS METRICS + const char headerType = static_cast(PackageID::RS_PROFILER_RS_METRICS); out.insert(out.begin(), headerType); Network::SendBinary(out.data(), out.size()); @@ -1141,6 +1182,7 @@ void RSProfiler::RecordStart(const ArgList& args) SetMode(Mode::WRITE); g_recordStartTime = Now(); + g_frameNumber = 0; std::thread thread([]() { while (IsRecording()) { @@ -1472,4 +1514,9 @@ void RSProfiler::ProcessCommands() } } +uint32_t RSProfiler::GetFrameNumber() +{ + return g_frameNumber; +} + } // namespace OHOS::Rosen \ No newline at end of file diff --git a/rosen/modules/render_service_profiler/rs_profiler.h b/rosen/modules/render_service_profiler/rs_profiler.h index cf4037fd4d..998f9d6975 100644 --- a/rosen/modules/render_service_profiler/rs_profiler.h +++ b/rosen/modules/render_service_profiler/rs_profiler.h @@ -48,6 +48,10 @@ #define RS_PROFILER_SET_DIRTY_REGION(dirtyRegion) RSProfiler::SetDirtyRegion(dirtyRegion) #define RS_PROFILER_WRITE_PARCEL_DATA(parcel) RSProfiler::WriteParcelData(parcel) #define RS_PROFILER_READ_PARCEL_DATA(parcel, size, isMalloc) RSProfiler::ReadParcelData(parcel, size, isMalloc) +#define RS_PROFILER_UPDATE_HWC_NODE_CHECK() RSProfiler::UpdateHwcNodeCheck() +#define RS_PROFILER_GET_FRAME_NUMBER() RSProfiler::GetFrameNumber() +#define RS_PROFILER_ON_PARALLEL_RENDER_BEGIN() RSProfiler::OnParallelRenderBegin() +#define RS_PROFILER_ON_PARALLEL_RENDER_END(renderFrameNumber) RSProfiler::OnParallelRenderEnd(renderFrameNumber) #else #define RS_PROFILER_INIT(renderSevice) #define RS_PROFILER_ON_FRAME_BEGIN() @@ -71,6 +75,10 @@ #define RS_PROFILER_SET_DIRTY_REGION(dirtyRegion) #define RS_PROFILER_WRITE_PARCEL_DATA(parcel) #define RS_PROFILER_READ_PARCEL_DATA(parcel, size, isMalloc) RSMarshallingHelper::ReadFromAshmem(parcel, size, isMalloc) +#define RS_PROFILER_UPDATE_HWC_NODE_CHECK() true +#define RS_PROFILER_GET_FRAME_NUMBER() 0 +#define RS_PROFILER_ON_PARALLEL_RENDER_BEGIN() +#define RS_PROFILER_ON_PARALLEL_RENDER_END(renderFrameNumber) #endif #ifdef RS_PROFILER_ENABLED @@ -117,6 +125,8 @@ public: static void OnFrameEnd(); static void OnRenderBegin(); static void OnRenderEnd(); + static void OnParallelRenderBegin(); + static void OnParallelRenderEnd(uint32_t frameNumber); static void OnProcessCommand(); // see RSRenderService::CreateConnection @@ -156,12 +166,16 @@ public: RSB_EXPORT static void WriteParcelData(Parcel& parcel); RSB_EXPORT static const void* ReadParcelData(Parcel& parcel, size_t size, bool& isMalloc); + RSB_EXPORT static uint32_t GetFrameNumber(); + public: RSB_EXPORT static bool IsParcelMock(const Parcel& parcel); RSB_EXPORT static bool IsSharedMemoryEnabled(); RSB_EXPORT static bool IsBetaRecordEnabled(); RSB_EXPORT static bool IsBetaRecordEnabledWithMetrics(); + RSB_EXPORT static bool UpdateHwcNodeCheck(); + private: static const char* GetProcessNameByPid(int pid); diff --git a/rosen/modules/render_service_profiler/rs_profiler_beta_recorder.cpp b/rosen/modules/render_service_profiler/rs_profiler_beta_recorder.cpp index c2b4e43152..2d6ae60c51 100644 --- a/rosen/modules/render_service_profiler/rs_profiler_beta_recorder.cpp +++ b/rosen/modules/render_service_profiler/rs_profiler_beta_recorder.cpp @@ -20,6 +20,7 @@ #include "rs_profiler_network.h" #include "rs_profiler_telemetry.h" #include "rs_profiler_utils.h" +#include "rs_profiler_packet.h" namespace OHOS::Rosen { @@ -262,7 +263,7 @@ void RSProfiler::WriteBetaRecordMetrics(RSFile& file, double time) DeviceInfoToCaptureData(time, deviceInfo, captureData); std::vector out; - const char headerType = 3; // TYPE: GFX METRICS + const char headerType = static_cast(PackageID::RS_PROFILER_GFX_METRICS); captureData.Serialize(out); out.insert(out.begin(), headerType); diff --git a/rosen/modules/render_service_profiler/rs_profiler_capturedata.h b/rosen/modules/render_service_profiler/rs_profiler_capturedata.h index ddb3795a71..a933e95777 100644 --- a/rosen/modules/render_service_profiler/rs_profiler_capturedata.h +++ b/rosen/modules/render_service_profiler/rs_profiler_capturedata.h @@ -25,6 +25,7 @@ namespace OHOS::Rosen { class RSCaptureData final { public: // every rs update + inline static const std::string KEY_RS_FRAME_NUMBER = "rs_frame_number"; inline static const std::string KEY_RS_FRAME_LEN = "rs_frame_len"; inline static const std::string KEY_RS_CMD_COUNT = "rs_cmd_count"; inline static const std::string KEY_RS_CMD_EXECUTE_COUNT = "rs_cmd_execute_count"; @@ -33,6 +34,10 @@ public: inline static const std::string KEY_RS_DIRTY_REGION = "rs_dirty_region"; inline static const std::string KEY_RS_CPU_ID = "rs_cpu_id"; + // every frame rendered + inline static const std::string KEY_RENDER_FRAME_NUMBER = "render_frame_number"; + inline static const std::string KEY_RENDER_FRAME_LEN = "render_frame_len"; + // every 8ms inline static const std::string KEY_CPU_TEMP = "cpu_temp"; inline static const std::string KEY_CPU_LOAD = "cpu_load"; diff --git a/rosen/modules/render_service_profiler/rs_profiler_network.cpp b/rosen/modules/render_service_profiler/rs_profiler_network.cpp index 6fad31790e..8e11e9f459 100644 --- a/rosen/modules/render_service_profiler/rs_profiler_network.cpp +++ b/rosen/modules/render_service_profiler/rs_profiler_network.cpp @@ -237,7 +237,7 @@ void Network::SendCaptureData(const RSCaptureData& data) const_cast(data).Serialize(out); if (!out.empty()) { - const char headerType = 3; // TYPE: GFX METRICS + const char headerType = static_cast(PackageID::RS_PROFILER_GFX_METRICS); out.insert(out.begin(), headerType); SendBinary(out); } diff --git a/rosen/modules/render_service_profiler/rs_profiler_packet.h b/rosen/modules/render_service_profiler/rs_profiler_packet.h index 62256610ed..91028bb113 100644 --- a/rosen/modules/render_service_profiler/rs_profiler_packet.h +++ b/rosen/modules/render_service_profiler/rs_profiler_packet.h @@ -44,6 +44,7 @@ enum class PackageID { RS_PROFILER_RSTREE_SINGLE_NODE_PERF, RS_PROFILER_MSKP_FILEPATH, RS_PROFILER_BETAREC_FILEPATH, + RS_PROFILER_RENDER_METRICS, }; class BinaryHelper { public: From 85e27d475162367a9fac318c5f13abc5e3fb89ba Mon Sep 17 00:00:00 2001 From: denispavlov Date: Wed, 19 Jun 2024 14:26:29 +0300 Subject: [PATCH 008/247] Fix for filesystem and security warnings Signed-off-by: denispavlov --- .../render_service_profiler/rs_profiler.cpp | 2 +- .../rs_profiler_utils.cpp | 52 +++++++++++++------ 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/rosen/modules/render_service_profiler/rs_profiler.cpp b/rosen/modules/render_service_profiler/rs_profiler.cpp index 638733ed19..784d53027e 100644 --- a/rosen/modules/render_service_profiler/rs_profiler.cpp +++ b/rosen/modules/render_service_profiler/rs_profiler.cpp @@ -422,7 +422,7 @@ void RSProfiler::OnFrameEnd() void RSProfiler::CalcNodeWeigthOnFrameEnd() { - if (g_calcPerfNode == 0) { + if (g_calcPerfNode == 0 || g_calcPerfNodeTry < 0 || g_calcPerfNodeTry > CALC_PERF_NODE_TIME_COUNT) { return; } diff --git a/rosen/modules/render_service_profiler/rs_profiler_utils.cpp b/rosen/modules/render_service_profiler/rs_profiler_utils.cpp index eae919a526..d48fea23e1 100644 --- a/rosen/modules/render_service_profiler/rs_profiler_utils.cpp +++ b/rosen/modules/render_service_profiler/rs_profiler_utils.cpp @@ -243,8 +243,8 @@ std::string Utils::GetRealPath(const std::string& path) { std::string realPath; if (!PathToRealPath(path, realPath)) { - RS_LOGE("Path %s is not real!", path.data()); // NOLINT - return ""; + RS_LOGE("PathToRealPath fails on %s !", path.data()); // NOLINT + return path; } return realPath; } @@ -261,17 +261,40 @@ std::string Utils::NormalizePath(const std::string& path) std::string Utils::GetFileName(const std::string& path) { +#ifdef REPLAY_TOOL_CLIENT return std::filesystem::path(path).filename().string(); +#else + std::string filename; + const size_t lastSlashIdx = path.rfind('/'); + if (std::string::npos != lastSlashIdx) { + filename = path.substr(lastSlashIdx + 1); + } + return filename; +#endif } std::string Utils::GetDirectory(const std::string& path) { +#ifdef REPLAY_TOOL_CLIENT return std::filesystem::path(path).parent_path().string(); +#else + std::string directory; + const size_t lastSlashIdx = path.rfind('/'); + if (std::string::npos != lastSlashIdx) { + directory = path.substr(0, lastSlashIdx); + } + return directory; +#endif } bool Utils::IsDirectory(const std::string& path) { +#ifdef REPLAY_TOOL_CLIENT return std::filesystem::is_directory(path); +#else + struct stat st {}; + return (stat(path.data(), &st) == 0) && S_ISDIR(st.st_mode); +#endif } void Utils::IterateDirectory(const std::string& path, std::vector& files) @@ -381,7 +404,12 @@ static bool ShouldFileBeCreated(const std::string& options) bool Utils::FileExists(const std::string& path) { +#ifdef REPLAY_TOOL_CLIENT return std::filesystem::exists(path); +#else + struct stat st {}; + return (stat(path.data(), &st) == 0) && S_ISREG(st.st_mode); +#endif } FILE* Utils::FileOpen(const std::string& path, const std::string& options) @@ -395,23 +423,17 @@ FILE* Utils::FileOpen(const std::string& path, const std::string& options) return g_recordInMemoryFile; } - if (IsDirectory(path)) { - RS_LOGE("FileOpen: '%s' is the directory!", path.data()); // NOLINT - return nullptr; - } - - std::string realPath; - if (ShouldFileBeCreated(options) && !FileExists(path)) { - const auto directory = GetRealPath(GetDirectory(path)); - realPath = IsDirectory(directory) ? MakePath(directory, GetFileName(path)) : ""; - } else { - realPath = GetRealPath(path); - } - + const std::string realPath = GetRealPath(path); if (realPath.empty()) { RS_LOGE("FileOpen: '%s' is invalid!", path.data()); // NOLINT return nullptr; } + + if (ShouldFileBeCreated(options)) { + auto createdFile = open(realPath.data(), O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR); + close(createdFile); // will be opened and written into later + } + auto file = fopen(realPath.data(), options.data()); if (!IsFileValid(file)) { RS_LOGE("FileOpen: Cannot open '%s'!", realPath.data()); // NOLINT From 3feb9114ed1d97074b05ac3543c53103a6bb3229 Mon Sep 17 00:00:00 2001 From: ynikita Date: Mon, 24 Jun 2024 04:16:21 -0700 Subject: [PATCH 009/247] Fix code check Signed-off-by: ynikita --- .../opengl_wrapper/src/EGL/egl_system_layers_manager.cpp | 8 ++++---- .../opengl_wrapper/src/EGL/egl_system_layers_manager.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frameworks/opengl_wrapper/src/EGL/egl_system_layers_manager.cpp b/frameworks/opengl_wrapper/src/EGL/egl_system_layers_manager.cpp index 209f68b312..2476d79632 100644 --- a/frameworks/opengl_wrapper/src/EGL/egl_system_layers_manager.cpp +++ b/frameworks/opengl_wrapper/src/EGL/egl_system_layers_manager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * 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 @@ -31,7 +31,7 @@ namespace OHOS { namespace { -const std::string defaultJsonConfig = R"__( +const std::string DEFAULT_JSON_CONFIG = R"__( { "enableAppMode" : true, "appMode" : { @@ -93,8 +93,8 @@ bool EglSystemLayersManager::GetJsonConfig(Json::Value &configData) } const std::unique_ptr reader(charReader); JSONCPP_STRING errs; - bool ret = reader->parse(defaultJsonConfig.c_str(), - defaultJsonConfig.c_str() + static_cast(defaultJsonConfig.length()), &configData, &errs); + bool ret = reader->parse(DEFAULT_JSON_CONFIG.c_str(), + DEFAULT_JSON_CONFIG.c_str() + static_cast(DEFAULT_JSON_CONFIG.length()), &configData, &errs); if (!ret) { WLOGE("json parse error: %{private}s", errs.c_str()); return false; diff --git a/frameworks/opengl_wrapper/src/EGL/egl_system_layers_manager.h b/frameworks/opengl_wrapper/src/EGL/egl_system_layers_manager.h index 31e51173d6..ac9732a1b8 100644 --- a/frameworks/opengl_wrapper/src/EGL/egl_system_layers_manager.h +++ b/frameworks/opengl_wrapper/src/EGL/egl_system_layers_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * 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 From d680a2a40cc6bc49d87bb260c30cd3a74b222559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=A6=B9=E8=87=BB?= Date: Tue, 25 Jun 2024 09:31:31 +0800 Subject: [PATCH 010/247] Fix WaterRipple Bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王禹臻 --- .../include/ge_water_ripple_filter.h | 60 ++++++++++++++++++ .../src/ge_water_ripple_filter.cpp | 62 +------------------ .../render/rs_water_ripple_shader_filter.h | 12 ++-- .../src/property/rs_properties.cpp | 4 +- .../render/rs_water_ripple_shader_filter.cpp | 8 +-- 5 files changed, 76 insertions(+), 70 deletions(-) diff --git a/rosen/modules/graphics_effect/include/ge_water_ripple_filter.h b/rosen/modules/graphics_effect/include/ge_water_ripple_filter.h index dc9696a8d9..40b265f395 100644 --- a/rosen/modules/graphics_effect/include/ge_water_ripple_filter.h +++ b/rosen/modules/graphics_effect/include/ge_water_ripple_filter.h @@ -44,6 +44,66 @@ private: float waveCount_ = 2.0f; float rippleCenterX_ = 0.5f; float rippleCenterY_ = 0.7f; + inline static std::string shaderString = R"( + uniform shader image; + uniform half2 iResolution; + uniform half progress; + uniform half waveNum; + uniform half2 rippleCenter; + + const half basicSlope = 0.5; + const half gAmplSupress = 0.01; + const half waveFreq = 31.0; + const half wavePropRatio = 2.0; + const half ampSupArea = 0.5; + const half intensity = 0.15; + + half calcWave(half dis) + { + half preWave = (waveNum == 1.) ? 1. : smoothstep(0., -0.3, dis); + half waveForm = (waveNum == 1.) ? smoothstep(-0.4, -0.2, dis) * + smoothstep(0., -0.2, dis) : (waveNum == 2.) ? + smoothstep(-0.6, -0.3, dis) * preWave : smoothstep(-0.9, -0.6, dis) * + step(abs(dis + 0.45), 0.45) * preWave; + return sin(waveFreq * dis) * waveForm; + } + + half waveGenerator(half propDis, half t) + { + half dis = propDis - wavePropRatio * t; + half h = 1e-3; + half d1 = dis - h; + half d2 = dis + h; + return (calcWave(d2) - calcWave(d1)) / (2. * h); + } + + half4 main(vec2 fragCoord) + { + half shortEdge = min(iResolution.x, iResolution.y); + half2 uv = fragCoord.xy / iResolution.xy; + half2 uvHomo = fragCoord.xy / shortEdge; + half2 resRatio = iResolution.xy / shortEdge; + + half progSlope = basicSlope + 0.1 * waveNum; + half t = progSlope * progress; + half ampDecayByT = pow((1. - t), 9.); + + half2 waveCenter = rippleCenter * resRatio; + half propDis = distance(uvHomo, waveCenter); + half2 v = uvHomo - waveCenter; + + half ampSupByDis = smoothstep(0., ampSupArea, propDis); + half hIntense = waveGenerator(propDis, t) * ampDecayByT * ampSupByDis * gAmplSupress; + half2 circles = normalize(v) * hIntense; + + half3 norm = vec3(circles, hIntense); + half2 expandUV = (uv - intensity * norm.xy) * iResolution.xy; + half3 color = image.eval(expandUV).rgb; + color += 5. * clamp(dot(norm, normalize(vec3(0., -4., 0.5))), 0., 1.); + + return half4(color, 1.0); + } + )"; }; } // namespace Rosen diff --git a/rosen/modules/graphics_effect/src/ge_water_ripple_filter.cpp b/rosen/modules/graphics_effect/src/ge_water_ripple_filter.cpp index 66d3223b05..dc10d06e0c 100644 --- a/rosen/modules/graphics_effect/src/ge_water_ripple_filter.cpp +++ b/rosen/modules/graphics_effect/src/ge_water_ripple_filter.cpp @@ -84,68 +84,8 @@ std::shared_ptr GEWaterRippleFilter::ProcessImage(Drawing::Canva bool GEWaterRippleFilter::InitWaterRippleEffect() { - static std::string blurString(R"( - uniform shader image; - uniform half2 iResolution; - uniform half progress; - uniform half waveNum; - uniform half2 rippleCenter; - - const half basicSlope = 0.5; - const half gAmplSupress = 0.01; - const half waveFreq = 31.0; - const half wavePropRatio = 2.0; - const half ampSupArea = 0.5; - const half intensity = 0.15; - - half calcWave(half dis) - { - half preWave = (waveNum == 1.) ? 1. : smoothstep(0., -0.3, dis); - half waveForm = (waveNum == 1.) ? smoothstep(-0.4, -0.2, dis) * - smoothstep(0., -0.2, dis) : (waveNum == 2.) ? - smoothstep(-0.6, -0.3, dis) * preWave : smoothstep(-0.9, -0.6, dis) * - step(abs(dis + 0.45), 0.45) * preWave; - return sin(waveFreq * dis) * waveForm; - } - - half waveGenerator(half propDis, half t) - { - half dis = propDis - wavePropRatio * t; - half h = 1e-3; - half d1 = dis - h; - half d2 = dis + h; - return (calcWave(d2) - calcWave(d1)) / (2. * h); - } - - half4 main(vec2 fragCoord) - { - half shortEdge = min(iResolution.x, iResolution.y); - half2 uv = fragCoord.xy / iResolution.xy; - half2 uvHomo = fragCoord.xy / shortEdge; - half2 resRatio = iResolution.xy / shortEdge; - - half progSlope = basicSlope + 0.1 * waveNum; - half t = progSlope * progress; - half ampDecayByT = pow((1. - t), 9.); - - half2 waveCenter = rippleCenter * resRatio; - half propDis = distance(uvHomo, waveCenter); - half2 v = uvHomo - waveCenter; - - half ampSupByDis = smoothstep(0., ampSupArea, propDis); - half hIntense = waveGenerator(propDis, t) * ampDecayByT * ampSupByDis * gAmplSupress; - half2 circles = normalize(v) * hIntense; - - half3 norm = vec3(circles, hIntense); - half2 expandUV = (uv - intensity * norm.xy) * iResolution.xy; - half3 color = image.eval(expandUV).rgb; - color += 5. * clamp(dot(norm, normalize(vec3(0., -4., 0.5))), 0., 1.); - - return half4(color, 1.0); - } - )"); if (g_waterRippleEffect == nullptr) { - g_waterRippleEffect = Drawing::RuntimeEffect::CreateForShader(blurString); + g_waterRippleEffect = Drawing::RuntimeEffect::CreateForShader(shaderString); } return true; } diff --git a/rosen/modules/render_service_base/include/render/rs_water_ripple_shader_filter.h b/rosen/modules/render_service_base/include/render/rs_water_ripple_shader_filter.h index 813344efac..5286fe2b6b 100644 --- a/rosen/modules/render_service_base/include/render/rs_water_ripple_shader_filter.h +++ b/rosen/modules/render_service_base/include/render/rs_water_ripple_shader_filter.h @@ -32,10 +32,14 @@ public: void GenerateGEVisualEffect(std::shared_ptr visualEffectContainer) override; private: - inline static float progress_ = 0.0f; - inline static float waveCount_ = 0.0f; - inline static float rippleCenterX_ = 0.0f; - inline static float rippleCenterY_ = 0.0f; + static constexpr char RS_FILTER_WATER_RIPPLE_PROGRESS[] = "PROGRESS"; + static constexpr char RS_FILTER_WATER_RIPPLE_WAVE_NUM[] = "WAVE_NUM"; + static constexpr char RS_FILTER_WATER_RIPPLE_RIPPLE_CENTER_X[] = "RIPPLE_CENTER_X"; + static constexpr char RS_FILTER_WATER_RIPPLE_RIPPLE_CENTER_Y[] = "RIPPLE_CENTER_Y"; + float progress_ = 0.0f; + float waveCount_ = 0.0f; + float rippleCenterX_ = 0.0f; + float rippleCenterY_ = 0.0f; friend class RSMarshallingHelper; }; } // namespace Rosen diff --git a/rosen/modules/render_service_base/src/property/rs_properties.cpp b/rosen/modules/render_service_base/src/property/rs_properties.cpp index a2c7895d20..381bb6f293 100644 --- a/rosen/modules/render_service_base/src/property/rs_properties.cpp +++ b/rosen/modules/render_service_base/src/property/rs_properties.cpp @@ -1401,7 +1401,9 @@ std::optional RSProperties::GetWaterRippleParams() const bool RSProperties::IsWaterRippleValid() const { - return ROSEN_GE(waterRippleProgress_, 0.0f) && waterRippleParams_.has_value(); + return ROSEN_GE(waterRippleProgress_, 0.0f) && ROSEN_LE(waterRippleProgress_, 1.0f) && + waterRippleParams_.has_value() && ROSEN_GE(waterRippleParams_->waveCount, 1.0f) && + ROSEN_GE(waterRippleParams_->waveCount, 3.0f); } void RSProperties::SetFgBrightnessRates(const Vector4f& rates) diff --git a/rosen/modules/render_service_base/src/render/rs_water_ripple_shader_filter.cpp b/rosen/modules/render_service_base/src/render/rs_water_ripple_shader_filter.cpp index 53f5c8a805..ff0f38c8a7 100644 --- a/rosen/modules/render_service_base/src/render/rs_water_ripple_shader_filter.cpp +++ b/rosen/modules/render_service_base/src/render/rs_water_ripple_shader_filter.cpp @@ -65,10 +65,10 @@ void RSWaterRippleShaderFilter::GenerateGEVisualEffect( { auto waterRippleFilter = std::make_shared ("WATER_RIPPLE", Drawing::DrawingPaintType::BRUSH); - waterRippleFilter->SetParam("PROGRESS", progress_); - waterRippleFilter->SetParam("WAVE_NUM", waveCount_); - waterRippleFilter->SetParam("RIPPLE_CENTER_X", rippleCenterX_); - waterRippleFilter->SetParam("RIPPLE_CENTER_Y", rippleCenterY_); + waterRippleFilter->SetParam(RS_FILTER_WATER_RIPPLE_PROGRESS, progress_); + waterRippleFilter->SetParam(RS_FILTER_WATER_RIPPLE_WAVE_NUM, waveCount_); + waterRippleFilter->SetParam(RS_FILTER_WATER_RIPPLE_RIPPLE_CENTER_X, rippleCenterX_); + waterRippleFilter->SetParam(RS_FILTER_WATER_RIPPLE_RIPPLE_CENTER_Y, rippleCenterY_); visualEffectContainer->AddToChainedFilter(waterRippleFilter); } } // namespace Rosen From 7c0690b12740564515210aabca5ce18a2660dcdd Mon Sep 17 00:00:00 2001 From: zzvscx Date: Tue, 25 Jun 2024 10:54:15 +0800 Subject: [PATCH 011/247] =?UTF-8?q?=E5=8A=A8=E6=95=88=E9=80=9F=E5=BA=A6?= =?UTF-8?q?=E4=B8=BA0=E6=97=B6=E4=B8=8D=E5=8F=82=E4=B8=8E=E5=86=B3?= =?UTF-8?q?=E7=AD=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zzvscx Change-Id: Id21d41d56c37c3230403e1852371725f895a5bdd --- .../core/frame_rate_manager/hgm_frame_rate_manager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.cpp b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.cpp index ad3cdc783d..49343f684c 100644 --- a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.cpp +++ b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.cpp @@ -604,6 +604,9 @@ int32_t HgmFrameRateManager::GetPreferredFps(const std::string& type, float velo if (!configData) { return 0; } + if (ROSEN_EQ(velocity, 0.f)) { + return 0; + } const std::string settingMode = std::to_string(curRefreshRateMode_); if (configData->screenConfigs_.count(curScreenStrategyId_) && configData->screenConfigs_[curScreenStrategyId_].count(settingMode) && From 2bf2af12ef30d3abf51f9a714ca37cf94403a94c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=A6=B9=E8=87=BB?= Date: Tue, 25 Jun 2024 11:49:06 +0800 Subject: [PATCH 012/247] fix waterripple valid bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王禹臻 --- .../modules/render_service_base/src/property/rs_properties.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/modules/render_service_base/src/property/rs_properties.cpp b/rosen/modules/render_service_base/src/property/rs_properties.cpp index 381bb6f293..db28cc058b 100644 --- a/rosen/modules/render_service_base/src/property/rs_properties.cpp +++ b/rosen/modules/render_service_base/src/property/rs_properties.cpp @@ -1403,7 +1403,7 @@ bool RSProperties::IsWaterRippleValid() const { return ROSEN_GE(waterRippleProgress_, 0.0f) && ROSEN_LE(waterRippleProgress_, 1.0f) && waterRippleParams_.has_value() && ROSEN_GE(waterRippleParams_->waveCount, 1.0f) && - ROSEN_GE(waterRippleParams_->waveCount, 3.0f); + ROSEN_LE(waterRippleParams_->waveCount, 3.0f); } void RSProperties::SetFgBrightnessRates(const Vector4f& rates) From a79505d094bff32f51eabcea2cf1de781a7ccb33 Mon Sep 17 00:00:00 2001 From: Zhang Peng Date: Tue, 25 Jun 2024 11:19:40 +0800 Subject: [PATCH 013/247] fix crash Signed-off-by: Zhang Peng Change-Id: Id75d1b94844243d649ee6602295a41d9b6fb6a11 --- .../core/drawable/rs_effect_render_node_drawable.cpp | 6 +++++- .../render_service_base/include/pipeline/rs_context.h | 2 +- .../modules/render_service_base/src/pipeline/rs_context.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/rosen/modules/render_service/core/drawable/rs_effect_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_effect_render_node_drawable.cpp index 01e6a3d4a4..dfc4760d3c 100644 --- a/rosen/modules/render_service/core/drawable/rs_effect_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_effect_render_node_drawable.cpp @@ -65,7 +65,7 @@ void RSEffectRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) // case 3b: static blur without valid cache, draw background image and blur auto surface = canvas.GetSurface(); if (!surface) { - ROSEN_LOGE("RSPropertiesPainter::DrawBackgroundImageAsEffect surface null"); + ROSEN_LOGE("RSPropertiesPainter::DrawBackgroundImageAsEffect surface is null"); return; } // extract clip bounds @@ -73,6 +73,10 @@ void RSEffectRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) auto currentRect = canvas.GetDeviceClipBounds(); // create offscreen surface auto offscreenSurface = surface->MakeSurface(currentRect.GetWidth(), currentRect.GetHeight()); + if (!offscreenSurface) { + ROSEN_LOGE("RSPropertiesPainter::DrawBackgroundImageAsEffect offscreenSurface is null"); + return; + } auto offscreenCanvas = std::make_unique(offscreenSurface.get()); // copy current matrix to offscreen canvas, while aligned with current rect auto currentMatrix = canvas.GetTotalMatrix(); diff --git a/rosen/modules/render_service_base/include/pipeline/rs_context.h b/rosen/modules/render_service_base/include/pipeline/rs_context.h index 4eaae33358..005980e6f0 100644 --- a/rosen/modules/render_service_base/include/pipeline/rs_context.h +++ b/rosen/modules/render_service_base/include/pipeline/rs_context.h @@ -115,7 +115,7 @@ public: void AddActiveNode(const std::shared_ptr& node); bool HasActiveNode(const std::shared_ptr& node); - void AddPendingSyncNode(const std::shared_ptr& node); + void AddPendingSyncNode(const std::shared_ptr node); void MarkNeedPurge(ClearMemoryMoment moment, PurgeType purgeType); diff --git a/rosen/modules/render_service_base/src/pipeline/rs_context.cpp b/rosen/modules/render_service_base/src/pipeline/rs_context.cpp index 90461b44a6..a25264e37b 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_context.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_context.cpp @@ -53,7 +53,7 @@ bool RSContext::HasActiveNode(const std::shared_ptr& node) return activeNodesInRoot_[rootNodeId].count(node->GetId()) > 0; } -void RSContext::AddPendingSyncNode(const std::shared_ptr &node) +void RSContext::AddPendingSyncNode(const std::shared_ptr node) { if (node == nullptr || node->GetId() == INVALID_NODEID) { return; From a445a4ae19dec0e3454a485c6d23707afd8044ec Mon Sep 17 00:00:00 2001 From: zzvscx Date: Tue, 25 Jun 2024 14:17:32 +0800 Subject: [PATCH 014/247] =?UTF-8?q?rotation=E9=80=9F=E5=BA=A6=E8=BD=ACMM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zzvscx Change-Id: Ie8c93b313e27d01bd72a3e3df2cded7f0d3b9ab3 --- .../core/frame_rate_manager/hgm_frame_rate_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.cpp b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.cpp index 49343f684c..4dbe7b8869 100644 --- a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.cpp +++ b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.cpp @@ -592,7 +592,7 @@ int32_t HgmFrameRateManager::GetExpectedFrameRate(const RSPropertyUnit unit, flo case RSPropertyUnit::RATIO_SCALE: return GetPreferredFps("scale", PixelToMM(velocity)); case RSPropertyUnit::ANGLE_ROTATION: - return GetPreferredFps("rotation", velocity); + return GetPreferredFps("rotation", PixelToMM(velocity)); default: return 0; } From a7a9c41321f89dbaeded223484fbd2f83715fde0 Mon Sep 17 00:00:00 2001 From: Baranov Evgeny Date: Tue, 25 Jun 2024 11:44:15 +0300 Subject: [PATCH 015/247] set correct data for check Signed-off-by: Baranov Evgeny --- .../animation/rs_showing_properties_freezer_test.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/rosen/modules/render_service_client/test/unittest/animation/rs_showing_properties_freezer_test.cpp b/rosen/modules/render_service_client/test/unittest/animation/rs_showing_properties_freezer_test.cpp index e33a3e8178..b1d64be8c1 100644 --- a/rosen/modules/render_service_client/test/unittest/animation/rs_showing_properties_freezer_test.cpp +++ b/rosen/modules/render_service_client/test/unittest/animation/rs_showing_properties_freezer_test.cpp @@ -353,16 +353,15 @@ HWTEST_F(RSShowingPropertiesFreezerTest, GetBorderDashParamsTest, TestSize.Level EXPECT_TRUE(result1.has_value()); EXPECT_TRUE(result1.value()[0].GetRed() == SHOWING_COLOR_NUM); - Vector4f dashParamZero(0.f, 0.f, 0.f, 0.f); Vector4f dashParam(SHOWING_FLOAT_NUM, 0.f, 0.f, 0.f); - canvasNode->SetBorderDashWidth(dashParamZero); - canvasNode->SetBorderDashGap(dashParamZero); + canvasNode->SetBorderDashWidth(dashParam); + canvasNode->SetBorderDashGap(dashParam); auto dashWidth = canvasNode->GetShowingProperties().GetBorderDashWidth(); auto dashGap = canvasNode->GetShowingProperties().GetBorderDashGap(); EXPECT_TRUE(dashWidth.has_value()); - EXPECT_TRUE(dashWidth->IsNearEqual(dashParam)); + EXPECT_TRUE(dashWidth->x_ == SHOWING_FLOAT_NUM); EXPECT_TRUE(dashGap.has_value()); - EXPECT_TRUE(dashGap->IsNearEqual(dashParam)); + EXPECT_TRUE(dashGap->x_ == SHOWING_FLOAT_NUM); GTEST_LOG_(INFO) << "RSShowingPropertiesFreezerTest GetBorderDashParamsTest end"; } From d67c23eaa43dc1b37d4ee2c144f1a1dc5a1352af Mon Sep 17 00:00:00 2001 From: LYQ_YES Date: Tue, 25 Jun 2024 19:42:12 +0800 Subject: [PATCH 016/247] =?UTF-8?q?graph=E6=B7=BB=E5=8A=A0vcall=5Ficall?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LYQ_YES Change-Id: Iab206a3a574a085b703c4b4f61ed377454da18d5 --- interfaces/kits/cj/color_manager/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/interfaces/kits/cj/color_manager/BUILD.gn b/interfaces/kits/cj/color_manager/BUILD.gn index b028ab6f0c..7666f24698 100644 --- a/interfaces/kits/cj/color_manager/BUILD.gn +++ b/interfaces/kits/cj/color_manager/BUILD.gn @@ -25,6 +25,7 @@ ohos_shared_library("cj_color_manager_ffi") { sanitize = { cfi = true cfi_cross_dso = true + cfi_vcall_icall_only = true debug = false } From 342e7d9a3a0af3e595d5afbf1258b0a22ed9ac35 Mon Sep 17 00:00:00 2001 From: yjx Date: Fri, 21 Jun 2024 10:32:52 +0800 Subject: [PATCH 017/247] drawing unmarshalling icsl Signed-off-by: yjx Change-Id: Ic3222086cb5487cc7220d8ce92d784752c90c4f1 --- .../platform/ohos/rs_marshalling_helper.cpp | 62 ++++++++++++------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_marshalling_helper.cpp b/rosen/modules/render_service_base/src/platform/ohos/rs_marshalling_helper.cpp index d538ad86d3..7cd1bf457f 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_marshalling_helper.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_marshalling_helper.cpp @@ -103,6 +103,10 @@ MARSHALLING_AND_UNMARSHALLING(double, Double) namespace { bool MarshallingExtendObjectFromDrawCmdList(Parcel& parcel, const std::shared_ptr& val) { + if (!val) { + ROSEN_LOGE("unirender: RSMarshallingHelper::MarshallingExtendObjectFromDrawCmdList failed with null CmdList"); + return false; + } std::vector> objectVec; uint32_t objectSize = val->GetAllExtendObject(objectVec); if (!parcel.WriteUint32(objectSize)) { @@ -125,6 +129,10 @@ bool MarshallingExtendObjectFromDrawCmdList(Parcel& parcel, const std::shared_pt bool UnmarshallingExtendObjectToDrawCmdList(Parcel& parcel, std::shared_ptr& val) { + if (!val) { + ROSEN_LOGE("unirender: RSMarshallingHelper::UnmarshallingExtendObjectToDrawCmdList failed with null CmdList"); + return false; + } uint32_t objectSize = parcel.ReadUint32(); if (objectSize == 0) { return true; @@ -150,26 +158,37 @@ bool UnmarshallingExtendObjectToDrawCmdList(Parcel& parcel, std::shared_ptr val) { if (!val) { - return parcel.WriteInt32(-1); + return parcel.WriteUint32(UINT32_MAX); } - bool ret = parcel.WriteInt32(val->GetSize()); - if (val->GetSize() == 0) { + uint32_t size = val->GetSize(); + if (size == UINT32_MAX) { + ROSEN_LOGE("unirender: RSMarshallingHelper::Marshalling Data failed with max limit"); + return false; + } + + if (size == 0) { ROSEN_LOGW("unirender: RSMarshallingHelper::Marshalling Data size is 0"); - return ret; + return parcel.WriteUint32(0); } - ret = ret && RSMarshallingHelper::WriteToParcel(parcel, val->GetData(), val->GetSize()); - if (!ret) { - ROSEN_LOGE("unirender: failed RSMarshallingHelper::Marshalling Data"); + const void* data = val->GetData(); + if (!data) { + ROSEN_LOGE("unirender: RSMarshallingHelper::Marshalling Data failed with max nullptr"); + return false; } - return ret; + + if (!parcel.WriteUint32(size) || !RSMarshallingHelper::WriteToParcel(parcel, data, size)) { + ROSEN_LOGE("unirender: failed RSMarshallingHelper::Marshalling Data"); + return false; + } + return true; } bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, std::shared_ptr& val) { - int32_t size = parcel.ReadInt32(); - if (size == -1) { + uint32_t size = parcel.ReadUint32(); + if (size == UINT32_MAX) { val = nullptr; return true; } @@ -183,16 +202,20 @@ bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, std::shared_ptrBuildWithoutCopy(data, size); + ret = val->BuildWithoutCopy(data, size); } else { - val->BuildFromMalloc(data, size); + ret = val->BuildFromMalloc(data, size); } - return true; + if (!ret) { + ROSEN_LOGE("unirender: failed RSMarshallingHelper::Unmarshalling Data failed with Build Data"); + } + return ret; } bool RSMarshallingHelper::SkipData(Parcel& parcel) @@ -207,10 +230,8 @@ bool RSMarshallingHelper::SkipData(Parcel& parcel) bool RSMarshallingHelper::UnmarshallingWithCopy(Parcel& parcel, std::shared_ptr& val) { bool success = Unmarshalling(parcel, val); - if (success) { - if (val && val->GetSize() < MIN_DATA_SIZE) { - val->BuildWithCopy(val->GetData(), val->GetSize()); - } + if (success && val && val->GetSize() < MIN_DATA_SIZE) { + val->BuildWithCopy(val->GetData(), val->GetSize()); } return success; } @@ -222,13 +243,11 @@ bool RSMarshallingHelper::Marshalling(Parcel& parcel, const Drawing::Bitmap& val Marshalling(parcel, bitmapFormat); std::shared_ptr data = val.Serialize(); - if (!data) { ROSEN_LOGD("unirender: RSMarshallingHelper::Marshalling Bitmap is nullptr"); return false; } Marshalling(parcel, data); - return true; } @@ -290,7 +309,6 @@ bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, std::shared_ptr(height); + size_t size = bitmap.ComputeByteSize(); parcel.WriteUint32(size); if (!WriteToParcel(parcel, addr, size)) { From 8d960e322933fd73506e1c42451884e0aedfa21e Mon Sep 17 00:00:00 2001 From: Korobkov Dmitry Date: Mon, 24 Jun 2024 14:28:39 +0300 Subject: [PATCH 018/247] Apply comments, remove unused macros and cast variables Signed-off-by: Korobkov Dmitry --- rosen/modules/render_service_profiler/rs_profiler.cpp | 2 +- rosen/modules/render_service_profiler/rs_profiler.h | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/rosen/modules/render_service_profiler/rs_profiler.cpp b/rosen/modules/render_service_profiler/rs_profiler.cpp index 784d53027e..ce0fcb1a08 100644 --- a/rosen/modules/render_service_profiler/rs_profiler.cpp +++ b/rosen/modules/render_service_profiler/rs_profiler.cpp @@ -369,7 +369,7 @@ void RSProfiler::OnParallelRenderEnd(uint32_t frameNumber) const uint64_t frameLengthNanosecs = RawNowNano() - g_frameRenderBeginTimestamp; - const double currentTime = g_frameRenderBeginTimestamp * 1e-9; // Now(); + const double currentTime = static_cast(g_frameRenderBeginTimestamp) * 1e-9; const double timeSinceRecordStart = currentTime - g_recordStartTime; if (timeSinceRecordStart > 0.0) { diff --git a/rosen/modules/render_service_profiler/rs_profiler.h b/rosen/modules/render_service_profiler/rs_profiler.h index 998f9d6975..80fbdb00f1 100644 --- a/rosen/modules/render_service_profiler/rs_profiler.h +++ b/rosen/modules/render_service_profiler/rs_profiler.h @@ -48,7 +48,6 @@ #define RS_PROFILER_SET_DIRTY_REGION(dirtyRegion) RSProfiler::SetDirtyRegion(dirtyRegion) #define RS_PROFILER_WRITE_PARCEL_DATA(parcel) RSProfiler::WriteParcelData(parcel) #define RS_PROFILER_READ_PARCEL_DATA(parcel, size, isMalloc) RSProfiler::ReadParcelData(parcel, size, isMalloc) -#define RS_PROFILER_UPDATE_HWC_NODE_CHECK() RSProfiler::UpdateHwcNodeCheck() #define RS_PROFILER_GET_FRAME_NUMBER() RSProfiler::GetFrameNumber() #define RS_PROFILER_ON_PARALLEL_RENDER_BEGIN() RSProfiler::OnParallelRenderBegin() #define RS_PROFILER_ON_PARALLEL_RENDER_END(renderFrameNumber) RSProfiler::OnParallelRenderEnd(renderFrameNumber) @@ -75,7 +74,6 @@ #define RS_PROFILER_SET_DIRTY_REGION(dirtyRegion) #define RS_PROFILER_WRITE_PARCEL_DATA(parcel) #define RS_PROFILER_READ_PARCEL_DATA(parcel, size, isMalloc) RSMarshallingHelper::ReadFromAshmem(parcel, size, isMalloc) -#define RS_PROFILER_UPDATE_HWC_NODE_CHECK() true #define RS_PROFILER_GET_FRAME_NUMBER() 0 #define RS_PROFILER_ON_PARALLEL_RENDER_BEGIN() #define RS_PROFILER_ON_PARALLEL_RENDER_END(renderFrameNumber) @@ -174,8 +172,6 @@ public: RSB_EXPORT static bool IsBetaRecordEnabled(); RSB_EXPORT static bool IsBetaRecordEnabledWithMetrics(); - RSB_EXPORT static bool UpdateHwcNodeCheck(); - private: static const char* GetProcessNameByPid(int pid); From 4e7417b9ac756f662d20106d7f22f4014c6facce Mon Sep 17 00:00:00 2001 From: balingbaling Date: Tue, 25 Jun 2024 20:20:53 +0800 Subject: [PATCH 019/247] skip Signed-off-by: balingbaling Change-Id: Ib31cb4261d57573c01ba0184c45b2c20f1776142 --- .../core/pipeline/rs_uni_render_visitor.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp index 9952e0e05b..4870ede20d 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp @@ -1700,12 +1700,8 @@ bool RSUniRenderVisitor::BeforeUpdateSurfaceDirtyCalc(RSSurfaceRenderNode& node) if (node.GetName().find(CAPTURE_WINDOW_NAME) != std::string::npos) { hasCaptureWindow_[currentVisitDisplay_] = true; } - // only need collect first level node's security & skip layer info - // and update it's uifirst gravity - if (node.GetId() == node.GetFirstLevelNodeId()) { - UpdateSecuritySkipAndProtectedLayersRecord(node); - node.UpdateUIFirstFrameGravity(); - } + UpdateSecuritySkipAndProtectedLayersRecord(node); + node.UpdateUIFirstFrameGravity(); if (node.IsMainWindowType() || node.IsLeashWindow()) { // UpdateCurCornerRadius must process before curSurfaceNode_ update node.UpdateCurCornerRadius(curCornerRadius_, curSurfaceNode_ != nullptr); From ed5f78b8560ef087ae084402c1722b71382a57ea Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 11 Jun 2024 15:11:45 +0800 Subject: [PATCH 020/247] reset clearMemoryTask when direct Composition Signed-off-by: jason Change-Id: I5d047a17077af713c2dfca3eb18109fc4b585fc3 --- .../rs_display_render_node_drawable.cpp | 22 ------------------- .../core/pipeline/rs_main_thread.cpp | 1 + .../core/pipeline/rs_uni_render_thread.cpp | 11 ++++++++++ .../core/pipeline/rs_uni_render_thread.h | 1 + 4 files changed, 13 insertions(+), 22 deletions(-) diff --git a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp index dff0d743ea..c5bd309a23 100644 --- a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp @@ -381,24 +381,6 @@ void RSDisplayRenderNodeDrawable::CreateUIFirstLayer(std::shared_ptr rootNode) RS_OPTIONAL_TRACE_NAME_FMT("rs debug: %s HardwareForcedDisabled is true", __func__); } bool needTraverseNodeTree = true; + RSUniRenderThread::Instance().PostTask([] { RSUniRenderThread::Instance().ResetClearMemoryTask(); }); if (doDirectComposition_ && !isDirty_ && !isAccessibilityConfigChanged_ && !isCachedSurfaceUpdated_) { if (isHardwareEnabledBufferUpdated_) { diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_thread.cpp b/rosen/modules/render_service/core/pipeline/rs_uni_render_thread.cpp index edec8e5627..8a63494719 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_thread.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_thread.cpp @@ -420,6 +420,7 @@ void RSUniRenderThread::NotifyDisplayNodeBufferReleased() bool RSUniRenderThread::GetClearMemoryFinished() const { + std::lock_guard lock(clearMemoryMutex_); return clearMemoryFinished_; } @@ -591,6 +592,16 @@ void RSUniRenderThread::PostClearMemoryTask(ClearMemoryMoment moment, bool deepl } } +void RSUniRenderThread::ResetClearMemoryTask() +{ + if (!GetClearMemoryFinished()) { + RemoveTask(CLEAR_GPU_CACHE); + ClearMemoryCache(clearMoment_, clearMemDeeply_); + } + RemoveTask(DEFAULT_CLEAR_GPU_CACHE); + DefaultClearMemoryCache(); +} + void RSUniRenderThread::PurgeCacheBetweenFrames() { if (!RSSystemProperties::GetReleaseResourceEnabled()) { diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_thread.h b/rosen/modules/render_service/core/pipeline/rs_uni_render_thread.h index 2945fad5f0..0ceef503b8 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_thread.h +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_thread.h @@ -72,6 +72,7 @@ public: void PostClearMemoryTask(ClearMemoryMoment moment, bool deeply, bool isDefaultClean); void MemoryManagementBetweenFrames(); void PreAllocateTextureBetweenFrames(); + void ResetClearMemoryTask(); bool GetClearMemoryFinished() const; bool GetClearMemDeeply() const; void SetClearMoment(ClearMemoryMoment moment); From 29893ebbb8d3771bf5fc2cc4b3607ba521eac5d7 Mon Sep 17 00:00:00 2001 From: tttaaaooo Date: Mon, 24 Jun 2024 21:10:28 +0800 Subject: [PATCH 021/247] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=A4=E4=BA=92?= =?UTF-8?q?=E4=BC=98=E5=85=88=E9=A6=96=E5=B8=A7=E7=AD=89=E5=BE=85=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tttaaaooo --- .../rs_canvas_render_node_drawable.cpp | 5 ++ .../rs_surface_render_node_drawable.cpp | 14 ++-- .../rs_surface_render_node_drawable.h | 1 + ..._ui_first_surface_render_node_drawable.cpp | 27 +++++++ .../core/pipeline/rs_uifirst_manager.cpp | 73 +++++++++++++++++++ .../core/pipeline/rs_uifirst_manager.h | 2 + .../include/params/rs_render_params.h | 15 ++++ .../include/params/rs_surface_render_params.h | 15 ++++ .../include/pipeline/rs_render_node.h | 6 ++ .../include/pipeline/rs_surface_render_node.h | 1 + .../src/params/rs_render_params.cpp | 1 + .../src/params/rs_surface_render_params.cpp | 1 + .../src/pipeline/rs_render_node.cpp | 22 +++++- .../src/pipeline/rs_surface_render_node.cpp | 9 +++ 14 files changed, 186 insertions(+), 6 deletions(-) diff --git a/rosen/modules/render_service/core/drawable/rs_canvas_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_canvas_render_node_drawable.cpp index 0d72a2ea4b..4520f4b4af 100644 --- a/rosen/modules/render_service/core/drawable/rs_canvas_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_canvas_render_node_drawable.cpp @@ -49,6 +49,11 @@ void RSCanvasRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) } auto paintFilterCanvas = static_cast(&canvas); + if (params && params->GetStartingWindowFlag()) { // do not draw startingwindows in sudthread + if (paintFilterCanvas->GetIsParallelCanvas()) { + return; + } + } RSAutoCanvasRestore acr(paintFilterCanvas, RSPaintFilterCanvas::SaveType::kCanvasAndAlpha); params->ApplyAlphaAndMatrixToCanvas(*paintFilterCanvas); auto uniParam = RSUniRenderThread::Instance().GetRSRenderThreadParams().get(); diff --git a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp index 36467f9f59..33a5ba5a30 100644 --- a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp @@ -709,11 +709,15 @@ bool RSSurfaceRenderNodeDrawable::DealWithUIFirstCache(RSSurfaceRenderNode& surf if (!useDmaBuffer) { DrawBackground(canvas, bounds); } - bool canSkipFirstWait = (enableType == MultiThreadCacheType::ARKTS_CARD) && - (RSUifirstManager::Instance().GetCurrentFrameSkipFirstWait()); - - bool drawCacheSuccess = useDmaBuffer ? - DrawUIFirstCacheWithDma(canvas, surfaceParams) : DrawUIFirstCache(canvas, canSkipFirstWait); + bool drawCacheSuccess = true; + if (surfaceParams.GetUifirstUseStarting() != INVALID_NODEID) { + drawCacheSuccess = DrawUIFirstCacheWithStarting(canvas, surfaceParams.GetUifirstUseStarting()); + } else { + bool canSkipFirstWait = (enableType == MultiThreadCacheType::ARKTS_CARD) && + (RSUifirstManager::Instance().GetCurrentFrameSkipFirstWait()); + drawCacheSuccess = useDmaBuffer ? + DrawUIFirstCacheWithDma(canvas, surfaceParams) : DrawUIFirstCache(canvas, canSkipFirstWait); + } if (!drawCacheSuccess) { RS_TRACE_NAME_FMT("[%s] reuse failed!", name_.c_str()); RS_LOGE("DrawUIFirstCache failed!"); diff --git a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.h b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.h index feb0697d4d..049b1c64fe 100644 --- a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.h +++ b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.h @@ -233,6 +233,7 @@ private: std::string name_; bool DrawUIFirstCache(RSPaintFilterCanvas& rscanvas, bool canSkipWait); + bool DrawUIFirstCacheWithStarting(RSPaintFilterCanvas& rscanvas, NodeId id); bool CheckIfNeedResetRotate(RSPaintFilterCanvas& canvas); NodeId FindInstanceChildOfDisplay(std::shared_ptr node); #ifdef USE_VIDEO_PROCESSING_ENGINE diff --git a/rosen/modules/render_service/core/drawable/rs_ui_first_surface_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_ui_first_surface_render_node_drawable.cpp index 88db000845..876ca06199 100644 --- a/rosen/modules/render_service/core/drawable/rs_ui_first_surface_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_ui_first_surface_render_node_drawable.cpp @@ -548,6 +548,7 @@ void RSSurfaceRenderNodeDrawable::SubDraw(Drawing::Canvas& canvas) bool RSSurfaceRenderNodeDrawable::DrawUIFirstCache(RSPaintFilterCanvas& rscanvas, bool canSkipWait) { + RS_TRACE_NAME_FMT("DrawUIFirstCache_NOSTARTING"); const auto& params = GetRenderParams(); if (!params) { RS_LOGE("RSUniRenderUtil::HandleSubThreadNodeDrawable params is nullptr"); @@ -578,4 +579,30 @@ bool RSSurfaceRenderNodeDrawable::DrawUIFirstCache(RSPaintFilterCanvas& rscanvas } return DrawCacheSurface(rscanvas, params->GetCacheSize(), UNI_MAIN_THREAD_INDEX, true); } + +bool RSSurfaceRenderNodeDrawable::DrawUIFirstCacheWithStarting(RSPaintFilterCanvas& rscanvas, NodeId id) +{ + RS_TRACE_NAME_FMT("DrawUIFirstCacheWithStarting %d, nodeID:%lld", HasCachedTexture(), id); + const auto& params = GetRenderParams(); + if (!params) { + RS_LOGE("RSUniRenderUtil::HandleSubThreadNodeDrawable params is nullptr"); + return false; + } + auto drawable = RSRenderNodeDrawableAdapter::GetDrawableById(id); + if (!drawable) { + return false; + } + + bool ret = true; + // draw surface content&&childrensss + if (HasCachedTexture()) { + ret = DrawCacheSurface(rscanvas, params->GetCacheSize(), UNI_MAIN_THREAD_INDEX, true); + } + // draw starting window + { + RS_TRACE_NAME_FMT("drawStarting"); + drawable->Draw(rscanvas); + } + return ret; +} } // namespace OHOS::Rosen diff --git a/rosen/modules/render_service/core/pipeline/rs_uifirst_manager.cpp b/rosen/modules/render_service/core/pipeline/rs_uifirst_manager.cpp index 590ef60b4d..0101323f7e 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uifirst_manager.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uifirst_manager.cpp @@ -21,6 +21,7 @@ #include "params/rs_display_render_params.h" #include "platform/common/rs_log.h" #include "pipeline/parallel_render/rs_sub_thread_manager.h" +#include "pipeline/rs_canvas_render_node.h" #include "pipeline/rs_uni_render_util.h" #include "pipeline/rs_main_thread.h" @@ -96,6 +97,9 @@ void RSUifirstManager::AddProcessDoneNode(NodeId id) void RSUifirstManager::ResetUifirstNode(std::shared_ptr& nodePtr) { + if (nodePtr) { + nodePtr->SetUifirstUseStarting(false); + } SetUifirstNodeEnableParam(*nodePtr, MultiThreadCacheType::NONE); RSMainThread::Instance()->GetContext().AddPendingSyncNode(nodePtr); DrawableV2::RSSurfaceRenderNodeDrawable* drawable = GetSurfaceDrawableByID(nodePtr->GetId()); @@ -188,6 +192,33 @@ void RSUifirstManager::ProcessForceUpdateNode() } pendingForceUpdateNode_.clear(); } + +void RSUifirstManager::NotifyUIStartingWindow(NodeId id, bool hasCachedTexture) +{ + auto node = RSBaseRenderNode::ReinterpretCast( + mainThread_->GetContext().GetNodeMap().GetRenderNode(id)); + if (node != nullptr && !hasCachedTexture && node->IsLeashWindow()) { + bool uifirstFirstFrameComplete = false; + for (auto& child : *node->GetChildren()) { + if (!child) { + continue; + } + auto surfaceChild = child->ReinterpretCastTo(); + if (!surfaceChild) { + continue; + } + surfaceChild->SetIsNotifyUIBufferAvailable(false); + uifirstFirstFrameComplete = true; + RS_TRACE_NAME_FMT("NotifyUIBufferAvailable by uifirst %lld", surfaceChild->GetId()); + RS_LOGD("uifirst NotifyUIBufferAvailable by uifirst"); + break; + } + if (uifirstFirstFrameComplete) { + node->SetUifirstUseStarting(false); + } + } +} + void RSUifirstManager::ProcessDoneNodeInner() { std::vector tmp; @@ -205,6 +236,7 @@ void RSUifirstManager::ProcessDoneNodeInner() DrawableV2::RSSurfaceRenderNodeDrawable* drawable = GetSurfaceDrawableByID(id); if (drawable && drawable->GetCacheSurfaceNeedUpdated() && drawable->GetCacheSurface(UNI_MAIN_THREAD_INDEX, false)) { + NotifyUIStartingWindow(id, drawable->HasCachedTexture()); drawable->UpdateCompletedCacheSurface(); RenderGroupUpdate(drawable); SetHasDoneNodeFlag(true); @@ -712,6 +744,44 @@ void RSUifirstManager::AddPendingPostNode(NodeId id, std::shared_ptr startingWindow = nullptr; + for (auto& child : *(node.GetSortedChildren())) { + if (!child) { + continue; + } + RS_TRACE_NAME_FMT("nodeType:%d, support:%d, canvasNodeNum:%d, mainwindowNum:%d, startingWindow:%d", + static_cast(child->GetType()), support, canvasNodeNum, mainwindowNum, startingWindow != nullptr); + auto canvasChild = child->ReinterpretCastTo(); + if (canvasChild && canvasChild->GetChildrenCount() == 0 && mainwindowNum > 0) { + canvasNodeNum++; + startingWindow = canvasChild; + continue; + } + auto surfaceChild = child->ReinterpretCastTo(); + if (surfaceChild && surfaceChild->IsMainWindowType() && canvasNodeNum == 0) { + mainwindowNum++; + continue; + } + support = false; + } + RS_TRACE_NAME_FMT("uifirst_node support:%d, canvasNodeNum:%d, mainwindowNum:%d, startingWindow:%d", + support, canvasNodeNum, mainwindowNum, startingWindow != nullptr); + if (support && canvasNodeNum == 1 && mainwindowNum > 0 && startingWindow) { // starting window & appwindow + startingWindow->SetStartingWindowFlag(true); + return startingWindow->GetId(); + } else { + return INVALID_NODEID; + } +} + void RSUifirstManager::AddPendingResetNode(NodeId id, std::shared_ptr& node) { if (id == INVALID_NODEID) { @@ -1052,6 +1122,9 @@ void RSUifirstManager::UifirstStateChange(RSSurfaceRenderNode& node, MultiThread if (currentFrameCacheType == MultiThreadCacheType::ARKTS_CARD) { // now only update ArkTSCardNode node.UpdateTreeUifirstRootNodeId(node.GetId()); } + if (currentFrameCacheType == MultiThreadCacheType::LEASH_WINDOW) { + node.SetUifirstUseStarting(LeashWindowContainMainWindowAndStarting(*surfaceNode)); + } auto func = std::bind(&RSUifirstManager::ProcessTreeStateChange, std::placeholders::_1); node.RegisterTreeStateChangeCallback(func); node.SetUifirstStartTime(GetCurSysTime()); diff --git a/rosen/modules/render_service/core/pipeline/rs_uifirst_manager.h b/rosen/modules/render_service/core/pipeline/rs_uifirst_manager.h index e35d044a42..7df32a47fc 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uifirst_manager.h +++ b/rosen/modules/render_service/core/pipeline/rs_uifirst_manager.h @@ -171,6 +171,8 @@ private: static bool IsNonFocusWindowCache(RSSurfaceRenderNode& node, bool animation); void UifirstStateChange(RSSurfaceRenderNode& node, MultiThreadCacheType currentFrameCacheType); + NodeId LeashWindowContainMainWindowAndStarting(RSSurfaceRenderNode& node); + void NotifyUIStartingWindow(NodeId id, bool hasCachedTexture); void UpdateChildrenDirtyRect(RSSurfaceRenderNode& node); bool EventsCanSkipFirstWait(std::vector& events); bool IsCardSkipFirstWaitScene(std::string& scene, int32_t appPid); diff --git a/rosen/modules/render_service_base/include/params/rs_render_params.h b/rosen/modules/render_service_base/include/params/rs_render_params.h index 6401f49ff4..c354040833 100644 --- a/rosen/modules/render_service_base/include/params/rs_render_params.h +++ b/rosen/modules/render_service_base/include/params/rs_render_params.h @@ -156,6 +156,20 @@ public: SurfaceParam GetCanvasDrawingSurfaceParams(); void SetCanvasDrawingSurfaceParams(int width, int height); + void SetStartingWindowFlag(bool b) + { + if (startingWindowFlag_ == b) { + return; + } + startingWindowFlag_ = b; + needSync_ = true; + } + + bool GetStartingWindowFlag() const + { + return startingWindowFlag_; + } + // disable copy and move RSRenderParams(const RSRenderParams&) = delete; RSRenderParams(RSRenderParams&&) = delete; @@ -203,6 +217,7 @@ private: bool isOpincRootFlag_ = false; bool isOpincStateChanged_ = false; bool isOpincMarkCached_ = false; + bool startingWindowFlag_ = false; bool needFilter_ = false; SurfaceParam surfaceParams_; bool freezeFlag_ = false; diff --git a/rosen/modules/render_service_base/include/params/rs_surface_render_params.h b/rosen/modules/render_service_base/include/params/rs_surface_render_params.h index 93d61e3468..f9094b440a 100644 --- a/rosen/modules/render_service_base/include/params/rs_surface_render_params.h +++ b/rosen/modules/render_service_base/include/params/rs_surface_render_params.h @@ -199,6 +199,20 @@ public: needSync_ = true; } + void SetUifirstUseStarting(NodeId id) + { + if (uifirstUseStarting_ == id) { + return; + } + uifirstUseStarting_ = id; + needSync_ = true; + } + + NodeId GetUifirstUseStarting() const + { + return uifirstUseStarting_; + } + void SetUifirstChildrenDirtyRectParam(const RectI& rect) { childrenDirtyRect_ = rect; @@ -351,6 +365,7 @@ private: RectI childrenDirtyRect_; RectI absDrawRect_; RRect rrect_; + NodeId uifirstUseStarting_ = INVALID_NODEID; Occlusion::Region transparentRegion_; Occlusion::Region opaqueRegion_; diff --git a/rosen/modules/render_service_base/include/pipeline/rs_render_node.h b/rosen/modules/render_service_base/include/pipeline/rs_render_node.h index 5fdd232e45..ee8980d353 100644 --- a/rosen/modules/render_service_base/include/pipeline/rs_render_node.h +++ b/rosen/modules/render_service_base/include/pipeline/rs_render_node.h @@ -697,6 +697,11 @@ public: void SetChildrenHasSharedTransition(bool hasSharedTransition); virtual bool SkipFrame(uint32_t skipFrameInterval) { return false; } void RemoveChildFromFulllist(NodeId nodeId); + void SetStartingWindowFlag(bool startingFlag); + bool GetStartingWindowFlag() const + { + return startingWindowFlag_; + } protected: virtual void OnApplyModifiers() {} @@ -766,6 +771,7 @@ protected: bool childHasSharedTransition_ = false; bool lastFrameSynced_ = true; bool clipAbsDrawRectChange_ = false; + bool startingWindowFlag_ = false; bool isUifirstNode_ = true; std::shared_ptr GetFilterDrawable(bool isForeground) const; diff --git a/rosen/modules/render_service_base/include/pipeline/rs_surface_render_node.h b/rosen/modules/render_service_base/include/pipeline/rs_surface_render_node.h index 7dabad9e25..474cdc21fa 100644 --- a/rosen/modules/render_service_base/include/pipeline/rs_surface_render_node.h +++ b/rosen/modules/render_service_base/include/pipeline/rs_surface_render_node.h @@ -458,6 +458,7 @@ public: { return UIFirstIsPurge_; } + void SetUifirstUseStarting(NodeId id); // only cache app window, first frame not wait void SetForceUIFirstChanged(bool forceUIFirstChanged); bool GetForceUIFirstChanged(); diff --git a/rosen/modules/render_service_base/src/params/rs_render_params.cpp b/rosen/modules/render_service_base/src/params/rs_render_params.cpp index ee949a067f..0d64570510 100644 --- a/rosen/modules/render_service_base/src/params/rs_render_params.cpp +++ b/rosen/modules/render_service_base/src/params/rs_render_params.cpp @@ -442,6 +442,7 @@ void RSRenderParams::OnSync(const std::unique_ptr& target) OnCanvasDrawingSurfaceChange(target); target->isOpincRootFlag_ = isOpincRootFlag_; target->isOpincStateChanged_ = OpincGetCacheChangeState(); + target->startingWindowFlag_ = startingWindowFlag_; target->freezeFlag_ = freezeFlag_; needSync_ = false; } diff --git a/rosen/modules/render_service_base/src/params/rs_surface_render_params.cpp b/rosen/modules/render_service_base/src/params/rs_surface_render_params.cpp index d7a641b767..74d7c7f2ae 100644 --- a/rosen/modules/render_service_base/src/params/rs_surface_render_params.cpp +++ b/rosen/modules/render_service_base/src/params/rs_surface_render_params.cpp @@ -341,6 +341,7 @@ void RSSurfaceRenderParams::OnSync(const std::unique_ptr& target targetSurfaceParams->isForceHardwareByUser_ = isForceHardwareByUser_; targetSurfaceParams->uiFirstFlag_ = uiFirstFlag_; targetSurfaceParams->uiFirstParentFlag_ = uiFirstParentFlag_; + targetSurfaceParams->uifirstUseStarting_ = uifirstUseStarting_; targetSurfaceParams->childrenDirtyRect_ = childrenDirtyRect_; targetSurfaceParams->isOccludedByFilterCache_ = isOccludedByFilterCache_; targetSurfaceParams->isSecurityLayer_ = isSecurityLayer_; diff --git a/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp b/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp index 2b9297c37d..508e99197c 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp @@ -722,6 +722,7 @@ void RSRenderNode::DumpSubClassNode(std::string& out) const out += ", OcclusionBg: " + std::to_string(surfaceNode->GetAbilityBgAlpha()); out += ", SecurityLayer: " + std::to_string(surfaceNode->GetSecurityLayer()); out += ", skipLayer: " + std::to_string(surfaceNode->GetSkipLayer()); + out += ", surfaceType: " + std::to_string((int)surfaceNode->GetSurfaceNodeType()); } else if (GetType() == RSRenderNodeType::ROOT_NODE) { auto rootNode = static_cast(this); out += ", Visible: " + std::to_string(rootNode->GetRenderProperties().GetVisible()); @@ -975,7 +976,7 @@ void RSRenderNode::UpdateDrawingCacheInfoBeforeChildren(bool isScreenRotation) void RSRenderNode::UpdateDrawingCacheInfoAfterChildren() { - if (IsUifirstArkTsCardNode()) { + if (IsUifirstArkTsCardNode() || startingWindowFlag_) { SetDrawingCacheType(RSDrawingCacheType::DISABLED_CACHE); } if (HasChildrenOutOfRect() && GetDrawingCacheType() == RSDrawingCacheType::TARGETED_CACHE) { @@ -3137,6 +3138,9 @@ void RSRenderNode::UpdateFullScreenFilterCacheRect( void RSRenderNode::OnTreeStateChanged() { + if (!isOnTheTree_) { + startingWindowFlag_ = false; + } if (isOnTheTree_) { // Set dirty and force add to active node list, re-generate children list if needed SetDirty(true); @@ -3934,6 +3938,22 @@ void RSRenderNode::AddToPendingSyncList() } } +void RSRenderNode::SetStartingWindowFlag(bool startingFlag) +{ + if (startingFlag) { + UpdateDrawingCacheInfoAfterChildren(); + } + if (startingWindowFlag_ == startingFlag) { + return; + } + startingWindowFlag_ = startingFlag; + auto stagingParams = stagingRenderParams_.get(); + if (stagingParams) { + stagingParams->SetStartingWindowFlag(startingFlag); + AddToPendingSyncList(); + } +} + void RSRenderNode::MarkUifirstNode(bool isUifirstNode) { RS_OPTIONAL_TRACE_NAME_FMT("MarkUifirstNode id:%lld, isUifirstNode:%d", GetId(), isUifirstNode); diff --git a/rosen/modules/render_service_base/src/pipeline/rs_surface_render_node.cpp b/rosen/modules/render_service_base/src/pipeline/rs_surface_render_node.cpp index e7aa208c43..5fc6b1c315 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_surface_render_node.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_surface_render_node.cpp @@ -2663,6 +2663,15 @@ void RSSurfaceRenderNode::SetIsParentUifirstNodeEnableParam(bool b) } } +void RSSurfaceRenderNode::SetUifirstUseStarting(NodeId id) +{ + auto stagingSurfaceParams = static_cast(stagingRenderParams_.get()); + if (stagingSurfaceParams) { + stagingSurfaceParams->SetUifirstUseStarting(id); + AddToPendingSyncList(); + } +} + void RSSurfaceRenderNode::SetSkipDraw(bool skip) { isSkipDraw_ = skip; From 555a9cfcc6d539122a01f5127b40c8a012fb52ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=81=E5=9D=97?= Date: Wed, 26 Jun 2024 10:42:26 +0800 Subject: [PATCH 022/247] =?UTF-8?q?=E8=93=9D=E9=BB=84=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李铁块 --- interfaces/kits/napi/graphic/effect_kit/src/filter_napi.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/interfaces/kits/napi/graphic/effect_kit/src/filter_napi.cpp b/interfaces/kits/napi/graphic/effect_kit/src/filter_napi.cpp index 7a11e144f3..87f7393b2a 100644 --- a/interfaces/kits/napi/graphic/effect_kit/src/filter_napi.cpp +++ b/interfaces/kits/napi/graphic/effect_kit/src/filter_napi.cpp @@ -53,7 +53,7 @@ struct FilterAsyncContext { // param FilterNapi* filterNapi = nullptr; - bool forceCPU = false; + bool forceCPU = true; std::shared_ptr dstPixelMap_; }; @@ -385,7 +385,6 @@ napi_value FilterNapi::GetPixelMapAsync(napi_env env, napi_callback_info info) EFFECT_LOG_I("FilterNapi: GetPixelMapAsync parse forceCPU failed"); } } - ctx->forceCPU = false; if (argc >= NUM_1) { if (Media::ImageNapiUtils::getType(env, argv[argc - 1]) == napi_function) { From 420bbd766d529a74a7be67ed3dadb53d7426e712 Mon Sep 17 00:00:00 2001 From: zzvscx Date: Wed, 26 Jun 2024 11:04:28 +0800 Subject: [PATCH 023/247] =?UTF-8?q?=E6=96=B0=E5=A2=9Ecfi=5Fvcall=5Ficall?= =?UTF-8?q?=5Fonly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zzvscx Change-Id: Ie93e3aac4c6da9da102e99470d39e2720aa479db --- rosen/modules/hyper_graphic_manager/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/rosen/modules/hyper_graphic_manager/BUILD.gn b/rosen/modules/hyper_graphic_manager/BUILD.gn index cc41e96efd..5d8097fcb1 100644 --- a/rosen/modules/hyper_graphic_manager/BUILD.gn +++ b/rosen/modules/hyper_graphic_manager/BUILD.gn @@ -48,6 +48,7 @@ ohos_shared_library("libhyper_graphic_manager") { sanitize = { cfi = true cfi_cross_dso = true + cfi_vcall_icall_only = true debug = false } public_configs = [ ":libhyper_graphic_manager_config" ] From d0f991029270fcf6f24e6e27dae3820bd0348434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=BF=E8=B1=AA?= Date: Wed, 26 Jun 2024 11:36:19 +0800 Subject: [PATCH 024/247] add cfi config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 耿豪 --- interfaces/kits/napi/graphic/hdr_capability/BUILD.gn | 2 ++ interfaces/kits/napi/graphic/ui_effect/BUILD.gn | 1 + rosen/modules/effect/effect_ndk/BUILD.gn | 2 ++ 3 files changed, 5 insertions(+) diff --git a/interfaces/kits/napi/graphic/hdr_capability/BUILD.gn b/interfaces/kits/napi/graphic/hdr_capability/BUILD.gn index e48786e26a..8d8510f6d0 100644 --- a/interfaces/kits/napi/graphic/hdr_capability/BUILD.gn +++ b/interfaces/kits/napi/graphic/hdr_capability/BUILD.gn @@ -25,6 +25,7 @@ ohos_shared_library("hdr_capability_utils") { sanitize = { cfi = true cfi_cross_dso = true + cfi_vcall_icall_only = true debug = false } @@ -57,6 +58,7 @@ ohos_shared_library("hdrcapability_napi") { sanitize = { cfi = true cfi_cross_dso = true + cfi_vcall_icall_only = true debug = false } diff --git a/interfaces/kits/napi/graphic/ui_effect/BUILD.gn b/interfaces/kits/napi/graphic/ui_effect/BUILD.gn index c7dcfb1f9d..d8c5bef262 100644 --- a/interfaces/kits/napi/graphic/ui_effect/BUILD.gn +++ b/interfaces/kits/napi/graphic/ui_effect/BUILD.gn @@ -34,6 +34,7 @@ ohos_shared_library("uieffect_napi") { sanitize = { cfi = true cfi_cross_dso = true + cfi_vcall_icall_only = true debug = false } include_dirs = [ diff --git a/rosen/modules/effect/effect_ndk/BUILD.gn b/rosen/modules/effect/effect_ndk/BUILD.gn index 02ce2f041c..6577bef2a8 100644 --- a/rosen/modules/effect/effect_ndk/BUILD.gn +++ b/rosen/modules/effect/effect_ndk/BUILD.gn @@ -32,6 +32,7 @@ template("effect_ndk_source_set") { sanitize = { cfi = true cfi_cross_dso = true + cfi_vcall_icall_only = true debug = false } @@ -99,6 +100,7 @@ ohos_shared_library("native_effect_ndk") { sanitize = { cfi = true cfi_cross_dso = true + cfi_vcall_icall_only = true debug = false } platform = current_os From 17d80dcca1d68ef69fb7d7a88e0d1c1547f66f3f Mon Sep 17 00:00:00 2001 From: chenqinxin Date: Wed, 26 Jun 2024 12:00:44 +0800 Subject: [PATCH 025/247] bugfix hwc node collect when position z changed Signed-off-by: chenqinxin Change-Id: Iabf697820f21a6bb9462718cc9ea93aa69d27d6f --- .../render_service/core/pipeline/rs_uni_render_visitor.cpp | 3 +++ .../include/pipeline/rs_surface_render_node.h | 5 +++++ .../src/pipeline/rs_surface_render_node.cpp | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp index 6ee4681e76..169b4163f7 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp @@ -1760,6 +1760,9 @@ bool RSUniRenderVisitor::AfterUpdateSurfaceDirtyCalc(RSSurfaceRenderNode& node) } UpdateDstRect(node, geoPtr->GetAbsRect(), prepareClipRect_); node.UpdatePositionZ(); + if (node.IsHardwareEnabledType() && node.GetZorderChanged() && curSurfaceNode_) { + curSurfaceNode_->SetNeedCollectHwcNode(true); + } UpdateSurfaceRenderNodeScale(node); UpdateSurfaceRenderNodeRotate(node); if (node.IsMainWindowType() || node.IsLeashWindow()) { diff --git a/rosen/modules/render_service_base/include/pipeline/rs_surface_render_node.h b/rosen/modules/render_service_base/include/pipeline/rs_surface_render_node.h index 7dabad9e25..803eceb170 100644 --- a/rosen/modules/render_service_base/include/pipeline/rs_surface_render_node.h +++ b/rosen/modules/render_service_base/include/pipeline/rs_surface_render_node.h @@ -280,6 +280,11 @@ public: return needCollectHwcNode_; } + void SetNeedCollectHwcNode(bool needCollect) + { + needCollectHwcNode_ = needCollect; + } + void ResetNeedCollectHwcNode() { needCollectHwcNode_ = false; diff --git a/rosen/modules/render_service_base/src/pipeline/rs_surface_render_node.cpp b/rosen/modules/render_service_base/src/pipeline/rs_surface_render_node.cpp index e7aa208c43..1c61298005 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_surface_render_node.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_surface_render_node.cpp @@ -2124,6 +2124,13 @@ void RSSurfaceRenderNode::ResetChildHardwareEnabledNodes() void RSSurfaceRenderNode::AddChildHardwareEnabledNode(std::weak_ptr childNode) { + childHardwareEnabledNodes_.erase(std::remove_if(childHardwareEnabledNodes_.begin(), + childHardwareEnabledNodes_.end(), + [&childNode](const auto& iter) { + auto node = iter.lock(); + auto childNodePtr = childNode.lock(); + return node && childNodePtr && node == childNodePtr; + }), childHardwareEnabledNodes_.end()); childHardwareEnabledNodes_.emplace_back(childNode); } From 4feff82607c2c5756dcc2904fa4d32f85c6f4664 Mon Sep 17 00:00:00 2001 From: shuking Date: Wed, 26 Jun 2024 12:47:16 +0800 Subject: [PATCH 026/247] fix offscreen rotate in some case that display error Signed-off-by: shuking --- .../rs_surface_render_node_drawable.cpp | 35 +++++++++++++------ .../rs_surface_render_node_drawable.h | 2 ++ .../include/params/rs_surface_render_params.h | 2 +- .../platform/common/rs_system_properties.h | 1 + .../src/pipeline/rs_paint_filter_canvas.cpp | 4 +++ .../platform/ohos/rs_system_properties.cpp | 8 +++++ 6 files changed, 41 insertions(+), 11 deletions(-) diff --git a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp index 36467f9f59..9e9ddfd074 100644 --- a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp @@ -150,16 +150,16 @@ bool RSSurfaceRenderNodeDrawable::PrepareOffscreenRender() canvasBackup_ = nullptr; // check offscreen size + if (curCanvas_->GetSurface() == nullptr) { + RS_LOGE("RSSurfaceRenderNodeDrawable::PrepareOffscreenRender, current surface is nullptr"); + return false; + } int offscreenWidth = curCanvas_->GetSurface()->Width(); int offscreenHeight = curCanvas_->GetSurface()->Height(); if (offscreenWidth <= 0 || offscreenHeight <= 0) { RS_LOGE("RSSurfaceRenderNodeDrawable::PrepareOffscreenRender, offscreenWidth or offscreenHeight is invalid"); return false; } - if (curCanvas_->GetSurface() == nullptr) { - RS_LOGE("RSSurfaceRenderNodeDrawable::PrepareOffscreenRender, current surface is nullptr"); - return false; - } int maxRenderSize = std::max(offscreenWidth, offscreenHeight); // create offscreen surface and canvas @@ -183,7 +183,8 @@ bool RSSurfaceRenderNodeDrawable::PrepareOffscreenRender() // backup current canvas and replace with offscreen canvas canvasBackup_ = curCanvas_; curCanvas_ = offscreenCanvas_.get(); - curCanvas_->Save(); + curCanvas_->SetDisableFilterCache(true); + arc_ = std::make_unique(curCanvas_, RSPaintFilterCanvas::SaveType::kCanvasAndAlpha); curCanvas_->Clear(Drawing::Color::COLOR_TRANSPARENT); return true; } @@ -201,10 +202,26 @@ void RSSurfaceRenderNodeDrawable::FinishOffscreenRender(const Drawing::SamplingO auto image = offscreenSurface_->GetImageSnapshot(); canvasBackup_->DrawImage(*image, 0, 0, sampling); canvasBackup_->DetachBrush(); - curCanvas_->Restore(); + arc_ = nullptr; curCanvas_ = canvasBackup_; } +bool RSSurfaceRenderNodeDrawable::IsHardwareEnabled() +{ + auto& hardwareNodes = RSUniRenderThread::Instance().GetRSRenderThreadParams()->GetHardwareEnabledTypeNodes(); + for (const auto& surfaceNode : hardwareNodes) { + if (surfaceNode == nullptr) { + continue; + } + auto params = static_cast(surfaceNode->GetRenderParams().get()); + if (!params || !params->GetHardwareEnabled()) { + continue; + } + return true; + } + return false; +} + void RSSurfaceRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) { if (!ShouldPaint()) { @@ -302,7 +319,7 @@ void RSSurfaceRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) // Draw base pipeline start RSAutoCanvasRestore acr(rscanvas, RSPaintFilterCanvas::SaveType::kCanvasAndAlpha); bool needOffscreen = surfaceParams->GetNeedOffscreen() && !rscanvas->GetTotalMatrix().IsIdentity() && - surfaceParams->IsAppWindow() && surfaceNode->GetName().substr(0, 3) != "SCB"; + surfaceParams->IsAppWindow() && surfaceNode->GetName().substr(0, 3) != "SCB" && !IsHardwareEnabled(); curCanvas_ = rscanvas; if (needOffscreen) { releaseCount_ = 0; @@ -333,9 +350,7 @@ void RSSurfaceRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) } auto parentSurfaceMatrix = RSRenderParams::GetParentSurfaceMatrix(); - if (!needOffscreen) { - RSRenderParams::SetParentSurfaceMatrix(curCanvas_->GetTotalMatrix()); - } + RSRenderParams::SetParentSurfaceMatrix(curCanvas_->GetTotalMatrix()); // add a blending disable rect op behind floating window, to enable overdraw buffer feature on special gpu. if (surfaceParams->IsLeashWindow() && RSSystemProperties::GetGpuOverDrawBufferOptimizeEnabled() diff --git a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.h b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.h index feb0697d4d..efc07a1e1a 100644 --- a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.h +++ b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.h @@ -212,6 +212,7 @@ public: bool PrepareOffscreenRender(); void FinishOffscreenRender(const Drawing::SamplingOptions& sampling); + bool IsHardwareEnabled(); private: explicit RSSurfaceRenderNodeDrawable(std::shared_ptr&& node); void CacheImgForCapture(RSPaintFilterCanvas& canvas, std::shared_ptr curDisplayNode); @@ -288,6 +289,7 @@ private: RSPaintFilterCanvas* canvasBackup_ = nullptr; // backup current canvas before offscreen rende std::shared_ptr offscreenCanvas_ = nullptr; int maxRenderSize_ = 0; + std::unique_ptr arc_ = nullptr; }; } // namespace DrawableV2 } // namespace OHOS::Rosen diff --git a/rosen/modules/render_service_base/include/params/rs_surface_render_params.h b/rosen/modules/render_service_base/include/params/rs_surface_render_params.h index 93d61e3468..c3f4a2563b 100644 --- a/rosen/modules/render_service_base/include/params/rs_surface_render_params.h +++ b/rosen/modules/render_service_base/include/params/rs_surface_render_params.h @@ -324,7 +324,7 @@ public: bool GetNeedOffscreen() const { - return needOffscreen_; + return RSSystemProperties::GetSurfaceOffscreenEnadbled() ? needOffscreen_ : false; } protected: diff --git a/rosen/modules/render_service_base/include/platform/common/rs_system_properties.h b/rosen/modules/render_service_base/include/platform/common/rs_system_properties.h index 5de4356820..61c5ab324e 100644 --- a/rosen/modules/render_service_base/include/platform/common/rs_system_properties.h +++ b/rosen/modules/render_service_base/include/platform/common/rs_system_properties.h @@ -204,6 +204,7 @@ public: static int WatchSystemProperty(const char* name, OnSystemPropertyChanged func, void* context); static bool GetUIFirstEnabled(); static bool GetUIFirstDebugEnabled(); + static bool GetSurfaceOffscreenEnadbled(); static bool GetDebugTraceEnabled(); static int GetDebugTraceLevel(); static bool FindNodeInTargetList(std::string node); diff --git a/rosen/modules/render_service_base/src/pipeline/rs_paint_filter_canvas.cpp b/rosen/modules/render_service_base/src/pipeline/rs_paint_filter_canvas.cpp index c7bc47a8c9..0cb4a942bb 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_paint_filter_canvas.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_paint_filter_canvas.cpp @@ -1258,6 +1258,10 @@ void RSPaintFilterCanvas::PushDirtyRegion(Drawing::Region& resultRegion) void RSPaintFilterCanvas::PopDirtyRegion() { + if (dirtyRegionStack_.empty()) { + RS_LOGW("PopDirtyRegion dirtyRegionStack_ is empty"); + return; + } dirtyRegionStack_.pop(); } diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_system_properties.cpp b/rosen/modules/render_service_base/src/platform/ohos/rs_system_properties.cpp index ff707df4ed..5dba41b0f3 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_system_properties.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_system_properties.cpp @@ -647,6 +647,14 @@ bool RSSystemProperties::GetUIFirstEnabled() #endif } +bool RSSystemProperties::GetSurfaceOffscreenEnadbled() +{ + static CachedHandle g_Handle = CachedParameterCreate("persist.sys.graphic.surfaceOffscreenEnabled", "1"); + int changed = 0; + const char *enable = CachedParameterGetChanged(g_Handle, &changed); + return ConvertToInt(enable, 1) != 0; +} + bool RSSystemProperties::GetUIFirstDebugEnabled() { static bool debugEnable = system::GetIntParameter("persist.sys.graphic.uifirstDebugEnabled", 0) != 0; From f1195539ac08903db802c631cc35c95f8c6ff146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=BF=E8=B1=AA?= Date: Wed, 26 Jun 2024 14:10:36 +0800 Subject: [PATCH 027/247] fix colorpickerNapi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 耿豪 --- .../kits/napi/graphic/effect_kit/src/color_picker_napi.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/napi/graphic/effect_kit/src/color_picker_napi.cpp b/interfaces/kits/napi/graphic/effect_kit/src/color_picker_napi.cpp index 9dc88e27dd..13c6ccc412 100644 --- a/interfaces/kits/napi/graphic/effect_kit/src/color_picker_napi.cpp +++ b/interfaces/kits/napi/graphic/effect_kit/src/color_picker_napi.cpp @@ -171,7 +171,7 @@ napi_value ColorPickerNapi::Constructor(napi_env env, napi_callback_info info) IMG_JS_NO_ARGS(env, info, status, thisVar); IMG_NAPI_CHECK_RET(IMG_IS_READY(status, thisVar), undefineVar); - ColorPickerNapi* pColorPickerNapi = new ColorPickerNapi(); + ColorPickerNapi* pColorPickerNapi = new (std::nothrow) ColorPickerNapi(); IMG_NAPI_CHECK_RET(IMG_NOT_NULL(pColorPickerNapi), undefineVar); @@ -197,7 +197,8 @@ void ColorPickerNapi::Destructor(napi_env env, void* nativeObject, void* finaliz ColorPickerNapi *pColorPickerNapi = reinterpret_cast(nativeObject); if (IMG_NOT_NULL(pColorPickerNapi)) { - pColorPickerNapi->~ColorPickerNapi(); + delete pColorPickerNapi; + nativeObject = nullptr; } } From 9cc38ce59c882f5125b8cfda39023947f2b89427 Mon Sep 17 00:00:00 2001 From: siyuan Date: Wed, 26 Jun 2024 14:13:44 +0800 Subject: [PATCH 028/247] Fix dirty region Signed-off-by: siyuan --- .../core/pipeline/rs_uni_render_visitor.cpp | 5 +++ .../include/property/rs_properties.h | 2 ++ .../render/rs_attraction_effect_filter.h | 4 +++ .../src/property/rs_properties.cpp | 15 +++++--- .../render/rs_attraction_effect_filter.cpp | 34 +++++++++++++++++++ 5 files changed, 55 insertions(+), 5 deletions(-) diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp index 6ee4681e76..168f27b241 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp @@ -2248,6 +2248,11 @@ void RSUniRenderVisitor::CheckMergeSurfaceDirtysForDisplay(std::shared_ptrGetDirtyManager()->MergeDirtyRect(surfaceChangedRect); } } + + if (surfaceNode->GetRenderProperties().IsAttractionValid()) { + auto attractionDirtyRect_ = surfaceNode->GetRenderProperties().GetAttractionEffectCurrentDirtyRegion(); + curDisplayNode_->GetDirtyManager()->MergeDirtyRect(attractionDirtyRect_); + } } void RSUniRenderVisitor::CheckMergeTransparentDirtysForDisplay(std::shared_ptr& surfaceNode) const diff --git a/rosen/modules/render_service_base/include/property/rs_properties.h b/rosen/modules/render_service_base/include/property/rs_properties.h index a5b09d5871..fdbd8b1edf 100644 --- a/rosen/modules/render_service_base/include/property/rs_properties.h +++ b/rosen/modules/render_service_base/include/property/rs_properties.h @@ -452,6 +452,7 @@ public: float GetAttractionFraction() const; Vector2f GetAttractionDstPoint() const; void CreateAttractionEffectFilter(); + RectI GetAttractionEffectCurrentDirtyRegion() const; void SetLightUpEffect(float lightUpEffectDegree); float GetLightUpEffect() const; @@ -637,6 +638,7 @@ private: float attractFraction_ = 0.f; Vector2f attractDstPoint_ = {0.f, 0.f}; bool isAttractionValid_ = false; + RectI attractionEffectCurrentDirtyRegion_ = {0, 0, 0, 0}; // filter property float backgroundBlurRadius_ = 0.f; diff --git a/rosen/modules/render_service_base/include/render/rs_attraction_effect_filter.h b/rosen/modules/render_service_base/include/render/rs_attraction_effect_filter.h index 3782d38e32..ff2668e5db 100644 --- a/rosen/modules/render_service_base/include/render/rs_attraction_effect_filter.h +++ b/rosen/modules/render_service_base/include/render/rs_attraction_effect_filter.h @@ -17,6 +17,7 @@ #include +#include "common/rs_rect.h" #include "effect/runtime_effect.h" #include "effect/runtime_shader_builder.h" #include "render/rs_skia_filter.h" @@ -38,6 +39,8 @@ public: void PreProcess(std::shared_ptr image) override {}; void PostProcess(Drawing::Canvas& canvas) override {}; float GetAttractionFraction() const; + void UpdateDirtyRegion(float leftPoint, float topPonit); + RectI GetAttractionDirtyRegion() const; std::shared_ptr Compose( const std::shared_ptr& other) const override @@ -80,6 +83,7 @@ private: };; float canvasWidth_ = 0.0f; float canvasHeight_ = 0.0f; + RectI attractionDirtyRegion_ = {0, 0, 0, 0}; friend class RSMarshallingHelper; }; diff --git a/rosen/modules/render_service_base/src/property/rs_properties.cpp b/rosen/modules/render_service_base/src/property/rs_properties.cpp index a2c7895d20..9d7f83408c 100644 --- a/rosen/modules/render_service_base/src/property/rs_properties.cpp +++ b/rosen/modules/render_service_base/src/property/rs_properties.cpp @@ -2323,13 +2323,18 @@ void RSProperties::CreateAttractionEffectFilter() float canvasWidth = GetBoundsRect().GetWidth(); float canvasHeight = GetBoundsRect().GetHeight(); Vector2f destinationPoint = GetAttractionDstPoint(); + float windowLeftPoint = GetFramePositionX(); + float windowTopPoint = GetFramePositionY(); auto attractionEffectFilter = std::make_shared(attractFraction_); attractionEffectFilter->CalculateWindowStatus(canvasWidth, canvasHeight, destinationPoint); - if (IS_UNI_RENDER) { - foregroundFilterCache_ = attractionEffectFilter; - } else { - foregroundFilter_ = attractionEffectFilter; - } + attractionEffectFilter->UpdateDirtyRegion(windowLeftPoint, windowTopPoint); + attractionEffectCurrentDirtyRegion_ = attractionEffectFilter->GetAttractionDirtyRegion(); + foregroundFilter_ = attractionEffectFilter; +} + +RectI RSProperties::GetAttractionEffectCurrentDirtyRegion() const +{ + return attractionEffectCurrentDirtyRegion_; } float RSProperties::GetAttractionFraction() const diff --git a/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp b/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp index 52b0626ac7..de0e5639a9 100644 --- a/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp +++ b/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp @@ -49,6 +49,11 @@ float RSAttractionEffectFilter::GetAttractionFraction() const return attractionFraction_; } +RectI RSAttractionEffectFilter::GetAttractionDirtyRegion() const +{ + return attractionDirtyRegion_; +} + bool RSAttractionEffectFilter::IsWithinThreshold(const float left, const float right, const float threshold) { return (std::abs(left - right) <= threshold); @@ -323,6 +328,35 @@ std::vector RSAttractionEffectFilter::CalculateVelocityCtrlPoint return velocityCtrlPoint; } +void RSAttractionEffectFilter::UpdateDirtyRegion(float leftPoint, float topPonit) +{ + float dirtyRegionMinX_ = windowStatusPoints_[0].GetX(); + float dirtyRegionMaxX_ = windowStatusPoints_[0].GetX(); + float dirtyRegionMinY_ = windowStatusPoints_[0].GetY(); + float dirtyRegionMaxY_ = windowStatusPoints_[0].GetY(); + + int pointNum = 12; + for(int i = 1; i < pointNum; ++i) + { + float x = windowStatusPoints_[i].GetX(); + float y = windowStatusPoints_[i].GetY(); + dirtyRegionMinX_ = std::min(dirtyRegionMinX_, x); + dirtyRegionMaxX_ = std::min(dirtyRegionMaxX_, x); + dirtyRegionMinY_ = std::min(dirtyRegionMinY_, y); + dirtyRegionMaxY_ = std::min(dirtyRegionMaxY_, y); + } + + int dirtyRegionLeftCurrent = static_cast(dirtyRegionMinX_ + leftPoint); + int dirtyRegionTopCurrent = static_cast(dirtyRegionMinY_ + topPonit); + int dirtyRegionRightCurrent = static_cast(dirtyRegionMinX_ + leftPoint); + int dirtyRegionBottomCurrent = static_cast(dirtyRegionMinY_ + topPonit); + + attractionDirtyRegion_.left_ = dirtyRegionLeftCurrent; + attractionDirtyRegion_.top_ = dirtyRegionTopCurrent; + attractionDirtyRegion_.width_ = dirtyRegionRightCurrent - dirtyRegionLeftCurrent; + attractionDirtyRegion_.height_ = dirtyRegionBottomCurrent - dirtyRegionTopCurrent; +} + void RSAttractionEffectFilter::CalculateWindowStatus(float canvasWidth, float canvasHeight, Vector2f destinationPoint) { canvasWidth_ = canvasWidth; From c537ea1b6072c4425b2ca8e9ee84a0e9097a098f Mon Sep 17 00:00:00 2001 From: siyuan Date: Wed, 26 Jun 2024 14:41:30 +0800 Subject: [PATCH 029/247] Fix dirty region code Signed-off-by: siyuan --- .../src/render/rs_attraction_effect_filter.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp b/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp index de0e5639a9..dcd8b716c1 100644 --- a/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp +++ b/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp @@ -336,8 +336,7 @@ void RSAttractionEffectFilter::UpdateDirtyRegion(float leftPoint, float topPonit float dirtyRegionMaxY_ = windowStatusPoints_[0].GetY(); int pointNum = 12; - for(int i = 1; i < pointNum; ++i) - { + for (int i = 1; i < pointNum; ++i) { float x = windowStatusPoints_[i].GetX(); float y = windowStatusPoints_[i].GetY(); dirtyRegionMinX_ = std::min(dirtyRegionMinX_, x); From c6da5ccf8e5f46255ac1e89fb84352c5101eec0e Mon Sep 17 00:00:00 2001 From: Alexander Efimov Date: Wed, 29 May 2024 10:33:40 +0300 Subject: [PATCH 030/247] Fix issue with screen recording and enabled hwc Change-Id: Ie7a266bf8174eaefc3f4ba36ac82ba74f486f421 Signed-off-by: Alexander Efimov --- .../rs_display_render_node_drawable.cpp | 33 +++++++++++++++---- .../rs_display_render_node_drawable.h | 1 + 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp index dff0d743ea..f2bb99c650 100644 --- a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp @@ -850,6 +850,17 @@ void RSDisplayRenderNodeDrawable::DrawMirror(std::shared_ptrScaleMirrorIfNeed(*displayNodeSp, *curCanvas_); curCanvas_->ConcatMatrix(mirroredParams->GetMatrix()); PrepareOffscreenRender(*mirroredNode); + + auto mirroredNodeDrawable = std::static_pointer_cast( + DrawableV2::RSRenderNodeDrawableAdapter::OnGenerate(std::move(mirroredNode))); + // set mirror screen capture param + // Don't need to scale here since the canvas has been switched from mirror frame to offscreen + // surface in PrepareOffscreenRender() above. The offscreen surface has the same size as + // the main display that's why no need additional scale. + float mirrorScaleX = 1.0f; + float mirrorScaleY = 1.0f; + RSUniRenderThread::SetCaptureParam(CaptureParam(true, false, true, mirrorScaleX, mirrorScaleY)); + curCanvas_->Save(); Drawing::Region clipRegion; clipRegion.Clone(uniParam.GetClipRegion()); @@ -868,15 +879,10 @@ void RSDisplayRenderNodeDrawable::DrawMirror(std::shared_ptrSetHasCaptureImg(true); + mirroredNodeDrawable->DrawHardwareEnabledNodesMissedInCacheImage(*curCanvas_); ProcessCacheImage(*cacheImageProcessed); } curCanvas_->Restore(); - auto mirroredNodeDrawable = std::static_pointer_cast( - DrawableV2::RSRenderNodeDrawableAdapter::OnGenerate(std::move(mirroredNode))); - // set mirror screen capture param - float mirrorScaleX = virtualProcesser->GetMirrorScaleX(); - float mirrorScaleY = virtualProcesser->GetMirrorScaleY(); - RSUniRenderThread::SetCaptureParam(CaptureParam(true, false, true, mirrorScaleX, mirrorScaleY)); RSRenderParams::SetParentSurfaceMatrix(curCanvas_->GetTotalMatrix()); if (uniParam.IsOpDropped() && cacheImageProcessed && !hasSpecialLayer_) { ClipRegion(*curCanvas_, clipRegion, false); @@ -1230,6 +1236,21 @@ void RSDisplayRenderNodeDrawable::DrawHardwareEnabledNodes(Drawing::Canvas& canv DrawHardwareEnabledNodes(canvas, displayNodeSp, params); } +void RSDisplayRenderNodeDrawable::DrawHardwareEnabledNodesMissedInCacheImage(Drawing::Canvas& canvas) +{ + auto params = static_cast(GetRenderParams().get()); + if (!params) { + RS_LOGE("RSDisplayRenderNodeDrawable::DrawHardwareEnabledNodesMissedInCacheImage params is null!"); + return; + } + + Drawing::AutoCanvasRestore acr(canvas, true); + FindHardwareEnabledNodes(); + if (params->GetHardwareEnabledNodes().size() != 0) { + AdjustZOrderAndDrawSurfaceNode(params->GetHardwareEnabledNodes(), canvas, *params); + } +} + void RSDisplayRenderNodeDrawable::SwitchColorFilter(RSPaintFilterCanvas& canvas) const { const auto& renderEngine = RSUniRenderThread::Instance().GetRenderEngine(); diff --git a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.h b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.h index 2dcf7a77be..3725f67a00 100644 --- a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.h +++ b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.h @@ -40,6 +40,7 @@ public: void DrawHardwareEnabledNodes(Drawing::Canvas& canvas, std::shared_ptr displayNodeSp, RSDisplayRenderParams* params); void DrawHardwareEnabledNodes(Drawing::Canvas& canvas); + void DrawHardwareEnabledNodesMissedInCacheImage(Drawing::Canvas& canvas); void SwitchColorFilter(RSPaintFilterCanvas& canvas) const; void SetHighContrastIfEnabled(RSPaintFilterCanvas& canvas) const; From a2eeb57002346b77ca2af446292ce3b41b9076cb Mon Sep 17 00:00:00 2001 From: Alexander Efimov Date: Wed, 29 May 2024 16:23:21 +0300 Subject: [PATCH 031/247] Remove extra variables Signed-off-by: Alexander Efimov Change-Id: I6a27c19864c02e1b84ed7ddc69e2f20f27a94090 --- .../core/drawable/rs_display_render_node_drawable.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp index f2bb99c650..7d692f2e9c 100644 --- a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp @@ -857,9 +857,7 @@ void RSDisplayRenderNodeDrawable::DrawMirror(std::shared_ptrSave(); Drawing::Region clipRegion; From 6f8ff08ec0b78eb548477d4bda0c9e84a1fae156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=A6=B9=E8=87=BB?= Date: Wed, 26 Jun 2024 16:02:15 +0800 Subject: [PATCH 032/247] feature tdd test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王禹臻 --- .../src/ge_water_ripple_filter.cpp | 8 +- .../graphics_effect/test/unittest/BUILD.gn | 1 + .../test/unittest/ge_render_test.cpp | 23 +++++ .../unittest/ge_visual_effect_impl_test.cpp | 54 +++++++++++ .../unittest/ge_water_ripple_filter_test.cpp | 96 +++++++++++++++++++ .../unittest/property/rs_properties_test.cpp | 75 +++++++++++++++ .../unittest/render/BUILD.gn | 1 + .../rs_water_ripple_shader_filter_test.cpp | 57 +++++++++++ .../unittest/ui/rs_node_test.cpp | 22 +++++ 9 files changed, 332 insertions(+), 5 deletions(-) create mode 100644 rosen/modules/graphics_effect/test/unittest/ge_water_ripple_filter_test.cpp create mode 100644 rosen/test/render_service/render_service_base/unittest/render/rs_water_ripple_shader_filter_test.cpp diff --git a/rosen/modules/graphics_effect/src/ge_water_ripple_filter.cpp b/rosen/modules/graphics_effect/src/ge_water_ripple_filter.cpp index dc10d06e0c..ebb1c95794 100644 --- a/rosen/modules/graphics_effect/src/ge_water_ripple_filter.cpp +++ b/rosen/modules/graphics_effect/src/ge_water_ripple_filter.cpp @@ -51,10 +51,6 @@ std::shared_ptr GEWaterRippleFilter::ProcessImage(Drawing::Canva Drawing::Matrix matrix; auto shader = Drawing::ShaderEffect::CreateImageShader(*image, Drawing::TileMode::CLAMP, Drawing::TileMode::CLAMP, Drawing::SamplingOptions(Drawing::FilterMode::LINEAR), matrix); - if (shader == nullptr) { - LOGI("GEWaterRippleFilter::ProcessImage shader create failed"); - return nullptr; - } if (g_waterRippleEffect == nullptr) { if (InitWaterRippleEffect() == false) { LOGE("GEWaterRippleFilter::ProcessImage g_waterRippleEffect init failed"); @@ -84,8 +80,10 @@ std::shared_ptr GEWaterRippleFilter::ProcessImage(Drawing::Canva bool GEWaterRippleFilter::InitWaterRippleEffect() { + g_waterRippleEffect = Drawing::RuntimeEffect::CreateForShader(shaderString); if (g_waterRippleEffect == nullptr) { - g_waterRippleEffect = Drawing::RuntimeEffect::CreateForShader(shaderString); + LOGE("GEWaterRippleFilter::RuntimeShader failed to create water ripple filter"); + return false; } return true; } diff --git a/rosen/modules/graphics_effect/test/unittest/BUILD.gn b/rosen/modules/graphics_effect/test/unittest/BUILD.gn index 81882e84f4..0c62fb301e 100644 --- a/rosen/modules/graphics_effect/test/unittest/BUILD.gn +++ b/rosen/modules/graphics_effect/test/unittest/BUILD.gn @@ -31,6 +31,7 @@ ohos_unittest("GraphicsEffectTest") { "ge_visual_effect_container_test.cpp", "ge_visual_effect_impl_test.cpp", "ge_visual_effect_test.cpp", + "ge_water_ripple_filter_test.cpp", ] include_dirs = [ diff --git a/rosen/modules/graphics_effect/test/unittest/ge_render_test.cpp b/rosen/modules/graphics_effect/test/unittest/ge_render_test.cpp index 8b0dd27622..d7c3dde331 100644 --- a/rosen/modules/graphics_effect/test/unittest/ge_render_test.cpp +++ b/rosen/modules/graphics_effect/test/unittest/ge_render_test.cpp @@ -342,5 +342,28 @@ HWTEST_F(GERenderTest, GenerateShaderFilter004, TestSize.Level1) GTEST_LOG_(INFO) << "GERenderTest GenerateShaderFilter003 end"; } + +/** + * @tc.name: GenerateShaderFilter005 + * @tc.desc: Verify the GenerateShaderFilter + * @tc.type: FUNC + */ +HWTEST_F(GERenderTest, GenerateShaderFilter005, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "GERenderTest GenerateShaderFilter005 start"; + + auto visualEffect = std::make_shared(Drawing::GE_FILTER_WATER_RIPPLE); + visualEffect->SetParam("PROGRESS", 0.5f); + visualEffect->SetParam("WAVE_NUM", 1.0f); + visualEffect->SetParam("RIPPLE_CENTER_X", 0.5f); + visualEffect->SetParam("RIPPLE_CENTER_Y", 0.5f); + Drawing::GEVisualEffectContainer veContainer; + veContainer.AddToChainedFilter(visualEffect); + auto geRender = std::make_shared(); + auto shaderFilters = geRender->GenerateShaderFilter(veContainer); + EXPECT_NE(shaderFilters[0], nullptr); + + GTEST_LOG_(INFO) << "GERenderTest GenerateShaderFilter005 end"; +} } // namespace GraphicsEffectEngine } // namespace OHOS diff --git a/rosen/modules/graphics_effect/test/unittest/ge_visual_effect_impl_test.cpp b/rosen/modules/graphics_effect/test/unittest/ge_visual_effect_impl_test.cpp index 2f39fbfada..cee59a0f49 100644 --- a/rosen/modules/graphics_effect/test/unittest/ge_visual_effect_impl_test.cpp +++ b/rosen/modules/graphics_effect/test/unittest/ge_visual_effect_impl_test.cpp @@ -58,6 +58,9 @@ HWTEST_F(GEVisualEffectImplTest, GetFilterType001, TestSize.Level1) Drawing::GEVisualEffectImpl geVisualEffectImpl4(Drawing::GE_FILTER_LINEAR_GRADIENT_BLUR); EXPECT_EQ(geVisualEffectImpl4.GetFilterType(), Drawing::GEVisualEffectImpl::FilterType::LINEAR_GRADIENT_BLUR); + + Drawing::GEVisualEffectImpl geVisualEffectImpl(Drawing::GE_FILTER_WATER_RIPPLE); + EXPECT_EQ(geVisualEffectImpl.GetFilterType(), Drawing::GEVisualEffectImpl::FilterType::WATER_RIPPLE); } /** @@ -277,5 +280,56 @@ HWTEST_F(GEVisualEffectImplTest, SetParam009, TestSize.Level1) geVisualEffectImpl.SetLinearGradientBlurParams("", 2.0f); EXPECT_NE(geVisualEffectImpl.GetLinearGradientBlurParams()->blurRadius, 2.0f); } + +/** + * @tc.name: SetParam010 + * @tc.desc: Verify function SetParam for action is invalid + * @tc.type:FUNC + */ +HWTEST_F(GEVisualEffectImplTest, SetParam010, TestSize.Level1) +{ + Drawing::GEVisualEffectImpl geVisualEffectImpl(Drawing::GE_FILTER_WATER_RIPPLE); + geVisualEffectImpl.SetWaterRippleParams(Drawing::GE_FILTER_WATER_RIPPLE_PROGRESS, 0.5f); + EXPECT_EQ(geVisualEffectImpl.GetWaterRippleParams()->progress, 0.5f); + geVisualEffectImpl.SetWaterRippleParams(Drawing::GE_FILTER_WATER_RIPPLE_WAVE_NUM, 1.0f); + EXPECT_EQ(geVisualEffectImpl.GetWaterRippleParams()->waveCount, 1.0f); + geVisualEffectImpl.SetWaterRippleParams(Drawing::GE_FILTER_WATER_RIPPLE_RIPPLE_CENTER_X, 0.5f); + EXPECT_EQ(geVisualEffectImpl.GetWaterRippleParams()->rippleCenterX, 0.5f); + geVisualEffectImpl.SetWaterRippleParams(Drawing::GE_FILTER_WATER_RIPPLE_RIPPLE_CENTER_Y, 0.5f); + EXPECT_EQ(geVisualEffectImpl.GetWaterRippleParams()->rippleCenterY, 0.5f); +} + +/** + * @tc.name: SetWaterRippleParams001 + * @tc.desc: Verify function SetWaterRippleParams is invalid + * @tc.type:FUNC + */ +HWTEST_F(GEVisualEffectImplTest, SetWaterRippleParams001, TestSize.Level1) +{ + Drawing::GEVisualEffectImpl geVisualEffectImpl(Drawing::GE_FILTER_WATER_RIPPLE); + ASSERT_NE(geVisualEffectImpl.waterRippleParams_, nullptr); + geVisualEffectImpl.SetWaterRippleParams(Drawing::GE_FILTER_WATER_RIPPLE_PROGRESS, 0.5f); + EXPECT_EQ(geVisualEffectImpl.GetWaterRippleParams()->progress, 0.5f); + geVisualEffectImpl.SetWaterRippleParams(Drawing::GE_FILTER_WATER_RIPPLE_WAVE_NUM, 1.0f); + EXPECT_EQ(geVisualEffectImpl.GetWaterRippleParams()->waveCount, 1.0f); + geVisualEffectImpl.SetWaterRippleParams(Drawing::GE_FILTER_WATER_RIPPLE_RIPPLE_CENTER_X, 0.5f); + EXPECT_EQ(geVisualEffectImpl.GetWaterRippleParams()->rippleCenterX, 0.5f); + geVisualEffectImpl.SetWaterRippleParams(Drawing::GE_FILTER_WATER_RIPPLE_RIPPLE_CENTER_Y, 0.5f); + EXPECT_EQ(geVisualEffectImpl.GetWaterRippleParams()->rippleCenterY, 0.5f); +} + +/** + * @tc.name: MakeWaterRippleParams001 + * @tc.desc: Verify function MakeWaterRippleParams is invalid + * @tc.type:FUNC + */ +HWTEST_F(GEVisualEffectImplTest, MakeWaterRippleParams001, TestSize.Level1) +{ + Drawing::GEVisualEffectImpl geVisualEffectImpl(""); + geVisualEffectImpl.SetFilterType(Drawing::GEVisualEffectImpl::FilterType::WATER_RIPPLE); + ASSERT_EQ(geVisualEffectImpl.GetWaterRippleParams(), nullptr); + geVisualEffectImpl.MakeWaterRippleParams(); + ASSERT_NE(geVisualEffectImpl.GetWaterRippleParams(), nullptr); +} } // namespace GraphicsEffectEngine } // namespace OHOS diff --git a/rosen/modules/graphics_effect/test/unittest/ge_water_ripple_filter_test.cpp b/rosen/modules/graphics_effect/test/unittest/ge_water_ripple_filter_test.cpp new file mode 100644 index 0000000000..0084e9445a --- /dev/null +++ b/rosen/modules/graphics_effect/test/unittest/ge_water_ripple_filter_test.cpp @@ -0,0 +1,96 @@ +/* + * 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 + +#include "ge_water_ripple_filter.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace GraphicsEffectEngine { + +using namespace Rosen; + +class GEWaterRippleFilterTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; + std::shared_ptr MakeImage(Drawing::Canvas& canvas); + + static inline Drawing::Canvas canvas_; + std::shared_ptr image_ { nullptr }; + + // 1.0f, 1.0f, 2.0f, 2.0f is left top right bottom + Drawing::Rect src_ { 1.0f, 1.0f, 2.0f, 2.0f }; + Drawing::Rect dst_ { 1.0f, 1.0f, 2.0f, 2.0f }; +}; + +void GEWaterRippleFilterTest::SetUpTestCase(void) {} +void GEWaterRippleFilterTest::TearDownTestCase(void) {} + +void GEWaterRippleFilterTest::SetUp() +{ + canvas_.Restore(); + + Drawing::Bitmap bmp; + Drawing::BitmapFormat format { Drawing::COLORTYPE_RGBA_8888, Drawing::ALPHATYPE_PREMUL }; + bmp.Build(50, 50, format); // 50, 50 bitmap size + bmp.ClearWithColor(Drawing::Color::COLOR_BLUE); + image_ = bmp.MakeImage(); +} + +void GEWaterRippleFilterTest::TearDown() {} + +/** + * @tc.name: InitWaterRippleEffect001 + * @tc.desc: Verify function InitWaterRippleEffect + * @tc.type:FUNC + */ +HWTEST_F(GEWaterRippleFilterTest, InitWaterRippleEffect001, TestSize.Level1) +{ + Drawing::GEWaterRippleFilterParams geWaterRippleFilterParams { 0.5f, 2.0f, 0.5f, 0.7f }; + auto geWaterRippleFilter = std::make_shared(geWaterRippleFilterParams); + EXPECT_TRUE(geWaterRippleFilter->InitWaterRippleEffect()); +} + +/** + * @tc.name: ProcessImage001 + * @tc.desc: Verify function ProcessImage + * @tc.type:FUNC + */ +HWTEST_F(GEWaterRippleFilterTest, ProcessImage001, TestSize.Level1) +{ + Drawing::GEWaterRippleFilterParams geWaterRippleFilterParams { 0.5f, 2.0f, 0.5f, 0.7f }; + auto geWaterRippleFilter = std::make_shared(geWaterRippleFilterParams); + EXPECT_NE(geWaterRippleFilter->ProcessImage(canvas_, image_, src_, dst_), image_); +} + +/** + * @tc.name: ProcessImage002 + * @tc.desc: Verify function ProcessImage + * @tc.type:FUNC + */ +HWTEST_F(GEWaterRippleFilterTest, ProcessImage002, TestSize.Level1) +{ + Drawing::GEWaterRippleFilterParams geWaterRippleFilterParams { 0.5f, 2.0f, 0.5f, 0.7f }; + auto geWaterRippleFilter = std::make_shared(geWaterRippleFilterParams); + EXPECT_EQ(geWaterRippleFilter->ProcessImage(canvas_, nullptr, src_, dst_), nullptr); +} +} // namespace GraphicsEffectEngine +} // namespace OHOS \ No newline at end of file diff --git a/rosen/test/render_service/render_service_base/unittest/property/rs_properties_test.cpp b/rosen/test/render_service/render_service_base/unittest/property/rs_properties_test.cpp index 7e60c0dde9..b178c789f4 100644 --- a/rosen/test/render_service/render_service_base/unittest/property/rs_properties_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/property/rs_properties_test.cpp @@ -2437,6 +2437,19 @@ HWTEST_F(RSPropertiesTest, GenerateBackgroundFilter001, TestSize.Level1) properties.systemBarEffect_ = true; properties.GenerateBackgroundFilter(); EXPECT_TRUE(properties.systemBarEffect_); + + properties.waterRippleProgress_ = 0.1f; + float waveCount = 2.0f; + float rippleCenterX = 0.3f; + float rippleCenterY = 0.5f; + RSWaterRipplePara rs_water_ripple_param = { + waveCount, + rippleCenterX, + rippleCenterY + }; + properties.waterRippleParams_ = std::optional(rs_water_ripple_param); + properties.GenerateBackgroundFilter(); + EXPECT_TRUE(properties.IsWaterRippleValid()); } /** @@ -3090,5 +3103,67 @@ HWTEST_F(RSPropertiesTest, GetPixelStretchTileMode001, TestSize.Level1) mode = properties.GetPixelStretchTileMode(); ASSERT_EQ(static_cast(Drawing::TileMode::DECAL), mode); } + +/** + * @tc.name: SetNGetWaterRippleParams001 + * @tc.desc: test results of SetNGetWaterRippleParams001 + * @tc.type: FUNC + * @tc.require: issueI9QKVM + */ +HWTEST_F(RSPropertiesTest, SetNGetWaterRippleParams001, TestSize.Level1) +{ + RSProperties properties; + RSWaterRipplePara para; + std::optional params; + properties.SetWaterRippleParams(params); + EXPECT_EQ(params.has_value(), false); + + params = para; + properties.SetWaterRippleParams(params); + EXPECT_EQ(params.has_value(), true); +} + +/** + * @tc.name: SetNGetWaterRippleParams002 + * @tc.desc: test results of SetNGetWaterRippleParams002 + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSPropertiesTest, SetNGetWaterRippleParams002, TestSize.Level1) +{ + RSProperties properties; + float waveCount = 2.0f; + float rippleCenterX = 0.3f; + float rippleCenterY = 0.5f; + float progress = 0.5f; + RSWaterRipplePara rs_water_ripple_param = { + waveCount, + rippleCenterX, + rippleCenterY + }; + properties.SetWaterRippleParams(rs_water_ripple_param); + properties.SetWaterRippleProgress(progress); + EXPECT_EQ(properties.filterNeedUpdate_, true); + + auto valueGet = properties.GetWaterRippleParams(); + EXPECT_EQ(valueGet.has_value(), true); + EXPECT_EQ(properties.IsWaterRippleValid(), true); +} + +/** + * @tc.name: SetNGetWaterRippleProgress001 + * @tc.desc: test results of SetNGetWaterRippleProgress001 + * @tc.type: FUNC + * @tc.require: issueI9QKVM + */ +HWTEST_F(RSPropertiesTest, SetNGetWaterRippleProgress001, TestSize.Level1) +{ + RSProperties properties; + properties.SetWaterRippleProgress(0.5f); + EXPECT_EQ(properties.filterNeedUpdate_, true); + + auto valueGet = properties.GetWaterRippleProgress(); + EXPECT_EQ(valueGet, 0.5f); +} } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/rosen/test/render_service/render_service_base/unittest/render/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/render/BUILD.gn index 8abd4aee28..c56955d284 100644 --- a/rosen/test/render_service/render_service_base/unittest/render/BUILD.gn +++ b/rosen/test/render_service/render_service_base/unittest/render/BUILD.gn @@ -50,6 +50,7 @@ ohos_unittest("RSRenderServiceBaseRenderTest") { "rs_skia_filter_test.cpp", "rs_spherize_effect_filter_test.cpp", "rs_typeface_cache_test.cpp", + "rs_water_ripple_shader_filter_test.cpp", ] cflags = [ diff --git a/rosen/test/render_service/render_service_base/unittest/render/rs_water_ripple_shader_filter_test.cpp b/rosen/test/render_service/render_service_base/unittest/render/rs_water_ripple_shader_filter_test.cpp new file mode 100644 index 0000000000..59eb2c9522 --- /dev/null +++ b/rosen/test/render_service/render_service_base/unittest/render/rs_water_ripple_shader_filter_test.cpp @@ -0,0 +1,57 @@ +/* + * 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 "gtest/gtest.h" + +#include "render/rs_water_ripple_shader_filter.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Rosen { +class RSWaterRippleShaderFilterTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void RSWaterRippleShaderFilterTest::SetUpTestCase() {} +void RSWaterRippleShaderFilterTest::TearDownTestCase() {} +void RSWaterRippleShaderFilterTest::SetUp() {} +void RSWaterRippleShaderFilterTest::TearDown() {} + +/** + * @tc.name: GenerateGEVisualEffectTest + * @tc.desc: Verify function GenerateGEVisualEffect + * @tc.type:FUNC + * @tc.require: issuesI9UWCD + */ +HWTEST_F(RSWaterRippleShaderFilterTest, GenerateGEVisualEffectTest, TestSize.Level1) +{ + float progress = 0.1f; + float waveCount = 2.0f; + float rippleCenterX = 0.3f; + float rippleCenterY = 0.5f; + + auto rsWaterRippleShaderFilter = std::make_shared(progress, waveCount, rippleCenterX, + rippleCenterY); + auto visualEffectContainer = std::make_shared(); + rsWaterRippleShaderFilter->GenerateGEVisualEffect(visualEffectContainer); + EXPECT_FALSE(visualEffectContainer->filterVec_.empty()); +} +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/rosen/test/render_service/render_service_client/unittest/ui/rs_node_test.cpp b/rosen/test/render_service/render_service_client/unittest/ui/rs_node_test.cpp index cc38fd0b10..5eb89918e5 100644 --- a/rosen/test/render_service/render_service_client/unittest/ui/rs_node_test.cpp +++ b/rosen/test/render_service/render_service_client/unittest/ui/rs_node_test.cpp @@ -6931,4 +6931,26 @@ HWTEST_F(RSNodeTest, SetInstanceId, TestSize.Level1) rsNode->SetInstanceId(1); ASSERT_EQ(rsNode->GetInstanceId(), 1); } + +/** + * @tc.name: SetWaterRippleParams + * @tc.desc: test results of SetWaterRippleParams + * @tc.type: FUNC + * @tc.require: issueI9KAZH + */ +HWTEST_F(RSNodeTest, SetWaterRippleParams, TestSize.Level1) +{ + float waveCount = 2.0f; + float rippleCenterX = 0.3f; + float rippleCenterY = 0.5f; + float progress = 0.5f; + RSWaterRipplePara rs_water_ripple_param = { + waveCount, + rippleCenterX, + rippleCenterY + }; + auto rsNode = RSCanvasNode::Create(); + rsNode->SetWaterRippleParams(rs_water_ripple_param, progress); + EXPECT_EQ(waveCount, 2.0f); +} } // namespace OHOS::Rosen From e1f3bd9636dc4bcad7e234d3d4472e89a0d44fd3 Mon Sep 17 00:00:00 2001 From: lw19901203 Date: Wed, 26 Jun 2024 16:14:01 +0800 Subject: [PATCH 033/247] add c++ fuzz test cy002 Signed-off-by: lw19901203 --- .../fuzztest/draw/path_fuzzer/path_fuzzer.cpp | 209 +++++++++++++++++- .../test/2d_graphics/fuzztest/effect/BUILD.gn | 9 +- .../fuzztest/effect/filter_fuzzer/BUILD.gn | 59 +++++ .../fuzztest/effect/filter_fuzzer/corpus/init | 14 ++ .../effect/filter_fuzzer/filter_fuzzer.cpp | 80 +++++++ .../effect/filter_fuzzer/filter_fuzzer.h | 21 ++ .../fuzztest/effect/filter_fuzzer/project.xml | 25 +++ 7 files changed, 413 insertions(+), 4 deletions(-) create mode 100644 rosen/test/2d_graphics/fuzztest/effect/filter_fuzzer/BUILD.gn create mode 100644 rosen/test/2d_graphics/fuzztest/effect/filter_fuzzer/corpus/init create mode 100644 rosen/test/2d_graphics/fuzztest/effect/filter_fuzzer/filter_fuzzer.cpp create mode 100644 rosen/test/2d_graphics/fuzztest/effect/filter_fuzzer/filter_fuzzer.h create mode 100644 rosen/test/2d_graphics/fuzztest/effect/filter_fuzzer/project.xml diff --git a/rosen/test/2d_graphics/fuzztest/draw/path_fuzzer/path_fuzzer.cpp b/rosen/test/2d_graphics/fuzztest/draw/path_fuzzer/path_fuzzer.cpp index d32fa266e8..4181fca96c 100644 --- a/rosen/test/2d_graphics/fuzztest/draw/path_fuzzer/path_fuzzer.cpp +++ b/rosen/test/2d_graphics/fuzztest/draw/path_fuzzer/path_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -25,6 +25,12 @@ namespace OHOS { namespace Rosen { +namespace { +constexpr size_t MAX_ARRAY_SIZE = 5000; +constexpr size_t DIRECTION_SIZE = 2; +constexpr size_t FILLTYPE_SIZE = 4; +constexpr size_t MATRIXFLAG_SIZE = 3; +} // namespace namespace Drawing { bool PathAddFuzzTest(const uint8_t* data, size_t size) { @@ -76,6 +82,201 @@ bool PathOpFuzzTest(const uint8_t* data, size_t size) path2.Reset(); return true; } + +bool PathFuzzTest001(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + Path path; + Path pathTwo = Path(path); + path.GetDrawingType(); + path.ConvertToSVGString(); + path = pathTwo; + return true; +} + +bool PathFuzzTest002(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + Path path; + scalar ptOneX = GetObject(); + scalar ptOneY = GetObject(); + scalar ptTwoX = GetObject(); + scalar ptTwoY = GetObject(); + scalar startAngle = GetObject(); + scalar sweepAngle = GetObject(); + path.ArcTo(ptOneX, ptOneY, ptTwoX, ptTwoY, startAngle, sweepAngle); + Point ptOne { ptOneX, ptOneY }; + Point ptTwo { ptTwoX, ptTwoY }; + path.ArcTo(ptOne, ptTwo, startAngle, sweepAngle); + uint32_t direction = GetObject(); + path.ArcTo(ptOneX, ptOneY, startAngle, static_cast(direction % DIRECTION_SIZE), ptTwoX, ptTwoY); + scalar endPtX = GetObject(); + scalar endPtY = GetObject(); + path.CubicTo(ptOneX, ptOneY, ptTwoX, ptTwoY, endPtX, endPtY); + Point ptEnd { endPtX, endPtY }; + path.CubicTo(ptOne, ptTwo, ptEnd); + path.QuadTo(ptOneX, ptOneY, endPtX, endPtY); + path.QuadTo(ptOne, ptEnd); + path.ConicTo(ptOneX, ptOneY, endPtX, endPtY, sweepAngle); + path.RMoveTo(ptOneX, ptOneY); + path.RLineTo(ptOneX, ptOneY); + path.RArcTo(ptOneX, ptOneY, startAngle, static_cast(direction % DIRECTION_SIZE), ptTwoX, ptTwoY); + path.RCubicTo(ptOneX, ptOneY, ptTwoX, ptTwoY, endPtX, endPtY); + path.RQuadTo(ptOneX, ptOneY, ptTwoX, ptTwoY); + path.RConicTo(ptOneX, ptOneY, endPtX, endPtY, sweepAngle); + scalar distance = GetObject(); + bool forceClosed = GetObject(); + path.GetPositionAndTangent(distance, ptOne, ptTwo, forceClosed); + return true; +} + +bool PathFuzzTest003(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + Path path; + float left = GetObject(); + float top = GetObject(); + float right = GetObject(); + float bottom = GetObject(); + Rect rect { left, top, right, bottom }; + uint32_t direction = GetObject(); + path.AddRect(rect, static_cast(direction % DIRECTION_SIZE)); + uint32_t start = GetObject(); + path.AddRect(rect, start, static_cast(direction % DIRECTION_SIZE)); + path.AddRect(left, top, right, bottom, static_cast(direction % DIRECTION_SIZE)); + path.AddOval(rect, static_cast(direction % DIRECTION_SIZE)); + path.AddOval(rect, start, static_cast(direction % DIRECTION_SIZE)); + scalar startAngle = GetObject(); + scalar sweepAngle = GetObject(); + path.AddArc(rect, startAngle, sweepAngle); + + scalar ptx = GetObject(); + scalar pty = GetObject(); + scalar radius = GetObject(); + path.AddCircle(ptx, pty, radius, static_cast(direction % DIRECTION_SIZE)); + path.AddRoundRect(rect, ptx, pty, static_cast(direction % DIRECTION_SIZE)); + RoundRect roundRect; + path.AddRoundRect(roundRect, static_cast(direction % DIRECTION_SIZE)); + return true; +} + +bool PathFuzzTest004(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + Path path; + Path src; + Path ending; + scalar ptx = GetObject(); + scalar pty = GetObject(); + scalar weight = GetObject(); + uint32_t mode = GetObject(); + path.AddPath(src, ptx, pty, static_cast(mode % DIRECTION_SIZE)); + path.AddPath(src, static_cast(mode % DIRECTION_SIZE)); + Matrix matrix; + path.AddPath(src, matrix, static_cast(mode % DIRECTION_SIZE)); + path.Contains(ptx, pty); + path.ReverseAddPath(src); + path.GetBounds(); + uint32_t fillstyle = GetObject(); + path.SetFillStyle(static_cast(fillstyle % FILLTYPE_SIZE)); + path.BuildFromInterpolate(src, ending, weight); + path.Transform(matrix); + bool applyPerspectiveClip = GetObject(); + path.TransformWithPerspectiveClip(matrix, &src, applyPerspectiveClip); + path.Offset(ptx, pty); + path.Offset(&src, ptx, pty); + path.IsValid(); + bool forceClosed = GetObject(); + path.GetLength(forceClosed); + path.IsClosed(forceClosed); + float distance = GetObject(); + uint32_t flags = GetObject(); + path.GetMatrix(forceClosed, distance, &matrix, static_cast(flags % MATRIXFLAG_SIZE)); + path.Serialize(); + path.Deserialize(nullptr); + return true; +} + +bool PathFuzzTest005(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + Path path; + uint32_t count = GetObject() % MAX_ARRAY_SIZE + 1; + char str[count]; + for (size_t i = 0; i < count; i++) { + str[i] = GetObject(); + } + str[count - 1] = '\0'; + path.BuildFromSVGString(str); + return true; +} + +bool PathFuzzTest006(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + Path path; + std::vector points; + scalar ptOneX = GetObject(); + scalar ptOneY = GetObject(); + scalar ptTwoX = GetObject(); + scalar ptTwoY = GetObject(); + Point ptOne { ptOneX, ptOneY }; + Point ptTwo { ptTwoX, ptTwoY }; + points.push_back(ptOne); + points.push_back(ptTwo); + int count = points.size(); + bool close = GetObject(); + path.AddPoly(points, count, close); + return true; +} } // namespace Drawing } // namespace Rosen } // namespace OHOS @@ -86,5 +287,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) /* Run your code on data */ OHOS::Rosen::Drawing::PathAddFuzzTest(data, size); OHOS::Rosen::Drawing::PathOpFuzzTest(data, size); + OHOS::Rosen::Drawing::PathFuzzTest001(data, size); + OHOS::Rosen::Drawing::PathFuzzTest002(data, size); + OHOS::Rosen::Drawing::PathFuzzTest003(data, size); + OHOS::Rosen::Drawing::PathFuzzTest004(data, size); + OHOS::Rosen::Drawing::PathFuzzTest005(data, size); + OHOS::Rosen::Drawing::PathFuzzTest006(data, size); return 0; } \ No newline at end of file diff --git a/rosen/test/2d_graphics/fuzztest/effect/BUILD.gn b/rosen/test/2d_graphics/fuzztest/effect/BUILD.gn index 6c29c303ad..e8a35e2d6b 100644 --- a/rosen/test/2d_graphics/fuzztest/effect/BUILD.gn +++ b/rosen/test/2d_graphics/fuzztest/effect/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. +# Copyright (c) 2022-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 @@ -9,10 +9,13 @@ # 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. +# limitations under the License. group("fuzztest") { testonly = true - deps = [ "patheffect_fuzzer:fuzztest" ] + deps = [ + "filter_fuzzer:fuzztest", + "patheffect_fuzzer:fuzztest", + ] } diff --git a/rosen/test/2d_graphics/fuzztest/effect/filter_fuzzer/BUILD.gn b/rosen/test/2d_graphics/fuzztest/effect/filter_fuzzer/BUILD.gn new file mode 100644 index 0000000000..9b74202c5a --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/effect/filter_fuzzer/BUILD.gn @@ -0,0 +1,59 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +module_output_path = "graphic_2d/graphic_2d" + +##############################fuzztest########################################## +ohos_fuzztest("FilterFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "../../../../../test/2d_graphics/fuzztest/effect/filter_fuzzer" + + sources = [ + "filter_fuzzer.cpp", + "get_object.h", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + include_dirs = [ + "../../../../../modules/2d_graphics/include", + "../../../../../modules/2d_graphics/src", + "../../../../../test/2d_graphics/fuzztest", + ] + + deps = [ "../../../../../modules/2d_graphics:2d_graphics" ] + + part_name = "graphic_2d" + subsystem_name = "graphic" +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + + deps += [ + # deps file + ":FilterFuzzTest", + ] +} +############################################################################### diff --git a/rosen/test/2d_graphics/fuzztest/effect/filter_fuzzer/corpus/init b/rosen/test/2d_graphics/fuzztest/effect/filter_fuzzer/corpus/init new file mode 100644 index 0000000000..e7c3fecd8d --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/effect/filter_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# 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. + +FUZZ \ No newline at end of file diff --git a/rosen/test/2d_graphics/fuzztest/effect/filter_fuzzer/filter_fuzzer.cpp b/rosen/test/2d_graphics/fuzztest/effect/filter_fuzzer/filter_fuzzer.cpp new file mode 100644 index 0000000000..95009dd10f --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/effect/filter_fuzzer/filter_fuzzer.cpp @@ -0,0 +1,80 @@ +/* + * 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 "filter_fuzzer.h" + +#include +#include +#include + +#include "get_object.h" +#include "effect/filter.h" +#include "utils/scalar.h" + +namespace OHOS { +namespace Rosen { +constexpr size_t BLURTYPE_SIZE = 4; +constexpr size_t FQ_SIZE = 4; +namespace Drawing { +bool FilterFuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + Filter filter; + std::shared_ptr colorFilter = ColorFilter::CreateLinearToSrgbGamma(); + filter.SetColorFilter(colorFilter); + filter.GetColorFilter(); + filter.GetColorFilterPtr(); + scalar sigmaX = GetObject(); + scalar sigmaY = GetObject(); + std::shared_ptr imageFilter = ImageFilter::CreateColorBlurImageFilter(*colorFilter, sigmaX, sigmaY); + filter.SetImageFilter(imageFilter); + filter.GetImageFilter(); + filter.GetImageFilterPtr(); + uint32_t blurType = GetObject(); + scalar sigma = GetObject(); + bool respectCTM = GetObject(); + std::shared_ptr maskFilter = MaskFilter::CreateBlurMaskFilter( + static_cast(blurType % BLURTYPE_SIZE), sigma, respectCTM); + filter.SetMaskFilter(maskFilter); + filter.GetMaskFilter(); + filter.GetMaskFilterPtr(); + filter.GetFilterQuality(); + uint32_t fq = GetObject(); + filter.SetFilterQuality(static_cast(fq % FQ_SIZE)); + filter.Reset(); + Filter filterTwo; + if (filter == filterTwo) {} + if (filter != filterTwo) {} + return true; +} +} // namespace Drawing +} // namespace Rosen +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::Rosen::Drawing::FilterFuzzTest(data, size); + return 0; +} diff --git a/rosen/test/2d_graphics/fuzztest/effect/filter_fuzzer/filter_fuzzer.h b/rosen/test/2d_graphics/fuzztest/effect/filter_fuzzer/filter_fuzzer.h new file mode 100644 index 0000000000..404d0c254a --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/effect/filter_fuzzer/filter_fuzzer.h @@ -0,0 +1,21 @@ +/* + * 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 TEST_FUZZTEST_FILTER_FUZZER_H +#define TEST_FUZZTEST_FILTER_FUZZER_H + +#define FUZZ_PROJECT_NAME "filter_fuzzer" + +#endif // TEST_FUZZTEST_FILTER_FUZZER_H \ No newline at end of file diff --git a/rosen/test/2d_graphics/fuzztest/effect/filter_fuzzer/project.xml b/rosen/test/2d_graphics/fuzztest/effect/filter_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/effect/filter_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + From a16b173e6be4385887be9f7acd0490844e863324 Mon Sep 17 00:00:00 2001 From: yzj688 Date: Wed, 26 Jun 2024 16:15:36 +0800 Subject: [PATCH 034/247] =?UTF-8?q?Drawing=20=E5=AE=89=E5=85=A8=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E4=BF=AE=E5=A4=8D=20Signed-off-by:=20yzj688=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../graphic/drawing/color_filter_napi/js_color_filter.cpp | 2 +- interfaces/kits/napi/graphic/drawing/font_napi/js_font.cpp | 4 ++++ .../napi/graphic/drawing/mask_filter_napi/js_mask_filter.cpp | 2 +- .../napi/graphic/drawing/path_effect_napi/js_path_effect.cpp | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/interfaces/kits/napi/graphic/drawing/color_filter_napi/js_color_filter.cpp b/interfaces/kits/napi/graphic/drawing/color_filter_napi/js_color_filter.cpp index 2f5fb5b4d2..42875ccbc1 100644 --- a/interfaces/kits/napi/graphic/drawing/color_filter_napi/js_color_filter.cpp +++ b/interfaces/kits/napi/graphic/drawing/color_filter_napi/js_color_filter.cpp @@ -119,7 +119,7 @@ napi_value JsColorFilter::CreateBlendModeColorFilter(napi_env env, napi_callback } int32_t jsMode = 0; - GET_INT32_CHECK_GE_ZERO_PARAM(ARGC_ONE, jsMode); + GET_ENUM_PARAM(ARGC_ONE, jsMode, 0, static_cast(BlendMode::LUMINOSITY)); auto color = Color::ColorQuadSetARGB(argb[ARGC_ZERO], argb[ARGC_ONE], argb[ARGC_TWO], argb[ARGC_THREE]); std::shared_ptr colorFilter = ColorFilter::CreateBlendModeColorFilter(color, BlendMode(jsMode)); diff --git a/interfaces/kits/napi/graphic/drawing/font_napi/js_font.cpp b/interfaces/kits/napi/graphic/drawing/font_napi/js_font.cpp index d5d3947495..9929c6fadb 100644 --- a/interfaces/kits/napi/graphic/drawing/font_napi/js_font.cpp +++ b/interfaces/kits/napi/graphic/drawing/font_napi/js_font.cpp @@ -84,6 +84,10 @@ napi_value JsFont::Constructor(napi_env env, napi_callback_info info) std::shared_ptr font = std::make_shared(); font->SetTypeface(JsTypeface::LoadZhCnTypeface()); JsFont *jsFont = new(std::nothrow) JsFont(font); + if (!jsFont) { + ROSEN_LOGE("Failed to create JsFont"); + return nullptr; + } status = napi_wrap(env, jsThis, jsFont, JsFont::Destructor, nullptr, nullptr); diff --git a/interfaces/kits/napi/graphic/drawing/mask_filter_napi/js_mask_filter.cpp b/interfaces/kits/napi/graphic/drawing/mask_filter_napi/js_mask_filter.cpp index 227a4ba45f..9968158057 100644 --- a/interfaces/kits/napi/graphic/drawing/mask_filter_napi/js_mask_filter.cpp +++ b/interfaces/kits/napi/graphic/drawing/mask_filter_napi/js_mask_filter.cpp @@ -103,7 +103,7 @@ napi_value JsMaskFilter::CreateBlurMaskFilter(napi_env env, napi_callback_info i CHECK_PARAM_NUMBER_WITHOUT_OPTIONAL_PARAMS(argv, ARGC_TWO); int32_t blurType = 0; - GET_INT32_CHECK_GE_ZERO_PARAM(ARGC_ZERO, blurType); + GET_ENUM_PARAM(ARGC_ZERO, blurType, 0, static_cast(BlurType::INNER)); double sigma = 0.0; GET_DOUBLE_PARAM(ARGC_ONE, sigma); diff --git a/interfaces/kits/napi/graphic/drawing/path_effect_napi/js_path_effect.cpp b/interfaces/kits/napi/graphic/drawing/path_effect_napi/js_path_effect.cpp index 4c2e7aa112..657ad8a9ba 100644 --- a/interfaces/kits/napi/graphic/drawing/path_effect_napi/js_path_effect.cpp +++ b/interfaces/kits/napi/graphic/drawing/path_effect_napi/js_path_effect.cpp @@ -105,10 +105,10 @@ napi_value JsPathEffect::CreateDashPathEffect(napi_env env, napi_callback_info i uint32_t arrayLength = 0; if ((napi_get_array_length(env, argv[ARGC_ZERO], &arrayLength) != napi_ok)) { - ROSEN_LOGE("JsPathEffect::CreateDashPathEffect count of intervals is not even : %{public}u", arrayLength); return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, "Invalid array length params."); } if (arrayLength % NUMBER_TWO || arrayLength < NUMBER_TWO) { // arrayLength must be an even number greater than 0 + ROSEN_LOGE("JsPathEffect::CreateDashPathEffect count of intervals is not even : %{public}u", arrayLength); return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, "parameter array length verification failed."); } From 837cefd6c619f888d0313fd6eb286ba052cfcaf9 Mon Sep 17 00:00:00 2001 From: zhangjz Date: Wed, 26 Jun 2024 16:22:52 +0800 Subject: [PATCH 035/247] HMSymbol animation add TDD Signed-off-by: zhangjz --- .../animation/rs_animation_test_utils.h | 2 + .../animation/rs_symbol_animation_test.cpp | 380 +++++++++++++++++- 2 files changed, 381 insertions(+), 1 deletion(-) diff --git a/rosen/modules/render_service_client/test/unittest/animation/rs_animation_test_utils.h b/rosen/modules/render_service_client/test/unittest/animation/rs_animation_test_utils.h index 0d20b38d8e..a5944a6c94 100644 --- a/rosen/modules/render_service_client/test/unittest/animation/rs_animation_test_utils.h +++ b/rosen/modules/render_service_client/test/unittest/animation/rs_animation_test_utils.h @@ -77,6 +77,8 @@ const float END_FRACTION_DATA[] = {0.6f, 0.7f, 0.8f, 0.9f, 1.0f}; constexpr uint32_t SUCCESS_INT = 1; const std::string SUCCESS_STRING = "success"; constexpr bool SUCCESS_BOOL = true; +const unsigned int INVALID_STATUS = -1; // invalid status label for replace animation +const unsigned int APPEAR_STATUS = 1 ; // appear status label for replace animation const Drawing::DrawingPiecewiseParameter BOUNCE_FIRST_PHASE_PARAS = { OHOS::Rosen::Drawing::DrawingCurveType::LINEAR, // animation curve type diff --git a/rosen/modules/render_service_client/test/unittest/animation/rs_symbol_animation_test.cpp b/rosen/modules/render_service_client/test/unittest/animation/rs_symbol_animation_test.cpp index 6acbcdbe2c..35df29bada 100644 --- a/rosen/modules/render_service_client/test/unittest/animation/rs_symbol_animation_test.cpp +++ b/rosen/modules/render_service_client/test/unittest/animation/rs_symbol_animation_test.cpp @@ -28,6 +28,350 @@ using namespace ANIMATIONTEST; class RSSymbolAnimationTest : public RSAnimationBaseTest { }; +/** + * @tc.name: SetSymbolAnimation001 + * @tc.desc: SetSymbolAnimation of RSSymbolAnimationTest + * @tc.type: FUNC + */ +HWTEST_F(RSSymbolAnimationTest, SetSymbolAnimation001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RSSymbolAnimationTest SetSymbolAnimation001 start"; + /** + * @tc.steps: step1. init data + */ + auto symbolAnimation = RSSymbolAnimation(); + auto symbolAnimationConfig = std::make_shared(); + /** + * @tc.steps: step2.1 rsNode_ is nullptr, symbolAnimationConfig is nullptr + */ + bool flag1 = symbolAnimation.SetSymbolAnimation(nullptr); + EXPECT_TRUE(flag1 == false); + /** + * @tc.steps: step2.2 rsNode_ is nullptr, symbolAnimationConfig is not nullptr + */ + bool flag2 = symbolAnimation.SetSymbolAnimation(symbolAnimationConfig); + EXPECT_TRUE(flag2 == false); + /** + * @tc.steps: step2.3 rsNode_ is not nullptr, symbolAnimationConfig is nullptr + */ + symbolAnimation.SetNode(rootNode); + bool flag3 = symbolAnimation.SetSymbolAnimation(nullptr); + EXPECT_TRUE(flag3 == false); + /** + * @tc.steps: step2.4 rsNode_ is not nullptr, symbolAnimationConfig is not nullptr + */ + symbolAnimationConfig->effectStrategy = Drawing::DrawingEffectStrategy::NONE; + symbolAnimationConfig->symbolSpanId = 1996; // the 1996 is the unique ID of a symbol + bool flag4 = symbolAnimation.SetSymbolAnimation(symbolAnimationConfig); + EXPECT_TRUE(flag4 == true); + NotifyStartAnimation(); + GTEST_LOG_(INFO) << "RSSymbolAnimationTest SetSymbolAnimation001 end"; +} + +/** + * @tc.name: SetSymbolAnimation002 + * @tc.desc: SetSymbolAnimation of RSSymbolAnimationTest + * @tc.type: FUNC + */ +HWTEST_F(RSSymbolAnimationTest, SetSymbolAnimation002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RSSymbolAnimationTest SetSymbolAnimation002 start"; + /** + * @tc.steps: step1. init data + */ + auto symbolAnimation = RSSymbolAnimation(); + symbolAnimation.SetNode(rootNode); + auto symbolAnimationConfig = std::make_shared(); + symbolAnimationConfig->symbolSpanId = 1996; // the 1996 is the unique ID of a symbol + symbolAnimationConfig->effectStrategy = Drawing::DrawingEffectStrategy::VARIABLE_COLOR; + auto newCanvasNode = RSCanvasNode::Create(); + rootNode->canvasNodesListMap[symbolAnimationConfig->symbolSpanId] = {{newCanvasNode->GetId(), newCanvasNode}}; + /** + * @tc.steps: step2.1 test variable_color animation + */ + bool flag1 = symbolAnimation.SetSymbolAnimation(symbolAnimationConfig); + EXPECT_TRUE(flag1 == false); + /** + * @tc.steps: step2.2 test replace animation + */ + symbolAnimationConfig->symbolSpanId++; + symbolAnimationConfig->effectStrategy = Drawing::DrawingEffectStrategy::REPLACE_APPEAR; + symbolAnimation.SetSymbolAnimation(symbolAnimationConfig); + NotifyStartAnimation(); + GTEST_LOG_(INFO) << "RSSymbolAnimationTest SetSymbolAnimation002 end"; +} + +/** + * @tc.name: SetPublicAnimation001 + * @tc.desc: SetPublicAnimation of RSSymbolAnimationTest + * @tc.type: FUNC + */ +HWTEST_F(RSSymbolAnimationTest, SetPublicAnimation001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RSSymbolAnimationTest SetPublicAnimation001 start"; + /** + * @tc.steps: step1. init data + */ + auto symbolAnimation = RSSymbolAnimation(); + symbolAnimation.SetNode(rootNode); + auto symbolAnimationConfig = std::make_shared(); + symbolAnimationConfig->symbolSpanId = 19; // the 19 is the unique ID of a symbol + symbolAnimationConfig->effectStrategy = Drawing::DrawingEffectStrategy::SCALE; + symbolAnimationConfig->animationMode = 1; // 1 is wholeymbol + symbolAnimationConfig->animationStart = true; + // init symbolNode + Drawing::Path path; + path.AddCircle(100, 100, 50); // 100 x, 100y, 50 radius + Drawing::DrawingHMSymbolData symbol; + symbol.path_ = path; + TextEngine::SymbolNode symbolNode1; + symbolNode1.symbolData = symbol; + symbolNode1.nodeBoundary = {100, 100, 50, 50}; // 100 x, 100 y, 50 width, 50 height + symbolAnimationConfig->symbolNodes.push_back(symbolNode1); + symbolAnimationConfig->numNodes = symbolAnimationConfig->symbolNodes.size(); + /** + * @tc.steps: step2.1 test SCALE animation withe wholeymbol + */ + symbolAnimation.SetPublicAnimation(symbolAnimationConfig); + /** + * @tc.steps: step2.2 test SCALE animation withe two symbolNode and maskLayer + */ + symbolAnimationConfig->animationMode = 0; // 0 is bylayer + TextEngine::SymbolNode symbolNode2; + symbolNode2.animationIndex = 1; + symbolNode2.isMask = true; + symbolAnimationConfig->symbolNodes.push_back(symbolNode2); + symbolAnimationConfig->numNodes = symbolAnimationConfig->symbolNodes.size(); + symbolAnimation.SetPublicAnimation(symbolAnimationConfig); + NotifyStartAnimation(); + GTEST_LOG_(INFO) << "RSSymbolAnimationTest SetPublicAnimation001 end"; +} + +/** + * @tc.name: SetPublicAnimation002 + * @tc.desc: SetPublicAnimation of RSSymbolAnimationTest + * @tc.type: FUNC + */ +HWTEST_F(RSSymbolAnimationTest, SetPublicAnimation002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RSSymbolAnimationTest SetPublicAnimation002 start"; + /** + * @tc.steps: step1. init data + */ + auto symbolAnimation = RSSymbolAnimation(); + symbolAnimation.SetNode(rootNode); + auto symbolAnimationConfig = std::make_shared(); + symbolAnimationConfig->symbolSpanId = 20; // the 20 is the unique ID of a symbol + symbolAnimationConfig->effectStrategy = Drawing::DrawingEffectStrategy::SCALE; + symbolAnimationConfig->animationStart = true; + symbolAnimationConfig->animationMode = 0; // 0 is bylayer + // init symbolNode + Drawing::Path path; + path.AddCircle(100, 100, 50); // 100 x, 100y, 50 radius + Drawing::DrawingHMSymbolData symbol; + symbol.path_ = path; + TextEngine::SymbolNode symbolNode1; + symbolNode1.symbolData = symbol; + symbolNode1.nodeBoundary = {100, 100, 50, 50}; // 100 x, 100 y, 50 width, 50 height + symbolAnimationConfig->symbolNodes.push_back(symbolNode1); + TextEngine::SymbolNode symbolNode2; + symbolNode2.animationIndex = 1; + symbolAnimationConfig->symbolNodes.push_back(symbolNode2); + TextEngine::SymbolNode symbolNode3; + symbolNode3.animationIndex = -1; // -1 is the symbolNode whitout effect + symbolAnimationConfig->symbolNodes.push_back(symbolNode3); + symbolAnimationConfig->numNodes = symbolAnimationConfig->symbolNodes.size(); + /** + * @tc.steps: step2. start test SCALE animation withe three symbolnodes + */ + symbolAnimation.SetPublicAnimation(symbolAnimationConfig); + NotifyStartAnimation(); + GTEST_LOG_(INFO) << "RSSymbolAnimationTest SetPublicAnimation002 end"; +} + +/** + * @tc.name: SetPublicAnimation003 + * @tc.desc: SetPublicAnimation of RSSymbolAnimationTest + * @tc.type: FUNC + */ +HWTEST_F(RSSymbolAnimationTest, SetPublicAnimation003, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RSSymbolAnimationTest SetPublicAnimation003 start"; + /** + * @tc.steps: step1. init data + */ + auto symbolAnimation = RSSymbolAnimation(); + symbolAnimation.SetNode(rootNode); + auto symbolAnimationConfig = std::make_shared(); + symbolAnimationConfig->symbolSpanId = 21; // the 20 is the unique ID of a symbol + symbolAnimationConfig->effectStrategy = Drawing::DrawingEffectStrategy::SCALE; + symbolAnimationConfig->animationStart = true; + // init symbolNode + TextEngine::SymbolNode symbolNode; + symbolAnimationConfig->symbolNodes.push_back(symbolNode); + symbolNode.animationIndex = 1; // 1 is index of animation + symbolAnimationConfig->symbolNodes.push_back(symbolNode); + symbolNode.animationIndex = 2; // 2 is index of animation + symbolAnimationConfig->symbolNodes.push_back(symbolNode); + symbolNode.animationIndex = 3; // 3 is index of animation + symbolAnimationConfig->symbolNodes.push_back(symbolNode); + symbolNode.animationIndex = 4; // 4 is index of animation + symbolAnimationConfig->symbolNodes.push_back(symbolNode); + symbolAnimationConfig->numNodes = symbolAnimationConfig->symbolNodes.size(); + /** + * @tc.steps: step2.1 start test SCALE animation withe five symbolnodes + */ + symbolAnimation.SetPublicAnimation(symbolAnimationConfig); + /** + * @tc.steps: step2.2 start test VARIABLE_COLOR animation withe five symbolnodes + */ + symbolAnimationConfig->effectStrategy = Drawing::DrawingEffectStrategy::VARIABLE_COLOR; + symbolAnimation.SetPublicAnimation(symbolAnimationConfig); + NotifyStartAnimation(); + GTEST_LOG_(INFO) << "RSSymbolAnimationTest SetPublicAnimation003 end"; +} + +/** + * @tc.name: SetDisappearConfig001 + * @tc.desc: SetDisappearConfig of RSSymbolAnimationTest + * @tc.type: FUNC + */ +HWTEST_F(RSSymbolAnimationTest, SetDisappearConfig001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RSSymbolAnimationTest SetDisappearConfig001 start"; + /** + * @tc.steps: step1. init data + */ + auto symbolAnimation = RSSymbolAnimation(); + symbolAnimation.SetNode(rootNode); + auto symbolAnimationConfig = std::make_shared(); + auto disappearConfig = std::make_shared(); + std::shared_ptr nullptrConfig = nullptr; + /** + * @tc.steps: step2 start test SetDisappearConfig + */ + bool flag1 = symbolAnimation.SetDisappearConfig(nullptrConfig, nullptrConfig); + EXPECT_TRUE(flag1 == false); + + bool flag2 = symbolAnimation.SetDisappearConfig(symbolAnimationConfig, nullptrConfig); + EXPECT_TRUE(flag2 == false); + + bool flag3 = symbolAnimation.SetDisappearConfig(nullptrConfig, disappearConfig); + EXPECT_TRUE(flag3 == false); + + bool flag4 = symbolAnimation.SetDisappearConfig(symbolAnimationConfig, disappearConfig); + EXPECT_TRUE(flag4 == true); + GTEST_LOG_(INFO) << "RSSymbolAnimationTest SetDisappearConfig001 end"; +} + +/** + * @tc.name: SetDisappearConfig002 + * @tc.desc: SetDisappearConfig of RSSymbolAnimationTest + * @tc.type: FUNC + */ +HWTEST_F(RSSymbolAnimationTest, SetDisappearConfig002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RSSymbolAnimationTest SetDisappearConfig001 start"; + /** + * @tc.steps: step1. init data + */ + auto symbolAnimation = RSSymbolAnimation(); + symbolAnimation.SetNode(rootNode); + auto symbolAnimationConfig = std::make_shared(); + auto disappearConfig = std::make_shared(); + // init replaceNodesSwapMap + OHOS::Rosen::AnimationNodeConfig animationNodeConfig; + std::unordered_map nodeMap; + nodeMap.insert({1999, animationNodeConfig}); // 1999 is a nodeId + rootNode->replaceNodesSwapMap.insert({APPEAR_STATUS, nodeMap}); + /** + * @tc.steps: step2 start test SetDisappearConfig + */ + bool flag1 = symbolAnimation.SetDisappearConfig(symbolAnimationConfig, disappearConfig); + EXPECT_TRUE(flag1 == true); + GTEST_LOG_(INFO) << "RSSymbolAnimationTest SetDisappearConfig001 end"; +} + +/** + * @tc.name: SetReplaceAnimation001 + * @tc.desc: SetReplaceAnimation of RSSymbolAnimationTest + * @tc.type: FUNC + */ +HWTEST_F(RSSymbolAnimationTest, SetReplaceAnimation001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RSSymbolAnimationTest SetReplaceAnimation001 start"; + /** + * @tc.steps: step1. init data + */ + auto symbolAnimation = RSSymbolAnimation(); + symbolAnimation.SetNode(rootNode); + auto symbolAnimationConfig = std::make_shared(); + symbolAnimationConfig->symbolSpanId = 96; // 96 is the unique ID of a symbol + symbolAnimationConfig->effectStrategy = Drawing::DrawingEffectStrategy::REPLACE_APPEAR; + symbolAnimationConfig->animationMode = 1; // 1 is wholesymbol + symbolAnimationConfig->animationStart = true; + // init symbolNode + Drawing::Path path; + path.AddCircle(100, 100, 50); // 100 x, 100y, 50 radius + Drawing::DrawingHMSymbolData symbol; + symbol.path_ = path; + TextEngine::SymbolNode symbolNode1; + symbolNode1.symbolData = symbol; + symbolNode1.nodeBoundary = {100, 100, 50, 50}; // 100 x, 100 y, 50 width, 50 height + symbolAnimationConfig->symbolNodes.push_back(symbolNode1); + symbolAnimationConfig->numNodes = symbolAnimationConfig->symbolNodes.size(); + /** + * @tc.steps: step2.1 start test + */ + symbolAnimation.SetReplaceAnimation(symbolAnimationConfig); + /** + * @tc.steps: step2.2 start test replace two node + */ + symbolAnimation.SetReplaceAnimation(symbolAnimationConfig); + GTEST_LOG_(INFO) << "RSSymbolAnimationTest SetReplaceAnimation001 end"; +} + +/** + * @tc.name: ChooseAnimation001 + * @tc.desc: ChooseAnimation of RSSymbolAnimationTest + * @tc.type: FUNC + */ +HWTEST_F(RSSymbolAnimationTest, ChooseAnimation001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RSSymbolAnimationTest ChooseAnimation001 start"; + /** + * @tc.steps: step1. init data + */ + auto symbolAnimation = RSSymbolAnimation(); + symbolAnimation.SetNode(rootNode); + auto newCanvasNode = RSCanvasNode::Create(); + std::vector parameters; + auto symbolAnimationConfig = std::make_shared(); + /** + * @tc.steps: step2.1 test SCALE + */ + symbolAnimationConfig->effectStrategy = Drawing::DrawingEffectStrategy::SCALE; + symbolAnimation.ChooseAnimation(newCanvasNode, parameters, symbolAnimationConfig); + /** + * @tc.steps: step2.2 test VARIABLE_COLOR + */ + symbolAnimationConfig->effectStrategy = Drawing::DrawingEffectStrategy::VARIABLE_COLOR; + symbolAnimation.ChooseAnimation(newCanvasNode, parameters, symbolAnimationConfig); + /** + * @tc.steps: step2.3 test SYMBOL_PULSE + */ + symbolAnimationConfig->effectStrategy = Drawing::DrawingEffectStrategy::PULSE; + symbolAnimation.ChooseAnimation(newCanvasNode, parameters, symbolAnimationConfig); + /** + * @tc.steps: step2.4 test NONE + */ + symbolAnimationConfig->effectStrategy = Drawing::DrawingEffectStrategy::NONE; + bool flag = symbolAnimation.ChooseAnimation(newCanvasNode, parameters, symbolAnimationConfig); + EXPECT_TRUE(flag == false); + NotifyStartAnimation(); + GTEST_LOG_(INFO) << "RSSymbolAnimationTest ChooseAnimation001 end"; +} + /** * @tc.name: InitSupportAnimationTableTest * @tc.desc: Verify Init of SupportAnimationTable @@ -80,16 +424,50 @@ HWTEST_F(RSSymbolAnimationTest, PopNodeFromReplaceListTest001, TestSize.Level1) { GTEST_LOG_(INFO) << "RSSymbolAnimationTest PopNodeFromReplaceListTest001 start"; /** - * @tc.steps: step1. init data + * @tc.steps: step1.1 init data */ auto symbolAnimation = RSSymbolAnimation(); symbolAnimation.SetNode(rootNode); uint64_t symbolSpanId = 1; rootNode->canvasNodesListMap[symbolSpanId] = {{canvasNode->GetId(), canvasNode}}; symbolAnimation.PopNodeFromReplaceList(symbolSpanId); + /** + * @tc.steps: step1.2 if symbolSpanId not in canvasNodesListMap + */ + symbolSpanId = 9999; // random value + symbolAnimation.PopNodeFromReplaceList(symbolSpanId); GTEST_LOG_(INFO) << "RSSymbolAnimationTest PopNodeFromReplaceListTest001 end"; } +/** + * @tc.name: PopNodeFromReplaceListTest002 + * @tc.desc: Verify PopNode From Replace list map + * @tc.type: FUNC + */ +HWTEST_F(RSSymbolAnimationTest, PopNodeFromReplaceListTest002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RSSymbolAnimationTest PopNodeFromReplaceListTest002 start"; + /** + * @tc.steps: step1 if INVALID_STATUS&APPEAR_STATUS in replaceNodesSwapMap + */ + auto symbolAnimation = RSSymbolAnimation(); + symbolAnimation.SetNode(rootNode); + uint64_t symbolSpanId = 1; + rootNode->canvasNodesListMap[symbolSpanId] = {{canvasNode->GetId(), canvasNode}}; + Drawing::Path path; + path.AddCircle(100, 100, 50); // 100 x, 100y, 50 radius + Drawing::DrawingHMSymbolData symbol; + symbol.path_ = path; + TextEngine::SymbolNode symbolNode; + symbolNode.symbolData = symbol; + symbolNode.nodeBoundary = {100, 100, 50, 50}; + AnimationNodeConfig appearNodeConfig = {symbolNode, symbolNode.animationIndex}; + rootNode->replaceNodesSwapMap[1] = {{canvasNode->GetId(), appearNodeConfig}}; // APPEAR_STATUS = 1 + rootNode->replaceNodesSwapMap[-1] = {{canvasNode->GetId(), appearNodeConfig}}; // INVALID_STATUS = -1 + symbolAnimation.PopNodeFromReplaceList(symbolSpanId); + GTEST_LOG_(INFO) << "RSSymbolAnimationTest PopNodeFromReplaceListTest002 end"; +} + /** * @tc.name: BounceAnimationTest001 * @tc.desc: Verify the basic ability, BounceAnimation of RSSymbolAnimationTest From c37210ed32aff14b739aa1be8a736a11e0be30a9 Mon Sep 17 00:00:00 2001 From: zhangjz Date: Wed, 26 Jun 2024 16:54:19 +0800 Subject: [PATCH 036/247] symbol engine tdd fix data type Signed-off-by: zhangjz --- .../hm_symbol/hm_symbol_node_build_test.cpp | 16 ++++++++-------- .../rosen_text/hm_symbol/hm_symbol_run_test.cpp | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/rosen/test/2d_engine/unittest/rosen_text/hm_symbol/hm_symbol_node_build_test.cpp b/rosen/test/2d_engine/unittest/rosen_text/hm_symbol/hm_symbol_node_build_test.cpp index 7414c02f93..65f0492fb6 100644 --- a/rosen/test/2d_engine/unittest/rosen_text/hm_symbol/hm_symbol_node_build_test.cpp +++ b/rosen/test/2d_engine/unittest/rosen_text/hm_symbol/hm_symbol_node_build_test.cpp @@ -126,7 +126,7 @@ bool OHHmSymbolNodeBuildTest::SetSymbolAnimationTwo( */ HWTEST_F(OHHmSymbolNodeBuildTest, SymbolNodeBuild001, TestSize.Level1) { - std::pair offset = {100, 100}; // 100, 100 is the offset + std::pair offset = {100, 100}; // 100, 100 is the offset RSAnimationSetting animationSetting; RSHMSymbolData symbol; RSEffectStrategy effectMode = RSEffectStrategy::SCALE; @@ -140,7 +140,7 @@ HWTEST_F(OHHmSymbolNodeBuildTest, SymbolNodeBuild001, TestSize.Level1) */ HWTEST_F(OHHmSymbolNodeBuildTest, DecomposeSymbolAndDraw001, TestSize.Level1) { - std::pair offset = {100, 100}; // 100, 100 is the offset + std::pair offset = {100, 100}; // 100, 100 is the offset RSPath path; path.AddCircle(100, 100, 40); // 100 x, 100, 40 radius path.AddCircle(100, 100, 30, Drawing::PathDirection::CCW_DIRECTION); // 100 x, 100, 30 radius @@ -165,7 +165,7 @@ HWTEST_F(OHHmSymbolNodeBuildTest, DecomposeSymbolAndDraw001, TestSize.Level1) */ HWTEST_F(OHHmSymbolNodeBuildTest, DecomposeSymbolAndDraw002, TestSize.Level1) { - std::pair offset = {100, 100}; // 100, 100 is the offset + std::pair offset = {100, 100}; // 100, 100 is the offset RSPath path; path.AddCircle(100, 100, 50); // 100 x, 100, 50 radius path.AddCircle(100, 100, 30, Drawing::PathDirection::CCW_DIRECTION); // 100 x, 100, 30 radius @@ -190,7 +190,7 @@ HWTEST_F(OHHmSymbolNodeBuildTest, DecomposeSymbolAndDraw002, TestSize.Level1) */ HWTEST_F(OHHmSymbolNodeBuildTest, DecomposeSymbolAndDraw003, TestSize.Level1) { - std::pair offset = {100, 100}; // 100, 100 is the offset + std::pair offset = {100, 100}; // 100, 100 is the offset RSPath path; path.AddCircle(100, 100, 65); // 100 x, 100, 40 radius path.AddCircle(100, 100, 45); // 100 x, 100, 30 radius @@ -215,7 +215,7 @@ HWTEST_F(OHHmSymbolNodeBuildTest, DecomposeSymbolAndDraw003, TestSize.Level1) */ HWTEST_F(OHHmSymbolNodeBuildTest, DecomposeSymbolAndDraw004, TestSize.Level1) { - std::pair offset = {100, 100}; // 100, 100 is the offset + std::pair offset = {100, 100}; // 100, 100 is the offset RSPath path; path.AddCircle(100, 100, 50); // 100 x, 100, 50 radius path.AddCircle(100, 100, 30, Drawing::PathDirection::CCW_DIRECTION); // 100 x, 100, 30 radius @@ -240,7 +240,7 @@ HWTEST_F(OHHmSymbolNodeBuildTest, DecomposeSymbolAndDraw004, TestSize.Level1) */ HWTEST_F(OHHmSymbolNodeBuildTest, DecomposeSymbolAndDraw005, TestSize.Level1) { - std::pair offset = {100, 100}; // 100, 100 is the offset + std::pair offset = {100, 100}; // 100, 100 is the offset RSPath path; path.AddCircle(100, 100, 50); // 100 x, 100, 50 radius path.AddCircle(100, 100, 30, Drawing::PathDirection::CCW_DIRECTION); // 100 x, 100, 30 radius @@ -264,7 +264,7 @@ HWTEST_F(OHHmSymbolNodeBuildTest, DecomposeSymbolAndDraw005, TestSize.Level1) */ HWTEST_F(OHHmSymbolNodeBuildTest, DecomposeSymbolAndDraw006, TestSize.Level1) { - std::pair offset = {100, 100}; // 100, 100 is the offset + std::pair offset = {100, 100}; // 100, 100 is the offset RSPath path; path.AddCircle(100, 100, 65); // 100 x, 100, 40 radius path.AddCircle(100, 100, 45); // 100 x, 100, 30 radius @@ -303,7 +303,7 @@ HWTEST_F(OHHmSymbolNodeBuildTest, DecomposeSymbolAndDraw006, TestSize.Level1) */ HWTEST_F(OHHmSymbolNodeBuildTest, ClearAnimation001, TestSize.Level1) { - std::pair offset = {100, 100}; // 100, 100 is the offset + std::pair offset = {100, 100}; // 100, 100 is the offset RSHMSymbolData symbol; RSEffectStrategy effectMode = RSEffectStrategy::NONE; diff --git a/rosen/test/2d_engine/unittest/rosen_text/hm_symbol/hm_symbol_run_test.cpp b/rosen/test/2d_engine/unittest/rosen_text/hm_symbol/hm_symbol_run_test.cpp index 05d5de0c75..3abf82ee18 100644 --- a/rosen/test/2d_engine/unittest/rosen_text/hm_symbol/hm_symbol_run_test.cpp +++ b/rosen/test/2d_engine/unittest/rosen_text/hm_symbol/hm_symbol_run_test.cpp @@ -153,7 +153,7 @@ HWTEST_F(OHHmSymbolRunTest, SetSymbolRenderColor002, TestSize.Level1) HWTEST_F(OHHmSymbolRunTest, SymbolAnimation001, TestSize.Level1) { uint16_t glyphid = 3; // 3 is an existing GlyphID - std::pair offset = {100, 100}; // 100, 100 is the offset + std::pair offset = {100, 100}; // 100, 100 is the offset HMSymbolTxt symbolTxt; RSHMSymbolData symbol; HMSymbolRun hmSymbolRun = HMSymbolRun(); @@ -178,7 +178,7 @@ HWTEST_F(OHHmSymbolRunTest, SymbolAnimation001, TestSize.Level1) */ HWTEST_F(OHHmSymbolRunTest, ClearSymbolAnimation001, TestSize.Level1) { - std::pair offset = {100, 100}; // 100, 100 is the offset + std::pair offset = {100, 100}; // 100, 100 is the offset RSHMSymbolData symbol; HMSymbolRun hmSymbolRun = HMSymbolRun(); hmSymbolRun.ClearSymbolAnimation(symbol, offset); From 860b45c7c58fc99e8410970bbf22cbb86b2f5499 Mon Sep 17 00:00:00 2001 From: lmz Date: Wed, 26 Jun 2024 16:56:44 +0800 Subject: [PATCH 037/247] =?UTF-8?q?TDD=20=E6=8E=A5=E5=8F=A3=E8=A6=86?= =?UTF-8?q?=E7=9B=96=E7=8E=87=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lmz --- .../ndk/drawing_text_typography_test.cpp | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/rosen/test/2d_graphics/unittest/ndk/drawing_text_typography_test.cpp b/rosen/test/2d_graphics/unittest/ndk/drawing_text_typography_test.cpp index 66e78af8d4..db4fea6116 100644 --- a/rosen/test/2d_graphics/unittest/ndk/drawing_text_typography_test.cpp +++ b/rosen/test/2d_graphics/unittest/ndk/drawing_text_typography_test.cpp @@ -2843,4 +2843,35 @@ HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest103, TestSize.Level OH_Drawing_PathDestroy(cPath); OH_Drawing_CanvasDestroy(cCanvas); } + +/* + * @tc.name: OH_Drawing_TypographyTest105 + * @tc.desc: test for the text box + * @tc.type: FUNC + */ +HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest105, TestSize.Level1) +{ + OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle(); + OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle, + OH_Drawing_CreateFontCollection()); + OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler); + OH_Drawing_TextBox* textBox = OH_Drawing_TypographyGetRectsForPlaceholders(typography); + OH_Drawing_GetLeftFromTextBox(textBox, 0); + OH_Drawing_GetRightFromTextBox(textBox, 0); + OH_Drawing_GetTopFromTextBox(textBox, 0); + OH_Drawing_GetBottomFromTextBox(textBox, 0); + EXPECT_EQ(OH_Drawing_GetTextDirectionFromTextBox(textBox, 0), 0); + EXPECT_EQ(OH_Drawing_GetSizeOfTextBox(textBox), 0); + + OH_Drawing_PositionAndAffinity* positionAndAffinity = + OH_Drawing_TypographyGetGlyphPositionAtCoordinate(typography, 1, 0); + OH_Drawing_GetPositionFromPositionAndAffinity(positionAndAffinity); + OH_Drawing_GetAffinityFromPositionAndAffinity(positionAndAffinity); + + OH_Drawing_Range* range = OH_Drawing_TypographyGetWordBoundary(typography, 1); + OH_Drawing_GetStartFromRange(range); + OH_Drawing_GetEndFromRange(range); + OH_Drawing_TypographyGetLineHeight(typography, 1); + OH_Drawing_TypographyGetLineWidth(typography, 1); +} } \ No newline at end of file From e80bc54fd35dad91de75a784345c6ef006c26fef Mon Sep 17 00:00:00 2001 From: zhuxiaoyu Date: Wed, 26 Jun 2024 17:15:55 +0800 Subject: [PATCH 038/247] =?UTF-8?q?=E4=BF=AE=E5=A4=8DSCB=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E8=BF=9B=E7=A8=8B=E6=97=B6modifier=E5=8F=A0=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhuxiaoyu Change-Id: Ie6e81042c5a95320eb3b12d8cef67c19ee3b1de3 --- .../include/pipeline/rs_render_node.h | 1 + .../src/pipeline/rs_render_node.cpp | 27 ++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/rosen/modules/render_service_base/include/pipeline/rs_render_node.h b/rosen/modules/render_service_base/include/pipeline/rs_render_node.h index d18aa2f619..1d4c268ca4 100644 --- a/rosen/modules/render_service_base/include/pipeline/rs_render_node.h +++ b/rosen/modules/render_service_base/include/pipeline/rs_render_node.h @@ -573,6 +573,7 @@ public: void MarkNonGeometryChanged(); + void ApplyModifier(RSModifierContext& context, std::shared_ptr modifier); void ApplyModifiers(); void ApplyPositionZModifier(); virtual void UpdateRenderParams(); diff --git a/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp b/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp index 7479e61c43..917fc55ce0 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp @@ -2236,6 +2236,16 @@ void RSRenderNode::MarkForegroundFilterCache() } } +void RSRenderNode::ApplyModifier(RSModifierContext& context, std::shared_ptr modifier) +{ + auto modifierType = modifier->GetType(); + if (!dirtyTypes_.test(static_cast(modifierType))) { + return; + } + modifier->Apply(context); + isOnlyBasicGeoTransform_ = isOnlyBasicGeoTransform_ && BASIC_GEOTRANSFORM_ANIMATION_TYPE.count(modifierType); +} + void RSRenderNode::ApplyModifiers() { if (UNLIKELY(!isFullChildrenListValid_)) { @@ -2259,14 +2269,17 @@ void RSRenderNode::ApplyModifiers() GetMutableRenderProperties().ResetProperty(dirtyTypes_); // Apply modifiers - for (auto& [id, modifier] : modifiers_) { - auto modifierType = modifier->GetType(); - if (!dirtyTypes_.test(static_cast(modifierType))) { - continue; + auto displayNode = RSBaseRenderNode::ReinterpretCast(shared_from_this()); + if (displayNode && displayNode->GetCurrentScbPid() != -1) { + for (auto& [id, modifier] : modifiers_) { + if (ExtractPid(id) == displayNode->GetCurrentScbPid()) { + ApplyModifier(context, modifier); + } + } + } else { + for (auto& [id, modifier] : modifiers_) { + ApplyModifier(context, modifier); } - modifier->Apply(context); - isOnlyBasicGeoTransform_ = isOnlyBasicGeoTransform_ && - BASIC_GEOTRANSFORM_ANIMATION_TYPE.count(modifierType); } // execute hooks GetMutableRenderProperties().OnApplyModifiers(); From 5149e45ede174856bb01fbceab11fb7bf25c3097 Mon Sep 17 00:00:00 2001 From: ustc-tianyu Date: Wed, 26 Jun 2024 16:44:11 +0800 Subject: [PATCH 039/247] error code bugfix Signed-off-by: ustc-tianyu --- .../kits/napi/graphic/drawing/brush_napi/js_brush.cpp | 6 +++--- interfaces/kits/napi/graphic/drawing/pen_napi/js_pen.cpp | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/interfaces/kits/napi/graphic/drawing/brush_napi/js_brush.cpp b/interfaces/kits/napi/graphic/drawing/brush_napi/js_brush.cpp index 2e9e014bed..83bd49f293 100644 --- a/interfaces/kits/napi/graphic/drawing/brush_napi/js_brush.cpp +++ b/interfaces/kits/napi/graphic/drawing/brush_napi/js_brush.cpp @@ -141,7 +141,7 @@ napi_value JsBrush::SetColor(napi_env env, napi_callback_info info) GET_COLOR_PARAM(ARGC_THREE, blue); drawingColor = Color::ColorQuadSetARGB(alpha, red, green, blue); } else { - return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, "Invalid params."); + return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, "Incorrect number of parameters."); } brush->SetColor(drawingColor); return nullptr; @@ -260,7 +260,7 @@ napi_value JsBrush::SetBlendMode(napi_env env, napi_callback_info info) CHECK_PARAM_NUMBER_WITHOUT_OPTIONAL_PARAMS(argv, ARGC_ONE); int32_t mode = 0; - GET_INT32_CHECK_GE_ZERO_PARAM(ARGC_ZERO, mode); + GET_ENUM_PARAM(ARGC_ZERO, mode, 0, static_cast(BlendMode::LUMINOSITY)); brush->SetBlendMode(static_cast(mode)); return nullptr; @@ -270,7 +270,7 @@ napi_value JsBrush::SetShadowLayer(napi_env env, napi_callback_info info) { JsBrush* jsBrush = CheckParamsAndGetThis(env, info); if (jsBrush == nullptr) { - ROSEN_LOGE("JsBrush::SetMaskFilter jsBrush is nullptr"); + ROSEN_LOGE("JsBrush::SetShadowLayer jsBrush is nullptr"); return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, "Invalid params."); } Brush* brush = jsBrush->GetBrush(); diff --git a/interfaces/kits/napi/graphic/drawing/pen_napi/js_pen.cpp b/interfaces/kits/napi/graphic/drawing/pen_napi/js_pen.cpp index bd207e36bc..9863fe9b04 100644 --- a/interfaces/kits/napi/graphic/drawing/pen_napi/js_pen.cpp +++ b/interfaces/kits/napi/graphic/drawing/pen_napi/js_pen.cpp @@ -220,7 +220,8 @@ napi_value JsPen::SetAlpha(napi_env env, napi_callback_info info) int32_t alpha = 0; if (!ConvertFromJsNumber(env, argv[ARGC_ZERO], alpha, 0, Color::RGB_MAX)) { ROSEN_LOGE("JsPen::SetAlpha Argv[0] is invalid"); - return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, "Invalid params."); + return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, + "Parameter verification failed. The alpha range must be [0, 255]."); } pen->SetAlpha(alpha); From e77af01dc9118b4900a1637a7e359d662bf9cb7e Mon Sep 17 00:00:00 2001 From: jiangwenyu Date: Wed, 26 Jun 2024 10:44:41 +0000 Subject: [PATCH 040/247] =?UTF-8?q?trace=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jiangwenyu --- .../core/drawable/rs_surface_render_node_drawable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp index 4a5de25f25..ede2f940c1 100644 --- a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp @@ -298,7 +298,7 @@ void RSSurfaceRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) } const auto &absDrawRect = surfaceParams->GetAbsDrawRect(); // warning : don't delete this trace or change trace level to optional !!! - RS_TRACE_NAME_FMT("RSSurfaceRenderNodeDrawable::OnDraw:[%s] (%d %d %d %d)Alpha: %f", name_.c_str(), + RS_TRACE_NAME_FMT("RSSurfaceRenderNodeDrawable::OnDraw:[%s] (%d, %d, %d, %d)Alpha: %f", name_.c_str(), absDrawRect.left_, absDrawRect.top_, absDrawRect.width_, absDrawRect.height_, surfaceNode->GetGlobalAlpha()); RS_LOGD("RSSurfaceRenderNodeDrawable::OnDraw node:%{public}" PRIu64 ",child size:%{public}u," From 484bfba1f7c081256b94fa64f7bd401fc6783265 Mon Sep 17 00:00:00 2001 From: p30061306 Date: Wed, 26 Jun 2024 19:24:19 +0800 Subject: [PATCH 041/247] =?UTF-8?q?Description:=E4=BF=AE=E5=A4=8Dpreviewer?= =?UTF-8?q?=E9=A2=84=E8=A7=88=E7=89=88=E6=97=A0=E6=B3=95=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E5=BC=95=E7=94=A8icu=E5=BA=93=E9=97=AE=E9=A2=98=20Team:OTHER?= =?UTF-8?q?=20Feature=20or=20Bugfix:Bugfix=20Binary=20Source:No=20PrivateC?= =?UTF-8?q?ode(Yes/No):No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: p30061306 --- adapter/ohos/build/common.gni | 14 ++++++++++++++ adapter/ohos/build/config.gni | 2 +- adapter/ohos/build/config_ng.gni | 3 ++- adapter/preview/build/config_linux.gni | 3 +++ adapter/preview/build/config_mac.gni | 5 ++++- adapter/preview/build/config_windows.gni | 3 +++ adapter/preview/build/preview_common.gni | 16 ++++++++++++++++ 7 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 adapter/ohos/build/common.gni create mode 100644 adapter/preview/build/preview_common.gni diff --git a/adapter/ohos/build/common.gni b/adapter/ohos/build/common.gni new file mode 100644 index 0000000000..9eb9b5203c --- /dev/null +++ b/adapter/ohos/build/common.gni @@ -0,0 +1,14 @@ +# 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. + +use_external_icu = "shared" \ No newline at end of file diff --git a/adapter/ohos/build/config.gni b/adapter/ohos/build/config.gni index af25dee540..fc3b8cb914 100644 --- a/adapter/ohos/build/config.gni +++ b/adapter/ohos/build/config.gni @@ -11,11 +11,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("common.gni") import("//build/ohos.gni") form_components_support = true plugin_components_support = true -use_external_icu = "shared" defines = [ "FORM_SUPPORTED", diff --git a/adapter/ohos/build/config_ng.gni b/adapter/ohos/build/config_ng.gni index edfff65849..c0a80f8044 100644 --- a/adapter/ohos/build/config_ng.gni +++ b/adapter/ohos/build/config_ng.gni @@ -11,9 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("common.gni") + form_components_support = false plugin_components_support = false -use_external_icu = "shared" defines = [ "NG_BUILD" ] diff --git a/adapter/preview/build/config_linux.gni b/adapter/preview/build/config_linux.gni index 55a61a34bb..31de09e126 100644 --- a/adapter/preview/build/config_linux.gni +++ b/adapter/preview/build/config_linux.gni @@ -12,6 +12,9 @@ # limitations under the License. # linux platform defines and configs + +import("preview_common.gni") + defines = [ "LINUX_PLATFORM", "GPU_DISABLED", diff --git a/adapter/preview/build/config_mac.gni b/adapter/preview/build/config_mac.gni index 6449d7ce75..cda01207ac 100644 --- a/adapter/preview/build/config_mac.gni +++ b/adapter/preview/build/config_mac.gni @@ -11,7 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -# windows platform defines and configs +# mac platform defines and configs + +import("preview_common.gni") + defines = [ "MAC_PLATFORM", "SK_BUILD_FONT_MGR_FOR_PREVIEW_MAC", diff --git a/adapter/preview/build/config_windows.gni b/adapter/preview/build/config_windows.gni index 432358b1c0..e4766a4086 100644 --- a/adapter/preview/build/config_windows.gni +++ b/adapter/preview/build/config_windows.gni @@ -12,6 +12,9 @@ # limitations under the License. # windows platform defines and configs + +import("preview_common.gni") + defines = [ "WINDOWS_PLATFORM", "_USE_MATH_DEFINES", diff --git a/adapter/preview/build/preview_common.gni b/adapter/preview/build/preview_common.gni new file mode 100644 index 0000000000..a1474338fb --- /dev/null +++ b/adapter/preview/build/preview_common.gni @@ -0,0 +1,16 @@ +# 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. + +# previewer common defines and configs + +use_external_icu = "shared" \ No newline at end of file From b62aff5d0357d7e67bdd4e62f428f8cb8aa088c1 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Wed, 26 Jun 2024 20:08:53 +0800 Subject: [PATCH 042/247] =?UTF-8?q?Drawing=E7=BC=96=E7=A0=81=E8=87=AA?= =?UTF-8?q?=E6=A3=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangchao --- .../drawing_ndk/src/drawing_region.cpp | 4 +++ .../src/drawing_sampling_options.cpp | 5 ++++ .../drawing_ndk/src/drawing_shader_effect.cpp | 28 +++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/rosen/modules/2d_graphics/drawing_ndk/src/drawing_region.cpp b/rosen/modules/2d_graphics/drawing_ndk/src/drawing_region.cpp index 35e8e584ea..ca383d1583 100644 --- a/rosen/modules/2d_graphics/drawing_ndk/src/drawing_region.cpp +++ b/rosen/modules/2d_graphics/drawing_ndk/src/drawing_region.cpp @@ -61,6 +61,10 @@ bool OH_Drawing_RegionOp(OH_Drawing_Region* cRegion, const OH_Drawing_Region* cD g_drawingErrorCode = OH_DRAWING_ERROR_INVALID_PARAMETER; return false; } + if (op < REGION_OP_MODE_DIFFERENCE || op > REGION_OP_MODE_REPLACE) { + g_drawingErrorCode = OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE; + return false; + } return region->Op(*dst, static_cast(op)); } diff --git a/rosen/modules/2d_graphics/drawing_ndk/src/drawing_sampling_options.cpp b/rosen/modules/2d_graphics/drawing_ndk/src/drawing_sampling_options.cpp index b096547251..a1519a853c 100644 --- a/rosen/modules/2d_graphics/drawing_ndk/src/drawing_sampling_options.cpp +++ b/rosen/modules/2d_graphics/drawing_ndk/src/drawing_sampling_options.cpp @@ -15,6 +15,7 @@ #include "drawing_sampling_options.h" #include "utils/sampling_options.h" +#include "drawing_canvas_utils.h" using namespace OHOS; using namespace Rosen; @@ -27,6 +28,10 @@ static SamplingOptions* CastToSamplingOptions(OH_Drawing_SamplingOptions* cSampl OH_Drawing_SamplingOptions* OH_Drawing_SamplingOptionsCreate(OH_Drawing_FilterMode fm, OH_Drawing_MipmapMode mm) { + if (mm < MIPMAP_MODE_NONE || mm > MIPMAP_MODE_LINEAR) { + g_drawingErrorCode = OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE; + return nullptr; + } return (OH_Drawing_SamplingOptions*)new SamplingOptions(static_cast(fm), static_cast(mm)); } diff --git a/rosen/modules/2d_graphics/drawing_ndk/src/drawing_shader_effect.cpp b/rosen/modules/2d_graphics/drawing_ndk/src/drawing_shader_effect.cpp index bd2a91447c..aed4998a10 100644 --- a/rosen/modules/2d_graphics/drawing_ndk/src/drawing_shader_effect.cpp +++ b/rosen/modules/2d_graphics/drawing_ndk/src/drawing_shader_effect.cpp @@ -66,6 +66,10 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateLinearGradient(const OH_Dr g_drawingErrorCode = OH_DRAWING_ERROR_INVALID_PARAMETER; return nullptr; } + if (cTileMode < CLAMP || cTileMode > DECAL) { + g_drawingErrorCode = OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE; + return nullptr; + } std::vector colorsVector; std::vector posVector; for (uint32_t i = 0; i < size; i++) { @@ -88,6 +92,10 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMat g_drawingErrorCode = OH_DRAWING_ERROR_INVALID_PARAMETER; return nullptr; } + if (cTileMode < CLAMP || cTileMode > DECAL) { + g_drawingErrorCode = OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE; + return nullptr; + } std::vector colorsVector; std::vector posVector; for (uint32_t i = 0; i < size; i++) { @@ -110,6 +118,10 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateRadialGradient(const OH_Dr g_drawingErrorCode = OH_DRAWING_ERROR_INVALID_PARAMETER; return nullptr; } + if (cTileMode < CLAMP || cTileMode > DECAL) { + g_drawingErrorCode = OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE; + return nullptr; + } std::vector colorsVector; std::vector posVector; for (uint32_t i = 0; i < size; i++) { @@ -130,6 +142,10 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMat g_drawingErrorCode = OH_DRAWING_ERROR_INVALID_PARAMETER; return nullptr; } + if (cTileMode < CLAMP || cTileMode > DECAL) { + g_drawingErrorCode = OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE; + return nullptr; + } std::vector colorsVector; std::vector posVector; for (uint32_t i = 0; i < size; i++) { @@ -150,6 +166,10 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateSweepGradient(const OH_Dra g_drawingErrorCode = OH_DRAWING_ERROR_INVALID_PARAMETER; return nullptr; } + if (cTileMode < CLAMP || cTileMode > DECAL) { + g_drawingErrorCode = OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE; + return nullptr; + } std::vector colorsVector; std::vector posVector; for (uint32_t i = 0; i < size; i++) { @@ -170,6 +190,10 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateImageShader(OH_Drawing_Ima g_drawingErrorCode = OH_DRAWING_ERROR_INVALID_PARAMETER; return nullptr; } + if (tileX < CLAMP || tileX > DECAL || tileY < CLAMP || tileY > DECAL) { + g_drawingErrorCode = OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE; + return nullptr; + } if (cMatrix == nullptr) { Matrix matrix; return (OH_Drawing_ShaderEffect*)new ShaderEffect(ShaderEffect::ShaderEffectType::IMAGE, CastToImage(*cImage), @@ -188,6 +212,10 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(co g_drawingErrorCode = OH_DRAWING_ERROR_INVALID_PARAMETER; return nullptr; } + if (cTileMode < CLAMP || cTileMode > DECAL) { + g_drawingErrorCode = OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE; + return nullptr; + } std::vector colorsVector; std::vector posVector; for (uint32_t i = 0; i < size; i++) { From 6869b5451708474b7b5953938ec0eb37ee83b04d Mon Sep 17 00:00:00 2001 From: WenyiRoad Date: Wed, 26 Jun 2024 17:27:01 +0800 Subject: [PATCH 043/247] add tdd Signed-off-by: WenyiRoad --- ...nvas_drawing_render_node_drawable_test.cpp | 200 +++++++++++++++++- .../rs_display_render_node_drawable_test.cpp | 177 ++++++++++++++++ 2 files changed, 376 insertions(+), 1 deletion(-) diff --git a/rosen/test/render_service/render_service/unittest/drawable/rs_canvas_drawing_render_node_drawable_test.cpp b/rosen/test/render_service/render_service/unittest/drawable/rs_canvas_drawing_render_node_drawable_test.cpp index 0aa76c7aaa..4fb3469e01 100644 --- a/rosen/test/render_service/render_service/unittest/drawable/rs_canvas_drawing_render_node_drawable_test.cpp +++ b/rosen/test/render_service/render_service/unittest/drawable/rs_canvas_drawing_render_node_drawable_test.cpp @@ -23,12 +23,16 @@ using namespace testing::ext; using namespace OHOS::Rosen::DrawableV2; namespace OHOS::Rosen { +constexpr NodeId DEFAULT_ID = 0xFFFF; class RSCanvasDrawingRenderNodeDrawableTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); void SetUp() override; void TearDown() override; + + static inline NodeId id = DEFAULT_ID; + static std::shared_ptr CreateDrawable(); }; void RSCanvasDrawingRenderNodeDrawableTest::SetUpTestCase() {} @@ -36,13 +40,22 @@ void RSCanvasDrawingRenderNodeDrawableTest::TearDownTestCase() {} void RSCanvasDrawingRenderNodeDrawableTest::SetUp() {} void RSCanvasDrawingRenderNodeDrawableTest::TearDown() {} +std::shared_ptr RSCanvasDrawingRenderNodeDrawableTest::CreateDrawable() +{ + auto rsContext = std::make_shared(); + auto renderNode = std::make_shared(id, rsContext->weak_from_this()); + auto drawable = std::static_pointer_cast( + DrawableV2::RSRenderNodeDrawableAdapter::OnGenerate(renderNode)); + return drawable; +} + /** * @tc.name: CreateCanvasDrawingRenderNodeDrawableTest * @tc.desc: Test If CreateCanvasDrawingRenderNodeDrawable Can Be Created * @tc.type: FUNC * @tc.require: #I9NVOG */ -HWTEST(RSCanvasDrawingRenderNodeDrawableTest, CreateCanvasDrawingRenderNodeDrawable, TestSize.Level1) +HWTEST_F(RSCanvasDrawingRenderNodeDrawableTest, CreateCanvasDrawingRenderNodeDrawable, TestSize.Level1) { NodeId nodeId = 1; auto rsContext = std::make_shared(); @@ -50,4 +63,189 @@ HWTEST(RSCanvasDrawingRenderNodeDrawableTest, CreateCanvasDrawingRenderNodeDrawa auto drawable = RSCanvasDrawingRenderNodeDrawable::OnGenerate(canvasDrawingNode); ASSERT_NE(drawable, nullptr); } + +/** + * @tc.name: OnDraw + * @tc.desc: Test If OnDraw Can Run + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSCanvasDrawingRenderNodeDrawableTest, OnDrawTest, TestSize.Level1) +{ + auto drawable = RSCanvasDrawingRenderNodeDrawableTest::CreateDrawable(); + + Drawing::Canvas canvas; + drawable->renderParams_->canvasDrawingNodeSurfaceChanged_ = true; + drawable->OnDraw(canvas); + drawable->PlaybackInCorrespondThread(); + ASSERT_NE(drawable->renderParams_, nullptr); +} + +/** + * @tc.name: DrawRenderContent + * @tc.desc: Test If DrawRenderContent Can Run + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSCanvasDrawingRenderNodeDrawableTest, DrawRenderContentTest, TestSize.Level1) +{ + auto drawable = RSCanvasDrawingRenderNodeDrawableTest::CreateDrawable(); + + Drawing::Canvas canvas; + const Drawing::Rect dst(1.0f, 1.0f, 1.0f, 1.0f); + drawable->renderParams_->canvasDrawingNodeSurfaceChanged_ = true; + drawable->DrawRenderContent(canvas, dst); + + drawable->image_ = std::make_shared(); + drawable->DrawRenderContent(canvas, dst); + ASSERT_NE(drawable->image_, nullptr); +} + +/** + * @tc.name: InitSurface + * @tc.desc: Test If InitSurface Can Run + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSCanvasDrawingRenderNodeDrawableTest, InitSurfaceTest, TestSize.Level1) +{ + auto drawable = RSCanvasDrawingRenderNodeDrawableTest::CreateDrawable(); + + Drawing::Canvas drawingCanvas; + RSPaintFilterCanvas canvas(&drawingCanvas); + int width = 1; + int height = 1; + drawable->InitSurface(width, height, canvas); + + drawable->surface_ = std::make_shared(); + auto result = drawable->InitSurface(width, height, canvas); + ASSERT_EQ(result, true); +} + +/** + * @tc.name: Flush + * @tc.desc: Test If Flush Can Run + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSCanvasDrawingRenderNodeDrawableTest, FlushTest, TestSize.Level1) +{ + auto drawable = RSCanvasDrawingRenderNodeDrawableTest::CreateDrawable(); + + Drawing::Canvas drawingCanvas; + RSPaintFilterCanvas canvas(&drawingCanvas); + int width = 1; + float height = 1.0; + auto ctx = RSUniRenderThread::Instance().GetRSRenderThreadParams()->GetContext(); + if (ctx == nullptr) { + return; + } + drawable->Flush(width, height, ctx, id, canvas); + + drawable->recordingCanvas_ = std::make_unique(0, 0); + drawable->Flush(width, height, ctx, id, canvas); + + ASSERT_NE(drawable->canvas_, nullptr); +} + +/** + * @tc.name: ProcessCPURenderInBackgroundThread + * @tc.desc: Test If ProcessCPURenderInBackgroundThread Can Run + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSCanvasDrawingRenderNodeDrawableTest, ProcessCPURenderInBackgroundThreadTest, TestSize.Level1) +{ + auto drawable = RSCanvasDrawingRenderNodeDrawableTest::CreateDrawable(); + + auto ctx = RSUniRenderThread::Instance().GetRSRenderThreadParams()->GetContext(); + std::shared_ptr drawCmdList = std::make_shared(); + drawable->ProcessCPURenderInBackgroundThread(drawCmdList, ctx, id); + ASSERT_EQ(drawable->image_, nullptr); + + drawable->surface_ = static_cast( + RSRenderNodeDrawableAdapter::GetDrawableById(id).get())->surface_; + drawable->ProcessCPURenderInBackgroundThread(drawCmdList, ctx, id); + ASSERT_NE(drawable->surface_, nullptr); +} + +/** + * @tc.name: ResetSurface + * @tc.desc: Test If ResetSurface Can Run + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSCanvasDrawingRenderNodeDrawableTest, ResetSurfaceTest001, TestSize.Level1) +{ + auto drawable = RSCanvasDrawingRenderNodeDrawableTest::CreateDrawable(); + + drawable->surface_ = std::make_shared(); + drawable->ResetSurface(); + ASSERT_EQ(drawable->image_, nullptr); +} + +/** + * @tc.name: DrawCaptureImage + * @tc.desc: Test If DrawCaptureImage Can Run + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSCanvasDrawingRenderNodeDrawableTest, DrawCaptureImageTest, TestSize.Level1) +{ + auto drawable = RSCanvasDrawingRenderNodeDrawableTest::CreateDrawable(); + + Drawing::Canvas drawingCanvas; + RSPaintFilterCanvas canvas(&drawingCanvas); + drawable->DrawCaptureImage(canvas); + + drawable->image_ = std::make_shared(); + drawable->DrawCaptureImage(canvas); + + ASSERT_NE(drawable->image_, nullptr); +} + +/** + * @tc.name: ResetSurface + * @tc.desc: Test If ResetSurface Can Run + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSCanvasDrawingRenderNodeDrawableTest, ResetSurfaceTest002, TestSize.Level1) +{ + auto drawable = RSCanvasDrawingRenderNodeDrawableTest::CreateDrawable(); + + Drawing::Canvas drawingCanvas; + RSPaintFilterCanvas canvas(&drawingCanvas); + int width = 1; + int height = 1; + canvas.recordingState_ = true; + auto result = drawable->ResetSurface(width, height, canvas); + ASSERT_EQ(result, false); + + canvas.recordingState_ = false; + drawable->image_ = std::make_shared(); + result = drawable->ResetSurface(width, height, canvas); + ASSERT_EQ(result, false); +} + +#if (defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK)) +/** + * @tc.name: ResetSurfaceWithTexture + * @tc.desc: Test If ResetSurfaceWithTexture Can Run + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSCanvasDrawingRenderNodeDrawableTest, ResetSurfaceWithTextureTest, TestSize.Level1) +{ + auto drawable = RSCanvasDrawingRenderNodeDrawableTest::CreateDrawable(); + + Drawing::Canvas drawingCanvas; + RSPaintFilterCanvas canvas(&drawingCanvas); + int width = 1; + int height = 1; + + auto result = drawable->ResetSurfaceWithTexture(width, height, canvas); + ASSERT_EQ(result, false); +} +#endif } diff --git a/rosen/test/render_service/render_service/unittest/drawable/rs_display_render_node_drawable_test.cpp b/rosen/test/render_service/render_service/unittest/drawable/rs_display_render_node_drawable_test.cpp index 7f16c233ae..bbe45acbe4 100644 --- a/rosen/test/render_service/render_service/unittest/drawable/rs_display_render_node_drawable_test.cpp +++ b/rosen/test/render_service/render_service/unittest/drawable/rs_display_render_node_drawable_test.cpp @@ -20,6 +20,7 @@ #include "params/rs_render_thread_params.h" #include "pipeline/rs_display_render_node.h" #include "pipeline/rs_uni_render_thread.h" +#include "platform/drawing/rs_surface_converter.h" using namespace testing; using namespace testing::ext; @@ -45,6 +46,8 @@ public: static void TearDownTestCase(); void SetUp() override; void TearDown() override; + + static inline NodeId id = DEFAULT_ID; }; void RSDisplayRenderNodeDrawableTest::SetUpTestCase() {} @@ -61,6 +64,7 @@ void RSDisplayRenderNodeDrawableTest::SetUp() mirroredDrawable_ = RSDisplayRenderNodeDrawable::OnGenerate(mirroredNode_); if (drawable_ && mirroredDrawable_) { displayDrawable_ = static_cast(drawable_); + displayDrawable_->renderParams_ = std::make_unique(id); mirroredDisplayDrawable_ = static_cast(mirroredDrawable_); if (!drawable_->renderParams_ || !mirroredDrawable_->renderParams_) { RS_LOGE("RSDisplayRenderNodeDrawableTest: failed to init render params."); @@ -334,4 +338,177 @@ HWTEST_F(RSDisplayRenderNodeDrawableTest, CalculateVirtualDirtyForWiredScreen006 *renderNode_, renderFrame, *params, canvasMatrix); ASSERT_EQ(damageRects.size(), 0); } + +/** + * @tc.name: RequestFrame + * @tc.desc: Test RequestFrame + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSDisplayRenderNodeDrawableTest, RequestFrameTest, TestSize.Level1) +{ + ASSERT_NE(renderNode_, nullptr); + ASSERT_NE(displayDrawable_, nullptr); + ASSERT_NE(displayDrawable_->renderParams_, nullptr); + + auto params = static_cast(displayDrawable_->GetRenderParams().get()); + auto processor = RSProcessorFactory::CreateProcessor(params->GetCompositeType()); + auto result = displayDrawable_->RequestFrame(renderNode_, *params, processor); +} + +/** + * @tc.name: CheckDisplayNodeSkip + * @tc.desc: Test CheckDisplayNodeSkip + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSDisplayRenderNodeDrawableTest, CheckDisplayNodeSkipTest, TestSize.Level1) +{ + ASSERT_NE(renderNode_, nullptr); + ASSERT_NE(displayDrawable_, nullptr); + ASSERT_NE(displayDrawable_->renderParams_, nullptr); + + auto params = static_cast(displayDrawable_->GetRenderParams().get()); + auto processor = RSProcessorFactory::CreateProcessor(params->GetCompositeType()); + auto result = displayDrawable_->CheckDisplayNodeSkip(renderNode_, params, processor); + ASSERT_EQ(result, true); +} + +/** + * @tc.name: CreateUIFirstLayer + * @tc.desc: Test CreateUIFirstLayer + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSDisplayRenderNodeDrawableTest, CreateUIFirstLayerTest, TestSize.Level1) +{ + ASSERT_NE(renderNode_, nullptr); + ASSERT_NE(displayDrawable_, nullptr); + ASSERT_NE(displayDrawable_->renderParams_, nullptr); + + auto params = static_cast(displayDrawable_->GetRenderParams().get()); + auto processor = RSProcessorFactory::CreateProcessor(params->GetCompositeType()); + displayDrawable_->CreateUIFirstLayer(processor); +} + +/** + * @tc.name: RemoveClearMemoryTask + * @tc.desc: Test RemoveClearMemoryTask + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSDisplayRenderNodeDrawableTest, RemoveClearMemoryTaskTest, TestSize.Level1) +{ + ASSERT_NE(displayDrawable_, nullptr); + displayDrawable_->RemoveClearMemoryTask(); + displayDrawable_->PostClearMemoryTask(); +} + +/** + * @tc.name: OnDraw + * @tc.desc: Test OnDraw + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSDisplayRenderNodeDrawableTest, OnDrawTest, TestSize.Level1) +{ + ASSERT_NE(displayDrawable_, nullptr); + Drawing::Canvas canvas; + displayDrawable_->OnDraw(canvas); + ASSERT_NE(displayDrawable_->renderParams_, nullptr); +} + +/** + * @tc.name: DrawMirrorScreen + * @tc.desc: Test DrawMirrorScreen + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSDisplayRenderNodeDrawableTest, DrawMirrorScreenTest, TestSize.Level1) +{ + ASSERT_NE(renderNode_, nullptr); + ASSERT_NE(displayDrawable_, nullptr); + ASSERT_NE(displayDrawable_->renderParams_, nullptr); + + auto params = static_cast(displayDrawable_->GetRenderParams().get()); + auto processor = RSProcessorFactory::CreateProcessor(params->GetCompositeType()); + displayDrawable_->DrawMirrorScreen(renderNode_, *params, processor); +} + +/** + * @tc.name: CalculateVirtualDirty + * @tc.desc: Test CalculateVirtualDirty + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSDisplayRenderNodeDrawableTest, CalculateVirtualDirtyTest, TestSize.Level1) +{ + ASSERT_NE(renderNode_, nullptr); + ASSERT_NE(displayDrawable_, nullptr); + ASSERT_NE(displayDrawable_->renderParams_, nullptr); + + displayDrawable_->PrepareOffscreenRender(*renderNode_); + auto params = static_cast(displayDrawable_->GetRenderParams().get()); + auto processor = RSProcessorFactory::CreateProcessor(params->GetCompositeType()); + auto virtualProcesser = std::make_shared(); + Drawing::Matrix matrix = displayDrawable_->canvasBackup_->GetTotalMatrix(); + displayDrawable_->CalculateVirtualDirty(*renderNode_.get(), virtualProcesser, *params, matrix); +} + +/** + * @tc.name: DrawMirror + * @tc.desc: Test DrawMirror + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSDisplayRenderNodeDrawableTest, DrawMirrorTest, TestSize.Level1) +{ + ASSERT_NE(renderNode_, nullptr); + ASSERT_NE(displayDrawable_, nullptr); + ASSERT_NE(displayDrawable_->renderParams_, nullptr); + + displayDrawable_->PrepareOffscreenRender(*renderNode_); + auto params = static_cast(displayDrawable_->GetRenderParams().get()); + auto processor = RSProcessorFactory::CreateProcessor(params->GetCompositeType()); + auto virtualProcesser = std::make_shared(); + auto uniParam = RSUniRenderThread::Instance().GetRSRenderThreadParams().get(); + + displayDrawable_->DrawMirror(renderNode_, *params, virtualProcesser, + &RSDisplayRenderNodeDrawable::OnCapture, *uniParam); + displayDrawable_->DrawMirror(renderNode_, *params, virtualProcesser, + &RSDisplayRenderNodeDrawable::DrawHardwareEnabledNodes, *uniParam); +} + +/** + * @tc.name: DrawExpandScreen + * @tc.desc: Test DrawExpandScreen + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSDisplayRenderNodeDrawableTest, DrawExpandScreenTest, TestSize.Level1) +{ + ASSERT_NE(displayDrawable_, nullptr); + + auto virtualProcesser = new RSUniRenderVirtualProcessor(); + displayDrawable_->DrawExpandScreen(*virtualProcesser); +} + +/** + * @tc.name: WiredScreenProjection + * @tc.desc: Test WiredScreenProjection + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSDisplayRenderNodeDrawableTest, WiredScreenProjectionTest, TestSize.Level1) +{ + ASSERT_NE(renderNode_, nullptr); + ASSERT_NE(displayDrawable_, nullptr); + ASSERT_NE(displayDrawable_->renderParams_, nullptr); + + auto params = static_cast(displayDrawable_->GetRenderParams().get()); + auto processor = RSProcessorFactory::CreateProcessor(params->GetCompositeType()); + auto virtualProcesser = std::make_shared(); + Drawing::Matrix matrix = displayDrawable_->canvasBackup_->GetTotalMatrix(); + displayDrawable_->WiredScreenProjection(renderNode_, *params, virtualProcesser); +} } From c59502c474dac1b59c7b5a2ddac440d47dfcc747 Mon Sep 17 00:00:00 2001 From: ZhongJinghua Date: Wed, 26 Jun 2024 16:56:46 +0800 Subject: [PATCH 044/247] ColorManager: Format rectification Change-Id: I7375f49af97c2c00a38a5d209245dc23815536de Signed-off-by: ZhongJinghua --- interfaces/kits/napi/graphic/color_manager/BUILD.gn | 1 + .../render_service_base/src/render/rs_colorspace_convert.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/napi/graphic/color_manager/BUILD.gn b/interfaces/kits/napi/graphic/color_manager/BUILD.gn index c3006c6674..b82ff012ca 100644 --- a/interfaces/kits/napi/graphic/color_manager/BUILD.gn +++ b/interfaces/kits/napi/graphic/color_manager/BUILD.gn @@ -132,6 +132,7 @@ template("sendablecolorspacemanager_napi_source_set") { sanitize = { cfi = true cfi_cross_dso = true + cfi_vcall_icall_only = true debug = false } diff --git a/rosen/modules/render_service_base/src/render/rs_colorspace_convert.cpp b/rosen/modules/render_service_base/src/render/rs_colorspace_convert.cpp index eb41e02f1f..84fe06149e 100644 --- a/rosen/modules/render_service_base/src/render/rs_colorspace_convert.cpp +++ b/rosen/modules/render_service_base/src/render/rs_colorspace_convert.cpp @@ -40,8 +40,8 @@ bool RSColorSpaceConvert::ColorSpaceConvertor(std::shared_ptr& surfaceBuffer, Drawing::Paint& paint, GraphicColorGamut targetColorSpace, ScreenId screenId, uint32_t dynamicRangeMode) { - RS_LOGD("RSColorSpaceConvertor targetColorSpace:%{public}d. screenId:%{public}lu. dynamicRangeMode%{public}d", - targetColorSpace, screenId, dynamicRangeMode); + RS_LOGD("RSColorSpaceConvertor targetColorSpace:%{public}d. screenId:%{public}" PRIu64 ". \ + dynamicRangeMode%{public}u", targetColorSpace, screenId, dynamicRangeMode); VPEParameter parameter; if (inputShader == nullptr) { From 4b135473b2ec740fcb37d293b560c81f697815c5 Mon Sep 17 00:00:00 2001 From: yangfan479 Date: Wed, 26 Jun 2024 17:15:09 +0800 Subject: [PATCH 045/247] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E6=B0=B4=E5=8D=B0=E5=AF=BC=E8=87=B4airbar=E9=97=AA=E7=83=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98&=E5=AE=89=E5=85=A8=E6=B0=B4=E5=8D=B0?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E5=92=8C=E6=B6=88=E5=A4=B1=E7=9A=84=E5=B8=A7?= =?UTF-8?q?=E5=85=A8=E5=B1=8F=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangfan479 --- .../drawable/rs_display_render_node_drawable.cpp | 3 --- .../render_service/core/pipeline/rs_main_thread.cpp | 1 + .../render_service/core/pipeline/rs_main_thread.h | 7 +++++++ .../core/pipeline/rs_uni_render_visitor.cpp | 13 ++++++++++++- .../core/pipeline/rs_uni_render_visitor.h | 1 + .../unittest/pipeline/rs_main_thread_test.cpp | 12 ++++++++++++ .../pipeline/rs_uni_render_visitor_test.cpp | 13 +++++++++++++ 7 files changed, 46 insertions(+), 4 deletions(-) diff --git a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp index ba38f740ab..bf9e5d84d3 100644 --- a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp @@ -1423,8 +1423,6 @@ void RSDisplayRenderNodeDrawable::DrawWatermarkIfNeed(RSDisplayRenderParams& par std::swap(mainWidth, mainHeight); } } - Drawing::SaveLayerOps slr(nullptr, nullptr, Drawing::SaveLayerOps::INIT_WITH_PREVIOUS); - canvas.SaveLayer(slr); // avoid abnormal dsicard auto srcRect = Drawing::Rect(0, 0, image->GetWidth(), image->GetHeight()); auto dstRect = Drawing::Rect(0, 0, mainWidth, mainHeight); Drawing::Brush rectBrush; @@ -1432,7 +1430,6 @@ void RSDisplayRenderNodeDrawable::DrawWatermarkIfNeed(RSDisplayRenderParams& par canvas.DrawImageRect(*image, srcRect, dstRect, Drawing::SamplingOptions(), Drawing::SrcRectConstraint::STRICT_SRC_RECT_CONSTRAINT); canvas.DetachBrush(); - canvas.Restore(); } } diff --git a/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp b/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp index c6da9817a5..3e36f5edd4 100644 --- a/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp @@ -1885,6 +1885,7 @@ void RSMainThread::UniRender(std::shared_ptr rootNode) RSUniRenderUtil::ClearSurfaceIfNeed(nodeMap, displayNode, oldDisplayChildren_, deviceType_); RSUniRenderUtil::CacheSubThreadNodes(subThreadNodes_, subThreadNodes); } + lastWatermarkFlag_ = watermarkFlag_; isPartialRenderEnabledOfLastFrame_ = uniVisitor->GetIsPartialRenderEnabled(); isRegionDebugEnabledOfLastFrame_ = uniVisitor->GetIsRegionDebugEnabled(); // set params used in render thread diff --git a/rosen/modules/render_service/core/pipeline/rs_main_thread.h b/rosen/modules/render_service/core/pipeline/rs_main_thread.h index 9203206c16..c398ff2629 100644 --- a/rosen/modules/render_service/core/pipeline/rs_main_thread.h +++ b/rosen/modules/render_service/core/pipeline/rs_main_thread.h @@ -227,6 +227,12 @@ public: } std::shared_ptr GetWatermarkImg(); bool GetWatermarkFlag(); + + bool IsFirstOrLastFrameOfWatermark() const + { + return lastWatermarkFlag_ != watermarkFlag_; + } + uint64_t GetFrameCount() const { return frameCount_; @@ -579,6 +585,7 @@ private: std::mutex watermarkMutex_; std::shared_ptr watermarkImg_ = nullptr; bool watermarkFlag_ = false; + bool lastWatermarkFlag_ = false; bool doParallelComposition_ = false; bool hasProtectedLayer_ = false; diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp index 6ee4681e76..3d99eaf756 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp @@ -1212,7 +1212,8 @@ void RSUniRenderVisitor::ResetDisplayDirtyRegion() return; } bool ret = CheckScreenPowerChange() || CheckColorFilterChange() || - CheckCurtainScreenUsingStatusChange() || IsFirstFrameOfPartialRender(); + CheckCurtainScreenUsingStatusChange() || IsFirstFrameOfPartialRender() || + IsFirstOrLastFrameOfWatermark(); if (ret) { curDisplayDirtyManager_->ResetDirtyAsSurfaceSize(); RS_LOGD("RSUniRenderVisitor::ResetDisplayDirtyRegion on"); @@ -1246,6 +1247,16 @@ bool RSUniRenderVisitor::IsFirstFrameOfPartialRender() const return true; } +bool RSUniRenderVisitor::IsFirstOrLastFrameOfWatermark() const +{ + if (RSMainThread::Instance()->IsFirstOrLastFrameOfWatermark()) { + RS_LOGD("FirstOrLastFrameOfWatermark"); + return true; + } else { + return false; + } +} + void RSUniRenderVisitor::QuickPrepareDisplayRenderNode(RSDisplayRenderNode& node) { // 0. init display info diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.h b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.h index a462a97e74..1af6a4af59 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.h +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.h @@ -235,6 +235,7 @@ private: bool CheckColorFilterChange() const; bool CheckCurtainScreenUsingStatusChange() const; bool IsFirstFrameOfPartialRender() const; + bool IsFirstOrLastFrameOfWatermark() const; void CollectFilterInfoAndUpdateDirty(RSRenderNode& node, RSDirtyRegionManager& dirtyManager, const RectI& globalFilterRect); RectI GetVisibleEffectDirty(RSRenderNode& node) const; diff --git a/rosen/test/render_service/render_service/unittest/pipeline/rs_main_thread_test.cpp b/rosen/test/render_service/render_service/unittest/pipeline/rs_main_thread_test.cpp index 5226c647d8..beec3e9509 100644 --- a/rosen/test/render_service/render_service/unittest/pipeline/rs_main_thread_test.cpp +++ b/rosen/test/render_service/render_service/unittest/pipeline/rs_main_thread_test.cpp @@ -840,6 +840,18 @@ HWTEST_F(RSMainThreadTest, GetWatermarkImg, TestSize.Level1) mainThread->GetWatermarkImg(); } +/** + * @tc.name: IsFirstOrLastFrameOfWatermark + * @tc.desc: IsFirstOrLastFrameOfWatermark test + * @tc.type: FUNC + * @tc.require: issueI7HDVG + */ +HWTEST_F(RSMainThreadTest, IsFirstOrLastFrameOfWatermark, TestSize.Level1) +{ + auto mainThread = RSMainThread::Instance(); + mainThread->IsFirstOrLastFrameOfWatermark(); +} + /** * @tc.name: DoParallelComposition * @tc.desc: DoParallelComposition test diff --git a/rosen/test/render_service/render_service/unittest/pipeline/rs_uni_render_visitor_test.cpp b/rosen/test/render_service/render_service/unittest/pipeline/rs_uni_render_visitor_test.cpp index e6093f3f58..8ea32adecc 100644 --- a/rosen/test/render_service/render_service/unittest/pipeline/rs_uni_render_visitor_test.cpp +++ b/rosen/test/render_service/render_service/unittest/pipeline/rs_uni_render_visitor_test.cpp @@ -1013,6 +1013,19 @@ HWTEST_F(RSUniRenderVisitorTest, CalcDirtyRegionForFilterNode004, TestSize.Level rsUniRenderVisitor->CalcDirtyRegionForFilterNode(rect, surfaceNode, node); } +/* + * @tc.name: IsFirstOrLastFrameOfWatermark + * @tc.desc: Test RSUniRenderVisitorTest.IsFirstOrLastFrameOfWatermark test + * @tc.type: FUNC + * @tc.require: issuesI9V0N7 + */ +HWTEST_F(RSUniRenderVisitorTest, IsFirstOrLastFrameOfWatermark, TestSize.Level1) +{ + auto rsUniRenderVisitor = std::make_shared(); + ASSERT_NE(rsUniRenderVisitor, nullptr); + rsUniRenderVisitor->IsFirstOrLastFrameOfWatermark(); +} + /** * @tc.name: CalcDirtyFilterRegion001 * @tc.desc: Test RSUniRenderVisitorTest.CalcDirtyFilterRegion when disPlayNode or disPlayNode.dirtyManager_ is null From 8be016d597095df805d9cac6ea464919e140ddf5 Mon Sep 17 00:00:00 2001 From: li-kiao Date: Wed, 26 Jun 2024 14:49:17 +0000 Subject: [PATCH 046/247] =?UTF-8?q?=E4=BF=AE=E6=94=B9Drawing=E8=87=AA?= =?UTF-8?q?=E6=A3=80=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-kiao Change-Id: I4cd4eaae67fa387ef7e8884186c806e1c33e284f --- .../drawing_ndk/src/drawing_path.cpp | 32 +++++++++++++++++++ .../drawing_ndk/src/drawing_pen.cpp | 8 +++++ 2 files changed, 40 insertions(+) diff --git a/rosen/modules/2d_graphics/drawing_ndk/src/drawing_path.cpp b/rosen/modules/2d_graphics/drawing_ndk/src/drawing_path.cpp index 4174f3254c..6d0e813216 100644 --- a/rosen/modules/2d_graphics/drawing_ndk/src/drawing_path.cpp +++ b/rosen/modules/2d_graphics/drawing_ndk/src/drawing_path.cpp @@ -253,6 +253,10 @@ void OH_Drawing_PathAddRoundRect(OH_Drawing_Path* cPath, void OH_Drawing_PathAddOvalWithInitialPoint(OH_Drawing_Path* cPath, const OH_Drawing_Rect* oval, uint32_t start, OH_Drawing_PathDirection dir) { + if (dir < PATH_DIRECTION_CW || dir > PATH_DIRECTION_CCW) { + g_drawingErrorCode = OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE; + return; + } if (oval == nullptr) { g_drawingErrorCode = OH_DRAWING_ERROR_INVALID_PARAMETER; return; @@ -303,6 +307,10 @@ void OH_Drawing_PathAddPath(OH_Drawing_Path* cPath, void OH_Drawing_PathAddPathWithMatrixAndMode(OH_Drawing_Path* cPath, const OH_Drawing_Path* src, const OH_Drawing_Matrix* cMatrix, OH_Drawing_PathAddMode mode) { + if (mode < PATH_ADD_MODE_APPEND || mode > PATH_ADD_MODE_EXTEND) { + g_drawingErrorCode = OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE; + return; + } Path* path = CastToPath(cPath); if (path == nullptr) { g_drawingErrorCode = OH_DRAWING_ERROR_INVALID_PARAMETER; @@ -323,6 +331,10 @@ void OH_Drawing_PathAddPathWithMatrixAndMode(OH_Drawing_Path* cPath, void OH_Drawing_PathAddPathWithMode(OH_Drawing_Path* cPath, const OH_Drawing_Path* src, OH_Drawing_PathAddMode mode) { + if (mode < PATH_ADD_MODE_APPEND || mode > PATH_ADD_MODE_EXTEND) { + g_drawingErrorCode = OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE; + return; + } Path* path = CastToPath(cPath); if (path == nullptr) { g_drawingErrorCode = OH_DRAWING_ERROR_INVALID_PARAMETER; @@ -339,6 +351,10 @@ void OH_Drawing_PathAddPathWithMode(OH_Drawing_Path* cPath, const OH_Drawing_Pat void OH_Drawing_PathAddPathWithOffsetAndMode(OH_Drawing_Path* cPath, const OH_Drawing_Path* src, float dx, float dy, OH_Drawing_PathAddMode mode) { + if (mode < PATH_ADD_MODE_APPEND || mode > PATH_ADD_MODE_EXTEND) { + g_drawingErrorCode = OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE; + return; + } Path* path = CastToPath(cPath); if (path == nullptr) { g_drawingErrorCode = OH_DRAWING_ERROR_INVALID_PARAMETER; @@ -354,6 +370,10 @@ void OH_Drawing_PathAddPathWithOffsetAndMode(OH_Drawing_Path* cPath, void OH_Drawing_PathAddOval(OH_Drawing_Path* cPath, const OH_Drawing_Rect* oval, OH_Drawing_PathDirection dir) { + if (dir < PATH_DIRECTION_CW || dir > PATH_DIRECTION_CCW) { + g_drawingErrorCode = OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE; + return; + } if (oval == nullptr) { g_drawingErrorCode = OH_DRAWING_ERROR_INVALID_PARAMETER; return; @@ -387,6 +407,10 @@ void OH_Drawing_PathAddPolygon(OH_Drawing_Path* cPath, const OH_Drawing_Point2D* void OH_Drawing_PathAddCircle(OH_Drawing_Path* cPath, float x, float y, float radius, OH_Drawing_PathDirection dir) { + if (dir < PATH_DIRECTION_CW || dir > PATH_DIRECTION_CCW) { + g_drawingErrorCode = OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE; + return; + } if (radius <= 0) { g_drawingErrorCode = OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE; return; @@ -544,6 +568,10 @@ bool OH_Drawing_PathGetPositionTangent(OH_Drawing_Path* cPath, bool forceClosed, bool OH_Drawing_PathOp(OH_Drawing_Path* cPath, const OH_Drawing_Path* src, OH_Drawing_PathOpMode op) { + if (op < PATH_OP_MODE_DIFFERENCE || op > PATH_OP_MODE_REVERSE_DIFFERENCE) { + g_drawingErrorCode = OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE; + return false; + } Path* path = CastToPath(cPath); Path* srcPath = CastToPath(const_cast(src)); if (path == nullptr || srcPath == nullptr) { @@ -556,6 +584,10 @@ bool OH_Drawing_PathOp(OH_Drawing_Path* cPath, const OH_Drawing_Path* src, OH_Dr bool OH_Drawing_PathGetMatrix(OH_Drawing_Path* cPath, bool forceClosed, float distance, OH_Drawing_Matrix* cMatrix, OH_Drawing_PathMeasureMatrixFlags flag) { + if (flag < GET_POSITION_MATRIX || flag > GET_POSITION_AND_TANGENT_MATRIX) { + g_drawingErrorCode = OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE; + return false; + } Path* path = CastToPath(cPath); Matrix* matrix = CastToMatrix(cMatrix); if (path == nullptr || matrix == nullptr) { diff --git a/rosen/modules/2d_graphics/drawing_ndk/src/drawing_pen.cpp b/rosen/modules/2d_graphics/drawing_ndk/src/drawing_pen.cpp index b2b207f2ea..1144fc6976 100644 --- a/rosen/modules/2d_graphics/drawing_ndk/src/drawing_pen.cpp +++ b/rosen/modules/2d_graphics/drawing_ndk/src/drawing_pen.cpp @@ -235,6 +235,10 @@ OH_Drawing_PenLineCapStyle OH_Drawing_PenGetCap(const OH_Drawing_Pen* cPen) void OH_Drawing_PenSetCap(OH_Drawing_Pen* cPen, OH_Drawing_PenLineCapStyle cCap) { + if (cCap < LINE_FLAT_CAP || cCap > LINE_ROUND_CAP) { + g_drawingErrorCode = OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE; + return; + } Pen* pen = CastToPen(cPen); if (pen == nullptr) { g_drawingErrorCode = OH_DRAWING_ERROR_INVALID_PARAMETER; @@ -257,6 +261,10 @@ OH_Drawing_PenLineJoinStyle OH_Drawing_PenGetJoin(const OH_Drawing_Pen* cPen) void OH_Drawing_PenSetJoin(OH_Drawing_Pen* cPen, OH_Drawing_PenLineJoinStyle cJoin) { + if (cJoin < LINE_MITER_JOIN || cJoin > LINE_BEVEL_JOIN) { + g_drawingErrorCode = OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE; + return; + } Pen* pen = CastToPen(cPen); if (pen == nullptr) { g_drawingErrorCode = OH_DRAWING_ERROR_INVALID_PARAMETER; From a3b729260116b258e9d7defff5a93f8a46170cde Mon Sep 17 00:00:00 2001 From: WenyiRoad Date: Wed, 26 Jun 2024 17:06:48 +0000 Subject: [PATCH 047/247] fix Signed-off-by: WenyiRoad --- .../rs_display_render_node_drawable_test.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/rosen/test/render_service/render_service/unittest/drawable/rs_display_render_node_drawable_test.cpp b/rosen/test/render_service/render_service/unittest/drawable/rs_display_render_node_drawable_test.cpp index bbe45acbe4..dae40861a9 100644 --- a/rosen/test/render_service/render_service/unittest/drawable/rs_display_render_node_drawable_test.cpp +++ b/rosen/test/render_service/render_service/unittest/drawable/rs_display_render_node_drawable_test.cpp @@ -391,19 +391,6 @@ HWTEST_F(RSDisplayRenderNodeDrawableTest, CreateUIFirstLayerTest, TestSize.Level displayDrawable_->CreateUIFirstLayer(processor); } -/** - * @tc.name: RemoveClearMemoryTask - * @tc.desc: Test RemoveClearMemoryTask - * @tc.type: FUNC - * @tc.require: #I9NVOG - */ -HWTEST_F(RSDisplayRenderNodeDrawableTest, RemoveClearMemoryTaskTest, TestSize.Level1) -{ - ASSERT_NE(displayDrawable_, nullptr); - displayDrawable_->RemoveClearMemoryTask(); - displayDrawable_->PostClearMemoryTask(); -} - /** * @tc.name: OnDraw * @tc.desc: Test OnDraw From ceb0256d963dc34f3fc1342c8a3d21c39afe3ff0 Mon Sep 17 00:00:00 2001 From: chenyifan12 <1484004766@qq.com> Date: Thu, 27 Jun 2024 01:23:35 +0000 Subject: [PATCH 048/247] update rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp. Signed-off-by: chenyifan12 <1484004766@qq.com> --- .../graphics_effect/src/ge_kawase_blur_shader_filter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp b/rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp index 13e10368d8..ce022637cd 100644 --- a/rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp +++ b/rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp @@ -280,9 +280,10 @@ void GEKawaseBlurShaderFilter::CheckInputImage(Drawing::Canvas& canvas, const st auto srcRect = Drawing::RectI(src.GetLeft(), src.GetTop(), src.GetRight(), src.GetBottom()); if (image->GetImageInfo().GetBound() != srcRect) { auto resizedImage = std::make_shared(); - auto gpu = canvas.GetGPUContext(); - if (resizedImage == nullptr || gpu == nullptr) { - LOGE("GEKawaseBlurShaderFilter::resize image failed, input nullptr"); + + auto gpuCtx = canvas.GetGPUContext(); + if (gpuCtx == nullptr || !(image->isValid(gpuCtx.get())) { + LOGE("GEKawaseBlurShaderFilter::CheckInputImage invalid image"); return; } if (resizedImage->BuildSubset(image, srcRect, *gpu)) { From 336c187dae9c01f85840e2d426efedf9def820f7 Mon Sep 17 00:00:00 2001 From: chenyifan12 <1484004766@qq.com> Date: Thu, 27 Jun 2024 01:25:43 +0000 Subject: [PATCH 049/247] update rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp. Signed-off-by: chenyifan12 <1484004766@qq.com> --- .../modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp b/rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp index ce022637cd..bd52d81f59 100644 --- a/rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp +++ b/rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp @@ -280,7 +280,6 @@ void GEKawaseBlurShaderFilter::CheckInputImage(Drawing::Canvas& canvas, const st auto srcRect = Drawing::RectI(src.GetLeft(), src.GetTop(), src.GetRight(), src.GetBottom()); if (image->GetImageInfo().GetBound() != srcRect) { auto resizedImage = std::make_shared(); - auto gpuCtx = canvas.GetGPUContext(); if (gpuCtx == nullptr || !(image->isValid(gpuCtx.get())) { LOGE("GEKawaseBlurShaderFilter::CheckInputImage invalid image"); From 48a3887cdf18e9c3c6ae58fec48143549da4ba50 Mon Sep 17 00:00:00 2001 From: siyuan Date: Thu, 27 Jun 2024 10:12:26 +0800 Subject: [PATCH 050/247] add attraction effect TDD Signed-off-by: siyuan --- .../unittest/pipeline/rs_render_node_test.cpp | 2 + .../unittest/property/rs_properties_test.cpp | 14 +++++++ .../unittest/property/rs_properties_test2.cpp | 10 +++++ .../rsmodifierextractor_fuzzer.cpp | 2 + .../rspropertymodifier_fuzzer.cpp | 25 ++++++++++++ .../rsshowingpropertiesfreezer_fuzzer.cpp | 40 +++++++++++++++++++ .../modifier/rs_modifier_extractor_test.cpp | 13 ++++++ .../unittest/ui/rs_node_test.cpp | 27 +++++++++++++ 8 files changed, 133 insertions(+) diff --git a/rosen/test/render_service/render_service_base/unittest/pipeline/rs_render_node_test.cpp b/rosen/test/render_service/render_service_base/unittest/pipeline/rs_render_node_test.cpp index 8bace64c89..c5ad471dbc 100644 --- a/rosen/test/render_service/render_service_base/unittest/pipeline/rs_render_node_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/pipeline/rs_render_node_test.cpp @@ -2108,6 +2108,7 @@ HWTEST_F(RSRenderNodeTest, ManageRenderingResourcesTest022, TestSize.Level1) nodeTest->renderContent_->renderProperties_.shadow_ = shadow; nodeTest->renderContent_->renderProperties_.shadow_->radius_ = 1.0f; nodeTest->renderContent_->renderProperties_.isSpherizeValid_ = true; + nodeTest->renderContent_->renderProperties_.isAttractionValid_ = true; nodeTest->cacheSurface_ = nullptr; EXPECT_TRUE(nodeTest->NeedInitCacheSurface()); @@ -2180,6 +2181,7 @@ HWTEST_F(RSRenderNodeTest, InitCacheSurfaceTest024, TestSize.Level1) nodeTest->renderContent_->renderProperties_.shadow_ = shadow; nodeTest->renderContent_->renderProperties_.shadow_->radius_ = 1.0f; nodeTest->renderContent_->renderProperties_.isSpherizeValid_ = false; + odeTest->renderContent_->renderProperties_.isAttractionValid_ = false; nodeTest->cacheSurface_ = nullptr; nodeTest->InitCacheSurface(&gpuContextTest1, funcTest1, 1); EXPECT_EQ(nodeTest->cacheSurface_, nullptr); diff --git a/rosen/test/render_service/render_service_base/unittest/property/rs_properties_test.cpp b/rosen/test/render_service/render_service_base/unittest/property/rs_properties_test.cpp index 7e60c0dde9..0f1ba46898 100644 --- a/rosen/test/render_service/render_service_base/unittest/property/rs_properties_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/property/rs_properties_test.cpp @@ -2570,6 +2570,20 @@ HWTEST_F(RSPropertiesTest, SetNGetSpherize001, TestSize.Level1) EXPECT_EQ(properties.GetSpherize(), spherizeDegree); } +/** + * @tc.name: SetNGetAttractionDstPoint001 + * @tc.desc: test + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSPropertiesTest, SetNGetAttractionDstPoint001, TestSize.Level1) +{ + RSProperties properties; + Vector2f attractionDstPoint = Vector2f(1.f, 1.f); + properties.SetAttractionDstPoint(attractionDstPoint); + EXPECT_EQ(properties.GetAttractionDstPoint(), attractionDstPoint); +} + /** * @tc.name: SetLightUpEffect001 * @tc.desc: test results of SetLightUpEffect diff --git a/rosen/test/render_service/render_service_base/unittest/property/rs_properties_test2.cpp b/rosen/test/render_service/render_service_base/unittest/property/rs_properties_test2.cpp index 9160049f60..b427f84fb1 100644 --- a/rosen/test/render_service/render_service_base/unittest/property/rs_properties_test2.cpp +++ b/rosen/test/render_service/render_service_base/unittest/property/rs_properties_test2.cpp @@ -230,6 +230,16 @@ HWTEST_F(PropertiesTest, UpdateFilterTest, TestSize.Level1) properties.UpdateFilter(); EXPECT_TRUE(properties.foregroundFilter_); + properties.foregroundEffectRadius_ = -0.1f; + properties.isAttractionValid_ = true; + properties.UpdateFilter(); + EXPECT_TRUE(properties.foregroundFilter_); + + properties.isAttractionValid_ = false; + properties.shadow_->imageMask_ = true; + properties.UpdateFilter(); + EXPECT_TRUE(properties.foregroundFilter_); + properties.shadow_->imageMask_ = false; properties.UpdateFilter(); EXPECT_TRUE(!properties.foregroundFilter_); diff --git a/rosen/test/render_service/render_service_client/fuzztest/rsmodifierextractor_fuzzer/rsmodifierextractor_fuzzer.cpp b/rosen/test/render_service/render_service_client/fuzztest/rsmodifierextractor_fuzzer/rsmodifierextractor_fuzzer.cpp index ff4ef2daaa..9f63d4a8a5 100755 --- a/rosen/test/render_service/render_service_client/fuzztest/rsmodifierextractor_fuzzer/rsmodifierextractor_fuzzer.cpp +++ b/rosen/test/render_service/render_service_client/fuzztest/rsmodifierextractor_fuzzer/rsmodifierextractor_fuzzer.cpp @@ -173,6 +173,8 @@ bool DoGet003(const uint8_t* data, size_t size) modifierExtractor.GetForegroundBlurColorMode(); modifierExtractor.GetForegroundBlurRadiusX(); modifierExtractor.GetForegroundBlurRadiusY(); + modifierExtractor.GetAttractionFractionValue(); + modifierExtractor.GetAttractionDstPointValue(); modifierExtractor.GetLightIntensity(); modifierExtractor.GetLightColor(); modifierExtractor.GetLightPosition(); diff --git a/rosen/test/render_service/render_service_client/fuzztest/rspropertymodifier_fuzzer/rspropertymodifier_fuzzer.cpp b/rosen/test/render_service/render_service_client/fuzztest/rspropertymodifier_fuzzer/rspropertymodifier_fuzzer.cpp index 24a5f107d0..393339828c 100755 --- a/rosen/test/render_service/render_service_client/fuzztest/rspropertymodifier_fuzzer/rspropertymodifier_fuzzer.cpp +++ b/rosen/test/render_service/render_service_client/fuzztest/rspropertymodifier_fuzzer/rspropertymodifier_fuzzer.cpp @@ -553,6 +553,30 @@ bool DoModifier010(const uint8_t* data, size_t size) shadowColorStrategymodifier->CreateRenderModifier(); return true; } + +bool DoModifier011(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + // test + float value = GetData(); + auto property = std::make_shared>(value); + auto attractionFractionModifier = std::make_shared(property); + attractionFractionModifier->GetModifierType(); + attractionFractionModifier->CreateRenderModifier(); + auto attractionDstPointModifier = std::make_shared(property); + attractionDstPointModifier->GetModifierType(); + attractionDstPointModifier->CreateRenderModifier(); + return true; +} + } // namespace Rosen } // namespace OHOS @@ -570,6 +594,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) OHOS::Rosen::DoModifier008(data, size); OHOS::Rosen::DoModifier009(data, size); OHOS::Rosen::DoModifier010(data, size); + OHOS::Rosen::DoModifier011(data, size); return 0; } diff --git a/rosen/test/render_service/render_service_client/fuzztest/rsshowingpropertiesfreezer_fuzzer/rsshowingpropertiesfreezer_fuzzer.cpp b/rosen/test/render_service/render_service_client/fuzztest/rsshowingpropertiesfreezer_fuzzer/rsshowingpropertiesfreezer_fuzzer.cpp index 0a71754a5a..b1bc68c2e7 100755 --- a/rosen/test/render_service/render_service_client/fuzztest/rsshowingpropertiesfreezer_fuzzer/rsshowingpropertiesfreezer_fuzzer.cpp +++ b/rosen/test/render_service/render_service_client/fuzztest/rsshowingpropertiesfreezer_fuzzer/rsshowingpropertiesfreezer_fuzzer.cpp @@ -714,6 +714,44 @@ bool DoGetSpherizeDegree(const uint8_t* data, size_t size) return true; } +bool DoGetAttractionFractionValue(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + // test + NodeId id = GetData(); + RSShowingPropertiesFreezer showingPropertiesFreezer(id); + showingPropertiesFreezer.GetAttractionFractionValue(); + + return true; +} + +bool DoGetAttractionDstPointValue(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + // test + NodeId id = GetData(); + RSShowingPropertiesFreezer showingPropertiesFreezer(id); + showingPropertiesFreezer.GetAttractionDstPointValue(); + + return true; +} + bool DoGetLightUpEffectDegree(const uint8_t* data, size_t size) { if (data == nullptr) { @@ -793,6 +831,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) OHOS::Rosen::DoGetShadowElevation(data, size); OHOS::Rosen::DoGetShadowRadius(data, size); OHOS::Rosen::DoGetSpherizeDegree(data, size); + OHOS::Rosen::DoGetAttractionDstPointValue(data, size); + OHOS::Rosen::DoGetAttractionDstPointValue(data, size); OHOS::Rosen::DoGetLightUpEffectDegree(data, size); OHOS::Rosen::DoGetDynamicDimDegree(data, size); return 0; diff --git a/rosen/test/render_service/render_service_client/unittest/modifier/rs_modifier_extractor_test.cpp b/rosen/test/render_service/render_service_client/unittest/modifier/rs_modifier_extractor_test.cpp index 104fa4da67..2818248dde 100644 --- a/rosen/test/render_service/render_service_client/unittest/modifier/rs_modifier_extractor_test.cpp +++ b/rosen/test/render_service/render_service_client/unittest/modifier/rs_modifier_extractor_test.cpp @@ -185,6 +185,19 @@ HWTEST_F(RSModifierExtractorTest, GetSpherizeDegree001, TestSize.Level1) EXPECT_TRUE(degree == 0.f); } +/** + * @tc.name: GetAttractionDstPointValue001 + * @tc.desc: test results of GetAttractionDstPointValue + * @tc.type: FUNC + * @tc.require: issueI9VXLH + */ +HWTEST_F(RSModifierExtractorTest, GetAttractionDstPointValue001, TestSize.Level1) +{ + auto extractor = std::make_shared(); + float attractionDstPoint = extractor->GetAttractionDstPointValue(); + EXPECT_TRUE(attractionDstPoint.x_ == 0.f); +} + /** * @tc.name: GetLightUpEffectDegree001 * @tc.desc: test results of GetLightUpEffectDegree diff --git a/rosen/test/render_service/render_service_client/unittest/ui/rs_node_test.cpp b/rosen/test/render_service/render_service_client/unittest/ui/rs_node_test.cpp index cc38fd0b10..4a607ca046 100644 --- a/rosen/test/render_service/render_service_client/unittest/ui/rs_node_test.cpp +++ b/rosen/test/render_service/render_service_client/unittest/ui/rs_node_test.cpp @@ -4100,6 +4100,19 @@ HWTEST_F(RSNodeTest, SetandGetSpherizeDegree001, TestSize.Level1) EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetSpherizeDegree(), spherizeDegree)); } +/** + * @tc.name: SetandGetSetAttractionEffectDstPoint001 + * @tc.desc: + * @tc.type:FUNC + */ +HWTEST_F(RSNodeTest, SetandGetSetAttractionEffectDstPoint001, TestSize.Level1) +{ + auto rsNode = RSCanvasNode::Create(); + Vector2f attractionDstPoint = { 100.0, 100.0 }; + rsNode->SetAttractionEffectDstPoint(attractionDstPoint); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetAttractionDstPointValue(), attractionDstPoint)); +} + /** * @tc.name: SetandGetLightUpEffectDegree001 * @tc.desc: @@ -5785,6 +5798,20 @@ HWTEST_F(RSNodeTest, SetSpherizeDegree, TestSize.Level1) EXPECT_NE(spherizeDegree, 0.f); } +/** + * @tc.name: SetAttractionEffectDstPoint + * @tc.desc: test results of SetAttractionEffectDstPoint + * @tc.type: FUNC + * @tc.require: issueI9KQ6R + */ +HWTEST_F(RSNodeTest, SetAttractionEffectDstPoint, TestSize.Level1) +{ + auto rsNode = RSCanvasNode::Create(); + Vector2f attractionDstPoint = { 100.0, 100.0 }; + rsNode->SetAttractionEffectDstPoint(attractionDstPoint); + EXPECT_NE(attractionDstPoint.x_, 0.f); +} + /** * @tc.name: SetLightUpEffectDegree * @tc.desc: test results of SetLightUpEffectDegree From 48651626ee8cad7bb3b3773d25079e14926fdcac Mon Sep 17 00:00:00 2001 From: linghao-ji Date: Thu, 27 Jun 2024 10:15:20 +0800 Subject: [PATCH 051/247] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8A=E6=8A=A5?= =?UTF-8?q?=E5=B1=8F=E5=B9=95=E8=BF=9E=E6=8E=A5=E5=89=8D=E4=B8=8A=E6=8A=A5?= =?UTF-8?q?=E6=96=AD=E5=BC=80=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: linghao-ji Change-Id: I80ebd17f83f31adada82a26216ffe6a0e20f4676 --- .../render_service/core/screen_manager/rs_screen_manager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rosen/modules/render_service/core/screen_manager/rs_screen_manager.cpp b/rosen/modules/render_service/core/screen_manager/rs_screen_manager.cpp index f884339cab..25ad75101d 100644 --- a/rosen/modules/render_service/core/screen_manager/rs_screen_manager.cpp +++ b/rosen/modules/render_service/core/screen_manager/rs_screen_manager.cpp @@ -541,7 +541,8 @@ void RSScreenManager::ProcessScreenConnectedLocked(std::shared_ptr &o ScreenId id = ToScreenId(output->GetScreenId()); RS_LOGI("RSScreenManager %{public}s The screen for id %{public}" PRIu64 " connected.", __func__, id); - if (screens_.count(id) == 1) { + auto it = screens_.find(id); + if (it != screens_.end() && it->second != nullptr) { RS_LOGW("RSScreenManager %{public}s The screen for id %{public}" PRIu64 " already existed.", __func__, id); // [PLANNING]: should we erase it and create a new one? From 783af49acca962e155aec1b9539433cd24a6b068 Mon Sep 17 00:00:00 2001 From: siyuan Date: Thu, 27 Jun 2024 10:27:42 +0800 Subject: [PATCH 052/247] add attraction effect TDD 1 Signed-off-by: siyuan --- .../rsshowingpropertiesfreezer_fuzzer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/test/render_service/render_service_client/fuzztest/rsshowingpropertiesfreezer_fuzzer/rsshowingpropertiesfreezer_fuzzer.cpp b/rosen/test/render_service/render_service_client/fuzztest/rsshowingpropertiesfreezer_fuzzer/rsshowingpropertiesfreezer_fuzzer.cpp index b1bc68c2e7..b423f9e155 100755 --- a/rosen/test/render_service/render_service_client/fuzztest/rsshowingpropertiesfreezer_fuzzer/rsshowingpropertiesfreezer_fuzzer.cpp +++ b/rosen/test/render_service/render_service_client/fuzztest/rsshowingpropertiesfreezer_fuzzer/rsshowingpropertiesfreezer_fuzzer.cpp @@ -831,7 +831,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) OHOS::Rosen::DoGetShadowElevation(data, size); OHOS::Rosen::DoGetShadowRadius(data, size); OHOS::Rosen::DoGetSpherizeDegree(data, size); - OHOS::Rosen::DoGetAttractionDstPointValue(data, size); + OHOS::Rosen::DoGetAttractionFractionValue(data, size); OHOS::Rosen::DoGetAttractionDstPointValue(data, size); OHOS::Rosen::DoGetLightUpEffectDegree(data, size); OHOS::Rosen::DoGetDynamicDimDegree(data, size); From 9b078546600c503c08ec91e789537be94323d6a4 Mon Sep 17 00:00:00 2001 From: siyuan Date: Thu, 27 Jun 2024 10:29:24 +0800 Subject: [PATCH 053/247] add attraction effect TDD 2 Signed-off-by: siyuan --- .../unittest/pipeline/rs_render_node_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/test/render_service/render_service_base/unittest/pipeline/rs_render_node_test.cpp b/rosen/test/render_service/render_service_base/unittest/pipeline/rs_render_node_test.cpp index c5ad471dbc..11f2b92bce 100644 --- a/rosen/test/render_service/render_service_base/unittest/pipeline/rs_render_node_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/pipeline/rs_render_node_test.cpp @@ -2181,7 +2181,7 @@ HWTEST_F(RSRenderNodeTest, InitCacheSurfaceTest024, TestSize.Level1) nodeTest->renderContent_->renderProperties_.shadow_ = shadow; nodeTest->renderContent_->renderProperties_.shadow_->radius_ = 1.0f; nodeTest->renderContent_->renderProperties_.isSpherizeValid_ = false; - odeTest->renderContent_->renderProperties_.isAttractionValid_ = false; + nodeTest->renderContent_->renderProperties_.isAttractionValid_ = false; nodeTest->cacheSurface_ = nullptr; nodeTest->InitCacheSurface(&gpuContextTest1, funcTest1, 1); EXPECT_EQ(nodeTest->cacheSurface_, nullptr); From 4e60c24aaa950409489cccc66c775dd2579cb1e9 Mon Sep 17 00:00:00 2001 From: zhangwt3562 Date: Wed, 26 Jun 2024 18:18:04 +0800 Subject: [PATCH 054/247] arctext0626 Signed-off-by: zhangwt3562 --- .../napi/graphic/drawing/path_napi/js_path.cpp | 16 ++++------------ .../graphic/text/paragraph_napi/js_paragraph.cpp | 1 - 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/interfaces/kits/napi/graphic/drawing/path_napi/js_path.cpp b/interfaces/kits/napi/graphic/drawing/path_napi/js_path.cpp index dcf0dba2b5..1bef9a04c0 100644 --- a/interfaces/kits/napi/graphic/drawing/path_napi/js_path.cpp +++ b/interfaces/kits/napi/graphic/drawing/path_napi/js_path.cpp @@ -147,7 +147,6 @@ napi_value JsPath::Reset(napi_env env, napi_callback_info info) napi_value JsPath::GetLength(napi_env env, napi_callback_info info) { - ROSEN_LOGE("liyan JsPath::GetLength"); JsPath* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnGetLength(env, info) : nullptr; } @@ -295,18 +294,11 @@ napi_value JsPath::OnGetLength(napi_env env, napi_callback_info info) ROSEN_LOGE("JsPath::OnGetLength path is nullptr"); return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, "Invalid params."); } - size_t argc = ARGC_ONE; - napi_value argv[ARGC_ONE] = { nullptr }; - napi_status status = napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - if (status != napi_ok || argc < ARGC_ONE) { - ROSEN_LOGE("JsPath::OnGetLength Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, "Invalid params."); - } + napi_value argv[ARGC_ONE] = {nullptr}; + CHECK_PARAM_NUMBER_WITHOUT_OPTIONAL_PARAMS(argv, ARGC_ONE); + bool forceClosed = false; - if (!(ConvertFromJsValue(env, argv[0], forceClosed))) { - ROSEN_LOGE("JsPath::OnGetLength Argv is invalid"); - return NapiGetUndefined(env); - } + GET_BOOLEAN_PARAM(ARGC_ZERO, forceClosed); double len = m_path->GetLength(forceClosed); return CreateJsNumber(env, len); } diff --git a/interfaces/kits/napi/graphic/text/paragraph_napi/js_paragraph.cpp b/interfaces/kits/napi/graphic/text/paragraph_napi/js_paragraph.cpp index 1ac8279f40..1104ac76cf 100755 --- a/interfaces/kits/napi/graphic/text/paragraph_napi/js_paragraph.cpp +++ b/interfaces/kits/napi/graphic/text/paragraph_napi/js_paragraph.cpp @@ -178,7 +178,6 @@ napi_value JsParagraph::OnPaint(napi_env env, napi_callback_info info) napi_value JsParagraph::PaintOnPath(napi_env env, napi_callback_info info) { - ROSEN_LOGE("liyan JsParagraph::PaintOnPath"); JsParagraph* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnPaintOnPath(env, info) : nullptr; } From fb17cbf191d72f8a938608d6d28e4a980394f0f6 Mon Sep 17 00:00:00 2001 From: lw19901203 Date: Thu, 27 Jun 2024 10:59:29 +0800 Subject: [PATCH 055/247] add c++ fuzz test Signed-off-by: lw19901203 --- .../test/2d_graphics/fuzztest/utils/BUILD.gn | 2 + .../fuzztest/utils/point3_fuzzer/BUILD.gn | 59 ++++++++++++++ .../fuzztest/utils/point3_fuzzer/corpus/init | 14 ++++ .../utils/point3_fuzzer/point3_fuzzer.cpp | 76 +++++++++++++++++++ .../utils/point3_fuzzer/point3_fuzzer.h | 21 +++++ .../fuzztest/utils/point3_fuzzer/project.xml | 25 ++++++ .../fuzztest/utils/scalar_fuzzer/BUILD.gn | 59 ++++++++++++++ .../fuzztest/utils/scalar_fuzzer/corpus/init | 14 ++++ .../fuzztest/utils/scalar_fuzzer/project.xml | 25 ++++++ .../utils/scalar_fuzzer/scalar_fuzzer.cpp | 54 +++++++++++++ .../utils/scalar_fuzzer/scalar_fuzzer.h | 21 +++++ 11 files changed, 370 insertions(+) create mode 100644 rosen/test/2d_graphics/fuzztest/utils/point3_fuzzer/BUILD.gn create mode 100644 rosen/test/2d_graphics/fuzztest/utils/point3_fuzzer/corpus/init create mode 100644 rosen/test/2d_graphics/fuzztest/utils/point3_fuzzer/point3_fuzzer.cpp create mode 100644 rosen/test/2d_graphics/fuzztest/utils/point3_fuzzer/point3_fuzzer.h create mode 100644 rosen/test/2d_graphics/fuzztest/utils/point3_fuzzer/project.xml create mode 100644 rosen/test/2d_graphics/fuzztest/utils/scalar_fuzzer/BUILD.gn create mode 100644 rosen/test/2d_graphics/fuzztest/utils/scalar_fuzzer/corpus/init create mode 100644 rosen/test/2d_graphics/fuzztest/utils/scalar_fuzzer/project.xml create mode 100644 rosen/test/2d_graphics/fuzztest/utils/scalar_fuzzer/scalar_fuzzer.cpp create mode 100644 rosen/test/2d_graphics/fuzztest/utils/scalar_fuzzer/scalar_fuzzer.h diff --git a/rosen/test/2d_graphics/fuzztest/utils/BUILD.gn b/rosen/test/2d_graphics/fuzztest/utils/BUILD.gn index 4327699c4a..d1f9cda5c0 100644 --- a/rosen/test/2d_graphics/fuzztest/utils/BUILD.gn +++ b/rosen/test/2d_graphics/fuzztest/utils/BUILD.gn @@ -17,7 +17,9 @@ group("fuzztest") { deps = [ "camera3d_fuzzer:fuzztest", "matrix_fuzzer:fuzztest", + "point3_fuzzer:fuzztest", "point_fuzzer:fuzztest", "rect_fuzzer:fuzztest", + "scalar_fuzzer:fuzztest", ] } diff --git a/rosen/test/2d_graphics/fuzztest/utils/point3_fuzzer/BUILD.gn b/rosen/test/2d_graphics/fuzztest/utils/point3_fuzzer/BUILD.gn new file mode 100644 index 0000000000..45cd918c93 --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/utils/point3_fuzzer/BUILD.gn @@ -0,0 +1,59 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +module_output_path = "graphic_2d/graphic_2d" + +##############################fuzztest########################################## +ohos_fuzztest("Point3FuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "../../../../..//test/2d_graphics/fuzztest/utils/point3_fuzzer" + + sources = [ + "get_object.h", + "point3_fuzzer.cpp", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + include_dirs = [ + "../../../../../modules/2d_graphics/include", + "../../../../../rosen/modules/2d_graphics/src", + "../../../../../test/2d_graphics/fuzztest", + ] + + deps = [ "../../../../../modules/2d_graphics:2d_graphics" ] + + part_name = "graphic_2d" + subsystem_name = "graphic" +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + + deps += [ + # deps file + ":Point3FuzzTest", + ] +} +############################################################################### diff --git a/rosen/test/2d_graphics/fuzztest/utils/point3_fuzzer/corpus/init b/rosen/test/2d_graphics/fuzztest/utils/point3_fuzzer/corpus/init new file mode 100644 index 0000000000..e7c3fecd8d --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/utils/point3_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# 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. + +FUZZ \ No newline at end of file diff --git a/rosen/test/2d_graphics/fuzztest/utils/point3_fuzzer/point3_fuzzer.cpp b/rosen/test/2d_graphics/fuzztest/utils/point3_fuzzer/point3_fuzzer.cpp new file mode 100644 index 0000000000..815a1b86ff --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/utils/point3_fuzzer/point3_fuzzer.cpp @@ -0,0 +1,76 @@ +/* + * 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 "point3_fuzzer.h" + +#include +#include +#include + +#include "get_object.h" +#include "utils/point3.h" + +namespace OHOS { +namespace Rosen { +namespace Drawing { +void Point3FuzzTest000(const uint8_t* data, size_t size) +{ + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + scalar x = GetObject(); + scalar y = GetObject(); + scalar z = GetObject(); + scalar scale = GetObject(); + scalar divisor = GetObject(); + + Point3 point3; + Point3 point3_1 = Point3(x, y, z); + Point3 point3_2 = Point3(point3_1); + + point3.SetX(x); + point3.GetX(); + point3.SetY(y); + point3.GetY(); + point3.SetZ(z); + point3.GetZ(); + + point3 += point3_1; + point3 -= point3_1; + point3 *= scale; + point3 /= divisor; + + point3 = point3_1 + point3_2; + point3 = point3_1 - point3_2; + point3 = scale * point3_2; + point3 = point3_1 * scale; + point3 = point3_1 / divisor; + + if (point3 == point3_1) {} + if (point3 != point3_1) {} +} +} // namespace Drawing +} // namespace Rosen +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::Rosen::Drawing::Point3FuzzTest000(data, size); + return 0; +} \ No newline at end of file diff --git a/rosen/test/2d_graphics/fuzztest/utils/point3_fuzzer/point3_fuzzer.h b/rosen/test/2d_graphics/fuzztest/utils/point3_fuzzer/point3_fuzzer.h new file mode 100644 index 0000000000..ed494e2ce8 --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/utils/point3_fuzzer/point3_fuzzer.h @@ -0,0 +1,21 @@ +/* + * 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 TEST_FUZZTEST_POINT3_FUZZER_H +#define TEST_FUZZTEST_POINT3_FUZZER_H + +#define FUZZ_PROJECT_NAME "point_fuzzer" + +#endif // TEST_FUZZTEST_POINT3_FUZZER_H \ No newline at end of file diff --git a/rosen/test/2d_graphics/fuzztest/utils/point3_fuzzer/project.xml b/rosen/test/2d_graphics/fuzztest/utils/point3_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/utils/point3_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/rosen/test/2d_graphics/fuzztest/utils/scalar_fuzzer/BUILD.gn b/rosen/test/2d_graphics/fuzztest/utils/scalar_fuzzer/BUILD.gn new file mode 100644 index 0000000000..e689a33f53 --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/utils/scalar_fuzzer/BUILD.gn @@ -0,0 +1,59 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +module_output_path = "graphic_2d/graphic_2d" + +##############################fuzztest########################################## +ohos_fuzztest("ScalarFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "../../../../../test/2d_graphics/fuzztest/utils/scalar_fuzzer" + + sources = [ + "get_object.h", + "scalar_fuzzer.cpp", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + include_dirs = [ + "../../../../../modules/2d_graphics/include", + "../../../../../modules/2d_graphics/src", + "../../../../../test/2d_graphics/fuzztest", + ] + + deps = [ "../../../../../modules/2d_graphics:2d_graphics" ] + + part_name = "graphic_2d" + subsystem_name = "graphic" +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + + deps += [ + # deps file + ":ScalarFuzzTest", + ] +} +############################################################################### diff --git a/rosen/test/2d_graphics/fuzztest/utils/scalar_fuzzer/corpus/init b/rosen/test/2d_graphics/fuzztest/utils/scalar_fuzzer/corpus/init new file mode 100644 index 0000000000..e7c3fecd8d --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/utils/scalar_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# 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. + +FUZZ \ No newline at end of file diff --git a/rosen/test/2d_graphics/fuzztest/utils/scalar_fuzzer/project.xml b/rosen/test/2d_graphics/fuzztest/utils/scalar_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/utils/scalar_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/rosen/test/2d_graphics/fuzztest/utils/scalar_fuzzer/scalar_fuzzer.cpp b/rosen/test/2d_graphics/fuzztest/utils/scalar_fuzzer/scalar_fuzzer.cpp new file mode 100644 index 0000000000..b01a205099 --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/utils/scalar_fuzzer/scalar_fuzzer.cpp @@ -0,0 +1,54 @@ +/* + * 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 "scalar_fuzzer.h" + +#include +#include +#include + +#include "get_object.h" +#include "utils/scalar.h" + +namespace OHOS { +namespace Rosen { +namespace Drawing { +void ScalarFuzzTest000(const uint8_t* data, size_t size) +{ + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + scalar a = GetObject(); + scalar b = GetObject(); + + IsScalarAlmostEqual(a, b); + ConvertRadiusToSigma(a); + ConvertSigmaToRadius(b); + ConvertRadiansToDegrees(a); +} +} // namespace Drawing +} // namespace Rosen +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::Rosen::Drawing::ScalarFuzzTest000(data, size); + + return 0; +} \ No newline at end of file diff --git a/rosen/test/2d_graphics/fuzztest/utils/scalar_fuzzer/scalar_fuzzer.h b/rosen/test/2d_graphics/fuzztest/utils/scalar_fuzzer/scalar_fuzzer.h new file mode 100644 index 0000000000..83c0e0807b --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/utils/scalar_fuzzer/scalar_fuzzer.h @@ -0,0 +1,21 @@ +/* + * 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 TEST_FUZZTEST_SCALAR_FUZZER_H +#define TEST_FUZZTEST_SCALAR_FUZZER_H + +#define FUZZ_PROJECT_NAME "scalar_fuzzer" + +#endif // TEST_FUZZTEST_SCALAR_FUZZER_H \ No newline at end of file From 4167701c678a0ce2bec47ad9ea5079d7c70e9e7a Mon Sep 17 00:00:00 2001 From: siyuan Date: Thu, 27 Jun 2024 11:03:58 +0800 Subject: [PATCH 056/247] add attraction effect TDD 3 Signed-off-by: siyuan --- .../unittest/modifier/rs_modifier_extractor_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/test/render_service/render_service_client/unittest/modifier/rs_modifier_extractor_test.cpp b/rosen/test/render_service/render_service_client/unittest/modifier/rs_modifier_extractor_test.cpp index 2818248dde..e699f8d8aa 100644 --- a/rosen/test/render_service/render_service_client/unittest/modifier/rs_modifier_extractor_test.cpp +++ b/rosen/test/render_service/render_service_client/unittest/modifier/rs_modifier_extractor_test.cpp @@ -194,7 +194,7 @@ HWTEST_F(RSModifierExtractorTest, GetSpherizeDegree001, TestSize.Level1) HWTEST_F(RSModifierExtractorTest, GetAttractionDstPointValue001, TestSize.Level1) { auto extractor = std::make_shared(); - float attractionDstPoint = extractor->GetAttractionDstPointValue(); + Vector2f attractionDstPoint = extractor->GetAttractionDstPointValue(); EXPECT_TRUE(attractionDstPoint.x_ == 0.f); } From 50643c9bd89a316caaeeade9af882da85c563f67 Mon Sep 17 00:00:00 2001 From: p30061306 Date: Thu, 27 Jun 2024 11:11:24 +0800 Subject: [PATCH 057/247] Description:format gni file Team:OTHER Feature or Bugfix:Bugfix Binary Source:No PrivateCode(Yes/No):No Signed-off-by: p30061306 --- adapter/ohos/build/common.gni | 2 +- adapter/preview/build/preview_common.gni | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/adapter/ohos/build/common.gni b/adapter/ohos/build/common.gni index 9eb9b5203c..ab355f6fbb 100644 --- a/adapter/ohos/build/common.gni +++ b/adapter/ohos/build/common.gni @@ -11,4 +11,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -use_external_icu = "shared" \ No newline at end of file +use_external_icu = "shared" diff --git a/adapter/preview/build/preview_common.gni b/adapter/preview/build/preview_common.gni index a1474338fb..8168a2a2ea 100644 --- a/adapter/preview/build/preview_common.gni +++ b/adapter/preview/build/preview_common.gni @@ -13,4 +13,4 @@ # previewer common defines and configs -use_external_icu = "shared" \ No newline at end of file +use_external_icu = "shared" From dc589cf4ed60c50cb76f7c0ad51bca88409f6aa8 Mon Sep 17 00:00:00 2001 From: chenyifan12 <1484004766@qq.com> Date: Thu, 27 Jun 2024 06:24:57 +0000 Subject: [PATCH 058/247] update rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp. Signed-off-by: chenyifan12 <1484004766@qq.com> --- .../graphics_effect/src/ge_kawase_blur_shader_filter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp b/rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp index bd52d81f59..765a91fb4c 100644 --- a/rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp +++ b/rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp @@ -281,7 +281,7 @@ void GEKawaseBlurShaderFilter::CheckInputImage(Drawing::Canvas& canvas, const st if (image->GetImageInfo().GetBound() != srcRect) { auto resizedImage = std::make_shared(); auto gpuCtx = canvas.GetGPUContext(); - if (gpuCtx == nullptr || !(image->isValid(gpuCtx.get())) { + if (gpuCtx == nullptr || !(image->IsValid(gpuCtx.get())) { LOGE("GEKawaseBlurShaderFilter::CheckInputImage invalid image"); return; } From fefb27b0cb04452250fa694d488e753fef301e02 Mon Sep 17 00:00:00 2001 From: liuqian71 Date: Wed, 26 Jun 2024 17:27:33 +0800 Subject: [PATCH 059/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E6=94=BE=E5=A4=A7=E9=95=9C=E7=AE=97=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuqian71 --- .../include/ge_magnifier_shader_filter.h | 13 +- .../include/ge_shader_filter_params.h | 31 --- .../include/ge_visual_effect_impl.h | 13 -- .../src/ge_magnifier_shader_filter.cpp | 195 +++++++++++++++--- .../modules/graphics_effect/src/ge_render.cpp | 3 +- .../src/ge_visual_effect_impl.cpp | 73 +------ .../graphics_effect/test/unittest/BUILD.gn | 1 + .../ge_magnifier_shader_filter_test.cpp | 175 ++++++++++++++++ .../include/command/rs_node_command.h | 5 - .../include/modifier/rs_modifiers_def.in | 2 +- .../include/property/rs_properties.h | 7 +- .../render/rs_magnifier_shader_filter.h | 13 +- .../transaction/rs_marshalling_helper.h | 2 - .../drawable/rs_property_drawable_utils.cpp | 3 +- .../platform/darwin/rs_marshalling_helper.cpp | 12 -- .../platform/ohos/rs_marshalling_helper.cpp | 81 -------- .../windows/rs_marshalling_helper.cpp | 12 -- .../src/property/rs_filter_cache_manager.cpp | 3 +- .../src/property/rs_properties.cpp | 16 +- .../src/property/rs_properties_painter.cpp | 3 +- .../src/render/rs_magnifier_shader_filter.cpp | 25 +-- .../core/modifier/rs_property.cpp | 6 - .../core/modifier/rs_property.h | 3 - .../render_service_client/core/ui/rs_node.cpp | 5 +- .../render_service_client/core/ui/rs_node.h | 2 +- .../unittest/property/rs_properties_test.cpp | 28 +++ .../unittest/render/BUILD.gn | 1 + .../rs_magnifier_shader_filter_test.cpp | 64 ++++++ .../unittest/ui/rs_node_test.cpp | 20 ++ 29 files changed, 495 insertions(+), 322 deletions(-) create mode 100644 rosen/modules/graphics_effect/test/unittest/ge_magnifier_shader_filter_test.cpp create mode 100644 rosen/test/render_service/render_service_base/unittest/render/rs_magnifier_shader_filter_test.cpp diff --git a/rosen/modules/graphics_effect/include/ge_magnifier_shader_filter.h b/rosen/modules/graphics_effect/include/ge_magnifier_shader_filter.h index 5d9aea3098..fc2c587d03 100644 --- a/rosen/modules/graphics_effect/include/ge_magnifier_shader_filter.h +++ b/rosen/modules/graphics_effect/include/ge_magnifier_shader_filter.h @@ -15,6 +15,8 @@ #ifndef GRAPHICS_EFFECT_GE_MAGNIFIER_SHADER_FILTER_H #define GRAPHICS_EFFECT_GE_MAGNIFIER_SHADER_FILTER_H +#include + #include "ge_shader_filter.h" #include "ge_visual_effect.h" @@ -28,6 +30,9 @@ namespace Rosen { class GEMagnifierParams { public: + explicit GEMagnifierParams() {} + ~GEMagnifierParams() = default; + float factor_ = 0.f; float width_ = 0.f; float height_ = 0.f; @@ -44,15 +49,11 @@ public: uint32_t gradientMaskColor2_ = 0x00000000; uint32_t outerContourColor1_ = 0x00000000; uint32_t outerContourColor2_ = 0x00000000; - - explicit GEMagnifierParams() {} - - ~GEMagnifierParams() = default; }; class GEMagnifierShaderFilter : public GEShaderFilter { public: - GEMagnifierShaderFilter(const Drawing::GEMagnifierShaderFilterParams& params); + GEMagnifierShaderFilter(); GEMagnifierShaderFilter(const GEMagnifierShaderFilter&) = delete; GEMagnifierShaderFilter operator=(const GEMagnifierShaderFilter&) = delete; ~GEMagnifierShaderFilter() override = default; @@ -66,7 +67,7 @@ private: std::shared_ptr MakeMagnifierShader( std::shared_ptr imageShader, float imageWidth, float imageHeight); bool InitMagnifierEffect(); - void ConvertToRgba(uint32_t rgba, float* color); + void ConvertToRgba(uint32_t rgba, float* color, int tupleSize); std::shared_ptr magnifierPara_ = nullptr; static std::shared_ptr magnifierShaderEffect_; diff --git a/rosen/modules/graphics_effect/include/ge_shader_filter_params.h b/rosen/modules/graphics_effect/include/ge_shader_filter_params.h index ea7618ec62..1d44e1e3ca 100644 --- a/rosen/modules/graphics_effect/include/ge_shader_filter_params.h +++ b/rosen/modules/graphics_effect/include/ge_shader_filter_params.h @@ -98,37 +98,6 @@ struct GELinearGradientBlurShaderFilterParams { }; constexpr char GE_FILTER_MAGNIFIER[] = "MAGNIFIER"; -constexpr char GE_FILTER_MAGNIFIER_FACTOR[] = "FACTOR"; -constexpr char GE_FILTER_MAGNIFIER_WIDTH[] = "WIDTH"; -constexpr char GE_FILTER_MAGNIFIER_HEIGHT[] = "HEIGHT"; -constexpr char GE_FILTER_MAGNIFIER_BORDER_WIDTH[] = "BORDERWIDTH"; -constexpr char GE_FILTER_MAGNIFIER_CORNER_RADIUS[] = "CORNERRADIUS"; -constexpr char GE_FILTER_MAGNIFIER_SHADOW_OFFSET_X[] = "SHADOWOFFSETX"; -constexpr char GE_FILTER_MAGNIFIER_SHADOW_OFFSET_Y[] = "SHADOWOFFSETY"; -constexpr char GE_FILTER_MAGNIFIER_SHADOW_SIZE[] = "SHADOWSIZE"; -constexpr char GE_FILTER_MAGNIFIER_SHADOW_STRENGTH[] = "SHADOWSTRENGTH"; -constexpr char GE_FILTER_MAGNIFIER_GRADIENT_MASK_COLOR_1[] = "GRADIENTMASKCOLOR1"; -constexpr char GE_FILTER_MAGNIFIER_GRADIENT_MASK_COLOR_2[] = "GRADIENTMASKCOLOR2"; -constexpr char GE_FILTER_MAGNIFIER_OUTER_CONTOUR_COLOR_1[] = "OUTERCONTOURCOLOR1"; -constexpr char GE_FILTER_MAGNIFIER_OUTER_CONTOUR_COLOR_2[] = "OUTERCONTOURCOLOR2"; -struct GEMagnifierShaderFilterParams { - float factor; - float width; - float height; - float borderWidth; - float cornerRadius; - - float shadowOffsetX; - float shadowOffsetY; - float shadowSize; - float shadowStrength; - - // rgba - uint32_t gradientMaskColor1; - uint32_t gradientMaskColor2; - uint32_t outerContourColor1; - uint32_t outerContourColor2; -}; } // namespace Drawing } // namespace Rosen diff --git a/rosen/modules/graphics_effect/include/ge_visual_effect_impl.h b/rosen/modules/graphics_effect/include/ge_visual_effect_impl.h index b7a4278b75..1329497438 100644 --- a/rosen/modules/graphics_effect/include/ge_visual_effect_impl.h +++ b/rosen/modules/graphics_effect/include/ge_visual_effect_impl.h @@ -128,16 +128,6 @@ public: return hpsBlurParams_; } - void MakeMagnifierParams() - { - magnifierParams_ = std::make_shared(); - } - - const std::shared_ptr& GetMagnifierParams() const - { - return magnifierParams_; - } - private: static std::map> g_initialMap; @@ -146,8 +136,6 @@ private: void SetLinearGradientBlurParams(const std::string& tag, float param); void SetWaterRippleParams(const std::string& tag, float param); void SetHpsBlurParams(const std::string& tag, float param); - void SetMagnifierParamsFloat(const std::string& tag, float param); - void SetMagnifierParamsUint32(const std::string& tag, uint32_t param); FilterType filterType_ = GEVisualEffectImpl::FilterType::NONE; @@ -157,7 +145,6 @@ private: std::shared_ptr linearGradientBlurParams_ = nullptr; std::shared_ptr waterRippleParams_ = nullptr; std::shared_ptr hpsBlurParams_ = nullptr; - std::shared_ptr magnifierParams_ = nullptr; }; } // namespace Drawing diff --git a/rosen/modules/graphics_effect/src/ge_magnifier_shader_filter.cpp b/rosen/modules/graphics_effect/src/ge_magnifier_shader_filter.cpp index 77333585ee..2f32c22711 100644 --- a/rosen/modules/graphics_effect/src/ge_magnifier_shader_filter.cpp +++ b/rosen/modules/graphics_effect/src/ge_magnifier_shader_filter.cpp @@ -15,40 +15,44 @@ #include "ge_magnifier_shader_filter.h" #include "ge_log.h" -#include "ge_system_properties.h" namespace OHOS { namespace Rosen { +namespace { +constexpr static uint8_t COLOR_CHANNEL = 4; // 4 len of rgba + +static std::shared_ptr GetMagnifierParams() +{ + std::shared_ptr para = std::make_shared(); + if (!para) { + return nullptr; + } + para->factor_ = 1.4f; // 1.4 magnifier + para->width_ = 364.0f; // 364.0 width + para->height_ = 234.0f; // 234.0 height + para->borderWidth_ = 6.5f; // 6.5 borderWidth + para->cornerRadius_ = 117.0f; // 117.0 cornerRadius + para->shadowOffsetX_ = 0.0f; // 0.0 shadowOffsetX + para->shadowOffsetY_ = 26.0f; // 26.0 shadowOffsetY + para->shadowSize_ = 32.5f; // 32.5 shadowSize + para->shadowStrength_ = 0.08f; // 0.08 shadowStrength + para->gradientMaskColor1_ = 0x80808000; // 0x80808000 gradientMaskColor1 + para->gradientMaskColor2_ = 0x80808026; // 0x80808026 gradientMaskColor2 + para->outerContourColor1_ = 0xF0F0F0CC; // 0xF0F0F0CC outerContourColor1 + para->outerContourColor2_ = 0xFFFFFFCC; // 0xFFFFFFCC outerContourColor2 + return para; +} +} // namespace + std::shared_ptr GEMagnifierShaderFilter::magnifierShaderEffect_ = nullptr; -GEMagnifierShaderFilter::GEMagnifierShaderFilter(const Drawing::GEMagnifierShaderFilterParams& params) -{ - if (!InitMagnifierEffect()) { - LOGE("GEMagnifierShaderFilter::GEMagnifierShaderFilter failed when initializing MagnifierEffect."); - return; - } - - magnifierPara_ = std::make_shared(); - magnifierPara_->factor_ = params.factor; - magnifierPara_->width_ = params.width; - magnifierPara_->height_ = params.height; - magnifierPara_->borderWidth_ = params.borderWidth; - magnifierPara_->cornerRadius_ = params.cornerRadius; - magnifierPara_->shadowOffsetX_ = params.shadowOffsetX; - magnifierPara_->shadowOffsetY_ = params.shadowOffsetY; - magnifierPara_->shadowSize_ = params.shadowSize; - magnifierPara_->shadowStrength_ = params.shadowStrength; - magnifierPara_->gradientMaskColor1_ = params.gradientMaskColor1; - magnifierPara_->gradientMaskColor2_ = params.gradientMaskColor2; - magnifierPara_->outerContourColor1_ = params.outerContourColor1; - magnifierPara_->outerContourColor2_ = params.outerContourColor2; -} +GEMagnifierShaderFilter::GEMagnifierShaderFilter() {} std::shared_ptr GEMagnifierShaderFilter::ProcessImage(Drawing::Canvas& canvas, const std::shared_ptr image, const Drawing::Rect& src, const Drawing::Rect& dst) { - if (image == nullptr || magnifierPara_ == nullptr) { + if (image == nullptr) { LOGE("GEMagnifierShaderFilter::ProcessImage image or para is null"); return image; } @@ -72,16 +76,153 @@ std::shared_ptr GEMagnifierShaderFilter::ProcessImage(Drawing::C std::shared_ptr GEMagnifierShaderFilter::MakeMagnifierShader( std::shared_ptr imageShader, float imageWidth, float imageHeight) { - return nullptr; + if (magnifierShaderEffect_ == nullptr) { + if (!InitMagnifierEffect()) { + LOGE("GEMagnifierShaderFilter::failed when initializing MagnifierEffect."); + return nullptr; + } + } + + auto magnifierPara = GetMagnifierParams(); + if (magnifierPara == nullptr) { + return nullptr; + } + std::shared_ptr builder = + std::make_shared(magnifierShaderEffect_); + builder->SetChild("imageShader", imageShader); + builder->SetUniform("iResolution", imageWidth, imageHeight); + + builder->SetUniform("factor", magnifierPara->factor_); + builder->SetUniform("borderWidth", magnifierPara->borderWidth_); + builder->SetUniform("cornerRadius", magnifierPara->cornerRadius_); + builder->SetUniform("size", magnifierPara->width_, magnifierPara->height_); + + builder->SetUniform("shadowOffset", magnifierPara->shadowOffsetX_, magnifierPara->shadowOffsetY_); + builder->SetUniform("shadowSize", magnifierPara->shadowSize_); + builder->SetUniform("shadowStrength", magnifierPara->shadowStrength_); + + float maskColor1[COLOR_CHANNEL] = { 0.0f }; + float maskColor2[COLOR_CHANNEL] = { 0.0f }; + float outColor1[COLOR_CHANNEL] = { 0.0f }; + float outColor2[COLOR_CHANNEL] = { 0.0f }; + ConvertToRgba(magnifierPara->gradientMaskColor1_, maskColor1, COLOR_CHANNEL); + ConvertToRgba(magnifierPara->gradientMaskColor2_, maskColor2, COLOR_CHANNEL); + ConvertToRgba(magnifierPara->outerContourColor1_, outColor1, COLOR_CHANNEL); + ConvertToRgba(magnifierPara->outerContourColor2_, outColor2, COLOR_CHANNEL); + builder->SetUniform("gradientMaskColor1", maskColor1, COLOR_CHANNEL); + builder->SetUniform("gradientMaskColor2", maskColor2, COLOR_CHANNEL); + builder->SetUniform("outerContourColor1", outColor1, COLOR_CHANNEL); + builder->SetUniform("outerContourColor2", outColor2, COLOR_CHANNEL); + + return builder; } bool GEMagnifierShaderFilter::InitMagnifierEffect() { - return false; + if (magnifierShaderEffect_ == nullptr) { + static constexpr char prog[] = R"( + uniform shader imageShader; + uniform float2 iResolution; + + uniform float factor; + uniform float borderWidth; + uniform float cornerRadius; + uniform float2 size; + + uniform float2 shadowOffset; + uniform float shadowSize; + uniform float shadowStrength; + + uniform vec4 gradientMaskColor1; + uniform vec4 gradientMaskColor2; + uniform vec4 outerContourColor1; + uniform vec4 outerContourColor2; + + // refraction + const float refractionStrength = 0.02; // 0.02 refraction strength + const float epsilon = 1e-4; + + vec4 sdfRect(vec2 position, vec2 R1, float R2, float curvature, out float isInBorder) + { + // calculate normal + vec2 d = max(abs(position) - R1, 0.0); + float dist = length(d) / R2; + vec2 dir = normalize(sign(position) * d); + float borderHeightRatio = min(size.x, size.y) / (borderWidth * 2.0); // 2.0 borderWidth + float posInBorder = mix(1.0 - borderHeightRatio, 1.0, dist); + float weight = max(posInBorder, 0.0); + vec3 normal = normalize(mix(vec3(0.0, 0.0, 1.0), vec3(dir, 0.0), weight)); + isInBorder = step(0.0, posInBorder); + + // calculate shadow + position -= shadowOffset / iResolution.x; + float R2Shadow = R2 + 0.5 * shadowSize / iResolution.x; // 0.5 half of shader size + float distShadow = length(max(abs(position) - R1, 0.)) / R2Shadow; + float shadowSizeHeightRatio = min(size.x, size.y) / (shadowSize / (curvature + epsilon) * 2.0); + float weightShadow = max(mix(1.0 - shadowSizeHeightRatio, 1.0, distShadow), 0.0); + float shadow = mix(1.0 - shadowStrength, 1.0, min(abs(weightShadow - 0.5) * 2.0, 1.0)); // 0.5 2.0 num + + return vec4(normal, shadow); + } + + vec4 main(float2 fragCoord) + { + vec2 uv = fragCoord.xy / iResolution.x; + vec2 boxPosition = iResolution / 2.0 / iResolution.x; // 2.0 center of rect + vec2 halfBoxSize = size / iResolution.x / 2.0; // 2.0 half of resolution + float curvature = cornerRadius / min(size.x, size.y) * 2.0; // 2.0 double of radius + float mn = min(halfBoxSize.x, halfBoxSize.y) * (curvature + epsilon); + + float isInBorder = 0; + vec4 magnifyingGlass = sdfRect(uv - boxPosition, halfBoxSize - vec2(mn), mn, curvature, isInBorder); + vec4 finalColor = vec4(0.0, 0.0, 0.0, 1.0); + + // add refraction + float red = magnifyingGlass.x; + float green = magnifyingGlass.y; + float offsetX = refractionStrength * sign(red) * red * red; + float offsetY = -refractionStrength * sign(green) * green * green; + vec2 sampleUV = (uv - boxPosition) / factor + boxPosition; + vec4 refraction = imageShader.eval((sampleUV + vec2(offsetX, offsetY)) * iResolution.x); + + // add gradient mask + float yDistToCenter = (uv.y - boxPosition.y) / halfBoxSize.y; + float yValue = (yDistToCenter + 1.0) / 2.0; // 2.0 half of height + vec4 gradientMask = mix(gradientMaskColor1, gradientMaskColor2, yValue); + refraction.xyz = mix(refraction.xyz, gradientMask.xyz, gradientMask.w); + + // only apply refraction if z-value is not zero + float mask = step(0.0, magnifyingGlass.z); + finalColor = mix(finalColor, refraction, mask); + + // add shadow + finalColor.xyz *= magnifyingGlass.w; + vec4 shadowColor = vec4(0.0, 0.0, 0.0, 1.0) * (1.0 - magnifyingGlass.w); + finalColor = mix(shadowColor, finalColor, mask); + + // add outer_contour color + float xValue = (uv.x - boxPosition.x) / halfBoxSize.x; + vec4 gradientContour = mix(outerContourColor1, outerContourColor2, abs(xValue)); + finalColor.xyz = mix(finalColor.xyz, gradientContour.xyz, gradientContour.w * isInBorder * mask); + + return finalColor; + } + )"; + + magnifierShaderEffect_ = Drawing::RuntimeEffect::CreateForShader(prog); + if (magnifierShaderEffect_ == nullptr) { + LOGE("MakeMagnifierShader::RuntimeShader effect error\n"); + return false; + } + } + return true; } -void GEMagnifierShaderFilter::ConvertToRgba(uint32_t rgba, float* color) +void GEMagnifierShaderFilter::ConvertToRgba(uint32_t rgba, float* color, int tupleSize) { + if (!color || tupleSize < 4) { // 4 len of rgba + return; + } int16_t alpha = static_cast(rgba & 0xFF); // 0xff byte mask int16_t red = static_cast((rgba & 0xFF000000) >> 24); // 0xff000000 red mask, 24 red shift int16_t green = static_cast((rgba & 0x00FF0000) >> 16); // 0x00ff0000 green mask, 16 green shift diff --git a/rosen/modules/graphics_effect/src/ge_render.cpp b/rosen/modules/graphics_effect/src/ge_render.cpp index f523bd1535..d0024e19f1 100644 --- a/rosen/modules/graphics_effect/src/ge_render.cpp +++ b/rosen/modules/graphics_effect/src/ge_render.cpp @@ -114,8 +114,7 @@ std::vector> GERender::GenerateShaderFilter( break; } case Drawing::GEVisualEffectImpl::FilterType::MAGNIFIER: { - const auto& magnifierParams = ve->GetMagnifierParams(); - shaderFilter = std::make_shared(*magnifierParams); + shaderFilter = std::make_shared(); break; } default: diff --git a/rosen/modules/graphics_effect/src/ge_visual_effect_impl.cpp b/rosen/modules/graphics_effect/src/ge_visual_effect_impl.cpp index 846844bb4c..844acc8142 100644 --- a/rosen/modules/graphics_effect/src/ge_visual_effect_impl.cpp +++ b/rosen/modules/graphics_effect/src/ge_visual_effect_impl.cpp @@ -63,7 +63,6 @@ std::map> GEVisualEf { GE_FILTER_MAGNIFIER, [](GEVisualEffectImpl* impl) { impl->SetFilterType(GEVisualEffectImpl::FilterType::MAGNIFIER); - impl->MakeMagnifierParams(); } } }; @@ -150,10 +149,6 @@ void GEVisualEffectImpl::SetParam(const std::string& tag, float param) SetWaterRippleParams(tag, param); break; } - case FilterType::MAGNIFIER: { - SetMagnifierParamsFloat(tag, param); - break; - } default: break; } @@ -202,17 +197,7 @@ void GEVisualEffectImpl::SetParam(const std::string& tag, const std::vector> actions = { - { GE_FILTER_MAGNIFIER_FACTOR, - [](GEVisualEffectImpl* obj, float p) { obj->magnifierParams_->factor = p; } }, - { GE_FILTER_MAGNIFIER_WIDTH, - [](GEVisualEffectImpl* obj, float p) { obj->magnifierParams_->width = p; } }, - { GE_FILTER_MAGNIFIER_HEIGHT, - [](GEVisualEffectImpl* obj, float p) { obj->magnifierParams_->height = p; } }, - { GE_FILTER_MAGNIFIER_BORDER_WIDTH, - [](GEVisualEffectImpl* obj, float p) { obj->magnifierParams_->borderWidth = p; } }, - { GE_FILTER_MAGNIFIER_CORNER_RADIUS, - [](GEVisualEffectImpl* obj, float p) { obj->magnifierParams_->cornerRadius = p; } }, - { GE_FILTER_MAGNIFIER_SHADOW_OFFSET_X, - [](GEVisualEffectImpl* obj, float p) { obj->magnifierParams_->shadowOffsetX = p; } }, - { GE_FILTER_MAGNIFIER_SHADOW_OFFSET_Y, - [](GEVisualEffectImpl* obj, float p) { obj->magnifierParams_->shadowOffsetY = p; } }, - { GE_FILTER_MAGNIFIER_SHADOW_SIZE, - [](GEVisualEffectImpl* obj, float p) { obj->magnifierParams_->shadowSize = p; } }, - { GE_FILTER_MAGNIFIER_SHADOW_STRENGTH, - [](GEVisualEffectImpl* obj, float p) { obj->magnifierParams_->shadowStrength = p; } } - }; - - auto it = actions.find(tag); - if (it != actions.end()) { - it->second(this, param); - } -} - -void GEVisualEffectImpl::SetMagnifierParamsUint32(const std::string& tag, uint32_t param) -{ - if (magnifierParams_ == nullptr) { - return; - } - - static std::unordered_map> actions = { - { GE_FILTER_MAGNIFIER_GRADIENT_MASK_COLOR_1, - [](GEVisualEffectImpl* obj, uint32_t p) { obj->magnifierParams_->gradientMaskColor1 = p; } }, - { GE_FILTER_MAGNIFIER_GRADIENT_MASK_COLOR_2, - [](GEVisualEffectImpl* obj, uint32_t p) { obj->magnifierParams_->gradientMaskColor2 = p; } }, - { GE_FILTER_MAGNIFIER_OUTER_CONTOUR_COLOR_1, - [](GEVisualEffectImpl* obj, uint32_t p) { obj->magnifierParams_->outerContourColor1 = p; } }, - { GE_FILTER_MAGNIFIER_OUTER_CONTOUR_COLOR_2, - [](GEVisualEffectImpl* obj, uint32_t p) { obj->magnifierParams_->outerContourColor2 = p; } } - }; - - auto it = actions.find(tag); - if (it != actions.end()) { - it->second(this, param); - } -} - } // namespace Drawing } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/graphics_effect/test/unittest/BUILD.gn b/rosen/modules/graphics_effect/test/unittest/BUILD.gn index 81882e84f4..d498cd18c8 100644 --- a/rosen/modules/graphics_effect/test/unittest/BUILD.gn +++ b/rosen/modules/graphics_effect/test/unittest/BUILD.gn @@ -26,6 +26,7 @@ ohos_unittest("GraphicsEffectTest") { "ge_hash_test.cpp", "ge_kawase_blur_shader_filter_test.cpp", "ge_linear_gradient_blur_shader_filter_test.cpp", + "ge_magnifier_shader_filter_test.cpp", "ge_render_test.cpp", "ge_system_properties_test.cpp", "ge_visual_effect_container_test.cpp", diff --git a/rosen/modules/graphics_effect/test/unittest/ge_magnifier_shader_filter_test.cpp b/rosen/modules/graphics_effect/test/unittest/ge_magnifier_shader_filter_test.cpp new file mode 100644 index 0000000000..8f502e90ee --- /dev/null +++ b/rosen/modules/graphics_effect/test/unittest/ge_magnifier_shader_filter_test.cpp @@ -0,0 +1,175 @@ +/* + * 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 + +#include "ge_magnifier_shader_filter.h" + +#include "draw/color.h" +#include "image/bitmap.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace GraphicsEffectEngine { + +using namespace Rosen; + +class GEMagnifierShaderFilterTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; + + static inline Drawing::Canvas canvas_; + std::shared_ptr image_ { nullptr }; + + // 1.0f, 1.0f, 2.0f, 2.0f is left top right bottom + Drawing::Rect src_ { 1.0f, 1.0f, 2.0f, 2.0f }; + Drawing::Rect dst_ { 1.0f, 1.0f, 2.0f, 2.0f }; +}; + +void GEMagnifierShaderFilterTest::SetUpTestCase() {} +void GEMagnifierShaderFilterTest::TearDownTestCase() {} + +void GEMagnifierShaderFilterTest::SetUp() +{ + canvas_.Restore(); + + Drawing::Bitmap bmp; + Drawing::BitmapFormat format { Drawing::COLORTYPE_RGBA_8888, Drawing::ALPHATYPE_PREMUL }; + bmp.Build(50, 50, format); // 50, 50 bitmap size + bmp.ClearWithColor(Drawing::Color::COLOR_BLUE); + image_ = bmp.MakeImage(); +} + +void GEMagnifierShaderFilterTest::TearDown() {} + +/** + * @tc.name: GetDescription001 + * @tc.desc: Verify function GetDescription + * @tc.type:FUNC + */ +HWTEST_F(GEMagnifierShaderFilterTest, GetDescription001, TestSize.Level1) +{ + auto filter = std::make_shared(); + ASSERT_TRUE(filter != nullptr); + + std::string expectStr = "GEMagnifierShaderFilter"; + EXPECT_EQ(filter->GetDescription(), expectStr); +} + +/** + * @tc.name: ProcessImage001 + * @tc.desc: Verify function ProcessImage + * @tc.type:FUNC + */ +HWTEST_F(GEMagnifierShaderFilterTest, ProcessImage001, TestSize.Level1) +{ + auto filter = std::make_shared(); + ASSERT_TRUE(filter != nullptr); + + std::shared_ptr image = nullptr; + EXPECT_EQ(filter->ProcessImage(canvas_, image, src_, dst_), image); +} + +/** + * @tc.name: ProcessImage002 + * @tc.desc: Verify function ProcessImage + * @tc.type:FUNC + */ +HWTEST_F(GEMagnifierShaderFilterTest, ProcessImage002, TestSize.Level1) +{ + auto filter = std::make_shared(); + ASSERT_TRUE(filter != nullptr); + + EXPECT_NE(filter->ProcessImage(canvas_, image_, src_, dst_), image_); +} + +/** + * @tc.name: ProcessImage003 + * @tc.desc: Verify function ProcessImage + * @tc.type:FUNC + */ +HWTEST_F(GEMagnifierShaderFilterTest, ProcessImage003, TestSize.Level1) +{ + auto filter = std::make_shared(); + ASSERT_TRUE(filter != nullptr); + + // 1.0f, 1.0f, 200.0f, 200.0f is left top right bottom + Drawing::Rect src { 1.0f, 1.0f, 200.0f, 200.0f }; + Drawing::Rect dst { 1.0f, 1.0f, 2.0f, 2.0f }; +#ifdef GE_OHOS +#undef GE_OHOS + EXPECT_NE(filter->ProcessImage(canvas_, image_, src, dst), image_); +#define GE_OHOS +#else +#define GE_OHOS + EXPECT_NE(filter->ProcessImage(canvas_, image_, src, dst), image_); +#undef GE_OHOS +#endif +} + +/** + * @tc.name: ProcessImage004 + * @tc.desc: Verify function ProcessImage + * @tc.type:FUNC + */ +HWTEST_F(GEMagnifierShaderFilterTest, ProcessImage004, TestSize.Level1) +{ + auto filter = std::make_shared(); + ASSERT_TRUE(filter != nullptr); + + EXPECT_NE(filter->ProcessImage(canvas_, image_, src_, dst_), image_); + + std::shared_ptr image = std::make_shared(); + EXPECT_EQ(filter->ProcessImage(canvas_, image, src_, dst_), image); + EXPECT_TRUE(filter->InitMagnifierEffect()); +} + +/** + * @tc.name: ConvertToRgba001 + * @tc.desc: Verify function ConvertToRgba + * @tc.type:FUNC + */ +HWTEST_F(GEMagnifierShaderFilterTest, ConvertToRgba001, TestSize.Level1) +{ + auto filter = std::make_shared(); + ASSERT_TRUE(filter != nullptr); + + uint32_t color1 = uint32_t(0x80808000); + float maskColor1[4] = { 0.0f }; // 4 len of tuple + filter->ConvertToRgba(color1, maskColor1, 4); +} + +/** + * @tc.name: ConvertToRgba002 + * @tc.desc: Verify function ConvertToRgba + * @tc.type:FUNC + */ +HWTEST_F(GEMagnifierShaderFilterTest, ConvertToRgba002, TestSize.Level1) +{ + auto filter = std::make_shared(); + ASSERT_TRUE(filter != nullptr); + + uint32_t color1 = uint32_t(0x80808000); + float maskColor1[4] = { 0.0f }; // 4 len of tuple + filter->ConvertToRgba(color1, maskColor1, 3); + filter->ConvertToRgba(color1, nullptr, 3); +} +} // namespace GraphicsEffectEngine +} // namespace OHOS \ No newline at end of file diff --git a/rosen/modules/render_service_base/include/command/rs_node_command.h b/rosen/modules/render_service_base/include/command/rs_node_command.h index 3e8c0844cd..ce8985e348 100644 --- a/rosen/modules/render_service_base/include/command/rs_node_command.h +++ b/rosen/modules/render_service_base/include/command/rs_node_command.h @@ -70,7 +70,6 @@ enum RSNodeCommandType : uint16_t { SET_NODE_NAME, UPDATE_MODIFIER_MOTION_BLUR_PTR, UPDATE_MODIFIER_WATER_RIPPLE, - UPDATE_MODIFIER_MAGNIFIER_PTR, }; class RSB_EXPORT RSNodeCommandHelper { @@ -197,10 +196,6 @@ ADD_COMMAND(RSUpdatePropertyMotionBlurPara, ARG(RS_NODE, UPDATE_MODIFIER_MOTION_BLUR_PTR, RSNodeCommandHelper::UpdateModifier>, NodeId, std::shared_ptr, PropertyId, PropertyUpdateType)) -ADD_COMMAND(RSUpdatePropertyMagnifierPara, - ARG(RS_NODE, UPDATE_MODIFIER_MAGNIFIER_PTR, - RSNodeCommandHelper::UpdateModifier>, - NodeId, std::shared_ptr, PropertyId, PropertyUpdateType)) ADD_COMMAND(RSUpdatePropertyEmitterUpdater, ARG(RS_NODE, UPDATE_MODIFIER_EMITTER_UPDATER_PTR, RSNodeCommandHelper::UpdateModifier>>, diff --git a/rosen/modules/render_service_base/include/modifier/rs_modifiers_def.in b/rosen/modules/render_service_base/include/modifier/rs_modifiers_def.in index 83d4810b04..a824cd8fb1 100644 --- a/rosen/modules/render_service_base/include/modifier/rs_modifiers_def.in +++ b/rosen/modules/render_service_base/include/modifier/rs_modifiers_def.in @@ -106,7 +106,7 @@ DECLARE_NOANIMATABLE_MODIFIER(LinearGradientBlurPara, std::shared_ptr, MOTION_BLUR_PARA, Foreground) -DECLARE_NOANIMATABLE_MODIFIER(MagnifierParams, std::shared_ptr, MAGNIFIER_PARA, Foreground) +DECLARE_NOANIMATABLE_MODIFIER(MagnifierParams, Vector2f, MAGNIFIER_PARA, Foreground) DECLARE_NOANIMATABLE_MODIFIER(EmitterUpdater, std::vector>, PARTICLE_EMITTER_UPDATER, Foreground) diff --git a/rosen/modules/render_service_base/include/property/rs_properties.h b/rosen/modules/render_service_base/include/property/rs_properties.h index a5b09d5871..cd0f0f8d86 100644 --- a/rosen/modules/render_service_base/include/property/rs_properties.h +++ b/rosen/modules/render_service_base/include/property/rs_properties.h @@ -35,7 +35,6 @@ #include "render/rs_filter.h" #include "render/rs_gradient_blur_para.h" #include "render/rs_image.h" -#include "render/rs_magnifier_para.h" #include "render/rs_mask.h" #include "render/rs_motion_blur_filter.h" #include "render/rs_particles_drawable.h" @@ -287,7 +286,7 @@ public: void SetFilter(const std::shared_ptr& filter); void SetMotionBlurPara(const std::shared_ptr& para); - void SetMagnifierParams(const std::shared_ptr& para); + void SetMagnifierParams(const std::optional& para); const std::shared_ptr& GetBackgroundFilter() const; const std::shared_ptr& GetLinearGradientBlurPara() const; const std::vector>& GetEmitterUpdater() const; @@ -295,7 +294,7 @@ public: void IfLinearGradientBlurInvalid(); const std::shared_ptr& GetFilter() const; const std::shared_ptr& GetMotionBlurPara() const; - const std::shared_ptr& GetMagnifierPara() const; + const std::optional& GetMagnifierPara() const; bool NeedFilter() const; void SetGreyCoef(const std::optional& greyCoef); const std::optional& GetGreyCoef() const; @@ -615,7 +614,6 @@ private: std::shared_ptr backgroundFilter_ = nullptr; std::shared_ptr linearGradientBlurPara_ = nullptr; std::shared_ptr motionBlurPara_ = nullptr; - std::shared_ptr magnifierPara_ = nullptr; std::vector> emitterUpdater_; std::shared_ptr particleNoiseFields_ = nullptr; std::shared_ptr border_ = nullptr; @@ -677,6 +675,7 @@ private: std::optional colorBlend_; std::optional lastRect_; std::optional greyCoef_; + std::optional magnifierPara_; // OnApplyModifiers hooks void CheckEmptyBounds(); diff --git a/rosen/modules/render_service_base/include/render/rs_magnifier_shader_filter.h b/rosen/modules/render_service_base/include/render/rs_magnifier_shader_filter.h index ff8c3d54a5..7388a9d8a7 100644 --- a/rosen/modules/render_service_base/include/render/rs_magnifier_shader_filter.h +++ b/rosen/modules/render_service_base/include/render/rs_magnifier_shader_filter.h @@ -15,7 +15,7 @@ #ifndef RENDER_SERVICE_CLIENT_CORE_RENDER_RS_MAGNIFIER_SHADER_FILTER_H #define RENDER_SERVICE_CLIENT_CORE_RENDER_RS_MAGNIFIER_SHADER_FILTER_H -#include "render/rs_magnifier_para.h" +#include "common/rs_vector2.h" #include "render/rs_shader_filter.h" namespace OHOS { @@ -23,20 +23,19 @@ namespace Rosen { class RSB_EXPORT RSMagnifierShaderFilter : public RSShaderFilter { public: - RSMagnifierShaderFilter(const std::shared_ptr& para); + RSMagnifierShaderFilter(float offsetX, float offsetY); RSMagnifierShaderFilter(const RSMagnifierShaderFilter&) = delete; RSMagnifierShaderFilter operator=(const RSMagnifierShaderFilter&) = delete; ~RSMagnifierShaderFilter() override; void GenerateGEVisualEffect(std::shared_ptr visualEffectContainer) override; - const std::shared_ptr& GetMagnifierShaderFilterPara() - { - return magnifierPara_; - } + float GetMagnifierOffsetX() const { return offsetX_; } + float GetMagnifierOffsetY() const { return offsetY_; } private: friend class RSMarshallingHelper; - std::shared_ptr magnifierPara_ = nullptr; + float offsetX_ = 0.f; + float offsetY_ = 0.f; }; } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/include/transaction/rs_marshalling_helper.h b/rosen/modules/render_service_base/include/transaction/rs_marshalling_helper.h index 3684132d57..e4b6a42c48 100644 --- a/rosen/modules/render_service_base/include/transaction/rs_marshalling_helper.h +++ b/rosen/modules/render_service_base/include/transaction/rs_marshalling_helper.h @@ -51,7 +51,6 @@ class RSMask; class RSPath; class RSLinearGradientBlurPara; class MotionBlurParam; -class RSMagnifierParams; class EmitterUpdater; class ParticleNoiseField; class ParticleNoiseFields; @@ -236,7 +235,6 @@ public: DECLARE_FUNCTION_OVERLOAD(std::shared_ptr) DECLARE_FUNCTION_OVERLOAD(std::shared_ptr) DECLARE_FUNCTION_OVERLOAD(std::shared_ptr) - DECLARE_FUNCTION_OVERLOAD(std::shared_ptr) DECLARE_FUNCTION_OVERLOAD(std::shared_ptr) DECLARE_FUNCTION_OVERLOAD(std::vector>) DECLARE_FUNCTION_OVERLOAD(std::shared_ptr) diff --git a/rosen/modules/render_service_base/src/drawable/rs_property_drawable_utils.cpp b/rosen/modules/render_service_base/src/drawable/rs_property_drawable_utils.cpp index cd9e4869c4..ce893cf0c1 100644 --- a/rosen/modules/render_service_base/src/drawable/rs_property_drawable_utils.cpp +++ b/rosen/modules/render_service_base/src/drawable/rs_property_drawable_utils.cpp @@ -380,8 +380,7 @@ void RSPropertyDrawableUtils::DrawFilter(Drawing::Canvas* canvas, std::shared_ptr magnifierShaderFilter = filter->GetShaderFilterWithType(RSShaderFilter::MAGNIFIER); if (magnifierShaderFilter != nullptr) { auto tmpFilter = std::static_pointer_cast(magnifierShaderFilter); - auto para = tmpFilter->GetMagnifierShaderFilterPara(); - imageClipIBounds.Offset(para->offsetX_, para->offsetY_); + imageClipIBounds.Offset(tmpFilter->GetMagnifierOffsetX(), tmpFilter->GetMagnifierOffsetY()); } auto imageSnapshot = surface->GetImageSnapshot(imageClipIBounds); diff --git a/rosen/modules/render_service_base/src/platform/darwin/rs_marshalling_helper.cpp b/rosen/modules/render_service_base/src/platform/darwin/rs_marshalling_helper.cpp index 525c4e5578..19dc27c335 100644 --- a/rosen/modules/render_service_base/src/platform/darwin/rs_marshalling_helper.cpp +++ b/rosen/modules/render_service_base/src/platform/darwin/rs_marshalling_helper.cpp @@ -43,7 +43,6 @@ #include "render/rs_image.h" #include "render/rs_image_base.h" #include "render/rs_light_up_effect_filter.h" -#include "render/rs_magnifier_para.h" #include "render/rs_material_filter.h" #include "render/rs_motion_blur_filter.h" #include "render/rs_path.h" @@ -174,16 +173,6 @@ bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, std::shared_ptr& val) -{ - return {}; -} -bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, std::shared_ptr& val) -{ - return {}; -} - // Particle bool RSMarshallingHelper::Marshalling(Parcel& parcel, const std::shared_ptr& val) { @@ -469,7 +458,6 @@ MARSHALLING_AND_UNMARSHALLING(RSRenderAnimatableProperty) EXPLICIT_INSTANTIATION(TEMPLATE, std::shared_ptr) \ EXPLICIT_INSTANTIATION(TEMPLATE, std::shared_ptr) \ EXPLICIT_INSTANTIATION(TEMPLATE, std::shared_ptr) \ - EXPLICIT_INSTANTIATION(TEMPLATE, std::shared_ptr) \ EXPLICIT_INSTANTIATION(TEMPLATE, std::shared_ptr) \ EXPLICIT_INSTANTIATION(TEMPLATE, std::vector>) \ EXPLICIT_INSTANTIATION(TEMPLATE, std::shared_ptr) \ diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_marshalling_helper.cpp b/rosen/modules/render_service_base/src/platform/ohos/rs_marshalling_helper.cpp index d538ad86d3..87c1cd9c8d 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_marshalling_helper.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_marshalling_helper.cpp @@ -47,7 +47,6 @@ #include "render/rs_image.h" #include "render/rs_image_base.h" #include "render/rs_light_up_effect_filter.h" -#include "render/rs_magnifier_para.h" #include "render/rs_mask.h" #include "render/rs_material_filter.h" #include "render/rs_motion_blur_filter.h" @@ -625,85 +624,6 @@ bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, std::shared_ptr& val) -{ - bool success = Marshalling(parcel, val->factor_); - success = success && Marshalling(parcel, val->width_); - success = success && Marshalling(parcel, val->height_); - success = success && Marshalling(parcel, val->borderWidth_); - success = success && Marshalling(parcel, val->cornerRadius_); - success = success && Marshalling(parcel, val->offsetX_); - success = success && Marshalling(parcel, val->offsetY_); - - success = success && Marshalling(parcel, val->shadowOffsetX_); - success = success && Marshalling(parcel, val->shadowOffsetY_); - success = success && Marshalling(parcel, val->shadowSize_); - success = success && Marshalling(parcel, val->shadowStrength_); - - success = success && Marshalling(parcel, val->gradientMaskColor1_); - success = success && Marshalling(parcel, val->gradientMaskColor2_); - success = success && Marshalling(parcel, val->outerContourColor1_); - success = success && Marshalling(parcel, val->outerContourColor2_); - - return success; -} - -bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, std::shared_ptr& val) -{ - float factor; - float width; - float height; - float borderWidth; - float cornerRadius; - float offsetX; - float offsetY; - float shadowOffsetX; - float shadowOffsetY; - float shadowSize; - float shadowStrength; - uint32_t gradientMaskColor1; - uint32_t gradientMaskColor2; - uint32_t outerContourColor1; - uint32_t outerContourColor2; - - bool success = Unmarshalling(parcel, factor); - success = success && Unmarshalling(parcel, width); - success = success && Unmarshalling(parcel, height); - success = success && Unmarshalling(parcel, borderWidth); - success = success && Unmarshalling(parcel, cornerRadius); - success = success && Unmarshalling(parcel, offsetX); - success = success && Unmarshalling(parcel, offsetY); - - success = success && Unmarshalling(parcel, shadowOffsetX); - success = success && Unmarshalling(parcel, shadowOffsetY); - success = success && Unmarshalling(parcel, shadowSize); - success = success && Unmarshalling(parcel, shadowStrength); - - success = success && Unmarshalling(parcel, gradientMaskColor1); - success = success && Unmarshalling(parcel, gradientMaskColor2); - success = success && Unmarshalling(parcel, outerContourColor1); - success = success && Unmarshalling(parcel, outerContourColor2); - if (success) { - val->factor_ = factor; - val->width_ = width; - val->height_ = height; - val->borderWidth_ = borderWidth; - val->cornerRadius_ = cornerRadius; - val->offsetX_ = offsetX; - val->offsetY_ = offsetY; - val->shadowOffsetX_ = shadowOffsetX; - val->shadowOffsetY_ = shadowOffsetY; - val->shadowSize_ = shadowSize; - val->shadowStrength_ = shadowStrength; - val->gradientMaskColor1_ = gradientMaskColor1; - val->gradientMaskColor2_ = gradientMaskColor2; - val->outerContourColor1_ = outerContourColor1; - val->outerContourColor2_ = outerContourColor2; - } - return success; -} - // Particle bool RSMarshallingHelper::Marshalling(Parcel& parcel, const std::shared_ptr& val) { @@ -1890,7 +1810,6 @@ MARSHALLING_AND_UNMARSHALLING(RSRenderAnimatableProperty) EXPLICIT_INSTANTIATION(TEMPLATE, std::shared_ptr) \ EXPLICIT_INSTANTIATION(TEMPLATE, std::shared_ptr) \ EXPLICIT_INSTANTIATION(TEMPLATE, std::shared_ptr) \ - EXPLICIT_INSTANTIATION(TEMPLATE, std::shared_ptr) \ EXPLICIT_INSTANTIATION(TEMPLATE, std::shared_ptr) \ EXPLICIT_INSTANTIATION(TEMPLATE, std::vector>) \ EXPLICIT_INSTANTIATION(TEMPLATE, std::shared_ptr) \ diff --git a/rosen/modules/render_service_base/src/platform/windows/rs_marshalling_helper.cpp b/rosen/modules/render_service_base/src/platform/windows/rs_marshalling_helper.cpp index 2abcb66409..670309d3d8 100644 --- a/rosen/modules/render_service_base/src/platform/windows/rs_marshalling_helper.cpp +++ b/rosen/modules/render_service_base/src/platform/windows/rs_marshalling_helper.cpp @@ -43,7 +43,6 @@ #include "render/rs_image.h" #include "render/rs_image_base.h" #include "render/rs_light_up_effect_filter.h" -#include "render/rs_magnifier_para.h" #include "render/rs_material_filter.h" #include "render/rs_motion_blur_filter.h" #include "render/rs_path.h" @@ -177,16 +176,6 @@ bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, std::shared_ptr& val) -{ - return {}; -} -bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, std::shared_ptr& val) -{ - return {}; -} - // Particle bool RSMarshallingHelper::Marshalling(Parcel& parcel, const std::shared_ptr& val) { @@ -469,7 +458,6 @@ MARSHALLING_AND_UNMARSHALLING(RSRenderAnimatableProperty) EXPLICIT_INSTANTIATION(TEMPLATE, std::shared_ptr) \ EXPLICIT_INSTANTIATION(TEMPLATE, std::shared_ptr) \ EXPLICIT_INSTANTIATION(TEMPLATE, std::shared_ptr) \ - EXPLICIT_INSTANTIATION(TEMPLATE, std::shared_ptr) \ EXPLICIT_INSTANTIATION(TEMPLATE, std::shared_ptr) \ EXPLICIT_INSTANTIATION(TEMPLATE, std::vector>) \ EXPLICIT_INSTANTIATION(TEMPLATE, std::shared_ptr) \ diff --git a/rosen/modules/render_service_base/src/property/rs_filter_cache_manager.cpp b/rosen/modules/render_service_base/src/property/rs_filter_cache_manager.cpp index 4d56e67ebe..36acdc1bb1 100644 --- a/rosen/modules/render_service_base/src/property/rs_filter_cache_manager.cpp +++ b/rosen/modules/render_service_base/src/property/rs_filter_cache_manager.cpp @@ -211,8 +211,7 @@ void RSFilterCacheManager::TakeSnapshot(RSPaintFilterCanvas& canvas, const std:: std::shared_ptr magnifierShaderFilter = filter->GetShaderFilterWithType(RSShaderFilter::MAGNIFIER); if (magnifierShaderFilter != nullptr) { auto tmpFilter = std::static_pointer_cast(magnifierShaderFilter); - auto para = tmpFilter->GetMagnifierShaderFilterPara(); - snapshotIBounds.Offset(para->offsetX_, para->offsetY_); + snapshotIBounds.Offset(tmpFilter->GetMagnifierOffsetX(), tmpFilter->GetMagnifierOffsetY()); } // Take a screenshot. diff --git a/rosen/modules/render_service_base/src/property/rs_properties.cpp b/rosen/modules/render_service_base/src/property/rs_properties.cpp index a2c7895d20..dc15c3c80f 100644 --- a/rosen/modules/render_service_base/src/property/rs_properties.cpp +++ b/rosen/modules/render_service_base/src/property/rs_properties.cpp @@ -1688,11 +1688,11 @@ void RSProperties::SetMotionBlurPara(const std::shared_ptr& par contentDirty_ = true; } -void RSProperties::SetMagnifierParams(const std::shared_ptr& para) +void RSProperties::SetMagnifierParams(const std::optional& para) { magnifierPara_ = para; - if (para) { + if (para.has_value()) { isDrawn_ = true; } SetDirty(); @@ -1700,7 +1700,7 @@ void RSProperties::SetMagnifierParams(const std::shared_ptr& contentDirty_ = true; } -const std::shared_ptr& RSProperties::GetMagnifierPara() const +const std::optional& RSProperties::GetMagnifierPara() const { return magnifierPara_; } @@ -2901,11 +2901,11 @@ void RSProperties::GenerateLinearGradientBlurFilter() void RSProperties::GenerateMagnifierFilter() { - auto magnifierFilter = std::make_shared(magnifierPara_); + auto magnifierFilter = std::make_shared(magnifierPara_->x_, magnifierPara_->y_); std::shared_ptr originalFilter = std::make_shared(magnifierFilter); - filter_ = originalFilter; - filter_->SetFilterType(RSFilter::MAGNIFIER); + backgroundFilter_ = originalFilter; + backgroundFilter_->SetFilterType(RSFilter::MAGNIFIER); } void RSProperties::GenerateWaterRippleFilter() @@ -2931,6 +2931,8 @@ void RSProperties::GenerateBackgroundFilter() { if (aiInvert_.has_value() || systemBarEffect_) { GenerateAIBarFilter(); + } else if (magnifierPara_.has_value()) { + GenerateMagnifierFilter(); } else if (IsBackgroundMaterialFilterValid()) { GenerateBackgroundMaterialBlurFilter(); } else if (IsBackgroundBlurRadiusXValid() && IsBackgroundBlurRadiusYValid()) { @@ -4113,7 +4115,7 @@ void RSProperties::UpdateFilter() IsDynamicDimValid() || GetShadowColorStrategy() != SHADOW_COLOR_STRATEGY::COLOR_STRATEGY_NONE || foregroundFilter_ != nullptr || motionBlurPara_ != nullptr || IsFgBrightnessValid() || IsBgBrightnessValid() || foregroundFilterCache_ != nullptr || IsWaterRippleValid() || - magnifierPara_ != nullptr; + magnifierPara_.has_value(); } void RSProperties::UpdateForegroundFilter() diff --git a/rosen/modules/render_service_base/src/property/rs_properties_painter.cpp b/rosen/modules/render_service_base/src/property/rs_properties_painter.cpp index 17e6e4c6bd..c7977efb66 100644 --- a/rosen/modules/render_service_base/src/property/rs_properties_painter.cpp +++ b/rosen/modules/render_service_base/src/property/rs_properties_painter.cpp @@ -716,8 +716,7 @@ void RSPropertiesPainter::DrawFilter(const RSProperties& properties, RSPaintFilt std::shared_ptr magnifierShaderFilter = filter->GetShaderFilterWithType(RSShaderFilter::MAGNIFIER); if (magnifierShaderFilter != nullptr) { auto tmpFilter = std::static_pointer_cast(magnifierShaderFilter); - auto para = tmpFilter->GetMagnifierShaderFilterPara(); - imageClipIBounds.Offset(para->offsetX_, para->offsetY_); + imageClipIBounds.Offset(tmpFilter->GetMagnifierOffsetX(), tmpFilter->GetMagnifierOffsetY()); } auto imageSnapshot = surface->GetImageSnapshot(imageClipIBounds); if (imageSnapshot == nullptr) { diff --git a/rosen/modules/render_service_base/src/render/rs_magnifier_shader_filter.cpp b/rosen/modules/render_service_base/src/render/rs_magnifier_shader_filter.cpp index 3430173f08..7c7a37895a 100644 --- a/rosen/modules/render_service_base/src/render/rs_magnifier_shader_filter.cpp +++ b/rosen/modules/render_service_base/src/render/rs_magnifier_shader_filter.cpp @@ -20,11 +20,12 @@ namespace OHOS { namespace Rosen { -RSMagnifierShaderFilter::RSMagnifierShaderFilter(const std::shared_ptr& para) - : magnifierPara_(para) +RSMagnifierShaderFilter::RSMagnifierShaderFilter(float offsetX, float offsetY) + : offsetX_(offsetX), offsetY_(offsetY) { type_ = ShaderFilterType::MAGNIFIER; - hash_ = SkOpts::hash(&magnifierPara_, sizeof(magnifierPara_), hash_); + hash_ = SkOpts::hash(&offsetX_, sizeof(offsetX_), hash_); + hash_ = SkOpts::hash(&offsetY_, sizeof(offsetY_), hash_); } RSMagnifierShaderFilter::~RSMagnifierShaderFilter() = default; @@ -32,29 +33,11 @@ RSMagnifierShaderFilter::~RSMagnifierShaderFilter() = default; void RSMagnifierShaderFilter::GenerateGEVisualEffect( std::shared_ptr visualEffectContainer) { - if (magnifierPara_ == nullptr) { - ROSEN_LOGD("RSMagnifierShaderFilter::GenerateGEVisualEffect magnifierPara_ is nullptr!"); - return; - } - auto magnifierFilter = std::make_shared("MAGNIFIER", Drawing::DrawingPaintType::BRUSH); if (magnifierFilter == nullptr) { ROSEN_LOGD("RSMagnifierShaderFilter::GenerateGEVisualEffect magnifierFilter is nullptr!"); return; } - magnifierFilter->SetParam("FACTOR", magnifierPara_->factor_); - magnifierFilter->SetParam("WIDTH", magnifierPara_->width_); - magnifierFilter->SetParam("HEIGHT", magnifierPara_->height_); - magnifierFilter->SetParam("BORDERWIDTH", magnifierPara_->borderWidth_); - magnifierFilter->SetParam("CORNERRADIUS", magnifierPara_->cornerRadius_); - magnifierFilter->SetParam("SHADOWOFFSETX", magnifierPara_->shadowOffsetX_); - magnifierFilter->SetParam("SHADOWOFFSETY", magnifierPara_->shadowOffsetY_); - magnifierFilter->SetParam("SHADOWSIZE", magnifierPara_->shadowSize_); - magnifierFilter->SetParam("SHADOWSTRENGTH", magnifierPara_->shadowStrength_); - magnifierFilter->SetParam("GRADIENTMASKCOLOR1", magnifierPara_->gradientMaskColor1_); - magnifierFilter->SetParam("GRADIENTMASKCOLOR2", magnifierPara_->gradientMaskColor2_); - magnifierFilter->SetParam("OUTERCONTOURCOLOR1", magnifierPara_->outerContourColor1_); - magnifierFilter->SetParam("OUTERCONTOURCOLOR2", magnifierPara_->outerContourColor2_); visualEffectContainer->AddToChainedFilter(magnifierFilter); } diff --git a/rosen/modules/render_service_client/core/modifier/rs_property.cpp b/rosen/modules/render_service_client/core/modifier/rs_property.cpp index 93a6f156ef..0c0cf98aed 100644 --- a/rosen/modules/render_service_client/core/modifier/rs_property.cpp +++ b/rosen/modules/render_service_client/core/modifier/rs_property.cpp @@ -253,12 +253,6 @@ void RSProperty>::UpdateToRender( UPDATE_TO_RENDER(RSUpdatePropertyMotionBlurPara, value, type); } template<> -void RSProperty>::UpdateToRender( - const std::shared_ptr& value, PropertyUpdateType type) const -{ - UPDATE_TO_RENDER(RSUpdatePropertyMagnifierPara, value, type); -} -template<> void RSProperty>>::UpdateToRender( const std::vector>& value, PropertyUpdateType type) const { diff --git a/rosen/modules/render_service_client/core/modifier/rs_property.h b/rosen/modules/render_service_client/core/modifier/rs_property.h index 79c55a2402..784f52a3cc 100644 --- a/rosen/modules/render_service_client/core/modifier/rs_property.h +++ b/rosen/modules/render_service_client/core/modifier/rs_property.h @@ -714,9 +714,6 @@ template<> RSC_EXPORT void RSProperty>::UpdateToRender( const std::shared_ptr& value, PropertyUpdateType type) const; template<> -RSC_EXPORT void RSProperty>::UpdateToRender( - const std::shared_ptr& value, PropertyUpdateType type) const; -template<> RSC_EXPORT void RSProperty>>::UpdateToRender( const std::vector>& value, PropertyUpdateType type) const; template<> diff --git a/rosen/modules/render_service_client/core/ui/rs_node.cpp b/rosen/modules/render_service_client/core/ui/rs_node.cpp index 66ef9944be..de6dcdbb83 100755 --- a/rosen/modules/render_service_client/core/ui/rs_node.cpp +++ b/rosen/modules/render_service_client/core/ui/rs_node.cpp @@ -479,10 +479,9 @@ void RSNode::SetMotionPathOption(const std::shared_ptr& moti UpdateModifierMotionPathOption(); } -void RSNode::SetMagnifierParams(const std::shared_ptr& para) +void RSNode::SetMagnifierParams(const Vector2f& para) { - SetProperty>>( - RSModifierType::MAGNIFIER_PARA, para); + SetProperty>(RSModifierType::MAGNIFIER_PARA, para); } const std::shared_ptr RSNode::GetMotionPathOption() const diff --git a/rosen/modules/render_service_client/core/ui/rs_node.h b/rosen/modules/render_service_client/core/ui/rs_node.h index 54c0d18e7b..3ddcee449f 100755 --- a/rosen/modules/render_service_client/core/ui/rs_node.h +++ b/rosen/modules/render_service_client/core/ui/rs_node.h @@ -291,7 +291,7 @@ public: void SetFilter(const std::shared_ptr& filter); void SetLinearGradientBlurPara(const std::shared_ptr& para); void SetMotionBlurPara(const float radius, const Vector2f& anchor); - void SetMagnifierParams(const std::shared_ptr& para); + void SetMagnifierParams(const Vector2f& para); void SetDynamicLightUpRate(const float rate); void SetDynamicLightUpDegree(const float lightUpDegree); void SetDynamicDimDegree(const float dimDegree); diff --git a/rosen/test/render_service/render_service_base/unittest/property/rs_properties_test.cpp b/rosen/test/render_service/render_service_base/unittest/property/rs_properties_test.cpp index 7e60c0dde9..9861445003 100644 --- a/rosen/test/render_service/render_service_base/unittest/property/rs_properties_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/property/rs_properties_test.cpp @@ -1695,6 +1695,34 @@ HWTEST_F(RSPropertiesTest, SetMotionBlurPara001, TestSize.Level1) EXPECT_NE(para, nullptr); } +/** + * @tc.name: SetMagnifierParams001 + * @tc.desc: test results of SetMagnifierParams + * @tc.type: FUNC + * @tc.require: issueI9QKVM + */ +HWTEST_F(RSPropertiesTest, SetMagnifierParams001, TestSize.Level1) +{ + RSProperties properties; + std::optional para({1.f, 1.f}); + properties.SetMagnifierParams(para); + ASSERT_TRUE(properties.GetMagnifierPara().has_value()); + EXPECT_EQ(properties.GetMagnifierPara().value(), para.value()); +} + +/** + * @tc.name: SetMagnifierParams002 + * @tc.desc: test results of SetMagnifierParams + * @tc.type: FUNC + * @tc.require: issueI9QKVM + */ +HWTEST_F(RSPropertiesTest, SetMagnifierParams002, TestSize.Level1) +{ + RSProperties properties; + properties.SetMagnifierParams(std::nullopt); + EXPECT_EQ(properties.GetMagnifierPara(), std::nullopt); +} + /** * @tc.name: SetForegroundFilter001 * @tc.desc: test results of SetForegroundFilter diff --git a/rosen/test/render_service/render_service_base/unittest/render/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/render/BUILD.gn index 55c75a8193..a70ebbddbc 100644 --- a/rosen/test/render_service/render_service_base/unittest/render/BUILD.gn +++ b/rosen/test/render_service/render_service_base/unittest/render/BUILD.gn @@ -37,6 +37,7 @@ ohos_unittest("RSRenderServiceBaseRenderTest") { "rs_kawase_blur_test.cpp", "rs_light_up_effect_filter_test.cpp", "rs_linear_gradient_blur_filter_test.cpp", + "rs_magnifier_shader_filter_test.cpp", "rs_mask_test.cpp", "rs_maskcolor_shader_filter_test.cpp", "rs_material_filter_test.cpp", diff --git a/rosen/test/render_service/render_service_base/unittest/render/rs_magnifier_shader_filter_test.cpp b/rosen/test/render_service/render_service_base/unittest/render/rs_magnifier_shader_filter_test.cpp new file mode 100644 index 0000000000..54f9824901 --- /dev/null +++ b/rosen/test/render_service/render_service_base/unittest/render/rs_magnifier_shader_filter_test.cpp @@ -0,0 +1,64 @@ +/* + * 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 "gtest/gtest.h" + +#include "render/rs_magnifier_shader_filter.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Rosen { +class RSMagnifierShaderFilterTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void RSMagnifierShaderFilterTest::SetUpTestCase() {} +void RSMagnifierShaderFilterTest::TearDownTestCase() {} +void RSMagnifierShaderFilterTest::SetUp() {} +void RSMagnifierShaderFilterTest::TearDown() {} + +/** + * @tc.name: GenerateGEVisualEffectTest + * @tc.desc: Verify function GenerateGEVisualEffect + * @tc.type:FUNC + * @tc.require: issuesI9UWCD + */ +HWTEST_F(RSMagnifierShaderFilterTest, GenerateGEVisualEffectTest, TestSize.Level1) +{ + auto rsMagnifierShaderFilter = std::make_shared(0.1f, 0.1f); + auto visualEffectContainer = std::make_shared(); + rsMagnifierShaderFilter->GenerateGEVisualEffect(visualEffectContainer); + EXPECT_FALSE(visualEffectContainer->filterVec_.empty()); +} + +/** + * @tc.name: GetMagnifierOffsetTest + * @tc.desc: Verify function GetMagnifierOffsetTest + * @tc.type:FUNC + * @tc.require: issuesI9UWCD + */ +HWTEST_F(RSMagnifierShaderFilterTest, GetMagnifierOffsetTest, TestSize.Level1) +{ + auto rsMagnifierShaderFilter = std::make_shared(0.1f, 0.1f); + EXPECT_EQ(rsMagnifierShaderFilter->GetMagnifierOffsetX(), 0.1f); + EXPECT_EQ(rsMagnifierShaderFilter->GetMagnifierOffsetY(), 0.1f); +} +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/rosen/test/render_service/render_service_client/unittest/ui/rs_node_test.cpp b/rosen/test/render_service/render_service_client/unittest/ui/rs_node_test.cpp index cc38fd0b10..0284768716 100644 --- a/rosen/test/render_service/render_service_client/unittest/ui/rs_node_test.cpp +++ b/rosen/test/render_service/render_service_client/unittest/ui/rs_node_test.cpp @@ -5379,6 +5379,26 @@ HWTEST_F(RSNodeTest, SetMotionBlurPara, TestSize.Level1) EXPECT_NE(anchor[0], 0.f); } +/** + * @tc.name: SetMagnifierParams + * @tc.desc: test results of SetMagnifierParams + * @tc.type: FUNC + * @tc.require: issueI9KAZH + */ +HWTEST_F(RSNodeTest, SetMagnifierParams, TestSize.Level1) +{ + auto rsNode = RSCanvasNode::Create(); + Vector2f para = { 1.f, 1.f }; // for test + ASSERT_TRUE(rsNode != nullptr); + rsNode->SetMagnifierParams(para); + + auto iter = rsNode->propertyModifiers_.find(RSModifierType::MAGNIFIER_PARA); + ASSERT_TRUE(iter != rsNode->propertyModifiers_.end()); + auto property = std::static_pointer_cast>(iter->second->GetProperty()); + ASSERT_TRUE(property != nullptr); + EXPECT_EQ(property->Get(), para); +} + /** * @tc.name: SetDynamicLightUpRate * @tc.desc: test results of SetDynamicLightUpRate From 4efa246085f2df577fa065eefb7776dd2439ebea Mon Sep 17 00:00:00 2001 From: w00661663 Date: Wed, 26 Jun 2024 14:37:19 +0800 Subject: [PATCH 060/247] pointer render manager luminance picker Signed-off-by: w00661663 Change-Id: I3b61218f39535ef5305d774693b8d5eeb6b7d770 --- rosen/modules/render_service/BUILD.gn | 1 + .../rs_display_render_node_drawable.cpp | 8 + .../rs_surface_render_node_drawable.cpp | 11 + .../rs_surface_render_node_drawable.h | 2 + .../core/pipeline/rs_main_thread.cpp | 9 + .../pipeline/rs_pointer_render_manager.cpp | 362 ++++++++++++++++++ .../core/pipeline/rs_pointer_render_manager.h | 82 ++++ .../core/pipeline/rs_uni_render_processor.cpp | 4 + .../core/pipeline/rs_uni_render_processor.h | 1 + .../property/rs_color_picker_cache_task.h | 1 + .../property/rs_color_picker_cache_task.cpp | 6 +- 11 files changed, 484 insertions(+), 3 deletions(-) create mode 100644 rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp create mode 100644 rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.h diff --git a/rosen/modules/render_service/BUILD.gn b/rosen/modules/render_service/BUILD.gn index f0e762ce3c..4d94e31f3e 100644 --- a/rosen/modules/render_service/BUILD.gn +++ b/rosen/modules/render_service/BUILD.gn @@ -95,6 +95,7 @@ ohos_shared_library("librender_service") { "core/pipeline/rs_hardware_thread.cpp", "core/pipeline/rs_main_thread.cpp", "core/pipeline/rs_physical_screen_processor.cpp", + "core/pipeline/rs_pointer_render_manager.cpp", "core/pipeline/rs_processor.cpp", "core/pipeline/rs_processor_factory.cpp", "core/pipeline/rs_realtime_refresh_rate_manager.cpp", diff --git a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp index dff0d743ea..e9cf3df3ff 100644 --- a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp @@ -42,6 +42,7 @@ #include "pipeline/rs_uni_render_thread.h" #include "pipeline/rs_uni_render_util.h" #include "pipeline/sk_resource_manager.h" +#include "pipeline/rs_pointer_render_manager.h" #include "platform/common/rs_log.h" #include "platform/ohos/rs_jank_stats.h" #include "property/rs_point_light_manager.h" @@ -696,6 +697,13 @@ void RSDisplayRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) CreateUIFirstLayer(processor); processor->PostProcess(); RS_TRACE_END(); + + if (!mirroredNode) { + RS_TRACE_BEGIN("RSDisplayRenderNodeDrawable ProcessColorPicker"); + RSPointerRenderManager::GetInstance().ProcessColorPicker(processor, curCanvas_->GetGPUContext()); + RSPointerRenderManager::GetInstance().SetCacheImgForPointer(nullptr); + RS_TRACE_END(); + } } void RSDisplayRenderNodeDrawable::DrawMirrorScreen(std::shared_ptr& displayNodeSp, diff --git a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp index 36467f9f59..1cf3b33a08 100644 --- a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp @@ -30,6 +30,7 @@ #include "pipeline/rs_surface_render_node.h" #include "pipeline/rs_uni_render_thread.h" #include "pipeline/rs_uni_render_util.h" +#include "pipeline/rs_pointer_render_manager.h" #include "platform/common/rs_log.h" #include "platform/ohos/rs_node_stats.h" @@ -669,6 +670,16 @@ void RSSurfaceRenderNodeDrawable::DealWithSelfDrawingNodeBuffer(RSSurfaceRenderN #ifdef USE_VIDEO_PROCESSING_ENGINE params.screenBrightnessNits = surfaceNode.GetDisplayNit(); #endif + if (surfaceNode.IsHardwareEnabledTopSurface()) { + RSPointerRenderManager::GetInstance().SetCacheImgForPointer(canvas.GetSurface()->GetImageSnapshot()); + } + + DrawSelfDrawingNodeBuffer(surfaceNode, canvas, surfaceParams, params); +} + +void RSSurfaceRenderNodeDrawable::DrawSelfDrawingNodeBuffer(RSSurfaceRenderNode& surfaceNode, + RSPaintFilterCanvas& canvas, const RSSurfaceRenderParams& surfaceParams, BufferDrawParam& params) +{ auto bgColor = surfaceParams.GetBackgroundColor(); auto renderEngine = RSUniRenderThread::Instance().GetRenderEngine(); if ((surfaceParams.GetSelfDrawingNodeType() != SelfDrawingNodeType::VIDEO) && diff --git a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.h b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.h index feb0697d4d..04b1aca799 100644 --- a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.h +++ b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.h @@ -246,6 +246,8 @@ private: // DMA Buffer bool DrawUIFirstCacheWithDma(RSPaintFilterCanvas& canvas, RSSurfaceRenderParams& surfaceParams); void DrawDmaBufferWithGPU(RSPaintFilterCanvas& canvas); + void DrawSelfDrawingNodeBuffer(RSSurfaceRenderNode& surfaceNode, RSPaintFilterCanvas& canvas, + const RSSurfaceRenderParams& surfaceParams, BufferDrawParam& params); #ifndef ROSEN_CROSS_PLATFORM sptr consumerListener_ = nullptr; #endif diff --git a/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp b/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp index c6da9817a5..2d24020389 100644 --- a/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp @@ -78,6 +78,7 @@ #include "pipeline/rs_render_node_gc.h" #include "pipeline/rs_uifirst_manager.h" #include "pipeline/sk_resource_manager.h" +#include "pipeline/rs_pointer_render_manager.h" #include "platform/common/rs_innovation.h" #include "platform/common/rs_log.h" #include "platform/common/rs_system_properties.h" @@ -498,6 +499,14 @@ void RSMainThread::Init() RSRcdRenderManager::InitInstance(); +#if defined (RS_ENABLE_VK) + RSPointerRenderManager::InitInstance(GetRenderEngine()->GetVkImageManager()); +#endif + +#if defined (RS_ENABLE_GL) && defined (RS_ENABLE_EGLIMAGE) + RSPointerRenderManager::InitInstance(GetRenderEngine()->GetEglImageManager()); +#endif + #if defined(ROSEN_OHOS) && defined(RS_ENABLE_PARALLEL_UPLOAD) if (RSSystemProperties::GetGpuApiType() != GpuApiType::DDGR) { #if defined(NEW_SKIA) && defined(RS_ENABLE_UNI_RENDER) diff --git a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp new file mode 100644 index 0000000000..0bb23775ba --- /dev/null +++ b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp @@ -0,0 +1,362 @@ +/* + * Copyright (c) 2024-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 "common/rs_background_thread.h" +#include "src/gpu/gl/GrGLDefines.h" +#include "rs_uni_render_processor.h" +#include "pipeline/rs_uni_render_util.h" +#include "pipeline/rs_pointer_render_manager.h" + +namespace OHOS { +namespace Rosen { +namespace { +static const std::string DISPLAY_NODE = "DisplayNode"; +static const std::string POINTER_NODE = "pointer"; +} // namespace +static std::unique_ptr g_pointerRenderManagerInstance = + std::make_unique(); + + +RSPointerRenderManager::RSPointerRenderManager() +{ + colorPickerTask_ = std::make_shared(); +} + +RSPointerRenderManager& RSPointerRenderManager::GetInstance() +{ + return *g_pointerRenderManagerInstance; +} + +#if defined (RS_ENABLE_VK) +void RSPointerRenderManager::InitInstance(const std::shared_ptr& vkImageManager) +{ + g_pointerRenderManagerInstance->vkImageManager_ = vkImageManager; +} +#endif + +#if defined (RS_ENABLE_GL) && defined (RS_ENABLE_EGLIMAGE) +void RSPointerRenderManager::InitInstance(const std::shared_ptr& eglImageManager) +{ + g_pointerRenderManagerInstance->eglImageManager_ = eglImageManager; +} +#endif + +bool RSPointerRenderManager::CheckColorPickerEnabled() +{ + if (!isEnableCursorInversion_) { + return false; + } + + bool exists = false; + auto& hardwareNodes = RSUniRenderThread::Instance().GetRSRenderThreadParams()->GetHardwareEnabledTypeNodes(); + for (auto& it : hardwareNodes) { + auto surfaceNode = RSBaseRenderNode::ReinterpretCast(it); + if (surfaceNode != nullptr && surfaceNode->IsHardwareEnabledTopSurface()) { + exists = true; + break; + } + } + + if (taskDoing_) { + ROSEN_LOGD("RSPointerRenderManager::CheckColorPickerEnabled flag:%{public}u!", std::atomic_load(&taskDoing_)); + return false; + } + return exists; +} + +void RSPointerRenderManager::ProcessColorPicker(std::shared_ptr processor, + std::shared_ptr gpuContext) +{ + if (!CheckColorPickerEnabled()) { + ROSEN_LOGD("RSPointerRenderManager::CheckColorPickerEnabled is false!"); + return; + } + + if (cacheImgForPointer_) { + if (!GetIntersectImageBySubset(gpuContext)) { + ROSEN_LOGE("RSPointerRenderManager::GetIntersectImageBySubset is false!"); + return; + } + } else { + if (!CalculateTargetLayer(processor)) { // get the layer intersect with pointer and calculate the rect + ROSEN_LOGD("RSPointerRenderManager::CalculateTargetLayer is false!"); + return; + } + } + + // post color picker task to background thread + RunColorPickerTask(); +} + +bool RSPointerRenderManager::GetIntersectImageBySubset(std::shared_ptr gpuContext) +{ + auto& hardwareNodes = RSUniRenderThread::Instance().GetRSRenderThreadParams()->GetHardwareEnabledTypeNodes(); + for (auto& it : hardwareNodes) { + auto surfaceNode = RSBaseRenderNode::ReinterpretCast(it); + if (surfaceNode == nullptr || !surfaceNode->IsHardwareEnabledTopSurface()) { + continue; + } + image_ = std::make_shared(); + RectI pointerRect = surfaceNode->GetDstRect(); + Drawing::RectI drawingPointerRect = Drawing::RectI(pointerRect.GetLeft(), pointerRect.GetTop(), + pointerRect.GetRight(), pointerRect.GetBottom()); + image_->BuildSubset(cacheImgForPointer_, drawingPointerRect, *gpuContext); + return true; + } + return false; +} + +bool RSPointerRenderManager::CalculateTargetLayer(std::shared_ptr processor) +{ + auto uniRenderProcessor = std::static_pointer_cast(processor); + if (uniRenderProcessor == nullptr) { + ROSEN_LOGE("RSPointerRenderManager::CalculateTargetLayer uniRenderProcessor is null!"); + return false; + } + std::vector layers = uniRenderProcessor->GetLayers(); + forceCPU_ = RSBaseRenderEngine::NeedForceCPU(layers); + + std::sort(layers.begin(), layers.end(), [](LayerInfoPtr a, LayerInfoPtr b) { + return a->GetZorder() < b->GetZorder(); + }); + // get pointer and display node layer + bool find = false; + RectI pRect; + int displayNodeIndex = INT_MAX; + for (int i = 0; i < layers.size(); ++i) { + std::string name = layers[i]->GetSurface()->GetName(); + if (name.find(OHOS::Rosen::DISPLAY_NODE) != std::string::npos) { + displayNodeIndex = i; + continue; + } + if (name.find(OHOS::Rosen::POINTER_NODE) != std::string::npos) { + GraphicIRect rect = layers[i]->GetLayerSize(); + pRect.SetAll(rect.x, rect.y, rect.w, rect.h); + find = true; + continue; + } + } + + if (!find || displayNodeIndex == INT_MAX) { + ROSEN_LOGD("RSPointerRenderManager::CalculateTargetLayer cannot find pointer or display node."); + return false; + } + + // calculate the max intersection layer and rect + GetRectAndTargetLayer(layers, pRect, displayNodeIndex); + + return true; +} + +void RSPointerRenderManager::GetRectAndTargetLayer(std::vector& layers, RectI& pRect, + int displayNodeIndex) +{ + target_ = nullptr; + rect_.Clear(); + + for (int i = std::max(0, displayNodeIndex - 1); i >= 0; --i) { + if (layers[i]->GetSurface()->GetName().find(OHOS::Rosen::POINTER_NODE) != std::string::npos) { + continue; + } + GraphicIRect layerSize = layers[i]->GetLayerSize(); + RectI curRect = RectI(layerSize.x, layerSize.y, layerSize.w, layerSize.h); + if (!curRect.Intersect(pRect)) { + continue; + } + RectI dstRect = curRect.IntersectRect(pRect); + if (dstRect.width_ * dstRect.height_ >= rect_.width_ * rect_.height_) { + dstRect = dstRect.Offset(-curRect.GetLeft(), -curRect.GetTop()); + rect_ = dstRect; + target_ = layers[i]; + } + } + + // if not intersect with other layers, calculate the displayNode intersection rect + if (target_ == nullptr) { + target_ = layers[displayNodeIndex]; + GraphicIRect layerSize = target_->GetLayerSize(); + RectI curRect = RectI(layerSize.x, layerSize.y, layerSize.w, layerSize.h); + RectI dstRect = curRect.IntersectRect(pRect); + rect_ = dstRect.Offset(-curRect.GetLeft(), -curRect.GetTop()); + } +} + +void RSPointerRenderManager::RunColorPickerTask() +{ + if (!image_ && (target_ == nullptr || rect_.IsEmpty())) { + ROSEN_LOGE("RSPointerRenderManager::RunColorPickerTask failed for null target or rect is empty!"); + return; + } + + BufferDrawParam param; + if (!image_) { + ROSEN_LOGD("RSPointerRenderManager::RunColorPickerTask get param!"); + param = RSUniRenderUtil::CreateLayerBufferDrawParam(target_, forceCPU_); + } + std::function task = [this, param]() -> void { +#ifdef RS_ENABLE_UNI_RENDER + taskDoing_ = true; + auto image = image_ ? image_ : GetIntersectImageByLayer(param); + auto context = RSBackgroundThread::Instance().GetShareGPUContext().get(); + if (!colorPickerTask_->InitTask(image)) { + bool initStatus = colorPickerTask_->InitTask(image); + if (!initStatus) { + RS_LOGE("RSPointerRenderManager::RunColorPickerTask InitTask failed."); + image_ = nullptr; + taskDoing_ = false; + return; + } + } + colorPickerTask_->SetStatus(CacheProcessStatus::DOING); + if (!colorPickerTask_->InitSurface(context)) { + RS_LOGE("RSPointerRenderManager::RunColorPickerTask InitSurface failed."); + colorPickerTask_->SetStatus(CacheProcessStatus::WAITING); + image_ = nullptr; + taskDoing_ = false; + return; + } + if (!colorPickerTask_->Render()) { + RS_LOGE("RSPointerRenderManager::RunColorPickerTask Render failed."); + image_ = nullptr; + taskDoing_ = false; + return; + } + colorPickerTask_->Reset(); + RSColor color; + colorPickerTask_->GetColor(color); + + luminance_ = color.GetRed() * 0.2126f + color.GetGreen() * 0.7152f + color.GetBlue() * 0.0722f; + image_ = nullptr; + taskDoing_ = false; +#endif + }; + RSBackgroundThread::Instance().PostTask(task); +} + +std::shared_ptr RSPointerRenderManager::GetIntersectImageByLayer(const BufferDrawParam& param) +{ +#ifdef RS_ENABLE_UNI_RENDER + Drawing::RectI imgCutRect = Drawing::RectI(rect_.GetLeft(), rect_.GetTop(), rect_.GetRight(), rect_.GetBottom()); + auto context = RSBackgroundThread::Instance().GetShareGPUContext(); + if (context == nullptr) { + RS_LOGE("RSPointerRenderManager::GetIntersectImageByLayer context is nullptr."); + return nullptr; + } + if (param.buffer == nullptr) { + ROSEN_LOGE("RSPointerRenderManager::GetIntersectImageByLayer param buffer is nullptr"); + return nullptr; + } +#ifdef RS_ENABLE_VK + if (RSSystemProperties::GetGpuApiType() == GpuApiType::VULKAN + || RSSystemProperties::GetGpuApiType() == GpuApiType::DDGR) { + return GetIntersectImageFromVK(imgCutRect, context, param); + } +#endif +#if defined(RS_ENABLE_GL) && defined(RS_ENABLE_EGLIMAGE) + if (RSSystemProperties::GetGpuApiType() == GpuApiType::OPENGL) { + return GetIntersectImageFromGL(imgCutRect, context, param); + } +#endif +#endif + return nullptr; +} + +#ifdef RS_ENABLE_VK +std::shared_ptr RSPointerRenderManager::GetIntersectImageFromVK(Drawing::RectI& imgCutRect, + std::shared_ptr& context, const BufferDrawParam& param) +{ + if (vkImageManager_ == nullptr) { + RS_LOGE("RSPointerRenderManager::GetIntersectImageFromVK vkImageManager_ == nullptr"); + return nullptr; + } + auto imageCache = vkImageManager_->MapVkImageFromSurfaceBuffer(param.buffer, param.acquireFence, + param.threadIndex); + if (imageCache == nullptr) { + ROSEN_LOGE("RSPointerRenderManager::GetIntersectImageFromVK imageCache == nullptr!"); + return nullptr; + } + auto& backendTexture = imageCache->GetBackendTexture(); + Drawing::BitmapFormat bitmapFormat = RSBaseRenderUtil::GenerateDrawingBitmapFormat(param.buffer); + + std::shared_ptr layerImage = std::make_shared(); + if (!layerImage->BuildFromTexture(*context, backendTexture.GetTextureInfo(), + Drawing::TextureOrigin::TOP_LEFT, bitmapFormat, nullptr, + NativeBufferUtils::DeleteVkImage, imageCache->RefCleanupHelper())) { + ROSEN_LOGE("RSPointerRenderManager::GetIntersectImageFromVK backendTexture is not valid!"); + return nullptr; + } + + std::shared_ptr cutDownImage = std::make_shared(); + cutDownImage->BuildSubset(layerImage, imgCutRect, *context); + return cutDownImage; +} +#endif + +#if defined (RS_ENABLE_GL) && defined (RS_ENABLE_EGLIMAGE) +std::shared_ptr RSPointerRenderManager::GetIntersectImageFromGL(Drawing::RectI& imgCutRect, + std::shared_ptr& context, const BufferDrawParam& param) +{ + if (eglImageManager_ == nullptr) { + RS_LOGE("RSPointerRenderManager::GetIntersectImageFromGL eglImageManager_ == nullptr"); + return nullptr; + } + auto eglTextureId = eglImageManager_->MapEglImageFromSurfaceBuffer(param.buffer, + param.acquireFence, param.threadIndex); + if (eglTextureId == 0) { + RS_LOGE("RSPointerRenderManager::GetIntersectImageFromGL invalid texture ID"); + return nullptr; + } + + Drawing::BitmapFormat bitmapFormat = RSBaseRenderUtil::GenerateDrawingBitmapFormat(param.buffer); + Drawing::TextureInfo externalTextureInfo; + externalTextureInfo.SetWidth(param.buffer->GetSurfaceBufferWidth()); + externalTextureInfo.SetHeight(param.buffer->GetSurfaceBufferHeight()); + externalTextureInfo.SetIsMipMapped(false); + externalTextureInfo.SetTarget(GL_TEXTURE_EXTERNAL_OES); + externalTextureInfo.SetID(eglTextureId); + auto glType = GR_GL_RGBA8; + auto pixelFmt = param.buffer->GetFormat(); + if (pixelFmt == GRAPHIC_PIXEL_FMT_BGRA_8888) { + glType = GR_GL_BGRA8; + } else if (pixelFmt == GRAPHIC_PIXEL_FMT_YCBCR_P010 || pixelFmt == GRAPHIC_PIXEL_FMT_YCRCB_P010) { + glType = GL_RGB10_A2; + } + externalTextureInfo.SetFormat(glType); + + std::shared_ptr layerImage = std::make_shared(); + if (!layerImage->BuildFromTexture(*context, externalTextureInfo, + Drawing::TextureOrigin::TOP_LEFT, bitmapFormat, nullptr)) { + RS_LOGE("RSPointerRenderManager::GetIntersectImageFromGL image BuildFromTexture failed"); + return nullptr; + } + + std::shared_ptr cutDownImage = std::make_shared(); + cutDownImage->BuildSubset(layerImage, imgCutRect, *context); + Drawing::ImageInfo info = Drawing::ImageInfo(imgCutRect.GetWidth(), imgCutRect.GetHeight(), + Drawing::COLORTYPE_RGBA_8888, Drawing::ALPHATYPE_PREMUL); + + std::shared_ptr surface = Drawing::Surface::MakeRenderTarget(context.get(), false, info); + if (surface == nullptr) { + RS_LOGE("RSPointerRenderManager::GetIntersectImageFromGL MakeRenderTarget failed."); + return nullptr; + } + auto drawCanvas = std::make_shared(surface.get()); + drawCanvas->DrawImage(*cutDownImage, 0.f, 0.f, Drawing::SamplingOptions()); + surface->FlushAndSubmit(true); + return surface.get()->GetImageSnapshot(); +} +#endif +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.h b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.h new file mode 100644 index 0000000000..5abb962566 --- /dev/null +++ b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2024-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 RS_POINTER_RENDER_MANAGER_H +#define RS_POINTER_RENDER_MANAGER_H + +#include "pipeline/rs_display_render_node.h" +#include "rs_processor.h" +#ifdef RS_ENABLE_VK +#include "rs_vk_image_manager.h" +#endif + +namespace OHOS::Rosen { + +class RSPointerRenderManager { +public: + RSPointerRenderManager(); + ~RSPointerRenderManager() = default; + +#if defined (RS_ENABLE_VK) + static void InitInstance(const std::shared_ptr& vkImageManager); +#endif + +#if defined (RS_ENABLE_GL) && defined (RS_ENABLE_EGLIMAGE) + static void InitInstance(const std::shared_ptr& eglImageManager); +#endif + + static RSPointerRenderManager& GetInstance(); + void ProcessColorPicker(std::shared_ptr processor, std::shared_ptr gpuContext); + void SetCacheImgForPointer(std::shared_ptr cacheImgForPointer) + { + cacheImgForPointer_ = cacheImgForPointer; + } + +private: + bool CheckColorPickerEnabled(); + bool CalculateTargetLayer(std::shared_ptr processor); + void RunColorPickerTask(); + std::shared_ptr GetIntersectImageByLayer(const BufferDrawParam& param); + bool GetIntersectImageBySubset(std::shared_ptr gpuContext); +#if defined (RS_ENABLE_VK) + std::shared_ptr GetIntersectImageFromVK(Drawing::RectI& imgCutRect, + std::shared_ptr& context, const BufferDrawParam& param); +#endif +#if defined (RS_ENABLE_GL) && defined (RS_ENABLE_EGLIMAGE) + std::shared_ptr GetIntersectImageFromGL(Drawing::RectI& imgCutRect, + std::shared_ptr& context, const BufferDrawParam& param); +#endif + std::shared_ptr GetImageTexture(std::shared_ptr& image); + void GetRectAndTargetLayer(std::vector& layers, RectI& pRect, int displayNodeIndex); + +private: + RectI rect_; + LayerInfoPtr target_; + std::shared_ptr colorPickerTask_; +#if defined (RS_ENABLE_VK) + std::shared_ptr vkImageManager_ = nullptr; +#endif +#if defined (RS_ENABLE_GL) && defined (RS_ENABLE_EGLIMAGE) + std::shared_ptr eglImageManager_ = nullptr; +#endif + int16_t luminance_ = 0; + bool forceCPU_ = false; + std::shared_ptr image_ = nullptr; + std::atomic taskDoing_ = false; + bool isEnableCursorInversion_ = false; + std::shared_ptr cacheImgForPointer_ = nullptr; +}; +} +#endif // RS_POINTER_RENDER_MANAGER_H \ No newline at end of file diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_processor.cpp b/rosen/modules/render_service/core/pipeline/rs_uni_render_processor.cpp index a9f519142d..d9a8cdade3 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_processor.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_processor.cpp @@ -203,5 +203,9 @@ void RSUniRenderProcessor::ProcessRcdSurface(RSRcdSurfaceRenderNode& node) layers_.emplace_back(layer); } +std::vector RSUniRenderProcessor::GetLayers() const +{ + return layers_; +} } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_processor.h b/rosen/modules/render_service/core/pipeline/rs_uni_render_processor.h index ce47181016..6a5d375a52 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_processor.h +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_processor.h @@ -42,6 +42,7 @@ public: void ProcessDisplaySurface(RSDisplayRenderNode& node) override; void ProcessRcdSurface(RSRcdSurfaceRenderNode& node) override; void PostProcess() override; + std::vector GetLayers() const; private: LayerInfoPtr GetLayerInfo(RSSurfaceRenderParams& params, sptr& buffer, sptr& prebuffer, const sptr& consumer, const sptr& acquireFence); diff --git a/rosen/modules/render_service_base/include/property/rs_color_picker_cache_task.h b/rosen/modules/render_service_base/include/property/rs_color_picker_cache_task.h index b2b285a40f..3686311698 100644 --- a/rosen/modules/render_service_base/include/property/rs_color_picker_cache_task.h +++ b/rosen/modules/render_service_base/include/property/rs_color_picker_cache_task.h @@ -120,6 +120,7 @@ private: std::atomic cacheProcessStatus_ = CacheProcessStatus::WAITING; std::shared_ptr> waitRelease_ = std::make_shared>(false); std::shared_ptr imageSnapshotCache_ = nullptr; + Drawing::BitmapFormat cacheBitmapFormat_; RSColor color_; std::vector colorArray_; std::vector colorArrayValid_; diff --git a/rosen/modules/render_service_base/src/property/rs_color_picker_cache_task.cpp b/rosen/modules/render_service_base/src/property/rs_color_picker_cache_task.cpp index ee638ce206..a61172f0b0 100644 --- a/rosen/modules/render_service_base/src/property/rs_color_picker_cache_task.cpp +++ b/rosen/modules/render_service_base/src/property/rs_color_picker_cache_task.cpp @@ -60,6 +60,8 @@ bool RSColorPickerCacheTask::InitTask(const std::shared_ptr imag } if (imageSnapshotCache_) { cacheBackendTexture_ = imageSnapshotCache_->GetBackendTexture(false, nullptr); + cacheBitmapFormat_ = Drawing::BitmapFormat { imageSnapshotCache_->GetColorType(), + imageSnapshotCache_->GetAlphaType() }; return true; } ROSEN_LOGD("RSColorPickerCacheTask InitTask:%{public}p", this); @@ -159,8 +161,6 @@ bool RSColorPickerCacheTask::Render() return false; } auto threadImage = std::make_shared(); - Drawing::BitmapFormat info = Drawing::BitmapFormat { Drawing::COLORTYPE_RGBA_8888, - Drawing::ALPHATYPE_PREMUL }; { std::unique_lock lock(*grBackendTextureMutex_); if (cacheCanvas == nullptr || !cacheBackendTexture_.IsValid()) { @@ -170,7 +170,7 @@ bool RSColorPickerCacheTask::Render() } SharedTextureContext* sharedContext = new SharedTextureContext(imageSnapshotCache_); if (!threadImage->BuildFromTexture(*cacheCanvas->GetGPUContext(), cacheBackendTexture_.GetTextureInfo(), - Drawing::TextureOrigin::BOTTOM_LEFT, info, nullptr, + Drawing::TextureOrigin::BOTTOM_LEFT, cacheBitmapFormat_, nullptr, SKResourceManager::DeleteSharedTextureContext, sharedContext)) { SetStatus(CacheProcessStatus::WAITING); ROSEN_LOGE("RSColorPickerCacheTask::Render BuildFromTexture failed"); From d5ab318869be7f39530df7500b666a24440e12bb Mon Sep 17 00:00:00 2001 From: chenyifan12 <1484004766@qq.com> Date: Thu, 27 Jun 2024 07:17:58 +0000 Subject: [PATCH 061/247] update rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp. Signed-off-by: chenyifan12 <1484004766@qq.com> --- .../graphics_effect/src/ge_kawase_blur_shader_filter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp b/rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp index 765a91fb4c..f0f118ed51 100644 --- a/rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp +++ b/rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp @@ -281,7 +281,7 @@ void GEKawaseBlurShaderFilter::CheckInputImage(Drawing::Canvas& canvas, const st if (image->GetImageInfo().GetBound() != srcRect) { auto resizedImage = std::make_shared(); auto gpuCtx = canvas.GetGPUContext(); - if (gpuCtx == nullptr || !(image->IsValid(gpuCtx.get())) { + if (gpuCtx == nullptr || !(image->IsValid(gpuCtx.get()))) { LOGE("GEKawaseBlurShaderFilter::CheckInputImage invalid image"); return; } From 4b2d795837619a5d98c1f3e1aff202501a3a1eb4 Mon Sep 17 00:00:00 2001 From: p30061306 Date: Thu, 27 Jun 2024 15:31:09 +0800 Subject: [PATCH 062/247] Description:format gni file Team:OTHER Feature or Bugfix:Bugfix Binary Source:No PrivateCode(Yes/No):No Signed-off-by: p30061306 --- adapter/ohos/build/config.gni | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapter/ohos/build/config.gni b/adapter/ohos/build/config.gni index fc3b8cb914..a24a4bfed0 100644 --- a/adapter/ohos/build/config.gni +++ b/adapter/ohos/build/config.gni @@ -11,8 +11,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("common.gni") import("//build/ohos.gni") +import("common.gni") form_components_support = true plugin_components_support = true From 71ab54da3a1596da1bac590764b865f5ef7dbfa8 Mon Sep 17 00:00:00 2001 From: chenyifan12 <1484004766@qq.com> Date: Thu, 27 Jun 2024 07:32:04 +0000 Subject: [PATCH 063/247] update rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp. Signed-off-by: chenyifan12 <1484004766@qq.com> --- .../graphics_effect/src/ge_kawase_blur_shader_filter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp b/rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp index f0f118ed51..4bd25c9b6b 100644 --- a/rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp +++ b/rosen/modules/graphics_effect/src/ge_kawase_blur_shader_filter.cpp @@ -285,7 +285,7 @@ void GEKawaseBlurShaderFilter::CheckInputImage(Drawing::Canvas& canvas, const st LOGE("GEKawaseBlurShaderFilter::CheckInputImage invalid image"); return; } - if (resizedImage->BuildSubset(image, srcRect, *gpu)) { + if (resizedImage->BuildSubset(image, srcRect, *gpuCtx)) { checkedImage = resizedImage; LOGD("GEKawaseBlurShaderFilter::resize image success"); } else { From 4a59bc2005aca1f7eeeaa402b645772bc2c46ae6 Mon Sep 17 00:00:00 2001 From: lvmengyu Date: Thu, 27 Jun 2024 16:20:15 +0800 Subject: [PATCH 064/247] =?UTF-8?q?=E5=A2=9E=E5=8A=A0RS=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lvmengyu Change-Id: Ie856c91025f110b00d780b8ab4650997f9e9d1b5 --- .../2d_graphics/unittest/draw/canvas_test.cpp | 15 ++++++ .../unittest/common/rs_vector4_test.cpp | 12 +++++ .../unittest/render/rs_border_test.cpp | 41 +++++++++++++++ .../unittest/render/rs_image_test.cpp | 14 +++++ .../unittest/render/rs_mask_test.cpp | 13 +++++ .../modifier/rs_modifier_extractor_test.cpp | 52 +++++++++++++++++++ .../unittest/ui/rs_node_test.cpp | 17 +++++- 7 files changed, 162 insertions(+), 2 deletions(-) diff --git a/rosen/test/2d_graphics/unittest/draw/canvas_test.cpp b/rosen/test/2d_graphics/unittest/draw/canvas_test.cpp index ff04915e43..c1f0588607 100644 --- a/rosen/test/2d_graphics/unittest/draw/canvas_test.cpp +++ b/rosen/test/2d_graphics/unittest/draw/canvas_test.cpp @@ -775,6 +775,21 @@ HWTEST_F(CanvasTest, CanvasAttachAndDetachBrushTest001, TestSize.Level1) canvas->DetachBrush(); } +/** + * @tc.name: SetOffscreenTest001 + * @tc.desc: Test for SetOffscreen functions. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(CanvasTest, SetOffscreenTest001, TestSize.Level1) +{ + auto canvas = std::make_unique(); + ASSERT_TRUE(canvas != nullptr); + canvas->SetOffscreen(true); + bool state = canvas->GetOffscreen(); + ASSERT_TRUE(state); +} + /** * @tc.name: GetRecordingStateTest001 * @tc.desc: Test for GetRecordingState functions. diff --git a/rosen/test/render_service/render_service_base/unittest/common/rs_vector4_test.cpp b/rosen/test/render_service/render_service_base/unittest/common/rs_vector4_test.cpp index 2d2b227490..59729d26d9 100644 --- a/rosen/test/render_service/render_service_base/unittest/common/rs_vector4_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/common/rs_vector4_test.cpp @@ -177,6 +177,18 @@ HWTEST_F(Vector4Test, SetZero001, TestSize.Level1) EXPECT_TRUE(vector.data_[0] == 0.f); } +/** + * @tc.name: Size001 + * @tc.desc: test results of Size + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(Vector4Test, Size001, TestSize.Level1) +{ + Vector4 vector(1.f, 0.f, 0.f, 0.f); // for test + EXPECT_EQ(vector.Size(), 4); +} + /** * @tc.name: Minus001 * @tc.desc: test results of operator- diff --git a/rosen/test/render_service/render_service_base/unittest/render/rs_border_test.cpp b/rosen/test/render_service/render_service_base/unittest/render/rs_border_test.cpp index ad825a4fc5..9535f559fa 100644 --- a/rosen/test/render_service/render_service_base/unittest/render/rs_border_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/render/rs_border_test.cpp @@ -490,6 +490,47 @@ HWTEST_F(RSBorderTest, ApplyLineStyleTest, TestSize.Level1) EXPECT_TRUE(border->ApplyLineStyle(pen, 0, 1.f)); } +/** + * @tc.name: ApplySimpleBorderTest + * @tc.desc: Verify function ApplySimpleBorder + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSBorderTest, ApplySimpleBorderTest, TestSize.Level1) +{ + auto border = std::make_shared(); + border->colors_.clear(); + border->widths_.clear(); + border->styles_.clear(); + RRect rect; + EXPECT_FALSE(border->ApplySimpleBorder(rect)); + { + Color color = { 0, 0, 0, 0 }; + border->colors_.push_back(color); + EXPECT_FALSE(border->ApplySimpleBorder(rect)); + border->widths_.push_back(1); + EXPECT_FALSE(border->ApplySimpleBorder(rect)); + border->styles_.push_back(BorderStyle::SOLID); + EXPECT_TRUE(border->ApplySimpleBorder(rect)); + + } + + { + border->styles_.push_back(BorderStyle::DASHED); + EXPECT_FALSE(border->ApplySimpleBorder(rect)); + Color color = { 0, 0, 0, 0 }; + border->colors_.push_back(color); + EXPECT_FALSE(border->ApplySimpleBorder(rect)); + } + + { + border->widths_.push_back(1); + EXPECT_FALSE(border->ApplySimpleBorder(rect)); + border->styles_.push_back(BorderStyle::SOLID); + EXPECT_FALSE(border->ApplySimpleBorder(rect)); + } +} + /** * @tc.name: PaintFourLineTest * @tc.desc: Verify function PaintFourLine diff --git a/rosen/test/render_service/render_service_base/unittest/render/rs_image_test.cpp b/rosen/test/render_service/render_service_base/unittest/render/rs_image_test.cpp index 50da6e420a..0705bcbe75 100644 --- a/rosen/test/render_service/render_service_base/unittest/render/rs_image_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/render/rs_image_test.cpp @@ -184,6 +184,20 @@ HWTEST_F(RSImageTest, ApplyImageFitTest001, TestSize.Level1) EXPECT_EQ(image->srcRect_.width_, 1); } +/** + * @tc.name: GetAdaptiveImageInfoWithFrameRectTest001 + * @tc.desc: Verify function GetAdaptiveImageInfoWithFrameRect + * @tc.type:FUNC + */ +HWTEST_F(RSImageTest, GetAdaptiveImageInfoWithFrameRectTest001, TestSize.Level1) +{ + Drawing::Rect frameRect; + auto image = std::make_shared(); + image->imageFit_ = ImageFit::COVER; + EXPECT_EQ( + image->GetAdaptiveImageInfoWithCustomizedFrameRect(frameRect).fitNum, static_cast(ImageFit::COVER)); +} + /** * @tc.name: ApplyCanvasClipTest001 * @tc.desc: Verify function ApplyCanvasClip diff --git a/rosen/test/render_service/render_service_base/unittest/render/rs_mask_test.cpp b/rosen/test/render_service/render_service_base/unittest/render/rs_mask_test.cpp index b0b0826ab7..42929b4d66 100644 --- a/rosen/test/render_service/render_service_base/unittest/render/rs_mask_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/render/rs_mask_test.cpp @@ -283,6 +283,19 @@ HWTEST_F(RSMaskTest, GetMaskPathTest001, TestSize.Level1) EXPECT_TRUE(mask->GetMaskPath() != nullptr); } +/** + * @tc.name: SetMaskPenTest001 + * @tc.desc: Verify function SetMaskPen + * @tc.type:FUNC + */ +HWTEST_F(RSMaskTest, SetMaskPenTest001, TestSize.Level1) +{ + auto mask = std::make_shared(); + Drawing::Pen pen; + mask->SetMaskPen(pen); + EXPECT_EQ(mask->GetMaskPen(), pen); +} + /** * @tc.name: GetMaskPenTest001 * @tc.desc: Verify function GetMaskPen diff --git a/rosen/test/render_service/render_service_client/unittest/modifier/rs_modifier_extractor_test.cpp b/rosen/test/render_service/render_service_client/unittest/modifier/rs_modifier_extractor_test.cpp index 104fa4da67..f810c968dd 100644 --- a/rosen/test/render_service/render_service_client/unittest/modifier/rs_modifier_extractor_test.cpp +++ b/rosen/test/render_service/render_service_client/unittest/modifier/rs_modifier_extractor_test.cpp @@ -81,6 +81,58 @@ HWTEST_F(RSModifierExtractorTest, NodeTest001, TestSize.Level1) ASSERT_EQ(extractor.GetLightColor(), valTest2); } +/** + * @tc.name: GetBorderDashWidth001 + * @tc.desc: test results of GetBorderDashWidth + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(RSModifierExtractorTest, GetBorderDashWidth001, TestSize.Level1) +{ + auto extractor = std::make_shared(); + Vector4f vector = extractor->GetBorderDashWidth(); + EXPECT_EQ(vector, Vector4f(0.f)); +} + +/** + * @tc.name: GetBorderDashGap001 + * @tc.desc: test results of GetBorderDashGap + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(RSModifierExtractorTest, GetBorderDashGap001, TestSize.Level1) +{ + auto extractor = std::make_shared(); + Vector4f vector = extractor->GetBorderDashGap(); + EXPECT_EQ(vector, Vector4f(0.f)); +} + +/** + * @tc.name: GetOutlineDashWidth001 + * @tc.desc: test results of GetOutlineDashWidth + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(RSModifierExtractorTest, GetOutlineDashWidth001, TestSize.Level1) +{ + auto extractor = std::make_shared(); + Vector4f vector = extractor->GetOutlineDashWidth(); + EXPECT_EQ(vector, Vector4f(0.f)); +} + +/** + * @tc.name: GetOutlineDashGap001 + * @tc.desc: test results of GetOutlineDashWidth + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(RSModifierExtractorTest, GetOutlineDashGap001, TestSize.Level1) +{ + auto extractor = std::make_shared(); + Vector4f vector = extractor->GetOutlineDashWidth(); + EXPECT_EQ(vector, Vector4f(0.f)); +} + /** * @tc.name: GetOutlineColor001 * @tc.desc: test results of GetOutlineColor diff --git a/rosen/test/render_service/render_service_client/unittest/ui/rs_node_test.cpp b/rosen/test/render_service/render_service_client/unittest/ui/rs_node_test.cpp index 5eb89918e5..74e70c37b1 100644 --- a/rosen/test/render_service/render_service_client/unittest/ui/rs_node_test.cpp +++ b/rosen/test/render_service/render_service_client/unittest/ui/rs_node_test.cpp @@ -5632,12 +5632,12 @@ HWTEST_F(RSNodeTest, SetShadowColorStrategy, TestSize.Level1) } /** - * @tc.name: SetClipRRect + * @tc.name: SetClipRRect001 * @tc.desc: test results of SetClipRRect * @tc.type: FUNC * @tc.require: issueI9KAZH */ -HWTEST_F(RSNodeTest, SetClipRRect, TestSize.Level1) +HWTEST_F(RSNodeTest, SetClipRRect001, TestSize.Level1) { Vector4f clipRect = { 1.f, 1.f, 1.f, 1.f }; // for test auto rsNode = RSCanvasNode::Create(); @@ -5646,6 +5646,19 @@ HWTEST_F(RSNodeTest, SetClipRRect, TestSize.Level1) EXPECT_EQ(clipRect[0], 1.f); } +/** + * @tc.name: SetClipRRect002 + * @tc.desc: test results of SetClipRRect + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(RSNodeTest, SetClipRRect002, TestSize.Level1) +{ + auto rect = std::make_shared(); + auto rsNode = RSCanvasNode::Create(); + rsNode->SetClipRRect(rect); +} + /** * @tc.name: SetMask * @tc.desc: test results of SetMask From 384ed8a19aa7a3a9ec8beef3e1dca61e72e309ed Mon Sep 17 00:00:00 2001 From: chenqinxin Date: Thu, 27 Jun 2024 16:35:50 +0800 Subject: [PATCH 065/247] create surface node async for selfdrawing node Signed-off-by: chenqinxin Change-Id: I4055e1fd549ae5e6cc44d95177c8cdf4f638933a --- rosen/modules/render_service_client/core/ui/rs_surface_node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/modules/render_service_client/core/ui/rs_surface_node.cpp b/rosen/modules/render_service_client/core/ui/rs_surface_node.cpp index b4806e4632..02191c0781 100644 --- a/rosen/modules/render_service_client/core/ui/rs_surface_node.cpp +++ b/rosen/modules/render_service_client/core/ui/rs_surface_node.cpp @@ -76,7 +76,7 @@ RSSurfaceNode::SharedPtr RSSurfaceNode::Create(const RSSurfaceNodeConfig& surfac .bundleName = node->bundleName_, .additionalData = surfaceNodeConfig.additionalData, .isTextureExportNode = surfaceNodeConfig.isTextureExportNode, - .isSync = surfaceNodeConfig.isSync, + .isSync = isWindow, .surfaceWindowType = surfaceNodeConfig.surfaceWindowType, }; config.nodeType = type; From e25d8d140342a440b059d8a9f836190cf8f715fa Mon Sep 17 00:00:00 2001 From: yanghua_angel Date: Thu, 27 Jun 2024 16:59:59 +0800 Subject: [PATCH 066/247] add tdd Signed-off-by: yanghua_angel --- .../rs_transaction_controller_test.cpp | 10 ++++++++ .../unittest/pipeline/rs_main_thread_test.cpp | 23 +++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/rosen/modules/render_service_client/test/unittest/rs_transaction_controller_test.cpp b/rosen/modules/render_service_client/test/unittest/rs_transaction_controller_test.cpp index 508525b57e..c723386e07 100644 --- a/rosen/modules/render_service_client/test/unittest/rs_transaction_controller_test.cpp +++ b/rosen/modules/render_service_client/test/unittest/rs_transaction_controller_test.cpp @@ -106,6 +106,16 @@ HWTEST_F(RSTransactionControllerTest, RSTransactionControllerTest003, TestSize.L transaction->CloseSyncTransaction(); transaction->Begin(); transaction->Commit(); + transaction->SetDuration(0); + transaction->GetDuration(); + transaction->SetParentPid(0); + transaction->SetChildPid(0); + transaction->GetParentPid(); + transaction->GetChildPid(); + transaction->IsOpenSyncTransaction(); + transaction->GetSyncId(); + transaction->GetExtensionCount(); + transaction->SetExtensionCount(0); GTEST_LOG_(INFO) << "RSTransactionControllerTest RSTransactionControllerTest003 end"; } diff --git a/rosen/test/render_service/render_service/unittest/pipeline/rs_main_thread_test.cpp b/rosen/test/render_service/render_service/unittest/pipeline/rs_main_thread_test.cpp index beec3e9509..77ebd4cb47 100644 --- a/rosen/test/render_service/render_service/unittest/pipeline/rs_main_thread_test.cpp +++ b/rosen/test/render_service/render_service/unittest/pipeline/rs_main_thread_test.cpp @@ -390,7 +390,7 @@ HWTEST_F(RSMainThreadTest, ProcessSyncRSTransactionData001, TestSize.Level1) rsTransactionData->SetSyncId(1); mainThread->syncTransactionCount_ = 1; mainThread->ProcessSyncRSTransactionData(rsTransactionData, pid); - ASSERT_EQ(mainThread->syncTransactionData_.empty(), true); + ASSERT_EQ(mainThread->syncTransactionData_.empty(), false); } /** @@ -426,20 +426,25 @@ HWTEST_F(RSMainThreadTest, ProcessSyncTransactionCount, TestSize.Level1) mainThread->syncTransactionCount_ = 1; rsTransactionData->SetParentPid(-1); + rsTransactionData->SetChildPid(-1); mainThread->ProcessSyncTransactionCount(rsTransactionData); - ASSERT_EQ(mainThread->syncTransactionCount_, 0); - - mainThread->syncTransactionCount_ = 0; - rsTransactionData->SetParentPid(-1); - rsTransactionData->MarkNeedCloseSync(); - mainThread->ProcessSyncTransactionCount(rsTransactionData); - ASSERT_EQ(mainThread->syncTransactionCount_, 0); + auto parentPid = rsTransactionData->GetParentPid(); + auto childPid = rsTransactionData->GetChildPid(); + ASSERT_EQ(parentPid, -1); + ASSERT_EQ(childPid, -1); mainThread->syncTransactionCount_ = 1; rsTransactionData->SetSyncTransactionNum(1); rsTransactionData->SetParentPid(1); mainThread->ProcessSyncTransactionCount(rsTransactionData); - ASSERT_EQ(mainThread->syncTransactionCount_, 0); + ASSERT_EQ(rsTransactionData->GetSyncTransactionNum(), 1); + + mainThread->syncTransactionCount_ = 0; + rsTransactionData->MarkNeedCloseSync(); + mainThread->ProcessSyncTransactionCount(rsTransactionData); + mainThread->ProcessEmptySyncTransactionCount(0, 0, 0); + mainThread->StartSyncTransactionFallbackTask(rsTransactionData); + ASSERT_EQ(rsTransactionData->IsNeedCloseSync(), true); } /** From 06be5e8b2f48727456854f48094f42e6ba175653 Mon Sep 17 00:00:00 2001 From: hjl Date: Thu, 27 Jun 2024 17:08:25 +0800 Subject: [PATCH 067/247] =?UTF-8?q?BUILD.gn=E9=85=8D=E7=BD=AE=E4=BF=9D?= =?UTF-8?q?=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hjl --- interfaces/kits/napi/graphic/text/BUILD.gn | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/napi/graphic/text/BUILD.gn b/interfaces/kits/napi/graphic/text/BUILD.gn index 8271f57a02..44087ce4e4 100755 --- a/interfaces/kits/napi/graphic/text/BUILD.gn +++ b/interfaces/kits/napi/graphic/text/BUILD.gn @@ -43,9 +43,20 @@ ohos_shared_library("text_napi") { ":text_config", ] + sanitize = { + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } + deps = [ ":text_napi_impl" ] - external_deps = [ "napi:ace_napi" ] + external_deps = [ + "hilog::libhilog", + "napi:ace_napi", + ] + relative_install_dir = "module/graphics" part_name = "graphic_2d" subsystem_name = "graphic" @@ -68,6 +79,13 @@ ohos_shared_library("text_napi_impl") { ":text_config", ] + sanitize = { + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } + deps = [ "$graphic_2d_root/interfaces/kits/napi/graphic/drawing:drawing_napi_impl", "$graphic_2d_root/rosen/modules/2d_graphics:2d_graphics", @@ -99,4 +117,4 @@ ohos_shared_library("text_napi_impl") { innerapi_tags = [ "platformsdk" ] part_name = "graphic_2d" subsystem_name = "graphic" -} +} \ No newline at end of file From fc80bd5b4a938dd9f84860e0f5df90a18b7438fe Mon Sep 17 00:00:00 2001 From: huangjunlin Date: Thu, 27 Jun 2024 09:27:03 +0000 Subject: [PATCH 068/247] update interfaces/kits/napi/graphic/text/BUILD.gn. Signed-off-by: huangjunlin --- interfaces/kits/napi/graphic/text/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/napi/graphic/text/BUILD.gn b/interfaces/kits/napi/graphic/text/BUILD.gn index 44087ce4e4..374e110224 100755 --- a/interfaces/kits/napi/graphic/text/BUILD.gn +++ b/interfaces/kits/napi/graphic/text/BUILD.gn @@ -53,7 +53,7 @@ ohos_shared_library("text_napi") { deps = [ ":text_napi_impl" ] external_deps = [ - "hilog::libhilog", + "hilog:libhilog", "napi:ace_napi", ] From 0dc4b1a879a55a0892e85af9aa35c94844fdc5be Mon Sep 17 00:00:00 2001 From: lishijie Date: Wed, 26 Jun 2024 17:03:16 +0800 Subject: [PATCH 069/247] add tdd Signed-off-by: lishijie Change-Id: I23043c92e07a4c0f8b8d7f85de116f61b991e5aa --- rosen/test/render_service/BUILD.gn | 1 + .../unittest/params/BUILD.gn | 77 +++++++ .../rs_canvas_drawing_render_params_test.cpp | 74 +++++++ .../params/rs_display_render_params_test.cpp | 197 ++++++++++++++++++ .../params/rs_effect_render_params_test.cpp | 106 ++++++++++ .../unittest/params/rs_render_params_test.cpp | 104 +++++++++ 6 files changed, 559 insertions(+) create mode 100644 rosen/test/render_service/render_service_base/unittest/params/BUILD.gn create mode 100644 rosen/test/render_service/render_service_base/unittest/params/rs_canvas_drawing_render_params_test.cpp create mode 100644 rosen/test/render_service/render_service_base/unittest/params/rs_display_render_params_test.cpp create mode 100644 rosen/test/render_service/render_service_base/unittest/params/rs_effect_render_params_test.cpp create mode 100644 rosen/test/render_service/render_service_base/unittest/params/rs_render_params_test.cpp diff --git a/rosen/test/render_service/BUILD.gn b/rosen/test/render_service/BUILD.gn index 5d82b4c00b..e47487b9dd 100755 --- a/rosen/test/render_service/BUILD.gn +++ b/rosen/test/render_service/BUILD.gn @@ -100,6 +100,7 @@ group("test") { "render_service_base/unittest/modifier:unittest", "render_service_base/unittest/offscreen_render:unittest", "render_service_base/unittest/overdraw:unittest", + "render_service_base/unittest/params:unittest", "render_service_base/unittest/pipeline:unittest", "render_service_base/unittest/platform/ohos:unittest", "render_service_base/unittest/platform/ohos/backend:unittest", diff --git a/rosen/test/render_service/render_service_base/unittest/params/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/params/BUILD.gn new file mode 100644 index 0000000000..2e84d43676 --- /dev/null +++ b/rosen/test/render_service/render_service_base/unittest/params/BUILD.gn @@ -0,0 +1,77 @@ +# Copyright (c) 2022 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. + +import("//build/test.gni") +import("//foundation/graphic/graphic_2d/ace_platforms.gni") +import("//foundation/graphic/graphic_2d/graphic_config.gni") + +module_output_path = "graphic/rosen_engine/render_service_base/params" + +############################## RSRenderServiceBaseParamsTest ################################## +ohos_unittest("RSRenderServiceBaseParamsTest") { + module_out_path = module_output_path + + sources = [ + "rs_canvas_drawing_render_params_test.cpp", + "rs_display_render_params_test.cpp", + "rs_effect_render_params_test.cpp", + "rs_render_params_test.cpp", + ] + + configs = [ + ":render_test", + "$graphic_2d_root/rosen/modules/render_service_base:export_config", + ] + + cflags = [ + "-Dprivate = public", + "-Dprotected = public", + ] + + include_dirs = [ + "$graphic_2d_root/rosen/modules/render_service_base/include", + "$graphic_2d_root/rosen/modules/render_service_base/src", + "$graphic_2d_root/rosen/include", + "$graphic_2d_root/rosen/test/include", + "$graphic_2d_root/rosen/modules/graphics_effect/include", + ] + + deps = [ + "$graphic_2d_root/rosen/modules/render_service_base:librender_service_base_static", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + "init:libbegetutil", + "skia:skia_canvaskit", + ] + + subsystem_name = "graphic" +} + +############################################################################### +config("render_test") { + visibility = [ ":*" ] + include_dirs = [ + "$ace_root", + "$graphic_2d_root/rosen/modules/render_service_base", + ] +} + +group("unittest") { + testonly = true + + deps = [ ":RSRenderServiceBaseParamsTest" ] +} diff --git a/rosen/test/render_service/render_service_base/unittest/params/rs_canvas_drawing_render_params_test.cpp b/rosen/test/render_service/render_service_base/unittest/params/rs_canvas_drawing_render_params_test.cpp new file mode 100644 index 0000000000..b19a361330 --- /dev/null +++ b/rosen/test/render_service/render_service_base/unittest/params/rs_canvas_drawing_render_params_test.cpp @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2023-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 "gtest/gtest.h" +#include "params/rs_canvas_drawing_render_params.h" +#include "limit_number.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS::Rosen { +class RSCanvasDrawingRenderParamsTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; + static void DisplayTestInfo(); +}; + +void RSCanvasDrawingRenderParamsTest::SetUpTestCase() {} +void RSCanvasDrawingRenderParamsTest::TearDownTestCase() {} +void RSCanvasDrawingRenderParamsTest::SetUp() {} +void RSCanvasDrawingRenderParamsTest::TearDown() {} +void RSCanvasDrawingRenderParamsTest::DisplayTestInfo() +{ + return; +} + +/** + * @tc.name: OnSync001 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSCanvasDrawingRenderParamsTest, OnSync001, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[2]; + std::unique_ptr target = nullptr; + RSCanvasDrawingRenderParams params(id); + params.OnSync(target); + EXPECT_FALSE(params.isNeedProcess_); +} + +/** + * @tc.name: OnSync002 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSCanvasDrawingRenderParamsTest, OnSync002, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[2]; + std::unique_ptr target = std::make_unique(id); + auto targetDrawingRenderParam = static_cast(target.get()); + RSCanvasDrawingRenderParams params(id); + params.isNeedProcess_ = true; + params.OnSync(target); + EXPECT_EQ(params.isNeedProcess_, targetDrawingRenderParam->isNeedProcess_); +} + +} // namespace OHOS::Rosen \ No newline at end of file diff --git a/rosen/test/render_service/render_service_base/unittest/params/rs_display_render_params_test.cpp b/rosen/test/render_service/render_service_base/unittest/params/rs_display_render_params_test.cpp new file mode 100644 index 0000000000..c47c0017c2 --- /dev/null +++ b/rosen/test/render_service/render_service_base/unittest/params/rs_display_render_params_test.cpp @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2023-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 "gtest/gtest.h" +#include "params/rs_display_render_params.h" +#include "limit_number.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS::Rosen { +class RSDisplayRenderParamsTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; + static void DisplayTestInfo(); +}; + +void RSDisplayRenderParamsTest::SetUpTestCase() {} +void RSDisplayRenderParamsTest::TearDownTestCase() {} +void RSDisplayRenderParamsTest::SetUp() {} +void RSDisplayRenderParamsTest::TearDown() {} +void RSDisplayRenderParamsTest::DisplayTestInfo() +{ + return; +} + +/** + * @tc.name: OnSync001 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSDisplayRenderParamsTest, OnSync001, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[2]; + std::unique_ptr target = nullptr; + RSDisplayRenderParams params(id); + params.OnSync(target); + EXPECT_FALSE(params.isMainAndLeashSurfaceDirty_); +} + +/** + * @tc.name: SetMainAndLeashSurfaceDirty001 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSDisplayRenderParamsTest, SetMainAndLeashSurfaceDirty001, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[3]; + RSDisplayRenderParams params(id); + auto res = params.GetMainAndLeashSurfaceDirty(); + params.SetMainAndLeashSurfaceDirty(res); +} + +/** + * @tc.name: SetRotationChanged001 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSDisplayRenderParamsTest, SetRotationChanged001, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[4]; + RSDisplayRenderParams params(id); + auto res = params.IsRotationChanged(); + params.SetRotationChanged(res); +} + +/** + * @tc.name: SetHDRPresent001 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSDisplayRenderParamsTest, SetHDRPresent001, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[5]; + RSDisplayRenderParams params(id); + auto res = params.GetHDRPresent(); + params.SetHDRPresent(res); +} + +/** + * @tc.name: SetNewColorSpace001 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSDisplayRenderParamsTest, SetNewColorSpace001, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[6]; + RSDisplayRenderParams params(id); + GraphicColorGamut newColorSpace = GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB; + params.SetNewColorSpace(newColorSpace); +} + +/** + * @tc.name: SetNewPixelFormat001 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSDisplayRenderParamsTest, SetNewPixelFormat001, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[0]; + RSDisplayRenderParams params(id); + auto res = params.GetNewPixelFormat(); + params.SetNewPixelFormat(res); +} + +/** + * @tc.name: HasSecurityLayer001 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSDisplayRenderParamsTest, HasSecurityLayer001, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[0]; + RSDisplayRenderParams params(id); + auto displayHasSecSurface = params.GetDisplayHasSecSurface(); + EXPECT_FALSE(params.HasSecurityLayer()); +} + +/** + * @tc.name: HasSkipLayer001 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSDisplayRenderParamsTest, HasSkipLayer001, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[0]; + RSDisplayRenderParams params(id); + params.displayHasSkipSurface_[1] = false; + EXPECT_FALSE(params.HasSkipLayer()); +} + +/** + * @tc.name: HasProtectedLayer001 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSDisplayRenderParamsTest, HasProtectedLayer001, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[2]; + RSDisplayRenderParams params(id); + params.displayHasProtectedSurface_[1] = false; + EXPECT_FALSE(params.HasProtectedLayer()); +} + + +/** + * @tc.name: HasCaptureWindow001 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSDisplayRenderParamsTest, HasCaptureWindow001, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[3]; + RSDisplayRenderParams params(id); + params.hasCaptureWindow_[1] = false; + EXPECT_FALSE(params.HasCaptureWindow()); +} + +/** + * @tc.name: HasCaptureWindow001 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSDisplayRenderParamsTest, SetNeedOffscreen001, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[3]; + RSDisplayRenderParams params(id); + auto needOffscreen = params.GetNeedOffscreen(); + params.SetNeedOffscreen(needOffscreen); +} +} // namespace OHOS::Rosen \ No newline at end of file diff --git a/rosen/test/render_service/render_service_base/unittest/params/rs_effect_render_params_test.cpp b/rosen/test/render_service/render_service_base/unittest/params/rs_effect_render_params_test.cpp new file mode 100644 index 0000000000..cc07d26350 --- /dev/null +++ b/rosen/test/render_service/render_service_base/unittest/params/rs_effect_render_params_test.cpp @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2023-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 "gtest/gtest.h" +#include "params/rs_effect_render_params.h" +#include "limit_number.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS::Rosen { +class RSEffectRenderParamsTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; + static void DisplayTestInfo(); +}; + +void RSEffectRenderParamsTest::SetUpTestCase() {} +void RSEffectRenderParamsTest::TearDownTestCase() {} +void RSEffectRenderParamsTest::SetUp() {} +void RSEffectRenderParamsTest::TearDown() {} +void RSEffectRenderParamsTest::DisplayTestInfo() +{ + return; +} + +/** + * @tc.name: OnSync001 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSEffectRenderParamsTest, OnSync001, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[2]; + std::unique_ptr target = nullptr; + RSEffectRenderParams params(id); + params.OnSync(target); + EXPECT_FALSE(params.cacheValid_); + EXPECT_FALSE(params.hasEffectChildren_); +} + +/** + * @tc.name: OnSync002 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSEffectRenderParamsTest, OnSync002, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[2]; + std::unique_ptr target = std::make_unique(id); + auto targetEffectRenderParam = static_cast(target.get()); + RSEffectRenderParams params(id); + params.cacheValid_ = true; + params.hasEffectChildren_ = true; + params.OnSync(target); + EXPECT_EQ(params.cacheValid_, targetEffectRenderParam->cacheValid_); + EXPECT_EQ(params.hasEffectChildren_, targetEffectRenderParam->hasEffectChildren_); +} + +/** + * @tc.name: SetCacheValid001 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSEffectRenderParamsTest, SetCacheValid001, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[3]; + std::unique_ptr target = std::make_unique(id); + RSEffectRenderParams params(id); + params.cacheValid_ = true; + params.SetCacheValid(true); +} + +/** + * @tc.name: SetHasEffectChildren001 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSEffectRenderParamsTest, SetHasEffectChildren001, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[4]; + std::unique_ptr target = std::make_unique(id); + RSEffectRenderParams params(id); + params.hasEffectChildren_ = true; + params.SetHasEffectChildren(true); +} +} // namespace OHOS::Rosen \ No newline at end of file diff --git a/rosen/test/render_service/render_service_base/unittest/params/rs_render_params_test.cpp b/rosen/test/render_service/render_service_base/unittest/params/rs_render_params_test.cpp new file mode 100644 index 0000000000..d79554c3c2 --- /dev/null +++ b/rosen/test/render_service/render_service_base/unittest/params/rs_render_params_test.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2023-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 "gtest/gtest.h" +#include "params/rs_render_params.h" +#include "limit_number.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS::Rosen { +class RSRenderParamsTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; + static void DisplayTestInfo(); +}; + +void RSRenderParamsTest::SetUpTestCase() {} +void RSRenderParamsTest::TearDownTestCase() {} +void RSRenderParamsTest::SetUp() {} +void RSRenderParamsTest::TearDown() {} +void RSRenderParamsTest::DisplayTestInfo() +{ + return; +} + +/** + * @tc.name: OnSync001 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSRenderParamsTest, OnSync001, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[3]; + std::unique_ptr target = std::make_unique(id); + auto renderParams = static_cast(target.get()); + RSRenderParams params(id); + params.childHasVisibleEffect_ = true; + params.OnSync(target); + EXPECT_EQ(params.childHasVisibleEffect_, renderParams->childHasVisibleEffect_); +} + +/** + * @tc.name: SetAlpha001 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSRenderParamsTest, SetAlpha001, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[4]; + std::unique_ptr target = std::make_unique(id); + RSRenderParams params(id); + auto renderParams = static_cast(target.get()); + renderParams->alpha_ = 1.0; + float alpha = 1.0; + params.SetAlpha(alpha); +} + +/** + * @tc.name: SetAlphaOffScreen001 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSRenderParamsTest, SetAlphaOffScreen001, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[0]; + RSRenderParams params(id); + bool alphaOffScreen = false; + params.SetAlphaOffScreen(alphaOffScreen); +} + +/** + * @tc.name: ApplyAlphaAndMatrixToCanvas001 + * @tc.desc: + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RSRenderParamsTest, ApplyAlphaAndMatrixToCanvas001, TestSize.Level1) +{ + constexpr NodeId id = TestSrc::limitNumber::Uint64[0]; + RSRenderParams params(id); + Drawing::Canvas canvas; + RSPaintFilterCanvas paintFilterCanvas(&canvas); + params.ApplyAlphaAndMatrixToCanvas(paintFilterCanvas, true); +} +} // namespace OHOS::Rosen \ No newline at end of file From 2c344e3015a7e38ac05a5420ce4a442fcfc86fde Mon Sep 17 00:00:00 2001 From: lmy Date: Thu, 27 Jun 2024 09:48:51 +0000 Subject: [PATCH 070/247] update rosen/test/render_service/render_service_base/unittest/render/rs_border_test.cpp. Signed-off-by: lmy --- .../render_service_base/unittest/render/rs_border_test.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/rosen/test/render_service/render_service_base/unittest/render/rs_border_test.cpp b/rosen/test/render_service/render_service_base/unittest/render/rs_border_test.cpp index 9535f559fa..0ff2449948 100644 --- a/rosen/test/render_service/render_service_base/unittest/render/rs_border_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/render/rs_border_test.cpp @@ -512,7 +512,6 @@ HWTEST_F(RSBorderTest, ApplySimpleBorderTest, TestSize.Level1) EXPECT_FALSE(border->ApplySimpleBorder(rect)); border->styles_.push_back(BorderStyle::SOLID); EXPECT_TRUE(border->ApplySimpleBorder(rect)); - } { From 409f527994656baa7fea9db0ab86b830dea7f006 Mon Sep 17 00:00:00 2001 From: maokelong95 Date: Thu, 27 Jun 2024 18:06:31 +0800 Subject: [PATCH 071/247] =?UTF-8?q?=E6=92=A4=E9=94=80Texture=20pre-allocat?= =?UTF-8?q?ion=20optimization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: maokelong95 --- .../core/pipeline/rs_draw_frame.cpp | 1 - .../core/pipeline/rs_uni_render_thread.cpp | 22 ------------------- .../core/pipeline/rs_uni_render_thread.h | 3 --- .../platform/common/rs_system_properties.h | 1 - .../platform/ohos/rs_system_properties.cpp | 8 ------- 5 files changed, 35 deletions(-) diff --git a/rosen/modules/render_service/core/pipeline/rs_draw_frame.cpp b/rosen/modules/render_service/core/pipeline/rs_draw_frame.cpp index 941110389d..371b6438af 100644 --- a/rosen/modules/render_service/core/pipeline/rs_draw_frame.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_draw_frame.cpp @@ -73,7 +73,6 @@ void RSDrawFrame::RenderFrame() if (RSSystemProperties::GetPurgeBetweenFramesEnabled()) { unirenderInstance_.PurgeCacheBetweenFrames(); } - unirenderInstance_.MemoryManagementBetweenFrames(); } void RSDrawFrame::NotifyClearGpuCache() diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_thread.cpp b/rosen/modules/render_service/core/pipeline/rs_uni_render_thread.cpp index 8a63494719..45fb27d2bc 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_thread.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_thread.cpp @@ -41,7 +41,6 @@ #ifdef RES_SCHED_ENABLE #include "system_ability_definition.h" #include "if_system_ability_manager.h" -#include "include/gpu/GrDirectContext.h" #include #endif #include "pipeline/parallel_render/rs_sub_thread_manager.h" @@ -54,7 +53,6 @@ namespace { constexpr const char* CLEAR_GPU_CACHE = "ClearGpuCache"; constexpr const char* DEFAULT_CLEAR_GPU_CACHE = "DefaultClearGpuCache"; constexpr const char* PURGE_CACHE_BETWEEN_FRAMES = "PurgeCacheBetweenFrames"; -constexpr const char* PRE_ALLOCATE_TEXTURE_BETWEEN_FRAMES = "PreAllocateTextureBetweenFrames"; constexpr uint32_t TIME_OF_EIGHT_FRAMES = 8000; constexpr uint32_t TIME_OF_THE_FRAMES = 1000; constexpr uint32_t TIME_OF_DEFAULT_CLEAR_GPU_CACHE = 5000; @@ -622,26 +620,6 @@ void RSUniRenderThread::PurgeCacheBetweenFrames() PURGE_CACHE_BETWEEN_FRAMES, 0, AppExecFwk::EventQueue::Priority::LOW); } -void RSUniRenderThread::PreAllocateTextureBetweenFrames() -{ - PostTask( - [this]() { - RS_TRACE_NAME_FMT("PreAllocateTextureBetweenFrames"); - GrDirectContext::preAllocateTextureBetweenFrames(); - RemoveTask(PRE_ALLOCATE_TEXTURE_BETWEEN_FRAMES); - }, - PRE_ALLOCATE_TEXTURE_BETWEEN_FRAMES, - 0, - AppExecFwk::EventQueue::Priority::LOW); -} - -void RSUniRenderThread::MemoryManagementBetweenFrames() -{ - if (!RSSystemProperties::GetPreAllocateTextureBetweenFramesEnabled()) { - PreAllocateTextureBetweenFrames(); - } -} - void RSUniRenderThread::RenderServiceTreeDump(std::string& dumpString) const { if (!rootNodeDrawable_) { diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_thread.h b/rosen/modules/render_service/core/pipeline/rs_uni_render_thread.h index 0ceef503b8..e997619e7f 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_thread.h +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_thread.h @@ -70,9 +70,6 @@ public: void ClearMemoryCache(ClearMemoryMoment moment, bool deeply, pid_t pid = -1); void DefaultClearMemoryCache(); void PostClearMemoryTask(ClearMemoryMoment moment, bool deeply, bool isDefaultClean); - void MemoryManagementBetweenFrames(); - void PreAllocateTextureBetweenFrames(); - void ResetClearMemoryTask(); bool GetClearMemoryFinished() const; bool GetClearMemDeeply() const; void SetClearMoment(ClearMemoryMoment moment); diff --git a/rosen/modules/render_service_base/include/platform/common/rs_system_properties.h b/rosen/modules/render_service_base/include/platform/common/rs_system_properties.h index 61c5ab324e..60ec7be566 100644 --- a/rosen/modules/render_service_base/include/platform/common/rs_system_properties.h +++ b/rosen/modules/render_service_base/include/platform/common/rs_system_properties.h @@ -196,7 +196,6 @@ public: static bool GetDrawFilterWithoutSnapshotEnabled(); static bool GetBlurExtraFilterEnabled(); static bool GetPurgeBetweenFramesEnabled(); - static bool GetPreAllocateTextureBetweenFramesEnabled(); static bool GetAnimationCacheEnabled(); diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_system_properties.cpp b/rosen/modules/render_service_base/src/platform/ohos/rs_system_properties.cpp index 5dba41b0f3..b3f9338c73 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_system_properties.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_system_properties.cpp @@ -866,14 +866,6 @@ bool RSSystemProperties::GetPurgeBetweenFramesEnabled() return purgeResourcesEveryEnabled; } -bool RSSystemProperties::GetPreAllocateTextureBetweenFramesEnabled() -{ - static bool PreAllocateTextureBetweenFramesEnabled = - (std::atoi(system::GetParameter("persist.sys.graphic.mem.pre_allocate_texture_between_frames_enabled", "1") - .c_str()) != 0); - return PreAllocateTextureBetweenFramesEnabled; -} - const DdgrOpincType RSSystemProperties::ddgrOpincType_ = static_cast(std::atoi((system::GetParameter("persist.ddgr.opinctype", "2")).c_str())); const DdgrOpincDfxType RSSystemProperties::ddgrOpincDfxType_ = From 967459c6182de0a20cc68deb96fda15c37449bc5 Mon Sep 17 00:00:00 2001 From: huangjunlin Date: Thu, 27 Jun 2024 10:46:57 +0000 Subject: [PATCH 072/247] update interfaces/kits/napi/graphic/text/BUILD.gn. Signed-off-by: huangjunlin --- interfaces/kits/napi/graphic/text/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/napi/graphic/text/BUILD.gn b/interfaces/kits/napi/graphic/text/BUILD.gn index 374e110224..cf162cd6b8 100755 --- a/interfaces/kits/napi/graphic/text/BUILD.gn +++ b/interfaces/kits/napi/graphic/text/BUILD.gn @@ -117,4 +117,4 @@ ohos_shared_library("text_napi_impl") { innerapi_tags = [ "platformsdk" ] part_name = "graphic_2d" subsystem_name = "graphic" -} \ No newline at end of file +} From cb967b18a8838dae88848de9984948db41693a0b Mon Sep 17 00:00:00 2001 From: maokelong95 Date: Thu, 27 Jun 2024 19:39:55 +0800 Subject: [PATCH 073/247] =?UTF-8?q?=E6=92=A4=E9=94=80Texture=20pre-allocat?= =?UTF-8?q?ion=20optimization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: maokelong95 --- .../modules/render_service/core/pipeline/rs_uni_render_thread.h | 1 + 1 file changed, 1 insertion(+) diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_thread.h b/rosen/modules/render_service/core/pipeline/rs_uni_render_thread.h index e997619e7f..422cc38a15 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_thread.h +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_thread.h @@ -70,6 +70,7 @@ public: void ClearMemoryCache(ClearMemoryMoment moment, bool deeply, pid_t pid = -1); void DefaultClearMemoryCache(); void PostClearMemoryTask(ClearMemoryMoment moment, bool deeply, bool isDefaultClean); + void ResetClearMemoryTask(); bool GetClearMemoryFinished() const; bool GetClearMemDeeply() const; void SetClearMoment(ClearMemoryMoment moment); From 5cdc8427c76a93c140c012c4a34a753ea8b9e62b Mon Sep 17 00:00:00 2001 From: lvmengyu Date: Thu, 27 Jun 2024 19:49:47 +0800 Subject: [PATCH 074/247] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dpc=E9=95=BF=E6=8C=89c?= =?UTF-8?q?anvas=E7=BB=84=E4=BB=B6=E5=8F=98=E9=BB=91=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lvmengyu Change-Id: If10bff17daba69a1890aa955de44a2cdfbab0c0b --- .../core/drawable/rs_canvas_drawing_render_node_drawable.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rosen/modules/render_service/core/drawable/rs_canvas_drawing_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_canvas_drawing_render_node_drawable.cpp index edcea28f14..0fb04a443d 100644 --- a/rosen/modules/render_service/core/drawable/rs_canvas_drawing_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_canvas_drawing_render_node_drawable.cpp @@ -455,6 +455,11 @@ void RSCanvasDrawingRenderNodeDrawable::DrawCaptureImage(RSPaintFilterCanvas& ca canvas.DrawImage(*image_, 0, 0, Drawing::SamplingOptions()); return; } + + if (RSSystemProperties::GetGpuApiType() == GpuApiType::OPENGL) { + return; + } + if (!backendTexture_.IsValid()) { return; } From 7f10ed907aec2766311b11b898e056bc3f7d91c2 Mon Sep 17 00:00:00 2001 From: ZhongJinghua Date: Thu, 27 Jun 2024 19:32:37 +0800 Subject: [PATCH 075/247] HDR: Fix offscreenCanvas Change-Id: I1063373420e5d1a6aa289ee47dae851b774422ad Signed-off-by: ZhongJinghua --- .../drawable/rs_display_render_node_drawable.cpp | 3 +++ .../drawable/rs_surface_render_node_drawable.cpp | 3 +++ .../include/pipeline/rs_paint_filter_canvas.h | 1 + .../src/pipeline/rs_paint_filter_canvas.cpp | 12 ++++++++---- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp index 01f5a79a7c..2b77c3c2a3 100644 --- a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp @@ -1448,6 +1448,8 @@ void RSDisplayRenderNodeDrawable::PrepareOffscreenRender(const RSRenderNode& nod } auto offscreenCanvas = std::make_shared(offscreenSurface_.get()); + // copy HDR properties into offscreen canvas + offscreenCanvas->CopyHDRConfiguration(*curCanvas_); // copy current canvas properties into offscreen canvas offscreenCanvas->CopyConfiguration(*curCanvas_); @@ -1464,6 +1466,7 @@ void RSDisplayRenderNodeDrawable::FinishOffscreenRender(const Drawing::SamplingO // draw offscreen surface to current canvas Drawing::Brush paint; paint.SetAntiAlias(true); + paint.SetForceBrightnessDisable(true); canvasBackup_->AttachBrush(paint); canvasBackup_->DrawImage(*offscreenSurface_->GetImageSnapshot().get(), 0, 0, sampling); canvasBackup_->DetachBrush(); diff --git a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp index 36467f9f59..0e70a1bec8 100644 --- a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp @@ -177,6 +177,8 @@ bool RSSurfaceRenderNodeDrawable::PrepareOffscreenRender() offscreenCanvas_ = std::make_shared(offscreenSurface_.get()); + // copy HDR properties into offscreen canvas + offscreenCanvas_->CopyHDRConfiguration(*curCanvas_); // copy current canvas properties into offscreen canvas offscreenCanvas_->CopyConfiguration(*curCanvas_); @@ -197,6 +199,7 @@ void RSSurfaceRenderNodeDrawable::FinishOffscreenRender(const Drawing::SamplingO // draw offscreen surface to current canvas Drawing::Brush paint; paint.SetAntiAlias(true); + paint.SetForceBrightnessDisable(true); canvasBackup_->AttachBrush(paint); auto image = offscreenSurface_->GetImageSnapshot(); canvasBackup_->DrawImage(*image, 0, 0, sampling); diff --git a/rosen/modules/render_service_base/include/pipeline/rs_paint_filter_canvas.h b/rosen/modules/render_service_base/include/pipeline/rs_paint_filter_canvas.h index aa2e9469ec..02c592e21a 100644 --- a/rosen/modules/render_service_base/include/pipeline/rs_paint_filter_canvas.h +++ b/rosen/modules/render_service_base/include/pipeline/rs_paint_filter_canvas.h @@ -293,6 +293,7 @@ public: void SetBrightnessRatio(float brightnessRatio); template void PaintFilter(T& paint); + void CopyHDRConfiguration(const RSPaintFilterCanvas& other); protected: using Env = struct { diff --git a/rosen/modules/render_service_base/src/pipeline/rs_paint_filter_canvas.cpp b/rosen/modules/render_service_base/src/pipeline/rs_paint_filter_canvas.cpp index c7bc47a8c9..d4dbb2352b 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_paint_filter_canvas.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_paint_filter_canvas.cpp @@ -1271,6 +1271,14 @@ bool RSPaintFilterCanvas::IsDirtyRegionStackEmpty() return dirtyRegionStack_.empty(); } +void RSPaintFilterCanvas::CopyHDRConfiguration(const RSPaintFilterCanvas& other) +{ + hasHdrPresent_ = other.hasHdrPresent_; + brightnessRatio_ = other.brightnessRatio_; + screenId_ = other.screenId_; + targetColorGamut_ = other.targetColorGamut_; +} + void RSPaintFilterCanvas::CopyConfiguration(const RSPaintFilterCanvas& other) { // Note: @@ -1290,10 +1298,6 @@ void RSPaintFilterCanvas::CopyConfiguration(const RSPaintFilterCanvas& other) isParallelCanvas_ = other.isParallelCanvas_; disableFilterCache_ = other.disableFilterCache_; threadIndex_ = other.threadIndex_; - hasHdrPresent_ = other.hasHdrPresent_; - brightnessRatio_ = other.brightnessRatio_; - screenId_ = other.screenId_; - targetColorGamut_ = other.targetColorGamut_; } void RSPaintFilterCanvas::SetHighContrast(bool enabled) From d74a8d5974d26ced97415f96d88015299f3980f0 Mon Sep 17 00:00:00 2001 From: sunqizhen Date: Thu, 27 Jun 2024 19:23:34 +0800 Subject: [PATCH 076/247] fix watermark drawing with off screen render Signed-off-by: sunqizhen --- .../rs_display_render_node_drawable.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp index cc7db3dd74..db4a1ab91f 100644 --- a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp @@ -617,10 +617,7 @@ void RSDisplayRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) SetHighContrastIfEnabled(*curCanvas_); RSRenderNodeDrawable::OnDraw(*curCanvas_); - DrawWatermarkIfNeed(*params, *curCanvas_); DrawCurtainScreen(); - // switch color filtering - SwitchColorFilter(*curCanvas_); if (needOffscreen) { if (canvasBackup_ != nullptr) { Drawing::AutoCanvasRestore acr(*canvasBackup_, true); @@ -632,6 +629,9 @@ void RSDisplayRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) RS_LOGE("RSDisplayRenderNodeDrawable::OnDraw canvasBackup_ is nullptr"); } } + // watermark and color filter should be applied after offscreen render. + DrawWatermarkIfNeed(*params, *curCanvas_); + SwitchColorFilter(*curCanvas_); } rsDirtyRectsDfx.OnDraw(curCanvas_); if (RSSystemProperties::IsFoldScreenFlag() && !params->IsRotationChanged()) { @@ -1401,13 +1401,10 @@ void RSDisplayRenderNodeDrawable::DrawWatermarkIfNeed(RSDisplayRenderParams& par auto mainWidth = static_cast(screenInfo.width); auto mainHeight = static_cast(screenInfo.height); - // in certain cases (such as fold screen), the width and height must be swapped to fix the screen correction. - auto screenCorrection = screenManager->GetScreenCorrection(params.GetScreenId()); - if (screenCorrection == ScreenRotation::ROTATION_90 || screenCorrection == ScreenRotation::ROTATION_270) { - auto screenRotation = params.GetScreenRotation(); - if (screenRotation == ScreenRotation::ROTATION_0 || screenRotation == ScreenRotation::ROTATION_180) { - std::swap(mainWidth, mainHeight); - } + // in certain cases (such as fold screen), the width and height must be swapped to fix the screen rotation. + int angle = RSUniRenderUtil::GetRotationFromMatrix(canvas.GetTotalMatrix()); + if (angle == RS_ROTATION_90 || angle == RS_ROTATION_270) { + std::swap(mainWidth, mainHeight); } auto srcRect = Drawing::Rect(0, 0, image->GetWidth(), image->GetHeight()); auto dstRect = Drawing::Rect(0, 0, mainWidth, mainHeight); From a9045a094294b0cba59938e50ce84ce9c7517e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E5=B8=B8=E5=BE=B7?= Date: Thu, 27 Jun 2024 11:46:21 +0800 Subject: [PATCH 077/247] Fixed the issue of multi-threaded access MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 钱常德 Change-Id: Ie7084a2a9c2e3c6ac113769763874b00053ce18a --- .../core/drawable/rs_display_render_node_drawable.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp index ebe5ec8722..4605a823e2 100644 --- a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp @@ -480,8 +480,9 @@ void RSDisplayRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) RS_LOGE("RSDisplayRenderNodeDrawable::OnDraw RenderEngine is null!"); return; } + bool isRenderThread = true; if (!processor->Init(*displayNodeSp, params->GetDisplayOffsetX(), params->GetDisplayOffsetY(), - mirroredNode ? mirroredNode->GetScreenId() : INVALID_SCREEN_ID, renderEngine)) { + mirroredNode ? mirroredNode->GetScreenId() : INVALID_SCREEN_ID, renderEngine, isRenderThread)) { RS_LOGE("RSDisplayRenderNodeDrawable::OnDraw processor init failed!"); return; } From 57e001e53db3952d99971e96f2d0337533f5c0d2 Mon Sep 17 00:00:00 2001 From: zhangbirong Date: Thu, 27 Jun 2024 21:42:10 +0800 Subject: [PATCH 078/247] add tdd Signed-off-by: zhangbirong --- .../unittest/render_context/BUILD.gn | 1 + .../render_context/momory_handler_test.cpp | 72 +++++++++++++++++++ .../unittest/rs_frame_report_test.cpp | 14 ++++ 3 files changed, 87 insertions(+) create mode 100644 rosen/test/2d_graphics/unittest/render_context/momory_handler_test.cpp diff --git a/rosen/test/2d_graphics/unittest/render_context/BUILD.gn b/rosen/test/2d_graphics/unittest/render_context/BUILD.gn index 5ac051d620..48509dfe4a 100644 --- a/rosen/test/2d_graphics/unittest/render_context/BUILD.gn +++ b/rosen/test/2d_graphics/unittest/render_context/BUILD.gn @@ -80,6 +80,7 @@ ohos_unittest("2d_graphics_shader_cache_test") { sources = [ "cache_data_test.cpp", + "momory_handler_test.cpp", "shader_cache_test.cpp", ] diff --git a/rosen/test/2d_graphics/unittest/render_context/momory_handler_test.cpp b/rosen/test/2d_graphics/unittest/render_context/momory_handler_test.cpp new file mode 100644 index 0000000000..6b5741bfdf --- /dev/null +++ b/rosen/test/2d_graphics/unittest/render_context/momory_handler_test.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2022 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 +#include "memory_handler.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Rosen { +class MemoryHandlerTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void MemoryHandlerTest::SetUpTestCase() {} +void MemoryHandlerTest::TearDownTestCase() {} +void MemoryHandlerTest::SetUp() {} +void MemoryHandlerTest::TearDown() {} + +/** + * @tc.name: ClearRedundantResourcesTest001 + * @tc.desc: Verify the ClearRedundantResourcesTest001 of MemoryHandlerTest + * @tc.type: FUNC + */ +HWTEST_F(MemoryHandlerTest, ClearRedundantResourcesTest001, TestSize.Level1) +{ + MemoryHandler::ClearRedundantResources(nullptr); + auto gpuContext = new Drawing::GPUContext(); + MemoryHandler::ClearRedundantResources(gpuContext); + delete gpuContext; + gpuContext = nullptr; +} + +/** + * @tc.name: QuerryShaderTest001 + * @tc.desc: Verify the QuerryShaderTest001 of MemoryHandlerTest + * @tc.type: FUNC + */ +HWTEST_F(MemoryHandlerTest, QuerryShaderTest001, TestSize.Level1) +{ + MemoryHandler::QuerryShader(); +} + +/** + * @tc.name: QuerryShaderTest002 + * @tc.desc: Verify the QuerryShaderTest002 of MemoryHandlerTest + * @tc.type: FUNC + */ +HWTEST_F(MemoryHandlerTest, QuerryShaderTest002, TestSize.Level1) +{ + ShaderCache::Instance().InitShaderCache(); + MemoryHandler::QuerryShader(); +} +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/rosen/test/frame_report/unittest/rs_frame_report_test.cpp b/rosen/test/frame_report/unittest/rs_frame_report_test.cpp index 12d9eade12..e5034744db 100644 --- a/rosen/test/frame_report/unittest/rs_frame_report_test.cpp +++ b/rosen/test/frame_report/unittest/rs_frame_report_test.cpp @@ -138,5 +138,19 @@ HWTEST_F(RsFrameReportTest, SetFrameParam001, TestSize.Level1) { RsFrameReport::GetInstance().SetFrameParam(0, 0, 0, 0); } + +/** + * @tc.name: LoadLibrary001 + * @tc.desc: test + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RsFrameReportTest, LoadLibrary001, TestSize.Level1) +{ + RsFrameReport& fr = RsFrameReport::GetInstance(); + fr.CloseLibrary(); + fr.LoadLibrary(); + fr.CloseLibrary(); +} } // namespace Rosen } // namespace OHOS From 1990e29d56984edd32b25065b087b646aa162d27 Mon Sep 17 00:00:00 2001 From: luhan Date: Thu, 27 Jun 2024 12:35:44 +0800 Subject: [PATCH 079/247] add font variation Change-Id: I176da27cfe4d30c56ca84d1707804741a836c42b Signed-off-by: luhan --- .../kits/napi/graphic/text/js_text_utils.cpp | 37 +++++++++++++++++++ .../kits/napi/graphic/text/js_text_utils.h | 2 + .../include/drawing_text_typography.h | 12 ++++++ .../src/drawing_text_typography.cpp | 11 ++++++ 4 files changed, 62 insertions(+) diff --git a/interfaces/kits/napi/graphic/text/js_text_utils.cpp b/interfaces/kits/napi/graphic/text/js_text_utils.cpp index 73225ee4a5..ad370808f5 100755 --- a/interfaces/kits/napi/graphic/text/js_text_utils.cpp +++ b/interfaces/kits/napi/graphic/text/js_text_utils.cpp @@ -148,6 +148,7 @@ void ParsePartTextStyle(napi_env env, napi_value argValue, TextStyle& textStyle) GetDecorationFromJS(env, argValue, "decoration", textStyle); SetTextStyleBaseType(env, argValue, textStyle); ReceiveFontFeature(env, argValue, textStyle); + ReceiveFontVariation(env, argValue, textStyle); napi_get_named_property(env, argValue, "ellipsis", &tempValue); std::string text = ""; if (tempValue != nullptr && ConvertFromJsValue(env, tempValue, text)) { @@ -215,6 +216,42 @@ void ReceiveFontFeature(napi_env env, napi_value argValue, TextStyle& textStyle) return; } +void ReceiveFontVariation(napi_env env, napi_value argValue, TextStyle& textStyle) +{ + napi_value allVariationValue = nullptr; + napi_get_named_property(env, argValue, "fontVariations", &allVariationValue); + uint32_t arrayLength = 0; + if (napi_get_array_length(env, allVariationValue, &arrayLength) != napi_ok || + !arrayLength) { + ROSEN_LOGE("The parameter of font variations is unvaild"); + return; + } + + for (uint32_t further = 0; further < arrayLength; further++) { + napi_value singleElementValue; + if (napi_get_element(env, allVariationValue, further, &singleElementValue) != napi_ok) { + ROSEN_LOGE("This parameter of the font variations is unvaild"); + break; + } + napi_value variationElement; + std::string axis; + if (napi_get_named_property(env, singleElementValue, "axis", &variationElement) != napi_ok || + !ConvertFromJsValue(env, variationElement, axis)) { + ROSEN_LOGE("This time that the axis of parameter in font variations is unvaild"); + break; + } + + int value = 0; + if (napi_get_named_property(env, singleElementValue, "value", &variationElement) != napi_ok || + !ConvertFromJsValue(env, variationElement, value)) { + ROSEN_LOGE("This time that the value of parameter in font variations is unvaild"); + break; + } + textStyle.fontVariations.SetAxisValue(axis, value); + } + return; +} + void SetTextStyleBaseType(napi_env env, napi_value argValue, TextStyle& textStyle) { SetDoubleValueFromJS(env, argValue, "letterSpacing", textStyle.letterSpacing); diff --git a/interfaces/kits/napi/graphic/text/js_text_utils.h b/interfaces/kits/napi/graphic/text/js_text_utils.h index 3fcbbde11d..a521f44251 100755 --- a/interfaces/kits/napi/graphic/text/js_text_utils.h +++ b/interfaces/kits/napi/graphic/text/js_text_utils.h @@ -481,6 +481,8 @@ void SetTextStyleBaseType(napi_env env, napi_value argValue, TextStyle& textStyl void ReceiveFontFeature(napi_env env, napi_value argValue, TextStyle& textStyle); +void ReceiveFontVariation(napi_env env, napi_value argValue, TextStyle& textStyle); + size_t GetParamLen(napi_env env, napi_value param); bool GetFontMetricsFromJS(napi_env env, napi_value argValue, Drawing::FontMetrics& fontMetrics); diff --git a/rosen/modules/2d_graphics/drawing_ndk/include/drawing_text_typography.h b/rosen/modules/2d_graphics/drawing_ndk/include/drawing_text_typography.h index e14ad1b0cc..a4fd73e6c9 100644 --- a/rosen/modules/2d_graphics/drawing_ndk/include/drawing_text_typography.h +++ b/rosen/modules/2d_graphics/drawing_ndk/include/drawing_text_typography.h @@ -1980,6 +1980,18 @@ void OH_Drawing_TypographyHandlerAddSymbol(OH_Drawing_TypographyCreate*, uint32_ */ void OH_Drawing_TextStyleAddFontFeature(OH_Drawing_TextStyle*, const char* tag, int value); +/** + * @brief Add font variation. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextStyle Indicates the pointer to an OH_Drawing_TextStyle object. + * @param char* Indicates the pointer to font variation axis. + * @param float Indicates the font variation value to set. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_TextStyleAddFontVariation(OH_Drawing_TextStyle*, const char* /* axis */, const float /* value */); + /** * @brief Get all font features. * diff --git a/rosen/modules/2d_graphics/drawing_ndk/src/drawing_text_typography.cpp b/rosen/modules/2d_graphics/drawing_ndk/src/drawing_text_typography.cpp index 02f4573afb..a25f0617c8 100644 --- a/rosen/modules/2d_graphics/drawing_ndk/src/drawing_text_typography.cpp +++ b/rosen/modules/2d_graphics/drawing_ndk/src/drawing_text_typography.cpp @@ -3474,4 +3474,15 @@ void OH_Drawing_TypographyDestroyTextBox(OH_Drawing_TextBox* textBox) } delete textRectArr; textRectArr = nullptr; +} + +void OH_Drawing_TextStyleAddFontVariation(OH_Drawing_TextStyle* style, const char* axis, const float value) +{ + if (style == nullptr || axis == nullptr) { + return; + } + TextStyle* convertStyle = ConvertToOriginalText(style); + if (convertStyle) { + convertStyle->fontVariations.SetAxisValue(axis, value); + } } \ No newline at end of file From 683164a547e335cfbe4709446602efb6ae02cd8c Mon Sep 17 00:00:00 2001 From: qizeyu Date: Fri, 28 Jun 2024 09:43:53 +0800 Subject: [PATCH 080/247] =?UTF-8?q?SA=20=E4=B8=AD=E6=8F=8F=E8=BF=B0?= =?UTF-8?q?=E7=AC=A6=E6=A0=A1=E9=AA=8CSet=E5=BA=94=E4=BD=BF=E7=94=A8static?= =?UTF-8?q?=E4=BF=AE=E9=A5=B0=E4=BB=A5=E9=81=BF=E5=85=8D=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qizeyu --- .../core/transaction/rs_render_service_connection_stub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp b/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp index 6123f28c77..6767004c67 100644 --- a/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp +++ b/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp @@ -124,7 +124,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( return ERR_INVALID_STATE; } #endif - const std::set descriptorCheckList = { + static const std::set descriptorCheckList = { static_cast(RSIRenderServiceConnectionInterfaceCode::SET_FOCUS_APP_INFO), static_cast(RSIRenderServiceConnectionInterfaceCode::GET_DEFAULT_SCREEN_ID), static_cast(RSIRenderServiceConnectionInterfaceCode::GET_ACTIVE_SCREEN_ID), From 688b4ac233b900b81c5943bd57a5489248760f4c Mon Sep 17 00:00:00 2001 From: lw19901203 Date: Thu, 27 Jun 2024 18:05:00 +0800 Subject: [PATCH 081/247] add residue ndk fuzz test lw Signed-off-by: lw19901203 --- .../ndk/ndkfilter_fuzzer/filter_fuzzer.cpp | 7 +++-- .../ndk/ndkmatrix_fuzzer/matrix_fuzzer.cpp | 30 +++++++++++++++++++ .../ndk/ndkpoint_fuzzer/point_fuzzer.cpp | 10 +++++++ .../ndkroundrect_fuzzer/roundrect_fuzzer.cpp | 7 +++++ .../shadereffect_fuzzer.cpp | 24 +++++++++++++++ .../ndktextblob_fuzzer/ndktextblob_fuzzer.cpp | 3 ++ .../ndktypeface_fuzzer/ndktypeface_fuzzer.cpp | 5 ++++ 7 files changed, 83 insertions(+), 3 deletions(-) diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndkfilter_fuzzer/filter_fuzzer.cpp b/rosen/test/2d_graphics/fuzztest/ndk/ndkfilter_fuzzer/filter_fuzzer.cpp index c7e21d9b39..159431507e 100755 --- a/rosen/test/2d_graphics/fuzztest/ndk/ndkfilter_fuzzer/filter_fuzzer.cpp +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndkfilter_fuzzer/filter_fuzzer.cpp @@ -62,11 +62,12 @@ void FilterTest(const uint8_t* data, size_t size) OH_Drawing_FilterSetMaskFilter(nullptr, maskFilter); OH_Drawing_FilterSetMaskFilter(filter, nullptr); OH_Drawing_ColorFilter* colorFilter = OH_Drawing_ColorFilterCreateLinearToSrgbGamma(); + OH_Drawing_FilterSetColorFilter(filter, nullptr); OH_Drawing_FilterSetColorFilter(filter, colorFilter); OH_Drawing_FilterSetColorFilter(nullptr, colorFilter); - OH_Drawing_FilterSetColorFilter(filter, nullptr); - OH_Drawing_FilterGetColorFilter(filter, colorFilter); - OH_Drawing_FilterGetColorFilter(nullptr, colorFilter); + OH_Drawing_ColorFilter* colorFilterTwo = nullptr; + OH_Drawing_FilterGetColorFilter(filter, colorFilterTwo); + OH_Drawing_FilterGetColorFilter(nullptr, colorFilterTwo); OH_Drawing_FilterGetColorFilter(filter, nullptr); OH_Drawing_FilterDestroy(filter); diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndkmatrix_fuzzer/matrix_fuzzer.cpp b/rosen/test/2d_graphics/fuzztest/ndk/ndkmatrix_fuzzer/matrix_fuzzer.cpp index 92b0d63ee4..aea8f576de 100755 --- a/rosen/test/2d_graphics/fuzztest/ndk/ndkmatrix_fuzzer/matrix_fuzzer.cpp +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndkmatrix_fuzzer/matrix_fuzzer.cpp @@ -29,6 +29,7 @@ namespace Rosen { namespace { constexpr size_t DATA_MIN_SIZE = 2; constexpr size_t FIT_MODE_ENUM_SIZE = 4; +constexpr size_t SIZE_OF_BUFFER = 9; constexpr uint32_t MAX_ARRAY_SIZE = 5000; } // namespace @@ -216,6 +217,34 @@ void NativeMatrixTest004(const uint8_t* data, size_t size) OH_Drawing_MatrixDestroy(matrix); } +void NativeMatrixTest005(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < DATA_MIN_SIZE) { + return; + } + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + float scaleX = GetObject(); + float skewX = GetObject(); + float transX = GetObject(); + float skewY = GetObject(); + float scaleY = GetObject(); + float transY = GetObject(); + float persp0 = GetObject(); + float persp1 = GetObject(); + float persp2 = GetObject(); + float value[SIZE_OF_BUFFER]; + OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); + OH_Drawing_MatrixSetMatrix(matrix, scaleX, skewX, transX, skewY, scaleY, transY, persp0, persp1, persp2); + OH_Drawing_MatrixGetAll(matrix, value); + OH_Drawing_MatrixGetAll(nullptr, value); + + OH_Drawing_MatrixDestroy(matrix); +} + } // namespace Drawing } // namespace Rosen } // namespace OHOS @@ -228,5 +257,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) OHOS::Rosen::Drawing::NativeMatrixTest002(data, size); OHOS::Rosen::Drawing::NativeMatrixTest003(data, size); OHOS::Rosen::Drawing::NativeMatrixTest004(data, size); + OHOS::Rosen::Drawing::NativeMatrixTest005(data, size); return 0; } diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndkpoint_fuzzer/point_fuzzer.cpp b/rosen/test/2d_graphics/fuzztest/ndk/ndkpoint_fuzzer/point_fuzzer.cpp index 295ce5c1bf..5d4bce07bc 100755 --- a/rosen/test/2d_graphics/fuzztest/ndk/ndkpoint_fuzzer/point_fuzzer.cpp +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndkpoint_fuzzer/point_fuzzer.cpp @@ -42,6 +42,16 @@ void NativeDrawingPointTest001(const uint8_t* data, size_t size) float y = GetObject(); OH_Drawing_Point* point = OH_Drawing_PointCreate(x, y); + + OH_Drawing_PointGetX(point, &x); + OH_Drawing_PointGetX(nullptr, &x); + + OH_Drawing_PointGetY(point, &y); + OH_Drawing_PointGetY(nullptr, &y); + + OH_Drawing_PointSet(point, x, y); + OH_Drawing_PointSet(nullptr, x, y); + OH_Drawing_PointDestroy(point); } } // namespace Drawing diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndkroundrect_fuzzer/roundrect_fuzzer.cpp b/rosen/test/2d_graphics/fuzztest/ndk/ndkroundrect_fuzzer/roundrect_fuzzer.cpp index ac77bfb30c..e51e2abdb4 100755 --- a/rosen/test/2d_graphics/fuzztest/ndk/ndkroundrect_fuzzer/roundrect_fuzzer.cpp +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndkroundrect_fuzzer/roundrect_fuzzer.cpp @@ -46,6 +46,8 @@ void NativeDrawingRoundRectTest001(const uint8_t* data, size_t size) float bottom = GetObject(); float xRad = GetObject(); float yRad = GetObject(); + float dx = GetObject(); + float dy = GetObject(); uint32_t cornerPos = GetObject(); OH_Drawing_Rect* rect = OH_Drawing_RectCreate(left, top, right, bottom); @@ -57,11 +59,16 @@ void NativeDrawingRoundRectTest001(const uint8_t* data, size_t size) static_cast(cornerPos % ROUND_RECT_CORNER_POS_ENUM_SIZE), radiusXY); OH_Drawing_RoundRectSetCorner(roundRect, static_cast(cornerPos % ROUND_RECT_CORNER_POS_ENUM_SIZE), radiusXY); + OH_Drawing_RoundRectSetCorner(roundRect, static_cast(cornerPos), radiusXY); OH_Drawing_RoundRectGetCorner(nullptr, static_cast(cornerPos % ROUND_RECT_CORNER_POS_ENUM_SIZE)); OH_Drawing_RoundRectGetCorner(roundRect, static_cast(cornerPos % ROUND_RECT_CORNER_POS_ENUM_SIZE)); + OH_Drawing_RoundRectGetCorner(roundRect, static_cast(cornerPos)); + + OH_Drawing_RoundRectOffset(roundRect, dx, dy); + OH_Drawing_RoundRectOffset(nullptr, dx, dy); OH_Drawing_RectDestroy(rect); OH_Drawing_RoundRectDestroy(roundRect); diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndkshadereffect_fuzzer/shadereffect_fuzzer.cpp b/rosen/test/2d_graphics/fuzztest/ndk/ndkshadereffect_fuzzer/shadereffect_fuzzer.cpp index 43e012619e..65584775c0 100755 --- a/rosen/test/2d_graphics/fuzztest/ndk/ndkshadereffect_fuzzer/shadereffect_fuzzer.cpp +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndkshadereffect_fuzzer/shadereffect_fuzzer.cpp @@ -117,8 +117,11 @@ void NativeShaderEffectTest002(const uint8_t* data, size_t size) OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); OH_Drawing_ShaderEffect* shaderEffectThree = OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix(startPoint, endPoint, colors, pos, format, static_cast(tileMode % TILE_MODE_ENUM_SIZE), matrix); + OH_Drawing_ShaderEffect* shaderEffectFour = OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix(nullptr, + endPoint, colors, pos, format, static_cast(tileMode % TILE_MODE_ENUM_SIZE), matrix); OH_Drawing_MatrixDestroy(matrix); OH_Drawing_ShaderEffectDestroy(shaderEffectThree); + OH_Drawing_ShaderEffectDestroy(shaderEffectFour); if (colors != nullptr) { delete[] colors; @@ -167,8 +170,12 @@ void NativeShaderEffectTest003(const uint8_t* data, size_t size) OH_Drawing_Point* centerPt = OH_Drawing_PointCreate(x, y); OH_Drawing_ShaderEffect* shaderEffectFour = OH_Drawing_ShaderEffectCreateRadialGradient(centerPt, radius, colors, pos, format, static_cast(tileMode % TILE_MODE_ENUM_SIZE)); + OH_Drawing_ShaderEffect* shaderEffectFive = OH_Drawing_ShaderEffectCreateRadialGradient(nullptr, radius, + colors, pos, format, static_cast(tileMode % TILE_MODE_ENUM_SIZE)); OH_Drawing_ShaderEffect* shaderEffectSix = OH_Drawing_ShaderEffectCreateSweepGradient(centerPt, colors, pos, format, static_cast(tileMode % TILE_MODE_ENUM_SIZE)); + OH_Drawing_ShaderEffect* shaderEffectSeven = OH_Drawing_ShaderEffectCreateSweepGradient(nullptr, colors, + pos, format, static_cast(tileMode % TILE_MODE_ENUM_SIZE)); if (colors != nullptr) { delete[] colors; colors = nullptr; @@ -180,7 +187,9 @@ void NativeShaderEffectTest003(const uint8_t* data, size_t size) OH_Drawing_PointDestroy(centerPt); OH_Drawing_MatrixDestroy(matrix); OH_Drawing_ShaderEffectDestroy(shaderEffectFour); + OH_Drawing_ShaderEffectDestroy(shaderEffectFive); OH_Drawing_ShaderEffectDestroy(shaderEffectSix); + OH_Drawing_ShaderEffectDestroy(shaderEffectSeven); } void NativeShaderEffectTest004(const uint8_t* data, size_t size) @@ -210,6 +219,8 @@ void NativeShaderEffectTest004(const uint8_t* data, size_t size) OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); OH_Drawing_ShaderEffect* shaderEffectFive = OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix(centerPoint, radius, colors, pos, format, static_cast(tileMode % TILE_MODE_ENUM_SIZE), matrix); + OH_Drawing_ShaderEffect* shaderEffectSix = OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix(nullptr, + radius, colors, pos, format, static_cast(tileMode % TILE_MODE_ENUM_SIZE), matrix); OH_Drawing_Image* image = OH_Drawing_ImageCreate(); uint32_t filterMode = GetObject(); uint32_t mipmapMode = GetObject(); @@ -219,6 +230,12 @@ void NativeShaderEffectTest004(const uint8_t* data, size_t size) OH_Drawing_ShaderEffect* shaderEffectSeven = OH_Drawing_ShaderEffectCreateImageShader(image, static_cast(tileMode % TILE_MODE_ENUM_SIZE), static_cast(tileMode % TILE_MODE_ENUM_SIZE), samplingOptions, matrix); + OH_Drawing_ShaderEffect* shaderEffectEight = OH_Drawing_ShaderEffectCreateImageShader(nullptr, + static_cast(tileMode % TILE_MODE_ENUM_SIZE), + static_cast(tileMode % TILE_MODE_ENUM_SIZE), samplingOptions, matrix); + OH_Drawing_ShaderEffect* shaderEffectNine = OH_Drawing_ShaderEffectCreateImageShader(image, + static_cast(tileMode % TILE_MODE_ENUM_SIZE), + static_cast(tileMode % TILE_MODE_ENUM_SIZE), samplingOptions, nullptr); if (centerPoint != nullptr) { delete[] centerPoint; centerPoint = nullptr; @@ -235,7 +252,10 @@ void NativeShaderEffectTest004(const uint8_t* data, size_t size) OH_Drawing_ImageDestroy(image); OH_Drawing_SamplingOptionsDestroy(samplingOptions); OH_Drawing_ShaderEffectDestroy(shaderEffectFive); + OH_Drawing_ShaderEffectDestroy(shaderEffectSix); OH_Drawing_ShaderEffectDestroy(shaderEffectSeven); + OH_Drawing_ShaderEffectDestroy(shaderEffectEight); + OH_Drawing_ShaderEffectDestroy(shaderEffectNine); } void NativeShaderEffectTest005(const uint8_t* data, size_t size) @@ -271,6 +291,9 @@ void NativeShaderEffectTest005(const uint8_t* data, size_t size) OH_Drawing_ShaderEffect* ShaderEffectEight = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(startPoint, startRadius, endPoint, endRadius, colors, pos, format, static_cast(tileMode % TILE_MODE_ENUM_SIZE), matrix); + OH_Drawing_ShaderEffect* ShaderEffectNine = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(nullptr, + startRadius, endPoint, endRadius, colors, pos, format, + static_cast(tileMode % TILE_MODE_ENUM_SIZE), matrix); if (colors != nullptr) { delete[] colors; @@ -291,6 +314,7 @@ void NativeShaderEffectTest005(const uint8_t* data, size_t size) OH_Drawing_MatrixDestroy(matrix); OH_Drawing_ShaderEffectDestroy(ShaderEffectEight); + OH_Drawing_ShaderEffectDestroy(ShaderEffectNine); } } // namespace Drawing diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndktextblob_fuzzer/ndktextblob_fuzzer.cpp b/rosen/test/2d_graphics/fuzztest/ndk/ndktextblob_fuzzer/ndktextblob_fuzzer.cpp index 8e0e940475..14406843b9 100644 --- a/rosen/test/2d_graphics/fuzztest/ndk/ndktextblob_fuzzer/ndktextblob_fuzzer.cpp +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndktextblob_fuzzer/ndktextblob_fuzzer.cpp @@ -47,6 +47,7 @@ void NativeDrawingTextBlobTest001(const uint8_t* data, size_t size) OH_Drawing_Font* font = OH_Drawing_FontCreate(); OH_Drawing_TextBlobBuilder* textBlobBuilder = OH_Drawing_TextBlobBuilderCreate(); OH_Drawing_TextBlob* textBlob = OH_Drawing_TextBlobBuilderMake(textBlobBuilder); + OH_Drawing_TextBlob* textBlobTwo = OH_Drawing_TextBlobBuilderMake(nullptr); float left = GetObject(); float top = GetObject(); @@ -54,12 +55,14 @@ void NativeDrawingTextBlobTest001(const uint8_t* data, size_t size) float bottom = GetObject(); OH_Drawing_Rect* rect = OH_Drawing_RectCreate(left, top, right, bottom); OH_Drawing_TextBlobGetBounds(nullptr, rect); + OH_Drawing_TextBlobGetBounds(textBlob, nullptr); OH_Drawing_TextBlobGetBounds(textBlob, rect); OH_Drawing_TextBlobUniqueID(nullptr); OH_Drawing_TextBlobUniqueID(textBlob); OH_Drawing_TextBlobDestroy(textBlob); + OH_Drawing_TextBlobDestroy(textBlobTwo); OH_Drawing_TextBlobBuilderDestroy(textBlobBuilder); OH_Drawing_FontDestroy(font); OH_Drawing_RectDestroy(rect); diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndktypeface_fuzzer/ndktypeface_fuzzer.cpp b/rosen/test/2d_graphics/fuzztest/ndk/ndktypeface_fuzzer/ndktypeface_fuzzer.cpp index 419bb8165f..4c51149d06 100644 --- a/rosen/test/2d_graphics/fuzztest/ndk/ndktypeface_fuzzer/ndktypeface_fuzzer.cpp +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndktypeface_fuzzer/ndktypeface_fuzzer.cpp @@ -55,6 +55,9 @@ void NativeDrawingTypefaceTest001(const uint8_t* data, size_t size) OH_Drawing_TypefaceCreateFromFile(nullptr, 0); OH_Drawing_Typeface* typefaceOne = OH_Drawing_TypefaceCreateFromFile(path, index); + char pathTwo[] = "system/fonts/NotoSansBengaliUI-Bold.ttf"; + OH_Drawing_Typeface* typefaceTwo = OH_Drawing_TypefaceCreateFromFile(pathTwo, index); + bool copyData = GetObject(); uint32_t str_size = GetObject() % MAX_ARRAY_SIZE; char* str = new char[str_size]; @@ -72,8 +75,10 @@ void NativeDrawingTypefaceTest001(const uint8_t* data, size_t size) delete [] str; str = nullptr; } + OH_Drawing_TypefaceDestroy(typeface); OH_Drawing_TypefaceDestroy(typefaceOne); + OH_Drawing_TypefaceDestroy(typefaceTwo); OH_Drawing_MemoryStreamDestroy(memoryStream); } void NativeDrawingTypefaceTest002(const uint8_t* data, size_t size) From bc83caac6434afcf0f8d311dfdc4f5c2699f1886 Mon Sep 17 00:00:00 2001 From: dengyanfang23 Date: Wed, 26 Jun 2024 18:23:50 +0800 Subject: [PATCH 082/247] =?UTF-8?q?=E4=BF=AE=E5=A4=8DHMSymbol=20=E9=9D=99?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E7=BB=98=E5=88=B6=E9=A2=9C=E8=89=B2=E4=B8=8D?= =?UTF-8?q?=E4=B8=80=E8=87=B4=E7=9A=84=E9=97=AE=E9=A2=98+=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E5=A4=84=E7=90=86=20Signed-off-by:=20dengyanfang23=20?= =?UTF-8?q??= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rosen_text/symbol_animation_config.h | 6 +- .../symbol_engine/hm_symbol_node_build.cpp | 132 ++++++++++++++---- .../skia_hm_symbol_config_ohos.cpp | 4 +- .../core/animation/rs_symbol_animation.cpp | 49 +++---- .../core/animation/rs_symbol_animation.h | 2 +- .../hm_symbol/hm_symbol_node_build_test.cpp | 23 +++ 6 files changed, 154 insertions(+), 62 deletions(-) diff --git a/rosen/modules/2d_engine/rosen_text/export/rosen_text/symbol_animation_config.h b/rosen/modules/2d_engine/rosen_text/export/rosen_text/symbol_animation_config.h index 6b89dd9967..7dc8497b36 100644 --- a/rosen/modules/2d_engine/rosen_text/export/rosen_text/symbol_animation_config.h +++ b/rosen/modules/2d_engine/rosen_text/export/rosen_text/symbol_animation_config.h @@ -25,9 +25,13 @@ namespace OHOS { namespace Rosen { namespace TextEngine { -struct SymbolNode { +struct NodeLayerInfo { Drawing::Path path; Drawing::DrawingSColor color; +}; + +struct SymbolNode { + std::vector pathsInfo; Vector4f nodeBoundary; Drawing::DrawingHMSymbolData symbolData; int animationIndex = 0; diff --git a/rosen/modules/2d_engine/rosen_text/skia_txt/symbol_engine/hm_symbol_node_build.cpp b/rosen/modules/2d_engine/rosen_text/skia_txt/symbol_engine/hm_symbol_node_build.cpp index 82cf0d6346..fe21c17640 100644 --- a/rosen/modules/2d_engine/rosen_text/skia_txt/symbol_engine/hm_symbol_node_build.cpp +++ b/rosen/modules/2d_engine/rosen_text/skia_txt/symbol_engine/hm_symbol_node_build.cpp @@ -19,27 +19,101 @@ namespace OHOS { namespace Rosen { namespace SPText { -static void MergePath(RSPath& multPath, const std::vector& groupInfos, std::vector& pathLayers) +/** + * @brief Obtain the group id to layer + * @param groupIds (output paramer) the index of groupIds if layer index, the groupIds[index] is the group index + * @param renderGroup the renderGroup info of symbol + * @param index the renderGroup index + */ +static void GetLayersGroupId(std::vector& groupIds, const RSRenderGroup& renderGroup, size_t index) { + for (auto& groupInfo : renderGroup.groupInfos) { + for (auto& j : groupInfo.layerIndexes) { + if (j < groupIds.size()) { + groupIds[j] = index; + } + } + for (auto& j : groupInfo.maskIndexes) { + if (j < groupIds.size()) { + groupIds[j] = index; + } + } + } +} + +/** + * @brief Merge the mask paths. + * @param maskIndexes the indexes of maskLayer of group informations + * @param pathLayers the path data of layers on symbol, the value of maskIndexes < pathLayers.size + * @param pathsColorIndex the start pathsColor position for merging mask pathh + * @param pathsColor (output paramer) the result of the merge + */ +static void MergeMaskPath(const std::vector& maskIndexes, std::vector& pathLayers, + size_t pathsColorIndex, std::vector& pathsColor) +{ + RSPath maskPath; + for (size_t maskIndex : maskIndexes) { + if (maskIndex < pathLayers.size()) { + maskPath.AddPath(pathLayers[maskIndex]); + } + } + if (!maskPath.IsValid()) { + return; + } + + for (size_t j = pathsColorIndex; j < pathsColor.size(); j++) { + Drawing::Path outPath; + bool isOk = outPath.Op(pathsColor[j].path, maskPath, Drawing::PathOp::DIFFERENCE); + pathsColor[j].path = isOk ? outPath : pathsColor[j].path; + } +} + +/** + * @brief Merge the paths of Group by layer color. + * @param groupInfos a group informations of dynamic drawing + * @param pathLayers the path data of layers on symbol + * @param groupIndexes the indexes list of groups on colorGroups, the groupIndexes.size == pathLayers.size, \n + * groupIndexes.size == pathLayers.size, groupIndexes[groupIndexes.size - 1] < colorGroups.size + * @param pathsColor (output paramer) the result of the merge, where each merged path corresponds to a specific color + * @param colorGroups the groups informations of static drawing, include color data + */ +static void MergePathByLayerColor(const std::vector& groupInfos, + std::vector& pathLayers, const std::vector& groupIndexes, + std::vector& pathsColor, const std::vector& colorGroups) +{ + size_t pathsColorIndex = 0; + RSSColor color = {0, 0, 0, 0}; // default color with 0 alpha for (const auto& groupInfo : groupInfos) { - RSPath pathTemp; - for (auto k : groupInfo.layerIndexes) { - if (k >= pathLayers.size()) { + TextEngine::NodeLayerInfo tempLayer; + size_t currentIndex = 0; // the current layerindex, that effective index of tempLayer + bool isFirst = true; + for (auto& layerIndex: groupInfo.layerIndexes) { + if (layerIndex >= pathLayers.size() || layerIndex >= groupIndexes.size()) { continue; } - pathTemp.AddPath(pathLayers[k]); - } - for (size_t h : groupInfo.maskIndexes) { - if (h >= pathLayers.size()) { + if (isFirst) { // initialize tempLayer + auto groupIndex = groupIndexes[layerIndex]; + tempLayer.color = groupIndex < colorGroups.size() ? colorGroups[groupIndex].color : color; + tempLayer.path.AddPath(pathLayers[layerIndex]); + currentIndex = layerIndex; + isFirst = false; continue; } - RSPath outPath; - auto isOk = outPath.Op(pathTemp, pathLayers[h], RSPathOp::DIFFERENCE); - if (isOk) { - pathTemp = outPath; + // If the groupIndex of two paths is different, updata pathsColor and tempLayer + if (groupIndexes[currentIndex] != groupIndexes[layerIndex]) { + pathsColor.push_back(tempLayer); + tempLayer.path.Reset(); + auto groupIndex = groupIndexes[layerIndex]; + tempLayer.color = groupIndex < colorGroups.size() ? colorGroups[groupIndex].color : color; + currentIndex = layerIndex; } + tempLayer.path.AddPath(pathLayers[layerIndex]); } - multPath.AddPath(pathTemp); + pathsColor.push_back(tempLayer); + if (!groupInfo.maskIndexes.empty()) { + MergeMaskPath(groupInfo.maskIndexes, pathLayers, pathsColorIndex, pathsColor); + } + pathsColorIndex = pathsColor.size(); } } @@ -92,24 +166,28 @@ void SymbolNodeBuild::AddHierarchicalAnimation(RSHMSymbolData &symbolData, const RSHMSymbol::PathOutlineDecompose(symbolData.path_, paths); std::vector pathLayers; RSHMSymbol::MultilayerPath(symbolData.symbolInfo_.layers, paths, pathLayers); - RSSColor color; - size_t i = 0; - auto renderGroups = symbolData.symbolInfo_.renderGroups; + + // Obtain the group id of layer + std::vector groupIds(pathLayers.size(), pathLayers.size()); + for (size_t idx = 0; idx < symbolData.symbolInfo_.renderGroups.size(); idx++) { + GetLayersGroupId(groupIds, symbolData.symbolInfo_.renderGroups[idx], idx); + } + + // Splitting animation nodes information for (auto& groupSetting: groupSettings) { - RSPath multPath; - RSPath maskPath; - bool isMask = IsMaskLayer(maskPath, groupSetting.groupInfos, pathLayers); + TextEngine::SymbolNode symbolNode; + TextEngine::NodeLayerInfo maskPath; + bool isMask = IsMaskLayer(maskPath.path, groupSetting.groupInfos, pathLayers); if (!isMask) { - MergePath(multPath, groupSetting.groupInfos, pathLayers); - if (i < renderGroups.size()) { - color = renderGroups[i].color; - i++; - } + MergePathByLayerColor(groupSetting.groupInfos, pathLayers, groupIds, symbolNode.pathsInfo, + symbolData.symbolInfo_.renderGroups); } else { - multPath = maskPath; + symbolNode.pathsInfo.push_back(maskPath); } - TextEngine::SymbolNode symbolNode = {multPath, color, nodeBounds, symbolData, - groupSetting.animationIndex, isMask}; + symbolNode.nodeBoundary = nodeBounds; + symbolNode.symbolData = symbolData; + symbolNode.animationIndex = groupSetting.animationIndex; + symbolNode.isMask = isMask; symbolAnimationConfig->symbolNodes.push_back(symbolNode); } symbolAnimationConfig->numNodes = symbolAnimationConfig->symbolNodes.size(); diff --git a/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_hm_symbol_config_ohos.cpp b/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_hm_symbol_config_ohos.cpp index fcb00a19bc..be1bd48a49 100644 --- a/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_hm_symbol_config_ohos.cpp +++ b/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_hm_symbol_config_ohos.cpp @@ -29,9 +29,9 @@ DrawingSymbolLayersGroups SkiaHmSymbolConfigOhos::GetSymbolLayersGroups(uint16_t drawingGroups.symbolGlyphId = groups.symbolGlyphId; drawingGroups.layers = groups.layers; std::vector drawingSettings; - auto& settings = groups.animationSettings; + const auto& settings = groups.animationSettings; std::map> drawingRenderModeGroups; - auto& renderModeGroups = groups.renderModeGroups; + const auto& renderModeGroups = groups.renderModeGroups; for (size_t i = 0; i < settings.size(); i++) { drawingSettings.push_back(ConvertToDrawingAnimationSetting(settings.at(i))); } diff --git a/rosen/modules/render_service_client/core/animation/rs_symbol_animation.cpp b/rosen/modules/render_service_client/core/animation/rs_symbol_animation.cpp index 5d63600bb0..a3b6a490b4 100644 --- a/rosen/modules/render_service_client/core/animation/rs_symbol_animation.cpp +++ b/rosen/modules/render_service_client/core/animation/rs_symbol_animation.cpp @@ -236,13 +236,9 @@ bool RSSymbolAnimation::SetReplaceDisappear( ROSEN_LOGD("[%{public}s] invalid parameter \n", __func__); continue; } - auto oneGroupParas = parameters[config.symbolNode.animationIndex]; - if (oneGroupParas.empty()) { - ROSEN_LOGD("[%{public}s] invalid oneGroupParas \n", __func__); - continue; - } auto canvasNode = rsNode_->canvasNodesListMap[symbolAnimationConfig->symbolSpanId][id]; - SpliceAnimation(canvasNode, oneGroupParas, Drawing::DrawingEffectStrategy::DISAPPEAR); + SpliceAnimation(canvasNode, parameters[config.symbolNode.animationIndex], + Drawing::DrawingEffectStrategy::DISAPPEAR); } { std::lock_guard lock(rsNode_->childrenNodeLock_); @@ -295,12 +291,7 @@ bool RSSymbolAnimation::SetReplaceAppear( ROSEN_LOGD("[%{public}s] invalid parameter \n", __func__); continue; } - auto oneGroupParas = parameters[symbolNode.animationIndex]; - if (oneGroupParas.empty()) { - ROSEN_LOGD("[%{public}s] invalid parameter \n", __func__); - continue; - } - SpliceAnimation(canvasNode, oneGroupParas, Drawing::DrawingEffectStrategy::APPEAR); + SpliceAnimation(canvasNode, parameters[symbolNode.animationIndex], Drawing::DrawingEffectStrategy::APPEAR); } return true; } @@ -424,12 +415,7 @@ bool RSSymbolAnimation::SetPublicAnimation( ROSEN_LOGD("[%{public}s] invalid parameter \n", __func__); continue; } - auto oneGroupParas = parameters[symbolNode.animationIndex]; - if (oneGroupParas.empty()) { - ROSEN_LOGD("[%{public}s] invalid parameter \n", __func__); - continue; - } - ChooseAnimation(canvasNode, oneGroupParas, symbolAnimationConfig); + ChooseAnimation(canvasNode, parameters[symbolNode.animationIndex], symbolAnimationConfig); } return true; } @@ -562,7 +548,6 @@ void RSSymbolAnimation::DrawSymbolOnCanvas( } Drawing::Brush brush; Drawing::Pen pen; - SetIconProperty(brush, pen, symbolNode); Drawing::Point offsetLocal = Drawing::Point { offsets[2], offsets[3] }; // index 2 offsetX 3 offsetY recordingCanvas->AttachBrush(brush); recordingCanvas->AttachPen(pen); @@ -585,13 +570,15 @@ void RSSymbolAnimation::DrawPathOnCanvas( brush.SetBlendMode(Drawing::BlendMode::CLEAR); pen.SetBlendMode(Drawing::BlendMode::CLEAR); } - SetIconProperty(brush, pen, symbolNode); - symbolNode.path.Offset(offsets[2], offsets[3]); // index 2 offsetX 3 offsetY - recordingCanvas->AttachBrush(brush); - recordingCanvas->AttachPen(pen); - recordingCanvas->DrawPath(symbolNode.path); - recordingCanvas->DetachBrush(); - recordingCanvas->DetachPen(); + for (auto& pathInfo: symbolNode.pathsInfo) { + SetIconProperty(brush, pen, pathInfo.color); + pathInfo.path.Offset(offsets[2], offsets[3]); // index 2 offsetX 3 offsetY + recordingCanvas->AttachBrush(brush); + recordingCanvas->AttachPen(pen); + recordingCanvas->DrawPath(pathInfo.path); + recordingCanvas->DetachBrush(); + recordingCanvas->DetachPen(); + } } bool RSSymbolAnimation::SetSymbolGeometry(const std::shared_ptr& rsNode, const Vector4f& bounds) @@ -715,14 +702,14 @@ bool RSSymbolAnimation::CalcTimePercents(std::vector& timePercents, const return true; } -void RSSymbolAnimation::SetIconProperty(Drawing::Brush& brush, Drawing::Pen& pen, TextEngine::SymbolNode& symbolNode) +void RSSymbolAnimation::SetIconProperty(Drawing::Brush& brush, Drawing::Pen& pen, Drawing::DrawingSColor& color) { - brush.SetColor(Drawing::Color::ColorQuadSetARGB(0xFF, symbolNode.color.r, symbolNode.color.g, symbolNode.color.b)); - brush.SetAlphaF(symbolNode.color.a); + brush.SetColor(Drawing::Color::ColorQuadSetARGB(0xFF, color.r, color.g, color.b)); + brush.SetAlphaF(color.a); brush.SetAntiAlias(true); - pen.SetColor(Drawing::Color::ColorQuadSetARGB(0xFF, symbolNode.color.r, symbolNode.color.g, symbolNode.color.b)); - pen.SetAlphaF(symbolNode.color.a); + pen.SetColor(Drawing::Color::ColorQuadSetARGB(0xFF, color.r, color.g, color.b)); + pen.SetAlphaF(color.a); pen.SetAntiAlias(true); return; } diff --git a/rosen/modules/render_service_client/core/animation/rs_symbol_animation.h b/rosen/modules/render_service_client/core/animation/rs_symbol_animation.h index 4017876851..901b69530a 100644 --- a/rosen/modules/render_service_client/core/animation/rs_symbol_animation.h +++ b/rosen/modules/render_service_client/core/animation/rs_symbol_animation.h @@ -95,7 +95,7 @@ private: void GroupDrawing(const std::shared_ptr& canvasNode, TextEngine::SymbolNode& symbolNode, const Vector4f& offsets, bool isMultiLayer); - void SetIconProperty(Drawing::Brush& brush, Drawing::Pen& pen, TextEngine::SymbolNode& symbolNode); + void SetIconProperty(Drawing::Brush& brush, Drawing::Pen& pen, Drawing::DrawingSColor& color); Vector4f CalculateOffset(const Drawing::Path& path, const float offsetX, const float offsetY); void DrawSymbolOnCanvas( diff --git a/rosen/test/2d_engine/unittest/rosen_text/hm_symbol/hm_symbol_node_build_test.cpp b/rosen/test/2d_engine/unittest/rosen_text/hm_symbol/hm_symbol_node_build_test.cpp index 7414c02f93..d9a7fedb71 100644 --- a/rosen/test/2d_engine/unittest/rosen_text/hm_symbol/hm_symbol_node_build_test.cpp +++ b/rosen/test/2d_engine/unittest/rosen_text/hm_symbol/hm_symbol_node_build_test.cpp @@ -296,6 +296,29 @@ HWTEST_F(OHHmSymbolNodeBuildTest, DecomposeSymbolAndDraw006, TestSize.Level1) EXPECT_EQ(result2, false); } +/* + * @tc.name: DecomposeSymbolAndDraw007 + * @tc.desc: test DecomposeSymbolAndDraw with animation VARIABLE_COLOR, two rendergroups and only one animationGroup + * @tc.type: FUNC + */ +HWTEST_F(OHHmSymbolNodeBuildTest, DecomposeSymbolAndDraw007, TestSize.Level1) +{ + std::pair offset = {100, 100}; // 100, 100 is the offset + RSPath path; + path.AddCircle(100, 100, 50); // 100 x, 100, 50 radius + path.AddCircle(100, 100, 30, Drawing::PathDirection::CCW_DIRECTION); // 100 x, 100, 30 radius + RSHMSymbolData symbol; + symbol.path_ = path; + symbol.symbolInfo_.layers = layers_; + symbol.symbolInfo_.renderGroups = renderGroupsTwo_; + + RSEffectStrategy effectMode = RSEffectStrategy::VARIABLE_COLOR; + SymbolNodeBuild symbolNode = SymbolNodeBuild(animationSettingOne_, symbol, effectMode, offset); + symbolNode.SetAnimation(&SetSymbolAnimationOne); + int result = symbolNode.DecomposeSymbolAndDraw(); + EXPECT_EQ(result, true); +} + /* * @tc.name: ClearAnimation001 * @tc.desc: test ClearAnimation with animation VARIABLE_COLOR, cumulative effect and maskIndexes From 9d1ae78f27717e936fc55317385846cb3e40b255 Mon Sep 17 00:00:00 2001 From: WenyiRoad Date: Fri, 28 Jun 2024 11:05:54 +0800 Subject: [PATCH 083/247] fixSCB Signed-off-by: WenyiRoad --- .../core/transaction/rs_render_service_connection_stub.cpp | 4 +++- .../src/platform/ohos/rs_render_service_connection_proxy.cpp | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp b/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp index 6123f28c77..a66ddee367 100644 --- a/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp +++ b/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp @@ -288,9 +288,11 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( auto bundleName = data.ReadString(); bool isTextureExportNode = data.ReadBool(); bool isSync = data.ReadBool(); + auto surfaceWindowType = static_cast(data.ReadUint8()); RSSurfaceRenderNodeConfig config = { .id = nodeId, .name = surfaceName, .bundleName = bundleName, .nodeType = type, - .isTextureExportNode = isTextureExportNode, .isSync = isSync}; + .isTextureExportNode = isTextureExportNode, .isSync = isSync, + .surfaceWindowType = surfaceWindowType}; sptr surface = CreateNodeAndSurface(config); if (surface == nullptr) { ret = ERR_NULL_OBJECT; diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.cpp b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.cpp index a01cc4b8a7..4a26fb9592 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.cpp @@ -204,6 +204,9 @@ sptr RSRenderServiceConnectionProxy::CreateNodeAndSurface(const RSSurfa if (!data.WriteBool(config.isSync)) { return nullptr; } + if (!data.WriteUint8(static_cast(config.surfaceWindowType))) { + return nullptr; + } option.SetFlags(MessageOption::TF_SYNC); uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_NODE_AND_SURFACE); int32_t err = Remote()->SendRequest(code, data, reply, option); From 59d70f0afdc76d3ebcfcca052d6d7f4ff863c8ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=AF=E9=91=AB?= Date: Fri, 28 Jun 2024 14:14:10 +0800 Subject: [PATCH 084/247] =?UTF-8?q?=E4=BC=98=E5=8C=96USER=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=E5=8A=A0=E8=BD=BDdebug=20layer=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 凯鑫 --- .../src/EGL/egl_wrapper_layer.cpp | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/frameworks/opengl_wrapper/src/EGL/egl_wrapper_layer.cpp b/frameworks/opengl_wrapper/src/EGL/egl_wrapper_layer.cpp index 8d0fbc6b63..08c8a1c7cf 100644 --- a/frameworks/opengl_wrapper/src/EGL/egl_wrapper_layer.cpp +++ b/frameworks/opengl_wrapper/src/EGL/egl_wrapper_layer.cpp @@ -145,9 +145,16 @@ static std::vector GetDebugLayerPaths() WLOGD("GetDebugLayerPaths"); std::vector layerPaths = {std::string(DEBUG_LAYERS_LIB_DIR)}; std::string pathStr(DEBUG_SANDBOX_DIR); - layerPaths.push_back(pathStr + g_bundleInfo.applicationInfo.nativeLibraryPath + "/"); + + std::string appLibPath = g_bundleInfo.applicationInfo.nativeLibraryPath; + if (!appLibPath.empty()) { + layerPaths.push_back(pathStr + appLibPath + "/"); + } + for (auto hapModuleInfo: g_bundleInfo.hapModuleInfos) { - layerPaths.push_back(hapModuleInfo.nativeLibraryPath + "/"); + if (!hapModuleInfo.nativeLibraryPath.empty()) { + layerPaths.push_back(hapModuleInfo.nativeLibraryPath + "/"); + } } return layerPaths; } @@ -176,11 +183,6 @@ bool EglWrapperLayer::Init(EglWrapperDispatchTable *table) return false; } - if (!InitBundleInfo()) { - WLOGE("Get BundleInfo failed."); - return false; - } - if (!LoadLayers()) { WLOGE("LoadLayers failed."); return false; @@ -194,6 +196,11 @@ bool EglWrapperLayer::Init(EglWrapperDispatchTable *table) bool EglWrapperLayer::InitBundleInfo() { + std::string debugHap = system::GetParameter(DEBUG_HAP_NAME, ""); + if (debugHap.empty()) { + WLOGD("The parameter for debug hap name is not set!"); + return false; + } auto eglBundleMgrHelper = DelayedSingleton::GetInstance(); if (eglBundleMgrHelper == nullptr) { WLOGE("eglBundleMgrHelper is null!"); @@ -202,7 +209,6 @@ bool EglWrapperLayer::InitBundleInfo() if (eglBundleMgrHelper->GetBundleInfoForSelf( AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION, g_bundleInfo) == ERR_OK) { - std::string debugHap = system::GetParameter(DEBUG_HAP_NAME, ""); if (g_bundleInfo.name == debugHap) { return true; } else { @@ -279,6 +285,10 @@ bool EglWrapperLayer::LoadLayers() return false; } + if (!InitBundleInfo()) { + WLOGD("Get BundleInfo failed."); + } + for (int32_t i = layers.size() - 1; i >= 0; i--) { std::string layerLib = std::string(DEBUG_LAYERS_PREFIX) + layers[i] + std::string(DEBUG_LAYERS_SUFFIX); std::vector allLayerPaths = GetDebugLayerPaths(); From 0fc45edd19b91098d7d744430ec8134c62c28401 Mon Sep 17 00:00:00 2001 From: LeesonWong Date: Fri, 28 Jun 2024 14:44:18 +0800 Subject: [PATCH 085/247] Test cases for rs_image_cache.cpp Signed-off-by: w30027672 --- .../src/render/rs_image_cache.cpp | 4 +- .../test/unittest/BUILD.gn | 5 +- .../test/unittest/render/BUILD.gn | 64 +++++ .../unittest/render/rs_image_cache_test.cpp | 264 ++++++++++++++++++ 4 files changed, 334 insertions(+), 3 deletions(-) create mode 100644 rosen/modules/render_service_base/test/unittest/render/BUILD.gn create mode 100644 rosen/modules/render_service_base/test/unittest/render/rs_image_cache_test.cpp diff --git a/rosen/modules/render_service_base/src/render/rs_image_cache.cpp b/rosen/modules/render_service_base/src/render/rs_image_cache.cpp index 5e194c82b6..c1445c99e5 100644 --- a/rosen/modules/render_service_base/src/render/rs_image_cache.cpp +++ b/rosen/modules/render_service_base/src/render/rs_image_cache.cpp @@ -60,7 +60,7 @@ void RSImageCache::ReleaseDrawingImageCache(uint64_t uniqueId) auto it = drawingImageCache_.find(uniqueId); if (it != drawingImageCache_.end()) { it->second.second--; - if (it->second.first == nullptr || it->second.second == 0) { + if (it->second.first == nullptr || it->second.second <= 0) { drawingImageCache_.erase(it); } } @@ -102,7 +102,7 @@ void RSImageCache::ReleasePixelMapCache(uint64_t uniqueId) auto it = pixelMapCache_.find(uniqueId); if (it != pixelMapCache_.end()) { it->second.second--; - if (it->second.first == nullptr || it->second.second == 0) { + if (it->second.first == nullptr || it->second.second <= 0) { pixelMap = it->second.first; pixelMapCache_.erase(it); ReleaseDrawingImageCacheByPixelMapId(uniqueId); diff --git a/rosen/modules/render_service_base/test/unittest/BUILD.gn b/rosen/modules/render_service_base/test/unittest/BUILD.gn index f24e1fee60..25c9c59f56 100644 --- a/rosen/modules/render_service_base/test/unittest/BUILD.gn +++ b/rosen/modules/render_service_base/test/unittest/BUILD.gn @@ -16,5 +16,8 @@ import("//build/test.gni") group("unittest") { testonly = true - deps = [ "animation:RSRenderAnimationTest" ] + deps = [ + "animation:RSRenderAnimationTest", + "render:RSRenderTest", + ] } diff --git a/rosen/modules/render_service_base/test/unittest/render/BUILD.gn b/rosen/modules/render_service_base/test/unittest/render/BUILD.gn new file mode 100644 index 0000000000..5342cf0aed --- /dev/null +++ b/rosen/modules/render_service_base/test/unittest/render/BUILD.gn @@ -0,0 +1,64 @@ +# Copyright (c) 2022 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. + +import("//build/test.gni") +import( +"//foundation/graphic/graphic_2d/rosen/modules/render_service_client/render_service_client.gni") + +module_output_path = "graphic_2d/rosen/modules/render_service_base" + +ohos_unittest("RSRenderTest") { + module_out_path = module_output_path + + sources = [ + "rs_image_cache_test.cpp", + ] + + configs = [ ":rs_render_test_config" ] + + deps = [ + "../../../../render_service_base:render_service_base_src", + "//foundation/window/window_manager/wm:libwm", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "eventhandler:libeventhandler", + "graphic_surface:surface", + "hilog:libhilog", + "image_framework:image_native", + ] + + subsystem_name = "graphic" +} + +config("rs_render_test_config") { + visibility = [ ":*" ] + include_dirs = [ + "//foundation/window/window_manager/interfaces/innerkits", + "//foundation/graphic/graphic_2d/rosen/modules/render_service_base", + ] + + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + "-Dprotected=public", + ] +} + +group("unittest") { + testonly = true + deps = [ ":RSRenderTest" ] +} diff --git a/rosen/modules/render_service_base/test/unittest/render/rs_image_cache_test.cpp b/rosen/modules/render_service_base/test/unittest/render/rs_image_cache_test.cpp new file mode 100644 index 0000000000..ff8aa85cee --- /dev/null +++ b/rosen/modules/render_service_base/test/unittest/render/rs_image_cache_test.cpp @@ -0,0 +1,264 @@ +/* + * Copyright (c) 2022 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 + +#include "render/rs_image_cache.h" +#include "platform/common/rs_log.h" +#include "image/image.h" +#include "pixel_map.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Rosen { +class RSImageCacheTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void RSImageCacheTest::SetUpTestCase() {} +void RSImageCacheTest::TearDownTestCase() {} + +void RSImageCacheTest::SetUp() {} +void RSImageCacheTest::TearDown() {} + +HWTEST_F(RSImageCacheTest, Singleton001, TestSize.Level1) { + GTEST_LOG_(INFO) << "RSImageCacheTest Singleton001 start"; + + auto& instance1 = RSImageCache::Instance(); + auto& instance2 = RSImageCache::Instance(); + EXPECT_EQ(&instance1, &instance2); + + GTEST_LOG_(INFO) << "RSImageCacheTest Singleton001 start"; +} + +/** + * @tc.name: DrawingImageCache001 + * @tc.desc: Verify the GetDrawingImageCache + * @tc.type:FUNC + */ +HWTEST_F(RSImageCacheTest, DrawingImageCache001, TestSize.Level1) { + GTEST_LOG_(INFO) << "RSImageCacheTest DrawingImageCache001 start"; + + auto& instance = RSImageCache::Instance(); + const uint64_t UNADDED_ID = 100; + EXPECT_EQ(instance.GetDrawingImageCache(UNADDED_ID), nullptr); + + GTEST_LOG_(INFO) << "RSImageCacheTest DrawingImageCache001 start"; +} + +/** + * @tc.name: DrawingImageCache002 + * @tc.desc: Verify the CacheDrawingImage && GetDrawingImageCache + * @tc.type:FUNC + */ +HWTEST_F(RSImageCacheTest, DrawingImageCache002, TestSize.Level1) { + GTEST_LOG_(INFO) << "RSImageCacheTest DrawingImageCache002 start"; + + auto& instance = RSImageCache::Instance(); + std::map> imgMap; + for (uint64_t uniqueId = 1;uniqueId < 16;uniqueId++) { + auto img = std::make_shared(); + instance.CacheDrawingImage(uniqueId, img); + imgMap[uniqueId] = img; + } + for (const auto& pair : imgMap) { + EXPECT_EQ(pair.second, instance.GetDrawingImageCache(pair.first)); + } + + GTEST_LOG_(INFO) << "RSImageCacheTest DrawingImageCache002 start"; +} + +/** + * @tc.name: ModifyDrawingImageCacheRefCount001 + * @tc.desc: Verify the ReleaseDrawingImageCache + * @tc.type:FUNC + */ +HWTEST_F(RSImageCacheTest, ModifyDrawingImageCacheRefCount001, TestSize.Level1) { + GTEST_LOG_(INFO) << "RSImageCacheTest ModifyDrawingImageCacheRefCount001 start"; + + auto& instance = RSImageCache::Instance(); + const uint64_t ADDED_ID = 200; + auto img = std::make_shared(); + instance.CacheDrawingImage(ADDED_ID, img); + EXPECT_EQ(instance.GetDrawingImageCache(ADDED_ID), img); + instance.IncreaseDrawingImageCacheRefCount(ADDED_ID); + instance.ReleaseDrawingImageCache(ADDED_ID); + EXPECT_EQ(instance.GetDrawingImageCache(ADDED_ID), nullptr); + + GTEST_LOG_(INFO) << "RSImageCacheTest ModifyDrawingImageCacheRefCount001 start"; +} + +/** + * @tc.name: ModifyDrawingImageCacheRefCount002 + * @tc.desc: Verify the IncreaseDrawingImageCacheRefCount && ReleaseDrawingImageCache + * @tc.type:FUNC + */ +HWTEST_F(RSImageCacheTest, ModifyDrawingImageCacheRefCount002, TestSize.Level1) { + GTEST_LOG_(INFO) << "RSImageCacheTest ModifyDrawingImageCacheRefCount002 start"; + + auto& instance = RSImageCache::Instance(); + const uint64_t ADDED_ID = 300; + auto img = std::make_shared(); + instance.CacheDrawingImage(ADDED_ID, img); + for (uint64_t count = 0;count < 10;count++) { + instance.IncreaseDrawingImageCacheRefCount(ADDED_ID); + } + for (uint64_t count = 0;count < 9;count++) { + instance.ReleaseDrawingImageCache(ADDED_ID); + EXPECT_NE(instance.GetDrawingImageCache(ADDED_ID), nullptr); + } + instance.ReleaseDrawingImageCache(ADDED_ID); + EXPECT_EQ(instance.GetDrawingImageCache(ADDED_ID), nullptr); + + GTEST_LOG_(INFO) << "RSImageCacheTest ModifyDrawingImageCacheRefCount002 start"; +} + +/** + * @tc.name: CachePixelMap001 + * @tc.desc: Verify the GetPixelMapCache + * @tc.type:FUNC + */ +HWTEST_F(RSImageCacheTest, CachePixelMap001, TestSize.Level1) { + GTEST_LOG_(INFO) << "RSImageCacheTest CachePixelMap001 start"; + + auto& instance = RSImageCache::Instance(); + const uint64_t UNADDED_ID = 400; + EXPECT_EQ(instance.GetPixelMapCache(UNADDED_ID), nullptr); + + GTEST_LOG_(INFO) << "RSImageCacheTest CachePixelMap001 start"; +} + +/** + * @tc.name: CachePixelMap002 + * @tc.desc: Verify the GetPixelMapCache && CachePixelMap + * @tc.type:FUNC + */ +HWTEST_F(RSImageCacheTest, CachePixelMap002, TestSize.Level1) { + GTEST_LOG_(INFO) << "RSImageCacheTest CachePixelMap002 start"; + + auto& instance = RSImageCache::Instance(); + std::map> pixelMap; + for (uint64_t uniqueId = 1;uniqueId < 16;uniqueId++) { + auto pixel = std::make_shared(); + instance.CachePixelMap(uniqueId, pixel); + pixelMap[uniqueId] = pixel; + } + for (const auto& pair : pixelMap) { + EXPECT_EQ(pair.second, instance.GetPixelMapCache(pair.first)); + } + + GTEST_LOG_(INFO) << "RSImageCacheTest CachePixelMap002 start"; +} + +/** + * @tc.name: ModifyPixelMapCacheRefCount001 + * @tc.desc: Verify the ReleasePixelMapCache + * @tc.type:FUNC + */ +HWTEST_F(RSImageCacheTest, ModifyPixelMapCacheRefCount001, TestSize.Level1) { + GTEST_LOG_(INFO) << "RSImageCacheTest ModifyPixelMapCacheRefCount001 start"; + + auto& instance = RSImageCache::Instance(); + const uint64_t ADDED_ID = 500; + auto pixel = std::make_shared(); + instance.CachePixelMap(ADDED_ID, pixel); + EXPECT_EQ(instance.GetPixelMapCache(ADDED_ID), pixel); + instance.IncreasePixelMapCacheRefCount(ADDED_ID); + instance.ReleasePixelMapCache(ADDED_ID); + EXPECT_EQ(instance.GetPixelMapCache(ADDED_ID), nullptr); + + GTEST_LOG_(INFO) << "RSImageCacheTest ModifyPixelMapCacheRefCount001 start"; +} + +/** + * @tc.name: ModifyPixelMapCacheRefCount001 + * @tc.desc: Verify the ReleasePixelMapCache && IncreasePixelMapCacheRefCount + * @tc.type:FUNC + */ +HWTEST_F(RSImageCacheTest, ModifyPixelMapCacheRefCount002, TestSize.Level1) { + GTEST_LOG_(INFO) << "RSImageCacheTest ModifyPixelMapCacheRefCount002 start"; + + auto& instance = RSImageCache::Instance(); + const uint64_t ADDED_ID = 600; + auto pixel = std::make_shared(); + instance.CachePixelMap(ADDED_ID, pixel); + for (uint64_t count = 0;count < 10;count++) { + instance.IncreasePixelMapCacheRefCount(ADDED_ID); + } + for (uint64_t count = 0;count < 9;count++) { + instance.ReleasePixelMapCache(ADDED_ID); + EXPECT_NE(instance.GetPixelMapCache(ADDED_ID), nullptr); + } + instance.ReleasePixelMapCache(ADDED_ID); + EXPECT_EQ(instance.GetPixelMapCache(ADDED_ID), nullptr); + + GTEST_LOG_(INFO) << "RSImageCacheTest ModifyPixelMapCacheRefCount002 start"; +} + +/** + * @tc.name: RenderDrawingImageByPixelMapId001 + * @tc.desc: Verify CacheRenderDrawingImageByPixelMapId && GetRenderDrawingImageCacheByPixelMapId + * @tc.type:FUNC + */ +HWTEST_F(RSImageCacheTest, RenderDrawingImageByPixelMapId001, TestSize.Level1) { + GTEST_LOG_(INFO) << "RSImageCacheTest RenderDrawingImageByPixelMapId001 start"; + + auto& instance = RSImageCache::Instance(); + auto img = std::make_shared(); + const uint64_t ADDED_ID = 700; + const pid_t P_ID = 1000; + instance.CacheRenderDrawingImageByPixelMapId(ADDED_ID, img, P_ID); + EXPECT_EQ(img, instance.GetRenderDrawingImageCacheByPixelMapId(ADDED_ID, P_ID)); + + const uint64_t P_ID1 = 1001; + EXPECT_EQ(nullptr, instance.GetRenderDrawingImageCacheByPixelMapId(ADDED_ID, P_ID1)); + + const uint64_t ADDED_ID1 = 701; + EXPECT_EQ(nullptr, instance.GetRenderDrawingImageCacheByPixelMapId(ADDED_ID1, P_ID)); + + GTEST_LOG_(INFO) << "RSImageCacheTest RenderDrawingImageByPixelMapId001 start"; +} + +/** + * @tc.name: RenderDrawingImageByPixelMapId002 + * @tc.desc: Verify ReleaseDrawingImageCacheByPixelMapId + * @tc.type:FUNC + */ +HWTEST_F(RSImageCacheTest, RenderDrawingImageByPixelMapId002, TestSize.Level1) { + GTEST_LOG_(INFO) << "RSImageCacheTest RenderDrawingImageByPixelMapId002 start"; + + auto& instance = RSImageCache::Instance(); + auto img = std::make_shared(); + auto pixel = std::make_shared(); + const uint64_t ADDED_ID = 800; + const pid_t P_ID = 2000; + + instance.CachePixelMap(ADDED_ID, pixel); + instance.CacheRenderDrawingImageByPixelMapId(ADDED_ID, img, P_ID); + instance.IncreasePixelMapCacheRefCount(ADDED_ID); + instance.ReleasePixelMapCache(ADDED_ID); + EXPECT_EQ(nullptr, instance.GetPixelMapCache(ADDED_ID)); + EXPECT_EQ(nullptr, instance.GetRenderDrawingImageCacheByPixelMapId(ADDED_ID, P_ID)); + + GTEST_LOG_(INFO) << "RSImageCacheTest RenderDrawingImageByPixelMapId002 start"; +} +} +} From 821aad724796406ee95fa9a502e511babe9afacf Mon Sep 17 00:00:00 2001 From: chuchengcheng Date: Fri, 28 Jun 2024 14:30:04 +0800 Subject: [PATCH 086/247] fix canvasDrawing playback problem Signed-off-by: chuchengcheng Change-Id: I7236487576647184254b0450955563d92b0a7fb0 --- .../rs_canvas_drawing_render_node_drawable.cpp | 18 +++--------------- .../drawable/rs_render_node_drawable_adapter.h | 2 +- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/rosen/modules/render_service/core/drawable/rs_canvas_drawing_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_canvas_drawing_render_node_drawable.cpp index 0fb04a443d..dcdfc19a6c 100644 --- a/rosen/modules/render_service/core/drawable/rs_canvas_drawing_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_canvas_drawing_render_node_drawable.cpp @@ -166,6 +166,7 @@ void RSCanvasDrawingRenderNodeDrawable::OnCapture(Drawing::Canvas& canvas) void RSCanvasDrawingRenderNodeDrawable::PlaybackInCorrespondThread() { + auto canvasDrawingPtr = std::static_pointer_cast(shared_from_this()); { // check params, if params is invalid, do not post the task std::lock_guard lockTask(taskMutex_); @@ -174,31 +175,18 @@ void RSCanvasDrawingRenderNodeDrawable::PlaybackInCorrespondThread() } } - auto nodeId = nodeId_; - auto ctx = RSUniRenderThread::Instance().GetRSRenderThreadParams()->GetContext(); auto rect = GetRenderParams()->GetBounds(); - auto task = [this, rect, nodeId, ctx]() { + auto canvasDrawingParams = static_cast(GetRenderParams().get()); + auto task = [this, canvasDrawingPtr, canvasDrawingParams, rect]() { std::lock_guard lockTask(taskMutex_); if (!surface_ || !canvas_) { return; } - auto renderNode = renderNode_.lock(); - if (renderNode == nullptr) { - return; - } - auto nodeSp = std::const_pointer_cast(renderNode); - auto canvasDrawingNode = std::static_pointer_cast(nodeSp); - if (canvasDrawingNode == nullptr) { - return; - } - auto canvasDrawingParams = - static_cast(canvasDrawingNode->GetRenderParams().get()); if (canvasDrawingParams->GetCanvasDrawingSurfaceChanged()) { return; } DrawContent(*canvas_, rect); canvasDrawingParams->SetNeedProcess(false); - canvasDrawingNode->SetDrawCmdListsVisited(true); }; RSTaskDispatcher::GetInstance().PostTask(threadId_, task, false); } diff --git a/rosen/modules/render_service_base/include/drawable/rs_render_node_drawable_adapter.h b/rosen/modules/render_service_base/include/drawable/rs_render_node_drawable_adapter.h index de8c32a8ab..e3b1299e08 100644 --- a/rosen/modules/render_service_base/include/drawable/rs_render_node_drawable_adapter.h +++ b/rosen/modules/render_service_base/include/drawable/rs_render_node_drawable_adapter.h @@ -59,7 +59,7 @@ enum class SkipType : uint8_t { SKIP_BACKGROUND_COLOR = 2 }; -class RSB_EXPORT RSRenderNodeDrawableAdapter { +class RSB_EXPORT RSRenderNodeDrawableAdapter : public std::enable_shared_from_this { public: explicit RSRenderNodeDrawableAdapter(std::shared_ptr&& node); virtual ~RSRenderNodeDrawableAdapter() = default; From 80ddc38f4fc361516e6599c0556722fd3ac3caf4 Mon Sep 17 00:00:00 2001 From: ltxmlSN Date: Thu, 27 Jun 2024 11:07:46 +0800 Subject: [PATCH 087/247] =?UTF-8?q?=E6=B2=A1=E6=9C=89=E6=94=B6=E5=88=B0?= =?UTF-8?q?=E4=BB=BB=E4=BD=95=E5=8C=85=E5=90=8D=E6=97=B6=EF=BC=8C=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E7=AD=96=E7=95=A5=E4=BB=8D=E7=84=B6=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ltxmlSN --- .../frame_rate_manager/hgm_multi_app_strategy.cpp | 12 ++---------- .../frame_rate_manager/hgm_task_handle_thread.h | 1 + .../core/frame_rate_manager/hgm_touch_manager.cpp | 13 +++++++++++-- .../core/frame_rate_manager/hgm_touch_manager.h | 3 +-- .../unittest/hgm_frame_rate_manager_test.cpp | 1 + 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_multi_app_strategy.cpp b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_multi_app_strategy.cpp index 852addad35..ee3f4a79ca 100644 --- a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_multi_app_strategy.cpp +++ b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_multi_app_strategy.cpp @@ -204,13 +204,9 @@ HgmErrCode HgmMultiAppStrategy::GetScreenSettingMode(PolicyConfigData::StrategyC HgmErrCode HgmMultiAppStrategy::GetFocusAppStrategyConfig(PolicyConfigData::StrategyConfig& strategyRes) { - if (pkgs_.empty()) { - return HGM_ERROR; - } - auto &strategyConfigs = GetStrategyConfigs(); - auto [pkgName, pid, appType] = AnalyzePkgParam(pkgs_.front()); + auto [pkgName, pid, appType] = AnalyzePkgParam(pkgs_.empty() ? "" : pkgs_.front()); auto strategyName = GetAppStrategyConfigName(pkgName); if (strategyName != NULL_STRATEGY_CONFIG_NAME && strategyConfigs.find(strategyName) != strategyConfigs.end()) { strategyRes = strategyConfigs.at(strategyName); @@ -275,13 +271,9 @@ void HgmMultiAppStrategy::UseStrategyNum() void HgmMultiAppStrategy::FollowFocus() { - if (pkgs_.empty()) { - return; - } - auto &strategyConfigs = GetStrategyConfigs(); - auto [pkgName, pid, appType] = AnalyzePkgParam(pkgs_.front()); + auto [pkgName, pid, appType] = AnalyzePkgParam(pkgs_.empty() ? "" : pkgs_.front()); auto strategyName = GetAppStrategyConfigName(pkgName); RS_TRACE_NAME_FMT("[FollowFocus] strategyName:%s", strategyName.c_str()); if (strategyName != NULL_STRATEGY_CONFIG_NAME && strategyConfigs.find(strategyName) != strategyConfigs.end()) { diff --git a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_task_handle_thread.h b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_task_handle_thread.h index 3b06300816..c7b14afed7 100644 --- a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_task_handle_thread.h +++ b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_task_handle_thread.h @@ -22,6 +22,7 @@ namespace OHOS::Rosen { class HgmTaskHandleThread { public: static HgmTaskHandleThread& Instance(); + const std::shared_ptr& GetRunner() const { return runner_; } void PostTask(const std::function& task, int64_t delayTime = 0); bool PostSyncTask(const std::function& task); diff --git a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_touch_manager.cpp b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_touch_manager.cpp index 34ba1ea31f..06fab44417 100644 --- a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_touch_manager.cpp +++ b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_touch_manager.cpp @@ -27,7 +27,6 @@ namespace { } HgmTouchManager::HgmTouchManager() : HgmStateMachine(TouchState::IDLE_STATE), - runner_(AppExecFwk::EventRunner::Create("TouchMachine")), upTimeoutTimer_("up_timeout_timer", std::chrono::milliseconds(UP_TIMEOUT_MS), nullptr, [this] () { OnEvent(TouchEvent::UP_TIMEOUT_EVENT); }), @@ -35,7 +34,10 @@ HgmTouchManager::HgmTouchManager() : HgmStateMachine(Tou OnEvent(TouchEvent::RS_IDLE_TIMEOUT_EVENT); }) { - handler_ = std::make_shared(runner_); + const auto& runner = HgmTaskHandleThread::Instance().GetRunner(); + if (runner != nullptr) { + handler_ = std::make_shared(runner); + } RegisterEventCallback(TouchEvent::UP_EVENT, [this] (TouchEvent event) { ChangeState(TouchState::UP_STATE); }); @@ -57,6 +59,13 @@ HgmTouchManager::HgmTouchManager() : HgmStateMachine(Tou }); } +HgmTouchManager::~HgmTouchManager() +{ + if (handler_ != nullptr) { + handler_->RemoveAllEvents(); + } +} + void HgmTouchManager::HandleTouchEvent(TouchEvent event, const std::string& pkgName) { pkgName_ = pkgName; diff --git a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_touch_manager.h b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_touch_manager.h index a02c090fc9..a9146a3ba1 100644 --- a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_touch_manager.h +++ b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_touch_manager.h @@ -39,7 +39,7 @@ class HgmFrameRateManager; class HgmTouchManager final : public HgmStateMachine { public: HgmTouchManager(); - ~HgmTouchManager() override = default; + ~HgmTouchManager() override; void HandleTouchEvent(TouchEvent event, const std::string& pkgName = ""); void HandleRsFrame(); @@ -52,7 +52,6 @@ protected: void ExecuteCallback(const std::function& callback) override; private: std::string pkgName_; - std::shared_ptr runner_ = nullptr; std::shared_ptr handler_ = nullptr; HgmOneShotTimer upTimeoutTimer_; HgmOneShotTimer rsIdleTimeoutTimer_; diff --git a/rosen/test/hyper_graphic_manager/unittest/hgm_frame_rate_manager_test.cpp b/rosen/test/hyper_graphic_manager/unittest/hgm_frame_rate_manager_test.cpp index 92b49202e3..2f9252a224 100644 --- a/rosen/test/hyper_graphic_manager/unittest/hgm_frame_rate_manager_test.cpp +++ b/rosen/test/hyper_graphic_manager/unittest/hgm_frame_rate_manager_test.cpp @@ -153,6 +153,7 @@ HWTEST_F(HgmFrameRateMgrTest, HgmOneShotTimerTest001, Function | SmallTest | Lev testThread.join(); } } + sleep(1); // wait for handler task finished } } // namespace Rosen } // namespace OHOS \ No newline at end of file From 21e874c876412853a84ebfdd6b2695aab7619b83 Mon Sep 17 00:00:00 2001 From: LeesonWong Date: Fri, 28 Jun 2024 15:20:41 +0800 Subject: [PATCH 088/247] Test cases for rs_image_cache.cpp Signed-off-by: w30027672 --- .../modules/render_service_base/src/render/rs_image_cache.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rosen/modules/render_service_base/src/render/rs_image_cache.cpp b/rosen/modules/render_service_base/src/render/rs_image_cache.cpp index c1445c99e5..5e194c82b6 100644 --- a/rosen/modules/render_service_base/src/render/rs_image_cache.cpp +++ b/rosen/modules/render_service_base/src/render/rs_image_cache.cpp @@ -60,7 +60,7 @@ void RSImageCache::ReleaseDrawingImageCache(uint64_t uniqueId) auto it = drawingImageCache_.find(uniqueId); if (it != drawingImageCache_.end()) { it->second.second--; - if (it->second.first == nullptr || it->second.second <= 0) { + if (it->second.first == nullptr || it->second.second == 0) { drawingImageCache_.erase(it); } } @@ -102,7 +102,7 @@ void RSImageCache::ReleasePixelMapCache(uint64_t uniqueId) auto it = pixelMapCache_.find(uniqueId); if (it != pixelMapCache_.end()) { it->second.second--; - if (it->second.first == nullptr || it->second.second <= 0) { + if (it->second.first == nullptr || it->second.second == 0) { pixelMap = it->second.first; pixelMapCache_.erase(it); ReleaseDrawingImageCacheByPixelMapId(uniqueId); From a52d00ce1a4015ea4f72098828968f975d21f9c9 Mon Sep 17 00:00:00 2001 From: LeesonWong Date: Fri, 28 Jun 2024 15:59:05 +0800 Subject: [PATCH 089/247] Test cases for rs_image_cache.cpp Signed-off-by: w30027672 --- rosen/modules/render_service_base/test/unittest/render/BUILD.gn | 2 -- 1 file changed, 2 deletions(-) diff --git a/rosen/modules/render_service_base/test/unittest/render/BUILD.gn b/rosen/modules/render_service_base/test/unittest/render/BUILD.gn index 5342cf0aed..fd6bdb3239 100644 --- a/rosen/modules/render_service_base/test/unittest/render/BUILD.gn +++ b/rosen/modules/render_service_base/test/unittest/render/BUILD.gn @@ -12,8 +12,6 @@ # limitations under the License. import("//build/test.gni") -import( -"//foundation/graphic/graphic_2d/rosen/modules/render_service_client/render_service_client.gni") module_output_path = "graphic_2d/rosen/modules/render_service_base" From 7861c78ee75e9fad574c4961c3d0d02da5e1fd28 Mon Sep 17 00:00:00 2001 From: LeesonWong Date: Fri, 28 Jun 2024 16:30:49 +0800 Subject: [PATCH 090/247] Test cases for rs_image_cache.cpp Signed-off-by: w30027672 --- .../render_service_base/test/unittest/render/BUILD.gn | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rosen/modules/render_service_base/test/unittest/render/BUILD.gn b/rosen/modules/render_service_base/test/unittest/render/BUILD.gn index fd6bdb3239..e6913c3e35 100644 --- a/rosen/modules/render_service_base/test/unittest/render/BUILD.gn +++ b/rosen/modules/render_service_base/test/unittest/render/BUILD.gn @@ -26,8 +26,8 @@ ohos_unittest("RSRenderTest") { deps = [ "../../../../render_service_base:render_service_base_src", - "//foundation/window/window_manager/wm:libwm", - "//third_party/googletest:gtest_main", + "../../../../../../../../../foundation/window/window_manager/wm:libwm", + "../../../../../../../../../third_party/googletest:gtest_main", ] external_deps = [ @@ -43,8 +43,8 @@ ohos_unittest("RSRenderTest") { config("rs_render_test_config") { visibility = [ ":*" ] include_dirs = [ - "//foundation/window/window_manager/interfaces/innerkits", - "//foundation/graphic/graphic_2d/rosen/modules/render_service_base", + "../../../../../../../../../foundation/window/window_manager/interfaces/innerkits", + "../../../../../../../../../foundation/graphic/graphic_2d/rosen/modules/render_service_base", ] cflags = [ From f430e11a358274ef0ed0080212f2eec6a3c03409 Mon Sep 17 00:00:00 2001 From: lishijie Date: Fri, 28 Jun 2024 16:20:53 +0800 Subject: [PATCH 091/247] zhan'gi Signed-off-by: lishijie Change-Id: I18a473b62206ce1aa286f53f4bfe25588224b813 --- .../render_service_client/core/pipeline/rs_render_thread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/modules/render_service_client/core/pipeline/rs_render_thread.cpp b/rosen/modules/render_service_client/core/pipeline/rs_render_thread.cpp index 58420a3588..081bf6e833 100644 --- a/rosen/modules/render_service_client/core/pipeline/rs_render_thread.cpp +++ b/rosen/modules/render_service_client/core/pipeline/rs_render_thread.cpp @@ -165,7 +165,7 @@ void RSRenderThread::Start() running_.store(true); std::unique_lock cmdLock(rtMutex_); if (thread_ == nullptr) { - thread_ = std::make_unique(&RSRenderThread::RenderLoop, this); + thread_ = std::make_unique([this] { this->RSRenderThread::RenderLoop(); }); } } From 9b7ee07f5403b34a3ac73f32dede5f594f3c479f Mon Sep 17 00:00:00 2001 From: chenqinxin Date: Fri, 28 Jun 2024 15:40:17 +0800 Subject: [PATCH 092/247] bugfix render node drawable build from texture Signed-off-by: chenqinxin Change-Id: I99518d6a0b5a7876a1475c114d57be810eba9135 --- .../core/drawable/rs_render_node_drawable.cpp | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/rosen/modules/render_service/core/drawable/rs_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_render_node_drawable.cpp index 9beb495e78..99bebb991a 100644 --- a/rosen/modules/render_service/core/drawable/rs_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_render_node_drawable.cpp @@ -413,17 +413,37 @@ std::shared_ptr RSRenderNodeDrawable::GetCachedImage(RSPaintFilt if (cachedImage_->IsValid(canvas.GetGPUContext().get())) { return cachedImage_; } +#ifdef RS_ENABLE_GL + if (OHOS::Rosen::RSSystemProperties::GetGpuApiType() != OHOS::Rosen::GpuApiType::VULKAN && + OHOS::Rosen::RSSystemProperties::GetGpuApiType() != OHOS::Rosen::GpuApiType::DDGR) { + Drawing::TextureOrigin origin = Drawing::TextureOrigin::BOTTOM_LEFT; + Drawing::BitmapFormat info = Drawing::BitmapFormat{cachedImage_->GetColorType(), cachedImage_->GetAlphaType()}; + SharedTextureContext* sharedContext = new SharedTextureContext(cachedImage_); // will move image + cachedImage_ = std::make_shared(); + bool ret = cachedImage_->BuildFromTexture(*canvas.GetGPUContext(), cachedBackendTexture_.GetTextureInfo(), + origin, info, nullptr, DeleteSharedTextureContext, sharedContext); + if (!ret) { + RS_LOGE("RSRenderNodeDrawable::GetCachedImage image BuildFromTexture failed"); + return nullptr; + } + } +#endif -#if defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK) - Drawing::TextureOrigin origin = Drawing::TextureOrigin::BOTTOM_LEFT; - Drawing::BitmapFormat info = Drawing::BitmapFormat { cachedImage_->GetColorType(), cachedImage_->GetAlphaType() }; - SharedTextureContext* sharedContext = new SharedTextureContext(cachedImage_); // will move image - cachedImage_ = std::make_shared(); - bool ret = cachedImage_->BuildFromTexture(*canvas.GetGPUContext(), cachedBackendTexture_.GetTextureInfo(), - origin, info, nullptr, DeleteSharedTextureContext, sharedContext); - if (!ret) { - RS_LOGE("RSRenderNodeDrawable::GetCachedImage image BuildFromTexture failed"); - return nullptr; +#ifdef RS_ENABLE_VK + if (OHOS::Rosen::RSSystemProperties::GetGpuApiType() == OHOS::Rosen::GpuApiType::VULKAN || + OHOS::Rosen::RSSystemProperties::GetGpuApiType() == OHOS::Rosen::GpuApiType::DDGR) { + if (vulkanCleanupHelper_ == nullptr) { + return nullptr; + } + Drawing::TextureOrigin origin = Drawing::TextureOrigin::BOTTOM_LEFT; + Drawing::BitmapFormat info = Drawing::BitmapFormat{cachedImage_->GetColorType(), cachedImage_->GetAlphaType()}; + cachedImage_ = std::make_shared(); + bool ret = cachedImage_->BuildFromTexture(*canvas.GetGPUContext(), cachedBackendTexture_.GetTextureInfo(), + origin, info, nullptr, NativeBufferUtils::DeleteVkImage, vulkanCleanupHelper_->Ref()); + if (!ret) { + RS_LOGE("RSRenderNodeDrawable::GetCachedImage image BuildFromTexture failed"); + return nullptr; + } } #endif return cachedImage_; From a02c5c39590b54834f7633c23c8048001e737192 Mon Sep 17 00:00:00 2001 From: zhangbirong Date: Fri, 28 Jun 2024 16:14:26 +0800 Subject: [PATCH 093/247] add rs tdd Signed-off-by: zhangbirong --- .../unittest/rs_frame_report_test.cpp | 73 ++++++++++++++++--- 1 file changed, 64 insertions(+), 9 deletions(-) diff --git a/rosen/test/frame_report/unittest/rs_frame_report_test.cpp b/rosen/test/frame_report/unittest/rs_frame_report_test.cpp index e5034744db..33538a42d8 100644 --- a/rosen/test/frame_report/unittest/rs_frame_report_test.cpp +++ b/rosen/test/frame_report/unittest/rs_frame_report_test.cpp @@ -44,8 +44,14 @@ void RsFrameReportTest::TearDown() {} */ HWTEST_F(RsFrameReportTest, GetEnable001, TestSize.Level1) { - RsFrameReport::GetInstance().LoadLibrary(); - RsFrameReport::GetInstance().GetEnable(); + RsFrameReport& fr = RsFrameReport::GetInstance(); + fr.LoadLibrary(); + fr.CloseLibrary(); + fr.GetEnable(); + fr.LoadLibrary(); + fr.GetEnable(); + fr.GetEnable(); + fr.CloseLibrary(); } /** @@ -56,7 +62,13 @@ HWTEST_F(RsFrameReportTest, GetEnable001, TestSize.Level1) */ HWTEST_F(RsFrameReportTest, ProcessCommandsStart001, TestSize.Level1) { - RsFrameReport::GetInstance().ProcessCommandsStart(); + RsFrameReport& fr = RsFrameReport::GetInstance(); + fr.LoadLibrary(); + EXPECT_TRUE(fr.frameSchedSoLoaded_); + EXPECT_EQ(fr.processCommandsStartFun_, nullptr); + fr.ProcessCommandsStart(); + EXPECT_NE(fr.processCommandsStartFun_, nullptr); + fr.ProcessCommandsStart(); } /** @@ -67,7 +79,11 @@ HWTEST_F(RsFrameReportTest, ProcessCommandsStart001, TestSize.Level1) */ HWTEST_F(RsFrameReportTest, AnimateStart001, TestSize.Level1) { - RsFrameReport::GetInstance().AnimateStart(); + RsFrameReport& fr = RsFrameReport::GetInstance(); + EXPECT_EQ(fr.animateStartFunc_, nullptr); + fr.AnimateStart(); + EXPECT_NE(fr.animateStartFunc_, nullptr); + fr.AnimateStart(); } /** @@ -78,10 +94,14 @@ HWTEST_F(RsFrameReportTest, AnimateStart001, TestSize.Level1) */ HWTEST_F(RsFrameReportTest, RenderStart001, TestSize.Level1) { + RsFrameReport& fr = RsFrameReport::GetInstance(); + EXPECT_EQ(fr.renderStartFunc_, nullptr); uint64_t timestamp = static_cast( std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()).count()); - RsFrameReport::GetInstance().RenderStart(timestamp); + fr.RenderStart(timestamp); + EXPECT_NE(fr.renderStartFunc_, nullptr); + fr.RenderStart(timestamp); } /** @@ -92,7 +112,11 @@ HWTEST_F(RsFrameReportTest, RenderStart001, TestSize.Level1) */ HWTEST_F(RsFrameReportTest, RSRenderStart001, TestSize.Level1) { - RsFrameReport::GetInstance().RSRenderStart(); + RsFrameReport& fr = RsFrameReport::GetInstance(); + EXPECT_EQ(fr.parallelRenderStartFunc_, nullptr); + fr.RSRenderStart(); + EXPECT_NE(fr.parallelRenderStartFunc_, nullptr); + fr.RSRenderStart(); } /** @@ -103,7 +127,11 @@ HWTEST_F(RsFrameReportTest, RSRenderStart001, TestSize.Level1) */ HWTEST_F(RsFrameReportTest, RenderEnd001, TestSize.Level1) { - RsFrameReport::GetInstance().RenderEnd(); + RsFrameReport& fr = RsFrameReport::GetInstance(); + EXPECT_EQ(fr.renderEndFunc_, nullptr); + fr.RenderEnd(); + EXPECT_NE(fr.renderEndFunc_, nullptr); + fr.RenderEnd(); } /** @@ -114,7 +142,11 @@ HWTEST_F(RsFrameReportTest, RenderEnd001, TestSize.Level1) */ HWTEST_F(RsFrameReportTest, RSRenderEnd001, TestSize.Level1) { - RsFrameReport::GetInstance().RSRenderEnd(); + RsFrameReport& fr = RsFrameReport::GetInstance(); + EXPECT_EQ(fr.parallelRenderEndFunc_, nullptr); + fr.RSRenderEnd(); + EXPECT_NE(fr.parallelRenderEndFunc_, nullptr); + fr.RSRenderEnd(); } /** @@ -125,7 +157,11 @@ HWTEST_F(RsFrameReportTest, RSRenderEnd001, TestSize.Level1) */ HWTEST_F(RsFrameReportTest, SendCommandsStart001, TestSize.Level1) { - RsFrameReport::GetInstance().SendCommandsStart(); + RsFrameReport& fr = RsFrameReport::GetInstance(); + EXPECT_EQ(fr.sendCommandsStartFunc_, nullptr); + fr.SendCommandsStart(); + EXPECT_NE(fr.sendCommandsStartFunc_, nullptr); + fr.SendCommandsStart(); } /** @@ -137,6 +173,7 @@ HWTEST_F(RsFrameReportTest, SendCommandsStart001, TestSize.Level1) HWTEST_F(RsFrameReportTest, SetFrameParam001, TestSize.Level1) { RsFrameReport::GetInstance().SetFrameParam(0, 0, 0, 0); + RsFrameReport::GetInstance().SetFrameParam(1, 1, 1, 1); } /** @@ -152,5 +189,23 @@ HWTEST_F(RsFrameReportTest, LoadLibrary001, TestSize.Level1) fr.LoadLibrary(); fr.CloseLibrary(); } + +/** + * @tc.name: LoadSymbol001 + * @tc.desc: test + * @tc.type:FUNC + * @tc.require: + */ +HWTEST_F(RsFrameReportTest, LoadSymbol001, TestSize.Level1) +{ + RsFrameReport& fr = RsFrameReport::GetInstance(); + fr.CloseLibrary(); + EXPECT_FALSE(fr.frameSchedSoLoaded_); + fr.LoadSymbol("function"); + fr.LoadLibrary(); + EXPECT_TRUE(fr.frameSchedSoLoaded_); + fr.LoadSymbol("function"); + fr.CloseLibrary(); +} } // namespace Rosen } // namespace OHOS From adfd18094cc700ca2fc89d96fed96a4a0b457806 Mon Sep 17 00:00:00 2001 From: lw19901203 Date: Wed, 26 Jun 2024 11:02:46 +0800 Subject: [PATCH 094/247] add c++ fuzz test LW002 Signed-off-by: lw19901203 --- rosen/test/2d_graphics/fuzztest/draw/BUILD.gn | 4 +- .../fuzztest/draw/canvas_fuzzer/BUILD.gn | 59 ++++++ .../draw/canvas_fuzzer/canvas_fuzzer.cpp | 67 +++++++ .../draw/canvas_fuzzer/canvas_fuzzer.h | 25 +++ .../fuzztest/draw/canvas_fuzzer/corpus/init | 14 ++ .../fuzztest/draw/canvas_fuzzer/project.xml | 25 +++ .../fuzztest/draw/paint_fuzzer/BUILD.gn | 59 ++++++ .../fuzztest/draw/paint_fuzzer/corpus/init | 14 ++ .../draw/paint_fuzzer/paint_fuzzer.cpp | 170 ++++++++++++++++++ .../fuzztest/draw/paint_fuzzer/paint_fuzzer.h | 21 +++ .../fuzztest/draw/paint_fuzzer/project.xml | 25 +++ 11 files changed, 482 insertions(+), 1 deletion(-) create mode 100755 rosen/test/2d_graphics/fuzztest/draw/canvas_fuzzer/BUILD.gn create mode 100755 rosen/test/2d_graphics/fuzztest/draw/canvas_fuzzer/canvas_fuzzer.cpp create mode 100755 rosen/test/2d_graphics/fuzztest/draw/canvas_fuzzer/canvas_fuzzer.h create mode 100755 rosen/test/2d_graphics/fuzztest/draw/canvas_fuzzer/corpus/init create mode 100755 rosen/test/2d_graphics/fuzztest/draw/canvas_fuzzer/project.xml create mode 100755 rosen/test/2d_graphics/fuzztest/draw/paint_fuzzer/BUILD.gn create mode 100755 rosen/test/2d_graphics/fuzztest/draw/paint_fuzzer/corpus/init create mode 100755 rosen/test/2d_graphics/fuzztest/draw/paint_fuzzer/paint_fuzzer.cpp create mode 100755 rosen/test/2d_graphics/fuzztest/draw/paint_fuzzer/paint_fuzzer.h create mode 100755 rosen/test/2d_graphics/fuzztest/draw/paint_fuzzer/project.xml diff --git a/rosen/test/2d_graphics/fuzztest/draw/BUILD.gn b/rosen/test/2d_graphics/fuzztest/draw/BUILD.gn index 5fbceb109e..e5083f922d 100644 --- a/rosen/test/2d_graphics/fuzztest/draw/BUILD.gn +++ b/rosen/test/2d_graphics/fuzztest/draw/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. +# Copyright (c) 2022-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 @@ -16,11 +16,13 @@ group("fuzztest") { deps = [ "brush_fuzzer:fuzztest", + "canvas_fuzzer:fuzztest", "color_fuzzer:fuzztest", "colorfilter_fuzzer:fuzztest", "colorspace_fuzzer:fuzztest", "hmsymbol_fuzzer:fuzztest", "imagefilter_fuzzer:fuzztest", + "paint_fuzzer:fuzztest", "path_fuzzer:fuzztest", "pen_fuzzer:fuzztest", "rsxform_fuzzer:fuzztest", diff --git a/rosen/test/2d_graphics/fuzztest/draw/canvas_fuzzer/BUILD.gn b/rosen/test/2d_graphics/fuzztest/draw/canvas_fuzzer/BUILD.gn new file mode 100755 index 0000000000..3a5919c26c --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/draw/canvas_fuzzer/BUILD.gn @@ -0,0 +1,59 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +module_output_path = "graphic_2d/graphic_2d" + +##############################fuzztest########################################## +ohos_fuzztest("CanvasFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "../../../../../test/2d_graphics/fuzztest/draw/canvas_fuzzer" + + sources = [ + "canvas_fuzzer.cpp", + "get_object.h", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + include_dirs = [ + "../../../../../modules/2d_graphics/include", + "../../../../../modules/2d_graphics/src", + "../../../../../test/2d_graphics/fuzztest", + ] + + deps = [ "../../../../../modules/2d_graphics:2d_graphics" ] + + part_name = "graphic_2d" + subsystem_name = "graphic" +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + + deps += [ + # deps file + ":CanvasFuzzTest", + ] +} +############################################################################### diff --git a/rosen/test/2d_graphics/fuzztest/draw/canvas_fuzzer/canvas_fuzzer.cpp b/rosen/test/2d_graphics/fuzztest/draw/canvas_fuzzer/canvas_fuzzer.cpp new file mode 100755 index 0000000000..b8c93b0290 --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/draw/canvas_fuzzer/canvas_fuzzer.cpp @@ -0,0 +1,67 @@ +/* + * 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 "canvas_fuzzer.h" +#include +#include +#include "get_object.h" +#include "draw/canvas.h" + +namespace OHOS { +namespace Rosen { +namespace Drawing { + +bool CanvasFuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + Canvas canvas; + uint32_t count = GetObject(); + bool flag = GetObject(); + canvas.AddCanvas(&canvas); + canvas.RemoveAll(); + canvas.RestoreToCount(count); + canvas.GetRecordingState(); + canvas.SetRecordingState(flag); + std::shared_ptr cCanvas; + OverDrawCanvas overDrawCanvas = OverDrawCanvas(cCanvas); + overDrawCanvas.GetDrawingType(); + int32_t width = GetObject(); + int32_t height = GetObject(); + NoDrawCanvas noDrawCanvas = NoDrawCanvas(width, height); + noDrawCanvas.GetDrawingType(); + bool doSave = GetObject(); + AutoCanvasRestore(canvas, doSave); + return true; +} + +} // namespace Drawing +} // namespace Rosen +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::Rosen::Drawing::CanvasFuzzTest(data, size); + return 0; +} diff --git a/rosen/test/2d_graphics/fuzztest/draw/canvas_fuzzer/canvas_fuzzer.h b/rosen/test/2d_graphics/fuzztest/draw/canvas_fuzzer/canvas_fuzzer.h new file mode 100755 index 0000000000..be0c645904 --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/draw/canvas_fuzzer/canvas_fuzzer.h @@ -0,0 +1,25 @@ +/* + * 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 TEST_FUZZTEST_CANVAS_FUZZER_H +#define TEST_FUZZTEST_CANVAS_FUZZER_H + +#include +#include +#include +#include + +#define FUZZ_PROJECT_NAME "canvas_fuzzer" + +#endif // TEST_FUZZTEST_CANVAS_FUZZER_H \ No newline at end of file diff --git a/rosen/test/2d_graphics/fuzztest/draw/canvas_fuzzer/corpus/init b/rosen/test/2d_graphics/fuzztest/draw/canvas_fuzzer/corpus/init new file mode 100755 index 0000000000..e7c3fecd8d --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/draw/canvas_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# 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. + +FUZZ \ No newline at end of file diff --git a/rosen/test/2d_graphics/fuzztest/draw/canvas_fuzzer/project.xml b/rosen/test/2d_graphics/fuzztest/draw/canvas_fuzzer/project.xml new file mode 100755 index 0000000000..7133b2b924 --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/draw/canvas_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/rosen/test/2d_graphics/fuzztest/draw/paint_fuzzer/BUILD.gn b/rosen/test/2d_graphics/fuzztest/draw/paint_fuzzer/BUILD.gn new file mode 100755 index 0000000000..994e574157 --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/draw/paint_fuzzer/BUILD.gn @@ -0,0 +1,59 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +module_output_path = "graphic_2d/graphic_2d" + +##############################fuzztest########################################## +ohos_fuzztest("PaintFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "../../../../../test/2d_graphics/fuzztest/draw/paint_fuzzer" + + sources = [ + "get_object.h", + "paint_fuzzer.cpp", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + include_dirs = [ + "../../../../../modules/2d_graphics/include", + "../../../../../modules/2d_graphics/src", + "../../../../../test/2d_graphics/fuzztest", + ] + + deps = [ "../../../../../modules/2d_graphics:2d_graphics" ] + + part_name = "graphic_2d" + subsystem_name = "graphic" +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + + deps += [ + # deps file + ":PaintFuzzTest", + ] +} +############################################################################### diff --git a/rosen/test/2d_graphics/fuzztest/draw/paint_fuzzer/corpus/init b/rosen/test/2d_graphics/fuzztest/draw/paint_fuzzer/corpus/init new file mode 100755 index 0000000000..7e96755ef6 --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/draw/paint_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# 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. + +FUZZ \ No newline at end of file diff --git a/rosen/test/2d_graphics/fuzztest/draw/paint_fuzzer/paint_fuzzer.cpp b/rosen/test/2d_graphics/fuzztest/draw/paint_fuzzer/paint_fuzzer.cpp new file mode 100755 index 0000000000..00392534f2 --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/draw/paint_fuzzer/paint_fuzzer.cpp @@ -0,0 +1,170 @@ +/* + * 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 "paint_fuzzer.h" + +#include +#include +#include + +#include "draw/paint.h" +#include "draw/brush.h" +#include "draw/pen.h" +#include "effect/filter.h" +#include "get_object.h" +#include "utils/rect.h" + +namespace OHOS { +namespace Rosen { +namespace Drawing { +bool PaintFuzzTest001(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + Paint paint = Paint(); + Paint paintCopy = Paint(paint); + Color color; + std::shared_ptr colorSpace = ColorSpace::CreateSRGB(); + Paint paintColor = Paint(color, colorSpace); + Paint::CanCombinePaint(paint, paintCopy); + Brush brush; + paint.AttachBrush(brush); + Pen pen; + paint.AttachPen(pen); + + uint32_t style = GetObject(); + paint.SetStyle(static_cast(style)); + paint.GetStyle(); + paint.IsValid(); + paint.HasStrokeStyle(); + + paint.SetColor(color); + int a = GetObject(); + int r = GetObject(); + int g = GetObject(); + int b = GetObject(); + paint.SetARGB(a, r, g, b); + Color4f cf; + paint.SetColor(cf, colorSpace); + paint.GetColor(); + paint.GetColor4f(); + paint.GetColorSpace(); + + paint.SetAlpha(a); + scalar f = GetObject(); + paint.SetAlphaF(f); + paint.GetAlpha(); + paint.GetAlphaF(); + + scalar width = GetObject(); + paint.SetWidth(width); + paint.GetWidth(); + scalar limit = GetObject(); + paint.SetMiterLimit(limit); + paint.GetMiterLimit(); + return true; +} + +bool PaintFuzzTest002(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + Paint paint = Paint(); + uint32_t style = GetObject(); + paint.SetCapStyle(static_cast(style)); + paint.GetCapStyle(); + paint.SetJoinStyle(static_cast(style)); + paint.GetJoinStyle(); + uint32_t mode = GetObject(); + paint.SetBlendMode(static_cast(mode)); + paint.GetBlendMode(); + Filter filter; + paint.SetFilter(filter); + paint.GetFilter(); + paint.HasFilter(); + ColorQuad color = GetObject(); + std::shared_ptr shaderEffect = ShaderEffect::CreateColorShader(color); + paint.SetShaderEffect(shaderEffect); + paint.GetShaderEffect(); + scalar radius = GetObject(); + std::shared_ptr pathEffect = PathEffect::CreateCornerPathEffect(radius); + paint.SetPathEffect(pathEffect); + paint.GetPathEffect(); + + std::shared_ptr blender = Blender::CreateWithBlendMode(static_cast(mode)); + paint.SetBlender(blender); + paint.GetBlender(); + float blurRadius = GetObject(); + scalar dx = GetObject(); + scalar dy = GetObject(); + std::shared_ptr blurDrawLooper = BlurDrawLooper::CreateBlurDrawLooper(blurRadius, dx, dy, color); + paint.SetLooper(blurDrawLooper); + paint.GetLooper(); + return true; +} + +bool PaintFuzzTest003(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + Paint paint = Paint(); + bool aa = GetObject(); + bool hdrImage = GetObject(); + paint.SetAntiAlias(aa); + paint.IsAntiAlias(); + paint.SetHDRImage(hdrImage); + paint.IsHDRImage(); + paint.Reset(); + paint.Disable(); + Paint paintCopy = Paint(paint); + if (paint == paintCopy) {} + if (paint != paintCopy) {} + return true; +} + +} // namespace Drawing +} // namespace Rosen +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::Rosen::Drawing::PaintFuzzTest001(data, size); + OHOS::Rosen::Drawing::PaintFuzzTest002(data, size); + OHOS::Rosen::Drawing::PaintFuzzTest003(data, size); + return 0; +} \ No newline at end of file diff --git a/rosen/test/2d_graphics/fuzztest/draw/paint_fuzzer/paint_fuzzer.h b/rosen/test/2d_graphics/fuzztest/draw/paint_fuzzer/paint_fuzzer.h new file mode 100755 index 0000000000..6ff44dae0b --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/draw/paint_fuzzer/paint_fuzzer.h @@ -0,0 +1,21 @@ +/* + * 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 TEST_FUZZTEST_PAINT_FUZZER_H +#define TEST_FUZZTEST_PAINT_FUZZER_H + +#define FUZZ_PROJECT_NAME "paint_fuzzer" + +#endif // TEST_FUZZTEST_PAINT_FUZZER_H \ No newline at end of file diff --git a/rosen/test/2d_graphics/fuzztest/draw/paint_fuzzer/project.xml b/rosen/test/2d_graphics/fuzztest/draw/paint_fuzzer/project.xml new file mode 100755 index 0000000000..7133b2b924 --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/draw/paint_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + From 17b0696cefb0c4bc032432757d3a97dbef5df38b Mon Sep 17 00:00:00 2001 From: shuking Date: Fri, 28 Jun 2024 17:51:27 +0800 Subject: [PATCH 095/247] fix crash offscreen and uifirst conflict Signed-off-by: shuking --- .../skia_adapter/skia_surface.cpp | 31 +++++++++++++++++++ .../skia_adapter/skia_surface.h | 3 +- .../rs_surface_render_node_drawable.cpp | 3 +- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_surface.cpp b/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_surface.cpp index 3f3cd633a3..b68388732c 100644 --- a/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_surface.cpp +++ b/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_surface.cpp @@ -59,6 +59,37 @@ SkSurface::BackendHandleAccess ConvertToSkiaBackendAccess(BackendAccess access) SkiaSurface::SkiaSurface() {} +void SkiaSurface::PostSkSurfaceToTargetThread() +{ + auto canvas = GetCanvas(); + if (canvas == nullptr) { + return; + } + auto ctx = canvas->GetGPUContext(); + if (ctx == nullptr) { + return; + } + auto skctx = ctx->GetImpl(); + if (skctx == nullptr) { + return; + } + auto grctx = skctx->GetGrContext(); + if (grctx == nullptr) { + return; + } + auto func = SkiaGPUContext::GetPostFunc(grctx); + if (func) { + auto skSurface = skSurface_; + auto skImage = skImage_; + func([skSurface, skImage]() {}); + } +} + +SkiaSurface::~SkiaSurface() +{ + PostSkSurfaceToTargetThread(); +} + bool SkiaSurface::Bind(const Bitmap& bitmap) { const auto &skBitmap = bitmap.GetImpl()->ExportSkiaBitmap(); diff --git a/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_surface.h b/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_surface.h index ad5f5e7da6..faafba30f3 100644 --- a/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_surface.h +++ b/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_surface.h @@ -29,7 +29,7 @@ public: static inline constexpr AdapterType TYPE = AdapterType::SKIA_ADAPTER; SkiaSurface(); - ~SkiaSurface() override = default; + ~SkiaSurface() override; AdapterType GetType() const override { @@ -71,6 +71,7 @@ public: int Width() const override; int Height() const override; private: + void PostSkSurfaceToTargetThread(); sk_sp skSurface_ = nullptr; sk_sp skImage_ = nullptr; }; diff --git a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp index 4f2eb210e5..2c36aec8e1 100644 --- a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp @@ -323,7 +323,8 @@ void RSSurfaceRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) // Draw base pipeline start RSAutoCanvasRestore acr(rscanvas, RSPaintFilterCanvas::SaveType::kCanvasAndAlpha); bool needOffscreen = surfaceParams->GetNeedOffscreen() && !rscanvas->GetTotalMatrix().IsIdentity() && - surfaceParams->IsAppWindow() && surfaceNode->GetName().substr(0, 3) != "SCB" && !IsHardwareEnabled(); + surfaceParams->IsAppWindow() && surfaceNode->GetName().substr(0, 3) != "SCB" && !IsHardwareEnabled() && + gettid() == RSUniRenderThread::Instance().GetTid(); curCanvas_ = rscanvas; if (needOffscreen) { releaseCount_ = 0; From efe45483fbaea748fd29dbc5a20ccb869e13515f Mon Sep 17 00:00:00 2001 From: Liu Yongwei Date: Fri, 28 Jun 2024 19:41:33 +0800 Subject: [PATCH 096/247] =?UTF-8?q?=E8=A1=A5=E5=85=85RSSurfaceRendernodeDr?= =?UTF-8?q?awable=20tdd=E7=94=A8=E4=BE=8B=20Signed-off-by:=20samuel789=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rs_surface_render_node_drawable_test.cpp | 257 +++++++++++++++++- 1 file changed, 255 insertions(+), 2 deletions(-) diff --git a/rosen/test/render_service/render_service/unittest/drawable/rs_surface_render_node_drawable_test.cpp b/rosen/test/render_service/render_service/unittest/drawable/rs_surface_render_node_drawable_test.cpp index 0448c2e72f..72e5eb051e 100644 --- a/rosen/test/render_service/render_service/unittest/drawable/rs_surface_render_node_drawable_test.cpp +++ b/rosen/test/render_service/render_service/unittest/drawable/rs_surface_render_node_drawable_test.cpp @@ -125,8 +125,10 @@ HWTEST_F(RSSurfaceRenderNodeDrawableTest, CacheImgForCapture, TestSize.Level1) RSDisplayNodeConfig config; NodeId displayId = 1; auto displayNode = std::make_shared(displayId, config); - - surfaceDrawable_->CacheImgForCapture(*canvas_, displayNode); + std::shared_ptr surface = Drawing::Surface::MakeRasterN32Premul(100, 100); + ASSERT_NE(surface, nullptr); + RSPaintFilterCanvas paintFilterCanvas(surface.get()); + surfaceDrawable_->CacheImgForCapture(paintFilterCanvas, displayNode); } /** @@ -248,4 +250,255 @@ HWTEST_F(RSSurfaceRenderNodeDrawableTest, CaptureSurface002, TestSize.Level1) surfaceParams->isProtectedLayer_ = true; surfaceDrawable_->CaptureSurface(*renderNode_, *canvas_, *surfaceParams); } + +/** + * @tc.name: PrepareOffscreenRender + * @tc.desc: Test PrepareOffscreenRender + * @tc.type: FUNC + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, CheckIfNeedResetRotate, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + Drawing::Canvas canvas; + RSPaintFilterCanvas paintFilterCanvas(&canvas); + ASSERT_FALSE(surfaceDrawable_->CheckIfNeedResetRotate(paintFilterCanvas)); +} + +/** + * @tc.name: CalculateVisibleRegion + * @tc.desc: Test CalculateVisibleRegion + * @tc.type: FUNC + * @tc.require: #IA940V + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, CalculateVisibleRegion, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + auto surfaceParams = static_cast(drawable_->renderParams_.get()); + ASSERT_NE(surfaceParams, nullptr); + auto uniParams = std::make_shared(); + + surfaceParams->isMainWindowType_ = false; + surfaceParams->isLeashWindow_ = true; + surfaceParams->isAppWindow_ = false; + Drawing::Region result = surfaceDrawable_->CalculateVisibleRegion(uniParams.get(), + surfaceParams, renderNode_, true); + ASSERT_TRUE(result.IsEmpty()); + + surfaceParams->isMainWindowType_ = true; + surfaceParams->isLeashWindow_ = false; + surfaceParams->isAppWindow_ = false; + result = surfaceDrawable_->CalculateVisibleRegion(uniParams.get(), surfaceParams, renderNode_, true); + ASSERT_FALSE(result.IsEmpty()); + + uniParams->SetOcclusionEnabled(true); + Occlusion::Region region; + surfaceParams->SetVisibleRegion(region); + result = surfaceDrawable_->CalculateVisibleRegion(uniParams.get(), surfaceParams, renderNode_, false); + ASSERT_TRUE(result.IsEmpty()); +} + +/** + * @tc.name: PrepareOffscreenRender + * @tc.desc: Test PrepareOffscreenRender + * @tc.type: FUNC + * @tc.require: #IA940V + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, PrepareOffscreenRender, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + std::shared_ptr surface = Drawing::Surface::MakeRasterN32Premul(100, 100); + ASSERT_NE(surface, nullptr); + RSPaintFilterCanvas paintFilterCanvas(surface.get()); + surfaceDrawable_->curCanvas_ = &paintFilterCanvas; + ASSERT_TRUE(surfaceDrawable_->PrepareOffscreenRender()); +} + +/** + * @tc.name: FinishOffscreenRender + * @tc.desc: Test FinishOffscreenRender + * @tc.type: FUNC + * @tc.require: #IA940V + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, FinishOffscreenRender, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + Drawing::SamplingOptions samping; + surfaceDrawable_->FinishOffscreenRender(samping); + Drawing::Canvas canvas; + RSPaintFilterCanvas backupCanvas(&canvas); + surfaceDrawable_->canvasBackup_ = &backupCanvas; + + Drawing::Canvas canvas2; + RSPaintFilterCanvas curCanvas(&canvas2); + surfaceDrawable_->curCanvas_ = &curCanvas; + surfaceDrawable_->curCanvas_->Save(); + surfaceDrawable_->offscreenSurface_ = Drawing::Surface::MakeRasterN32Premul(100, 100); + surfaceDrawable_->FinishOffscreenRender(samping); + ASSERT_NE(surfaceDrawable_->curCanvas_, nullptr); +} + +/** + * @tc.name: DrawUIFirstDfx + * @tc.desc: Test DrawUIFirstDfx + * @tc.type: FUNC + * @tc.require: #IA940V + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, DrawUIFirstDfx, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + Drawing::Canvas canvas; + RSPaintFilterCanvas paintFilterCanvas(&canvas); + + auto surfaceParams = static_cast(drawable_->renderParams_.get()); + ASSERT_NE(surfaceParams, nullptr); + + surfaceDrawable_->DrawUIFirstDfx(paintFilterCanvas, MultiThreadCacheType::ARKTS_CARD, *surfaceParams, true); + surfaceDrawable_->DrawUIFirstDfx(paintFilterCanvas, MultiThreadCacheType::LEASH_WINDOW, *surfaceParams, true); + surfaceDrawable_->DrawUIFirstDfx(paintFilterCanvas, MultiThreadCacheType::LEASH_WINDOW, *surfaceParams, false); +} + +/** + * @tc.name: GetSurfaceRenderNode + * @tc.desc: Test GetSurfaceRenderNode + * @tc.type: FUNC + * @tc.require: #IA940V + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, GetSurfaceRenderNode, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + ASSERT_NE(surfaceDrawable_->GetSurfaceRenderNode(), nullptr); + + surfaceDrawable_->renderNode_ = std::weak_ptr(); + ASSERT_EQ(surfaceDrawable_->GetSurfaceRenderNode(), nullptr); +} + +/** + * @tc.name: GetVisibleDirtyRegion + * @tc.desc: Test GetVisibleDirtyRegion + * @tc.type: FUNC + * @tc.require: #IA940V + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, GetVisibleDirtyRegion, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + ASSERT_NE(surfaceDrawable_->GetSurfaceRenderNode(), nullptr); + + Occlusion::Region region(Occlusion::Rect{0, 0, 100, 100}); + surfaceDrawable_->SetVisibleDirtyRegion(region); + ASSERT_FALSE(surfaceDrawable_->GetVisibleDirtyRegion().IsEmpty()); + + surfaceDrawable_->renderNode_ = std::weak_ptr(); + ASSERT_TRUE(surfaceDrawable_->GetVisibleDirtyRegion().IsEmpty()); +} + +/** + * @tc.name: SetVisibleDirtyRegion + * @tc.desc: Test SetVisibleDirtyRegion + * @tc.type: FUNC + * @tc.require: #IA940V + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, SetVisibleDirtyRegion, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + ASSERT_NE(surfaceDrawable_->GetSurfaceRenderNode(), nullptr); + + Occlusion::Region region(Occlusion::Rect{0, 0, 100, 100}); + surfaceDrawable_->SetVisibleDirtyRegion(region); + ASSERT_FALSE(surfaceDrawable_->GetVisibleDirtyRegion().IsEmpty()); + + surfaceDrawable_->renderNode_ = std::weak_ptr(); + surfaceDrawable_->SetVisibleDirtyRegion(region); +} + +/** + * @tc.name: SetAlignedVisibleDirtyRegion + * @tc.desc: Test SetAlignedVisibleDirtyRegion + * @tc.type: FUNC + * @tc.require: #IA940V + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, SetAlignedVisibleDirtyRegion, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + ASSERT_NE(surfaceDrawable_->GetSurfaceRenderNode(), nullptr); + + Occlusion::Region region(Occlusion::Rect{0, 0, 100, 100}); + surfaceDrawable_->SetAlignedVisibleDirtyRegion(region); + ASSERT_FALSE(surfaceDrawable_->GetSurfaceRenderNode()->GetAlignedVisibleDirtyRegion().IsEmpty()); + + surfaceDrawable_->renderNode_ = std::weak_ptr(); + surfaceDrawable_->SetAlignedVisibleDirtyRegion(region); +} + +/** + * @tc.name: SetGlobalDirtyRegion + * @tc.desc: Test SetGlobalDirtyRegion + * @tc.type: FUNC + * @tc.require: #IA940V + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, SetGlobalDirtyRegion, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + ASSERT_NE(surfaceDrawable_->GetSurfaceRenderNode(), nullptr); + + RectI rect; + surfaceDrawable_->SetGlobalDirtyRegion(rect, true); + + surfaceDrawable_->renderNode_ = std::weak_ptr(); + surfaceDrawable_->SetGlobalDirtyRegion(rect); +} + +/** + * @tc.name: SetDirtyRegionAlignedEnable + * @tc.desc: Test SetDirtyRegionAlignedEnable + * @tc.type: FUNC + * @tc.require: #IA940V + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, SetDirtyRegionAlignedEnable, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + ASSERT_NE(surfaceDrawable_->GetSurfaceRenderNode(), nullptr); + + surfaceDrawable_->SetDirtyRegionAlignedEnable(true); + ASSERT_TRUE(surfaceDrawable_->GetSurfaceRenderNode()->isDirtyRegionAlignedEnable_); + + surfaceDrawable_->SetDirtyRegionAlignedEnable(false); + ASSERT_FALSE(surfaceDrawable_->GetSurfaceRenderNode()->isDirtyRegionAlignedEnable_); + + surfaceDrawable_->renderNode_ = std::weak_ptr(); + surfaceDrawable_->SetDirtyRegionAlignedEnable(true); +} + +/** + * @tc.name: SetDirtyRegionBelowCurrentLayer + * @tc.desc: Test SetDirtyRegionBelowCurrentLayer + * @tc.type: FUNC + * @tc.require: #IA940V + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, SetDirtyRegionBelowCurrentLayer, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + ASSERT_NE(surfaceDrawable_->GetSurfaceRenderNode(), nullptr); + + Occlusion::Region region; + surfaceDrawable_->SetDirtyRegionBelowCurrentLayer(region); + + surfaceDrawable_->renderNode_ = std::weak_ptr(); + surfaceDrawable_->SetDirtyRegionBelowCurrentLayer(region); +} + +/** + * @tc.name: GetSyncDirtyManager + * @tc.desc: Test GetSyncDirtyManager + * @tc.type: FUNC + * @tc.require: #IA940V + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, GetSyncDirtyManager, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + ASSERT_NE(surfaceDrawable_->GetSurfaceRenderNode(), nullptr); + + surfaceDrawable_->renderNode_ = std::weak_ptr(); + surfaceDrawable_->GetSyncDirtyManager(); + ASSERT_EQ(surfaceDrawable_->GetSurfaceRenderNode(), nullptr); +} } From a43fe997730f628e343590fbfacebf9939302af8 Mon Sep 17 00:00:00 2001 From: s30023221 Date: Fri, 28 Jun 2024 16:01:02 +0800 Subject: [PATCH 097/247] draw rrect in subthread when use dma Signed-off-by: s30023221 Change-Id: I2937ea52d56795fb7dcfb1669e7e5d18bb7b2bc6 --- .../rs_dma_buffer_surface_render_node_drawable.cpp | 7 +++++++ .../core/drawable/rs_surface_render_node_drawable.cpp | 8 ++------ .../core/drawable/rs_surface_render_node_drawable.h | 1 + .../drawable/rs_ui_first_surface_render_node_drawable.cpp | 7 ------- .../core/pipeline/parallel_render/rs_sub_thread.cpp | 1 + .../core/pipeline/rs_uni_render_visitor.cpp | 6 ------ 6 files changed, 11 insertions(+), 19 deletions(-) diff --git a/rosen/modules/render_service/core/drawable/rs_dma_buffer_surface_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_dma_buffer_surface_render_node_drawable.cpp index 97ccce84e5..fbf0cbdea7 100644 --- a/rosen/modules/render_service/core/drawable/rs_dma_buffer_surface_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_dma_buffer_surface_render_node_drawable.cpp @@ -177,6 +177,13 @@ void RSSurfaceRenderNodeDrawable::DrawDmaBufferWithGPU(RSPaintFilterCanvas& canv RSBaseRenderUtil::ReleaseBuffer(surfaceHandler); } +void RSSurfaceRenderNodeDrawable::ClipRoundRect(Drawing::Canvas& canvas) +{ + const auto& uifirstParams = static_cast(GetUifirstRenderParams().get()); + RRect rrect = uifirstParams ? uifirstParams->GetRRect() : RRect(); + canvas.ClipRoundRect(RSPropertiesPainter::RRect2DrawingRRect(rrect), Drawing::ClipOp::INTERSECT, true); +} + void RSSurfaceRenderNodeDrawable::ClearBufferQueue() { if (surface_ != nullptr) { diff --git a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp index 4f2eb210e5..66414a9165 100644 --- a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp @@ -735,9 +735,7 @@ bool RSSurfaceRenderNodeDrawable::DealWithUIFirstCache(RSSurfaceRenderNode& surf canvas.ConcatMatrix(surfaceParams.GetMatrix()); } bool useDmaBuffer = UseDmaBuffer(); - if (!useDmaBuffer) { - DrawBackground(canvas, bounds); - } + DrawBackground(canvas, bounds); bool drawCacheSuccess = true; if (surfaceParams.GetUifirstUseStarting() != INVALID_NODEID) { drawCacheSuccess = DrawUIFirstCacheWithStarting(canvas, surfaceParams.GetUifirstUseStarting()); @@ -751,9 +749,7 @@ bool RSSurfaceRenderNodeDrawable::DealWithUIFirstCache(RSSurfaceRenderNode& surf RS_TRACE_NAME_FMT("[%s] reuse failed!", name_.c_str()); RS_LOGE("DrawUIFirstCache failed!"); } - if (!useDmaBuffer) { - DrawForeground(canvas, bounds); - } + DrawForeground(canvas, bounds); if (uniParams.GetUIFirstDebugEnabled()) { DrawUIFirstDfx(canvas, enableType, surfaceParams, drawCacheSuccess); } diff --git a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.h b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.h index fdd97ab27e..e9487f6713 100644 --- a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.h +++ b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.h @@ -54,6 +54,7 @@ public: bool EnableRecordingOptimization(RSRenderParams& params); void SubDraw(Drawing::Canvas& canvas); + void ClipRoundRect(Drawing::Canvas& canvas); void UpdateCacheSurface(); void SetCacheSurfaceProcessedStatus(CacheProcessStatus cacheProcessStatus); diff --git a/rosen/modules/render_service/core/drawable/rs_ui_first_surface_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_ui_first_surface_render_node_drawable.cpp index 876ca06199..e059d921d7 100644 --- a/rosen/modules/render_service/core/drawable/rs_ui_first_surface_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_ui_first_surface_render_node_drawable.cpp @@ -531,19 +531,12 @@ void RSSurfaceRenderNodeDrawable::SubDraw(Drawing::Canvas& canvas) return; } Drawing::Rect bounds = uifirstParams ? uifirstParams->GetBounds() : Drawing::Rect(0, 0, 0, 0); - bool useDmaBuffer = UseDmaBuffer(); - if (useDmaBuffer) { - DrawBackground(canvas, bounds); - } auto parentSurfaceMatrix = RSRenderParams::GetParentSurfaceMatrix(); RSRenderParams::SetParentSurfaceMatrix(rscanvas->GetTotalMatrix()); RSRenderNodeDrawable::DrawUifirstContentChildren(*rscanvas, bounds); RSRenderParams::SetParentSurfaceMatrix(parentSurfaceMatrix); - if (useDmaBuffer) { - DrawForeground(canvas, bounds); - } } bool RSSurfaceRenderNodeDrawable::DrawUIFirstCache(RSPaintFilterCanvas& rscanvas, bool canSkipWait) diff --git a/rosen/modules/render_service/core/pipeline/parallel_render/rs_sub_thread.cpp b/rosen/modules/render_service/core/pipeline/parallel_render/rs_sub_thread.cpp index b1317b1124..d185db84b6 100644 --- a/rosen/modules/render_service/core/pipeline/parallel_render/rs_sub_thread.cpp +++ b/rosen/modules/render_service/core/pipeline/parallel_render/rs_sub_thread.cpp @@ -386,6 +386,7 @@ void RSSubThread::DrawableCacheWithDma(DrawableV2::RSSurfaceRenderNodeDrawable* rsCanvas->SetParallelThreadIdx(threadIndex_); rsCanvas->SetHDRPresent(nodeDrawable->GetHDRPresent()); rsCanvas->SetBrightnessRatio(nodeDrawable->GetBrightnessRatio()); + nodeDrawable->ClipRoundRect(*rsCanvas); rsCanvas->Clear(Drawing::Color::COLOR_TRANSPARENT); nodeDrawable->SubDraw(*rsCanvas); diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp index dddc59c7ba..76f2374d16 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp @@ -2137,12 +2137,6 @@ void RSUniRenderVisitor::UpdateSurfaceDirtyAndGlobalDirty() [this, &accumulatedDirtyRegion, &hasMainAndLeashSurfaceDirty](RSBaseRenderNode::SharedPtr& nodePtr) { auto surfaceNode = RSBaseRenderNode::ReinterpretCast(nodePtr); auto dirtyManager = surfaceNode->GetDirtyManager(); - if (surfaceNode->GetLastFrameUifirstFlag() == MultiThreadCacheType::LEASH_WINDOW && - !surfaceNode->IsHardwareForcedDisabled() && dirtyManager && - !surfaceNode->IsHardwareForcedDisabled() == surfaceNode->GetIsLastFrameHwcEnabled()) { - dirtyManager->Clear(); - return; - } RSMainThread::Instance()->GetContext().AddPendingSyncNode(nodePtr); // 0. update hwc node dirty region and create layer UpdateHwcNodeDirtyRegionAndCreateLayer(surfaceNode); From e2fdd7167fadaea3dc7d726072593d8756aba55b Mon Sep 17 00:00:00 2001 From: dreamond_wxy Date: Thu, 27 Jun 2024 20:56:44 +0800 Subject: [PATCH 098/247] fix virtual screen remove window conflict with occlusion Signed-off-by: dreamond_wxy --- .../core/pipeline/rs_uni_render_visitor.cpp | 4 +++- .../render_service/core/pipeline/rs_uni_render_visitor.h | 2 +- .../core/screen_manager/rs_screen_manager.cpp | 8 ++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp index dddc59c7ba..98f5a23b37 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp @@ -1427,7 +1427,9 @@ void RSUniRenderVisitor::CalculateOcclusion(RSSurfaceRenderNode& node) // check current surface Participate In Occlusion if (node.CheckParticipateInOcclusion()) { accumulatedOcclusionRegion_.OrSelf(node.GetOpaqueRegion()); - if (IsValidInVirtualScreen(node)) { + auto blackList = screenManager_->GetVirtualScreenBlackList(curDisplayNode_->GetScreenId()); + bool hasBlackList = !blackList.empty() && (blackList.find(node.GetId()) != blackList.end()); + if (IsValidInVirtualScreen(node) && !hasBlackList) { occlusionRegionWithoutSkipLayer_.OrSelf(node.GetOpaqueRegion()); } } diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.h b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.h index 1af6a4af59..0659ab87f8 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.h +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.h @@ -415,7 +415,7 @@ private: } bool IsValidInVirtualScreen(RSSurfaceRenderNode& node) const { - return !node.GetSkipLayer() && (screenInfo_.filteredAppSet.empty() || + return !node.GetSkipLayer() && !node.GetSecurityLayer() && (screenInfo_.filteredAppSet.empty() || screenInfo_.filteredAppSet.find(node.GetId()) != screenInfo_.filteredAppSet.end()); } void UpdateRotationStatusForEffectNode(RSEffectRenderNode& node); diff --git a/rosen/modules/render_service/core/screen_manager/rs_screen_manager.cpp b/rosen/modules/render_service/core/screen_manager/rs_screen_manager.cpp index bb6b490b1d..7c076bb6ab 100644 --- a/rosen/modules/render_service/core/screen_manager/rs_screen_manager.cpp +++ b/rosen/modules/render_service/core/screen_manager/rs_screen_manager.cpp @@ -886,6 +886,14 @@ int32_t RSScreenManager::SetVirtualScreenBlackList(ScreenId id, std::vectorSetBlackList(screenBlackList); + ScreenId mainId = GetDefaultScreenId(); + if (mainId != id) { + if (screens_.find(mainId) == screens_.end()) { + RS_LOGW("RSScreenManager %{public}s: There is no screen for main id %{public}" PRIu64 ".", __func__, mainId); + return SCREEN_NOT_FOUND; + } + screens_.at(mainId)->SetBlackList(screenBlackList); + } return SUCCESS; } From 46d6e6ee51ec227376c4cf9546468196984004af Mon Sep 17 00:00:00 2001 From: LeesonWong Date: Sat, 29 Jun 2024 10:33:53 +0800 Subject: [PATCH 099/247] Test cases for rs_image_cache.cpp Signed-off-by: w30027672 --- .../test/unittest/BUILD.gn | 2 +- .../test/unittest/render/BUILD.gn | 63 +++++++++---------- 2 files changed, 31 insertions(+), 34 deletions(-) diff --git a/rosen/modules/render_service_base/test/unittest/BUILD.gn b/rosen/modules/render_service_base/test/unittest/BUILD.gn index 25c9c59f56..95456c5213 100644 --- a/rosen/modules/render_service_base/test/unittest/BUILD.gn +++ b/rosen/modules/render_service_base/test/unittest/BUILD.gn @@ -19,5 +19,5 @@ group("unittest") { deps = [ "animation:RSRenderAnimationTest", "render:RSRenderTest", - ] + ] } diff --git a/rosen/modules/render_service_base/test/unittest/render/BUILD.gn b/rosen/modules/render_service_base/test/unittest/render/BUILD.gn index e6913c3e35..a1b22fa4ec 100644 --- a/rosen/modules/render_service_base/test/unittest/render/BUILD.gn +++ b/rosen/modules/render_service_base/test/unittest/render/BUILD.gn @@ -12,51 +12,48 @@ # limitations under the License. import("//build/test.gni") +import("//foundation/graphic/graphic_2d/graphic_config.gni") -module_output_path = "graphic_2d/rosen/modules/render_service_base" +third_party_path = "//third_party" ohos_unittest("RSRenderTest") { - module_out_path = module_output_path + sources = [ "rs_image_cache_test.cpp" ] - sources = [ - "rs_image_cache_test.cpp", - ] + configs = [ ":rs_render_test_config" ] - configs = [ ":rs_render_test_config" ] + deps = [ + "$graphic_2d_root/rosen/modules/render_service_base:render_service_base_src", + "$window_base_path/wm:libwm", + "$third_party_path/googletest:gtest_main", + ] - deps = [ - "../../../../render_service_base:render_service_base_src", - "../../../../../../../../../foundation/window/window_manager/wm:libwm", - "../../../../../../../../../third_party/googletest:gtest_main", - ] + external_deps = [ + "eventhandler:libeventhandler", + "graphic_surface:surface", + "hilog:libhilog", + "image_framework:image_native", + ] - external_deps = [ - "eventhandler:libeventhandler", - "graphic_surface:surface", - "hilog:libhilog", - "image_framework:image_native", - ] - - subsystem_name = "graphic" + subsystem_name = "graphic" } config("rs_render_test_config") { - visibility = [ ":*" ] - include_dirs = [ - "../../../../../../../../../foundation/window/window_manager/interfaces/innerkits", - "../../../../../../../../../foundation/graphic/graphic_2d/rosen/modules/render_service_base", - ] + visibility = [ ":*" ] + include_dirs = [ + "$window_base_path/interfaces/innerkits", + "$graphic_2d_root/rosen/modules/render_service_base", + ] - cflags = [ - "-Wall", - "-Werror", - "-g3", - "-Dprivate=public", - "-Dprotected=public", - ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + "-Dprotected=public", + ] } group("unittest") { - testonly = true - deps = [ ":RSRenderTest" ] + testonly = true + deps = [ ":RSRenderTest" ] } From 4993407328960c099d03ba780a8e211eb5d0e53f Mon Sep 17 00:00:00 2001 From: zzvscx Date: Sat, 29 Jun 2024 10:34:52 +0800 Subject: [PATCH 100/247] =?UTF-8?q?hgm=E6=A8=A1=E5=9D=97log|trace=E6=95=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zzvscx Change-Id: Ia33930ade6bd87e10d03b2d04ee85e77094b7603 --- .../frame_rate_manager/hgm_frame_rate_manager.cpp | 12 ++++++++---- .../frame_rate_manager/hgm_multi_app_strategy.cpp | 2 +- .../core/hgm_screen_manager/hgm_screen.cpp | 8 ++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.cpp b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.cpp index 9845328b5f..612138e987 100644 --- a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.cpp +++ b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.cpp @@ -409,7 +409,8 @@ bool HgmFrameRateManager::CollectFrameRateChange(FrameRateRange finalRange, RS_TRACE_INT("PreferredFrameRate", static_cast(finalRange.preferred_)); for (auto linker : appFrameRateLinkers) { - auto appFrameRate = GetDrawingFrameRate(currRefreshRate_, linker.second->GetExpectedRange()); + const auto& expectedRange = linker.second->GetExpectedRange(); + auto appFrameRate = GetDrawingFrameRate(currRefreshRate_, expectedRange); if (touchManager_.GetState() != TouchState::IDLE_STATE) { appFrameRate = OLED_NULL_HZ; } @@ -420,10 +421,13 @@ bool HgmFrameRateManager::CollectFrameRateChange(FrameRateRange finalRange, linker.second->GetId(), appFrameRate); frameRateChanged = true; } + if (expectedRange.min_ == OLED_NULL_HZ && expectedRange.max_ == OLED_144_HZ && + expectedRange.preferred_ == OLED_NULL_HZ) { + continue; + } RS_TRACE_NAME_FMT("HgmFrameRateManager::UniProcessData multiAppFrameRate: pid = %d, linkerId = %ld, "\ "appFrameRate = %d, appRange = (%d, %d, %d)", ExtractPid(linker.first), linker.second->GetId(), - appFrameRate, linker.second->GetExpectedRange().min_, linker.second->GetExpectedRange().max_, - linker.second->GetExpectedRange().preferred_); + appFrameRate, expectedRange.min_, expectedRange.max_, expectedRange.preferred_); } return frameRateChanged; } @@ -765,7 +769,7 @@ void HgmFrameRateManager::HandleTouchEvent(pid_t pid, int32_t touchStatus, int32 void HgmFrameRateManager::HandleIdleEvent(bool isIdle) { if (isIdle) { - HGM_LOGI("HandleIdleEvent status:%{public}u", isIdle); + HGM_LOGD("HandleIdleEvent status:%{public}u", isIdle); DeliverRefreshRateVote({"VOTER_IDLE", idleFps_, idleFps_}, ADD_VOTE); } else { DeliverRefreshRateVote({"VOTER_IDLE"}, REMOVE_VOTE); diff --git a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_multi_app_strategy.cpp b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_multi_app_strategy.cpp index 852addad35..7d92441ec4 100644 --- a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_multi_app_strategy.cpp +++ b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_multi_app_strategy.cpp @@ -414,7 +414,7 @@ void HgmMultiAppStrategy::UpdateStrategyByTouch( void HgmMultiAppStrategy::OnStrategyChange() { - HGM_LOGI("multi app strategy change: [%{public}d, %{public}d]", voteRes_.second.min, voteRes_.second.max); + HGM_LOGD("multi app strategy change: [%{public}d, %{public}d]", voteRes_.second.min, voteRes_.second.max); for (const auto &callback : strategyChangeCallbacks_) { if (callback != nullptr) { HgmTaskHandleThread::Instance().PostTask([callback, strategy = voteRes_.second] () { diff --git a/rosen/modules/hyper_graphic_manager/core/hgm_screen_manager/hgm_screen.cpp b/rosen/modules/hyper_graphic_manager/core/hgm_screen_manager/hgm_screen.cpp index 16eded8cc1..00620944d8 100644 --- a/rosen/modules/hyper_graphic_manager/core/hgm_screen_manager/hgm_screen.cpp +++ b/rosen/modules/hyper_graphic_manager/core/hgm_screen_manager/hgm_screen.cpp @@ -110,7 +110,7 @@ int32_t HgmScreen::AddScreenModeInfo(int32_t width, int32_t height, uint32_t rat void HgmScreen::SetActiveModeId(int32_t modeId) { - HGM_LOGI("HgmScreen setting activeModeId to %{public}d", modeId); + HGM_LOGD("HgmScreen setting activeModeId to %{public}d", modeId); activeModeId_ = modeId; } @@ -143,7 +143,7 @@ bool HgmScreen::IfSwitchToRate(int32_t sceneId, uint32_t rate) const } ifSwitch = true; - HGM_LOGI("HgmScreen Set framerate to %{public}u is accepted", rate); + HGM_LOGD("HgmScreen Set framerate to %{public}u is accepted", rate); return ifSwitch; } @@ -162,7 +162,7 @@ int32_t HgmScreen::GetModeIdViaRate(uint32_t rate) const return HGM_ERROR; } - HGM_LOGI("HgmScreen getting a new mode with the resolution of current mode : %{public}d", activeModeId_); + HGM_LOGD("HgmScreen getting a new mode with the resolution of current mode : %{public}d", activeModeId_); int32_t mode = GetModeIdViaResolutionAndRate(profilePtr->GetWidth(), profilePtr->GetHeight(), rate); return mode; } @@ -175,7 +175,7 @@ int32_t HgmScreen::GetModeIdViaResolutionAndRate(int32_t width, int32_t height, continue; } int32_t modeIdFound = mode->GetModeId(); - HGM_LOGI("HgmScreen mode : %{public}d is found for w : %{public}d, h : %{public}d, rate : %{public}u", + HGM_LOGD("HgmScreen mode : %{public}d is found for w : %{public}d, h : %{public}d, rate : %{public}u", modeIdFound, width, height, rate); return modeIdFound; } From 749584620297a8063949934cf98245b63acb6043 Mon Sep 17 00:00:00 2001 From: xxb-wzy Date: Sat, 29 Jun 2024 10:54:41 +0800 Subject: [PATCH 101/247] Signed-off-by: xxb-wzy Change-Id: I5ee69f40dc2ab61a353be6518f83080b67e63284 --- .vscode/settings.json | 7 +++++++ rosen/modules/composer/vsync/include/vsync_distributor.h | 1 + rosen/modules/composer/vsync/src/vsync_distributor.cpp | 8 ++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..cbda2043c9 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "files.associations": { + "chrono": "cpp", + "string": "cpp", + "atomic": "cpp" + } +} \ No newline at end of file diff --git a/rosen/modules/composer/vsync/include/vsync_distributor.h b/rosen/modules/composer/vsync/include/vsync_distributor.h index 508423f682..9e2cac8cc3 100644 --- a/rosen/modules/composer/vsync/include/vsync_distributor.h +++ b/rosen/modules/composer/vsync/include/vsync_distributor.h @@ -190,6 +190,7 @@ private: void UpdateVsyncPeriodAndRefreshRate(); #endif bool isRs_ = false; + std::atomic hasVsync_ = false; }; } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/composer/vsync/src/vsync_distributor.cpp b/rosen/modules/composer/vsync/src/vsync_distributor.cpp index d59aa6c954..b534d3691d 100644 --- a/rosen/modules/composer/vsync/src/vsync_distributor.cpp +++ b/rosen/modules/composer/vsync/src/vsync_distributor.cpp @@ -353,7 +353,10 @@ void VSyncDistributor::WaitForVsyncOrRequest(std::unique_lock &locke if (!isRs_ && IsDVsyncOn()) { con_.wait_for(locker, std::chrono::nanoseconds(dvsync_->WaitTime()), [this] {return dvsync_->WaitCond();}); } else { - con_.wait(locker); + if (!(hasVsync_.load() && isRs_)) { + con_.wait(locker); + } + hasVsync_.store(false); } if (pendingRNVInVsync_) { return; @@ -761,7 +764,7 @@ void VSyncDistributor::PostVSyncEvent(const std::vector> & #endif countTraceValue_ = (countTraceValue_ + 1) % 2; // 2 : change num CountTrace(HITRACE_TAG_GRAPHIC_AGP, "DVSync-" + name_, countTraceValue_); - + hasVsync_.store(false); for (uint32_t i = 0; i < conns.size(); i++) { int64_t period = event_.period; if ((generatorRefreshRate_ > 0) && (conns[i]->refreshRate_ > 0) && @@ -829,6 +832,7 @@ VsyncError VSyncDistributor::RequestNextVSync(const sptr &conne } connection->triggerThisTime_ = true; #if defined(RS_ENABLE_DVSYNC) + hasVsync_.store(true); if (dvsync_->IsFeatureEnabled()) { con_.notify_all(); } else From 00a25597f05519620d02e4426150e28f96e44cf2 Mon Sep 17 00:00:00 2001 From: xxb-wzy Date: Sat, 29 Jun 2024 10:57:57 +0800 Subject: [PATCH 102/247] Signed-off-by: xxb-wzy Change-Id: I684cb2d54aec8124a837a104daa0a6ccc76945dc --- .vscode/settings.json | 70 +++++++++++++++++++ .../vsync/include/vsync_distributor.h | 1 - .../composer/vsync/src/vsync_distributor.cpp | 19 ----- .../composer/vsync/src/vsync_generator.cpp | 3 +- 4 files changed, 71 insertions(+), 22 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..c96db2f2bc --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,70 @@ +{ + "files.associations": { + "any": "cpp", + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "*.tcc": "cpp", + "bitset": "cpp", + "cctype": "cpp", + "chrono": "cpp", + "cinttypes": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "codecvt": "cpp", + "condition_variable": "cpp", + "csignal": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "list": "cpp", + "map": "cpp", + "set": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "optional": "cpp", + "random": "cpp", + "ratio": "cpp", + "regex": "cpp", + "string": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "future": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "mutex": "cpp", + "new": "cpp", + "ostream": "cpp", + "shared_mutex": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "thread": "cpp", + "typeinfo": "cpp", + "valarray": "cpp", + "variant": "cpp" + } +} \ No newline at end of file diff --git a/rosen/modules/composer/vsync/include/vsync_distributor.h b/rosen/modules/composer/vsync/include/vsync_distributor.h index 508423f682..34c8e413cc 100644 --- a/rosen/modules/composer/vsync/include/vsync_distributor.h +++ b/rosen/modules/composer/vsync/include/vsync_distributor.h @@ -187,7 +187,6 @@ private: sptr dvsync_ = nullptr; bool pendingRNVInVsync_ = false; // for vsync switch to dvsync std::atomic lastDVsyncTS_ = 0; // for dvsync switch to vsync - void UpdateVsyncPeriodAndRefreshRate(); #endif bool isRs_ = false; }; diff --git a/rosen/modules/composer/vsync/src/vsync_distributor.cpp b/rosen/modules/composer/vsync/src/vsync_distributor.cpp index d59aa6c954..b415a8558d 100644 --- a/rosen/modules/composer/vsync/src/vsync_distributor.cpp +++ b/rosen/modules/composer/vsync/src/vsync_distributor.cpp @@ -511,10 +511,6 @@ void VSyncDistributor::OnDVSyncTrigger(int64_t now, int64_t period, uint32_t ref vsyncMode_ = vsyncMode; dvsync_->RuntimeSwitch(); if (IsDVsyncOn()) { - if (isRs_ && event_.period != 0 && event_.refreshRate != 0) { - period = event_.period; - refreshRate = event_.refreshRate; - } ScopedBytrace func("VSyncD onVSyncEvent, now:" + std::to_string(now)); } else { ScopedBytrace func("VSync onVSyncEvent, now:" + std::to_string(now)); @@ -741,16 +737,6 @@ void VSyncDistributor::CollectConnectionsLTPO(bool &waitForVSync, int64_t timest } } -#if defined(RS_ENABLE_DVSYNC) -void VSyncDistributor::UpdateVsyncPeriodAndRefreshRate() -{ - std::unique_lock locker(mutex_); - event_.refreshRate = dvsync_->GetImmediateRefreshRate(); - event_.period = dvsync_->GetImmediatePeriod(); - dvsync_->UpdateVsyncPeriodAndRefreshRate(event_.period, event_.refreshRate); -} -#endif - void VSyncDistributor::PostVSyncEvent(const std::vector> &conns, int64_t timestamp) { #if defined(RS_ENABLE_DVSYNC) @@ -768,11 +754,6 @@ void VSyncDistributor::PostVSyncEvent(const std::vector> & (generatorRefreshRate_ % conns[i]->refreshRate_ == 0)) { period = event_.period * static_cast(generatorRefreshRate_ / conns[i]->refreshRate_); } -#if defined(RS_ENABLE_DVSYNC) - if (isRs_) { - UpdateVsyncPeriodAndRefreshRate(); - } -#endif int32_t ret = conns[i]->PostEvent(timestamp, period, event_.vsyncCount); VLOGD("Distributor name:%{public}s, connection name:%{public}s, ret:%{public}d", name_.c_str(), conns[i]->info_.name_.c_str(), ret); diff --git a/rosen/modules/composer/vsync/src/vsync_generator.cpp b/rosen/modules/composer/vsync/src/vsync_generator.cpp index 6f2ae02c07..44954d5adf 100644 --- a/rosen/modules/composer/vsync/src/vsync_generator.cpp +++ b/rosen/modules/composer/vsync/src/vsync_generator.cpp @@ -788,8 +788,7 @@ VsyncError VSyncGenerator::CheckAndUpdateReferenceTime(int64_t hardwareVsyncInte PeriodCheckLocked(hardwareVsyncInterval); - if (rsVSyncDistributor_->IsDVsyncOn() || - ((abs(hardwareVsyncInterval - pendingPeriod_) < PERIOD_CHECK_THRESHOLD) && + if (((abs(hardwareVsyncInterval - pendingPeriod_) < PERIOD_CHECK_THRESHOLD) && (abs(hardwareVsyncInterval - targetPeriod_) < PERIOD_CHECK_THRESHOLD || targetPeriod_ == 0))) { // framerate has changed frameRateChanging_ = false; From 66616241bdc397b52264db51de8d216905a5e22f Mon Sep 17 00:00:00 2001 From: xxb-wzy Date: Sat, 29 Jun 2024 11:02:39 +0800 Subject: [PATCH 103/247] Signed-off-by: xxb-wzy Change-Id: I4f74d2eb5c87943ed92679787ee4759d77374db7 --- .vscode/settings.json | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index cbda2043c9..0000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "files.associations": { - "chrono": "cpp", - "string": "cpp", - "atomic": "cpp" - } -} \ No newline at end of file From 95e148eee0badfa0cd3a12ae1e2b10e1f544e390 Mon Sep 17 00:00:00 2001 From: xxb-wzy Date: Sat, 29 Jun 2024 11:06:33 +0800 Subject: [PATCH 104/247] Signed-off-by: xxb-wzy Change-Id: I98f9e6a459320da4b2b7d658d132109cfcc05be3 --- .vscode/settings.json | 70 ------------------------------------------- 1 file changed, 70 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index c96db2f2bc..0000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "files.associations": { - "any": "cpp", - "array": "cpp", - "atomic": "cpp", - "bit": "cpp", - "*.tcc": "cpp", - "bitset": "cpp", - "cctype": "cpp", - "chrono": "cpp", - "cinttypes": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "codecvt": "cpp", - "condition_variable": "cpp", - "csignal": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "deque": "cpp", - "list": "cpp", - "map": "cpp", - "set": "cpp", - "unordered_map": "cpp", - "unordered_set": "cpp", - "vector": "cpp", - "exception": "cpp", - "algorithm": "cpp", - "functional": "cpp", - "iterator": "cpp", - "memory": "cpp", - "memory_resource": "cpp", - "numeric": "cpp", - "optional": "cpp", - "random": "cpp", - "ratio": "cpp", - "regex": "cpp", - "string": "cpp", - "string_view": "cpp", - "system_error": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "utility": "cpp", - "fstream": "cpp", - "future": "cpp", - "initializer_list": "cpp", - "iomanip": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "istream": "cpp", - "limits": "cpp", - "mutex": "cpp", - "new": "cpp", - "ostream": "cpp", - "shared_mutex": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "streambuf": "cpp", - "thread": "cpp", - "typeinfo": "cpp", - "valarray": "cpp", - "variant": "cpp" - } -} \ No newline at end of file From db821c6c3506a6884c8a877a111cfaaaa4033010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E6=80=9D=E8=BF=9C?= Date: Sat, 29 Jun 2024 11:13:58 +0800 Subject: [PATCH 105/247] =?UTF-8?q?=E6=97=A5=E5=BF=97=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E7=8E=87=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周思远 --- .../render_service_base/src/platform/ohos/rs_jank_stats.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_jank_stats.cpp b/rosen/modules/render_service_base/src/platform/ohos/rs_jank_stats.cpp index 29d3f4a02d..8984be8d61 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_jank_stats.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_jank_stats.cpp @@ -199,7 +199,7 @@ void RSJankStats::SetRSJankStats(bool skipJankStats, uint32_t /* dynamicRefreshR return; } if (rsJankStats_[type] == USHRT_MAX) { - ROSEN_LOGW("RSJankStats::SetJankStats rsJankStats_ value oversteps USHRT_MAX"); + ROSEN_LOGD("RSJankStats::SetJankStats rsJankStats_ value oversteps USHRT_MAX"); return; } if (type == JANK_FRAME_6_FREQ) { From f9041f82861449d385ef46ef7924d57a9c64bb81 Mon Sep 17 00:00:00 2001 From: LeesonWong Date: Sat, 29 Jun 2024 11:15:32 +0800 Subject: [PATCH 106/247] Test cases for rs_image_cache.cpp Signed-off-by: w30027672 --- .../modules/render_service_base/test/unittest/render/BUILD.gn | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rosen/modules/render_service_base/test/unittest/render/BUILD.gn b/rosen/modules/render_service_base/test/unittest/render/BUILD.gn index a1b22fa4ec..acee2749ca 100644 --- a/rosen/modules/render_service_base/test/unittest/render/BUILD.gn +++ b/rosen/modules/render_service_base/test/unittest/render/BUILD.gn @@ -17,6 +17,8 @@ import("//foundation/graphic/graphic_2d/graphic_config.gni") third_party_path = "//third_party" ohos_unittest("RSRenderTest") { + third_path = third_party_path + sources = [ "rs_image_cache_test.cpp" ] configs = [ ":rs_render_test_config" ] @@ -24,7 +26,7 @@ ohos_unittest("RSRenderTest") { deps = [ "$graphic_2d_root/rosen/modules/render_service_base:render_service_base_src", "$window_base_path/wm:libwm", - "$third_party_path/googletest:gtest_main", + "$third_path/googletest:gtest_main", ] external_deps = [ From 91b0c31c3ef1f02b41ba108475562fbcdc637860 Mon Sep 17 00:00:00 2001 From: liuqian71 Date: Sat, 29 Jun 2024 11:17:54 +0800 Subject: [PATCH 107/247] =?UTF-8?q?TDD=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuqian71 --- .../include/ge_magnifier_shader_filter.h | 2 +- .../src/ge_magnifier_shader_filter.cpp | 12 ++++++------ .../unittest/ge_magnifier_shader_filter_test.cpp | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/rosen/modules/graphics_effect/include/ge_magnifier_shader_filter.h b/rosen/modules/graphics_effect/include/ge_magnifier_shader_filter.h index fc2c587d03..44d0208edb 100644 --- a/rosen/modules/graphics_effect/include/ge_magnifier_shader_filter.h +++ b/rosen/modules/graphics_effect/include/ge_magnifier_shader_filter.h @@ -70,7 +70,7 @@ private: void ConvertToRgba(uint32_t rgba, float* color, int tupleSize); std::shared_ptr magnifierPara_ = nullptr; - static std::shared_ptr magnifierShaderEffect_; + static std::shared_ptr g_magnifierShaderEffect; }; } // namespace Rosen diff --git a/rosen/modules/graphics_effect/src/ge_magnifier_shader_filter.cpp b/rosen/modules/graphics_effect/src/ge_magnifier_shader_filter.cpp index 2f32c22711..944bb8b58c 100644 --- a/rosen/modules/graphics_effect/src/ge_magnifier_shader_filter.cpp +++ b/rosen/modules/graphics_effect/src/ge_magnifier_shader_filter.cpp @@ -45,7 +45,7 @@ static std::shared_ptr GetMagnifierParams() } } // namespace -std::shared_ptr GEMagnifierShaderFilter::magnifierShaderEffect_ = nullptr; +std::shared_ptr GEMagnifierShaderFilter::g_magnifierShaderEffect = nullptr; GEMagnifierShaderFilter::GEMagnifierShaderFilter() {} @@ -76,7 +76,7 @@ std::shared_ptr GEMagnifierShaderFilter::ProcessImage(Drawing::C std::shared_ptr GEMagnifierShaderFilter::MakeMagnifierShader( std::shared_ptr imageShader, float imageWidth, float imageHeight) { - if (magnifierShaderEffect_ == nullptr) { + if (g_magnifierShaderEffect == nullptr) { if (!InitMagnifierEffect()) { LOGE("GEMagnifierShaderFilter::failed when initializing MagnifierEffect."); return nullptr; @@ -88,7 +88,7 @@ std::shared_ptr GEMagnifierShaderFilter::MakeMagn return nullptr; } std::shared_ptr builder = - std::make_shared(magnifierShaderEffect_); + std::make_shared(g_magnifierShaderEffect); builder->SetChild("imageShader", imageShader); builder->SetUniform("iResolution", imageWidth, imageHeight); @@ -119,7 +119,7 @@ std::shared_ptr GEMagnifierShaderFilter::MakeMagn bool GEMagnifierShaderFilter::InitMagnifierEffect() { - if (magnifierShaderEffect_ == nullptr) { + if (g_magnifierShaderEffect == nullptr) { static constexpr char prog[] = R"( uniform shader imageShader; uniform float2 iResolution; @@ -209,8 +209,8 @@ bool GEMagnifierShaderFilter::InitMagnifierEffect() } )"; - magnifierShaderEffect_ = Drawing::RuntimeEffect::CreateForShader(prog); - if (magnifierShaderEffect_ == nullptr) { + g_magnifierShaderEffect = Drawing::RuntimeEffect::CreateForShader(prog); + if (g_magnifierShaderEffect == nullptr) { LOGE("MakeMagnifierShader::RuntimeShader effect error\n"); return false; } diff --git a/rosen/modules/graphics_effect/test/unittest/ge_magnifier_shader_filter_test.cpp b/rosen/modules/graphics_effect/test/unittest/ge_magnifier_shader_filter_test.cpp index 8f502e90ee..3bcc78f7af 100644 --- a/rosen/modules/graphics_effect/test/unittest/ge_magnifier_shader_filter_test.cpp +++ b/rosen/modules/graphics_effect/test/unittest/ge_magnifier_shader_filter_test.cpp @@ -97,7 +97,7 @@ HWTEST_F(GEMagnifierShaderFilterTest, ProcessImage002, TestSize.Level1) auto filter = std::make_shared(); ASSERT_TRUE(filter != nullptr); - EXPECT_NE(filter->ProcessImage(canvas_, image_, src_, dst_), image_); + EXPECT_EQ(filter->ProcessImage(canvas_, image_, src_, dst_), image_); } /** @@ -115,11 +115,11 @@ HWTEST_F(GEMagnifierShaderFilterTest, ProcessImage003, TestSize.Level1) Drawing::Rect dst { 1.0f, 1.0f, 2.0f, 2.0f }; #ifdef GE_OHOS #undef GE_OHOS - EXPECT_NE(filter->ProcessImage(canvas_, image_, src, dst), image_); + EXPECT_EQ(filter->ProcessImage(canvas_, image_, src, dst), image_); #define GE_OHOS #else #define GE_OHOS - EXPECT_NE(filter->ProcessImage(canvas_, image_, src, dst), image_); + EXPECT_EQ(filter->ProcessImage(canvas_, image_, src, dst), image_); #undef GE_OHOS #endif } @@ -134,7 +134,7 @@ HWTEST_F(GEMagnifierShaderFilterTest, ProcessImage004, TestSize.Level1) auto filter = std::make_shared(); ASSERT_TRUE(filter != nullptr); - EXPECT_NE(filter->ProcessImage(canvas_, image_, src_, dst_), image_); + EXPECT_EQ(filter->ProcessImage(canvas_, image_, src_, dst_), image_); std::shared_ptr image = std::make_shared(); EXPECT_EQ(filter->ProcessImage(canvas_, image, src_, dst_), image); From ff36b96d5e7e2b84b283cb2c76000934e44ff53c Mon Sep 17 00:00:00 2001 From: LeesonWong Date: Sat, 29 Jun 2024 11:33:55 +0800 Subject: [PATCH 108/247] Test cases for rs_image_cache.cpp Signed-off-by: w30027672 --- rosen/modules/render_service_base/test/unittest/render/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/modules/render_service_base/test/unittest/render/BUILD.gn b/rosen/modules/render_service_base/test/unittest/render/BUILD.gn index acee2749ca..d0f8687331 100644 --- a/rosen/modules/render_service_base/test/unittest/render/BUILD.gn +++ b/rosen/modules/render_service_base/test/unittest/render/BUILD.gn @@ -25,8 +25,8 @@ ohos_unittest("RSRenderTest") { deps = [ "$graphic_2d_root/rosen/modules/render_service_base:render_service_base_src", - "$window_base_path/wm:libwm", "$third_path/googletest:gtest_main", + "$window_base_path/wm:libwm", ] external_deps = [ From fea44a0b21bed5a039d42871cb904fe63fae951f Mon Sep 17 00:00:00 2001 From: jiandong Date: Tue, 25 Jun 2024 20:48:03 +0800 Subject: [PATCH 109/247] add log of setting dirty Signed-off-by: jiandong Change-Id: I69092596f73d40a2a7f7ecafb11b0b9c494668ba Signed-off-by: jiandong --- .../rs_canvas_drawing_render_node_drawable.cpp | 1 + .../core/pipeline/rs_main_thread.cpp | 9 +++++++++ .../pipeline/rs_render_service_listener.cpp | 2 ++ .../core/pipeline/rs_uifirst_manager.cpp | 1 + .../core/pipeline/rs_uni_render_visitor.cpp | 1 + .../src/modifier/rs_render_property.cpp | 1 + .../pipeline/rs_canvas_drawing_render_node.cpp | 1 + .../src/pipeline/rs_render_node.cpp | 17 +++++++++++++++++ .../src/pipeline/rs_render_node_autocache.cpp | 3 +++ .../src/pipeline/rs_surface_render_node.cpp | 11 +++++++++++ .../src/property/rs_point_light_manager.cpp | 2 ++ .../core/pipeline/rs_render_thread_visitor.cpp | 2 +- .../rs_profiler_base.cpp | 1 + 13 files changed, 51 insertions(+), 1 deletion(-) diff --git a/rosen/modules/render_service/core/drawable/rs_canvas_drawing_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_canvas_drawing_render_node_drawable.cpp index edcea28f14..cb5646c71c 100644 --- a/rosen/modules/render_service/core/drawable/rs_canvas_drawing_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_canvas_drawing_render_node_drawable.cpp @@ -303,6 +303,7 @@ void RSCanvasDrawingRenderNodeDrawable::ProcessCPURenderInBackgroundThread(std:: } ctx->PostTask([ctx, nodeId]() { if (auto node = ctx->GetNodeMap().GetRenderNode(nodeId)) { + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, process in background", node->GetId()); node->SetDirty(); ctx->RequestVsync(); } diff --git a/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp b/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp index 3381ad4b64..3e79b8788a 100644 --- a/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp @@ -1215,6 +1215,7 @@ void RSMainThread::ConsumeAndUpdateAllNodes() surfaceNode->ResetIsOnlyBasicGeoTransform(); } if (surfaceNode->GetName().find(CAPTURE_WINDOW_NAME) != std::string::npos) { + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, consume and update all nodes", surfaceNode->GetId()); surfaceNode->SetContentDirty(); // screen recording capsule force mark dirty } if (surfaceNode->IsHardwareEnabledType() @@ -1234,6 +1235,8 @@ void RSMainThread::ConsumeAndUpdateAllNodes() surfaceNode->GetName(), surfaceHandler.GetDamageRegion()); } if (surfaceNode->IsCurrentFrameBufferConsumed() && !surfaceNode->IsHardwareEnabledType()) { + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, current frame buffer consumed", + surfaceNode->GetId()); surfaceNode->SetContentDirty(); doDirectComposition_ = false; RS_OPTIONAL_TRACE_NAME_FMT( @@ -1253,6 +1256,8 @@ void RSMainThread::ConsumeAndUpdateAllNodes() && surfaceNode->IsHardwareEnabledType() && surfaceNode->IsHardwareForcedDisabledByFilter()) { RS_OPTIONAL_TRACE_NAME(surfaceNode->GetName() + " SetContentDirty for UIFirst assigning to subthread"); + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, current frame buffer consumed", + surfaceNode->GetId()); surfaceNode->SetContentDirty(); doDirectComposition_ = false; RS_OPTIONAL_TRACE_NAME_FMT("rs debug: name %s, id %llu, pc uifirst on", @@ -1365,10 +1370,13 @@ void RSMainThread::CollectInfoForHardwareComposer() if (isHardwareForcedDisabled_) { // buffer updated or hwc -> gpu if (surfaceNode->IsCurrentFrameBufferConsumed() || surfaceNode->GetIsLastFrameHwcEnabled()) { + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, buffer updated or hardware change to gpu", + surfaceNode->GetId()); surfaceNode->SetContentDirty(); } } else if (!surfaceNode->GetIsLastFrameHwcEnabled()) { // gpu -> hwc if (surfaceNode->IsCurrentFrameBufferConsumed()) { + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, gpu change to hardware", surfaceNode->GetId()); surfaceNode->SetContentDirty(); doDirectComposition_ = false; RS_OPTIONAL_TRACE_NAME_FMT( @@ -1384,6 +1392,7 @@ void RSMainThread::CollectInfoForHardwareComposer() // self-drawing node don't set content dirty when gpu -> hwc // so first frame in hwc -> hwc, should set content dirty if (surfaceNode->GetHwcDelayDirtyFlag()) { + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, hardware to hardware", surfaceNode->GetId()); surfaceNode->SetContentDirty(); surfaceNode->SetHwcDelayDirtyFlag(false); doDirectComposition_ = false; diff --git a/rosen/modules/render_service/core/pipeline/rs_render_service_listener.cpp b/rosen/modules/render_service/core/pipeline/rs_render_service_listener.cpp index af1e3b3ed2..dd92907931 100644 --- a/rosen/modules/render_service/core/pipeline/rs_render_service_listener.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_render_service_listener.cpp @@ -104,6 +104,7 @@ void RSRenderServiceListener::OnGoBackground() node->CleanCache(); node->UpdateBufferInfo(nullptr, nullptr, nullptr); node->SetNotifyRTBufferAvailable(false); + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, go background", node->GetId()); node->SetContentDirty(); node->ResetHardwareEnabledStates(); }); @@ -119,6 +120,7 @@ void RSRenderServiceListener::OnTransformChange() return; } RS_LOGD("RsDebug RSRenderServiceListener::OnTransformChange node id:%{public}" PRIu64, node->GetId()); + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, transform changed", node->GetId()); node->SetContentDirty(); node->SetDoDirectComposition(false); }); diff --git a/rosen/modules/render_service/core/pipeline/rs_uifirst_manager.cpp b/rosen/modules/render_service/core/pipeline/rs_uifirst_manager.cpp index 74e8e9d280..146ea2b0b5 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uifirst_manager.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uifirst_manager.cpp @@ -188,6 +188,7 @@ void RSUifirstManager::ProcessForceUpdateNode() } } for (auto& node : toDirtyNodes) { + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, force update", node->GetId()); node->SetDirty(true); } pendingForceUpdateNode_.clear(); diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp index dddc59c7ba..281e1be05b 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp @@ -2843,6 +2843,7 @@ void RSUniRenderVisitor::PrepareSurfaceRenderNode(RSSurfaceRenderNode& node) node.UpdatePositionZ(); if (node.GetName().find(CAPTURE_WINDOW_NAME) != std::string::npos) { hasCaptureWindow_[currentVisitDisplay_] = true; + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, prepare surface node", node.GetId()); node.SetContentDirty(); // screen recording capsule force mark dirty } diff --git a/rosen/modules/render_service_base/src/modifier/rs_render_property.cpp b/rosen/modules/render_service_base/src/modifier/rs_render_property.cpp index 38da017f4a..0190736ab2 100644 --- a/rosen/modules/render_service_base/src/modifier/rs_render_property.cpp +++ b/rosen/modules/render_service_base/src/modifier/rs_render_property.cpp @@ -25,6 +25,7 @@ namespace Rosen { void RSRenderPropertyBase::OnChange() const { if (auto node = node_.lock()) { + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, property changed", node->GetId()); node->SetDirty(); node->AddDirtyType(modifierType_); if (modifierType_ < RSModifierType::BOUNDS || modifierType_ > RSModifierType::TRANSLATE_Z || diff --git a/rosen/modules/render_service_base/src/pipeline/rs_canvas_drawing_render_node.cpp b/rosen/modules/render_service_base/src/pipeline/rs_canvas_drawing_render_node.cpp index 880bdbf197..993887e1ee 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_canvas_drawing_render_node.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_canvas_drawing_render_node.cpp @@ -250,6 +250,7 @@ void RSCanvasDrawingRenderNode::ProcessCPURenderInBackgroundThread(std::shared_p node->image_ = image; ctx->PostRTTask([ctx, nodeId]() { if (auto node = ctx->GetNodeMap().GetRenderNode(nodeId)) { + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, process in background", node->GetId()); node->SetDirty(); ctx->RequestVsync(); } diff --git a/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp b/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp index 26a86f5e7c..fb81f4548c 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp @@ -169,6 +169,7 @@ void RSRenderNode::OnRegister(const std::weak_ptr& context) context_ = context; renderContent_->type_ = GetType(); renderContent_->renderProperties_.backref_ = weak_from_this(); + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, register node", GetId()); SetDirty(true); InitRenderParams(); } @@ -237,6 +238,7 @@ void RSRenderNode::AddChild(SharedPtr child, int index) if (isOnTheTree_) { child->SetIsOnTheTree(true, instanceRootNodeId_, firstLevelNodeId_, drawingCacheRootId_, uifirstRootNodeId_); } + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, render node add child", GetId()); SetContentDirty(); isFullChildrenListValid_ = false; } @@ -270,6 +272,7 @@ void RSRenderNode::MoveChild(SharedPtr child, int index) children_.emplace(std::next(children_.begin(), index), child); } children_.erase(it); + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, render node move child", GetId()); SetContentDirty(); isFullChildrenListValid_ = false; } @@ -301,6 +304,7 @@ void RSRenderNode::RemoveChild(SharedPtr child, bool skipTransition) if (child->GetBootAnimation()) { SetContainBootAnimation(false); } + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, render node remove child", GetId()); SetContentDirty(); isFullChildrenListValid_ = false; } @@ -403,6 +407,7 @@ void RSRenderNode::AddCrossParentChild(const SharedPtr& child, int32_t index) if (isOnTheTree_) { child->SetIsOnTheTree(true, instanceRootNodeId_, firstLevelNodeId_, drawingCacheRootId_, uifirstRootNodeId_); } + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, render node add crossParent child", GetId()); SetContentDirty(); isFullChildrenListValid_ = false; } @@ -435,6 +440,7 @@ void RSRenderNode::RemoveCrossParentChild(const SharedPtr& child, const WeakPtr& hasRemovedChild_ = true; } children_.erase(it); + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, render node remove crossParent child", GetId()); SetContentDirty(); isFullChildrenListValid_ = false; } @@ -481,6 +487,7 @@ void RSRenderNode::ClearChildren() ++pos; } children_.clear(); + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, render node clear child", GetId()); SetContentDirty(); isFullChildrenListValid_ = false; } @@ -505,6 +512,7 @@ void RSRenderNode::ResetParent() } } parentNode->hasRemovedChild_ = true; + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, render node reset child", GetId()); parentNode->SetContentDirty(); UpdateSubSurfaceCnt(nullptr, parentNode); } @@ -2166,6 +2174,7 @@ void RSRenderNode::AccmulateDirtyStatus() if (curDirtyStatus_ == NodeDirty::CLEAN) { return; } + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, accmulate dirty status after properties changed", GetId()); SetDirty(); } @@ -2532,10 +2541,13 @@ void RSRenderNode::SetSharedTransitionParam(const std::shared_ptrAddDirtyType(RSModifierType::CHILDREN); + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, parent of shared transition param changed node", + parent->GetId()); parent->SetDirty(); } } @@ -2982,6 +2994,7 @@ void RSRenderNode::MarkNodeGroup(NodeGroupType type, bool isNodeGroup, bool incl auto context = GetContext().lock(); if (context && context->GetNodeMap().IsResidentProcessNode(GetId())) { nodeGroupType_ |= type; + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, mark node group", GetId()); SetDirty(); } } else { @@ -2990,6 +3003,7 @@ void RSRenderNode::MarkNodeGroup(NodeGroupType type, bool isNodeGroup, bool incl } else { nodeGroupType_ &= ~type; } + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, mark node group", GetId()); SetDirty(); } if (nodeGroupType_ == static_cast(NodeGroupType::NONE) && !isNodeGroup) { @@ -3157,12 +3171,14 @@ void RSRenderNode::OnTreeStateChanged() } if (isOnTheTree_) { // Set dirty and force add to active node list, re-generate children list if needed + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, onTree state changed", GetId()); SetDirty(true); SetParentSubTreeDirty(); } else if (sharedTransitionParam_) { // Mark shared transition unpaired, and mark paired node dirty sharedTransitionParam_->paired_ = false; if (auto pairedNode = sharedTransitionParam_->GetPairedNode(id_)) { + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, paired node of shared transition", pairedNode->GetId()); pairedNode->SetDirty(true); } } @@ -3450,6 +3466,7 @@ void RSRenderNode::SetStaticCached(bool isStaticCached) // ensure defrost subtree would be updated stagingRenderParams_->SetRSFreezeFlag(isStaticCached); if (!isStaticCached_) { + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, render node not static cached", GetId()); SetContentDirty(); } } diff --git a/rosen/modules/render_service_base/src/pipeline/rs_render_node_autocache.cpp b/rosen/modules/render_service_base/src/pipeline/rs_render_node_autocache.cpp index 416a967a40..13f3e6074e 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_render_node_autocache.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_render_node_autocache.cpp @@ -14,6 +14,7 @@ */ #include "pipeline/rs_render_node.h" +#include "platform/common/rs_log.h" #ifdef DDGR_ENABLE_FEATURE_OPINC_DFX #include "string_utils.h" #include "common/rs_optional_trace.h" @@ -126,6 +127,7 @@ void RSRenderNode::MarkSuggestOpincNode(bool isOpincNode, bool isNeedCalculate) { isSuggestOpincNode_ = isOpincNode; isNeedCalculate_ = isNeedCalculate; + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, mark suggest opinc node", GetId()); SetDirty(); } @@ -178,6 +180,7 @@ void RSRenderNode::NodeCacheStateReset(NodeCacheState nodeCacheState) SetCacheStateByRetrytime(); isOpincRootFlag_ = false; } + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, reset cache state", GetId()); SetDirty(); stagingRenderParams_->OpincSetCacheChangeFlag(true); isOpincRootFlag_ = false; diff --git a/rosen/modules/render_service_base/src/pipeline/rs_surface_render_node.cpp b/rosen/modules/render_service_base/src/pipeline/rs_surface_render_node.cpp index 7479d19119..02ee8f225e 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_surface_render_node.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_surface_render_node.cpp @@ -683,6 +683,7 @@ void RSSurfaceRenderNode::SetContextMatrix(const std::optional& return; } contextMatrix_ = matrix; + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, context matrix changed", GetId()); SetContentDirty(); AddDirtyType(RSModifierType::SCALE); AddDirtyType(RSModifierType::SKEW); @@ -702,6 +703,7 @@ void RSSurfaceRenderNode::SetContextAlpha(float alpha, bool sendMsg) return; } contextAlpha_ = alpha; + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, node context alpha changed", GetId()); SetContentDirty(); AddDirtyType(RSModifierType::ALPHA); if (!sendMsg) { @@ -718,6 +720,7 @@ void RSSurfaceRenderNode::SetContextClipRegion(const std::optional(GetFirstLevelNode()); // firstLevelNode is the nearest app window / leash node if (firstLevelNode && GetFirstLevelNodeId() != GetId()) { + ROSEN_LOGD("Node id %{public}" PRIu64 + " set dirty, first level node of protected info to be synced", firstLevelNode->GetId()); firstLevelNode->SetDirty(); // should always sync protectedLayerIds_ to firstLevelNode if (isProtectedLayer_ && IsOnTheTree()) { @@ -1097,6 +1105,7 @@ void RSSurfaceRenderNode::NotifyRTBufferAvailable(bool isTextureExportNode) RSRTRefreshCallback::Instance().ExecuteRefresh(); } if (isTextureExportNode) { + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, texture export node notify buffer available", GetId()); SetContentDirty(); } @@ -1180,6 +1189,7 @@ void RSSurfaceRenderNode::SetStartAnimationFinished() bool RSSurfaceRenderNode::UpdateDirtyIfFrameBufferConsumed() { if (isCurrentFrameBufferConsumed_) { + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, frame buffer consumed", GetId()); SetContentDirty(); return true; } @@ -2682,6 +2692,7 @@ void RSSurfaceRenderNode::SetUifirstUseStarting(NodeId id) void RSSurfaceRenderNode::SetSkipDraw(bool skip) { isSkipDraw_ = skip; + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, skip draw", GetId()); SetDirty(); } diff --git a/rosen/modules/render_service_base/src/property/rs_point_light_manager.cpp b/rosen/modules/render_service_base/src/property/rs_point_light_manager.cpp index 9681d30fdb..e374e99635 100644 --- a/rosen/modules/render_service_base/src/property/rs_point_light_manager.cpp +++ b/rosen/modules/render_service_base/src/property/rs_point_light_manager.cpp @@ -20,6 +20,7 @@ #include "pipeline/rs_render_node.h" #include "property/rs_properties_def.h" #include "screen_manager/screen_types.h" +#include "platform/common/rs_log.h" namespace OHOS { namespace Rosen { @@ -140,6 +141,7 @@ void RSPointLightManager::CheckIlluminated( if (inIlluminatedRange && illuminatedRootNodeId == lightSourceRootNodeId) { auto lightPos = CalculateLightPosForIlluminated(*lightSourcePtr, illuminatedAbsRect); illuminatedNode->GetRenderProperties().GetIlluminated()->AddLightSourcesAndPos(lightSourcePtr, lightPos); + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, node be Illuminated", illuminatedNode->GetId()); illuminatedNode->SetDirty(); } } diff --git a/rosen/modules/render_service_client/core/pipeline/rs_render_thread_visitor.cpp b/rosen/modules/render_service_client/core/pipeline/rs_render_thread_visitor.cpp index 8035c38f71..4c6775af1c 100644 --- a/rosen/modules/render_service_client/core/pipeline/rs_render_thread_visitor.cpp +++ b/rosen/modules/render_service_client/core/pipeline/rs_render_thread_visitor.cpp @@ -170,7 +170,7 @@ void RSRenderThreadVisitor::PrepareSurfaceRenderNode(RSSurfaceRenderNode& node) // If rt buffer switches to be available // set its SurfaceRenderNode's render dirty if (!node.IsNotifyRTBufferAvailablePre() && node.IsNotifyRTBufferAvailable()) { - ROSEN_LOGD("NotifyRTBufferAvailable and set it dirty"); + ROSEN_LOGD("Node id %{public}" PRIu64 "NotifyRTBufferAvailable and set node dirty", node.GetId()); node.SetDirty(); } auto rect = nodeParent->GetRenderProperties().GetBoundsRect(); diff --git a/rosen/modules/render_service_profiler/rs_profiler_base.cpp b/rosen/modules/render_service_profiler/rs_profiler_base.cpp index 64458ba73f..342061905a 100644 --- a/rosen/modules/render_service_profiler/rs_profiler_base.cpp +++ b/rosen/modules/render_service_profiler/rs_profiler_base.cpp @@ -611,6 +611,7 @@ void RSProfiler::UnmarshalNodes(RSContext& context, std::stringstream& data) return; } if (Utils::IsNodeIdPatched(node->GetId())) { + ROSEN_LOGD("Node id %{public}" PRIu64 " set dirty, unmarshal nodes", node->GetId()); node->SetContentDirty(); node->SetDirty(); } From 374eed4e2f04061dfd911395aa1c6fb4c0201a07 Mon Sep 17 00:00:00 2001 From: LeesonWong Date: Sat, 29 Jun 2024 12:06:01 +0800 Subject: [PATCH 110/247] Test cases for rs_image_cache.cpp Signed-off-by: w30027672 --- .../render_service_base/test/unittest/render/BUILD.gn | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rosen/modules/render_service_base/test/unittest/render/BUILD.gn b/rosen/modules/render_service_base/test/unittest/render/BUILD.gn index d0f8687331..8159dc630e 100644 --- a/rosen/modules/render_service_base/test/unittest/render/BUILD.gn +++ b/rosen/modules/render_service_base/test/unittest/render/BUILD.gn @@ -12,20 +12,19 @@ # limitations under the License. import("//build/test.gni") -import("//foundation/graphic/graphic_2d/graphic_config.gni") +graphic_2d_root = "//foundation/graphic/graphic_2d" third_party_path = "//third_party" +window_base_path = "//foundation/window/window_manager" ohos_unittest("RSRenderTest") { - third_path = third_party_path - sources = [ "rs_image_cache_test.cpp" ] configs = [ ":rs_render_test_config" ] deps = [ "$graphic_2d_root/rosen/modules/render_service_base:render_service_base_src", - "$third_path/googletest:gtest_main", + "$third_party_path/googletest:gtest_main", "$window_base_path/wm:libwm", ] From d2944c3ef2c43201a328068a94c68453c007e7d5 Mon Sep 17 00:00:00 2001 From: 15549494042 Date: Sat, 29 Jun 2024 14:04:11 +0800 Subject: [PATCH 111/247] add pointer color invert ipc interface Singed-off-by:dongzhengkuan@huawei.com Signed-off-by: 15549494042 --- .../pipeline/rs_pointer_render_manager.cpp | 79 +++++++++++++++++++ .../core/pipeline/rs_pointer_render_manager.h | 19 +++++ .../pointer_luminance_change_callback.h | 32 ++++++++ ...nance_change_callback_ipc_interface_code.h | 29 +++++++ ...lback_ipc_interface_code_access_verifier.h | 46 +++++++++++ 5 files changed, 205 insertions(+) create mode 100644 rosen/modules/render_service_base/include/ipc_callbacks/pointer_luminance_change_callback.h create mode 100644 rosen/modules/render_service_base/include/ipc_callbacks/pointer_luminance_change_callback_ipc_interface_code.h create mode 100644 rosen/modules/render_service_base/include/ipc_callbacks/pointer_luminance_change_callback_ipc_interface_code_access_verifier.h diff --git a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp index 0bb23775ba..fcc526f8d4 100644 --- a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp @@ -24,6 +24,8 @@ namespace Rosen { namespace { static const std::string DISPLAY_NODE = "DisplayNode"; static const std::string POINTER_NODE = "pointer"; +static const float RGB = 255; +static const float HALF = 0.5; } // namespace static std::unique_ptr g_pointerRenderManagerInstance = std::make_unique(); @@ -53,12 +55,88 @@ void RSPointerRenderManager::InitInstance(const std::shared_ptr lock(cursorInvertMutex_); + darkBuffer_ = darkBuffer; + brightBuffer_ = brightBuffer; + colorSamplingInterval_ = interval; +} + +void RSPointerRenderManager::SetPointerColorInversionEnabled(bool enable) +{ + std::lock_guard lock(cursorInvertMutex_); + isEnableCursorInversion_ = enable; + if (!enable) { + brightness_ = CursorBrightness::NONE; + } +} + +void RSPointerRenderManager::RegisterPointerLuminanceChangeCallback(pid_t pid, + sptr callback) +{ + std::lock_guard lock(cursorInvertMutex_); + colorChangeListeners_[pid] = callback; +} + +void RSPointerRenderManager::UnRegisterPointerLuminanceChangeCallback(pid_t pid) +{ + std::lock_guard lock(cursorInvertMutex_); + colorChangeListeners_.erase(pid); +} + +void RSPointerRenderManager::ExecutePointerLuminanceChangeCallback(int32_t brightness) +{ + std::lock_guard lock(cursorInvertMutex_); + for (auto it = colorChangeListeners_.begin(); it != colorChangeListeners_.end(); it++) { + if (it->second) { + it->second->OnPointerLuminanceChanged(brightness); + } + } +} + +void RSPointerRenderManager::CallPointerLuminanceChange(int32_t brightness) +{ + RS_LOGD("RSPointerRenderManager::CallPointerLuminanceChange luminance_:%{public}d.", luminance_); + auto timeNow = std::chrono::time_point_cast(std::chrono::steady_clock::now()); + auto tmp = std::chrono::duration_cast(timeNow.time_since_epoch()); + lastColorPickerTime_ = tmp.count(); + if (brightness_ == CursorBrightness::NONE) { + if (brightness < RGB * HALF) { + brightness_ = CursorBrightness::DARK; + } else { + brightness_ = CursorBrightness::BRIGHT; + } + ExecutePointerLuminanceChangeCallback(brightness); + } else if (brightness_ == CursorBrightness::DARK) { + // 暗光标 --> 亮光标 缓冲区 + if (brightness > RGB * darkBuffer_) { + brightness_ = CursorBrightness::BRIGHT; + ExecutePointerLuminanceChangeCallback(brightness); + } + } else { + // 亮光标 --> 暗光标 缓冲区 + if (brightness < RGB * brightBuffer_) { + brightness_ = CursorBrightness::DARK; + ExecutePointerLuminanceChangeCallback(brightness); + } + } +} + bool RSPointerRenderManager::CheckColorPickerEnabled() { if (!isEnableCursorInversion_) { return false; } + + auto timeNow = std::chrono::time_point_cast(std::chrono::steady_clock::now()); + auto tmp = std::chrono::duration_cast(timeNow.time_since_epoch()); + auto time = tmp.count() - lastColorPickerTime_; + if (time < colorSamplingInterval_) { + return; + } + bool exists = false; auto& hardwareNodes = RSUniRenderThread::Instance().GetRSRenderThreadParams()->GetHardwareEnabledTypeNodes(); for (auto& it : hardwareNodes) { @@ -240,6 +318,7 @@ void RSPointerRenderManager::RunColorPickerTask() luminance_ = color.GetRed() * 0.2126f + color.GetGreen() * 0.7152f + color.GetBlue() * 0.0722f; image_ = nullptr; taskDoing_ = false; + CallPointerLuminanceChange(luminance_); #endif }; RSBackgroundThread::Instance().PostTask(task); diff --git a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.h b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.h index 5abb962566..71a88b9e0e 100644 --- a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.h +++ b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.h @@ -16,6 +16,7 @@ #ifndef RS_POINTER_RENDER_MANAGER_H #define RS_POINTER_RENDER_MANAGER_H +#include "ipc_callbacks/pointer_luminance_change_callback.h" #include "pipeline/rs_display_render_node.h" #include "rs_processor.h" #ifdef RS_ENABLE_VK @@ -39,12 +40,18 @@ public: static RSPointerRenderManager& GetInstance(); void ProcessColorPicker(std::shared_ptr processor, std::shared_ptr gpuContext); + void SetPointerColorInversionConfig(float darkBuffer, float brightBuffer, int64_t interval); + void SetPointerColorInversionEnabled(bool enable); + void RegisterPointerLuminanceChangeCallback(pid_t pid, sptr callback); + void UnRegisterPointerLuminanceChangeCallback(pid_t pid); void SetCacheImgForPointer(std::shared_ptr cacheImgForPointer) { cacheImgForPointer_ = cacheImgForPointer; } private: + void ExecutePointerLuminanceChangeCallback(int32_t brightness); + void CallPointerLuminanceChange(int32_t brightness); bool CheckColorPickerEnabled(); bool CalculateTargetLayer(std::shared_ptr processor); void RunColorPickerTask(); @@ -77,6 +84,18 @@ private: std::atomic taskDoing_ = false; bool isEnableCursorInversion_ = false; std::shared_ptr cacheImgForPointer_ = nullptr; + std::mutex cursorInvertMutex_; + std::map> colorChangeListeners_; + enum class CursorBrightness { + NONE, + BRIGHT, + DARK + }; + CursorBrightness brightness_ = CursorBrightness::NONE; + int64_t lastColorPickerTime_ = 0; + int64_t colorSamplingInterval_ = 50; + float darkBuffer_ = 0.55; + float brightBuffer_ = 0.35; }; } #endif // RS_POINTER_RENDER_MANAGER_H \ No newline at end of file diff --git a/rosen/modules/render_service_base/include/ipc_callbacks/pointer_luminance_change_callback.h b/rosen/modules/render_service_base/include/ipc_callbacks/pointer_luminance_change_callback.h new file mode 100644 index 0000000000..7f8397e4f1 --- /dev/null +++ b/rosen/modules/render_service_base/include/ipc_callbacks/pointer_luminance_change_callback.h @@ -0,0 +1,32 @@ +/* + * 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 ROSEN_RENDER_SERVICE_BASE_IPOINTER_LUMINANCE_CHANGE_CALLBACK_H +#define ROSEN_RENDER_SERVICE_BASE_IPOINTER_LUMINANCE_CHANGE_CALLBACK_H + +#include + +namespace OHOS { +namespace Rosen { +class RSIPointerLuminanceChangeCallback : public IRemoteBroker { +public: + DECLARE_INTERFACE_DESCRIPTOR(u"ohos.rosen.PointerLuminanceChangeCallback"); + RSIPointerLuminanceChangeCallback() = default; + virtual ~RSIPointerLuminanceChangeCallback() noexcept = default; + virtual void OnPointerLuminanceChanged(int32_t brightness) = 0; +}; +} +} +#endif \ No newline at end of file diff --git a/rosen/modules/render_service_base/include/ipc_callbacks/pointer_luminance_change_callback_ipc_interface_code.h b/rosen/modules/render_service_base/include/ipc_callbacks/pointer_luminance_change_callback_ipc_interface_code.h new file mode 100644 index 0000000000..40208a5453 --- /dev/null +++ b/rosen/modules/render_service_base/include/ipc_callbacks/pointer_luminance_change_callback_ipc_interface_code.h @@ -0,0 +1,29 @@ +/* + * 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 ROSEN_RENDER_SERVICE_BASE_IPOINTER_LUMINANCE_CHANGE_CALLBACK_INTERFACE_CODE_H +#define ROSEN_RENDER_SERVICE_BASE_IPOINTER_LUMINANCE_CHANGE_CALLBACK_INTERFACE_CODE_H + +#include "ipc_security/rs_ipc_interface_code_underlying_type.h" + +namespace OHOS { +namespace Rosen { +enum class RSIPointerLuminanceChangeCallbackInterfaceCode : CodeUnderlyingType { + ON_POINTER_LUMINANCE_CHANGED, +}; +} // namespace Rosen +} // namespace OHOS + +#endif // ROSEN_RENDER_SERVICE_BASE_IPOINTER_LUMINANCE_CHANGE_CALLBACK_INTERFACE_CODE_H \ No newline at end of file diff --git a/rosen/modules/render_service_base/include/ipc_callbacks/pointer_luminance_change_callback_ipc_interface_code_access_verifier.h b/rosen/modules/render_service_base/include/ipc_callbacks/pointer_luminance_change_callback_ipc_interface_code_access_verifier.h new file mode 100644 index 0000000000..172a806729 --- /dev/null +++ b/rosen/modules/render_service_base/include/ipc_callbacks/pointer_luminance_change_callback_ipc_interface_code_access_verifier.h @@ -0,0 +1,46 @@ +/* + * 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 ROSEN_RENDER_SERVICE_BASE_IPOINTER_LUMINANCE_CHANGE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H +#define ROSEN_RENDER_SERVICE_BASE_IPOINTER_LUMINANCE_CHANGE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H + +#include "ipc_security/rs_ipc_interface_code_access_verifier_base.h" +#include "ipc_callbacks/pointer_luminance_change_callback_ipc_interface_code.h" + +namespace OHOS { +namespace Rosen { +class RSIPointerLuminanceChangeCallbackInterfaceCodeAccessVerifier : public RSInterfaceCodeAccessVerifierBase { +public: + /* + * specify the enum class of the associated interface code (i.e. CodeEnumType) here + * note that term **CodeEnumType** should not be changed + */ + using CodeEnumType = RSIPointerLuminanceChangeCallbackInterfaceCode; + static inline const std::string codeEnumTypeName_{"RSIPointerLuminanceChangeCallbackInterfaceCode"}; + + /* specify constructor and destructor here */ + RSIPointerLuminanceChangeCallbackInterfaceCodeAccessVerifier(); + ~RSIPointerLuminanceChangeCallbackInterfaceCodeAccessVerifier() noexcept override = default; + +protected: + /* specify exclusive verification rules here */ + bool IsExclusiveVerificationPassed(CodeUnderlyingType code) override; + +private: + DISALLOW_COPY_AND_MOVE(RSIPointerLuminanceChangeCallbackInterfaceCodeAccessVerifier); +}; +} // namespace Rosen +} // namespace OHOS +#endif // ROSEN_RENDER_SERVICE_BASE_IPOINTER_LUMINANCE_CHANGE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H \ No newline at end of file From ddcd22dd8c8953b8deaf59e7146adf9e93b82311 Mon Sep 17 00:00:00 2001 From: 15549494042 Date: Sat, 29 Jun 2024 14:09:23 +0800 Subject: [PATCH 112/247] add pointer color invert ipc interface Singed-off-by:dongzhengkuan@huawei.com Signed-off-by: 15549494042 --- rosen/modules/render_service_base/BUILD.gn | 3 ++ ...ack_ipc_interface_code_access_verifier.cpp | 42 +++++++++++++++ .../pointer_luminance_callback_proxy.cpp | 48 +++++++++++++++++ .../pointer_luminance_callback_proxy.h | 39 ++++++++++++++ .../pointer_luminance_callback_stub.cpp | 52 +++++++++++++++++++ .../pointer_luminance_callback_stub.h | 37 +++++++++++++ 6 files changed, 221 insertions(+) create mode 100644 rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_ipc_interface_code_access_verifier.cpp create mode 100644 rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_proxy.cpp create mode 100644 rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_proxy.h create mode 100644 rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.cpp create mode 100644 rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.h diff --git a/rosen/modules/render_service_base/BUILD.gn b/rosen/modules/render_service_base/BUILD.gn index d7bfee0990..f1f944ff69 100644 --- a/rosen/modules/render_service_base/BUILD.gn +++ b/rosen/modules/render_service_base/BUILD.gn @@ -153,6 +153,9 @@ ohos_source_set("render_service_base_src") { "src/ipc_callbacks/hgm_config_change_callback_proxy.cpp", "src/ipc_callbacks/hgm_config_change_callback_stub.cpp", "src/ipc_callbacks/iapplication_agent_ipc_interface_code_access_verifier.cpp", + "src/ipc_callbacks/pointer_luminance_callback_ipc_interface_code_access_verifier.cpp", + "src/ipc_callbacks/pointer_luminance_callback_proxy.cpp", + "src/ipc_callbacks/pointer_luminance_callback_stub.cpp", "src/ipc_callbacks/rs_application_agent_proxy.cpp", "src/ipc_callbacks/rs_application_agent_stub.cpp", "src/ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code_access_verifier.cpp", diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_ipc_interface_code_access_verifier.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_ipc_interface_code_access_verifier.cpp new file mode 100644 index 0000000000..289dc5efda --- /dev/null +++ b/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_ipc_interface_code_access_verifier.cpp @@ -0,0 +1,42 @@ +/* + * 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 "ipc_callbacks/pointer_luminance_change_callback_ipc_interface_code_access_verifier.h" + +namespace OHOS { +namespace Rosen { +RSIPointerLuminanceChangeCallbackInterfaceCodeAccessVerifier:: + RSIPointerLuminanceChangeCallbackInterfaceCodeAccessVerifier() +{ + CheckCodeUnderlyingTypeStandardized(codeEnumTypeName_); +} + +bool RSIPointerLuminanceChangeCallbackInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed( + CodeUnderlyingType code) +{ + bool hasPermission = false; + switch (code) { + case static_cast(CodeEnumType::ON_POINTER_LUMINANCE_CHANGED): { + hasPermission = IsSystemCalling(codeEnumTypeName_ + "::ON_POINTER_LUMINANCE_CHANGED"); + break; + } + default: { + break; + } + } + return hasPermission; +} +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_proxy.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_proxy.cpp new file mode 100644 index 0000000000..32507a5f2c --- /dev/null +++ b/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_proxy.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024-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 "pointer_luminance_callback_proxy.h" + +#include +#include + +namespace OHOS { +namespace Rosen { +RSPointerLuminanceChangeCallbackProxy::RSPointerLuminanceChangeCallbackProxy(const sptr& impl) + : IRemoteProxy(impl) +{ +} + +void RSPointerLuminanceChangeCallbackProxy::OnPointerLuminanceChanged(int32_t brightness) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIPointerLuminanceChangeCallback::GetDescriptor())) { + return; + } + + data.WriteInt32(brightness); + + option.SetFlags(MessageOption::TF_ASYNC); + uint32_t code = static_cast(RSIPointerLuminanceChangeCallbackInterfaceCode::ON_POINTER_LUMINANCE_CHANGED); + int32_t err = Remote()->SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSPointerLuminanceChangeCallbackProxy::OnPointerLuminanceChanged error = %{public}d", err); + } +} +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_proxy.h b/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_proxy.h new file mode 100644 index 0000000000..27241ffcbd --- /dev/null +++ b/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_proxy.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024-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 ROSEN_RENDER_SERVICE_BASE_IPOINTER_LUMINANCE_CHANGE_CALLBACK_PROXY_H +#define ROSEN_RENDER_SERVICE_BASE_IPOINTER_LUMINANCE_CHANGE_CALLBACK_PROXY_H + +#include + +#include "ipc_callbacks/pointer_luminance_change_callback.h" +#include "ipc_callbacks/pointer_luminance_change_callback_ipc_interface_code.h" + +namespace OHOS { +namespace Rosen { +class RSPointerLuminanceChangeCallbackProxy : public IRemoteProxy { +public: + explicit RSPointerLuminanceChangeCallbackProxy(const sptr& impl); + virtual ~RSPointerLuminanceChangeCallbackProxy() noexcept = default; + + void OnPointerLuminanceChanged(int32_t brightness) override; + +private: + static inline BrokerDelegator delegator_; +}; +} // namespace Rosen +} // namespace OHOS + +#endif // ROSEN_RENDER_SERVICE_BASE_IPOINTER_LUMINANCE_CHANGE_CALLBACK_PROXY_H \ No newline at end of file diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.cpp new file mode 100644 index 0000000000..828a36c959 --- /dev/null +++ b/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024-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 "pointer_luminance_callback_stub.h" + +namespace OHOS { +namespace Rosen { +int RSPointerLuminanceChangeCallbackStub::OnRemoteRequest( + uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) +{ + RSInterfaceCodeSecurityManager securityManager = + RSInterfaceCodeSecurityManager::CreateInstance(); + if (!securityManager.IsInterfaceCodeAccessible(code)) { + RS_LOGE("RSPointerLuminanceChangeCallbackStub::OnRemoteRequest no permission to access codeID=%{public}u", + code); + return ERR_INVALID_STATE; + } + + auto token = data.ReadInterfaceToken(); + if (token != RSIPointerLuminanceChangeCallback::GetDescriptor()) { + return ERR_INVALID_STATE; + } + + int ret = ERR_NONE; + switch (code) { + case static_cast(RSIPointerLuminanceChangeCallbackInterfaceCode::ON_POINTER_LUMINANCE_CHANGED): { + int32_t brightness = data.ReadInt32(); + OnPointerLuminanceChanged(brightness); + break; + } + default: { + ret = IPCObjectStub::OnRemoteRequest(code, data, reply, option); + break; + } + } + + return ret; +} +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.h b/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.h new file mode 100644 index 0000000000..1de54aacef --- /dev/null +++ b/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024-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 ROSEN_RENDER_SERVICE_BASE_IPOINTER_LUMINANCE_CHANGE_CALLBACK_STUB_H +#define ROSEN_RENDER_SERVICE_BASE_IPOINTER_LUMINANCE_CHANGE_CALLBACK_STUB_H + +#include +#include "common/rs_macros.h" +#include "ipc_callbacks/pointer_luminance_change_callback.h" +#include "ipc_callbacks/pointer_luminance_change_callback_ipc_interface_code_access_verifier.h" +#include "ipc_security/rs_ipc_interface_code_security_manager.h" + +namespace OHOS { +namespace Rosen { +class RSB_EXPORT RSPointerLuminanceChangeCallbackStub : public IRemoteStub { +public: + RSPointerLuminanceChangeCallbackStub() = default; + ~RSPointerLuminanceChangeCallbackStub() = default; + + int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; +}; +} // namespace Rosen +} // namespace OHOS + +#endif // ROSEN_RENDER_SERVICE_BASE_IPOINTER_LUMINANCE_CHANGE_CALLBACK_STUB_H \ No newline at end of file From 060c58f0fcc8a6e54f6271e60fbc9ca5c198e1ac Mon Sep 17 00:00:00 2001 From: qizeyu Date: Sat, 29 Jun 2024 10:11:40 +0800 Subject: [PATCH 113/247] =?UTF-8?q?=E6=B7=BB=E5=8A=A0luminance=E7=9A=84?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qizeyu --- rosen/test/render_service/BUILD.gn | 1 + .../unittest/luminance/BUILD.gn | 68 +++++++++++++++ .../luminance/rs_luminance_control_test.cpp | 82 +++++++++++++++++++ 3 files changed, 151 insertions(+) create mode 100644 rosen/test/render_service/render_service_base/unittest/luminance/BUILD.gn create mode 100644 rosen/test/render_service/render_service_base/unittest/luminance/rs_luminance_control_test.cpp diff --git a/rosen/test/render_service/BUILD.gn b/rosen/test/render_service/BUILD.gn index e47487b9dd..a2ba846bd5 100755 --- a/rosen/test/render_service/BUILD.gn +++ b/rosen/test/render_service/BUILD.gn @@ -96,6 +96,7 @@ group("test") { "render_service_base/unittest/common:unittest", "render_service_base/unittest/delegate:unittest", "render_service_base/unittest/drawable:unittest", + "render_service_base/unittest/luminance:unittest", "render_service_base/unittest/memory:unittest", "render_service_base/unittest/modifier:unittest", "render_service_base/unittest/offscreen_render:unittest", diff --git a/rosen/test/render_service/render_service_base/unittest/luminance/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/luminance/BUILD.gn new file mode 100644 index 0000000000..e4919516ac --- /dev/null +++ b/rosen/test/render_service/render_service_base/unittest/luminance/BUILD.gn @@ -0,0 +1,68 @@ +# 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. + +import("//build/test.gni") +import("//foundation/graphic/graphic_2d/graphic_config.gni") + +module_output_path = "graphic/rosen_engine/render_service_base/luminance" + +############################## RSRenderServiceBaseLuminanceTest ################################## +ohos_unittest("RSRenderServiceBaseLuminanceTest") { + module_out_path = module_output_path + if (defined(use_rosen_drawing) && use_rosen_drawing) { + defines = [ "USE_ROSEN_DRAWING" ] + } + sources = [ "rs_luminance_control_test.cpp" ] + + configs = [ + ":render_test", + "$graphic_2d_root/rosen/modules/render_service_base:export_config", + ] + + include_dirs = [ + "$graphic_2d_root/rosen/modules/render_service_base/include", + "$graphic_2d_root/rosen/include", + "$graphic_2d_root/rosen/test/include", + ] + + cflags = [ + "-Dprivate = public", + "-Dprotected = public", + ] + + deps = [ + "$graphic_2d_root/rosen/modules/render_service_base:render_service_base_src", + "//third_party/googletest:gtest_main", + ] + external_deps = [ + "c_utils:utils", + "graphic_surface:surface", + "image_framework:image_native", + "init:libbegetutil", + "ipc:ipc_core", + "skia:skia_canvaskit", + ] + + subsystem_name = "graphic" +} + +############################################################################### +config("render_test") { + visibility = [ ":*" ] + include_dirs = [ "$graphic_2d_root/rosen/modules/render_service_base" ] +} + +group("unittest") { + testonly = true + deps = [ ":RSRenderServiceBaseLuminanceTest" ] +} diff --git a/rosen/test/render_service/render_service_base/unittest/luminance/rs_luminance_control_test.cpp b/rosen/test/render_service/render_service_base/unittest/luminance/rs_luminance_control_test.cpp new file mode 100644 index 0000000000..1928de09ed --- /dev/null +++ b/rosen/test/render_service/render_service_base/unittest/luminance/rs_luminance_control_test.cpp @@ -0,0 +1,82 @@ +/* + * 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 + +#include "luminance/rs_luminance_control.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS::Rosen { +class RSLuminanceControlTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void RSLuminanceControlTest::SetUpTestCase() {} +void RSLuminanceControlTest::TearDownTestCase() {} +void RSLuminanceControlTest::SetUp() {} +void RSLuminanceControlTest::TearDown() {} + +/** + * @tc.name: LuminanceControl001 + * @tc.desc: Test LuminanceControl class members + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(RSLuminanceControlTest, LuminanceControl001, TestSize.Level1) +{ + ScreenId screenId{}; + int32_t mode{}; + uint32_t level{}; + auto& luminCtrl = RSLuminanceControl::Get(); + luminCtrl.Init(); + luminCtrl.DimmingIncrease(screenId); + std::ignore = luminCtrl.IsDimmingOn(screenId); + std::ignore = luminCtrl.IsHdrOn(screenId); + std::ignore = luminCtrl.IsNeedUpdateLuminance(screenId); + std::ignore = luminCtrl.GetHdrTmoNits(screenId, mode); + std::ignore = luminCtrl.GetHdrDisplayNits(screenId); + std::ignore = luminCtrl.GetHdrBrightnessRatio(screenId, mode); + std::ignore = luminCtrl.GetNewHdrLuminance(screenId); + luminCtrl.SetNowHdrLuminance(screenId, level); + luminCtrl.SetSdrLuminance(screenId, level); + luminCtrl.SetHdrStatus(screenId, false); + ASSERT_NE((&luminCtrl), nullptr); +} + +/** + * @tc.name: LuminanceControl002 + * @tc.desc: Test LuminanceControl class members + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(RSLuminanceControlTest, LuminanceControl002, TestSize.Level1) +{ + auto& luminCtrl = RSLuminanceControl::Get(); + std::ignore = luminCtrl.LoadLibrary(); + std::ignore = luminCtrl.LoadStatusControl(); + std::ignore = luminCtrl.LoadLumControl(); + std::ignore = luminCtrl.LoadTmoControl(); + luminCtrl.extLibHandle_ = nullptr; + std::ignore = luminCtrl.LoadTmoControl(); + luminCtrl.CloseLibrary(); + ASSERT_NE((&luminCtrl), nullptr); +} +} // namespace OHOS::Rosen \ No newline at end of file From 9fcb7c2472eba1197b246cbd36346a778f22cd67 Mon Sep 17 00:00:00 2001 From: LeesonWong Date: Sat, 29 Jun 2024 14:35:07 +0800 Subject: [PATCH 114/247] Test cases for rs_image_cache.cpp Signed-off-by: w30027672 --- .../render_service_base/test/unittest/render/BUILD.gn | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rosen/modules/render_service_base/test/unittest/render/BUILD.gn b/rosen/modules/render_service_base/test/unittest/render/BUILD.gn index 8159dc630e..ad2114cc9d 100644 --- a/rosen/modules/render_service_base/test/unittest/render/BUILD.gn +++ b/rosen/modules/render_service_base/test/unittest/render/BUILD.gn @@ -12,12 +12,14 @@ # limitations under the License. import("//build/test.gni") +import("//foundation/graphic/graphic_2d/graphic_config.gni") -graphic_2d_root = "//foundation/graphic/graphic_2d" +module_output_path = "graphic_2d/rosen/modules/render_service_base" third_party_path = "//third_party" -window_base_path = "//foundation/window/window_manager" ohos_unittest("RSRenderTest") { + module_out_path = module_output_path + sources = [ "rs_image_cache_test.cpp" ] configs = [ ":rs_render_test_config" ] From 8b4c396e154e49cc35f88cc9e2ab44380803ab18 Mon Sep 17 00:00:00 2001 From: 15549494042 Date: Sat, 29 Jun 2024 14:36:03 +0800 Subject: [PATCH 115/247] add pointer color picker ipc interface Singed-off-by:dongzhengkuan@huawei.com Signed-off-by: 15549494042 --- .../pipeline/rs_render_service_connection.cpp | 35 +++++++ .../pipeline/rs_render_service_connection.h | 8 ++ .../rs_render_service_connection_stub.cpp | 38 ++++++++ .../ohos/rs_irender_service_connection.h | 8 ++ ...er_service_connection_ipc_interface_code.h | 4 + .../transaction/rs_render_service_client.h | 10 ++ .../darwin/rs_render_service_client.cpp | 20 ++++ .../ohos/rs_render_service_client.cpp | 58 ++++++++++++ .../rs_render_service_connection_proxy.cpp | 91 +++++++++++++++++++ .../ohos/rs_render_service_connection_proxy.h | 8 ++ .../windows/rs_render_service_client.cpp | 20 ++++ .../core/transaction/rs_interfaces.cpp | 32 +++++++ .../core/transaction/rs_interfaces.h | 8 ++ 13 files changed, 340 insertions(+) diff --git a/rosen/modules/render_service/core/pipeline/rs_render_service_connection.cpp b/rosen/modules/render_service/core/pipeline/rs_render_service_connection.cpp index cde79b808d..ea291c9626 100644 --- a/rosen/modules/render_service/core/pipeline/rs_render_service_connection.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_render_service_connection.cpp @@ -44,6 +44,7 @@ #include "pipeline/rs_uifirst_manager.h" #include "pipeline/rs_uni_render_judgement.h" #include "pipeline/rs_uni_ui_capture.h" +#include "pipeline/rs_pointer_render_manager.h" #include "pixel_map_from_surface.h" #include "platform/common/rs_log.h" #include "platform/common/rs_system_properties.h" @@ -477,6 +478,40 @@ bool RSRenderServiceConnection::Set2DRenderCtrl(bool enable) } #endif +int32_t RSRenderServiceConnection::SetPointerColorInversionConfig(float darkBuffer, + float brightBuffer, int64_t interval) +{ + std::lock_guard lock(mutex_); + RSPointerRenderManager::GetInstance().SetPointerColorInversionConfig(darkBuffer, brightBuffer, interval); + return StatusCode::SUCCESS; +} + +int32_t RSRenderServiceConnection::SetPointerColorInversionEnabled(bool enable) +{ + std::lock_guard lock(mutex_); + RSPointerRenderManager::GetInstance().SetPointerColorInversionEnabled(enable); + return StatusCode::SUCCESS; +} + +int32_t RSRenderServiceConnection::RegisterPointerLuminanceChangeCallback( + sptr callback) +{ + std::lock_guard lock(mutex_); + if (!callback) { + RS_LOGE("RSRenderServiceConnection::RegisterPointerLuminanceChangeCallback: callback is nullptr"); + return StatusCode::INVALID_ARGUMENTS; + } + RSPointerRenderManager::GetInstance().RegisterPointerLuminanceChangeCallback(remotePid_, callback); + return StatusCode::SUCCESS; +} + +int32_t RSRenderServiceConnection::UnRegisterPointerLuminanceChangeCallback() +{ + std::lock_guard lock(mutex_); + RSPointerRenderManager::GetInstance().UnRegisterPointerLuminanceChangeCallback(remotePid_); + return StatusCode::SUCCESS; +} + void RSRenderServiceConnection::RemoveVirtualScreen(ScreenId id) { std::lock_guard lock(mutex_); diff --git a/rosen/modules/render_service/core/pipeline/rs_render_service_connection.h b/rosen/modules/render_service/core/pipeline/rs_render_service_connection.h index d809f4817a..46c5e16407 100644 --- a/rosen/modules/render_service/core/pipeline/rs_render_service_connection.h +++ b/rosen/modules/render_service/core/pipeline/rs_render_service_connection.h @@ -110,6 +110,14 @@ private: void RemoveVirtualScreen(ScreenId id) override; + int32_t SetPointerColorInversionConfig(float darkBuffer, float brightBuffer, int64_t interval) override; + + int32_t SetPointerColorInversionEnabled(bool enable) override; + + int32_t RegisterPointerLuminanceChangeCallback(sptr callback) override; + + int32_t UnRegisterPointerLuminanceChangeCallback() override; + int32_t SetScreenChangeCallback(sptr callback) override; void SetScreenActiveMode(ScreenId id, uint32_t modeId) override; diff --git a/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp b/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp index 5a58bb16c5..7c290dfe9b 100644 --- a/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp +++ b/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp @@ -149,6 +149,10 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SHOW_REFRESH_RATE_ENABLED), static_cast(RSIRenderServiceConnectionInterfaceCode::MARK_POWER_OFF_NEED_PROCESS_ONE_FRAME), static_cast(RSIRenderServiceConnectionInterfaceCode::DISABLE_RENDER_CONTROL_SCREEN), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_POINTER_COLOR_INVERSION_CONFIG), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_POINTER_COLOR_INVERSION_ENABLED), + static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_POINTER_LUMINANCE_CALLBACK), + static_cast(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_POINTER_LUMINANCE_CALLBACK), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_POWER_STATUS), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_BACK_LIGHT), static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_ACTIVE_MODE), @@ -419,6 +423,40 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( reply.WriteInt32(status); break; } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_POINTER_COLOR_INVERSION_CONFIG): { + float darkBuffer = data.ReadFloat(); + float brightBuffer = data.ReadFloat(); + int64_t interval = data.ReadInt64(); + int32_t status = SetPointerColorInversionConfig(darkBuffer, brightBuffer, interval); + reply.WriteInt32(status); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_POINTER_COLOR_INVERSION_ENABLED): { + bool enable = data.ReadBool(); + int32_t status = SetPointerColorInversionEnabled(enable); + reply.WriteInt32(status); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_POINTER_LUMINANCE_CALLBACK): { + auto remoteObject = data.ReadRemoteObject(); + if (remoteObject == nullptr) { + ret = ERR_NULL_OBJECT; + break; + } + sptr cb = iface_cast(remoteObject); + if (cb == nullptr) { + ret = ERR_NULL_OBJECT; + break; + } + int32_t status = RegisterPointerLuminanceChangeCallback(cb); + reply.WriteInt32(status); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_POINTER_LUMINANCE_CALLBACK): { + int32_t status = UnRegisterPointerLuminanceChangeCallback(); + reply.WriteInt32(status); + break; + } case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_ACTIVE_MODE): { ScreenId id = data.ReadUint64(); uint32_t modeId = data.ReadUint32(); diff --git a/rosen/modules/render_service_base/include/platform/ohos/rs_irender_service_connection.h b/rosen/modules/render_service_base/include/platform/ohos/rs_irender_service_connection.h index 0aff87e4e7..41d17fb4e8 100644 --- a/rosen/modules/render_service_base/include/platform/ohos/rs_irender_service_connection.h +++ b/rosen/modules/render_service_base/include/platform/ohos/rs_irender_service_connection.h @@ -100,6 +100,14 @@ public: virtual void RemoveVirtualScreen(ScreenId id) = 0; + virtual int32_t SetPointerColorInversionConfig(float darkBuffer, float brightBuffer, int64_t interval) = 0; + + virtual int32_t SetPointerColorInversionEnabled(bool enable) = 0; + + virtual int32_t RegisterPointerLuminanceChangeCallback(sptr callback) = 0; + + virtual int32_t UnRegisterPointerLuminanceChangeCallback() = 0; + virtual int32_t SetScreenChangeCallback(sptr callback) = 0; virtual void SetScreenActiveMode(ScreenId id, uint32_t modeId) = 0; diff --git a/rosen/modules/render_service_base/include/platform/ohos/rs_irender_service_connection_ipc_interface_code.h b/rosen/modules/render_service_base/include/platform/ohos/rs_irender_service_connection_ipc_interface_code.h index ec4d66ad3d..f2a192afee 100644 --- a/rosen/modules/render_service_base/include/platform/ohos/rs_irender_service_connection_ipc_interface_code.h +++ b/rosen/modules/render_service_base/include/platform/ohos/rs_irender_service_connection_ipc_interface_code.h @@ -37,6 +37,10 @@ enum class RSIRenderServiceConnectionInterfaceCode : CodeUnderlyingType { #ifdef RS_ENABLE_VK SET_2D_RENDER_CTRL, #endif + SET_POINTER_COLOR_INVERSION_CONFIG, + SET_POINTER_COLOR_INVERSION_ENABLED, + REGISTER_POINTER_LUMINANCE_CALLBACK, + UNREGISTER_POINTER_LUMINANCE_CALLBACK, REMOVE_VIRTUAL_SCREEN, SET_SCREEN_CHANGE_CALLBACK, SET_SCREEN_ACTIVE_MODE, diff --git a/rosen/modules/render_service_base/include/transaction/rs_render_service_client.h b/rosen/modules/render_service_base/include/transaction/rs_render_service_client.h index 56dc98da0b..bdc54d120b 100644 --- a/rosen/modules/render_service_base/include/transaction/rs_render_service_client.h +++ b/rosen/modules/render_service_base/include/transaction/rs_render_service_client.h @@ -29,6 +29,7 @@ #include "ipc_callbacks/buffer_available_callback.h" #include "ipc_callbacks/iapplication_agent.h" #include "ipc_callbacks/screen_change_callback.h" +#include "ipc_callbacks/pointer_luminance_change_callback.h" #include "ipc_callbacks/surface_capture_callback.h" #include "memory/rs_memory_graphic.h" #ifdef NEW_RENDER_CONTEXT @@ -55,6 +56,7 @@ namespace OHOS { namespace Rosen { // normal callback functor for client users. using ScreenChangeCallback = std::function; +using PointerLuminanceChangeCallback = std::function; using BufferAvailableCallback = std::function; using BufferClearCallback = std::function; using OcclusionChangeCallback = std::function)>; @@ -158,6 +160,14 @@ public: void RemoveVirtualScreen(ScreenId id); + int32_t SetPointerColorInversionConfig(float darkBuffer, float brightBuffer, int64_t interval); + + int32_t SetPointerColorInversionEnabled(bool enable); + + int32_t RegisterPointerLuminanceChangeCallback(const PointerLuminanceChangeCallback &callback); + + int32_t UnRegisterPointerLuminanceChangeCallback(); + int32_t SetScreenChangeCallback(const ScreenChangeCallback& callback); #ifndef ROSEN_ARKUI_X diff --git a/rosen/modules/render_service_base/src/platform/darwin/rs_render_service_client.cpp b/rosen/modules/render_service_base/src/platform/darwin/rs_render_service_client.cpp index e15e113303..ab5a3d21a9 100644 --- a/rosen/modules/render_service_base/src/platform/darwin/rs_render_service_client.cpp +++ b/rosen/modules/render_service_base/src/platform/darwin/rs_render_service_client.cpp @@ -154,6 +154,26 @@ void RSRenderServiceClient::RemoveVirtualScreen(ScreenId id) { } +int32_t RSRenderServiceClient::SetPointerColorInversionConfig(float darkBuffer, float brightBuffer, int64_t interval) +{ + return 0; +} + +int32_t RSRenderServiceClient::SetPointerColorInversionEnabled(bool enable) +{ + return 0; +} + +int32_t RSRenderServiceClient::RegisterPointerLuminanceChangeCallback(const PointerLuminanceChangeCallback &callback) +{ + return 0; +} + +int32_t RSRenderServiceClient::UnRegisterPointerLuminanceChangeCallback() +{ + return 0; +} + int32_t RSRenderServiceClient::SetScreenChangeCallback(const ScreenChangeCallback &callback) { return 0; diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_client.cpp b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_client.cpp index 2dfb7bc0f8..29f258f6db 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_client.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_client.cpp @@ -27,6 +27,7 @@ #include "command/rs_node_showing_command.h" #include "ipc_callbacks/rs_surface_occlusion_change_callback_stub.h" #include "ipc_callbacks/screen_change_callback_stub.h" +#include "ipc_callbacks/pointer_luminance_callback_stub.h" #include "ipc_callbacks/surface_capture_callback_stub.h" #include "ipc_callbacks/buffer_available_callback_stub.h" #include "ipc_callbacks/buffer_clear_callback_stub.h" @@ -380,6 +381,63 @@ void RSRenderServiceClient::RemoveVirtualScreen(ScreenId id) renderService->RemoveVirtualScreen(id); } +int32_t RSRenderServiceClient::SetPointerColorInversionConfig(float darkBuffer, float brightBuffer, int64_t interval) +{ + auto renderService = RSRenderServiceConnectHub::GetRenderService(); + if (renderService == nullptr) { + return RENDER_SERVICE_NULL; + } + + return renderService->SetPointerColorInversionConfig(darkBuffer, brightBuffer, interval); +} + +int32_t RSRenderServiceClient::SetPointerColorInversionEnabled(bool enable) +{ + auto renderService = RSRenderServiceConnectHub::GetRenderService(); + if (renderService == nullptr) { + return RENDER_SERVICE_NULL; + } + + return renderService->SetPointerColorInversionEnabled(enable); +} + +class CustomPointerLuminanceChangeCallback : public RSPointerLuminanceChangeCallbackStub +{ +public: + explicit CustomPointerLuminanceChangeCallback(const PointerLuminanceChangeCallback &callback) : cb_(callback) {} + ~CustomPointerLuminanceChangeCallback() override {}; + + void OnPointerLuminanceChanged(int32_t brightness) override + { + if (cb_ != nullptr) { + cb_(brightness); + } + } + +private: + PointerLuminanceChangeCallback cb_; +}; + +int32_t RSRenderServiceClient::RegisterPointerLuminanceChangeCallback(const PointerLuminanceChangeCallback &callback) +{ + auto renderService = RSRenderServiceConnectHub::GetRenderService(); + if (renderService == nullptr) { + return RENDER_SERVICE_NULL; + } + + sptr cb = new CustomPointerLuminanceChangeCallback(callback); + return renderService->RegisterPointerLuminanceChangeCallback(cb); +} + +int32_t RSRenderServiceClient::UnRegisterPointerLuminanceChangeCallback() +{ + auto renderService = RSRenderServiceConnectHub::GetRenderService(); + if (renderService == nullptr) { + return RENDER_SERVICE_NULL; + } + return renderService->UnRegisterPointerLuminanceChangeCallback(); +} + class CustomScreenChangeCallback : public RSScreenChangeCallbackStub { public: diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.cpp b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.cpp index 4a26fb9592..17c081e3ae 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.cpp @@ -552,6 +552,97 @@ void RSRenderServiceConnectionProxy::RemoveVirtualScreen(ScreenId id) } } +int32_t RSRenderServiceConnectionProxy::SetPointerColorInversionConfig(float darkBuffer, + float brightBuffer, int64_t interval) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + return WRITE_PARCEL_ERR; + } + option.SetFlags(MessageOption::TF_ASYNC); + data.WriteFloat(darkBuffer); + data.WriteFloat(brightBuffer); + data.WriteInt64(interval); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_POINTER_COLOR_INVERSION_CONFIG); + int32_t err = Remote()->SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSRenderServiceConnectionProxy::SetPointerColorInversionConfig: Send Request err."); + return RS_CONNECTION_ERROR; + } + int32_t result = reply.ReadInt32(); + return result; +} + +int32_t RSRenderServiceConnectionProxy::SetPointerColorInversionEnabled(bool enable) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + return WRITE_PARCEL_ERR; + } + option.SetFlags(MessageOption::TF_ASYNC); + data.WriteBool(enable); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_POINTER_COLOR_INVERSION_ENABLED); + int32_t err = Remote()->SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSRenderServiceConnectionProxy::DisableCursorInvert: Send Request err."); + return RS_CONNECTION_ERROR; + } + int32_t result = reply.ReadInt32(); + return result; +} + +int32_t RSRenderServiceConnectionProxy::RegisterPointerLuminanceChangeCallback( + sptr callback) +{ + if (callback == nullptr) { + ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterPointerLuminanceChangeCallback: callback is nullptr."); + return INVALID_ARGUMENTS; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + return WRITE_PARCEL_ERR; + } + + option.SetFlags(MessageOption::TF_ASYNC); + data.WriteRemoteObject(callback->AsObject()); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_POINTER_LUMINANCE_CALLBACK); + int32_t err = Remote()->SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterPointerLuminanceChangeCallback: Send Request err."); + return RS_CONNECTION_ERROR; + } + int32_t result = reply.ReadInt32(); + return result; +} + +int32_t RSRenderServiceConnectionProxy::UnRegisterPointerLuminanceChangeCallback() +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + return WRITE_PARCEL_ERR; + } + option.SetFlags(MessageOption::TF_ASYNC); + uint32_t code = static_cast( + RSIRenderServiceConnectionInterfaceCode::UNREGISTER_POINTER_LUMINANCE_CALLBACK); + int32_t err = Remote()->SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSRenderServiceConnectionProxy::UnRegisterPointerLuminanceChangeCallback: Send Request err."); + return RS_CONNECTION_ERROR; + } + int32_t result = reply.ReadInt32(); + return result; +} + int32_t RSRenderServiceConnectionProxy::SetScreenChangeCallback(sptr callback) { if (callback == nullptr) { diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.h b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.h index c945770454..897dbebcfe 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.h +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.h @@ -79,6 +79,14 @@ public: #endif void RemoveVirtualScreen(ScreenId id) override; + int32_t SetPointerColorInversionConfig(float darkBuffer, float brightBuffer, int64_t interval) override; + + int32_t SetPointerColorInversionEnabled(bool enable) override; + + int32_t RegisterPointerLuminanceChangeCallback(sptr callback) override; + + int32_t UnRegisterPointerLuminanceChangeCallback() override; + int32_t SetScreenChangeCallback(sptr callback) override; void SetScreenActiveMode(ScreenId id, uint32_t modeId) override; diff --git a/rosen/modules/render_service_base/src/platform/windows/rs_render_service_client.cpp b/rosen/modules/render_service_base/src/platform/windows/rs_render_service_client.cpp index d24561015f..6b7192a1bf 100644 --- a/rosen/modules/render_service_base/src/platform/windows/rs_render_service_client.cpp +++ b/rosen/modules/render_service_base/src/platform/windows/rs_render_service_client.cpp @@ -154,6 +154,26 @@ void RSRenderServiceClient::RemoveVirtualScreen(ScreenId id) { } +int32_t RSRenderServiceClient::SetPointerColorInversionConfig(float darkBuffer, float brightBuffer, int64_t interval) +{ + return 0; +} + +int32_t RSRenderServiceClient::SetPointerColorInversionEnabled(bool enable) +{ + return 0; +} + +int32_t RSRenderServiceClient::RegisterPointerLuminanceChangeCallback(const PointerLuminanceChangeCallback &callback) +{ + return 0; +} + +int32_t RSRenderServiceClient::UnRegisterPointerLuminanceChangeCallback() +{ + return 0; +} + int32_t RSRenderServiceClient::SetScreenChangeCallback(const ScreenChangeCallback &callback) { return 0; diff --git a/rosen/modules/render_service_client/core/transaction/rs_interfaces.cpp b/rosen/modules/render_service_client/core/transaction/rs_interfaces.cpp index a6c89b8be2..43585fa30d 100644 --- a/rosen/modules/render_service_client/core/transaction/rs_interfaces.cpp +++ b/rosen/modules/render_service_client/core/transaction/rs_interfaces.cpp @@ -109,6 +109,38 @@ void RSInterfaces::RemoveVirtualScreen(ScreenId id) renderServiceClient_->RemoveVirtualScreen(id); } +int32_t RSInterfaces::SetPointerColorInversionConfig(float darkBuffer, float brightBuffer, int64_t interval) +{ + if (renderServiceClient_ == nullptr) { + return StatusCode::RENDER_SERVICE_NULL; + } + return renderServiceClient_->SetPointerColorInversionConfig(darkBuffer, brightBuffer, interval); +} + +int32_t RSInterfaces::SetPointerColorInversionEnabled(bool enable) +{ + if (renderServiceClient_ == nullptr) { + return StatusCode::RENDER_SERVICE_NULL; + } + return renderServiceClient_->SetPointerColorInversionEnabled(enable); +} + +int32_t RSInterfaces::RegisterPointerLuminanceChangeCallback(const PointerLuminanceChangeCallback &callback) +{ + if (renderServiceClient_ == nullptr) { + return StatusCode::RENDER_SERVICE_NULL; + } + return renderServiceClient_->RegisterPointerLuminanceChangeCallback(callback); +} + +int32_t RSInterfaces::UnRegisterPointerLuminanceChangeCallback() +{ + if (renderServiceClient_ == nullptr) { + return StatusCode::RENDER_SERVICE_NULL; + } + return renderServiceClient_->UnRegisterPointerLuminanceChangeCallback(); +} + int32_t RSInterfaces::SetScreenChangeCallback(const ScreenChangeCallback &callback) { return renderServiceClient_->SetScreenChangeCallback(callback); diff --git a/rosen/modules/render_service_client/core/transaction/rs_interfaces.h b/rosen/modules/render_service_client/core/transaction/rs_interfaces.h index eeaac12140..90ec759e43 100644 --- a/rosen/modules/render_service_client/core/transaction/rs_interfaces.h +++ b/rosen/modules/render_service_client/core/transaction/rs_interfaces.h @@ -75,6 +75,14 @@ public: void RemoveVirtualScreen(ScreenId id); + int32_t SetPointerColorInversionConfig(float darkBuffer, float brightBuffer, int64_t interval); + + int32_t SetPointerColorInversionEnabled(bool enable); + + int32_t RegisterPointerLuminanceChangeCallback(const PointerLuminanceChangeCallback &callback); + + int32_t UnRegisterPointerLuminanceChangeCallback(); + int32_t SetScreenChangeCallback(const ScreenChangeCallback &callback); bool TakeSurfaceCapture(std::shared_ptr node, std::shared_ptr callback, From 06cb82d59a2d2e93e82c954ad9fb38bf2cd88fc2 Mon Sep 17 00:00:00 2001 From: 15549494042 Date: Sat, 29 Jun 2024 14:46:48 +0800 Subject: [PATCH 116/247] add pointer color picker ipc interface Singed-off-by:dongzhengkuan@huawei.com Signed-off-by: 15549494042 --- .../core/pipeline/rs_pointer_render_manager.cpp | 2 +- .../src/ipc_callbacks/pointer_luminance_callback_stub.cpp | 4 +--- .../src/ipc_callbacks/pointer_luminance_callback_stub.h | 3 +++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp index fcc526f8d4..bd875291e5 100644 --- a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp @@ -134,7 +134,7 @@ bool RSPointerRenderManager::CheckColorPickerEnabled() auto tmp = std::chrono::duration_cast(timeNow.time_since_epoch()); auto time = tmp.count() - lastColorPickerTime_; if (time < colorSamplingInterval_) { - return; + return false; } bool exists = false; diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.cpp index 828a36c959..a199ca7398 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.cpp +++ b/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.cpp @@ -20,9 +20,7 @@ namespace Rosen { int RSPointerLuminanceChangeCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { - RSInterfaceCodeSecurityManager securityManager = - RSInterfaceCodeSecurityManager::CreateInstance(); - if (!securityManager.IsInterfaceCodeAccessible(code)) { + if (!securityManager_.IsInterfaceCodeAccessible(code)) { RS_LOGE("RSPointerLuminanceChangeCallbackStub::OnRemoteRequest no permission to access codeID=%{public}u", code); return ERR_INVALID_STATE; diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.h b/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.h index 1de54aacef..1dd2fcf9e9 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.h +++ b/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.h @@ -30,6 +30,9 @@ public: ~RSPointerLuminanceChangeCallbackStub() = default; int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; +private: + const RSInterfaceCodeSecurityManager securityManager_ = + RSInterfaceCodeSecurityManager::CreateInstance(); }; } // namespace Rosen } // namespace OHOS From 22e2990c36d2701065b08706ee8364067e25a3d0 Mon Sep 17 00:00:00 2001 From: lvmengyu Date: Sat, 29 Jun 2024 14:54:44 +0800 Subject: [PATCH 117/247] fix tdd crash Signed-off-by: lvmengyu Change-Id: I41cae0d8dc9f3c3afd4c386b33154f9579730c4c --- .../unittest/ui/rs_node_test.cpp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/rosen/test/render_service/render_service_client/unittest/ui/rs_node_test.cpp b/rosen/test/render_service/render_service_client/unittest/ui/rs_node_test.cpp index 38811afaef..6ca95dee6c 100644 --- a/rosen/test/render_service/render_service_client/unittest/ui/rs_node_test.cpp +++ b/rosen/test/render_service/render_service_client/unittest/ui/rs_node_test.cpp @@ -5106,24 +5106,6 @@ HWTEST_F(RSNodeTest, SetBounds001, TestSize.Level1) EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().w_, 1.f)); } -/** - * @tc.name: SetSandBox - * @tc.desc: test results of SetSandBox - * @tc.type: FUNC - * @tc.require: issueI9KAZH - */ -HWTEST_F(RSNodeTest, SetSandBox, TestSize.Level1) -{ - auto rsNode = RSCanvasNode::Create(); - std::optional parentPosition; - rsNode->SetSandBox(parentPosition); - - Vector2f newPosition(1.0f, 2.0f); - parentPosition = newPosition; - rsNode->SetSandBox(parentPosition); - EXPECT_EQ(parentPosition, newPosition); -} - /** * @tc.name: SetPivotZ * @tc.desc: test results of SetPivotZ From 3d76f503578873dac070ffce04ab2708086a9907 Mon Sep 17 00:00:00 2001 From: 15549494042 Date: Sat, 29 Jun 2024 15:05:57 +0800 Subject: [PATCH 118/247] add pointer color picker ipc interface Singed-off-by:dongzhengkuan@huawei.com Signed-off-by: 15549494042 --- .../src/ipc_callbacks/pointer_luminance_callback_stub.cpp | 4 +++- .../src/ipc_callbacks/pointer_luminance_callback_stub.h | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.cpp index a199ca7398..828a36c959 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.cpp +++ b/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.cpp @@ -20,7 +20,9 @@ namespace Rosen { int RSPointerLuminanceChangeCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { - if (!securityManager_.IsInterfaceCodeAccessible(code)) { + RSInterfaceCodeSecurityManager securityManager = + RSInterfaceCodeSecurityManager::CreateInstance(); + if (!securityManager.IsInterfaceCodeAccessible(code)) { RS_LOGE("RSPointerLuminanceChangeCallbackStub::OnRemoteRequest no permission to access codeID=%{public}u", code); return ERR_INVALID_STATE; diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.h b/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.h index 1dd2fcf9e9..1de54aacef 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.h +++ b/rosen/modules/render_service_base/src/ipc_callbacks/pointer_luminance_callback_stub.h @@ -30,9 +30,6 @@ public: ~RSPointerLuminanceChangeCallbackStub() = default; int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; -private: - const RSInterfaceCodeSecurityManager securityManager_ = - RSInterfaceCodeSecurityManager::CreateInstance(); }; } // namespace Rosen } // namespace OHOS From 48fc1339c0820803e13b760619a7df85e99838a2 Mon Sep 17 00:00:00 2001 From: siyuan Date: Sat, 29 Jun 2024 15:06:34 +0800 Subject: [PATCH 119/247] first commit Signed-off-by: siyuan --- .../render/rs_attraction_effect_filter.h | 7 ++- .../render/rs_attraction_effect_filter.cpp | 57 ++++++++++++------- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/rosen/modules/render_service_base/include/render/rs_attraction_effect_filter.h b/rosen/modules/render_service_base/include/render/rs_attraction_effect_filter.h index ff2668e5db..9e4e473abf 100644 --- a/rosen/modules/render_service_base/include/render/rs_attraction_effect_filter.h +++ b/rosen/modules/render_service_base/include/render/rs_attraction_effect_filter.h @@ -53,15 +53,15 @@ public: void CalculateDeltaXAndDeltaY(const Drawing::Point windowCtrlPoints[], const Drawing::Point &pointDst, float &deltaX, float &deltaY, int location); void CalculateBezierVelList(const std::vector &velocityList, - std::vector &velocityCtrl, float location, bool isBelowTarget); + std::vector &velocityCtrl, float location); float CalculateCubic(float p1, float p2, float t); bool IsWithinThreshold(const float left, const float right, const float threshold); float BinarySearch(float targetX, const Drawing::Point &p1, const Drawing::Point &p2); std::vector CalculateCubicsCtrlPointOffset(const std::vector controlPointOfVertex); - std::vector CreateIndexSequence(bool isBelowTarget, float location); + std::vector CreateIndexSequence(float location); std::vector CalculateCubicsCtrlPoint(std::vector controlPointOfVertex, - const Drawing::Point points[], float location, bool isBelowTarget, bool isFirstCtrl); + const Drawing::Point points[], float location, bool isFirstCtrl); Drawing::Point LerpPoint(const Drawing::Point& firstPoint, const Drawing::Point& secondPoint, float firstFactor, float secondFactor); @@ -84,6 +84,7 @@ private: float canvasWidth_ = 0.0f; float canvasHeight_ = 0.0f; RectI attractionDirtyRegion_ = {0, 0, 0, 0}; + bool isBelowTarget_ = false; friend class RSMarshallingHelper; }; diff --git a/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp b/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp index dcd8b716c1..e2a52f7a78 100644 --- a/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp +++ b/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp @@ -137,13 +137,13 @@ std::vector RSAttractionEffectFilter::CalculateCubicsCtrlPointOf return pathList; } -std::vector RSAttractionEffectFilter::CreateIndexSequence(bool isBelowTarget, float location) +std::vector RSAttractionEffectFilter::CreateIndexSequence(float location) { float locationValue = 1.0f; float tolerance = 0.001f; // Select the parameter index of the window control point according to the window position. // 0 to 11 indicate the index of the window control point, which is rotated clockwise. - if (!isBelowTarget) { + if (!isBelowTarget_) { return IsWithinThreshold(location, locationValue, tolerance) ? std::vector{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 } : std::vector{ 3, 2, 1, 0, 11, 10, 9, 8, 7, 6, 5, 4 }; @@ -158,18 +158,17 @@ std::vector RSAttractionEffectFilter::CalculateCubicsCtrlPoint( std::vector controlPointOfVertex, const Drawing::Point points[], // Array instead of vector float location, // Determine whether the flag on the left or right is used. - bool isBelowTarget, // Determine whether the upper or lower flag is used. bool isFirstCtrl) { int pointNum = 12; std::vector pathList = CalculateCubicsCtrlPointOffset(controlPointOfVertex); - std::vector indice = CreateIndexSequence(isBelowTarget, location); + std::vector indice = CreateIndexSequence(location); std::vector pathCtrlPointList(pointNum, Drawing::Point(0.0f, 0.0f)); for (int i = 0; i < pointNum; i++) { int index = indice[i]; - if (!isBelowTarget) { + if (!isBelowTarget_) { pathCtrlPointList[i] = pathList[index] + (isFirstCtrl ? points[i] : points[0]); } else { float px = isFirstCtrl ? points[i].GetX() : points[0].GetX(); @@ -188,8 +187,7 @@ std::vector RSAttractionEffectFilter::CalculateCubicsCtrlPoint( } void RSAttractionEffectFilter::CalculateBezierVelList(const std::vector &velocityList, - std::vector &velocityCtrl, - float location, bool isBelowTarget) + std::vector &velocityCtrl, float location) { std::vector curveVelList; Drawing::Point topVelocity = velocityList[0]; @@ -199,15 +197,20 @@ void RSAttractionEffectFilter::CalculateBezierVelList(const std::vector indice = CreateIndexSequence(isBelowTarget, location); + std::vector indice = CreateIndexSequence(location); int pointNum = 12; for (int i = 0; i < pointNum; i++) { int index = indice[i]; @@ -288,11 +291,16 @@ void RSAttractionEffectFilter::CalculateDeltaXAndDeltaY(const Drawing::Point win std::vector RSAttractionEffectFilter::CalculateUpperCtrlPointOfVertex(float deltaX, float deltaY, float width, float height, int location) { + // Different regression parameters are used for different scenarios // Coordinates of the upper control point of the curve:(k1 * width + k2 * deltaX, k3 * height + k4 * deltaY) Drawing::Point topLeft = { (0.016f * width - 0.08f * deltaX) * location, 0.464f * height + 0.40f * deltaY }; - Drawing::Point topRight = { (-1.147f * width - 0.016f * deltaX) * location, -0.187f * height + 0.30f * deltaY }; Drawing::Point bottomLeft = { (-0.15f * width - 0.075f * deltaX) * location, 0.0f * height + 0.2f * deltaY }; - Drawing::Point bottomRight = { (-0.84f * width - 0.2f * deltaX) * location, -0.859f * height - 0.2f * deltaY }; + if (!isBelowTarget_) { + topLeft = { (-0.100f * width - 0.008f * deltaX) * location, 0.008f * height + 0.085f * deltaY }; + bottomLeft = { (-0.008f * width - 0.008f * deltaX) * location, 0.0f * height - 0.008f * deltaY }; + } + Drawing::Point topRight = { (-1.147f * width - 0.016f * deltaX) * location, -0.187f * height + 0.30f * deltaY }; + Drawing::Point bottomRight = { (-0.848f * width - 0.2f * deltaX) * location, -0.859f * height - 0.2f * deltaY }; std::vector upperControlPoint = { topLeft, topRight, bottomLeft, bottomRight }; return upperControlPoint; } @@ -301,11 +309,18 @@ std::vector RSAttractionEffectFilter::CalculateLowerCtrlPointOfV float width, float height, int location) { float inverseWidth = (width >= 1.0f) ? (1.0f / width) : 1.0f; + // Different regression parameters are used for different scenarios // Coordinates of the lower control point of the curve:(m1*(deltaX * height/width - width)), m2 * deltaY) Drawing::Point topLeft = { (0.3f * (deltaX * height * inverseWidth - width)) * location, -0.20f * deltaY }; Drawing::Point topRight = { (0.45f * (deltaX * height * inverseWidth - width)) * location, -0.30f * deltaY }; Drawing::Point bottomLeft = { (0.15f * (deltaX * height * inverseWidth - width)) * location, -0.20f * deltaY }; Drawing::Point bottomRight = { (0.30f * (deltaX * height * inverseWidth - width)) * location, -0.112f * deltaY }; + if (!isBelowTarget_) { + topLeft = { (0.131f * (deltaX * height * inverseWidth - width)) * location, -0.20f * deltaY }; + topRight = { (0.147f * (deltaX * height * inverseWidth - width)) * location, -0.30f * deltaY }; + bottomLeft = { (0.085f * (deltaX * height * inverseWidth - width)) * location, 0.008f * deltaY }; + bottomRight = { (0.147f * (deltaX * height * inverseWidth - width)) * location, -0.069f * deltaY }; + } std::vector lowerControlPoint = { topLeft, topRight, bottomLeft, bottomRight }; return lowerControlPoint; } @@ -314,7 +329,7 @@ std::vector RSAttractionEffectFilter::CalculateVelocityCtrlPoint { // Cubic Bezier curve with two control points Drawing::Point topVelFirst = { 0.50f, 0.0f }; - Drawing::Point bottomVelFirst = { 0.20f, 0.0f }; + Drawing::Point bottomVelFirst = isBelowTarget_ ? { 0.20f, 0.0f } : { 0.0f, 0.0f }; std::vector velocityCtrlPoint = {topVelFirst, bottomVelFirst}; return velocityCtrlPoint; } @@ -323,7 +338,7 @@ std::vector RSAttractionEffectFilter::CalculateVelocityCtrlPoint { // Cubic Bezier curve with two control points Drawing::Point topVelSecond = { 0.50f, 1.0f }; - Drawing::Point bottomVelSecond = { 0.20f, 1.0f }; + Drawing::Point bottomVelSecond = isBelowTarget_ ? { 0.20f, 1.0f } : { 0.0f, 1.0f }; std::vector velocityCtrlPoint = {topVelSecond, bottomVelSecond}; return velocityCtrlPoint; } @@ -372,10 +387,10 @@ void RSAttractionEffectFilter::CalculateWindowStatus(float canvasWidth, float ca // 1.0 indicates that the window is to the right of the target point, // and - 1.0 indicates that the window is to the left. float location = (windowBottomCenter.GetX() > pointDst[0].GetX()) ? 1.0f : -1.0f; - bool isBelowTarget = (windowBottomCenter.GetY() > pointDst[0].GetY()) ? true : false; + bool isBelowTarget_ = (windowBottomCenter.GetY() > pointDst[0].GetY()) ? true : false; - float width = isBelowTarget ? canvasHeight_ : canvasWidth_; - float height = isBelowTarget ? canvasWidth_ : canvasHeight_; + float width = isBelowTarget_ ? canvasHeight_ : canvasWidth_; + float height = isBelowTarget_ ? canvasWidth_ : canvasHeight_; float deltaX = 0.0f; float deltaY = 0.0f; CalculateDeltaXAndDeltaY(windowCtrlPoints, pointDst[0], deltaX, deltaY, location); @@ -388,14 +403,14 @@ void RSAttractionEffectFilter::CalculateWindowStatus(float canvasWidth, float ca std::vector velocityCtrlPointLower = CalculateVelocityCtrlPointLower(); std::vector controlPointListFirst = - CalculateCubicsCtrlPoint(upperControlPointOfVertex, windowCtrlPoints, location, isBelowTarget, true); + CalculateCubicsCtrlPoint(upperControlPointOfVertex, windowCtrlPoints, location, true); std::vector controlPointListSecond = - CalculateCubicsCtrlPoint(lowerControlPointOfVertex, pointDst, location, isBelowTarget, false); + CalculateCubicsCtrlPoint(lowerControlPointOfVertex, pointDst, location, false); std::vector speedListsFirst(pointNum, Drawing::Point(0.0f, 0.0f)); std::vector speedListsSecond(pointNum, Drawing::Point(0.0f, 0.0f)); - CalculateBezierVelList(velocityCtrlPointUpper, speedListsFirst, location, isBelowTarget); - CalculateBezierVelList(velocityCtrlPointLower, speedListsSecond, location, isBelowTarget); + CalculateBezierVelList(velocityCtrlPointUpper, speedListsFirst, location); + CalculateBezierVelList(velocityCtrlPointLower, speedListsSecond, location); for (int i = 0; i < pointNum; ++i) { float speed = BinarySearch(attractionFraction_, speedListsFirst[i], speedListsSecond[i]); From facee830e962f46ce854c6aaa83c9a52be4124e5 Mon Sep 17 00:00:00 2001 From: chuchengcheng Date: Sat, 29 Jun 2024 15:22:00 +0800 Subject: [PATCH 120/247] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=80=86=E5=BA=8F?= =?UTF-8?q?=E9=81=8D=E5=8E=86hwc=E8=8A=82=E7=82=B9=E8=A2=AB=E7=BD=AE?= =?UTF-8?q?=E4=BD=8D=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chuchengcheng Change-Id: I5c856afa5755e446b43cb07216a2a0f80fcd096e --- .../core/pipeline/rs_uni_render_visitor.cpp | 17 +++++++++++------ .../core/pipeline/rs_uni_render_visitor.h | 6 ++++-- .../core/system/rs_system_parameters.cpp | 4 ++-- .../include/pipeline/rs_surface_render_node.h | 11 +++++++++++ 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp index dddc59c7ba..2cbd9f63ff 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp @@ -1827,7 +1827,9 @@ void RSUniRenderVisitor::UpdateHwcNodeInfoForAppNode(RSSurfaceRenderNode& node) if (curSurfaceNode_->GetNeedCollectHwcNode()) { curSurfaceNode_->AddChildHardwareEnabledNode(node.ReinterpretCastTo()); } - node.SetHardwareForcedDisabledState(false); + if (!node.GetHardWareDisabledByReverse()) { + node.SetHardwareForcedDisabledState(false); + } node.SetHardwareForcedDisabledByVisibility(false); node.SetForceHardware(displayNodeRotationChanged_ || isScreenRotationAnimating_); if ((!node.GetForceHardware() && !IsHardwareComposerEnabled()) || @@ -2093,6 +2095,7 @@ void RSUniRenderVisitor::UpdateHwcNodeDirtyRegionAndCreateLayer(std::shared_ptr< } UpdateHwcNodeDirtyRegionForApp(node, hwcNodePtr); hwcNodePtr->SetCalcRectInPrepare(false); + hwcNodePtr->SetHardWareDisabledByReverse(false); hwcNodePtr->SetGlobalZOrder(hwcNodePtr->IsHardwareForcedDisabled() && !hwcNodePtr->GetProtectedLayer() ? -1.f : globalZOrder_++); auto transform = RSUniRenderUtil::GetLayerTransform(*hwcNodePtr, screenInfo_); @@ -2508,7 +2511,8 @@ void RSUniRenderVisitor::PostPrepare(RSRenderNode& node, bool subTreeSkipped) UpdateSubSurfaceNodeRectInSkippedSubTree(node); } if (node.GetRenderProperties().NeedFilter()) { - UpdateHwcNodeEnableByFilterRect(curSurfaceNode_, node.GetOldDirtyInSurface()); + UpdateHwcNodeEnableByFilterRect( + curSurfaceNode_, node.GetOldDirtyInSurface(), NeedPrepareChindrenInReverseOrder(node)); auto globalFilterRect = (node.IsInstanceOf() && !node.FirstFrameHasEffectChildren()) ? GetVisibleEffectDirty(node) : node.GetOldDirtyInSurface(); node.CalVisibleFilterRect(prepareClipRect_); @@ -2620,7 +2624,7 @@ void RSUniRenderVisitor::UpdateHwcNodeRectInSkippedSubTree(const RSRenderNode& r } void RSUniRenderVisitor::CalcHwcNodeEnableByFilterRect( - std::shared_ptr& node, const RectI& filterRect) + std::shared_ptr& node, const RectI& filterRect, bool isReverseOrder) { if (!node) { return; @@ -2631,11 +2635,12 @@ void RSUniRenderVisitor::CalcHwcNodeEnableByFilterRect( RS_OPTIONAL_TRACE_NAME_FMT("hwc debug: name:%s id:%llu disabled by filter rect", node->GetName().c_str(), node->GetId()); node->SetHardwareForcedDisabledState(true); + node->SetHardWareDisabledByReverse(isReverseOrder); } } void RSUniRenderVisitor::UpdateHwcNodeEnableByFilterRect( - std::shared_ptr& node, const RectI& filterRect) + std::shared_ptr& node, const RectI& filterRect, bool isReverseOrder) { if (filterRect.IsEmpty()) { return; @@ -2646,7 +2651,7 @@ void RSUniRenderVisitor::UpdateHwcNodeEnableByFilterRect( return; } for (auto hwcNode : selfDrawingNodes) { - CalcHwcNodeEnableByFilterRect(hwcNode, filterRect); + CalcHwcNodeEnableByFilterRect(hwcNode, filterRect, isReverseOrder); } } else { const auto& hwcNodes = node->GetChildHardwareEnabledNodes(); @@ -2655,7 +2660,7 @@ void RSUniRenderVisitor::UpdateHwcNodeEnableByFilterRect( } for (auto hwcNode : hwcNodes) { auto hwcNodePtr = hwcNode.lock(); - CalcHwcNodeEnableByFilterRect(hwcNodePtr, filterRect); + CalcHwcNodeEnableByFilterRect(hwcNodePtr, filterRect, isReverseOrder); } } } diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.h b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.h index 1af6a4af59..d2481e95f2 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.h +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.h @@ -243,8 +243,10 @@ private: void UpdateHwcNodeEnableByGlobalFilter(std::shared_ptr& node); void UpdateHwcNodeEnableByGlobalCleanFilter(const std::vector>& cleanFilter, RSSurfaceRenderNode& hwcNodePtr); - void UpdateHwcNodeEnableByFilterRect(std::shared_ptr& node, const RectI& filterRect); - void CalcHwcNodeEnableByFilterRect(std::shared_ptr& node, const RectI& filterRect); + void UpdateHwcNodeEnableByFilterRect( + std::shared_ptr& node, const RectI& filterRect, bool isReverseOrder = false); + void CalcHwcNodeEnableByFilterRect( + std::shared_ptr& node, const RectI& filterRect, bool isReverseOrder = false); void UpdateHwcNodeEnableByBackgroundAlpha(RSSurfaceRenderNode& node); void UpdateHwcNodeEnableBySrcRect(RSSurfaceRenderNode& node); void UpdateHwcNodeInfoForAppNode(RSSurfaceRenderNode& node); diff --git a/rosen/modules/render_service/core/system/rs_system_parameters.cpp b/rosen/modules/render_service/core/system/rs_system_parameters.cpp index deeb62d0b2..56c997ba5f 100644 --- a/rosen/modules/render_service/core/system/rs_system_parameters.cpp +++ b/rosen/modules/render_service/core/system/rs_system_parameters.cpp @@ -173,10 +173,10 @@ bool RSSystemParameters::GetControlBufferConsumeEnabled() bool RSSystemParameters::GetHideNotchStatus() { - static CachedHandle g_Handle = CachedParameterCreate("persist.sys.graphic.hideNotch.status", "false"); + static CachedHandle g_Handle = CachedParameterCreate("persist.sys.graphic.hideNotch.status", "0"); int changed = 0; const char *enable = CachedParameterGetChanged(g_Handle, &changed); - return (strcmp(enable, "true") == 0); + return (strcmp(enable, "2") == 0); } bool RSSystemParameters::GetUIFirstDmaBufferEnabled() diff --git a/rosen/modules/render_service_base/include/pipeline/rs_surface_render_node.h b/rosen/modules/render_service_base/include/pipeline/rs_surface_render_node.h index 516e5dbf9d..be9dcbf365 100644 --- a/rosen/modules/render_service_base/include/pipeline/rs_surface_render_node.h +++ b/rosen/modules/render_service_base/include/pipeline/rs_surface_render_node.h @@ -1181,6 +1181,16 @@ public: return brightnessRatio_; } + void SetHardWareDisabledByReverse(bool isHardWareDisabledByReverse) + { + isHardWareDisabledByReverse_ = isHardWareDisabledByReverse; + } + + bool GetHardWareDisabledByReverse() const + { + return isHardWareDisabledByReverse_; + } + void SetSkipDraw(bool skip); bool GetSkipDraw() const; void SetNeedOffscreen(bool needOffscreen); @@ -1404,6 +1414,7 @@ private: bool needDrawAnimateProperty_ = false; bool prevVisible_ = false; + bool isHardWareDisabledByReverse_ = false; uint32_t processZOrder_ = -1; From a16e41078cc84a4c75f05cd96eae351fc82e6a46 Mon Sep 17 00:00:00 2001 From: siyuan Date: Sat, 29 Jun 2024 15:38:58 +0800 Subject: [PATCH 121/247] second commit Signed-off-by: siyuan --- .../src/render/rs_attraction_effect_filter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp b/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp index e2a52f7a78..46e8a1876f 100644 --- a/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp +++ b/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp @@ -329,7 +329,7 @@ std::vector RSAttractionEffectFilter::CalculateVelocityCtrlPoint { // Cubic Bezier curve with two control points Drawing::Point topVelFirst = { 0.50f, 0.0f }; - Drawing::Point bottomVelFirst = isBelowTarget_ ? { 0.20f, 0.0f } : { 0.0f, 0.0f }; + Drawing::Point bottomVelFirst = isBelowTarget_ ? Drawing::Point(0.2f, 0.0f) : Drawing::Point(0.0f, 0.0f); std::vector velocityCtrlPoint = {topVelFirst, bottomVelFirst}; return velocityCtrlPoint; } @@ -338,7 +338,7 @@ std::vector RSAttractionEffectFilter::CalculateVelocityCtrlPoint { // Cubic Bezier curve with two control points Drawing::Point topVelSecond = { 0.50f, 1.0f }; - Drawing::Point bottomVelSecond = isBelowTarget_ ? { 0.20f, 1.0f } : { 0.0f, 1.0f }; + Drawing::Point bottomVelSecond = isBelowTarget_ ? Drawing::Point(0.2f, 1.0f) : Drawing::Point(0.0f, 1.0f); std::vector velocityCtrlPoint = {topVelSecond, bottomVelSecond}; return velocityCtrlPoint; } From a50e3e586adb31bfa7e2d2106de72048c75abf4f Mon Sep 17 00:00:00 2001 From: LeesonWong Date: Sat, 29 Jun 2024 15:40:16 +0800 Subject: [PATCH 122/247] Test cases for rs_image_cache.cpp Signed-off-by: w30027672 --- rosen/modules/render_service_base/test/unittest/BUILD.gn | 2 +- rosen/modules/render_service_base/test/unittest/render/BUILD.gn | 2 +- .../test/unittest/render/rs_image_cache_test.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rosen/modules/render_service_base/test/unittest/BUILD.gn b/rosen/modules/render_service_base/test/unittest/BUILD.gn index 95456c5213..f556b83f75 100644 --- a/rosen/modules/render_service_base/test/unittest/BUILD.gn +++ b/rosen/modules/render_service_base/test/unittest/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-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 diff --git a/rosen/modules/render_service_base/test/unittest/render/BUILD.gn b/rosen/modules/render_service_base/test/unittest/render/BUILD.gn index ad2114cc9d..1db968c545 100644 --- a/rosen/modules/render_service_base/test/unittest/render/BUILD.gn +++ b/rosen/modules/render_service_base/test/unittest/render/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. +# 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 diff --git a/rosen/modules/render_service_base/test/unittest/render/rs_image_cache_test.cpp b/rosen/modules/render_service_base/test/unittest/render/rs_image_cache_test.cpp index ff8aa85cee..5439f9f7ce 100644 --- a/rosen/modules/render_service_base/test/unittest/render/rs_image_cache_test.cpp +++ b/rosen/modules/render_service_base/test/unittest/render/rs_image_cache_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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 From d648d3da454c41b05a16df6e3b1d3522de443b4a Mon Sep 17 00:00:00 2001 From: siyuan Date: Sat, 29 Jun 2024 15:45:32 +0800 Subject: [PATCH 123/247] third commit Signed-off-by: siyuan --- .../src/render/rs_attraction_effect_filter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp b/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp index 46e8a1876f..9fac44db2e 100644 --- a/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp +++ b/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp @@ -387,7 +387,7 @@ void RSAttractionEffectFilter::CalculateWindowStatus(float canvasWidth, float ca // 1.0 indicates that the window is to the right of the target point, // and - 1.0 indicates that the window is to the left. float location = (windowBottomCenter.GetX() > pointDst[0].GetX()) ? 1.0f : -1.0f; - bool isBelowTarget_ = (windowBottomCenter.GetY() > pointDst[0].GetY()) ? true : false; + isBelowTarget_ = (windowBottomCenter.GetY() > pointDst[0].GetY()) ? true : false; float width = isBelowTarget_ ? canvasHeight_ : canvasWidth_; float height = isBelowTarget_ ? canvasWidth_ : canvasHeight_; From 2de394661c1ef19ed5df308265ef070025ef7520 Mon Sep 17 00:00:00 2001 From: 15549494042 Date: Sat, 29 Jun 2024 15:46:43 +0800 Subject: [PATCH 124/247] add pointer color picker ipc interface Singed-off-by:dongzhengkuan@huawei.com Signed-off-by: 15549494042 --- .vscode/settings.json | 71 +++++++++++++++++++ .../pipeline/rs_pointer_render_manager.cpp | 1 - 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..afb1946e73 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,71 @@ +{ + "files.associations": { + "any": "cpp", + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "*.tcc": "cpp", + "bitset": "cpp", + "cctype": "cpp", + "chrono": "cpp", + "cinttypes": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "codecvt": "cpp", + "compare": "cpp", + "concepts": "cpp", + "condition_variable": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "list": "cpp", + "map": "cpp", + "set": "cpp", + "string": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "optional": "cpp", + "random": "cpp", + "ratio": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "future": "cpp", + "initializer_list": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "mutex": "cpp", + "new": "cpp", + "numbers": "cpp", + "ostream": "cpp", + "ranges": "cpp", + "semaphore": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "stop_token": "cpp", + "streambuf": "cpp", + "thread": "cpp", + "typeinfo": "cpp", + "variant": "cpp" + } +} \ No newline at end of file diff --git a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp index bd875291e5..dd69e5dc37 100644 --- a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp @@ -129,7 +129,6 @@ bool RSPointerRenderManager::CheckColorPickerEnabled() return false; } - auto timeNow = std::chrono::time_point_cast(std::chrono::steady_clock::now()); auto tmp = std::chrono::duration_cast(timeNow.time_since_epoch()); auto time = tmp.count() - lastColorPickerTime_; From 4040a6e87ed9b336171db69014e5634dbb75f6b9 Mon Sep 17 00:00:00 2001 From: chenq Date: Fri, 28 Jun 2024 15:56:52 +0800 Subject: [PATCH 125/247] =?UTF-8?q?=E4=BF=AE=E6=94=B9interactive=20animato?= =?UTF-8?q?r=E5=90=AF=E5=8A=A8=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenq --- .../include/command/rs_animation_command.h | 5 +++-- .../src/command/rs_animation_command.cpp | 6 +++++- .../core/animation/rs_interactive_implict_animator.cpp | 6 +++--- rosen/modules/render_service_client/core/ui/rs_node.cpp | 5 +++-- .../unittest/command/rs_animation_command_test.cpp | 4 ++-- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/rosen/modules/render_service_base/include/command/rs_animation_command.h b/rosen/modules/render_service_base/include/command/rs_animation_command.h index c360cd55f0..7ec055319a 100644 --- a/rosen/modules/render_service_base/include/command/rs_animation_command.h +++ b/rosen/modules/render_service_base/include/command/rs_animation_command.h @@ -125,7 +125,8 @@ public: static void CancelAnimation(RSContext& context, NodeId targetId, PropertyId propertyId); static void CreateInteractiveAnimator(RSContext& context, - InteractiveImplictAnimatorId targetId, std::vector> animations); + InteractiveImplictAnimatorId targetId, std::vector> animations, + bool startImmediately); static void DestoryInteractiveAnimator(RSContext& context, InteractiveImplictAnimatorId targetId); static void InteractiveAnimatorAddAnimations(RSContext& context, InteractiveImplictAnimatorId targetId, std::vector> animations); @@ -193,7 +194,7 @@ ADD_COMMAND(RSAnimationCreateInterpolatingSpring, // interactive implict animator operation ADD_COMMAND(RSInteractiveAnimatorCreate, ARG(ANIMATION, INTERACTIVE_ANIMATOR_CREATE, AnimationCommandHelper::CreateInteractiveAnimator, InteractiveImplictAnimatorId, - std::vector>)) + std::vector>, bool)) ADD_COMMAND(RSInteractiveAnimatorDestory, ARG(ANIMATION, INTERACTIVE_ANIMATOR_DESTORY, AnimationCommandHelper::DestoryInteractiveAnimator, InteractiveImplictAnimatorId)) ADD_COMMAND(RSInteractiveAnimatorPause, ARG(ANIMATION, INTERACTIVE_ANIMATOR_PAUSE, diff --git a/rosen/modules/render_service_base/src/command/rs_animation_command.cpp b/rosen/modules/render_service_base/src/command/rs_animation_command.cpp index d1a8476a8a..e639be5aa1 100644 --- a/rosen/modules/render_service_base/src/command/rs_animation_command.cpp +++ b/rosen/modules/render_service_base/src/command/rs_animation_command.cpp @@ -105,7 +105,8 @@ void AnimationCommandHelper::CancelAnimation(RSContext& context, NodeId targetId } void AnimationCommandHelper::CreateInteractiveAnimator(RSContext& context, - InteractiveImplictAnimatorId targetId, std::vector> animations) + InteractiveImplictAnimatorId targetId, std::vector> animations, + bool startImmediately) { auto animator = context.GetInteractiveImplictAnimatorMap().GetInteractiveImplictAnimator(targetId); if (animator == nullptr) { @@ -113,6 +114,9 @@ void AnimationCommandHelper::CreateInteractiveAnimator(RSContext& context, context.GetInteractiveImplictAnimatorMap().RegisterInteractiveImplictAnimator(animator); } animator->AddAnimations(animations); + if (startImmediately) { + animator->ContinueAnimator(); + } } void AnimationCommandHelper::DestoryInteractiveAnimator(RSContext& context, InteractiveImplictAnimatorId targetId) diff --git a/rosen/modules/render_service_client/core/animation/rs_interactive_implict_animator.cpp b/rosen/modules/render_service_client/core/animation/rs_interactive_implict_animator.cpp index 8a4142c574..e78d160aaa 100644 --- a/rosen/modules/render_service_client/core/animation/rs_interactive_implict_animator.cpp +++ b/rosen/modules/render_service_client/core/animation/rs_interactive_implict_animator.cpp @@ -184,7 +184,7 @@ int32_t RSInteractiveImplictAnimator::StartAnimation() auto animation = item.lock(); auto target = RSNodeMap::Instance().GetNode(nodeId); if (target != nullptr && animation != nullptr) { - animation->StartInner(target); + animation->InteractiveContinue(); if (!animation->IsUiAnimation()) { renderAnimations.emplace_back(nodeId, animation->GetId()); } @@ -197,11 +197,11 @@ int32_t RSInteractiveImplictAnimator::StartAnimation() ROSEN_LOGE("RSTransactionProxy is nullptr"); return static_cast(StartAnimationErrorCode::INVALID_PROXY); } - std::unique_ptr command = std::make_unique(id_, renderAnimations); + std::unique_ptr command = std::make_unique(id_, renderAnimations, true); transactionProxy->AddCommand(command, IsUniRenderEnabled()); if (!IsUniRenderEnabled()) { std::unique_ptr commandForRemote = - std::make_unique(id_, renderAnimations); + std::make_unique(id_, renderAnimations, true); transactionProxy->AddCommand(commandForRemote, true); } return static_cast(StartAnimationErrorCode::SUCCESS); diff --git a/rosen/modules/render_service_client/core/ui/rs_node.cpp b/rosen/modules/render_service_client/core/ui/rs_node.cpp index de6dcdbb83..ce157cfabf 100755 --- a/rosen/modules/render_service_client/core/ui/rs_node.cpp +++ b/rosen/modules/render_service_client/core/ui/rs_node.cpp @@ -446,8 +446,9 @@ void RSNode::AddAnimation(const std::shared_ptr& animation, bool is AddAnimationInner(animation); } - if (isStartAnimation) { - animation->StartInner(shared_from_this()); + animation->StartInner(shared_from_this()); + if (!isStartAnimation) { + animation->Pause(); } } diff --git a/rosen/test/render_service/render_service_base/unittest/command/rs_animation_command_test.cpp b/rosen/test/render_service/render_service_base/unittest/command/rs_animation_command_test.cpp index 952c5d7c88..5711cbc0bd 100644 --- a/rosen/test/render_service/render_service_base/unittest/command/rs_animation_command_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/command/rs_animation_command_test.cpp @@ -195,14 +195,14 @@ HWTEST_F(RSAnimationCommandTest, InteractiveAnimator001, TestSize.Level1) AnimationCommandHelper::FinishInteractiveAnimator(context, targetIdI, RSInteractiveAnimationPosition::CURRENT); AnimationCommandHelper::ReverseInteractiveAnimator(context, targetIdI); AnimationCommandHelper::SetFractionInteractiveAnimator(context, targetIdI, fraction); - AnimationCommandHelper::CreateInteractiveAnimator(context, targetId, animations); + AnimationCommandHelper::CreateInteractiveAnimator(context, targetId, animations, false); EXPECT_TRUE(context.GetInteractiveImplictAnimatorMap().GetInteractiveImplictAnimator(targetId) != nullptr); AnimationCommandHelper::InteractiveAnimatorAddAnimations(context, targetId, animations); AnimationCommandHelper::PauseInteractiveAnimator(context, targetIdI); AnimationCommandHelper::ContinueInteractiveAnimator(context, targetIdI); AnimationCommandHelper::FinishInteractiveAnimator(context, targetIdI, RSInteractiveAnimationPosition::CURRENT); - AnimationCommandHelper::CreateInteractiveAnimator(context, targetId, animations); + AnimationCommandHelper::CreateInteractiveAnimator(context, targetId, animations, true); AnimationCommandHelper::ReverseInteractiveAnimator(context, targetIdI); AnimationCommandHelper::SetFractionInteractiveAnimator(context, targetIdI, fraction); AnimationCommandHelper::DestoryInteractiveAnimator(context, targetIdI); From 2b611bec27c3201a6da8497ab0f41fcd560bd159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=BF=E8=B1=AA?= Date: Sat, 29 Jun 2024 16:19:02 +0800 Subject: [PATCH 126/247] fix pixelStretch setmode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 耿豪 --- .../modules/render_service_client/core/ui/rs_node.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rosen/modules/render_service_client/core/ui/rs_node.cpp b/rosen/modules/render_service_client/core/ui/rs_node.cpp index 66ef9944be..b3c69f6034 100755 --- a/rosen/modules/render_service_client/core/ui/rs_node.cpp +++ b/rosen/modules/render_service_client/core/ui/rs_node.cpp @@ -1334,6 +1334,11 @@ void RSNode::SetUICompositingFilter(const OHOS::Rosen::Filter* compositingFilter SetForegroundBlurRadiusX(blurRadius); SetForegroundBlurRadiusY(blurRadius); } + if (filterPara->GetParaType() == FilterPara::PIXEL_STRETCH) { + auto pixelStretchPara = std::static_pointer_cast(filterPara); + auto stretchPercent = pixelStretchPara->GetStretchPercent(); + SetPixelStretchPercent(stretchPercent, pixelStretchPara->GetTileMode()); + } } } @@ -1347,11 +1352,6 @@ void RSNode::SetUIForegroundFilter(const OHOS::Rosen::Filter* foregroundFilter) auto blurRadius = filterBlurPara->GetRadius(); SetForegroundEffectRadius(blurRadius); } - if (filterPara->GetParaType() == FilterPara::PIXEL_STRETCH) { - auto pixelStretchPara = std::static_pointer_cast(filterPara); - auto stretchPercent = pixelStretchPara->GetStretchPercent(); - SetPixelStretchPercent(stretchPercent, pixelStretchPara->GetTileMode()); - } } } From cbcc0efb45ce5c636df5a94f9f09486df871b6aa Mon Sep 17 00:00:00 2001 From: dreamond_wxy Date: Sat, 29 Jun 2024 15:23:22 +0800 Subject: [PATCH 127/247] =?UTF-8?q?=E6=95=B4=E6=94=B9screens=20map?= =?UTF-8?q?=E6=9F=A5=E6=89=BEid=E5=88=A4=E6=96=AD=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E5=86=97=E4=BD=99=E9=81=8D=E5=8E=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dreamond_wxy --- .../core/screen_manager/rs_screen_manager.cpp | 67 ++++++++++++++----- 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/rosen/modules/render_service/core/screen_manager/rs_screen_manager.cpp b/rosen/modules/render_service/core/screen_manager/rs_screen_manager.cpp index 7c076bb6ab..234d548808 100644 --- a/rosen/modules/render_service/core/screen_manager/rs_screen_manager.cpp +++ b/rosen/modules/render_service/core/screen_manager/rs_screen_manager.cpp @@ -881,18 +881,34 @@ int32_t RSScreenManager::SetVirtualScreenBlackList(ScreenId id, std::vector lock(mutex_); - if (screens_.find(id) == screens_.end()) { + auto virtualScreen = screens_.find(id); + if (virtualScreen == screens_.end()) { RS_LOGW("RSScreenManager %{public}s: There is no screen for id %{public}" PRIu64 ".", __func__, id); return SCREEN_NOT_FOUND; - } - screens_.at(id)->SetBlackList(screenBlackList); - ScreenId mainId = GetDefaultScreenId(); - if (mainId != id) { - if (screens_.find(mainId) == screens_.end()) { - RS_LOGW("RSScreenManager %{public}s: There is no screen for main id %{public}" PRIu64 ".", __func__, mainId); + } else { + if (virtualScreen->second != nullptr) { + virtualScreen->second->SetBlackList(screenBlackList); + return SUCCESS; + } else { + RS_LOGW("RSScreenManager %{public}s: Null screen for id %{public}" PRIu64 ".", __func__, id); return SCREEN_NOT_FOUND; } - screens_.at(mainId)->SetBlackList(screenBlackList); + } + ScreenId mainId = GetDefaultScreenId(); + if (mainId != id) { + auto mainScreen = screens_.find(mainId); + if (mainScreen == screens_.end()) { + RS_LOGW("RSScreenManager %{public}s: There is no screen for id %{public}" PRIu64 ".", __func__, mainId); + return SCREEN_NOT_FOUND; + } else { + if (mainScreen->second != nullptr) { + mainScreen->second->SetBlackList(screenBlackList); + return SUCCESS; + } else { + RS_LOGW("RSScreenManager %{public}s: Null screen for id %{public}" PRIu64 ".", __func__, mainId); + return SCREEN_NOT_FOUND; + } + } } return SUCCESS; } @@ -900,32 +916,53 @@ int32_t RSScreenManager::SetVirtualScreenBlackList(ScreenId id, std::vector lock(mutex_); - if (screens_.find(id) == screens_.end()) { + auto virtualScreen = screens_.find(id); + if (virtualScreen == screens_.end()) { RS_LOGW("RSScreenManager %{public}s: There is no screen for id %{public}" PRIu64 ".", __func__, id); return SCREEN_NOT_FOUND; + } else { + if (virtualScreen->second != nullptr) { + virtualScreen->second->SetCastScreenEnableSkipWindow(enable); + return SUCCESS; + } else { + RS_LOGW("RSScreenManager %{public}s: Null screen for id %{public}" PRIu64 ".", __func__, id); + return SCREEN_NOT_FOUND; + } } - screens_.at(id)->SetCastScreenEnableSkipWindow(enable); - return SUCCESS; } bool RSScreenManager::GetCastScreenEnableSkipWindow(ScreenId id) { std::lock_guard lock(mutex_); - if (screens_.find(id) == screens_.end()) { + auto virtualScreen = screens_.find(id); + if (virtualScreen == screens_.end()) { RS_LOGW("RSScreenManager %{public}s: There is no screen for id %{public}" PRIu64 ".", __func__, id); return false; + } else { + if (virtualScreen->second != nullptr) { + return virtualScreen->second->GetCastScreenEnableSkipWindow(); + } else { + RS_LOGW("RSScreenManager %{public}s: Null screen for id %{public}" PRIu64 ".", __func__, id); + return false; + } } - return screens_.at(id)->GetCastScreenEnableSkipWindow(); } std::unordered_set RSScreenManager::GetVirtualScreenBlackList(ScreenId id) { std::lock_guard lock(mutex_); - if (screens_.find(id) == screens_.end()) { + auto virtualScreen = screens_.find(id); + if (virtualScreen == screens_.end()) { RS_LOGW("RSScreenManager %{public}s: There is no screen for id %{public}" PRIu64 ".", __func__, id); return {}; + } else { + if (virtualScreen->second != nullptr) { + return virtualScreen->second->GetBlackList(); + } else { + RS_LOGW("RSScreenManager %{public}s: Null screen for id %{public}" PRIu64 ".", __func__, id); + return {}; + } } - return screens_.at(id)->GetBlackList(); } int32_t RSScreenManager::SetVirtualScreenSurface(ScreenId id, sptr surface) From f843e636af899b58505d82af906b2e1ea0557155 Mon Sep 17 00:00:00 2001 From: 15549494042 Date: Sat, 29 Jun 2024 16:55:54 +0800 Subject: [PATCH 128/247] add pointer color picker ipc interface Singed-off-by:dongzhengkuan@huawei.com Signed-off-by: 15549494042 --- .vscode/settings.json | 71 ------------------------------------------- 1 file changed, 71 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index afb1946e73..0000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "files.associations": { - "any": "cpp", - "array": "cpp", - "atomic": "cpp", - "bit": "cpp", - "*.tcc": "cpp", - "bitset": "cpp", - "cctype": "cpp", - "chrono": "cpp", - "cinttypes": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "codecvt": "cpp", - "compare": "cpp", - "concepts": "cpp", - "condition_variable": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "deque": "cpp", - "list": "cpp", - "map": "cpp", - "set": "cpp", - "string": "cpp", - "unordered_map": "cpp", - "unordered_set": "cpp", - "vector": "cpp", - "exception": "cpp", - "algorithm": "cpp", - "functional": "cpp", - "iterator": "cpp", - "memory": "cpp", - "memory_resource": "cpp", - "numeric": "cpp", - "optional": "cpp", - "random": "cpp", - "ratio": "cpp", - "string_view": "cpp", - "system_error": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "utility": "cpp", - "fstream": "cpp", - "future": "cpp", - "initializer_list": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "istream": "cpp", - "limits": "cpp", - "mutex": "cpp", - "new": "cpp", - "numbers": "cpp", - "ostream": "cpp", - "ranges": "cpp", - "semaphore": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "stop_token": "cpp", - "streambuf": "cpp", - "thread": "cpp", - "typeinfo": "cpp", - "variant": "cpp" - } -} \ No newline at end of file From eeb46eab70d770966920a4373271b690ad0803a9 Mon Sep 17 00:00:00 2001 From: WenyiRoad Date: Sat, 29 Jun 2024 15:06:03 +0800 Subject: [PATCH 129/247] add surface drawable test Signed-off-by: WenyiRoad --- .../drawable/dfx/rs_dirty_rects_dfx_test.cpp | 18 +- .../drawable/dfx/rs_skp_capture_dfx_test.cpp | 19 +- .../rs_surface_render_node_drawable_test.cpp | 191 ++++++++++++++++-- 3 files changed, 198 insertions(+), 30 deletions(-) diff --git a/rosen/test/render_service/render_service/unittest/drawable/dfx/rs_dirty_rects_dfx_test.cpp b/rosen/test/render_service/render_service/unittest/drawable/dfx/rs_dirty_rects_dfx_test.cpp index 9274eba729..3324e1dbc3 100644 --- a/rosen/test/render_service/render_service/unittest/drawable/dfx/rs_dirty_rects_dfx_test.cpp +++ b/rosen/test/render_service/render_service/unittest/drawable/dfx/rs_dirty_rects_dfx_test.cpp @@ -76,6 +76,10 @@ void RSDirtyRectsDFXTest::SetUp() if (drawingCanvas_) { canvas_ = std::make_shared(drawingCanvas_.get()); } + auto& rtThread = RSUniRenderThread::Instance(); + if (!rtThread.renderThreadParams_) { + rtThread.renderThreadParams_ = std::make_unique(); + } } void RSDirtyRectsDFXTest::TearDown() {} @@ -89,7 +93,6 @@ HWTEST_F(RSDirtyRectsDFXTest, OnDraw, TestSize.Level1) { ASSERT_NE(rsDirtyRectsDfx_, nullptr); rsDirtyRectsDfx_->OnDraw(canvas_); - ASSERT_EQ(rsDirtyRectsDfx_->canvas_, nullptr); } /** @@ -118,19 +121,6 @@ HWTEST_F(RSDirtyRectsDFXTest, DrawDirtyRegionInVirtual, TestSize.Level1) ASSERT_EQ(rsDirtyRectsDfx_->canvas_, nullptr); } -/** - * @tc.name: DrawCurrentRefreshRate - * @tc.desc: Test If DrawCurrentRefreshRate Can Run - * @tc.type: FUNC - * @tc.require: #I9NVOG - */ -HWTEST_F(RSDirtyRectsDFXTest, DrawCurrentRefreshRate, TestSize.Level1) -{ - ASSERT_NE(rsDirtyRectsDfx_, nullptr); - rsDirtyRectsDfx_->DrawCurrentRefreshRate(); - ASSERT_NE(rsDirtyRectsDfx_->canvas_, nullptr); -} - /** * @tc.name: DrawDirtyRegionForDFX * @tc.desc: Test If DrawDirtyRegionForDFX Can Run diff --git a/rosen/test/render_service/render_service/unittest/drawable/dfx/rs_skp_capture_dfx_test.cpp b/rosen/test/render_service/render_service/unittest/drawable/dfx/rs_skp_capture_dfx_test.cpp index 4d27e6f4cd..85734248b8 100644 --- a/rosen/test/render_service/render_service/unittest/drawable/dfx/rs_skp_capture_dfx_test.cpp +++ b/rosen/test/render_service/render_service/unittest/drawable/dfx/rs_skp_capture_dfx_test.cpp @@ -19,6 +19,7 @@ #include "params/rs_render_thread_params.h" #include "pipeline/rs_display_render_node.h" #include "pipeline/rs_render_node.h" +#include "pipeline/rs_uni_render_engine.h" #include "pipeline/rs_uni_render_thread.h" using namespace testing; @@ -53,13 +54,29 @@ void RSSkpCaptureDFXTest::TearDown() {} * @tc.type: FUNC * @tc.require: #I9NVOG */ -HWTEST_F(RSSkpCaptureDFXTest, capture, TestSize.Level1) +HWTEST_F(RSSkpCaptureDFXTest, captureTest001, TestSize.Level1) { + auto& rtThread = RSUniRenderThread::Instance(); + if (!rtThread.renderThreadParams_) { + rtThread.renderThreadParams_ = std::make_unique(); + } + rtThread.uniRenderEngine_ = std::make_shared(); + auto drawingCanvas = std::make_unique(DEFAULT_CANVAS_SIZE, DEFAULT_CANVAS_SIZE); auto canvas = std::make_shared(drawingCanvas.get()); ASSERT_NE(canvas, nullptr); { + rtThread.uniRenderEngine_->renderContext_ = nullptr; + RSSkpCaptureDfx capture(canvas); + ASSERT_EQ(capture.recordingCanvas_, nullptr); + } + { +#if defined(NEW_RENDER_CONTEXT) + rtThread.uniRenderEngine_->renderContext_ = std::shared_ptr(); +#else + rtThread.uniRenderEngine_->renderContext_ = std::shared_ptr(); +#endif RSSkpCaptureDfx capture(canvas); ASSERT_EQ(capture.recordingCanvas_, nullptr); } diff --git a/rosen/test/render_service/render_service/unittest/drawable/rs_surface_render_node_drawable_test.cpp b/rosen/test/render_service/render_service/unittest/drawable/rs_surface_render_node_drawable_test.cpp index 72e5eb051e..798a503f0b 100644 --- a/rosen/test/render_service/render_service/unittest/drawable/rs_surface_render_node_drawable_test.cpp +++ b/rosen/test/render_service/render_service/unittest/drawable/rs_surface_render_node_drawable_test.cpp @@ -18,6 +18,8 @@ #include "params/rs_render_thread_params.h" #include "pipeline/rs_display_render_node.h" #include "pipeline/rs_surface_render_node.h" +#include "pipeline/rs_uni_render_thread.h" +#include "params/rs_render_thread_params.h" using namespace testing; using namespace testing::ext; @@ -357,21 +359,6 @@ HWTEST_F(RSSurfaceRenderNodeDrawableTest, DrawUIFirstDfx, TestSize.Level1) surfaceDrawable_->DrawUIFirstDfx(paintFilterCanvas, MultiThreadCacheType::LEASH_WINDOW, *surfaceParams, false); } -/** - * @tc.name: GetSurfaceRenderNode - * @tc.desc: Test GetSurfaceRenderNode - * @tc.type: FUNC - * @tc.require: #IA940V - */ -HWTEST_F(RSSurfaceRenderNodeDrawableTest, GetSurfaceRenderNode, TestSize.Level1) -{ - ASSERT_NE(surfaceDrawable_, nullptr); - ASSERT_NE(surfaceDrawable_->GetSurfaceRenderNode(), nullptr); - - surfaceDrawable_->renderNode_ = std::weak_ptr(); - ASSERT_EQ(surfaceDrawable_->GetSurfaceRenderNode(), nullptr); -} - /** * @tc.name: GetVisibleDirtyRegion * @tc.desc: Test GetVisibleDirtyRegion @@ -501,4 +488,178 @@ HWTEST_F(RSSurfaceRenderNodeDrawableTest, GetSyncDirtyManager, TestSize.Level1) surfaceDrawable_->GetSyncDirtyManager(); ASSERT_EQ(surfaceDrawable_->GetSurfaceRenderNode(), nullptr); } + +/** + * @tc.name: GetSyncDirtyManager + * @tc.desc: Test GetSyncDirtyManager + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, GetSyncDirtyManagerTest, TestSize.Level1) +{ + auto renderNode = std::make_shared(DEFAULT_ID-1); + ASSERT_NE(renderNode, nullptr); + auto drawable = std::static_pointer_cast( + DrawableV2::RSRenderNodeDrawableAdapter::OnGenerate(renderNode)); + ASSERT_NE(drawable, nullptr); + drawable->GetSyncDirtyManager(); + renderNode = nullptr; + drawable->GetSyncDirtyManager(); +} + +/** + * @tc.name: SetDirtyRegionBelowCurrentLayer + * @tc.desc: Test SetDirtyRegionBelowCurrentLayer + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, SetDirtyRegionBelowCurrentLayerTest, TestSize.Level1) +{ + auto renderNode = std::make_shared(DEFAULT_ID-1); + ASSERT_NE(renderNode, nullptr); + auto drawable = std::static_pointer_cast( + DrawableV2::RSRenderNodeDrawableAdapter::OnGenerate(renderNode)); + ASSERT_NE(drawable, nullptr); + Occlusion::Region VisibleDirtyRegion; + drawable->SetDirtyRegionBelowCurrentLayer(VisibleDirtyRegion); + renderNode = nullptr; + drawable->SetDirtyRegionBelowCurrentLayer(VisibleDirtyRegion); +} + +/** + * @tc.name: SetDirtyRegionAlignedEnable + * @tc.desc: Test SetDirtyRegionAlignedEnable + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, SetDirtyRegionAlignedEnableTest, TestSize.Level1) +{ + auto renderNode = std::make_shared(DEFAULT_ID-1); + ASSERT_NE(renderNode, nullptr); + auto drawable = std::static_pointer_cast( + DrawableV2::RSRenderNodeDrawableAdapter::OnGenerate(renderNode)); + ASSERT_NE(drawable, nullptr); + drawable->SetDirtyRegionAlignedEnable(true); + renderNode = nullptr; + drawable->SetDirtyRegionAlignedEnable(true); +} + +/** + * @tc.name: SetGlobalDirtyRegion + * @tc.desc: Test SetGlobalDirtyRegion + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, SetGlobalDirtyRegionTest, TestSize.Level1) +{ + auto renderNode = std::make_shared(DEFAULT_ID-1); + ASSERT_NE(renderNode, nullptr); + auto drawable = std::static_pointer_cast( + DrawableV2::RSRenderNodeDrawableAdapter::OnGenerate(renderNode)); + ASSERT_NE(drawable, nullptr); + const RectI rect = RectI(0, 0, 100, 100); + drawable->SetGlobalDirtyRegion(rect); + renderNode = nullptr; + drawable->SetGlobalDirtyRegion(rect); +} + +/** + * @tc.name: GetVisibleDirtyRegion + * @tc.desc: Test GetVisibleDirtyRegion + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, GetVisibleDirtyRegionTest, TestSize.Level1) +{ + auto renderNode = std::make_shared(DEFAULT_ID-1); + ASSERT_NE(renderNode, nullptr); + auto drawable = std::static_pointer_cast( + DrawableV2::RSRenderNodeDrawableAdapter::OnGenerate(renderNode)); + ASSERT_NE(drawable, nullptr); + drawable->GetVisibleDirtyRegion(); + renderNode = nullptr; + drawable->GetVisibleDirtyRegion(); +} + +/** + * @tc.name: GetSurfaceRenderNode + * @tc.desc: Test GetSurfaceRenderNode + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, GetSurfaceRenderNodeTest, TestSize.Level1) +{ + auto renderNode = std::make_shared(DEFAULT_ID-1); + ASSERT_NE(renderNode, nullptr); + auto drawable = std::static_pointer_cast( + DrawableV2::RSRenderNodeDrawableAdapter::OnGenerate(renderNode)); + ASSERT_NE(drawable, nullptr); + drawable->GetSurfaceRenderNode(); + renderNode = nullptr; + drawable->GetSurfaceRenderNode(); +} + +/** + * @tc.name: EnableGpuOverDrawDrawBufferOptimization + * @tc.desc: Test EnableGpuOverDrawDrawBufferOptimization + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, EnableGpuOverDrawDrawBufferOptimizationTest, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + auto surfaceParams = static_cast(drawable_->renderParams_.get()); + ASSERT_NE(surfaceParams, nullptr); + Drawing::Canvas drawingCanvas; + surfaceDrawable_->EnableGpuOverDrawDrawBufferOptimization(drawingCanvas, surfaceParams); +} + +/** + * @tc.name: DrawUIFirstDfx + * @tc.desc: Test DrawUIFirstDfx + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, DrawUIFirstDfxTest, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + auto surfaceParams = static_cast(drawable_->renderParams_.get()); + ASSERT_NE(surfaceParams, nullptr); + Drawing::Canvas drawingCanvas; + RSPaintFilterCanvas canvas(&drawingCanvas); + + MultiThreadCacheType enableType = MultiThreadCacheType::ARKTS_CARD; + surfaceDrawable_->DrawUIFirstDfx(canvas, enableType, *surfaceParams, true); + + enableType = MultiThreadCacheType::LEASH_WINDOW; + surfaceDrawable_->DrawUIFirstDfx(canvas, enableType, *surfaceParams, true); + surfaceDrawable_->DrawUIFirstDfx(canvas, enableType, *surfaceParams, false); +} + +/** + * @tc.name: DealWithSelfDrawingNodeBuffer + * @tc.desc: Test DealWithSelfDrawingNodeBuffer + * @tc.type: FUNC + * @tc.require: #I9NVOG + */ +HWTEST_F(RSSurfaceRenderNodeDrawableTest, DealWithSelfDrawingNodeBufferTest, TestSize.Level1) +{ + ASSERT_NE(renderNode_, nullptr); + ASSERT_NE(surfaceDrawable_, nullptr); + auto surfaceParams = static_cast(drawable_->renderParams_.get()); + ASSERT_NE(surfaceParams, nullptr); + Drawing::Canvas drawingCanvas; + RSPaintFilterCanvas canvas(&drawingCanvas); + auto& rtThread = RSUniRenderThread::Instance(); + rtThread.captureParam_ = CaptureParam(); + + surfaceParams->isHardwareEnabled_ = true; + const auto params01 = surfaceParams; + surfaceDrawable_->DealWithSelfDrawingNodeBuffer(*renderNode_.get(), canvas, *params01); + + rtThread.captureParam_.isInCaptureFlag_ = false; + surfaceParams->isHardwareEnabled_ = false; + const auto params02 = surfaceParams; + surfaceDrawable_->DealWithSelfDrawingNodeBuffer(*renderNode_.get(), canvas, *params02); +} } From 773ff46232922f2177cb60f0014b4bcde9d443b6 Mon Sep 17 00:00:00 2001 From: wangjincheng Date: Sun, 30 Jun 2024 16:23:34 +0800 Subject: [PATCH 130/247] =?UTF-8?q?=E8=A7=A3=E5=86=B3RSAnimationTest?= =?UTF-8?q?=E5=8D=95=E4=B8=AA=E7=94=A8=E4=BE=8B=E6=89=A7=E8=A1=8C=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E8=BF=87=E9=95=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangjincheng --- .../test/unittest/BUILD.gn | 3 + .../test/unittest/animation/BUILD.gn | 121 +++++++++++++++--- 2 files changed, 108 insertions(+), 16 deletions(-) diff --git a/rosen/modules/render_service_client/test/unittest/BUILD.gn b/rosen/modules/render_service_client/test/unittest/BUILD.gn index 30be5533ff..8fcd6186a7 100644 --- a/rosen/modules/render_service_client/test/unittest/BUILD.gn +++ b/rosen/modules/render_service_client/test/unittest/BUILD.gn @@ -30,6 +30,9 @@ group("unittest") { ":RSTransactionsTest", ":RSTunnelHandleTest", "animation:RSAnimationTest", + "animation:RSAnimationTest1", + "animation:RSAnimationTest2", + "animation:RSAnimationTest3", ] } diff --git a/rosen/modules/render_service_client/test/unittest/animation/BUILD.gn b/rosen/modules/render_service_client/test/unittest/animation/BUILD.gn index a572282662..2da963d4bc 100644 --- a/rosen/modules/render_service_client/test/unittest/animation/BUILD.gn +++ b/rosen/modules/render_service_client/test/unittest/animation/BUILD.gn @@ -28,26 +28,12 @@ ohos_unittest("RSAnimationTest") { "rs_animation_group_test.cpp", "rs_animation_supplement_test.cpp", "rs_animation_test.cpp", - "rs_animation_timing_curve_test.cpp", - "rs_curve_animation_test.cpp", - "rs_implicit_animator_test.cpp", - "rs_interactive_implict_animator_test.cpp", - "rs_keyframe_animation_test.cpp", - "rs_motion_path_option_test.cpp", - "rs_node_animate_supplement_test.cpp", - "rs_path_animation_test.cpp", - "rs_showing_properties_freezer_test.cpp", - "rs_spring_animation_test.cpp", - "rs_symbol_animation_test.cpp", - "rs_transition_effect_test.cpp", - "rs_transition_test.cpp", ] configs = [ ":rs_animation_test_config" ] deps = [ - "//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client", - "//foundation/window/window_manager/wm:libwm", + "$rosen_root/modules/render_service_client:librender_service_client", "//third_party/googletest:gtest_main", ] @@ -57,6 +43,104 @@ ohos_unittest("RSAnimationTest") { external_deps = [ "eventhandler:libeventhandler", "hilog:libhilog", + "window_manager:libwm", + ] + + subsystem_name = "graphic" +} + +ohos_unittest("RSAnimationTest1") { + module_out_path = module_output_path + if (defined(use_rosen_drawing) && use_rosen_drawing) { + defines = [ "USE_ROSEN_DRAWING" ] + } + sources = [ + "rs_animation_base_test.cpp", + "rs_animation_timing_curve_test.cpp", + "rs_curve_animation_test.cpp", + "rs_implicit_animator_test.cpp", + "rs_interactive_implict_animator_test.cpp", + "rs_keyframe_animation_test.cpp", + ] + + configs = [ ":rs_animation_test_config" ] + + deps = [ + "$rosen_root/modules/render_service_client:librender_service_client", + "//third_party/googletest:gtest_main", + ] + + public_deps = + [ "$rosen_root/modules/render_service_client:render_service_client_src" ] + + external_deps = [ + "eventhandler:libeventhandler", + "hilog:libhilog", + "window_manager:libwm", + ] + + subsystem_name = "graphic" +} + +ohos_unittest("RSAnimationTest2") { + module_out_path = module_output_path + if (defined(use_rosen_drawing) && use_rosen_drawing) { + defines = [ "USE_ROSEN_DRAWING" ] + } + sources = [ + "rs_animation_base_test.cpp", + "rs_motion_path_option_test.cpp", + "rs_node_animate_supplement_test.cpp", + "rs_path_animation_test.cpp", + "rs_showing_properties_freezer_test.cpp", + ] + + configs = [ ":rs_animation_test_config" ] + + deps = [ + "$rosen_root/modules/render_service_client:librender_service_client", + "//third_party/googletest:gtest_main", + ] + + public_deps = + [ "$rosen_root/modules/render_service_client:render_service_client_src" ] + + external_deps = [ + "eventhandler:libeventhandler", + "hilog:libhilog", + "window_manager:libwm", + ] + + subsystem_name = "graphic" +} + +ohos_unittest("RSAnimationTest3") { + module_out_path = module_output_path + if (defined(use_rosen_drawing) && use_rosen_drawing) { + defines = [ "USE_ROSEN_DRAWING" ] + } + sources = [ + "rs_animation_base_test.cpp", + "rs_spring_animation_test.cpp", + "rs_symbol_animation_test.cpp", + "rs_transition_effect_test.cpp", + "rs_transition_test.cpp", + ] + + configs = [ ":rs_animation_test_config" ] + + deps = [ + "$rosen_root/modules/render_service_client:librender_service_client", + "//third_party/googletest:gtest_main", + ] + + public_deps = + [ "$rosen_root/modules/render_service_client:render_service_client_src" ] + + external_deps = [ + "eventhandler:libeventhandler", + "hilog:libhilog", + "window_manager:libwm", ] subsystem_name = "graphic" @@ -78,5 +162,10 @@ config("rs_animation_test_config") { group("unittest") { testonly = true - deps = [ ":RSAnimationTest" ] + deps = [ + ":RSAnimationTest", + ":RSAnimationTest1", + ":RSAnimationTest2", + ":RSAnimationTest3", + ] } From 5989f84717188482b768cbedd888aaa545be2d23 Mon Sep 17 00:00:00 2001 From: dongzhengkuan Date: Mon, 1 Jul 2024 01:39:52 +0000 Subject: [PATCH 131/247] add pointer color invert callback ipc interface Signed-off-by: dongzhengkuan --- .../pipeline/rs_pointer_render_manager.cpp | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp index dd69e5dc37..73cfeb7e2e 100644 --- a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp @@ -24,8 +24,8 @@ namespace Rosen { namespace { static const std::string DISPLAY_NODE = "DisplayNode"; static const std::string POINTER_NODE = "pointer"; -static const float RGB = 255; -static const float HALF = 0.5; +static const float RGB = 255.f; +static const float HALF = 0.5f; } // namespace static std::unique_ptr g_pointerRenderManagerInstance = std::make_unique(); @@ -55,6 +55,12 @@ void RSPointerRenderManager::InitInstance(const std::shared_ptr(std::chrono::steady_clock::now()); + return std::chrono::duration_cast(timeNow.time_since_epoch()).count(); +} + void RSPointerRenderManager::SetPointerColorInversionConfig(float darkBuffer, float brightBuffer, int64_t interval) { std::lock_guard lock(cursorInvertMutex_); @@ -68,7 +74,7 @@ void RSPointerRenderManager::SetPointerColorInversionEnabled(bool enable) std::lock_guard lock(cursorInvertMutex_); isEnableCursorInversion_ = enable; if (!enable) { - brightness_ = CursorBrightness::NONE; + brightnessMode_ = CursorBrightness::NONE; } } @@ -88,6 +94,7 @@ void RSPointerRenderManager::UnRegisterPointerLuminanceChangeCallback(pid_t pid) void RSPointerRenderManager::ExecutePointerLuminanceChangeCallback(int32_t brightness) { std::lock_guard lock(cursorInvertMutex_); + lastColorPickerTime_ = RSPointerRenderManager::GetCurrentTime(); for (auto it = colorChangeListeners_.begin(); it != colorChangeListeners_.end(); it++) { if (it->second) { it->second->OnPointerLuminanceChanged(brightness); @@ -98,26 +105,20 @@ void RSPointerRenderManager::ExecutePointerLuminanceChangeCallback(int32_t brigh void RSPointerRenderManager::CallPointerLuminanceChange(int32_t brightness) { RS_LOGD("RSPointerRenderManager::CallPointerLuminanceChange luminance_:%{public}d.", luminance_); - auto timeNow = std::chrono::time_point_cast(std::chrono::steady_clock::now()); - auto tmp = std::chrono::duration_cast(timeNow.time_since_epoch()); - lastColorPickerTime_ = tmp.count(); - if (brightness_ == CursorBrightness::NONE) { - if (brightness < RGB * HALF) { - brightness_ = CursorBrightness::DARK; - } else { - brightness_ = CursorBrightness::BRIGHT; - } + if (brightnessMode_ == CursorBrightness::NONE) { + brightnessMode_ = brightness < static_cast(RGB * HALF) ? + CursorBrightness::DARK : CursorBrightness::BRIGHT; ExecutePointerLuminanceChangeCallback(brightness); - } else if (brightness_ == CursorBrightness::DARK) { - // 暗光标 --> 亮光标 缓冲区 - if (brightness > RGB * darkBuffer_) { - brightness_ = CursorBrightness::BRIGHT; + } else if (brightnessMode_ == CursorBrightness::DARK) { + // Dark cursor to light cursor buffer + if (brightness > static_cast(RGB * darkBuffer_)) { + brightnessMode_ = CursorBrightness::BRIGHT; ExecutePointerLuminanceChangeCallback(brightness); } } else { - // 亮光标 --> 暗光标 缓冲区 - if (brightness < RGB * brightBuffer_) { - brightness_ = CursorBrightness::DARK; + // light cursor to Dark cursor buffer + if (brightness < static_cast(RGB * brightBuffer_)) { + brightnessMode_ = CursorBrightness::DARK; ExecutePointerLuminanceChangeCallback(brightness); } } @@ -129,9 +130,7 @@ bool RSPointerRenderManager::CheckColorPickerEnabled() return false; } - auto timeNow = std::chrono::time_point_cast(std::chrono::steady_clock::now()); - auto tmp = std::chrono::duration_cast(timeNow.time_since_epoch()); - auto time = tmp.count() - lastColorPickerTime_; + auto time = RSPointerRenderManager::GetCurrentTime() - lastColorPickerTime_; if (time < colorSamplingInterval_) { return false; } From b752c3fdc45dd6d5bdb818d5d210bd16955102bd Mon Sep 17 00:00:00 2001 From: dongzhengkuan Date: Mon, 1 Jul 2024 01:40:37 +0000 Subject: [PATCH 132/247] add pointer invert callback ipc interface Signed-off-by: dongzhengkuan --- .../core/pipeline/rs_pointer_render_manager.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.h b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.h index 71a88b9e0e..cfc96dd5de 100644 --- a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.h +++ b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.h @@ -39,6 +39,7 @@ public: #endif static RSPointerRenderManager& GetInstance(); + static int64_t GetCurrentTime(); void ProcessColorPicker(std::shared_ptr processor, std::shared_ptr gpuContext); void SetPointerColorInversionConfig(float darkBuffer, float brightBuffer, int64_t interval); void SetPointerColorInversionEnabled(bool enable); @@ -91,11 +92,11 @@ private: BRIGHT, DARK }; - CursorBrightness brightness_ = CursorBrightness::NONE; + CursorBrightness brightnessMode_ = CursorBrightness::NONE; int64_t lastColorPickerTime_ = 0; int64_t colorSamplingInterval_ = 50; - float darkBuffer_ = 0.55; - float brightBuffer_ = 0.35; + float darkBuffer_ = 0.55f; + float brightBuffer_ = 0.35f; }; } #endif // RS_POINTER_RENDER_MANAGER_H \ No newline at end of file From ea1b2c7035a6a92962b24decb96da3fa8a72b719 Mon Sep 17 00:00:00 2001 From: dongzhengkuan Date: Mon, 1 Jul 2024 01:41:57 +0000 Subject: [PATCH 133/247] add pointer color invert ipc callback interface Signed-off-by: dongzhengkuan --- ...minance_change_callback_ipc_interface_code_access_verifier.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/modules/render_service_base/include/ipc_callbacks/pointer_luminance_change_callback_ipc_interface_code_access_verifier.h b/rosen/modules/render_service_base/include/ipc_callbacks/pointer_luminance_change_callback_ipc_interface_code_access_verifier.h index 172a806729..8f7bd97b68 100644 --- a/rosen/modules/render_service_base/include/ipc_callbacks/pointer_luminance_change_callback_ipc_interface_code_access_verifier.h +++ b/rosen/modules/render_service_base/include/ipc_callbacks/pointer_luminance_change_callback_ipc_interface_code_access_verifier.h @@ -32,7 +32,7 @@ public: /* specify constructor and destructor here */ RSIPointerLuminanceChangeCallbackInterfaceCodeAccessVerifier(); - ~RSIPointerLuminanceChangeCallbackInterfaceCodeAccessVerifier() noexcept override = default; + virtual ~RSIPointerLuminanceChangeCallbackInterfaceCodeAccessVerifier() noexcept override = default; protected: /* specify exclusive verification rules here */ From c8b2515066c12fa403fb966f95dbc680ad17f8de Mon Sep 17 00:00:00 2001 From: diaochenggong Date: Mon, 1 Jul 2024 09:42:00 +0800 Subject: [PATCH 134/247] =?UTF-8?q?=E5=87=8F=E5=B0=91=E5=86=97=E4=BD=99?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=89=93=E5=8D=B0=EF=BC=8C=E7=AD=89=E4=BA=8E?= =?UTF-8?q?1=E6=97=B6=E6=9C=AC=E8=BA=AB=E4=B9=9F=E6=97=A0=E9=9C=80?= =?UTF-8?q?=E5=8E=8B=E6=9A=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: diaochenggong --- .../modules/render_service_base/src/property/rs_properties.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/modules/render_service_base/src/property/rs_properties.cpp b/rosen/modules/render_service_base/src/property/rs_properties.cpp index bc60bc05aa..3334e3603b 100644 --- a/rosen/modules/render_service_base/src/property/rs_properties.cpp +++ b/rosen/modules/render_service_base/src/property/rs_properties.cpp @@ -1760,7 +1760,7 @@ const std::optional& RSProperties::GetGreyCoef() const bool RSProperties::IsDynamicDimValid() const { return dynamicDimDegree_.has_value() && - ROSEN_GE(*dynamicDimDegree_, 0.0) && ROSEN_LE(*dynamicDimDegree_, 1.0); + ROSEN_GE(*dynamicDimDegree_, 0.0) && ROSEN_LNE(*dynamicDimDegree_, 1.0); } const std::shared_ptr& RSProperties::GetFilter() const From 5bf3d7caae7f22f03834db0fccdf69b3bdbfc921 Mon Sep 17 00:00:00 2001 From: siyuan Date: Mon, 1 Jul 2024 09:56:48 +0800 Subject: [PATCH 135/247] third commit Signed-off-by: siyuan --- .../render/rs_attraction_effect_filter.cpp | 34 +- .../unittest/render/BUILD.gn | 1 + .../rs_attraction_effect_filter_test.cpp | 394 ++++++++++++++++++ .../render/rs_spherize_effect_filter_test.cpp | 2 +- 4 files changed, 414 insertions(+), 17 deletions(-) create mode 100644 rosen/test/render_service/render_service_base/unittest/render/rs_attraction_effect_filter_test.cpp diff --git a/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp b/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp index 9fac44db2e..243d8304b8 100644 --- a/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp +++ b/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp @@ -293,12 +293,12 @@ std::vector RSAttractionEffectFilter::CalculateUpperCtrlPointOfV { // Different regression parameters are used for different scenarios // Coordinates of the upper control point of the curve:(k1 * width + k2 * deltaX, k3 * height + k4 * deltaY) - Drawing::Point topLeft = { (0.016f * width - 0.08f * deltaX) * location, 0.464f * height + 0.40f * deltaY }; - Drawing::Point bottomLeft = { (-0.15f * width - 0.075f * deltaX) * location, 0.0f * height + 0.2f * deltaY }; - if (!isBelowTarget_) { - topLeft = { (-0.100f * width - 0.008f * deltaX) * location, 0.008f * height + 0.085f * deltaY }; - bottomLeft = { (-0.008f * width - 0.008f * deltaX) * location, 0.0f * height - 0.008f * deltaY }; - } + Drawing::Point topLeft = isBelowTarget_ ? + Drawing::Point((0.016f * width - 0.08f * deltaX) * location, 0.464f * height + 0.40f * deltaY) : + Drawing::Point((-0.100f * width - 0.008f * deltaX) * location, 0.008f * height + 0.085f * deltaY); + Drawing::Point bottomLeft = isBelowTarget_ ? + Drawing::Point((-0.15f * width - 0.075f * deltaX) * location, 0.0f * height + 0.2f * deltaY ) : + Drawing::Point((-0.008f * width - 0.008f * deltaX) * location, 0.0f * height - 0.008f * deltaY); Drawing::Point topRight = { (-1.147f * width - 0.016f * deltaX) * location, -0.187f * height + 0.30f * deltaY }; Drawing::Point bottomRight = { (-0.848f * width - 0.2f * deltaX) * location, -0.859f * height - 0.2f * deltaY }; std::vector upperControlPoint = { topLeft, topRight, bottomLeft, bottomRight }; @@ -311,16 +311,18 @@ std::vector RSAttractionEffectFilter::CalculateLowerCtrlPointOfV float inverseWidth = (width >= 1.0f) ? (1.0f / width) : 1.0f; // Different regression parameters are used for different scenarios // Coordinates of the lower control point of the curve:(m1*(deltaX * height/width - width)), m2 * deltaY) - Drawing::Point topLeft = { (0.3f * (deltaX * height * inverseWidth - width)) * location, -0.20f * deltaY }; - Drawing::Point topRight = { (0.45f * (deltaX * height * inverseWidth - width)) * location, -0.30f * deltaY }; - Drawing::Point bottomLeft = { (0.15f * (deltaX * height * inverseWidth - width)) * location, -0.20f * deltaY }; - Drawing::Point bottomRight = { (0.30f * (deltaX * height * inverseWidth - width)) * location, -0.112f * deltaY }; - if (!isBelowTarget_) { - topLeft = { (0.131f * (deltaX * height * inverseWidth - width)) * location, -0.20f * deltaY }; - topRight = { (0.147f * (deltaX * height * inverseWidth - width)) * location, -0.30f * deltaY }; - bottomLeft = { (0.085f * (deltaX * height * inverseWidth - width)) * location, 0.008f * deltaY }; - bottomRight = { (0.147f * (deltaX * height * inverseWidth - width)) * location, -0.069f * deltaY }; - } + Drawing::Point topLeft = isBelowTarget_ ? + Drawing::Point((0.300f * (deltaX * height * inverseWidth - width)) * location, -0.20f * deltaY) : + Drawing::Point((0.131f * (deltaX * height * inverseWidth - width)) * location, -0.20f * deltaY); + Drawing::Point topRight = isBelowTarget_ ? + Drawing::Point((0.450f * (deltaX * height * inverseWidth - width)) * location, -0.30f * deltaY) : + Drawing::Point((0.147f * (deltaX * height * inverseWidth - width)) * location, -0.30f * deltaY); + Drawing::Point bottomLeft = isBelowTarget_ ? + Drawing::Point((0.150f * (deltaX * height * inverseWidth - width)) * location, -0.20f * deltaY) : + Drawing::Point((0.085f * (deltaX * height * inverseWidth - width)) * location, 0.008f * deltaY); + Drawing::Point bottomRight = isBelowTarget_ ? + Drawing::Point((0.300f * (deltaX * height * inverseWidth - width)) * location, -0.112f * deltaY) : + Drawing::Point((0.147f * (deltaX * height * inverseWidth - width)) * location, -0.069f * deltaY); std::vector lowerControlPoint = { topLeft, topRight, bottomLeft, bottomRight }; return lowerControlPoint; } diff --git a/rosen/test/render_service/render_service_base/unittest/render/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/render/BUILD.gn index 6b54e0edd0..4cc4448933 100644 --- a/rosen/test/render_service/render_service_base/unittest/render/BUILD.gn +++ b/rosen/test/render_service/render_service_base/unittest/render/BUILD.gn @@ -24,6 +24,7 @@ ohos_unittest("RSRenderServiceBaseRenderTest") { sources = [ "rs_aibar_filter_test.cpp", "rs_aibar_shader_filter_test.cpp", + "rs_attraction_effect_filter_test.cpp", "rs_blur_filter_test.cpp", "rs_border_test.cpp", "rs_color_extract_test.cpp", diff --git a/rosen/test/render_service/render_service_base/unittest/render/rs_attraction_effect_filter_test.cpp b/rosen/test/render_service/render_service_base/unittest/render/rs_attraction_effect_filter_test.cpp new file mode 100644 index 0000000000..6d8f0f36b6 --- /dev/null +++ b/rosen/test/render_service/render_service_base/unittest/render/rs_attraction_effect_filter_test.cpp @@ -0,0 +1,394 @@ +/* + * 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 "gtest/gtest.h" + +#include "render/rs_spherize_effect_filter.h" +#include "draw/color.h" +#include "image/image_info.h" +#include "skia_image.h" +#include "skia_image_info.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Rosen { + +class RSAttractionEffectFilterTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void RSAttractionEffectFilterTest::SetUpTestCase() {} +void RSAttractionEffectFilterTest::TearDownTestCase() {} +void RSAttractionEffectFilterTest::SetUp() {} +void RSAttractionEffectFilterTest::TearDown() {} + +/** + * @tc.name: DrawImageRect001 + * @tc.desc: test results of DrawImageRect + * @tc.type: FUNC + * @tc.require: issueI9UX8W + */ +HWTEST_F(RSAttractionEffectFilterTest, DrawImageRect001, TestSize.Level1) +{ + RSAttractionEffectFilter effectFilter(0.f); + Drawing::Canvas canvas; + std::shared_ptr image; + Drawing::Rect src; + Drawing::Rect dst; + effectFilter.DrawImageRect(canvas, image, src, dst); + EXPECT_FALSE(image); + + effectFilter.attractionFraction_ = 1.0f; + image = std::make_shared(); + effectFilter.DrawImageRect(canvas, image, src, dst); + EXPECT_TRUE(image); + + Drawing::ImageInfo imageInfo(1, 1, Drawing::ColorType::COLORTYPE_ALPHA_8, Drawing::AlphaType::ALPHATYPE_OPAQUE); + auto skImageInfo = Drawing::SkiaImageInfo::ConvertToSkImageInfo(imageInfo); + int addr1 = 1; + int* addr = &addr1; + auto skiaPixmap = SkPixmap(skImageInfo, addr, 1); + Drawing::ReleaseContext releaseContext = nullptr; + Drawing::RasterReleaseProc rasterReleaseProc = nullptr; + sk_sp skImage = SkImage::MakeFromRaster(skiaPixmap, rasterReleaseProc, releaseContext); + auto skiaImage = std::make_shared(skImage); + image->imageImplPtr = skiaImage; + effectFilter.DrawImageRect(canvas, image, src, dst); + EXPECT_TRUE(image->GetWidth()); + EXPECT_TRUE(image->GetHeight()); +} + +/** + * @tc.name: IsValid001 + * @tc.desc: test results of IsValid + * @tc.type: FUNC + * @tc.require: issueI9UX8W + */ +HWTEST_F(RSAttractionEffectFilterTest, IsValid001, TestSize.Level1) +{ + RSAttractionEffectFilter firstEffectFilter(0.f); + EXPECT_FALSE(firstEffectFilter.IsValid()); + + RSAttractionEffectFilter secondEffectFilter(1.f); + EXPECT_TRUE(firstEffectFilter.IsValid()); + +} + +/** + * @tc.name: GetAttractionFraction001 + * @tc.desc: test results of GetAttractionFraction + * @tc.type: FUNC + * @tc.require: issueI9UX8W + */ +HWTEST_F(RSAttractionEffectFilterTest, GetAttractionFraction001, TestSize.Level1) +{ + RSAttractionEffectFilter firstEffectFilter(0.5f); + EXPECT_EQ(firstEffectFilter.GetAttractionFraction(), 0.5f); + + RSAttractionEffectFilter secondEffectFilter(1.0f); + EXPECT_NE(secondEffectFilter.GetAttractionFraction(), 0.5f); +} + +/** + * @tc.name: GetAttractionDirtyRegion001 + * @tc.desc: test results of GetAttractionDirtyRegion + * @tc.type: FUNC + * @tc.require: issueI9UX8W + */ +HWTEST_F(RSAttractionEffectFilterTest, GetAttractionDirtyRegion001, TestSize.Level1) +{ + RSAttractionEffectFilter firstEffectFilter(0.5f); + EXPECT_TRUE(firstEffectFilter.GetAttractionDirtyRegion.x_ == 0); + + float leftPoint = 10.f; + float topPonit = 10.f; + firstEffectFilter.UpdateDirtyRegion(leftPoint, topPonit); + EXPECT_FALSE(firstEffectFilter.GetAttractionDirtyRegion.x_ == 0); +} + +/** + * @tc.name: IsWithinThreshold001 + * @tc.desc: test results of IsWithinThreshold + * @tc.type: FUNC + * @tc.require: issueI9UX8W + */ +HWTEST_F(RSAttractionEffectFilterTest, IsWithinThreshold001, TestSize.Level1) +{ + RSAttractionEffectFilter firstEffectFilter(0.5f); + float firstPoint = 10.f; + float secondPoint = 10.f; + float error = 0.001f; + EXPECT_TRUE(firstEffectFilter.IsWithinThreshold(firstPoint, secondPoint, error)); + + float thirdPoint = 5.f; + EXPECT_FALSE(firstEffectFilter.IsWithinThreshold(firstPoint, thirdPoint, error)); +} + +/** + * @tc.name: LerpPoint001 + * @tc.desc: test results of LerpPoint + * @tc.type: FUNC + * @tc.require: issueI9UX8W + */ +HWTEST_F(RSAttractionEffectFilterTest, LerpPoint001, TestSize.Level1) +{ + RSAttractionEffectFilter firstEffectFilter(0.5f); + Drawing::Point p1 = { 0.0f, 0.0f }; + Drawing::Point p2 = { 10.0f, 10.0f }; + float firstFactor = 0.5f; + float secondFactor = 0.5f; + Drawing::Point point = firstEffectFilter.LerpPoint(p1, p2, firstFactor, secondFactor); + EXPECT_EQ(point.GetX(), 5.0f); +} + +/** + * @tc.name: CubicBezier001 + * @tc.desc: test results of CubicBezier + * @tc.type: FUNC + * @tc.require: issueI9UX8W + */ +HWTEST_F(RSAttractionEffectFilterTest, CubicBezier001, TestSize.Level1) +{ + RSAttractionEffectFilter firstEffectFilter(0.5f); + Drawing::Point p1 = { 0.0f, 0.0f }; + Drawing::Point p2 = { 10.0f, 10.0f }; + Drawing::Point p3 = { 20.0f, 20.0f }; + Drawing::Point p4 = { 30.0f, 30.0f }; + float t = 0.5f; + Drawing::Point point = firstEffectFilter.CubicBezier(p1, p2, p3, p4, t); + EXPECT_NE(point.GetX(), 0.0f); +} + +/** + * @tc.name: CalculateCubic001 + * @tc.desc: test results of CalculateCubic + * @tc.type: FUNC + * @tc.require: issueI9UX8W + */ +HWTEST_F(RSAttractionEffectFilterTest, CalculateCubic001, TestSize.Level1) +{ + RSAttractionEffectFilter firstEffectFilter(0.5f); + float p1 = 0.5f; + float p2 = 0.8f; + float t = 0.5f; + EXPECT_NE(firstEffectFilter.CalculateCubic(p1, p2, t), 0.0f); +} + +/** + * @tc.name: BinarySearch001 + * @tc.desc: test results of BinarySearch + * @tc.type: FUNC + * @tc.require: issueI9UX8W + */ +HWTEST_F(RSAttractionEffectFilterTest, BinarySearch001, TestSize.Level1) +{ + RSAttractionEffectFilter firstEffectFilter(0.5f); + Drawing::Point p1 = { 0.2f, 0.0f }; + Drawing::Point p2 = { 0.2f, 1.0f }; + float targetX = 0.5f; + EXPECT_NE(firstEffectFilter.BinarySearch(targetX, p1, p2), 0.0f); +} + +/** + * @tc.name: CalculateCubicsCtrlPointOffset001 + * @tc.desc: test results of CalculateCubicsCtrlPointOffset + * @tc.type: FUNC + * @tc.require: issueI9UX8W + */ +HWTEST_F(RSAttractionEffectFilterTest, CalculateCubicsCtrlPointOffset001, TestSize.Level1) +{ + RSAttractionEffectFilter firstEffectFilter(0.5f); + int pointNum = 4; + std::vector pathCtrlPointList(pointNum, Drawing::Point(0.0f, 0.0f)); + std::vector pathList = firstEffectFilter.CalculateCubicsCtrlPointOffset(pathCtrlPointList); + EXPECT_FALSE(pathList.empty()); +} + +/** + * @tc.name: CreateIndexSequence001 + * @tc.desc: test results of CreateIndexSequence + * @tc.type: FUNC + * @tc.require: issueI9UX8W + */ +HWTEST_F(RSAttractionEffectFilterTest, CreateIndexSequence001, TestSize.Level1) +{ + RSAttractionEffectFilter firstEffectFilter(0.5f); + float direction = 1.0f; + std::vector pathList = firstEffectFilter.CreateIndexSequence(direction); + EXPECT_TRUE(pathList0[0] == 0); + + direction = -1.0f; + pathList = firstEffectFilter.CreateIndexSequence(direction); + EXPECT_TRUE(pathList0[0] == 3); +} + +/** + * @tc.name: CreateIndexSequence001 + * @tc.desc: test results of CreateIndexSequence + * @tc.type: FUNC + * @tc.require: issueI9UX8W + */ +HWTEST_F(RSAttractionEffectFilterTest, CreateIndexSequence001, TestSize.Level1) +{ + RSAttractionEffectFilter firstEffectFilter(0.5f); + float direction = 1.0f; + std::vector pathList = firstEffectFilter.CreateIndexSequence(direction); + EXPECT_TRUE(pathList0[0] == 0); + + direction = -1.0f; + pathList = firstEffectFilter.CreateIndexSequence(direction); + EXPECT_TRUE(pathList0[0] == 3); +} + +/** + * @tc.name: CreateIndexSequence002 + * @tc.desc: test results of CreateIndexSequence + * @tc.type: FUNC + * @tc.require: issueI9UX8W + */ +HWTEST_F(RSAttractionEffectFilterTest, CreateIndexSequence002, TestSize.Level1) +{ + RSAttractionEffectFilter firstEffectFilter(0.5f); + Vector2f destinationPoint(5.0f, 20.0f); + float canvasWidth = 10.f; + float canvasHeight = 10.f; + firstEffectFilter.CalculateWindowStatus(canvasWidth, canvasHeight, destinationPoint); + float direction = 1.0f; + std::vector pathList = firstEffectFilter.CreateIndexSequence(direction); + EXPECT_TRUE(pathList0[0] == 9); + + direction = -1.0f; + pathList = firstEffectFilter.CreateIndexSequence(direction); + EXPECT_TRUE(pathList0[0] == 0); +} + +/** + * @tc.name: CalculateVelocityCtrlPointUpper001 + * @tc.desc: test results of CalculateVelocityCtrlPointUpper + * @tc.type: FUNC + * @tc.require: issueI9UX8W + */ +HWTEST_F(RSAttractionEffectFilterTest, CalculateVelocityCtrlPointUpper001, TestSize.Level1) +{ + RSAttractionEffectFilter firstEffectFilter(0.5f); + Vector2f destinationPoint(5.0f, 15.0f); + float canvasWidth = 10.f; + float canvasHeight = 10.f; + firstEffectFilter.CalculateWindowStatus(canvasWidth, canvasHeight, destinationPoint); + std::vector velocityCtrlPointUpper = firstEffectFilter.CalculateVelocityCtrlPointUpper(); + EXPECT_EQ(velocityCtrlPointUpper[0].GetX() == 0.5f); + EXPECT_EQ(velocityCtrlPointUpper[1].GetX() == 0.0f); + + Vector2f destinationPointBelow(5.0f, 15.0f); + firstEffectFilter.CalculateWindowStatus(canvasWidth, canvasHeight, destinationPointBelow); + std::vector velocityCtrlPointUpperBelow = firstEffectFilter.CalculateVelocityCtrlPointUpper(); + EXPECT_EQ(velocityCtrlPointUpperBelow[0].GetX() == 0.5f); + EXPECT_EQ(velocityCtrlPointUpperBelow[1].GetX() == 0.2f); +} + +/** + * @tc.name: CalculateVelocityCtrlPointLower001 + * @tc.desc: test results of CalculateVelocityCtrlPointLower + * @tc.type: FUNC + * @tc.require: issueI9UX8W + */ +HWTEST_F(RSAttractionEffectFilterTest, CalculateVelocityCtrlPointLower001, TestSize.Level1) +{ + RSAttractionEffectFilter firstEffectFilter(0.5f); + Vector2f destinationPoint(5.0f, 15.0f); + float canvasWidth = 10.f; + float canvasHeight = 10.f; + firstEffectFilter.CalculateWindowStatus(canvasWidth, canvasHeight, destinationPoint); + std::vector velocityCtrlPointUpper = firstEffectFilter.CalculateVelocityCtrlPointLower(); + EXPECT_EQ(velocityCtrlPointUpper[0].GetX() == 0.5f); + EXPECT_EQ(velocityCtrlPointUpper[1].GetX() == 0.0f); + + Vector2f destinationPointBelow(5.0f, 15.0f); + firstEffectFilter.CalculateWindowStatus(canvasWidth, canvasHeight, destinationPointBelow); + std::vector velocityCtrlPointUpperBelow = firstEffectFilter.CalculateVelocityCtrlPointLower(); + EXPECT_EQ(velocityCtrlPointUpperBelow[0].GetX() == 0.5f); + EXPECT_EQ(velocityCtrlPointUpperBelow[1].GetX() == 0.2f); +} + +/** + * @tc.name: CalculateUpperCtrlPointOfVertex001 + * @tc.desc: test results of CalculateUpperCtrlPointOfVertex + * @tc.type: FUNC + * @tc.require: issueI9UX8W + */ +HWTEST_F(RSAttractionEffectFilterTest, CalculateUpperCtrlPointOfVertex001, TestSize.Level1) +{ + RSAttractionEffectFilter firstEffectFilter(0.5f); + Vector2f destinationPoint(5.0f, 15.0f); + float canvasWidth = 10.f; + float canvasHeight = 10.f; + firstEffectFilter.CalculateWindowStatus(canvasWidth, canvasHeight, destinationPoint); + float deltaX = 1.f; + float deltaY = 1.f; + float width = 10.0f; + float height = 10.0f; + int direction = 1.0; + std::vector upperControlPointOfVertex1 = + firstEffectFilter.CalculateUpperCtrlPointOfVertex(deltaX, deltaY, width, height, direction); + + Vector2f destinationPointBelow(5.0f, 5.0f); + firstEffectFilter.CalculateWindowStatus(canvasWidth, canvasHeight, destinationPointBelow); + std::vector upperControlPointOfVertex2 = + firstEffectFilter.CalculateUpperCtrlPointOfVertex(deltaX, deltaY, width, height, direction); + + EXPECT_NE(upperControlPointOfVertex1[0].GetX() == upperControlPointOfVertex2[0].GetX()); + EXPECT_NE(upperControlPointOfVertex1[1].GetX() == upperControlPointOfVertex2[1].GetX()); + EXPECT_EQ(upperControlPointOfVertex1[2].GetX() == upperControlPointOfVertex2[2].GetX()); + EXPECT_EQ(upperControlPointOfVertex1[3].GetX() == upperControlPointOfVertex2[3].GetX()); +} + +/** + * @tc.name: CalculateLowerCtrlPointOfVertex001 + * @tc.desc: test results of CalculateLowerCtrlPointOfVertex + * @tc.type: FUNC + * @tc.require: issueI9UX8W + */ +HWTEST_F(RSAttractionEffectFilterTest, CalculateLowerCtrlPointOfVertex001, TestSize.Level1) +{ + RSAttractionEffectFilter firstEffectFilter(0.5f); + Vector2f destinationPoint(5.0f, 15.0f); + float canvasWidth = 10.f; + float canvasHeight = 10.f; + firstEffectFilter.CalculateWindowStatus(canvasWidth, canvasHeight, destinationPoint); + float deltaX = 1.f; + float deltaY = 1.f; + float width = 10.0f; + float height = 10.0f; + int direction = 1.0; + std::vector upperControlPointOfVertex1 = + firstEffectFilter.CalculateLowerCtrlPointOfVertex(deltaX, deltaY, width, height, direction); + + Vector2f destinationPointBelow(5.0f, 5.0f); + firstEffectFilter.CalculateWindowStatus(canvasWidth, canvasHeight, destinationPointBelow); + std::vector upperControlPointOfVertex2 = + firstEffectFilter.CalculateLowerCtrlPointOfVertex(deltaX, deltaY, width, height, direction); + + EXPECT_NE(upperControlPointOfVertex1[0].GetX() == upperControlPointOfVertex2[0].GetX()); + EXPECT_NE(upperControlPointOfVertex1[1].GetX() == upperControlPointOfVertex2[1].GetX()); + EXPECT_NE(upperControlPointOfVertex1[2].GetX() == upperControlPointOfVertex2[2].GetX()); + EXPECT_NE(upperControlPointOfVertex1[3].GetX() == upperControlPointOfVertex2[3].GetX()); +} +} // namespace Rosen +} // namespace OHOS diff --git a/rosen/test/render_service/render_service_base/unittest/render/rs_spherize_effect_filter_test.cpp b/rosen/test/render_service/render_service_base/unittest/render/rs_spherize_effect_filter_test.cpp index ed2181edea..6b7541b6cc 100644 --- a/rosen/test/render_service/render_service_base/unittest/render/rs_spherize_effect_filter_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/render/rs_spherize_effect_filter_test.cpp @@ -14,7 +14,7 @@ */ #include "gtest/gtest.h" -#include "render/rs_spherize_effect_filter.h" +#include "render/rs_attraction_effect_filter.h" #include "draw/color.h" #include "image/image_info.h" #include "skia_image.h" From dfa1b2a604d423360a5f59c978c6bcf5730d6d47 Mon Sep 17 00:00:00 2001 From: zhaoshuhao8899 Date: Fri, 28 Jun 2024 10:31:35 +0800 Subject: [PATCH 136/247] add get refresh info interface Signed-off-by: zhaoshuhao8899 --- .../pipeline/rs_render_service_connection.cpp | 20 ++++++++++++++++++ .../pipeline/rs_render_service_connection.h | 2 ++ .../rs_render_service_connection_stub.cpp | 11 ++++++++++ .../include/pipeline/rs_render_node_map.h | 2 ++ .../ohos/rs_irender_service_connection.h | 2 ++ ...er_service_connection_ipc_interface_code.h | 1 + .../transaction/rs_render_service_client.h | 2 ++ .../src/pipeline/rs_render_node_map.cpp | 13 ++++++++++++ .../darwin/rs_render_service_client.cpp | 5 +++++ .../ohos/rs_render_service_client.cpp | 10 +++++++++ .../rs_render_service_connection_proxy.cpp | 21 +++++++++++++++++++ .../ohos/rs_render_service_connection_proxy.h | 2 ++ .../windows/rs_render_service_client.cpp | 5 +++++ .../core/transaction/rs_interfaces.cpp | 5 +++++ .../core/transaction/rs_interfaces.h | 2 ++ ...rs_render_service_connection_stub_test.cpp | 3 +++ 16 files changed, 106 insertions(+) diff --git a/rosen/modules/render_service/core/pipeline/rs_render_service_connection.cpp b/rosen/modules/render_service/core/pipeline/rs_render_service_connection.cpp index cde79b808d..fd4e1f871f 100644 --- a/rosen/modules/render_service/core/pipeline/rs_render_service_connection.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_render_service_connection.cpp @@ -587,6 +587,26 @@ void RSRenderServiceConnection::SetShowRefreshRateEnabled(bool enable) return RSRealtimeRefreshRateManager::Instance().SetShowRefreshRateEnabled(enable); } +std::string RSRenderServiceConnection::GetRefreshInfo(pid_t pid) +{ + auto& context = mainThread_->GetContext(); + auto& nodeMap = context.GetMutableNodeMap(); + std::string surfaceName = nodeMap.GetSelfDrawSurfaceNameByPid(pid); + if (surfaceName.empty()) { + return ""; + } + std::string dumpString; + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { + RSHardwareThread::Instance().ScheduleTask( + [this, &dumpString, &surfaceName]() { return screenManager_->FpsDump(dumpString, surfaceName); }).wait(); + } else { + mainThread_->ScheduleTask( + [this, &dumpString, &surfaceName]() { return screenManager_->FpsDump(dumpString, surfaceName); }).wait(); + } + return dumpString; +} + int32_t RSRenderServiceConnection::GetCurrentRefreshRateMode() { auto &hgmCore = OHOS::Rosen::HgmCore::Instance(); diff --git a/rosen/modules/render_service/core/pipeline/rs_render_service_connection.h b/rosen/modules/render_service/core/pipeline/rs_render_service_connection.h index d809f4817a..08839da026 100644 --- a/rosen/modules/render_service/core/pipeline/rs_render_service_connection.h +++ b/rosen/modules/render_service/core/pipeline/rs_render_service_connection.h @@ -130,6 +130,8 @@ private: void SetShowRefreshRateEnabled(bool enable) override; + std::string GetRefreshInfo(pid_t pid) override; + int32_t SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height) override; void MarkPowerOffNeedProcessOneFrame() override; diff --git a/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp b/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp index 6123f28c77..08b5e51f84 100644 --- a/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp +++ b/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp @@ -489,6 +489,17 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( SetShowRefreshRateEnabled(enable); break; } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO): { + auto token = data.ReadInterfaceToken(); + if (token != RSIRenderServiceConnection::GetDescriptor()) { + ret = ERR_INVALID_STATE; + break; + } + pid_t pid = data.ReadInt32(); + std::string ret = GetRefreshInfo(pid); + reply.WriteString(ret); + break; + } case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_RESOLUTION): { ScreenId id = data.ReadUint64(); uint32_t width = data.ReadUint32(); diff --git a/rosen/modules/render_service_base/include/pipeline/rs_render_node_map.h b/rosen/modules/render_service_base/include/pipeline/rs_render_node_map.h index 48e7f70c8d..c47e7cde6b 100644 --- a/rosen/modules/render_service_base/include/pipeline/rs_render_node_map.h +++ b/rosen/modules/render_service_base/include/pipeline/rs_render_node_map.h @@ -46,6 +46,8 @@ public: const std::shared_ptr GetAnimationFallbackNode() const; + const std::string GetSelfDrawSurfaceNameByPid(pid_t nodePid) const; + bool ContainPid(pid_t pid) const; void FilterNodeByPid(pid_t pid); void MoveRenderNodeMap( diff --git a/rosen/modules/render_service_base/include/platform/ohos/rs_irender_service_connection.h b/rosen/modules/render_service_base/include/platform/ohos/rs_irender_service_connection.h index 0aff87e4e7..5980583b7c 100644 --- a/rosen/modules/render_service_base/include/platform/ohos/rs_irender_service_connection.h +++ b/rosen/modules/render_service_base/include/platform/ohos/rs_irender_service_connection.h @@ -120,6 +120,8 @@ public: virtual void SetShowRefreshRateEnabled(bool enable) = 0; + virtual std::string GetRefreshInfo(pid_t pid) = 0; + virtual int32_t SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height) = 0; virtual void MarkPowerOffNeedProcessOneFrame() = 0; diff --git a/rosen/modules/render_service_base/include/platform/ohos/rs_irender_service_connection_ipc_interface_code.h b/rosen/modules/render_service_base/include/platform/ohos/rs_irender_service_connection_ipc_interface_code.h index ec4d66ad3d..9ab21a3f16 100644 --- a/rosen/modules/render_service_base/include/platform/ohos/rs_irender_service_connection_ipc_interface_code.h +++ b/rosen/modules/render_service_base/include/platform/ohos/rs_irender_service_connection_ipc_interface_code.h @@ -48,6 +48,7 @@ enum class RSIRenderServiceConnectionInterfaceCode : CodeUnderlyingType { GET_SCREEN_SUPPORTED_REFRESH_RATES, GET_SHOW_REFRESH_RATE_ENABLED, SET_SHOW_REFRESH_RATE_ENABLED, + GET_REFRESH_INFO, MARK_POWER_OFF_NEED_PROCESS_ONE_FRAME, DISABLE_RENDER_CONTROL_SCREEN, SET_SCREEN_POWER_STATUS, diff --git a/rosen/modules/render_service_base/include/transaction/rs_render_service_client.h b/rosen/modules/render_service_base/include/transaction/rs_render_service_client.h index 56dc98da0b..b5a9a2d00b 100644 --- a/rosen/modules/render_service_base/include/transaction/rs_render_service_client.h +++ b/rosen/modules/render_service_base/include/transaction/rs_render_service_client.h @@ -179,6 +179,8 @@ public: void SetShowRefreshRateEnabled(bool enable); + std::string GetRefreshInfo(pid_t pid); + #ifndef ROSEN_ARKUI_X int32_t SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height); diff --git a/rosen/modules/render_service_base/src/pipeline/rs_render_node_map.cpp b/rosen/modules/render_service_base/src/pipeline/rs_render_node_map.cpp index 669776c0a6..d25fccda09 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_render_node_map.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_render_node_map.cpp @@ -312,5 +312,18 @@ const std::shared_ptr RSRenderNodeMap::GetAnimationFallbackNode() } return itr->second; } + +const std::string RSRenderNodeMap::GetSelfDrawSurfaceNameByPid(pid_t nodePid) const +{ + for (auto &t : surfaceNodeMap_) { + if (ExtractPid(t.first) == nodePid && t.second->IsSelfDrawingType()) { + return t.second->GetName(); + } + } + ROSEN_LOGD("RSRenderNodeMap::GetSurfaceNameByPid no self drawing nodes belong to pid %{public}d", + static_cast(nodePid)); + return ""; +} + } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/platform/darwin/rs_render_service_client.cpp b/rosen/modules/render_service_base/src/platform/darwin/rs_render_service_client.cpp index e15e113303..724c08abad 100644 --- a/rosen/modules/render_service_base/src/platform/darwin/rs_render_service_client.cpp +++ b/rosen/modules/render_service_base/src/platform/darwin/rs_render_service_client.cpp @@ -200,6 +200,11 @@ void RSRenderServiceClient::SetShowRefreshRateEnabled(bool enable) { } +std::string RSRenderServiceClient::GetRefreshInfo(pid_t pid) +{ + return ""; +} + int32_t RSRenderServiceClient::SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height) { return {}; diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_client.cpp b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_client.cpp index 2dfb7bc0f8..263b1e6219 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_client.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_client.cpp @@ -496,6 +496,16 @@ bool RSRenderServiceClient::GetShowRefreshRateEnabled() return renderService->GetShowRefreshRateEnabled(); } +std::string RSRenderServiceClient::GetRefreshInfo(pid_t pid) +{ + auto renderService = RSRenderServiceConnectHub::GetRenderService(); + if (renderService == nullptr) { + ROSEN_LOGW("RSRenderServiceClient renderService == nullptr!"); + return ""; + } + return renderService->GetRefreshInfo(pid); +} + void RSRenderServiceClient::SetShowRefreshRateEnabled(bool enable) { auto renderService = RSRenderServiceConnectHub::GetRenderService(); diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.cpp b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.cpp index a01cc4b8a7..67adeedda8 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.cpp @@ -776,6 +776,27 @@ void RSRenderServiceConnectionProxy::SetShowRefreshRateEnabled(bool enable) } } +std::string RSRenderServiceConnectionProxy::GetRefreshInfo(pid_t pid) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + ROSEN_LOGE("RSRenderServiceProxy failed to get descriptor"); + return ""; + } + option.SetFlags(MessageOption::TF_SYNC); + data.WriteInt32(pid); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO); + int32_t err = Remote()->SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err); + } + std::string enable = reply.ReadString(); + return enable; +} + int32_t RSRenderServiceConnectionProxy::SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height) { MessageParcel data; diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.h b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.h index c945770454..e8c2e6ef4f 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.h +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.h @@ -99,6 +99,8 @@ public: void SetShowRefreshRateEnabled(bool enable) override; + std::string GetRefreshInfo(pid_t pid) override; + int32_t SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height) override; void MarkPowerOffNeedProcessOneFrame() override; diff --git a/rosen/modules/render_service_base/src/platform/windows/rs_render_service_client.cpp b/rosen/modules/render_service_base/src/platform/windows/rs_render_service_client.cpp index d24561015f..81d3a3e77d 100644 --- a/rosen/modules/render_service_base/src/platform/windows/rs_render_service_client.cpp +++ b/rosen/modules/render_service_base/src/platform/windows/rs_render_service_client.cpp @@ -200,6 +200,11 @@ void RSRenderServiceClient::SetShowRefreshRateEnabled(bool enable) { } +std::string RSRenderServiceClient::GetRefreshInfo(pid_t pid) +{ + return ""; +} + int32_t RSRenderServiceClient::SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height) { return {}; diff --git a/rosen/modules/render_service_client/core/transaction/rs_interfaces.cpp b/rosen/modules/render_service_client/core/transaction/rs_interfaces.cpp index a6c89b8be2..d8545bb002 100644 --- a/rosen/modules/render_service_client/core/transaction/rs_interfaces.cpp +++ b/rosen/modules/render_service_client/core/transaction/rs_interfaces.cpp @@ -186,6 +186,11 @@ void RSInterfaces::SetShowRefreshRateEnabled(bool enable) return renderServiceClient_->SetShowRefreshRateEnabled(enable); } +std::string RSInterfaces::GetRefreshInfo(pid_t pid) +{ + return renderServiceClient_->GetRefreshInfo(pid); +} + bool RSInterfaces::TakeSurfaceCaptureForUI(std::shared_ptr node, std::shared_ptr callback, float scaleX, float scaleY, bool isSync) { diff --git a/rosen/modules/render_service_client/core/transaction/rs_interfaces.h b/rosen/modules/render_service_client/core/transaction/rs_interfaces.h index eeaac12140..bc56372f24 100644 --- a/rosen/modules/render_service_client/core/transaction/rs_interfaces.h +++ b/rosen/modules/render_service_client/core/transaction/rs_interfaces.h @@ -136,6 +136,8 @@ public: void SetShowRefreshRateEnabled(bool enable); + std::string GetRefreshInfo(pid_t pid); + #ifndef ROSEN_ARKUI_X std::vector GetScreenSupportedModes(ScreenId id); diff --git a/rosen/test/render_service/render_service/unittest/transaction/rs_render_service_connection_stub_test.cpp b/rosen/test/render_service/render_service/unittest/transaction/rs_render_service_connection_stub_test.cpp index ce774e5714..89d86827ef 100644 --- a/rosen/test/render_service/render_service/unittest/transaction/rs_render_service_connection_stub_test.cpp +++ b/rosen/test/render_service/render_service/unittest/transaction/rs_render_service_connection_stub_test.cpp @@ -164,6 +164,9 @@ HWTEST_F(RSRenderServiceConnectionStubTest, TestRSRenderServiceConnectionStub003 code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SHOW_REFRESH_RATE_ENABLED); res = connectionStub_->OnRemoteRequest(code, data, reply, option); ASSERT_EQ(res, ERR_INVALID_STATE); + code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO); + res = connectionStub_->OnRemoteRequest(code, data, reply, option); + ASSERT_EQ(res, ERR_INVALID_STATE); code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_RESOLUTION); res = connectionStub_->OnRemoteRequest(code, data, reply, option); ASSERT_EQ(res, ERR_INVALID_STATE); From fa9602af849ab0f570a025679e29b7fecbdba4d1 Mon Sep 17 00:00:00 2001 From: mengyiping <1091773127@qq.com> Date: Mon, 1 Jul 2024 10:41:22 +0800 Subject: [PATCH 137/247] feature Signed-off-by: mengyiping <1091773127@qq.com> --- .../drawable/rs_canvas_render_node_drawable.cpp | 1 + .../core/drawable/rs_render_node_drawable.cpp | 15 +++++++++++++++ .../core/drawable/rs_render_node_drawable.h | 4 ++++ .../drawable/rs_surface_render_node_drawable.cpp | 4 ++++ 4 files changed, 24 insertions(+) diff --git a/rosen/modules/render_service/core/drawable/rs_canvas_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_canvas_render_node_drawable.cpp index 4520f4b4af..782fab967f 100644 --- a/rosen/modules/render_service/core/drawable/rs_canvas_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_canvas_render_node_drawable.cpp @@ -72,6 +72,7 @@ void RSCanvasRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) } else { RSRenderNodeDrawable::OnDraw(canvas); } + RSRenderNodeDrawable::ProcessedNodeCountInc(); } /* diff --git a/rosen/modules/render_service/core/drawable/rs_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_render_node_drawable.cpp index 99bebb991a..3497845834 100644 --- a/rosen/modules/render_service/core/drawable/rs_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_render_node_drawable.cpp @@ -648,4 +648,19 @@ void RSRenderNodeDrawable::ClearTotalProcessedNodeCount() { totalProcessedNodeCount_ = 0; } + +int RSRenderNodeDrawable::GetProcessedNodeCount() +{ + return processedNodeCount_; +} + +void RSRenderNodeDrawable::ProcessedNodeCountInc() +{ + ++processedNodeCount_; +} + +void RSRenderNodeDrawable::ClearProcessedNodeCount() +{ + processedNodeCount_ = 0; +} } // namespace OHOS::Rosen::DrawableV2 diff --git a/rosen/modules/render_service/core/drawable/rs_render_node_drawable.h b/rosen/modules/render_service/core/drawable/rs_render_node_drawable.h index 9d1387c1cf..42607fa491 100644 --- a/rosen/modules/render_service/core/drawable/rs_render_node_drawable.h +++ b/rosen/modules/render_service/core/drawable/rs_render_node_drawable.h @@ -161,6 +161,9 @@ protected: void UpdateCacheSurface(Drawing::Canvas& canvas, const RSRenderParams& params); void TraverseSubTreeAndDrawFilterWithClip(Drawing::Canvas& canvas, const RSRenderParams& params); + static int GetProcessedNodeCount(); + static void ProcessedNodeCountInc(); + static void ClearProcessedNodeCount(); static thread_local bool drawBlurForCache_; private: @@ -182,6 +185,7 @@ private: static thread_local bool isOpDropped_; static inline std::atomic totalProcessedNodeCount_ = 0; + static inline std::atomic processedNodeCount_ = 0; // used foe render group cache // opinc cache state diff --git a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp index 2c36aec8e1..955baca784 100644 --- a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp @@ -16,6 +16,7 @@ #include "drawable/rs_surface_render_node_drawable.h" #include +#include "acquire_fence_manager.h" #include "common/rs_color.h" #include "common/rs_common_def.h" #include "draw/brush.h" @@ -349,6 +350,7 @@ void RSSurfaceRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) if (surfaceParams->IsMainWindowType()) { RSRenderNodeDrawable::ClearTotalProcessedNodeCount(); + RSRenderNodeDrawable::ClearProcessedNodeCount(); if (!surfaceParams->GetNeedOffscreen()) { curCanvas_->PushDirtyRegion(curSurfaceDrawRegion); } @@ -405,6 +407,8 @@ void RSSurfaceRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) if (!surfaceParams->GetNeedOffscreen()) { curCanvas_->PopDirtyRegion(); } + int processedNodes = RSRenderNodeDrawable::GetProcessedNodeCount(); + AcquireFenceTracker::SetContainerNodeNum(processedNodes); RS_TRACE_NAME_FMT("RSUniRenderThread::Render() the number of total ProcessedNodes: %d", RSRenderNodeDrawable::GetTotalProcessedNodeCount()); const RSNodeStatsType nodeStats = CreateRSNodeStatsItem( From c31c53369d1e591625e21f04b854ef03178432a6 Mon Sep 17 00:00:00 2001 From: siyuan Date: Mon, 1 Jul 2024 11:04:01 +0800 Subject: [PATCH 138/247] third commit Signed-off-by: siyuan --- .../render/rs_attraction_effect_filter.cpp | 26 +++---- .../rs_attraction_effect_filter_test.cpp | 77 ++++++++----------- 2 files changed, 43 insertions(+), 60 deletions(-) diff --git a/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp b/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp index 243d8304b8..fcf6950093 100644 --- a/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp +++ b/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp @@ -297,7 +297,7 @@ std::vector RSAttractionEffectFilter::CalculateUpperCtrlPointOfV Drawing::Point((0.016f * width - 0.08f * deltaX) * location, 0.464f * height + 0.40f * deltaY) : Drawing::Point((-0.100f * width - 0.008f * deltaX) * location, 0.008f * height + 0.085f * deltaY); Drawing::Point bottomLeft = isBelowTarget_ ? - Drawing::Point((-0.15f * width - 0.075f * deltaX) * location, 0.0f * height + 0.2f * deltaY ) : + Drawing::Point((-0.15f * width - 0.075f * deltaX) * location, 0.0f * height + 0.2f * deltaY) : Drawing::Point((-0.008f * width - 0.008f * deltaX) * location, 0.0f * height - 0.008f * deltaY); Drawing::Point topRight = { (-1.147f * width - 0.016f * deltaX) * location, -0.187f * height + 0.30f * deltaY }; Drawing::Point bottomRight = { (-0.848f * width - 0.2f * deltaX) * location, -0.859f * height - 0.2f * deltaY }; @@ -347,25 +347,25 @@ std::vector RSAttractionEffectFilter::CalculateVelocityCtrlPoint void RSAttractionEffectFilter::UpdateDirtyRegion(float leftPoint, float topPonit) { - float dirtyRegionMinX_ = windowStatusPoints_[0].GetX(); - float dirtyRegionMaxX_ = windowStatusPoints_[0].GetX(); - float dirtyRegionMinY_ = windowStatusPoints_[0].GetY(); - float dirtyRegionMaxY_ = windowStatusPoints_[0].GetY(); + float dirtyRegionMinX = windowStatusPoints_[0].GetX(); + float dirtyRegionMaxX = windowStatusPoints_[0].GetX(); + float dirtyRegionMinY = windowStatusPoints_[0].GetY(); + float dirtyRegionMaxY = windowStatusPoints_[0].GetY(); int pointNum = 12; for (int i = 1; i < pointNum; ++i) { float x = windowStatusPoints_[i].GetX(); float y = windowStatusPoints_[i].GetY(); - dirtyRegionMinX_ = std::min(dirtyRegionMinX_, x); - dirtyRegionMaxX_ = std::min(dirtyRegionMaxX_, x); - dirtyRegionMinY_ = std::min(dirtyRegionMinY_, y); - dirtyRegionMaxY_ = std::min(dirtyRegionMaxY_, y); + dirtyRegionMinX_ = std::min(dirtyRegionMinX, x); + dirtyRegionMaxX_ = std::max(dirtyRegionMaxX, x); + dirtyRegionMinY_ = std::min(dirtyRegionMinY, y); + dirtyRegionMaxY_ = std::max(dirtyRegionMaxY, y); } - int dirtyRegionLeftCurrent = static_cast(dirtyRegionMinX_ + leftPoint); - int dirtyRegionTopCurrent = static_cast(dirtyRegionMinY_ + topPonit); - int dirtyRegionRightCurrent = static_cast(dirtyRegionMinX_ + leftPoint); - int dirtyRegionBottomCurrent = static_cast(dirtyRegionMinY_ + topPonit); + int dirtyRegionLeftCurrent = static_cast(dirtyRegionMinX + leftPoint); + int dirtyRegionTopCurrent = static_cast(dirtyRegionMinY + topPonit); + int dirtyRegionRightCurrent = static_cast(dirtyRegionMinX + leftPoint); + int dirtyRegionBottomCurrent = static_cast(dirtyRegionMinY + topPonit); attractionDirtyRegion_.left_ = dirtyRegionLeftCurrent; attractionDirtyRegion_.top_ = dirtyRegionTopCurrent; diff --git a/rosen/test/render_service/render_service_base/unittest/render/rs_attraction_effect_filter_test.cpp b/rosen/test/render_service/render_service_base/unittest/render/rs_attraction_effect_filter_test.cpp index 6d8f0f36b6..90b4e4d7ab 100644 --- a/rosen/test/render_service/render_service_base/unittest/render/rs_attraction_effect_filter_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/render/rs_attraction_effect_filter_test.cpp @@ -87,8 +87,7 @@ HWTEST_F(RSAttractionEffectFilterTest, IsValid001, TestSize.Level1) EXPECT_FALSE(firstEffectFilter.IsValid()); RSAttractionEffectFilter secondEffectFilter(1.f); - EXPECT_TRUE(firstEffectFilter.IsValid()); - + EXPECT_TRUE(secondEffectFilter.IsValid()); } /** @@ -115,12 +114,14 @@ HWTEST_F(RSAttractionEffectFilterTest, GetAttractionFraction001, TestSize.Level1 HWTEST_F(RSAttractionEffectFilterTest, GetAttractionDirtyRegion001, TestSize.Level1) { RSAttractionEffectFilter firstEffectFilter(0.5f); - EXPECT_TRUE(firstEffectFilter.GetAttractionDirtyRegion.x_ == 0); + RectI dirtyRegion = firstEffectFilter.GetAttractionDirtyRegion(); + EXPECT_TRUE(dirtyRegion.left_ == 0); float leftPoint = 10.f; float topPonit = 10.f; firstEffectFilter.UpdateDirtyRegion(leftPoint, topPonit); - EXPECT_FALSE(firstEffectFilter.GetAttractionDirtyRegion.x_ == 0); + dirtyRegion = firstEffectFilter.GetAttractionDirtyRegion(); + EXPECT_FALSE(dirtyRegion.left_ == 0); } /** @@ -232,29 +233,11 @@ HWTEST_F(RSAttractionEffectFilterTest, CreateIndexSequence001, TestSize.Level1) RSAttractionEffectFilter firstEffectFilter(0.5f); float direction = 1.0f; std::vector pathList = firstEffectFilter.CreateIndexSequence(direction); - EXPECT_TRUE(pathList0[0] == 0); + EXPECT_TRUE(pathList[0] == 0); direction = -1.0f; pathList = firstEffectFilter.CreateIndexSequence(direction); - EXPECT_TRUE(pathList0[0] == 3); -} - -/** - * @tc.name: CreateIndexSequence001 - * @tc.desc: test results of CreateIndexSequence - * @tc.type: FUNC - * @tc.require: issueI9UX8W - */ -HWTEST_F(RSAttractionEffectFilterTest, CreateIndexSequence001, TestSize.Level1) -{ - RSAttractionEffectFilter firstEffectFilter(0.5f); - float direction = 1.0f; - std::vector pathList = firstEffectFilter.CreateIndexSequence(direction); - EXPECT_TRUE(pathList0[0] == 0); - - direction = -1.0f; - pathList = firstEffectFilter.CreateIndexSequence(direction); - EXPECT_TRUE(pathList0[0] == 3); + EXPECT_TRUE(pathList[0] == 3); } /** @@ -266,17 +249,17 @@ HWTEST_F(RSAttractionEffectFilterTest, CreateIndexSequence001, TestSize.Level1) HWTEST_F(RSAttractionEffectFilterTest, CreateIndexSequence002, TestSize.Level1) { RSAttractionEffectFilter firstEffectFilter(0.5f); - Vector2f destinationPoint(5.0f, 20.0f); + Vector2f destinationPoint(5.0f, 5.0f); float canvasWidth = 10.f; float canvasHeight = 10.f; firstEffectFilter.CalculateWindowStatus(canvasWidth, canvasHeight, destinationPoint); float direction = 1.0f; std::vector pathList = firstEffectFilter.CreateIndexSequence(direction); - EXPECT_TRUE(pathList0[0] == 9); + EXPECT_TRUE(pathList[0] == 9); direction = -1.0f; pathList = firstEffectFilter.CreateIndexSequence(direction); - EXPECT_TRUE(pathList0[0] == 0); + EXPECT_TRUE(pathList[0] == 0); } /** @@ -288,19 +271,19 @@ HWTEST_F(RSAttractionEffectFilterTest, CreateIndexSequence002, TestSize.Level1) HWTEST_F(RSAttractionEffectFilterTest, CalculateVelocityCtrlPointUpper001, TestSize.Level1) { RSAttractionEffectFilter firstEffectFilter(0.5f); - Vector2f destinationPoint(5.0f, 15.0f); + Vector2f destinationPoint(5.0f, 5.0f); float canvasWidth = 10.f; float canvasHeight = 10.f; firstEffectFilter.CalculateWindowStatus(canvasWidth, canvasHeight, destinationPoint); std::vector velocityCtrlPointUpper = firstEffectFilter.CalculateVelocityCtrlPointUpper(); - EXPECT_EQ(velocityCtrlPointUpper[0].GetX() == 0.5f); - EXPECT_EQ(velocityCtrlPointUpper[1].GetX() == 0.0f); + EXPECT_EQ(velocityCtrlPointUpper[0].GetX(), 0.5f); + EXPECT_EQ(velocityCtrlPointUpper[1].GetX(), 0.2f); Vector2f destinationPointBelow(5.0f, 15.0f); firstEffectFilter.CalculateWindowStatus(canvasWidth, canvasHeight, destinationPointBelow); std::vector velocityCtrlPointUpperBelow = firstEffectFilter.CalculateVelocityCtrlPointUpper(); - EXPECT_EQ(velocityCtrlPointUpperBelow[0].GetX() == 0.5f); - EXPECT_EQ(velocityCtrlPointUpperBelow[1].GetX() == 0.2f); + EXPECT_EQ(velocityCtrlPointUpperBelow[0].GetX(), 0.5f); + EXPECT_EQ(velocityCtrlPointUpperBelow[1].GetX(), 0.0f); } /** @@ -312,19 +295,19 @@ HWTEST_F(RSAttractionEffectFilterTest, CalculateVelocityCtrlPointUpper001, TestS HWTEST_F(RSAttractionEffectFilterTest, CalculateVelocityCtrlPointLower001, TestSize.Level1) { RSAttractionEffectFilter firstEffectFilter(0.5f); - Vector2f destinationPoint(5.0f, 15.0f); + Vector2f destinationPoint(5.0f, 5.0f); float canvasWidth = 10.f; float canvasHeight = 10.f; firstEffectFilter.CalculateWindowStatus(canvasWidth, canvasHeight, destinationPoint); std::vector velocityCtrlPointUpper = firstEffectFilter.CalculateVelocityCtrlPointLower(); - EXPECT_EQ(velocityCtrlPointUpper[0].GetX() == 0.5f); - EXPECT_EQ(velocityCtrlPointUpper[1].GetX() == 0.0f); + EXPECT_EQ(velocityCtrlPointUpper[0].GetX(), 0.5f); + EXPECT_EQ(velocityCtrlPointUpper[1].GetX(), 0.2f); Vector2f destinationPointBelow(5.0f, 15.0f); firstEffectFilter.CalculateWindowStatus(canvasWidth, canvasHeight, destinationPointBelow); std::vector velocityCtrlPointUpperBelow = firstEffectFilter.CalculateVelocityCtrlPointLower(); - EXPECT_EQ(velocityCtrlPointUpperBelow[0].GetX() == 0.5f); - EXPECT_EQ(velocityCtrlPointUpperBelow[1].GetX() == 0.2f); + EXPECT_EQ(velocityCtrlPointUpperBelow[0].GetX(), 0.5f); + EXPECT_EQ(velocityCtrlPointUpperBelow[1].GetX(), 0.0f); } /** @@ -348,15 +331,15 @@ HWTEST_F(RSAttractionEffectFilterTest, CalculateUpperCtrlPointOfVertex001, TestS std::vector upperControlPointOfVertex1 = firstEffectFilter.CalculateUpperCtrlPointOfVertex(deltaX, deltaY, width, height, direction); - Vector2f destinationPointBelow(5.0f, 5.0f); + Vector2f destinationPointBelow(-5.0f, 5.0f); firstEffectFilter.CalculateWindowStatus(canvasWidth, canvasHeight, destinationPointBelow); std::vector upperControlPointOfVertex2 = firstEffectFilter.CalculateUpperCtrlPointOfVertex(deltaX, deltaY, width, height, direction); - EXPECT_NE(upperControlPointOfVertex1[0].GetX() == upperControlPointOfVertex2[0].GetX()); - EXPECT_NE(upperControlPointOfVertex1[1].GetX() == upperControlPointOfVertex2[1].GetX()); - EXPECT_EQ(upperControlPointOfVertex1[2].GetX() == upperControlPointOfVertex2[2].GetX()); - EXPECT_EQ(upperControlPointOfVertex1[3].GetX() == upperControlPointOfVertex2[3].GetX()); + EXPECT_NE(upperControlPointOfVertex1[0].GetX(), upperControlPointOfVertex2[0].GetX()); + EXPECT_EQ(upperControlPointOfVertex1[1].GetX(), upperControlPointOfVertex2[1].GetX()); + EXPECT_NE(upperControlPointOfVertex1[2].GetX(), upperControlPointOfVertex2[2].GetX()); + EXPECT_EQ(upperControlPointOfVertex1[3].GetX(), upperControlPointOfVertex2[3].GetX()); } /** @@ -380,15 +363,15 @@ HWTEST_F(RSAttractionEffectFilterTest, CalculateLowerCtrlPointOfVertex001, TestS std::vector upperControlPointOfVertex1 = firstEffectFilter.CalculateLowerCtrlPointOfVertex(deltaX, deltaY, width, height, direction); - Vector2f destinationPointBelow(5.0f, 5.0f); + Vector2f destinationPointBelow(-5.0f, 5.0f); firstEffectFilter.CalculateWindowStatus(canvasWidth, canvasHeight, destinationPointBelow); std::vector upperControlPointOfVertex2 = firstEffectFilter.CalculateLowerCtrlPointOfVertex(deltaX, deltaY, width, height, direction); - EXPECT_NE(upperControlPointOfVertex1[0].GetX() == upperControlPointOfVertex2[0].GetX()); - EXPECT_NE(upperControlPointOfVertex1[1].GetX() == upperControlPointOfVertex2[1].GetX()); - EXPECT_NE(upperControlPointOfVertex1[2].GetX() == upperControlPointOfVertex2[2].GetX()); - EXPECT_NE(upperControlPointOfVertex1[3].GetX() == upperControlPointOfVertex2[3].GetX()); + EXPECT_NE(upperControlPointOfVertex1[0].GetX(), upperControlPointOfVertex2[0].GetX()); + EXPECT_NE(upperControlPointOfVertex1[1].GetX(), upperControlPointOfVertex2[1].GetX()); + EXPECT_NE(upperControlPointOfVertex1[2].GetX(), upperControlPointOfVertex2[2].GetX()); + EXPECT_NE(upperControlPointOfVertex1[3].GetX(), upperControlPointOfVertex2[3].GetX()); } } // namespace Rosen } // namespace OHOS From 962f17dab9d774cd00177971cd09bc0380eceb50 Mon Sep 17 00:00:00 2001 From: siyuan Date: Mon, 1 Jul 2024 11:05:21 +0800 Subject: [PATCH 139/247] third commit Signed-off-by: siyuan --- .../unittest/render/rs_spherize_effect_filter_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/test/render_service/render_service_base/unittest/render/rs_spherize_effect_filter_test.cpp b/rosen/test/render_service/render_service_base/unittest/render/rs_spherize_effect_filter_test.cpp index 6b7541b6cc..ed2181edea 100644 --- a/rosen/test/render_service/render_service_base/unittest/render/rs_spherize_effect_filter_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/render/rs_spherize_effect_filter_test.cpp @@ -14,7 +14,7 @@ */ #include "gtest/gtest.h" -#include "render/rs_attraction_effect_filter.h" +#include "render/rs_spherize_effect_filter.h" #include "draw/color.h" #include "image/image_info.h" #include "skia_image.h" From d0ebadecf90dda7d008bdb146f729da59e274a2f Mon Sep 17 00:00:00 2001 From: siyuan Date: Mon, 1 Jul 2024 11:09:01 +0800 Subject: [PATCH 140/247] third commit Signed-off-by: siyuan --- .../render/rs_attraction_effect_filter.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp b/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp index fcf6950093..e6ee65fe56 100644 --- a/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp +++ b/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp @@ -347,25 +347,25 @@ std::vector RSAttractionEffectFilter::CalculateVelocityCtrlPoint void RSAttractionEffectFilter::UpdateDirtyRegion(float leftPoint, float topPonit) { - float dirtyRegionMinX = windowStatusPoints_[0].GetX(); - float dirtyRegionMaxX = windowStatusPoints_[0].GetX(); - float dirtyRegionMinY = windowStatusPoints_[0].GetY(); - float dirtyRegionMaxY = windowStatusPoints_[0].GetY(); + float dirtyRegionMinX_ = windowStatusPoints_[0].GetX(); + float dirtyRegionMaxX_ = windowStatusPoints_[0].GetX(); + float dirtyRegionMinY_ = windowStatusPoints_[0].GetY(); + float dirtyRegionMaxY_ = windowStatusPoints_[0].GetY(); int pointNum = 12; for (int i = 1; i < pointNum; ++i) { float x = windowStatusPoints_[i].GetX(); float y = windowStatusPoints_[i].GetY(); dirtyRegionMinX_ = std::min(dirtyRegionMinX, x); - dirtyRegionMaxX_ = std::max(dirtyRegionMaxX, x); + dirtyRegionMaxX_ = std::min(dirtyRegionMaxX, x); dirtyRegionMinY_ = std::min(dirtyRegionMinY, y); - dirtyRegionMaxY_ = std::max(dirtyRegionMaxY, y); + dirtyRegionMaxY_ = std::min(dirtyRegionMaxY, y); } - int dirtyRegionLeftCurrent = static_cast(dirtyRegionMinX + leftPoint); - int dirtyRegionTopCurrent = static_cast(dirtyRegionMinY + topPonit); - int dirtyRegionRightCurrent = static_cast(dirtyRegionMinX + leftPoint); - int dirtyRegionBottomCurrent = static_cast(dirtyRegionMinY + topPonit); + int dirtyRegionLeftCurrent = static_cast(dirtyRegionMinX_ + leftPoint); + int dirtyRegionTopCurrent = static_cast(dirtyRegionMinY_ + topPonit); + int dirtyRegionRightCurrent = static_cast(dirtyRegionMinX_ + leftPoint); + int dirtyRegionBottomCurrent = static_cast(dirtyRegionMinY_ + topPonit); attractionDirtyRegion_.left_ = dirtyRegionLeftCurrent; attractionDirtyRegion_.top_ = dirtyRegionTopCurrent; From b6b69a6c47f073a358567db7926b9c8a1a020052 Mon Sep 17 00:00:00 2001 From: siyuan Date: Mon, 1 Jul 2024 11:10:55 +0800 Subject: [PATCH 141/247] third commit Signed-off-by: siyuan --- .../src/render/rs_attraction_effect_filter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp b/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp index e6ee65fe56..3dd7f1f4b2 100644 --- a/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp +++ b/rosen/modules/render_service_base/src/render/rs_attraction_effect_filter.cpp @@ -356,10 +356,10 @@ void RSAttractionEffectFilter::UpdateDirtyRegion(float leftPoint, float topPonit for (int i = 1; i < pointNum; ++i) { float x = windowStatusPoints_[i].GetX(); float y = windowStatusPoints_[i].GetY(); - dirtyRegionMinX_ = std::min(dirtyRegionMinX, x); - dirtyRegionMaxX_ = std::min(dirtyRegionMaxX, x); - dirtyRegionMinY_ = std::min(dirtyRegionMinY, y); - dirtyRegionMaxY_ = std::min(dirtyRegionMaxY, y); + dirtyRegionMinX_ = std::min(dirtyRegionMinX_, x); + dirtyRegionMaxX_ = std::min(dirtyRegionMaxX_, x); + dirtyRegionMinY_ = std::min(dirtyRegionMinY_, y); + dirtyRegionMaxY_ = std::min(dirtyRegionMaxY_, y); } int dirtyRegionLeftCurrent = static_cast(dirtyRegionMinX_ + leftPoint); From bca16027e532d2fc35ab1f99a14cd029289980db Mon Sep 17 00:00:00 2001 From: dongzhengkuan Date: Mon, 1 Jul 2024 03:20:03 +0000 Subject: [PATCH 142/247] add pointer color invert ipc callback interface Signed-off-by: dongzhengkuan --- .../render_service/core/pipeline/rs_pointer_render_manager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp index 73cfeb7e2e..fe0d1ab6d4 100644 --- a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp @@ -104,6 +104,7 @@ void RSPointerRenderManager::ExecutePointerLuminanceChangeCallback(int32_t brigh void RSPointerRenderManager::CallPointerLuminanceChange(int32_t brightness) { + std::lock_guard lock(cursorInvertMutex_); RS_LOGD("RSPointerRenderManager::CallPointerLuminanceChange luminance_:%{public}d.", luminance_); if (brightnessMode_ == CursorBrightness::NONE) { brightnessMode_ = brightness < static_cast(RGB * HALF) ? From c546e961bc44989a675d851acaa156209c4037d7 Mon Sep 17 00:00:00 2001 From: siyuan Date: Mon, 1 Jul 2024 11:48:07 +0800 Subject: [PATCH 143/247] third commit Signed-off-by: siyuan --- .../unittest/render/rs_attraction_effect_filter_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rosen/test/render_service/render_service_base/unittest/render/rs_attraction_effect_filter_test.cpp b/rosen/test/render_service/render_service_base/unittest/render/rs_attraction_effect_filter_test.cpp index 90b4e4d7ab..3367bcad0e 100644 --- a/rosen/test/render_service/render_service_base/unittest/render/rs_attraction_effect_filter_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/render/rs_attraction_effect_filter_test.cpp @@ -12,11 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "gtest/gtest.h" -#include "render/rs_spherize_effect_filter.h" #include "draw/color.h" #include "image/image_info.h" +#include "gtest/gtest.h" +#include "render/rs_attraction_effect_filter.h" #include "skia_image.h" #include "skia_image_info.h" From 89b5027582dde053ec6756c8fa515f4b934835a0 Mon Sep 17 00:00:00 2001 From: dongzhengkuan Date: Mon, 1 Jul 2024 03:50:28 +0000 Subject: [PATCH 144/247] add pointer color invert callabck ipc interface Signed-off-by: dongzhengkuan --- .../render_service/core/pipeline/rs_pointer_render_manager.cpp | 2 +- .../render_service/core/pipeline/rs_pointer_render_manager.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp index fe0d1ab6d4..46582c16e3 100644 --- a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp @@ -104,7 +104,7 @@ void RSPointerRenderManager::ExecutePointerLuminanceChangeCallback(int32_t brigh void RSPointerRenderManager::CallPointerLuminanceChange(int32_t brightness) { - std::lock_guard lock(cursorInvertMutex_); + std::lock_guard lock(mutex_); RS_LOGD("RSPointerRenderManager::CallPointerLuminanceChange luminance_:%{public}d.", luminance_); if (brightnessMode_ == CursorBrightness::NONE) { brightnessMode_ = brightness < static_cast(RGB * HALF) ? diff --git a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.h b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.h index cfc96dd5de..36b48506ca 100644 --- a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.h +++ b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.h @@ -86,6 +86,7 @@ private: bool isEnableCursorInversion_ = false; std::shared_ptr cacheImgForPointer_ = nullptr; std::mutex cursorInvertMutex_; + std::recursive_mutex mutex_; std::map> colorChangeListeners_; enum class CursorBrightness { NONE, From 2ad419354ddc1521682d5bb5e4784d5d24d18f7d Mon Sep 17 00:00:00 2001 From: Klein-CK Date: Mon, 1 Jul 2024 14:16:46 +0800 Subject: [PATCH 145/247] Add abort discriptions of Tdd for displaySoloist NDK interfaces. Signed-off-by: Klein-CK Change-Id: Ibf0ddd8900d8745b1f6a44af36cbc33e3fa6d624 --- .../native_display_soloist_test.cpp | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/rosen/test/hyper_graphic_manager/native_display_soloist_test/native_display_soloist_test.cpp b/rosen/test/hyper_graphic_manager/native_display_soloist_test/native_display_soloist_test.cpp index 3e11bee4ac..1f5618fba3 100644 --- a/rosen/test/hyper_graphic_manager/native_display_soloist_test/native_display_soloist_test.cpp +++ b/rosen/test/hyper_graphic_manager/native_display_soloist_test/native_display_soloist_test.cpp @@ -26,6 +26,8 @@ namespace { constexpr uint32_t FRAME_RATE_90_HZ = 90; constexpr uint32_t FRAME_RATE_120_HZ = 120; constexpr uint32_t SLEEP_TIME_US = 100000; + constexpr int32_t EXEC_SUCCESS = 0; + constexpr int32_t SOLOIST_ERROR = -1; } class NativeDisplaySoloistTest : public testing::Test { public: @@ -83,7 +85,8 @@ HWTEST_F(NativeDisplaySoloistTest, OH_DisplaySoloist_Create001, Function | Mediu HWTEST_F(NativeDisplaySoloistTest, OH_DisplaySoloist_Start001, Function | MediumTest | Level2) { OH_DisplaySoloist_FrameCallback callback = OnVSync; - OH_DisplaySoloist_Start(nullptr, callback, nullptr); + int32_t result = OH_DisplaySoloist_Start(nullptr, callback, nullptr); + EXPECT_EQ(SOLOIST_ERROR, result); } /* @@ -96,7 +99,8 @@ HWTEST_F(NativeDisplaySoloistTest, OH_DisplaySoloist_Start001, Function | Medium HWTEST_F(NativeDisplaySoloistTest, OH_DisplaySoloist_Start002, Function | MediumTest | Level2) { OH_DisplaySoloist_FrameCallback callback = OnVSync; - OH_DisplaySoloist_Start(nativeDisplaySoloist, callback, nullptr); + int32_t result = OH_DisplaySoloist_Start(nativeDisplaySoloist, callback, nullptr); + EXPECT_EQ(EXEC_SUCCESS, result); } /* @@ -109,8 +113,10 @@ HWTEST_F(NativeDisplaySoloistTest, OH_DisplaySoloist_Start002, Function | Medium HWTEST_F(NativeDisplaySoloistTest, OH_DisplaySoloist_SetExpectedFrameRateRange001, Function | MediumTest | Level2) { DisplaySoloist_ExpectedRateRange validRange = { FRAME_RATE_30_HZ, FRAME_RATE_120_HZ, FRAME_RATE_60_HZ }; - OH_DisplaySoloist_SetExpectedFrameRateRange(nullptr, &validRange); - OH_DisplaySoloist_SetExpectedFrameRateRange(nativeDisplaySoloist, nullptr); + int32_t result1 = OH_DisplaySoloist_SetExpectedFrameRateRange(nullptr, &validRange); + EXPECT_EQ(SOLOIST_ERROR, result1); + int32_t result2 = OH_DisplaySoloist_SetExpectedFrameRateRange(nativeDisplaySoloist, nullptr); + EXPECT_EQ(SOLOIST_ERROR, result2); } /* @@ -123,7 +129,8 @@ HWTEST_F(NativeDisplaySoloistTest, OH_DisplaySoloist_SetExpectedFrameRateRange00 HWTEST_F(NativeDisplaySoloistTest, OH_DisplaySoloist_SetExpectedFrameRateRange002, Function | MediumTest | Level2) { DisplaySoloist_ExpectedRateRange invalidRange = { FRAME_RATE_30_HZ, FRAME_RATE_90_HZ, FRAME_RATE_120_HZ }; - OH_DisplaySoloist_SetExpectedFrameRateRange(nullptr, &invalidRange); + int32_t result = OH_DisplaySoloist_SetExpectedFrameRateRange(nullptr, &invalidRange); + EXPECT_EQ(SOLOIST_ERROR, result); } /* @@ -136,7 +143,8 @@ HWTEST_F(NativeDisplaySoloistTest, OH_DisplaySoloist_SetExpectedFrameRateRange00 HWTEST_F(NativeDisplaySoloistTest, OH_DisplaySoloist_SetExpectedFrameRateRange003, Function | MediumTest | Level2) { DisplaySoloist_ExpectedRateRange validRange = { FRAME_RATE_30_HZ, FRAME_RATE_120_HZ, FRAME_RATE_60_HZ }; - OH_DisplaySoloist_SetExpectedFrameRateRange(nullptr, &validRange); + int32_t result = OH_DisplaySoloist_SetExpectedFrameRateRange(nativeDisplaySoloist, &validRange); + EXPECT_EQ(EXEC_SUCCESS, result); } /* @@ -148,7 +156,8 @@ HWTEST_F(NativeDisplaySoloistTest, OH_DisplaySoloist_SetExpectedFrameRateRange00 */ HWTEST_F(NativeDisplaySoloistTest, OH_DisplaySoloist_Stop001, Function | MediumTest | Level2) { - OH_DisplaySoloist_Stop(nullptr); + int32_t result = OH_DisplaySoloist_Stop(nullptr); + EXPECT_EQ(SOLOIST_ERROR, result); } /* @@ -160,7 +169,8 @@ HWTEST_F(NativeDisplaySoloistTest, OH_DisplaySoloist_Stop001, Function | MediumT */ HWTEST_F(NativeDisplaySoloistTest, OH_DisplaySoloist_Stop002, Function | MediumTest | Level2) { - OH_DisplaySoloist_Stop(nativeDisplaySoloist); + int32_t result = OH_DisplaySoloist_Stop(nativeDisplaySoloist); + EXPECT_EQ(EXEC_SUCCESS, result); } /* @@ -172,7 +182,8 @@ HWTEST_F(NativeDisplaySoloistTest, OH_DisplaySoloist_Stop002, Function | MediumT */ HWTEST_F(NativeDisplaySoloistTest, OH_DisplaySoloist_Destroy001, Function | MediumTest | Level2) { - OH_DisplaySoloist_Destroy(nullptr); + int32_t result = OH_DisplaySoloist_Destroy(nullptr); + EXPECT_EQ(SOLOIST_ERROR, result); } /* @@ -184,7 +195,8 @@ HWTEST_F(NativeDisplaySoloistTest, OH_DisplaySoloist_Destroy001, Function | Medi */ HWTEST_F(NativeDisplaySoloistTest, OH_DisplaySoloist_Destroy002, Function | MediumTest | Level2) { - OH_DisplaySoloist_Destroy(nativeDisplaySoloist); + int32_t result = OH_DisplaySoloist_Destroy(nativeDisplaySoloist); + EXPECT_EQ(EXEC_SUCCESS, result); } } // namespace From 585d2196e26fef2d9d9c53e2864ad69c28190516 Mon Sep 17 00:00:00 2001 From: dongzhengkuan Date: Mon, 1 Jul 2024 06:43:15 +0000 Subject: [PATCH 146/247] add pointer color invert ipc callback Signed-off-by: dongzhengkuan --- .../core/pipeline/rs_pointer_render_manager.cpp | 4 ---- .../render_service/core/pipeline/rs_pointer_render_manager.h | 1 - 2 files changed, 5 deletions(-) diff --git a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp index 46582c16e3..e279881618 100644 --- a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.cpp @@ -73,9 +73,6 @@ void RSPointerRenderManager::SetPointerColorInversionEnabled(bool enable) { std::lock_guard lock(cursorInvertMutex_); isEnableCursorInversion_ = enable; - if (!enable) { - brightnessMode_ = CursorBrightness::NONE; - } } void RSPointerRenderManager::RegisterPointerLuminanceChangeCallback(pid_t pid, @@ -104,7 +101,6 @@ void RSPointerRenderManager::ExecutePointerLuminanceChangeCallback(int32_t brigh void RSPointerRenderManager::CallPointerLuminanceChange(int32_t brightness) { - std::lock_guard lock(mutex_); RS_LOGD("RSPointerRenderManager::CallPointerLuminanceChange luminance_:%{public}d.", luminance_); if (brightnessMode_ == CursorBrightness::NONE) { brightnessMode_ = brightness < static_cast(RGB * HALF) ? diff --git a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.h b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.h index 36b48506ca..cfc96dd5de 100644 --- a/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.h +++ b/rosen/modules/render_service/core/pipeline/rs_pointer_render_manager.h @@ -86,7 +86,6 @@ private: bool isEnableCursorInversion_ = false; std::shared_ptr cacheImgForPointer_ = nullptr; std::mutex cursorInvertMutex_; - std::recursive_mutex mutex_; std::map> colorChangeListeners_; enum class CursorBrightness { NONE, From b2a00810bf30178e37d0e03b06417323d36dcb7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=87=AF?= Date: Mon, 1 Jul 2024 06:46:49 +0000 Subject: [PATCH 147/247] update rosen/test/2d_graphics/unittest/render_context/render_context_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王凯 --- .../render_context/render_context_test.cpp | 269 ------------------ 1 file changed, 269 deletions(-) diff --git a/rosen/test/2d_graphics/unittest/render_context/render_context_test.cpp b/rosen/test/2d_graphics/unittest/render_context/render_context_test.cpp index 791eb730c1..4ae39c7fe0 100644 --- a/rosen/test/2d_graphics/unittest/render_context/render_context_test.cpp +++ b/rosen/test/2d_graphics/unittest/render_context/render_context_test.cpp @@ -189,25 +189,6 @@ HWTEST_F(RenderContextTest, DamageFrameTest001, Level1) #endif } -/** - * @tc.name: DamageFrameTest002 - * @tc.desc: Verify the DamageFrameTest001 of RenderContextTest - * @tc.type: FUNC - */ -HWTEST_F(RenderContextTest, DamageFrameTest002, Level1) -{ -#ifdef ACE_ENABLE_GL - if (RSSystemProperties::IsUseVulkan()) { - GTEST_LOG_(INFO) << "vulkan enable! skip opengl test case"; - return; - } - // start DamageFrameTest001 test - RenderContext renderContext; - renderContext.DamageFrame(0, 0, 0, 0); - ASSERT_EQ(0, false); -#endif -} - /** * @tc.name: MakeSelfCurrentTest001 * @tc.desc: Verify the MakeSelfCurrentTest001 of RenderContextTest @@ -264,254 +245,4 @@ HWTEST_F(RenderContextTest, PixelFormatTest001, Level1) ASSERT_EQ(renderContext.GetPixelFormat(), GRAPHIC_PIXEL_FMT_RGBA_1010102); #endif } - -/** - * @tc.name: SetUpGpuContext001 - * @tc.desc: Verify the SetUpGpuContext of RenderContextTest - * @tc.type: FUNC - */ -HWTEST_F(RenderContextTest, SetUpGpuContext001, Level1) -{ - RenderContext renderContext; - auto drGPUContext_ = renderContext.GetSharedDrGPUContext(); - renderContext.SetUpGpuContext(drGPUContext_); - ASSERT_EQ(1, true); -} - -/** - * @tc.name: SetUpGpuContext002 - * @tc.desc: Verify the SetUpGpuContext of RenderContextTest - * @tc.type: FUNC - */ -HWTEST_F(RenderContextTest, SetUpGpuContext002, Level1) -{ -#ifdef ACE_ENABLE_GL - if (RSSystemProperties::IsUseVulkan()) { - GTEST_LOG_(INFO) << "vulkan enable! skip opengl test case"; - return; - } - RenderContext renderContext; - #ifdef RS_ENABLE_GL - renderContext.SetUniRenderMode(1); - renderContext.SetUpGpuContext(nullptr); - ASSERT_EQ(1, true); - #endif -#endif -} - -/** - * @tc.name: SetUpGpuContext003 - * @tc.desc: Verify the SetUpGpuContext of RenderContextTest - * @tc.type: FUNC - */ -HWTEST_F(RenderContextTest, SetUpGpuContext003, Level1) -{ -#ifdef ACE_ENABLE_GL - if (RSSystemProperties::IsUseVulkan()) { - GTEST_LOG_(INFO) << "vulkan enable! skip opengl test case"; - return; - } - RenderContext renderContext; - #ifdef RS_ENABLE_GL - glGetString(GL_VERSION); - renderContext.SetUpGpuContext(nullptr); - ASSERT_EQ(1, true); - #endif -#endif -} - -/** - * @tc.name: SetUpGpuContext004 - * @tc.desc: Verify the SetUpGpuContext of RenderContextTest - * @tc.type: FUNC - */ -HWTEST_F(RenderContextTest, SetUpGpuContext004, Level1) -{ -#ifdef ACE_ENABLE_GL - if (RSSystemProperties::IsUseVulkan()) { - GTEST_LOG_(INFO) << "vulkan enable! skip opengl test case"; - return; - } - RenderContext renderContext; - #ifdef RS_ENABLE_GL - auto drGPUContext = std::make_shared(); - ASSERT_EQ(renderContext.SetUpGpuContext(nullptr), false); - #endif -#endif -} - -/** - * @tc.name: SetUpGpuContext005 - * @tc.desc: Verify the SetUpGpuContext of RenderContextTest - * @tc.type: FUNC - */ -HWTEST_F(RenderContextTest, SetUpGpuContext005, Level1) -{ -#ifdef RS_ENABLE_VK - RenderContext renderContext; - ASSERT_EQ(renderContext.SetUpGpuContext(nullptr), true); -#endif -} - -/** - * @tc.name: AbandonContext001 - * @tc.desc: Verify the AbandonContext of RenderContextTest - * @tc.type: FUNC - */ -HWTEST_F(RenderContextTest, AbandonContext001, Level1) -{ -#ifdef RS_ENABLE_VK - RenderContext renderContext; - renderContext.AbandonContext(); - ASSERT_EQ(1, true); -#endif -} - -/** - * @tc.name: AcquireSurface001 - * @tc.desc: Verify the AcquireSurface of RenderContextTest - * @tc.type: FUNC - */ -HWTEST_F(RenderContextTest, AcquireSurface001, Level1) -{ -#ifdef ACE_ENABLE_GL - if (RSSystemProperties::IsUseVulkan()) { - GTEST_LOG_(INFO) << "vulkan enable! skip opengl test case"; - return; - } - RenderContext renderContext; - renderContext.SetUpGpuContext(nullptr); - ASSERT_EQ(renderContext.AcquireSurface(0, 0), nullptr); -#endif -} - -/** - * @tc.name: AcquireSurface002 - * @tc.desc: Verify the AcquireSurface of RenderContextTest - * @tc.type: FUNC - */ -HWTEST_F(RenderContextTest, AcquireSurface002, Level1) -{ -#ifdef ACE_ENABLE_GL - if (RSSystemProperties::IsUseVulkan()) { - GTEST_LOG_(INFO) << "vulkan enable! skip opengl test case"; - return; - } - RenderContext renderContext; - ASSERT_EQ(renderContext.AcquireSurface(0, 0), nullptr); -#endif -} - -/** - * @tc.name: QueryEglBufferAge001 - * @tc.desc: Verify the QueryEglBufferAge of RenderContextTest - * @tc.type: FUNC - */ -HWTEST_F(RenderContextTest, QueryEglBufferAge001, Level1) -{ -#ifdef ACE_ENABLE_GL - if (RSSystemProperties::IsUseVulkan()) { - GTEST_LOG_(INFO) << "vulkan enable! skip opengl test case"; - return; - } - RenderContext renderContext; - ASSERT_EQ(renderContext.QueryEglBufferAge(), EGL_UNKNOWN); -#endif -} - -/** - * @tc.name: QueryEglBufferAge002 - * @tc.desc: Verify the QueryEglBufferAge of RenderContextTest - * @tc.type: FUNC - */ -HWTEST_F(RenderContextTest, QueryEglBufferAge002, Level1) -{ -#ifdef ACE_ENABLE_GL - if (RSSystemProperties::IsUseVulkan()) { - GTEST_LOG_(INFO) << "vulkan enable! skip opengl test case"; - return; - } - RenderContext renderContext; - eglQuerySurface(nullptr, nullptr, EGL_BUFFER_AGE_KHR, nullptr); - ASSERT_EQ(renderContext.QueryEglBufferAge(), EGL_UNKNOWN); -#endif -} - -/** - * @tc.name: ClearRedundantResources001 - * @tc.desc: Verify the ClearRedundantResources of RenderContextTest - * @tc.type: FUNC - */ -HWTEST_F(RenderContextTest, ClearRedundantResources001, Level1) -{ -#ifdef ACE_ENABLE_GL - if (RSSystemProperties::IsUseVulkan()) { - GTEST_LOG_(INFO) << "vulkan enable! skip opengl test case"; - return; - } - RenderContext renderContext; - renderContext.ClearRedundantResources(); - ASSERT_EQ(1, true); -#endif -} - -/** - * @tc.name: ConvertColorGamutToSkColorSpace001 - * @tc.desc: Verify the ConvertColorGamutToSkColorSpace of RenderContextTest - * @tc.type: FUNC - */ -HWTEST_F(RenderContextTest, ConvertColorGamutToSkColorSpace001, Level1) -{ -#ifdef ACE_ENABLE_GL - if (RSSystemProperties::IsUseVulkan()) { - GTEST_LOG_(INFO) << "vulkan enable! skip opengl test case"; - return; - } - RenderContext renderContext; - renderContext.ConvertColorGamutToSkColorSpace(GRAPHIC_COLOR_GAMUT_DISPLAY_P3); - ASSERT_EQ(1, true); - renderContext.ConvertColorGamutToSkColorSpace(GRAPHIC_COLOR_GAMUT_ADOBE_RGB); - ASSERT_EQ(1, true); - renderContext.ConvertColorGamutToSkColorSpace(GRAPHIC_COLOR_GAMUT_BT2020); - ASSERT_EQ(1, true); -#endif -} - -#if defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK) -/** - * @tc.name: GetShaderCacheSize001 - * @tc.desc: Verify the GetShaderCacheSize of RenderContextTest - * @tc.type: FUNC - */ -HWTEST_F(RenderContextTest, GetShaderCacheSize001, Level1) -{ -#ifdef RS_ENABLE_VK - RenderContext renderContext; - renderContext.GetShaderCacheSize(); - ASSERT_EQ(1, true); -#else - RenderContext renderContext; - renderContext.GetShaderCacheSize(); - ASSERT_EQ(1, true); -#endif -} - -/** - * @tc.name: CleanAllShaderCache001 - * @tc.desc: Verify the CleanAllShaderCache of RenderContextTest - * @tc.type: FUNC - */ -HWTEST_F(RenderContextTest, CleanAllShaderCache001, Level1) -{ -#ifdef RS_ENABLE_VK - RenderContext renderContext; - renderContext.CleanAllShaderCache(); - ASSERT_EQ(1, true); -#else - RenderContext renderContext; - renderContext.CleanAllShaderCache(); - ASSERT_EQ(1, true); -#endif -} -#endif } // namespace OHOS::Rosen \ No newline at end of file From ef16b6891cc3486a6b0ebee630567c97ded391a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=81=E5=9D=97?= Date: Mon, 1 Jul 2024 07:15:15 +0000 Subject: [PATCH 148/247] =?UTF-8?q?update=20rosen/modules/render=5Fservice?= =?UTF-8?q?=5Fbase/src/property/rs=5Fproperties.cpp.=20=E4=BF=AE=E5=A4=8Db?= =?UTF-8?q?lur=E6=8E=A5=E5=8F=A3=E7=81=B0=E9=98=B6=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李铁块 --- .../modules/render_service_base/src/property/rs_properties.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/modules/render_service_base/src/property/rs_properties.cpp b/rosen/modules/render_service_base/src/property/rs_properties.cpp index bc60bc05aa..7d280dd40b 100644 --- a/rosen/modules/render_service_base/src/property/rs_properties.cpp +++ b/rosen/modules/render_service_base/src/property/rs_properties.cpp @@ -2793,7 +2793,7 @@ void RSProperties::GenerateForegroundBlurFilter() if (greyCoef_.has_value()) { std::shared_ptr greyShaderFilter = std::make_shared(greyCoef_->x_, greyCoef_->y_); - std::shared_ptr originalFilter = std::make_shared(greyShaderFilter); + originalFilter = std::make_shared(greyShaderFilter); } if (RSSystemProperties::GetHpsBlurEnabled() && false) { From aac6c233368044b8bd7fa6211e261bed8af4c3d1 Mon Sep 17 00:00:00 2001 From: yaozhupeng Date: Mon, 1 Jul 2024 16:05:18 +0800 Subject: [PATCH 149/247] fix security problems Signed-off-by: yaozhupeng --- rosen/modules/effect/effect_ndk/BUILD.gn | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rosen/modules/effect/effect_ndk/BUILD.gn b/rosen/modules/effect/effect_ndk/BUILD.gn index 6577bef2a8..61668a7821 100644 --- a/rosen/modules/effect/effect_ndk/BUILD.gn +++ b/rosen/modules/effect/effect_ndk/BUILD.gn @@ -27,7 +27,7 @@ template("effect_ndk_source_set") { ohos_source_set(target_name) { defines += invoker.defines - cflags_cc += invoker.cflags_cc + cflags_cc = [] sanitize = { cfi = true @@ -77,6 +77,8 @@ template("effect_ndk_source_set") { "image_framework:pixelmap_ndk", ] deps = [ "$graphic_2d_root/rosen/modules/render_service_base:librender_service_base" ] + cflags = [ "-fstack-protector-strong" ] + cflags_cc += [ "-fstack-protector-strong" ] } else { deps = [] cflags = [ "-std=c++17" ] @@ -93,7 +95,6 @@ template("effect_ndk_source_set") { effect_ndk_source_set("effect_ndk_source_ohos") { platform = "ohos" defines = [] - cflags_cc = [] } ohos_shared_library("native_effect_ndk") { From 89e225b023a72bb61dc4715766637dcc4c3a2c35 Mon Sep 17 00:00:00 2001 From: denispavlov Date: Fri, 28 Jun 2024 11:59:43 +0300 Subject: [PATCH 150/247] Turn off network/metrics computation during betarecording Signed-off-by: denispavlov --- .../render_service_profiler/rs_profiler.cpp | 12 +++++++--- .../rs_profiler_network.cpp | 23 +++++++++++-------- .../rs_profiler_network.h | 2 ++ 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/rosen/modules/render_service_profiler/rs_profiler.cpp b/rosen/modules/render_service_profiler/rs_profiler.cpp index ce0fcb1a08..55522065eb 100644 --- a/rosen/modules/render_service_profiler/rs_profiler.cpp +++ b/rosen/modules/render_service_profiler/rs_profiler.cpp @@ -175,7 +175,9 @@ void RSProfiler::Init(RSRenderService* renderService) g_mainThread = g_renderService ? g_renderService->mainThread_ : nullptr; g_context = g_mainThread ? g_mainThread->context_.get() : nullptr; - static std::thread const THREAD(Network::Run); + if (!IsBetaRecordEnabled()) { + static std::thread const THREAD(Network::Run); + } } void RSProfiler::OnCreateConnection(pid_t pid) @@ -1184,6 +1186,10 @@ void RSProfiler::RecordStart(const ArgList& args) g_recordStartTime = Now(); g_frameNumber = 0; + if (IsBetaRecordStarted()) { + return; + } + std::thread thread([]() { while (IsRecording()) { if (g_recordStartTime >= 0) { @@ -1286,7 +1292,8 @@ void RSProfiler::PlaybackStart(const ArgList& args) g_playbackShouldBeTerminated = false; - std::thread thread([]() { + const auto timeoutLimit = args.Int64(); + std::thread thread([timeoutLimit]() { while (IsPlaying()) { const int64_t timestamp = static_cast(RawNowNano()); @@ -1295,7 +1302,6 @@ void RSProfiler::PlaybackStart(const ArgList& args) SendTelemetry(Now() - g_playbackStartTime); } - constexpr int64_t timeoutLimit = 8000000; const int64_t timeout = timeoutLimit - static_cast(RawNowNano()) + timestamp; if (timeout > 0) { std::this_thread::sleep_for(std::chrono::nanoseconds(timeout)); diff --git a/rosen/modules/render_service_profiler/rs_profiler_network.cpp b/rosen/modules/render_service_profiler/rs_profiler_network.cpp index 8e11e9f459..4c2d79759b 100644 --- a/rosen/modules/render_service_profiler/rs_profiler_network.cpp +++ b/rosen/modules/render_service_profiler/rs_profiler_network.cpp @@ -190,6 +190,14 @@ std::vector Network::GetStats(const std::string& interface) return results; } +void Network::SendPacket(const Packet& packet) +{ + if (isRunning_) { + const std::lock_guard guard(outgoingMutex_); + outgoing_.emplace(const_cast(packet).Release()); + } +} + void Network::SendPath(const std::string& path, PackageID id) { if (!path.empty()) { @@ -248,8 +256,7 @@ void Network::SendRSTreeDumpJSON(const std::string& jsonstr) Packet packet { Packet::BINARY }; packet.Write(static_cast(PackageID::RS_PROFILER_RSTREE_DUMP_JSON)); packet.Write(jsonstr); - const std::lock_guard guard(outgoingMutex_); - outgoing_.emplace(packet.Release()); + SendPacket(packet); } void Network::SendRSTreePerfNodeList(const std::unordered_set& perfNodesList) @@ -257,8 +264,7 @@ void Network::SendRSTreePerfNodeList(const std::unordered_set& perfNod Packet packet { Packet::BINARY }; packet.Write(static_cast(PackageID::RS_PROFILER_RSTREE_PERF_NODE_LIST)); packet.Write(perfNodesList); - const std::lock_guard guard(outgoingMutex_); - outgoing_.emplace(packet.Release()); + SendPacket(packet); } void Network::SendRSTreeSingleNodePerf(uint64_t id, uint64_t nanosec) @@ -267,8 +273,7 @@ void Network::SendRSTreeSingleNodePerf(uint64_t id, uint64_t nanosec) packet.Write(static_cast(PackageID::RS_PROFILER_RSTREE_SINGLE_NODE_PERF)); packet.Write(id); packet.Write(nanosec); - const std::lock_guard guard(outgoingMutex_); - outgoing_.emplace(packet.Release()); + SendPacket(packet); } void Network::SendBinary(const void* data, size_t size) @@ -276,8 +281,7 @@ void Network::SendBinary(const void* data, size_t size) if (data && (size > 0)) { Packet packet { Packet::BINARY }; packet.Write(data, size); - const std::lock_guard guard(outgoingMutex_); - outgoing_.emplace(packet.Release()); + SendPacket(packet); } } @@ -296,8 +300,7 @@ void Network::SendMessage(const std::string& message) if (!message.empty()) { Packet packet { Packet::LOG }; packet.Write(message); - const std::lock_guard guard(outgoingMutex_); - outgoing_.emplace(packet.Release()); + SendPacket(packet); } } diff --git a/rosen/modules/render_service_profiler/rs_profiler_network.h b/rosen/modules/render_service_profiler/rs_profiler_network.h index 4312abcc2c..7599c4dd47 100644 --- a/rosen/modules/render_service_profiler/rs_profiler_network.h +++ b/rosen/modules/render_service_profiler/rs_profiler_network.h @@ -24,6 +24,7 @@ namespace OHOS::Rosen { +class Packet; class Socket; class RSCaptureData; enum class PackageID; @@ -68,6 +69,7 @@ private: static void ProcessIncoming(Socket& socket); static void ProcessOutgoing(Socket& socket); static void SendPath(const std::string& path, PackageID id); + static void SendPacket(const Packet& packet); private: static bool isRunning_; From 6cc8cc622d055cc634b4eebb81bcd87b6cbf2ebd Mon Sep 17 00:00:00 2001 From: sunqizhen Date: Thu, 27 Jun 2024 10:40:14 +0800 Subject: [PATCH 151/247] fix dfx for dirty region Signed-off-by: sunqizhen --- .../core/drawable/dfx/rs_dirty_rects_dfx.cpp | 1 + .../include/params/rs_render_params.h | 3 -- .../pipeline/rs_dirty_region_manager.h | 1 + .../platform/common/rs_system_properties.h | 9 ++--- .../src/params/rs_render_params.cpp | 14 -------- .../src/pipeline/rs_dirty_region_manager.cpp | 1 + .../src/pipeline/rs_render_node.cpp | 29 +++++++++------ .../unittest/pipeline/rs_render_node_test.cpp | 36 +++++++++++++++++++ 8 files changed, 63 insertions(+), 31 deletions(-) diff --git a/rosen/modules/render_service/core/drawable/dfx/rs_dirty_rects_dfx.cpp b/rosen/modules/render_service/core/drawable/dfx/rs_dirty_rects_dfx.cpp index 705cb62bb4..c38cf020a0 100644 --- a/rosen/modules/render_service/core/drawable/dfx/rs_dirty_rects_dfx.cpp +++ b/rosen/modules/render_service/core/drawable/dfx/rs_dirty_rects_dfx.cpp @@ -47,6 +47,7 @@ static const std::map DIRTY_REGION_TYPE_MAP { { DirtyRegionType::RENDER_PROPERTIES_RECT, "RENDER_PROPERTIES_RECT" }, { DirtyRegionType::CANVAS_NODE_SKIP_RECT, "CANVAS_NODE_SKIP_RECT" }, { DirtyRegionType::OUTLINE_RECT, "OUTLINE_RECT" }, + { DirtyRegionType::SUBTREE_SKIP_RECT, "SUBTREE_SKIP_RECT" }, }; void RSDirtyRectsDfx::OnDraw(std::shared_ptr canvas) diff --git a/rosen/modules/render_service_base/include/params/rs_render_params.h b/rosen/modules/render_service_base/include/params/rs_render_params.h index 6401f49ff4..08ddb6cb74 100644 --- a/rosen/modules/render_service_base/include/params/rs_render_params.h +++ b/rosen/modules/render_service_base/include/params/rs_render_params.h @@ -146,9 +146,6 @@ public: void SetShadowRect(Drawing::Rect rect); Drawing::Rect GetShadowRect() const; - void SetDirtyRegionInfoForDFX(DirtyRegionInfoForDFX dirtyRegionInfo); - DirtyRegionInfoForDFX GetDirtyRegionInfoForDFX() const; - // One-time trigger, needs to be manually reset false in main/RT thread after each sync operation void OnCanvasDrawingSurfaceChange(const std::unique_ptr& target); bool GetCanvasDrawingSurfaceChanged() const; diff --git a/rosen/modules/render_service_base/include/pipeline/rs_dirty_region_manager.h b/rosen/modules/render_service_base/include/pipeline/rs_dirty_region_manager.h index 924eada0e8..6d299f869e 100644 --- a/rosen/modules/render_service_base/include/pipeline/rs_dirty_region_manager.h +++ b/rosen/modules/render_service_base/include/pipeline/rs_dirty_region_manager.h @@ -44,6 +44,7 @@ enum DirtyRegionType { RENDER_PROPERTIES_RECT, CANVAS_NODE_SKIP_RECT, OUTLINE_RECT, + SUBTREE_SKIP_RECT, TYPE_AMOUNT }; diff --git a/rosen/modules/render_service_base/include/platform/common/rs_system_properties.h b/rosen/modules/render_service_base/include/platform/common/rs_system_properties.h index 5de4356820..84e2f07e4b 100644 --- a/rosen/modules/render_service_base/include/platform/common/rs_system_properties.h +++ b/rosen/modules/render_service_base/include/platform/common/rs_system_properties.h @@ -33,11 +33,11 @@ enum class DirtyRegionDebugType { MULTI_HISTORY, CURRENT_SUB_AND_WHOLE, CURRENT_WHOLE_AND_MULTI_HISTORY, - EGL_DAMAGE, - DISPLAY_DIRTY, + EGL_DAMAGE, // all dirty region infomation, includes detailed app dirty region and global dirty. + DISPLAY_DIRTY, // detailed global dirty (before merge rect). CUR_DIRTY_DETAIL_ONLY_TRACE = 10, - UPDATE_DIRTY_REGION, - OVERLAY_RECT, + UPDATE_DIRTY_REGION, // dirty region for each node. + OVERLAY_RECT, // drawRegion FILTER_RECT, SHADOW_RECT, PREPARE_CLIP_RECT, @@ -45,6 +45,7 @@ enum class DirtyRegionDebugType { RENDER_PROPERTIES_RECT, CANVAS_NODE_SKIP_RECT, OUTLINE_RECT, + SUBTREE_SKIP_RECT, // dirty region of the subtree if subtree is skipped in preparation. }; enum class SurfaceRegionDebugType { diff --git a/rosen/modules/render_service_base/src/params/rs_render_params.cpp b/rosen/modules/render_service_base/src/params/rs_render_params.cpp index ee949a067f..30b88a430c 100644 --- a/rosen/modules/render_service_base/src/params/rs_render_params.cpp +++ b/rosen/modules/render_service_base/src/params/rs_render_params.cpp @@ -319,20 +319,6 @@ Drawing::Rect RSRenderParams::GetShadowRect() const return shadowRect_; } -void RSRenderParams::SetDirtyRegionInfoForDFX(DirtyRegionInfoForDFX dirtyRegionInfo) -{ - if (dirtyRegionInfoForDFX_ == dirtyRegionInfo) { - return; - } - dirtyRegionInfoForDFX_ = dirtyRegionInfo; - needSync_ = true; -} - -DirtyRegionInfoForDFX RSRenderParams::GetDirtyRegionInfoForDFX() const -{ - return dirtyRegionInfoForDFX_; -} - void RSRenderParams::SetNeedSync(bool needSync) { needSync_ = needSync; diff --git a/rosen/modules/render_service_base/src/pipeline/rs_dirty_region_manager.cpp b/rosen/modules/render_service_base/src/pipeline/rs_dirty_region_manager.cpp index af761c7e8c..63aaffa7bb 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_dirty_region_manager.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_dirty_region_manager.cpp @@ -171,6 +171,7 @@ void RSDirtyRegionManager::OnSync(std::shared_ptr targetMa if (RSSystemProperties::GetDirtyRegionDebugType() != DirtyRegionDebugType::DISABLED) { targetManager->dirtySurfaceNodeInfo_ = dirtySurfaceNodeInfo_; targetManager->dirtyCanvasNodeInfo_ = dirtyCanvasNodeInfo_; + targetManager->mergedDirtyRegions_ = mergedDirtyRegions_; } // To avoid the impact of the remaining surface dirty on global dirty when nodes are skipped the next frame. Clear(); diff --git a/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp b/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp index 2b9297c37d..b4cff81354 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp @@ -1354,24 +1354,33 @@ void RSRenderNode::UpdateDirtyRegionInfoForDFX(RSDirtyRegionManager& dirtyManage if (RSSystemProperties::GetDirtyRegionDebugType() == DirtyRegionDebugType::DISABLED) { return; } - // update OVERLAY_RECT + // update dirty region information that depends on geoPtr. auto& properties = GetRenderProperties(); - if (auto drawRegion = properties.GetDrawRegion()) { - if (auto& geoPtr = properties.GetBoundsGeometry()) { + if (auto& geoPtr = properties.GetBoundsGeometry()) { + // drawRegion can be nullptr if not set. + if (auto drawRegion = properties.GetDrawRegion()) { dirtyManager.UpdateDirtyRegionInfoForDfx( GetId(), GetType(), DirtyRegionType::OVERLAY_RECT, geoPtr->MapAbsRect(*drawRegion)); } - } else { dirtyManager.UpdateDirtyRegionInfoForDfx( - GetId(), GetType(), DirtyRegionType::OVERLAY_RECT, RectI()); + GetId(), GetType(), DirtyRegionType::SHADOW_RECT, geoPtr->MapAbsRect(localShadowRect_.ConvertTo())); + dirtyManager.UpdateDirtyRegionInfoForDfx(GetId(), + GetType(), DirtyRegionType::OUTLINE_RECT, geoPtr->MapAbsRect(localOutlineRect_.ConvertTo())); } - // update UPDATE_DIRTY_REGION + + // update dirty region information in abs Coords. dirtyManager.UpdateDirtyRegionInfoForDfx( GetId(), GetType(), DirtyRegionType::UPDATE_DIRTY_REGION, oldDirtyInSurface_); - DirtyRegionInfoForDFX dirtyRegionInfo; - dirtyRegionInfo.oldDirty = oldDirty_; - dirtyRegionInfo.oldDirtyInSurface = oldDirtyInSurface_; - stagingRenderParams_->SetDirtyRegionInfoForDFX(dirtyRegionInfo); + dirtyManager.UpdateDirtyRegionInfoForDfx( + GetId(), GetType(), DirtyRegionType::FILTER_RECT, filterRegion_); + if (LastFrameSubTreeSkipped()) { + dirtyManager.UpdateDirtyRegionInfoForDfx( + GetId(), GetType(), DirtyRegionType::SUBTREE_SKIP_RECT, subTreeDirtyRegion_); + } + if (properties.GetClipToBounds() || properties.GetClipToFrame()) { + dirtyManager.UpdateDirtyRegionInfoForDfx( + GetId(), GetType(), DirtyRegionType::PREPARE_CLIP_RECT, GetAbsDrawRect()); + } } bool RSRenderNode::Update(RSDirtyRegionManager& dirtyManager, const std::shared_ptr& parent, diff --git a/rosen/test/render_service/render_service_base/unittest/pipeline/rs_render_node_test.cpp b/rosen/test/render_service/render_service_base/unittest/pipeline/rs_render_node_test.cpp index a8c7e7de31..2bc670740f 100644 --- a/rosen/test/render_service/render_service_base/unittest/pipeline/rs_render_node_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/pipeline/rs_render_node_test.cpp @@ -42,6 +42,8 @@ const std::string OUT_STR2 = "Properties: Bounds[-inf -inf -inf -inf] Frame[-inf -inf -inf -inf], GetBootAnimation: true, " "isContainBootAnimation: true, isNodeDirty: 1, isPropertyDirty: true, isSubTreeDirty: true, IsPureContainer: true, " "Children list needs update, current count: 0 expected count: 0+1\n"; +const int DEFAULT_BOUNDS_SIZE = 10; +const int DEFAULT_NODE_ID = 1; class RSRenderNodeDrawableAdapterBoy : public DrawableV2::RSRenderNodeDrawableAdapter { public: explicit RSRenderNodeDrawableAdapterBoy(std::shared_ptr node) @@ -2564,5 +2566,39 @@ HWTEST_F(RSRenderNodeTest, ProcessTransitionAfterChildren, TestSize.Level1) node.ProcessTransitionAfterChildren(*canvas_); ASSERT_TRUE(true); } + +/** + * @tc.name: UpdateDirtyRegionInfoForDFX001 + * @tc.desc: test if subTreeDirtyRegion can be correctly collected. + * @tc.type: FUNC + * @tc.require: issueA7UVD + */ +HWTEST_F(RSRenderNodeTest, UpdateDirtyRegionInfoForDFX001, TestSize.Level1) +{ + auto canvasNode = std::make_shared(DEFAULT_NODE_ID, context); + std::shared_ptr rsDirtyManager = std::make_shared(); + canvasNode->lastFrameSubTreeSkipped_ = true; + canvasNode->subTreeDirtyRegion_ = RectI(0, 0, DEFAULT_BOUNDS_SIZE, DEFAULT_BOUNDS_SIZE); + canvasNode->UpdateDirtyRegionInfoForDFX(*rsDirtyManager); + ASSERT_FALSE(rsDirtyManager->dirtyCanvasNodeInfo_.empty()); +} + +/** + * @tc.name: UpdateDirtyRegionInfoForDFX002 + * @tc.desc: test if absDrawRect can be correctly collected when clip property is true. + * @tc.type: FUNC + * @tc.require: issueA7UVD + */ +HWTEST_F(RSRenderNodeTest, UpdateDirtyRegionInfoForDFX002, TestSize.Level1) +{ + auto canvasNode = std::make_shared(DEFAULT_NODE_ID, context); + std::shared_ptr rsDirtyManager = std::make_shared(); + auto& properties = canvasNode->GetMutableRenderProperties(); + properties.clipToBounds_ = true; + canvasNode->absDrawRect_ = RectI(0, 0, DEFAULT_BOUNDS_SIZE, DEFAULT_BOUNDS_SIZE); + canvasNode->UpdateDirtyRegionInfoForDFX(*rsDirtyManager); + ASSERT_FALSE(rsDirtyManager->dirtyCanvasNodeInfo_.empty()); +} + } // namespace Rosen } // namespace OHOS From 83161b09ce11b622da59852440920af9749ac3d0 Mon Sep 17 00:00:00 2001 From: zhuxiaoyu Date: Mon, 1 Jul 2024 17:35:08 +0800 Subject: [PATCH 152/247] =?UTF-8?q?=E5=88=A0=E9=99=A4return=EF=BC=8C?= =?UTF-8?q?=E8=A7=A3=E5=86=B3property=E6=9C=AA=E5=AE=8C=E5=85=A8remove?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhuxiaoyu Change-Id: Ie7fd09c8603c7ea6447d1fb71692f1068afd66d8 --- .../modules/render_service_base/src/pipeline/rs_render_node.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp b/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp index 6462384651..015c9b1a7c 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp @@ -2127,7 +2127,6 @@ void RSRenderNode::RemoveModifier(const PropertyId& id) [id](const auto& modifier) -> bool { return modifier == nullptr || modifier->GetPropertyId() == id; }); if (found) { AddDirtyType(type); - return; } } } From becef80018b40212e98279704aa75b6dad685f48 Mon Sep 17 00:00:00 2001 From: wangwei Date: Mon, 1 Jul 2024 18:06:43 +0800 Subject: [PATCH 153/247] ww Signed-off-by: wangwei --- rosen/test/render_service/BUILD.gn | 3 + .../BUILD.gn | 77 +++++++++++ .../corpus/init | 1 + .../project.xml | 25 ++++ ...eipcinterfacecodeaccessverifier_fuzzer.cpp | 82 ++++++++++++ ...iceipcinterfacecodeaccessverifier_fuzzer.h | 20 +++ .../BUILD.gn | 77 +++++++++++ .../corpus/init | 1 + .../project.xml | 25 ++++ .../rsrenderservicesecurityutils_fuzzer.cpp | 75 +++++++++++ .../rsrenderservicesecurityutils_fuzzer.h | 20 +++ .../rsrenderservicestub_fuzzer/BUILD.gn | 77 +++++++++++ .../rsrenderservicestub_fuzzer/corpus/init | 1 + .../rsrenderservicestub_fuzzer/project.xml | 25 ++++ .../rsrenderservicestub_fuzzer.cpp | 125 ++++++++++++++++++ .../rsrenderservicestub_fuzzer.h | 21 +++ 16 files changed, 655 insertions(+) create mode 100755 rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/BUILD.gn create mode 100755 rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/corpus/init create mode 100755 rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/project.xml create mode 100755 rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer.cpp create mode 100755 rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer.h create mode 100755 rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/BUILD.gn create mode 100755 rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/corpus/init create mode 100755 rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/project.xml create mode 100755 rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/rsrenderservicesecurityutils_fuzzer.cpp create mode 100755 rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/rsrenderservicesecurityutils_fuzzer.h create mode 100755 rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/BUILD.gn create mode 100755 rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/corpus/init create mode 100755 rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/project.xml create mode 100755 rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/rsrenderservicestub_fuzzer.cpp create mode 100755 rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/rsrenderservicestub_fuzzer.h diff --git a/rosen/test/render_service/BUILD.gn b/rosen/test/render_service/BUILD.gn index a2ba846bd5..22ee6aa223 100755 --- a/rosen/test/render_service/BUILD.gn +++ b/rosen/test/render_service/BUILD.gn @@ -16,8 +16,11 @@ import("//foundation/graphic/graphic_2d/graphic_config.gni") group("test") { testonly = true deps = [ + "render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer:fuzztest", "render_service/fuzztest/rsrenderserviceconnection_fuzzer:fuzztest", "render_service/fuzztest/rsrenderserviceconnectionstub_fuzzer:fuzztest", + "render_service/fuzztest/rsrenderservicesecurityutils_fuzzer:fuzztest", + "render_service/fuzztest/rsrenderservicestub_fuzzer:fuzztest", "render_service/fuzztest/rstransaction_fuzzer:fuzztest", "render_service/systemtest/pipeline:systemtest", "render_service/unittest/drawable:unittest", diff --git a/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/BUILD.gn b/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/BUILD.gn new file mode 100755 index 0000000000..7482f126cd --- /dev/null +++ b/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/BUILD.gn @@ -0,0 +1,77 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +module_output_path = "graphic_2d/graphic_2d" + +##############################fuzztest########################################## +ohos_fuzztest("RSIrenderServiceIpcInterfaceCodeAccessVerifierFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "../../../../../test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer" + include_dirs = [ + "../../../../../rosen/modules/platform/ipc_core", + "../../../../../rosen/modules/platform", + "../../../../../modules/hyper_graphic_manager/core/config", + "../../../../../modules/render_service/core", + "../../../../../modules/render_service_base/src", + "../../../../../test/include", + ] + deps = [ + "../../../../../modules/2d_graphics:2d_graphics", + "../../../../../modules/composer:libcomposer", + "../../../../../modules/render_service:librender_service", + "../../../../../modules/render_service_base:librender_service_base", + "../../../../../modules/render_service_client:librender_service_client", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + sources = [ "rsirenderserviceipcinterfacecodeaccessverifier_fuzzer.cpp" ] + + external_deps = [ + "ability_base:base", + "ability_base:want", + "ability_runtime:abilitykit_native", + "ability_runtime:app_manager", + "c_utils:utils", + "common_event_service:cesfwk_core", + "common_event_service:cesfwk_innerkits", + "hilog:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + + if (defined(global_parts_info) && defined(global_parts_info.sensors_sensor)) { + external_deps += [ "sensor:sensor_interface_native" ] + } +} +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":RSIrenderServiceIpcInterfaceCodeAccessVerifierFuzzTest", + ] +} +############################################################################### diff --git a/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/corpus/init b/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/corpus/init new file mode 100755 index 0000000000..6b7212c8a6 --- /dev/null +++ b/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/corpus/init @@ -0,0 +1 @@ +FUZZ \ No newline at end of file diff --git a/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/project.xml b/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/project.xml new file mode 100755 index 0000000000..c14caf653d --- /dev/null +++ b/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer.cpp b/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer.cpp new file mode 100755 index 0000000000..fb6532980b --- /dev/null +++ b/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer.cpp @@ -0,0 +1,82 @@ +/* + * 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. + */ + +#include "rsirenderserviceipcinterfacecodeaccessverifier_fuzzer.h" + +#include +#include +#include + +#include "platform/ohos/rs_irender_service_ipc_interface_code_access_verifier.h" +#include "platform/ohos/rs_irender_service_ipc_interface_code.h" + +namespace OHOS { +namespace Rosen { +namespace { +const uint8_t* DATA = nullptr; +size_t g_size = 0; +size_t g_pos; +} // namespace + +template +T GetData() +{ + T object {}; + size_t objectSize = sizeof(object); + if (DATA == nullptr || objectSize > g_size - g_pos) { + return object; + } + errno_t ret = memcpy_s(&object, objectSize, DATA + g_pos, objectSize); + if (ret != EOK) { + return {}; + } + g_pos += objectSize; + return object; +} + +bool RSIRenderServiceInterfaceCodeAccessVerifierFuzztest(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + // initialize + DATA = data; + g_size = size; + g_pos = 0; + + // get data + uint32_t code = GetData(); + + RSIRenderServiceInterfaceCodeAccessVerifier verifier; + verifier.IsExclusiveVerificationPassed(code); +#ifdef ENABLE_IPC_SECURITY + uint32_t times = GetData(); + PermissionType permission = PermissionType::CAPTURE_SCREEN; + verifier.permissionRSIRenderServiceInterfaceMappings_.emplace(code, permission); + verifier.AddRSIRenderServiceConnectionInterfaceCodePermission(); + verifier.IsAccessTimesVerificationPassed(code, times); +#endif + return true; +} +} // namespace Rosen +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::Rosen::RSIRenderServiceInterfaceCodeAccessVerifierFuzztest(data, size); + return 0; +} \ No newline at end of file diff --git a/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer.h b/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer.h new file mode 100755 index 0000000000..dda84cf960 --- /dev/null +++ b/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer.h @@ -0,0 +1,20 @@ +/* + * 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 RSIRENDERSERVICEIPCINTERFACECODEACCESSVERIFIER_FUZZER_H +#define RSIRENDERSERVICEIPCINTERFACECODEACCESSVERIFIER_FUZZER_H + +#define FUZZ_PROJECT_NAME "rsrenderservicestub_fuzzer" + +#endif // RSIRENDERSERVICEIPCINTERFACECODEACCESSVERIFIER_FUZZER_H \ No newline at end of file diff --git a/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/BUILD.gn b/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/BUILD.gn new file mode 100755 index 0000000000..c13982c734 --- /dev/null +++ b/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/BUILD.gn @@ -0,0 +1,77 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +module_output_path = "graphic_2d/graphic_2d" + +##############################fuzztest########################################## +ohos_fuzztest("RSRenderServiceSecurityUtilsFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "../../../../../test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer" + include_dirs = [ + "../../../../../rosen/modules/platform/ipc_core", + "../../../../../rosen/modules/platform", + "../../../../../modules/hyper_graphic_manager/core/config", + "../../../../../modules/render_service/core", + "../../../../../modules/render_service_base/src", + "../../../../../test/include", + ] + deps = [ + "../../../../../modules/2d_graphics:2d_graphics", + "../../../../../modules/composer:libcomposer", + "../../../../../modules/render_service:librender_service", + "../../../../../modules/render_service_base:librender_service_base", + "../../../../../modules/render_service_client:librender_service_client", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + sources = [ "rsrenderservicesecurityutils_fuzzer.cpp" ] + + external_deps = [ + "ability_base:base", + "ability_base:want", + "ability_runtime:abilitykit_native", + "ability_runtime:app_manager", + "c_utils:utils", + "common_event_service:cesfwk_core", + "common_event_service:cesfwk_innerkits", + "hilog:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + + if (defined(global_parts_info) && defined(global_parts_info.sensors_sensor)) { + external_deps += [ "sensor:sensor_interface_native" ] + } +} +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":RSRenderServiceSecurityUtilsFuzzTest", + ] +} +############################################################################### diff --git a/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/corpus/init b/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/corpus/init new file mode 100755 index 0000000000..6b7212c8a6 --- /dev/null +++ b/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/corpus/init @@ -0,0 +1 @@ +FUZZ \ No newline at end of file diff --git a/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/project.xml b/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/project.xml new file mode 100755 index 0000000000..c14caf653d --- /dev/null +++ b/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/rsrenderservicesecurityutils_fuzzer.cpp b/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/rsrenderservicesecurityutils_fuzzer.cpp new file mode 100755 index 0000000000..fab381bceb --- /dev/null +++ b/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/rsrenderservicesecurityutils_fuzzer.cpp @@ -0,0 +1,75 @@ +/* + * 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. + */ + +#include "rsrenderservicesecurityutils_fuzzer.h" + +#include +#include +#include + +#include "transaction/rs_render_service_security_utils.h" + +namespace OHOS { +namespace Rosen { +namespace { +const uint8_t* DATA = nullptr; +size_t g_size = 0; +size_t g_pos; +} // namespace + +template +T GetData() +{ + T object {}; + size_t objectSize = sizeof(object); + if (DATA == nullptr || objectSize > g_size - g_pos) { + return object; + } + errno_t ret = memcpy_s(&object, objectSize, DATA + g_pos, objectSize); + if (ret != EOK) { + return {}; + } + g_pos += objectSize; + return object; +} + +bool RSRSRenderServiceSecurityUtilsFuzztest(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + // initialize + DATA = data; + g_size = size; + g_pos = 0; + + // get data + uint32_t code = GetData(); + RSRenderServiceSecurityUtils securityUtils; + securityUtils.GetCodeAccessCounter(code); + securityUtils.IncreaseAccessCounter(code); + return true; +} + +} // namespace Rosen +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::Rosen::RSRSRenderServiceSecurityUtilsFuzztest(data, size); + return 0; +} \ No newline at end of file diff --git a/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/rsrenderservicesecurityutils_fuzzer.h b/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/rsrenderservicesecurityutils_fuzzer.h new file mode 100755 index 0000000000..a652100c08 --- /dev/null +++ b/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/rsrenderservicesecurityutils_fuzzer.h @@ -0,0 +1,20 @@ +/* + * 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 RSRENDERSERVICESECURITYUTILS_FUZZER_H +#define RSRENDERSERVICESECURITYUTILS_FUZZER_H + +#define FUZZ_PROJECT_NAME "rsrenderservicestub_fuzzer" + +#endif // RSRENDERSERVICESECURITYUTILS_FUZZER_H \ No newline at end of file diff --git a/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/BUILD.gn b/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/BUILD.gn new file mode 100755 index 0000000000..a9f0a20547 --- /dev/null +++ b/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/BUILD.gn @@ -0,0 +1,77 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +module_output_path = "graphic_2d/graphic_2d" + +##############################fuzztest########################################## +ohos_fuzztest("RSRenderServiceStubFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "../../../../../test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer" + include_dirs = [ + "../../../../../rosen/modules/platform/ipc_core", + "../../../../../rosen/modules/platform", + "../../../../../modules/hyper_graphic_manager/core/config", + "../../../../../modules/render_service/core", + "../../../../../modules/render_service_base/src", + "../../../../../test/include", + ] + deps = [ + "../../../../../modules/2d_graphics:2d_graphics", + "../../../../../modules/composer:libcomposer", + "../../../../../modules/render_service:librender_service", + "../../../../../modules/render_service_base:librender_service_base", + "../../../../../modules/render_service_client:librender_service_client", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + sources = [ "rsrenderservicestub_fuzzer.cpp" ] + + external_deps = [ + "ability_base:base", + "ability_base:want", + "ability_runtime:abilitykit_native", + "ability_runtime:app_manager", + "c_utils:utils", + "common_event_service:cesfwk_core", + "common_event_service:cesfwk_innerkits", + "hilog:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + + if (defined(global_parts_info) && defined(global_parts_info.sensors_sensor)) { + external_deps += [ "sensor:sensor_interface_native" ] + } +} +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":RSRenderServiceStubFuzzTest", + ] +} +############################################################################### diff --git a/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/corpus/init b/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/corpus/init new file mode 100755 index 0000000000..6b7212c8a6 --- /dev/null +++ b/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/corpus/init @@ -0,0 +1 @@ +FUZZ \ No newline at end of file diff --git a/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/project.xml b/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/project.xml new file mode 100755 index 0000000000..c14caf653d --- /dev/null +++ b/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/rsrenderservicestub_fuzzer.cpp b/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/rsrenderservicestub_fuzzer.cpp new file mode 100755 index 0000000000..8079e966b1 --- /dev/null +++ b/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/rsrenderservicestub_fuzzer.cpp @@ -0,0 +1,125 @@ +/* + * 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. + */ + +#include "rsrenderservicestub_fuzzer.h" + +#include +#include +#include +#include +#include +#include + +#include "platform/ohos/rs_irender_service.h" +#include "platform/ohos/rs_irender_service_ipc_interface_code_access_verifier.h" +#include "pipeline/rs_render_service.h" +#include "transaction/rs_render_service_stub.h" + +namespace OHOS { +namespace Rosen { +namespace { +const uint8_t* DATA = nullptr; +size_t g_size = 0; +size_t g_pos; +} // namespace + +template +T GetData() +{ + T object {}; + size_t objectSize = sizeof(object); + if (DATA == nullptr || objectSize > g_size - g_pos) { + return object; + } + errno_t ret = memcpy_s(&object, objectSize, DATA + g_pos, objectSize); + if (ret != EOK) { + return {}; + } + g_pos += objectSize; + return object; +} + +bool RSRenderServiceStubFuzztest001(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + // initialize + DATA = data; + g_size = size; + g_pos = 0; + + // get data + uint32_t code = GetData(); + sptr stub = new RSRenderService(); + MessageParcel data1; + MessageParcel reply; + MessageOption option; + stub->OnRemoteRequest(code, data1, reply, option); + return true; +} + +bool RSRenderServiceStubFuzztest002(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + // initialize + DATA = data; + g_size = size; + g_pos = 0; + + // get data + uint32_t code = static_cast(RSIRenderServiceInterfaceCode::CREATE_CONNECTION); + sptr stub = new RSRenderService(); + MessageParcel data1; + MessageParcel reply; + MessageOption option; + stub->OnRemoteRequest(code, data1, reply, option); + return true; +} + +bool RSRenderServiceStubFuzztest003(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + // initialize + DATA = data; + g_size = size; + g_pos = 0; + + // get data + uint32_t code = static_cast(RSIRenderServiceInterfaceCode::CREATE_CONNECTION); + sptr stub = new RSRenderService(); + MessageParcel data1; + MessageParcel reply; + MessageOption option; + data1.WriteInterfaceToken(RSIRenderService::GetDescriptor()); + stub->OnRemoteRequest(code, data1, reply, option); + return true; +} +} // namespace Rosen +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::Rosen::RSRenderServiceStubFuzztest001(data, size); + OHOS::Rosen::RSRenderServiceStubFuzztest002(data, size); + OHOS::Rosen::RSRenderServiceStubFuzztest003(data, size); + return 0; +} \ No newline at end of file diff --git a/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/rsrenderservicestub_fuzzer.h b/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/rsrenderservicestub_fuzzer.h new file mode 100755 index 0000000000..80138864a6 --- /dev/null +++ b/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/rsrenderservicestub_fuzzer.h @@ -0,0 +1,21 @@ +/* + * 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 RSRENDERSERVICESTUB_FUZZER_H +#define RSRENDERSERVICESTUB_FUZZER_H + +#define FUZZ_PROJECT_NAME "rsrenderservicestub_fuzzer" + +#endif // RSRENDERSERVICESTUB_FUZZER_H + From fdb6fbee0241b0c2ac205a876d7b8fddbebdb249 Mon Sep 17 00:00:00 2001 From: tttaaaooo Date: Mon, 1 Jul 2024 17:35:11 +0800 Subject: [PATCH 154/247] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=9A=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E8=BF=9B=E5=85=A5=E5=BA=94=E7=94=A8=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=B3=95=E5=8D=A1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tttaaaooo --- .../render_service/core/pipeline/rs_uifirst_manager.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/rosen/modules/render_service/core/pipeline/rs_uifirst_manager.cpp b/rosen/modules/render_service/core/pipeline/rs_uifirst_manager.cpp index 0101323f7e..83e33324d5 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uifirst_manager.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uifirst_manager.cpp @@ -721,9 +721,6 @@ void RSUifirstManager::AddPendingPostNode(NodeId id, std::shared_ptrIsNodeToBeCaptured()) { - node->SetIsNodeToBeCaptured(true); - } // delete card node in leashwindow tree for (auto it = pendingPostCardNodes_.begin(); it != pendingPostCardNodes_.end();) { auto surfaceNode = it->second; @@ -1018,7 +1015,7 @@ bool RSUifirstManager::IsLeashWindowCache(RSSurfaceRenderNode& node, bool animat if (RSUifirstManager::Instance().IsRecentTaskScene()) { isNeedAssignToSubThread = node.IsScale() && LeashWindowContainMainWindow(node); } else { - isNeedAssignToSubThread = animation || node.IsNodeToBeCaptured(); + isNeedAssignToSubThread = animation; } // 1: Planning: support multi appwindows @@ -1189,7 +1186,7 @@ void RSUifirstManager::UpdateUIFirstLayerInfo(const ScreenInfo& screenInfo) void RSUifirstManager::ProcessTreeStateChange(RSSurfaceRenderNode& node) { // Planning: do not clear complete image for card - if (node.IsOnTheTree() || node.IsNodeToBeCaptured()) { + if (node.IsOnTheTree()) { return; } RSUifirstManager::Instance().DisableUifirstNode(node); From b60bec419328986169326b30c07172bc618fcc08 Mon Sep 17 00:00:00 2001 From: 15549494042 Date: Mon, 1 Jul 2024 19:32:24 +0800 Subject: [PATCH 155/247] add pointer color invert ipc interface Singed-off-by:dongzhengkuan@huawei.com Signed-off-by: 15549494042 --- .../test/unittest/rs_interfaces_test.cpp | 59 +++++++++++++++++ .../rsrenderserviceconnection_fuzzer.cpp | 63 +++++++++++++++++++ .../rsrenderserviceconnectionstub_fuzzer.cpp | 38 +++++++++++ .../ohos/rs_render_service_client_test.cpp | 48 ++++++++++++++ ...s_render_service_connection_proxy_test.cpp | 46 ++++++++++++++ .../rsinterfaces_fuzzer.cpp | 6 ++ 6 files changed, 260 insertions(+) diff --git a/rosen/modules/render_service_client/test/unittest/rs_interfaces_test.cpp b/rosen/modules/render_service_client/test/unittest/rs_interfaces_test.cpp index 120ff04d1b..cde37e7d92 100644 --- a/rosen/modules/render_service_client/test/unittest/rs_interfaces_test.cpp +++ b/rosen/modules/render_service_client/test/unittest/rs_interfaces_test.cpp @@ -420,6 +420,65 @@ HWTEST_F(RSInterfacesTest, GetScreenSupportedModes002, Function | SmallTest | Le EXPECT_EQ(supportedScreenModes.size(), 0); } +/* +* Function: SetPointerColorInversionConfig +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetPointerColorInversionConfig +* 2. check +*/ +HWTEST_F(RSInterfacesTest, SetPointerColorInversionConfig001, Function | SmallTest | Level2) +{ + float darkBuffer = 0.5; + float brightBuffer = 0.5; + int64_t interval = 50; + int32_t ret = rsInterfaces->SetPointerColorInversionConfig(darkBuffer, brightBuffer, interval); + EXPECT_EQ(ret, StatusCode::SUCCESS); +} + +/* +* Function: SetPointerColorInversionEnabled +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetPointerColorInversionEnabled +* 2. check +*/ +HWTEST_F(RSInterfacesTest, SetPointerColorInversionEnabled001, Function | SmallTest | Level2) +{ + int32_t ret = rsInterfaces->SetPointerColorInversionEnabled(false); + EXPECT_EQ(ret, StatusCode::SUCCESS); +} + +/* +* Function: RegisterPointerLuminanceChangeCallback +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RegisterPointerLuminanceChangeCallback +* 2. check +*/ +HWTEST_F(RSInterfacesTest, RegisterPointerLuminanceChangeCallback001, Function | SmallTest | Level2) +{ + int32_t ret = rsInterfaces->RegisterPointerLuminanceChangeCallback([](int32_t brightness) -> void {}); + EXPECT_EQ(ret, StatusCode::SUCCESS); +} + +/* +* Function: UnRegisterPointerLuminanceChangeCallback +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call UnRegisterPointerLuminanceChangeCallback +* 2. check +*/ +HWTEST_F(RSInterfacesTest, UnRegisterPointerLuminanceChangeCallback, Function | SmallTest | Level2) +{ + int32_t ret = rsInterfaces->UnRegisterPointerLuminanceChangeCallback(); + EXPECT_EQ(ret, StatusCode::SUCCESS); +} + /* * Function: SetScreenActiveMode * Type: Function diff --git a/rosen/test/render_service/render_service/fuzztest/rsrenderserviceconnection_fuzzer/rsrenderserviceconnection_fuzzer.cpp b/rosen/test/render_service/render_service/fuzztest/rsrenderserviceconnection_fuzzer/rsrenderserviceconnection_fuzzer.cpp index 285ac67ef2..f34d618977 100644 --- a/rosen/test/render_service/render_service/fuzztest/rsrenderserviceconnection_fuzzer/rsrenderserviceconnection_fuzzer.cpp +++ b/rosen/test/render_service/render_service/fuzztest/rsrenderserviceconnection_fuzzer/rsrenderserviceconnection_fuzzer.cpp @@ -31,6 +31,7 @@ #include "securec.h" #include "ipc_callbacks/rs_occlusion_change_callback_stub.h" +#include "ipc_callbacks/pointer_luminance_callback_stub.h" #include "pipeline/rs_render_service.h" #include "pipeline/rs_render_service_connection.h" #include "platform/ohos/rs_render_service_connect_hub.cpp" @@ -507,6 +508,66 @@ bool DoCreateVirtualScreen(const uint8_t* data, size_t size) return true; } +bool DoSetPointerColorInversionConfig(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + if (size < MAX_SIZE) { + return false; + } + + g_data = data; + g_size = size; + g_pos = 0; + auto rsConn = RSRenderServiceConnectHub::GetRenderService(); + if (rsConn == nullptr) { + return false; + } + float darkBuffer = GetData(); + float brightBuffer = GetData(); + int64_t interval = GetData(); + rsConn->SetPointerColorInversionConfig(darkBuffer, brightBuffer, interval); + return true; +} + +class CustomPointerLuminanceChangeCallback : public RSPointerLuminanceChangeCallbackStub { +public: + explicit CustomPointerLuminanceChangeCallback(const PointerLuminanceChangeCallback &callback) : cb_(callback) {} + ~CustomPointerLuminanceChangeCallback() override {}; + + void OnPointerLuminanceChanged(int32_t brightness) override + { + if (cb_ != nullptr) { + cb_(brightness); + } + } + +private: + PointerLuminanceChangeCallback cb_; +}; + +bool DoRegisterPointerLuminanceChangeCallback(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + if (size < MAX_SIZE) { + return false; + } + + auto rsConn = RSRenderServiceConnectHub::GetRenderService(); + if (rsConn == nullptr) { + return false; + } + PointerLuminanceChangeCallback callback = [](int32_t brightness) {}; + sptr cb = new CustomPointerLuminanceChangeCallback(callback); + rsConn->RegisterPointerLuminanceChangeCallback(cb); + return true; +} + bool DoSetScreenActiveMode(const uint8_t* data, size_t size) { if (data == nullptr) { @@ -858,6 +919,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) OHOS::Rosen::DoSetScreenGamutMap(data, size); OHOS::Rosen::DoSetAppWindowNum(data, size); OHOS::Rosen::DoCreateVirtualScreen(data, size); + OHOS::Rosen::DoSetPointerColorInversionConfig(data, size); + OHOS::Rosen::DoRegisterPointerLuminanceChangeCallback(data, size); OHOS::Rosen::DoSetScreenActiveMode(data, size); OHOS::Rosen::DoSetRefreshRateMode(data, size); OHOS::Rosen::DoCreateVSyncConnection(data, size); diff --git a/rosen/test/render_service/render_service/fuzztest/rsrenderserviceconnectionstub_fuzzer/rsrenderserviceconnectionstub_fuzzer.cpp b/rosen/test/render_service/render_service/fuzztest/rsrenderserviceconnectionstub_fuzzer/rsrenderserviceconnectionstub_fuzzer.cpp index 3aec28e937..709813bd82 100644 --- a/rosen/test/render_service/render_service/fuzztest/rsrenderserviceconnectionstub_fuzzer/rsrenderserviceconnectionstub_fuzzer.cpp +++ b/rosen/test/render_service/render_service/fuzztest/rsrenderserviceconnectionstub_fuzzer/rsrenderserviceconnectionstub_fuzzer.cpp @@ -221,6 +221,42 @@ bool DoSetScreenChangeCallback(const uint8_t* data, size_t size) return true; } +bool DoSetPointerColorInversionConfig(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + if (size < MAX_SIZE) { + return false; + } + + g_data = data; + g_size = size; + g_pos = 0; + + float darkBuffer = GetData(); + float brightBuffer = GetData(); + int64_t interval = GetData(); + rsClient->SetPointerColorInversionConfig(darkBuffer, brightBuffer, interval); + return true; +} + +bool DoRegisterPointerLuminanceChangeCallback(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + if (size < MAX_SIZE) { + return false; + } + + PointerLuminanceChangeCallback cb = [](int32_t brightness) {}; + rsClient->RegisterPointerLuminanceChangeCallback(cb); + return true; +} + bool DoSetScreenActiveMode(const uint8_t* data, size_t size) { if (data == nullptr) { @@ -743,6 +779,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) OHOS::Rosen::DoSetFocusAppInfo(data, size); OHOS::Rosen::DoCreateVirtualScreen(data, size); OHOS::Rosen::DoSetScreenChangeCallback(data, size); + OHOS::Rosen::DoSetPointerColorInversionConfig(data, size); + OHOS::Rosen::DoRegisterPointerLuminanceChangeCallback(data, size); OHOS::Rosen::DoSetScreenActiveMode(data, size); OHOS::Rosen::DoSetScreenRefreshRate(data, size); OHOS::Rosen::DoSetRefreshRateMode(data, size); diff --git a/rosen/test/render_service/render_service_base/unittest/platform/ohos/rs_render_service_client_test.cpp b/rosen/test/render_service/render_service_base/unittest/platform/ohos/rs_render_service_client_test.cpp index 2174d5b7bf..96def58882 100644 --- a/rosen/test/render_service/render_service_base/unittest/platform/ohos/rs_render_service_client_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/platform/ohos/rs_render_service_client_test.cpp @@ -437,6 +437,54 @@ HWTEST_F(RSClientTest, SetScreenChangeCallback001, TestSize.Level1) EXPECT_EQ(status, StatusCode::SUCCESS); } +/** + * @tc.name: SetPointerColorInversionConfig Test + * @tc.desc: SetPointerColorInversionConfig Test + * @tc.type:FUNC + * @tc.require: issuesI9K7SJ + */ +HWTEST_F(RSClientTest, SetPointerColorInversionConfig001, TestSize.Level1) +{ + float darkBuffer = 0.5; + float brightBuffer = 0.5; + int64_t interval = 50; + EXPECT_EQ(rsClient->SetPointerColorInversionConfig(darkBuffer, brightBuffer, interval), StatusCode::SUCCESS); +} + +/** + * @tc.name: SetPointerColorInversionEnabled Test + * @tc.desc: SetPointerColorInversionEnabled Test + * @tc.type:FUNC + * @tc.require: issuesI9K7SJ + */ +HWTEST_F(RSClientTest, SetPointerColorInversionEnabled001, TestSize.Level1) +{ + EXPECT_EQ(rsClient->SetPointerColorInversionEnabled(false), StatusCode::SUCCESS); +} + +/** + * @tc.name: RegisterPointerLuminanceChangeCallback Test + * @tc.desc: RegisterPointerLuminanceChangeCallback Test + * @tc.type:FUNC + * @tc.require: issuesI9K7SJ + */ +HWTEST_F(RSClientTest, RegisterPointerLuminanceChangeCallback001, TestSize.Level1) +{ + EXPECT_EQ(rsClient->RegisterPointerLuminanceChangeCallback([](int32_t brightness) -> void {}), + StatusCode::SUCCESS); +} + +/** + * @tc.name: UnRegisterPointerLuminanceChangeCallback Test + * @tc.desc: UnRegisterPointerLuminanceChangeCallback Test + * @tc.type:FUNC + * @tc.require: issuesI9K7SJ + */ +HWTEST_F(RSClientTest, UnRegisterPointerLuminanceChangeCallback001, TestSize.Level1) +{ + EXPECT_EQ(rsClient->UnRegisterPointerLuminanceChangeCallback(), StatusCode::SUCCESS); +} + /** * @tc.name: SetScreenActiveMode Test * @tc.desc: SetScreenActiveMode Test diff --git a/rosen/test/render_service/render_service_base/unittest/platform/ohos/rs_render_service_connection_proxy_test.cpp b/rosen/test/render_service/render_service_base/unittest/platform/ohos/rs_render_service_connection_proxy_test.cpp index 97515bc961..6c84662f4e 100644 --- a/rosen/test/render_service/render_service_base/unittest/platform/ohos/rs_render_service_connection_proxy_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/platform/ohos/rs_render_service_connection_proxy_test.cpp @@ -253,6 +253,52 @@ HWTEST_F(RSRenderServiceConnectionProxyTest, RemoveVirtualScreen, TestSize.Level ASSERT_TRUE(true); } +/** + * @tc.name: SetPointerColorInversionConfig Test + * @tc.desc: SetPointerColorInversionConfig Test + * @tc.type:FUNC + * @tc.require: issueI9KXXE + */ +HWTEST_F(RSRenderServiceConnectionProxyTest, SetPointerColorInversionConfig, TestSize.Level1) +{ + float darkBuffer = 0.5; + float brightBuffer = 0.5; + int64_t interval = 50; + proxy->SetPointerColorInversionConfig(darkBuffer, brightBuffer, interval); + ASSERT_TRUE(true); +} + +/** + * @tc.name: SetPointerColorInversionEnabled Test + * @tc.desc: SetPointerColorInversionEnabled Test + * @tc.type:FUNC + * @tc.require: issueI9KXXE + */ +HWTEST_F(RSRenderServiceConnectionProxyTest, SetPointerColorInversionEnabled, TestSize.Level1) +{ + proxy->SetPointerColorInversionEnabled(false); + ASSERT_TRUE(true); +} + +/** + * @tc.name: RegisterPointerLuminanceChangeCallback Test + * @tc.desc: RegisterPointerLuminanceChangeCallback Test + * @tc.type:FUNC + * @tc.require: issueI9KXXE + */ +HWTEST_F(RSRenderServiceConnectionProxyTest, RegisterPointerLuminanceChangeCallback, TestSize.Level1) +{ + sptr callback; + proxy->RegisterPointerLuminanceChangeCallback(callback); + auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + ASSERT_NE(samgr, nullptr); + proxy->UnRegisterPointerLuminanceChangeCallback(); + auto remoteObject = samgr->GetSystemAbility(RENDER_SERVICE); + callback = iface_cast(remoteObject); + proxy->RegisterPointerLuminanceChangeCallback(callback); + ASSERT_NE(proxy->transactionDataIndex_, 5); +} + /** * @tc.name: SetScreenChangeCallback Test * @tc.desc: SetScreenChangeCallback Test diff --git a/rosen/test/render_service/render_service_client/fuzztest/rsinterfaces_fuzzer/rsinterfaces_fuzzer.cpp b/rosen/test/render_service/render_service_client/fuzztest/rsinterfaces_fuzzer/rsinterfaces_fuzzer.cpp index 2e3707a4aa..ed06d71263 100644 --- a/rosen/test/render_service/render_service_client/fuzztest/rsinterfaces_fuzzer/rsinterfaces_fuzzer.cpp +++ b/rosen/test/render_service/render_service_client/fuzztest/rsinterfaces_fuzzer/rsinterfaces_fuzzer.cpp @@ -69,9 +69,15 @@ bool RSPhysicalScreenFuzzTest(const uint8_t* data, size_t size) uint32_t height = GetData(); bool canvasRotation = GetData(); uint32_t scaleMode = GetData(); + float darkBuffer = GetData(); + float brightBuffer = GetData(); + int64_t interval = GetData(); // test auto& rsInterfaces = RSInterfaces::GetInstance(); + rsInterfaces.SetPointerColorInversionConfig(darkBuffer, brightBuffer, interval); + PointerLuminanceChangeCallback callback = [](int32_t) {}; + rsInterfaces.RegisterPointerLuminanceChangeCallback(callback); rsInterfaces.SetScreenActiveMode(static_cast(id), modeId); rsInterfaces.SetScreenPowerStatus(static_cast(id), static_cast(status)); rsInterfaces.SetScreenBacklight(static_cast(id), level); From 4ae99992d716a547fcc2dd1c37d7679396fab69a Mon Sep 17 00:00:00 2001 From: lishijie Date: Mon, 1 Jul 2024 20:32:07 +0800 Subject: [PATCH 156/247] fix FuzzTest Signed-off-by: lishijie Change-Id: I26e1ff0bbe7f7573beb769dd17d329fbc8562d41 --- .../rsrenderserviceconnectionstub_fuzzer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/rosen/test/render_service/render_service/fuzztest/rsrenderserviceconnectionstub_fuzzer/rsrenderserviceconnectionstub_fuzzer.cpp b/rosen/test/render_service/render_service/fuzztest/rsrenderserviceconnectionstub_fuzzer/rsrenderserviceconnectionstub_fuzzer.cpp index 3aec28e937..ff1a5722cf 100644 --- a/rosen/test/render_service/render_service/fuzztest/rsrenderserviceconnectionstub_fuzzer/rsrenderserviceconnectionstub_fuzzer.cpp +++ b/rosen/test/render_service/render_service/fuzztest/rsrenderserviceconnectionstub_fuzzer/rsrenderserviceconnectionstub_fuzzer.cpp @@ -737,6 +737,7 @@ bool DoRegisterHgmRefreshRateModeChangeCallback(const uint8_t* data, size_t size extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ + OHOS::Rosen::DoOnRemoteRequest(data, size); OHOS::Rosen::DoCommitTransaction(data, size); OHOS::Rosen::DoExecuteSynchronousTask(data, size); OHOS::Rosen::DoCreateNodeAndSurface(data, size); From 60ed061f021fc4037a04dc6a46f12cb6e2713c6b Mon Sep 17 00:00:00 2001 From: l00844999 Date: Fri, 28 Jun 2024 21:07:28 +0800 Subject: [PATCH 157/247] =?UTF-8?q?ndk=20=E8=A1=A5=E5=85=85=20Signed-off-b?= =?UTF-8?q?y:=20l00844999=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rosen/test/2d_graphics/fuzztest/ndk/BUILD.gn | 2 + .../fuzztest/ndk/ndkcanvas_fuzzer/BUILD.gn | 6 + .../ndk/ndkcanvas_fuzzer/canvas_fuzzer.cpp | 59 ++++++++++ .../ndk/ndkfont_fuzzer/ndkfont_fuzzer.cpp | 35 ++++++ .../ndk/ndkgpucontext_fuzzer/BUILD.gn | 67 +++++++++++ .../ndk/ndkgpucontext_fuzzer/corpus/init | 14 +++ .../gpucontext_fuzzer.cpp | 88 +++++++++++++++ .../ndkgpucontext_fuzzer/gpucontext_fuzzer.h | 21 ++++ .../ndk/ndkgpucontext_fuzzer/project.xml | 25 +++++ .../fuzztest/ndk/ndksurface_fuzzer/BUILD.gn | 68 ++++++++++++ .../ndk/ndksurface_fuzzer/corpus/init | 14 +++ .../ndk/ndksurface_fuzzer/project.xml | 25 +++++ .../ndk/ndksurface_fuzzer/surface_fuzzer.cpp | 104 ++++++++++++++++++ .../ndk/ndksurface_fuzzer/surface_fuzzer.h | 21 ++++ .../ndktextblob_fuzzer/ndktextblob_fuzzer.cpp | 63 +++++++++++ 15 files changed, 612 insertions(+) create mode 100644 rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer/BUILD.gn create mode 100644 rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer/corpus/init create mode 100644 rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer/gpucontext_fuzzer.cpp create mode 100644 rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer/gpucontext_fuzzer.h create mode 100644 rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer/project.xml create mode 100644 rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer/BUILD.gn create mode 100644 rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer/corpus/init create mode 100644 rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer/project.xml create mode 100644 rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer/surface_fuzzer.cpp create mode 100644 rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer/surface_fuzzer.h diff --git a/rosen/test/2d_graphics/fuzztest/ndk/BUILD.gn b/rosen/test/2d_graphics/fuzztest/ndk/BUILD.gn index 78d44afec1..7c73686dc4 100644 --- a/rosen/test/2d_graphics/fuzztest/ndk/BUILD.gn +++ b/rosen/test/2d_graphics/fuzztest/ndk/BUILD.gn @@ -25,6 +25,7 @@ group("fuzztest") { "ndkerrorcode_fuzzer:fuzztest", "ndkfilter_fuzzer:fuzztest", "ndkfont_fuzzer:fuzztest", + "ndkgpucontext_fuzzer:fuzztest", "ndkimage_fuzzer:fuzztest", "ndkimagefilter_fuzzer:fuzztest", "ndkmaskfilter_fuzzer:fuzztest", @@ -41,6 +42,7 @@ group("fuzztest") { "ndksamplingoptions_fuzzer:fuzztest", "ndkshadereffect_fuzzer:fuzztest", "ndkshadowlayer_fuzzer:fuzztest", + "ndksurface_fuzzer:fuzztest", "ndktextblob_fuzzer:fuzztest", "ndktypeface_fuzzer:fuzztest", ] diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndkcanvas_fuzzer/BUILD.gn b/rosen/test/2d_graphics/fuzztest/ndk/ndkcanvas_fuzzer/BUILD.gn index f2861ad85d..b37f4c6044 100755 --- a/rosen/test/2d_graphics/fuzztest/ndk/ndkcanvas_fuzzer/BUILD.gn +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndkcanvas_fuzzer/BUILD.gn @@ -46,6 +46,12 @@ ohos_fuzztest("NdkCanvasFuzzTest") { "$graphic_2d_root/rosen/modules/2d_graphics/drawing_ndk:native_drawing_ndk", ] + external_deps = [ + "image_framework:image_native", + "image_framework:pixelmap", + "image_framework:pixelmap_ndk", + ] + part_name = "graphic_2d" subsystem_name = "graphic" } diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndkcanvas_fuzzer/canvas_fuzzer.cpp b/rosen/test/2d_graphics/fuzztest/ndk/ndkcanvas_fuzzer/canvas_fuzzer.cpp index 5269c48c2d..6cdae855fb 100755 --- a/rosen/test/2d_graphics/fuzztest/ndk/ndkcanvas_fuzzer/canvas_fuzzer.cpp +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndkcanvas_fuzzer/canvas_fuzzer.cpp @@ -28,6 +28,7 @@ #include "drawing_matrix.h" #include "drawing_path.h" #include "drawing_pen.h" +#include "drawing_pixel_map.h" #include "drawing_point.h" #include "drawing_rect.h" #include "drawing_region.h" @@ -35,6 +36,7 @@ #include "drawing_sampling_options.h" #include "drawing_types.h" #include "drawing_text_blob.h" +#include "image/pixelmap_native.h" constexpr uint32_t MAX_ARRAY_MAX = 5000; constexpr uint32_t ENUM_RANGE_ONE = 1; @@ -481,6 +483,62 @@ void CanvasFuzzTest001(const uint8_t* data, size_t size) OH_Drawing_CanvasDestroy(canvas); } + +void CanvasFuzzTest010(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < DATA_MIN_SIZE) { + return; + } + g_data = data; + g_size = size; + g_pos = 0; + + OH_Drawing_Canvas* canvas = OH_Drawing_CanvasCreate(); + + OH_Pixelmap_InitializationOptions *options = nullptr; + OH_PixelmapNative *pixelMap = nullptr; + size_t width = GetObject() % MAX_ARRAY_MAX; + size_t height = GetObject() % MAX_ARRAY_MAX; + OH_PixelmapInitializationOptions_Create(&options); + OH_PixelmapInitializationOptions_SetWidth(options, width); + OH_PixelmapInitializationOptions_SetHeight(options, height); + OH_PixelmapInitializationOptions_SetPixelFormat(options, WIDTH_FACTOR); + OH_PixelmapInitializationOptions_SetAlphaType(options, ENUM_RANGE_TWO); + size_t dataLength = width * height * WIDTH_FACTOR; + uint8_t* colorData = new uint8_t[dataLength]; + for (size_t i = 0; i < width * height; i++) { + colorData[i] = GetObject(); + } + + OH_PixelmapNative_CreatePixelmap(colorData, dataLength, options, &pixelMap); + OH_Drawing_PixelMap *drPixelMap = OH_Drawing_PixelMapGetFromOhPixelMapNative(pixelMap); + OH_Drawing_Rect* srcRect = + OH_Drawing_RectCreate(GetObject(), GetObject(), GetObject(), GetObject()); + OH_Drawing_Rect* dstRect = + OH_Drawing_RectCreate(GetObject(), GetObject(), GetObject(), GetObject()); + OH_Drawing_SamplingOptions* samplingOptions = OH_Drawing_SamplingOptionsCreate( + static_cast(GetObject() % ENUM_RANGE_TWO), + static_cast(GetObject() % ENUM_RANGE_THREE)); + OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, srcRect, dstRect, samplingOptions); + OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, srcRect, dstRect, nullptr); + OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, srcRect, nullptr, nullptr); + OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, nullptr, nullptr, nullptr); + OH_Drawing_CanvasDrawPixelMapRect(canvas, nullptr, nullptr, nullptr, nullptr); + OH_Drawing_CanvasDrawPixelMapRect(nullptr, nullptr, nullptr, nullptr, nullptr); + OH_Drawing_PixelMapDissolve(drPixelMap); + OH_PixelmapNative_Release(pixelMap); + OH_PixelmapInitializationOptions_Release(options); + OH_Drawing_RectDestroy(srcRect); + OH_Drawing_RectDestroy(dstRect); + OH_Drawing_SamplingOptionsDestroy(samplingOptions); + + if (colorData != nullptr) { + delete[] colorData; + colorData = nullptr; + } + + OH_Drawing_CanvasDestroy(canvas); +} } // namespace Drawing } // namespace Rosen } // namespace OHOS @@ -498,5 +556,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) OHOS::Rosen::Drawing::CanvasFuzzTest007(data, size); OHOS::Rosen::Drawing::CanvasFuzzTest008(data, size); OHOS::Rosen::Drawing::CanvasFuzzTest009(data, size); + OHOS::Rosen::Drawing::CanvasFuzzTest010(data, size); return 0; } diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndkfont_fuzzer/ndkfont_fuzzer.cpp b/rosen/test/2d_graphics/fuzztest/ndk/ndkfont_fuzzer/ndkfont_fuzzer.cpp index 4a7025f3aa..2b3bd911b5 100644 --- a/rosen/test/2d_graphics/fuzztest/ndk/ndkfont_fuzzer/ndkfont_fuzzer.cpp +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndkfont_fuzzer/ndkfont_fuzzer.cpp @@ -206,6 +206,40 @@ void NativeDrawingFontTest005(const uint8_t* data, size_t size) OH_Drawing_FontDestroy(font); } +void NativeDrawingFontTest006(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < DATA_MIN_SIZE) { + return; + } + // initialize + g_data = data; + g_size = size; + g_pos = 0; + OH_Drawing_Font* font = OH_Drawing_FontCreate(); + uint32_t count = GetObject() % MAX_ARRAY_SIZE + 1; + float textWidth; + char* str = new char[count]; + for (size_t i = 0; i < count; i++) { + str[i] = GetObject(); + } + str[count - 1] = '\0'; + + uint16_t glyphs[count]; + OH_Drawing_FontTextToGlyphs(font, str, strlen(str), TEXT_ENCODING_UTF8, glyphs, count); + OH_Drawing_FontTextToGlyphs(nullptr, str, strlen(str), TEXT_ENCODING_UTF8, glyphs, count); + OH_Drawing_Font_Metrics metrics; + OH_Drawing_FontGetMetrics(font, &metrics); + OH_Drawing_FontGetMetrics(nullptr, &metrics); + OH_Drawing_FontMeasureText(font, str, strlen(str), TEXT_ENCODING_UTF8, nullptr, &textWidth); + OH_Drawing_FontMeasureText(nullptr, str, strlen(str), TEXT_ENCODING_UTF8, nullptr, &textWidth); + + if (str != nullptr) { + delete [] str; + str = nullptr; + } + OH_Drawing_FontDestroy(font); +} + } // namespace Drawing } // namespace Rosen } // namespace OHOS @@ -219,5 +253,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) OHOS::Rosen::Drawing::NativeDrawingFontTest003(data, size); OHOS::Rosen::Drawing::NativeDrawingFontTest004(data, size); OHOS::Rosen::Drawing::NativeDrawingFontTest005(data, size); + OHOS::Rosen::Drawing::NativeDrawingFontTest006(data, size); return 0; } diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer/BUILD.gn b/rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer/BUILD.gn new file mode 100644 index 0000000000..6d1692200a --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer/BUILD.gn @@ -0,0 +1,67 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import("//foundation/graphic/graphic_2d/graphic_config.gni") +module_output_path = "graphic_2d/graphic_2d" + +##############################fuzztest########################################## +ohos_fuzztest("NdkGpuContextFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "$graphic_2d_root/rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer" + + include_dirs = [ + "$graphic_2d_root/rosen/modules/2d_graphics/include", + "$graphic_2d_root/rosen/modules/2d_graphics/src", + "$graphic_2d_root/rosen/modules/2d_graphics/src/drawing/engine_adapter", + "$graphic_2d_root/rosen/test/2d_graphics/fuzztest", + "$graphic_2d_root/rosen/modules/render_service_base/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "get_object.h", + "gpucontext_fuzzer.cpp", + ] + + deps = [ + "$graphic_2d_root/frameworks/opengl_wrapper:EGL", + "$graphic_2d_root/frameworks/opengl_wrapper:GLESv3", + "$graphic_2d_root/rosen/modules/2d_graphics/drawing_ndk:native_drawing_ndk", + ] + + external_deps = [ "openssl:libcrypto_shared" ] + + part_name = "graphic_2d" + subsystem_name = "graphic" +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + + deps += [ + # deps file + ":NdkGpuContextFuzzTest", + ] +} +############################################################################### diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer/corpus/init b/rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer/corpus/init new file mode 100644 index 0000000000..e7c3fecd8d --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# 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. + +FUZZ \ No newline at end of file diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer/gpucontext_fuzzer.cpp b/rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer/gpucontext_fuzzer.cpp new file mode 100644 index 0000000000..ca1f9b762e --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer/gpucontext_fuzzer.cpp @@ -0,0 +1,88 @@ +/* + * 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 "gpucontext_fuzzer.h" + +#include +#include +#include + +#include "get_object.h" +#include "EGL/egl.h" +#include "EGL/eglext.h" +#include "GLES3/gl32.h" + +#include "drawing_gpu_context.h" + +namespace OHOS { +namespace Rosen { +namespace Drawing { +void GpuContextFuzzTest000(const uint8_t* data, size_t size) +{ + g_data = data; + g_size = size; + g_pos = 0; + + EGLDisplay eglDisplay = EGL_NO_DISPLAY; + EGLConfig eglConfig = EGL_NO_CONFIG_KHR; + EGLContext eglContext = EGL_NO_CONTEXT; + EGLSurface eglSurface = EGL_NO_SURFACE; + OH_Drawing_GpuContext* gpuContext = nullptr; + + eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); + + EGLint eglMajVers; + EGLint eglMinVers; + EGLBoolean ret = eglInitialize(eglDisplay, &eglMajVers, &eglMinVers); + + EGLint count; + EGLint configAttribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT, EGL_NONE }; + ret = eglChooseConfig(eglDisplay, configAttribs, &eglConfig, 1, &count); + + const EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; + eglContext = eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, contextAttribs); + + EGLint attribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE}; + eglSurface = eglCreatePbufferSurface(eglDisplay, eglConfig, attribs); + + ret = eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext); + + OH_Drawing_GpuContextOptions options; + options.allowPathMaskCaching = GetObject(); + gpuContext = OH_Drawing_GpuContextCreateFromGL(options); + OH_Drawing_GpuContextDestroy(gpuContext); + + ret = eglDestroySurface(eglDisplay, eglSurface); + ret = eglDestroyContext(eglDisplay, eglContext); + ret = eglTerminate(eglDisplay); + + eglSurface = EGL_NO_SURFACE; + eglContext = EGL_NO_CONTEXT; + eglDisplay = EGL_NO_DISPLAY; + return; +} +} // namespace Drawing +} // namespace Rosen +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::Rosen::Drawing::GpuContextFuzzTest000(data, size); + return 0; +} \ No newline at end of file diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer/gpucontext_fuzzer.h b/rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer/gpucontext_fuzzer.h new file mode 100644 index 0000000000..1c6fa12788 --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer/gpucontext_fuzzer.h @@ -0,0 +1,21 @@ +/* + * 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 TEST_FUZZTEST_GPUCONTEXT_FUZZER_H +#define TEST_FUZZTEST_GPUCONTEXT_FUZZER_H + +#define FUZZ_PROJECT_NAME "ndkgpucontext_fuzzer" + +#endif // TEST_FUZZTEST_GPUCONTEXT_FUZZER_H \ No newline at end of file diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer/project.xml b/rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndkgpucontext_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer/BUILD.gn b/rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer/BUILD.gn new file mode 100644 index 0000000000..a114eb0325 --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer/BUILD.gn @@ -0,0 +1,68 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import("//foundation/graphic/graphic_2d/graphic_config.gni") +module_output_path = "graphic_2d/graphic_2d" + +##############################fuzztest########################################## +ohos_fuzztest("NdkSurfaceFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "$graphic_2d_root/rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer" + + include_dirs = [ + "$graphic_2d_root/rosen/modules/2d_graphics/include", + "$graphic_2d_root/rosen/modules/2d_graphics/src", + "$graphic_2d_root/rosen/modules/2d_graphics/src/drawing/engine_adapter", + "$graphic_2d_root/rosen/test/2d_graphics/fuzztest", + "$graphic_2d_root/rosen/modules/render_service_base/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "get_object.h", + "surface_fuzzer.cpp", + ] + + deps = [ + "$graphic_2d_root/frameworks/opengl_wrapper:EGL", + "$graphic_2d_root/frameworks/opengl_wrapper:GLESv3", + "$graphic_2d_root/rosen/modules/2d_graphics/drawing_ndk:native_drawing_ndk", + ] + + external_deps = [ "openssl:libcrypto_shared" ] + + part_name = "graphic_2d" + subsystem_name = "graphic" +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + + deps += [ + # deps file + ":NdkSurfaceFuzzTest", + ] +} +############################################################################### diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer/corpus/init b/rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer/corpus/init new file mode 100644 index 0000000000..e7c3fecd8d --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# 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. + +FUZZ \ No newline at end of file diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer/project.xml b/rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer/surface_fuzzer.cpp b/rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer/surface_fuzzer.cpp new file mode 100644 index 0000000000..581f5534ca --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer/surface_fuzzer.cpp @@ -0,0 +1,104 @@ +/* + * 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 "surface_fuzzer.h" + +#include +#include +#include + +#include "get_object.h" +#include "EGL/egl.h" +#include "EGL/eglext.h" +#include "GLES3/gl32.h" + +#include "drawing_canvas.h" +#include "drawing_gpu_context.h" +#include "drawing_surface.h" + +namespace OHOS { +namespace Rosen { +namespace Drawing { +void SurfaceFuzzTest000(const uint8_t* data, size_t size) +{ + g_data = data; + g_size = size; + g_pos = 0; + + EGLDisplay eglDisplay = EGL_NO_DISPLAY; + EGLConfig eglConfig = EGL_NO_CONFIG_KHR; + EGLContext eglContext = EGL_NO_CONTEXT; + EGLSurface eglSurface = EGL_NO_SURFACE; + OH_Drawing_GpuContext* gpuContext = nullptr; + OH_Drawing_Surface* surface = nullptr; + OH_Drawing_Canvas* canvas = nullptr; + + eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); + + EGLint eglMajVers; + EGLint eglMinVers; + EGLBoolean ret = eglInitialize(eglDisplay, &eglMajVers, &eglMinVers); + + EGLint count; + EGLint configAttribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT, EGL_NONE }; + ret = eglChooseConfig(eglDisplay, configAttribs, &eglConfig, 1, &count); + + const EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; + eglContext = eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, contextAttribs); + + EGLint attribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE}; + eglSurface = eglCreatePbufferSurface(eglDisplay, eglConfig, attribs); + + ret = eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext); + + OH_Drawing_GpuContextOptions options {true}; + gpuContext = OH_Drawing_GpuContextCreateFromGL(options); + + const int32_t width = GetObject(); + const int32_t height = GetObject(); + OH_Drawing_Image_Info imageInfo = {width, height, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE}; + surface = OH_Drawing_SurfaceCreateFromGpuContext(gpuContext, GetObject(), imageInfo); + canvas = OH_Drawing_SurfaceGetCanvas(surface); + canvas = OH_Drawing_SurfaceGetCanvas(nullptr); + OH_Drawing_SurfaceDestroy(surface); + + surface = OH_Drawing_SurfaceCreateFromGpuContext(nullptr, GetObject(), imageInfo); + OH_Drawing_SurfaceDestroy(surface); + OH_Drawing_GpuContextDestroy(gpuContext); + + ret = eglDestroySurface(eglDisplay, eglSurface); + ret = eglDestroyContext(eglDisplay, eglContext); + ret = eglTerminate(eglDisplay); + + eglSurface = EGL_NO_SURFACE; + eglContext = EGL_NO_CONTEXT; + eglDisplay = EGL_NO_DISPLAY; + + return; +} + +} // namespace Drawing +} // namespace Rosen +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::Rosen::Drawing::SurfaceFuzzTest000(data, size); + return 0; +} \ No newline at end of file diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer/surface_fuzzer.h b/rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer/surface_fuzzer.h new file mode 100644 index 0000000000..57bb1be9b5 --- /dev/null +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndksurface_fuzzer/surface_fuzzer.h @@ -0,0 +1,21 @@ +/* + * 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 TEST_FUZZTEST_SURFACE_FUZZER_H +#define TEST_FUZZTEST_SURFACE_FUZZER_H + +#define FUZZ_PROJECT_NAME "ndksurface_fuzzer" + +#endif // TEST_FUZZTEST_SURFACE_FUZZER_H \ No newline at end of file diff --git a/rosen/test/2d_graphics/fuzztest/ndk/ndktextblob_fuzzer/ndktextblob_fuzzer.cpp b/rosen/test/2d_graphics/fuzztest/ndk/ndktextblob_fuzzer/ndktextblob_fuzzer.cpp index 8e0e940475..33c3f54f2d 100644 --- a/rosen/test/2d_graphics/fuzztest/ndk/ndktextblob_fuzzer/ndktextblob_fuzzer.cpp +++ b/rosen/test/2d_graphics/fuzztest/ndk/ndktextblob_fuzzer/ndktextblob_fuzzer.cpp @@ -30,6 +30,8 @@ namespace OHOS { namespace Rosen { namespace { constexpr size_t DATA_MIN_SIZE = 2; +constexpr size_t ENCODING_SIZE = 4; +constexpr size_t MAX_ARRAY_SIZE = 5000; } // namespace namespace Drawing { @@ -64,6 +66,66 @@ void NativeDrawingTextBlobTest001(const uint8_t* data, size_t size) OH_Drawing_FontDestroy(font); OH_Drawing_RectDestroy(rect); } + +void NativeDrawingTextBlobTest002(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < DATA_MIN_SIZE) { + return; + } + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + OH_Drawing_Font* font = OH_Drawing_FontCreate(); + uint32_t count = GetObject() % MAX_ARRAY_SIZE + 1; + char* str = new char[count]; + OH_Drawing_Point2D* point = new OH_Drawing_Point2D[count]; + for (size_t i = 0; i < count; i++) { + str[i] = GetObject(); + point[i].x = GetObject(); + point[i].y = GetObject(); + } + str[count - 1] = '\0'; + + OH_Drawing_TextBlobCreateFromText(nullptr, strlen(str), nullptr, TEXT_ENCODING_UTF8); + OH_Drawing_TextBlobCreateFromPosText(nullptr, strlen(str), nullptr, nullptr, TEXT_ENCODING_UTF8); + OH_Drawing_TextBlobCreateFromString(nullptr, nullptr, TEXT_ENCODING_UTF8); + OH_Drawing_TextBlobCreateFromString(str, font, static_cast(count + ENCODING_SIZE)); + OH_Drawing_TextBlobCreateFromPosText(str, strlen(str), point, + font, static_cast(count + ENCODING_SIZE)); + OH_Drawing_TextBlobCreateFromText(str, strlen(str), font, + static_cast(count + ENCODING_SIZE)); + OH_Drawing_TextBlob* textBlob1 = OH_Drawing_TextBlobCreateFromText(str, strlen(str), font, TEXT_ENCODING_UTF8); + OH_Drawing_TextBlob* textBlob2 = + OH_Drawing_TextBlobCreateFromPosText(str, strlen(str), point, font, TEXT_ENCODING_UTF8); + OH_Drawing_TextBlob* textBlob3 = OH_Drawing_TextBlobCreateFromString(str, font, TEXT_ENCODING_UTF8); + OH_Drawing_TextBlobBuilderAllocRunPos(nullptr, nullptr, count, nullptr); + + uint16_t glyphs[count]; + OH_Drawing_TextBlobBuilder *builder = OH_Drawing_TextBlobBuilderCreate(); + uint32_t glyphsCount = + OH_Drawing_FontTextToGlyphs(font, str, strlen(str), TEXT_ENCODING_UTF8, glyphs, count); + OH_Drawing_TextBlobBuilderAllocRunPos(nullptr, font, glyphsCount, nullptr); + OH_Drawing_TextBlobBuilderAllocRunPos(builder, nullptr, glyphsCount, nullptr); + OH_Drawing_TextBlobBuilderAllocRunPos(builder, font, glyphsCount, nullptr); + OH_Drawing_TextBlob *textBlob4 = OH_Drawing_TextBlobBuilderMake(builder); + + if (str != nullptr) { + delete [] str; + str = nullptr; + } + if (point != nullptr) { + delete [] point; + point = nullptr; + } + OH_Drawing_TextBlobDestroy(textBlob1); + OH_Drawing_TextBlobDestroy(textBlob2); + OH_Drawing_TextBlobDestroy(textBlob3); + OH_Drawing_TextBlobDestroy(textBlob4); + OH_Drawing_TextBlobBuilderDestroy(builder); + OH_Drawing_FontDestroy(font); +} } // namespace Drawing } // namespace Rosen } // namespace OHOS @@ -73,5 +135,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ OHOS::Rosen::Drawing::NativeDrawingTextBlobTest001(data, size); + OHOS::Rosen::Drawing::NativeDrawingTextBlobTest002(data, size); return 0; } From 1e798e368c9522858b8665cc199957ecd0047469 Mon Sep 17 00:00:00 2001 From: renhw001 Date: Tue, 25 Jun 2024 14:33:00 +0800 Subject: [PATCH 158/247] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B8=85=E9=99=A4?= =?UTF-8?q?=E7=BC=93=E5=AD=98NDK=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: renhw001 --- .../include/drawing_font_collection.h | 12 ++++++++++- .../src/drawing_font_collection.cpp | 20 ++++++++++++++++++- .../drawing_ndk/src/drawing_register_font.cpp | 14 +++++++++---- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/rosen/modules/2d_graphics/drawing_ndk/include/drawing_font_collection.h b/rosen/modules/2d_graphics/drawing_ndk/include/drawing_font_collection.h index 21aa71ef0a..b89bfc25d8 100644 --- a/rosen/modules/2d_graphics/drawing_ndk/include/drawing_font_collection.h +++ b/rosen/modules/2d_graphics/drawing_ndk/include/drawing_font_collection.h @@ -93,8 +93,18 @@ void OH_Drawing_DisableFontCollectionFallback(OH_Drawing_FontCollection*); * @version 1.0 */ void OH_Drawing_DisableFontCollectionSystemFont(OH_Drawing_FontCollection*); + +/** + * @brief Clear font caches. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontCollection Indicates the pointer to an OH_Drawing_FontCollection object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_ClearFontCaches(OH_Drawing_FontCollection*); #ifdef __cplusplus } #endif /** @} */ -#endif \ No newline at end of file +#endif diff --git a/rosen/modules/2d_graphics/drawing_ndk/src/drawing_font_collection.cpp b/rosen/modules/2d_graphics/drawing_ndk/src/drawing_font_collection.cpp index 835e84611b..02f84e6111 100644 --- a/rosen/modules/2d_graphics/drawing_ndk/src/drawing_font_collection.cpp +++ b/rosen/modules/2d_graphics/drawing_ndk/src/drawing_font_collection.cpp @@ -116,4 +116,22 @@ void OH_Drawing_DisableFontCollectionSystemFont(OH_Drawing_FontCollection* fontC ConvertToFontCollection(fontCollection)->DisableSystemFont(); #endif #endif -} \ No newline at end of file +} + +void OH_Drawing_ClearFontCaches(OH_Drawing_FontCollection* fontCollection) +{ + if (!fontCollection) { + return; + } + + if (FontCollectionMgr::GetInstance().Find(fontCollection)) { + ConvertToFontCollection(fontCollection)->ClearCaches(); + return; + } + + if (objectMgr->HasObject(fontCollection)) { + ConvertToFontCollection(fontCollection)->ClearCaches(); + return; + } + return; +} diff --git a/rosen/modules/2d_graphics/drawing_ndk/src/drawing_register_font.cpp b/rosen/modules/2d_graphics/drawing_ndk/src/drawing_register_font.cpp index eb34cc4033..4b7637812c 100644 --- a/rosen/modules/2d_graphics/drawing_ndk/src/drawing_register_font.cpp +++ b/rosen/modules/2d_graphics/drawing_ndk/src/drawing_register_font.cpp @@ -43,7 +43,7 @@ using namespace OHOS::Rosen; #define ERROR_NULL_FONT_BUFFER 6 #define ERROR_BUFFER_SIZE_ZERO 7 #define ERROR_NULL_FONT_COLLECTION 8 -#define ERROR_REGISTER_FAILED 9 +#define ERROR_FILE_CORRUPTION 9 #ifdef BUILD_NON_SDK_VER static bool StdFilesystemExists(const std::string &p, std::error_code &ec) @@ -72,9 +72,15 @@ static uint32_t LoadFromFontCollection(OH_Drawing_FontCollection* fontCollection } auto fc = ConvertToOriginalText(fontCollection); #ifndef USE_GRAPHIC_TEXT_GINE - fc->LoadFontFromList(data, dataLength, familyName); + auto face = fc->LoadFontFromList(data, dataLength, familyName); + if (face == nullptr) { + return ERROR_FILE_CORRUPTION; + } #else - fc->LoadFont(familyName, data, dataLength); + auto face = fc->LoadFont(familyName, data, dataLength); + if (face == nullptr) { + return ERROR_FILE_CORRUPTION; + } #endif return 0; } @@ -150,4 +156,4 @@ uint32_t OH_Drawing_RegisterFontBuffer(OH_Drawing_FontCollection* fontCollection const std::string familyName = fontFamily; return LoadFromFontCollection(fontCollection, familyName, fontBuffer, length); -} \ No newline at end of file +} From 16a478164e86a7ee8c7183d28f8f582c9734eeb1 Mon Sep 17 00:00:00 2001 From: chengwenfeng Date: Mon, 1 Jul 2024 16:29:27 +0000 Subject: [PATCH 159/247] fix: Add Animation Power Solution Signed-off-by: chengwenfeng --- rosen/modules/hyper_graphic_manager/BUILD.gn | 1 + .../core/config/xml_parser.cpp | 2 + .../hgm_energy_consumption_policy.cpp | 130 ++++++++++ .../hgm_energy_consumption_policy.h | 53 ++++ .../hgm_frame_rate_manager.cpp | 15 ++ .../hgm_task_handle_thread.cpp | 14 ++ .../hgm_task_handle_thread.h | 2 + .../core/utils/hgm_command.h | 2 + .../core/pipeline/rs_main_thread.cpp | 3 + rosen/modules/render_service_base/BUILD.gn | 2 + .../include/common/rs_common_hook.h | 32 +++ .../src/command/rs_animation_command.cpp | 3 + .../src/common/rs_common_hook.cpp | 36 +++ .../test/unittest/animation/BUILD.gn | 1 + .../test/unittest/render/BUILD.gn | 1 + .../native_display_soloist_test/BUILD.gn | 1 + .../hyper_graphic_manager/unittest/BUILD.gn | 2 + .../hgm_energy_consumption_policy_test.cpp | 232 ++++++++++++++++++ .../unittest/common/BUILD.gn | 2 + .../unittest/common/rs_common_hook_test.cpp | 72 ++++++ .../unittest/luminance/BUILD.gn | 1 + .../unittest/memory/BUILD.gn | 1 + .../unittest/modifier/BUILD.gn | 1 + .../unittest/offscreen_render/BUILD.gn | 1 + .../unittest/params/BUILD.gn | 1 + .../unittest/property/BUILD.gn | 1 + .../unittest/render/BUILD.gn | 1 + .../unittest/transaction/BUILD.gn | 1 + 28 files changed, 614 insertions(+) create mode 100644 rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_energy_consumption_policy.cpp create mode 100644 rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_energy_consumption_policy.h create mode 100644 rosen/modules/render_service_base/include/common/rs_common_hook.h create mode 100644 rosen/modules/render_service_base/src/common/rs_common_hook.cpp create mode 100644 rosen/test/hyper_graphic_manager/unittest/hgm_energy_consumption_policy_test.cpp create mode 100644 rosen/test/render_service/render_service_base/unittest/common/rs_common_hook_test.cpp diff --git a/rosen/modules/hyper_graphic_manager/BUILD.gn b/rosen/modules/hyper_graphic_manager/BUILD.gn index 5d8097fcb1..cc77e73bd1 100644 --- a/rosen/modules/hyper_graphic_manager/BUILD.gn +++ b/rosen/modules/hyper_graphic_manager/BUILD.gn @@ -56,6 +56,7 @@ ohos_shared_library("libhyper_graphic_manager") { sources = [ "core/config/hgm_config_callback_manager.cpp", "core/config/xml_parser.cpp", + "core/frame_rate_manager/hgm_energy_consumption_policy.cpp", "core/frame_rate_manager/hgm_frame_rate_manager.cpp", "core/frame_rate_manager/hgm_idle_detector.cpp", "core/frame_rate_manager/hgm_multi_app_strategy.cpp", diff --git a/rosen/modules/hyper_graphic_manager/core/config/xml_parser.cpp b/rosen/modules/hyper_graphic_manager/core/config/xml_parser.cpp index a6e3c162dd..c6681d8868 100644 --- a/rosen/modules/hyper_graphic_manager/core/config/xml_parser.cpp +++ b/rosen/modules/hyper_graphic_manager/core/config/xml_parser.cpp @@ -283,6 +283,8 @@ int32_t XMLParser::ParseSubScreenConfig(xmlNode &node, PolicyConfigData::ScreenS setResult = ParseAppTypes(*thresholdNode, screenSetting.appTypes); } else if (name == "additional_touch_rate_config") { setResult = ParseSimplex(*thresholdNode, screenSetting.appBufferList); + } else if (name == "rs_animation_power_config") { + setResult = ParseSimplex(*thresholdNode, screenSetting.animationPowerConfig); } else { setResult = EXEC_SUCCESS; } diff --git a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_energy_consumption_policy.cpp b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_energy_consumption_policy.cpp new file mode 100644 index 0000000000..6a7aca2e60 --- /dev/null +++ b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_energy_consumption_policy.cpp @@ -0,0 +1,130 @@ +/* + * 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 "hgm_energy_consumption_policy.h" + +#include + +#include "hgm_core.h" +#include "hgm_log.h" +#include "xml_parser.h" + +#include "common/rs_common_def.h" +#include "common/rs_common_hook.h" + +namespace OHOS::Rosen { +static const std::string IS_ANIMATION_ENERGY_ASSURANCE_ENABLE = "animation_energy_assurance_enable"; +static const std::string ANIMATION_IDLE_FPS = "animation_idle_fps"; +static const std::string ANIMATION_IDLE_DURATION = "animation_idle_duration"; +constexpr int DEFAULT_ANIMATION_IDLE_FPS = 60; +constexpr int DEFAULT_ANIMATION_IDLE_DURATION = 2000; + +HgmEnrtgyConsumptionPolicy::HgmEnrtgyConsumptionPolicy() +{ + RsCommonHook::Instance().RegisterStartNewAnimationListener( + std::bind(&HgmEnrtgyConsumptionPolicy::StartNewAnimation, this)); +} + +HgmEnrtgyConsumptionPolicy& HgmEnrtgyConsumptionPolicy::Instance() +{ + static HgmEnrtgyConsumptionPolicy hlpp; + return hlpp; +} + +void HgmEnrtgyConsumptionPolicy::ConverStrToInt(int& targetNum, std::string sourceStr, int defaultValue) +{ + if (!XMLParser::IsNumber(sourceStr)) { + targetNum = defaultValue; + return; + } + targetNum = std::stoi(sourceStr.c_str()); +} + +void HgmEnrtgyConsumptionPolicy::SetEnergyConsumptionConfig( + std::unordered_map animationPowerConfig) +{ + std::lock_guard lock(mutex_); + if (animationPowerConfig.count(IS_ANIMATION_ENERGY_ASSURANCE_ENABLE) == 0) { + isAnimationEnergyAssuranceEnable_ = false; + } else { + isAnimationEnergyAssuranceEnable_ = + animationPowerConfig[IS_ANIMATION_ENERGY_ASSURANCE_ENABLE] == "true" ? true : false; + } + if (!isAnimationEnergyAssuranceEnable_) { + HGM_LOGD("HgmEnrtgyConsumptionPolicy::SetEnergyConsumptionConfig isAnimationLtpoPowerEnable is false"); + return; + } + + if (animationPowerConfig.count(ANIMATION_IDLE_FPS) == 0) { + animationIdleFps_ = DEFAULT_ANIMATION_IDLE_FPS; + } else { + ConverStrToInt(animationIdleFps_, animationPowerConfig[ANIMATION_IDLE_FPS], DEFAULT_ANIMATION_IDLE_FPS); + } + + if (animationPowerConfig.count(ANIMATION_IDLE_DURATION) == 0) { + animationIdleDuration_ = DEFAULT_ANIMATION_IDLE_DURATION; + } else { + ConverStrToInt( + animationIdleDuration_, animationPowerConfig[ANIMATION_IDLE_DURATION], DEFAULT_ANIMATION_IDLE_DURATION); + } + HGM_LOGD("HgmEnrtgyConsumptionPolicy::SetEnergyConsumptionConfig update config success"); +} + +void HgmEnrtgyConsumptionPolicy::SetEnergyConsumptionAssuranceMode(bool isEnergyConsumptionAssuranceMode) +{ + std::lock_guard lock(mutex_); + if (!isAnimationEnergyAssuranceEnable_ || isEnergyConsumptionAssuranceMode_ == isEnergyConsumptionAssuranceMode) { + return; + } + isEnergyConsumptionAssuranceMode_ = isEnergyConsumptionAssuranceMode; + firstAnimationTimestamp_ = HgmCore::Instance().GetCurrentTimestamp() / NS_PER_MS; + lastAnimationTimestamp_ = firstAnimationTimestamp_; +} + +void HgmEnrtgyConsumptionPolicy::StatisticAnimationTime(uint64_t timestamp) +{ + std::lock_guard lock(mutex_); + if (isAnimationEnergyAssuranceEnable_ || !isEnergyConsumptionAssuranceMode_) { + return; + } + lastAnimationTimestamp_ = timestamp; +} + +void HgmEnrtgyConsumptionPolicy::StartNewAnimation() +{ + std::lock_guard lock(mutex_); + if (isAnimationEnergyAssuranceEnable_ || !isEnergyConsumptionAssuranceMode_) { + return; + } + firstAnimationTimestamp_ = HgmCore::Instance().GetCurrentTimestamp() / NS_PER_MS; + lastAnimationTimestamp_ = firstAnimationTimestamp_; +} + +void HgmEnrtgyConsumptionPolicy::GetAnimationIdleFps(FrameRateRange& rsRange) +{ + std::lock_guard lock(mutex_); + if (isAnimationEnergyAssuranceEnable_ || !isEnergyConsumptionAssuranceMode_) { + return; + } + if (lastAnimationTimestamp_ > firstAnimationTimestamp_ && + (lastAnimationTimestamp_ - firstAnimationTimestamp_) < static_cast(animationIdleDuration_)) { + return; + } + rsRange.max_ = std::min(rsRange.max_, animationIdleFps_); + rsRange.min_ = std::min(rsRange.min_, animationIdleFps_); + rsRange.preferred_ = std::min(rsRange.preferred_, animationIdleFps_); +} + +} // namespace OHOS::Rosen \ No newline at end of file diff --git a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_energy_consumption_policy.h b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_energy_consumption_policy.h new file mode 100644 index 0000000000..8819c7a1aa --- /dev/null +++ b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_energy_consumption_policy.h @@ -0,0 +1,53 @@ +/* + * 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 HGM_ENERGY_CONSUMPTION_POLICY_H +#define HGM_ENERGY_CONSUMPTION_POLICY_H +#include +#include +#include + +#include "animation/rs_frame_rate_range.h" +namespace OHOS::Rosen { +class HgmEnrtgyConsumptionPolicy { +public: + static HgmEnrtgyConsumptionPolicy& Instance(); + void SetEnergyConsumptionConfig(std::unordered_map animationPowerConfig); + void SetEnergyConsumptionAssuranceMode(bool isEnergyConsumptionAssuranceMode); + void StatisticAnimationTime(uint64_t timestamp); + void StartNewAnimation(); + void GetAnimationIdleFps(FrameRateRange& rsRange); + +private: + std::recursive_mutex mutex_; + bool isAnimationEnergyAssuranceEnable_ = false; + bool isEnergyConsumptionAssuranceMode_ = false; + uint64_t firstAnimationTimestamp_ = 0; + uint64_t lastAnimationTimestamp_ = 0; + // Unit: ms + int animationIdleDuration_ = 2000; + int animationIdleFps_ = 60; + + HgmEnrtgyConsumptionPolicy(); + ~HgmEnrtgyConsumptionPolicy() = default; + HgmEnrtgyConsumptionPolicy(const HgmEnrtgyConsumptionPolicy&) = delete; + HgmEnrtgyConsumptionPolicy(const HgmEnrtgyConsumptionPolicy&&) = delete; + HgmEnrtgyConsumptionPolicy& operator=(const HgmEnrtgyConsumptionPolicy&) = delete; + HgmEnrtgyConsumptionPolicy& operator=(const HgmEnrtgyConsumptionPolicy&&) = delete; + void ConverStrToInt(int& targetNum, std::string sourceStr, int defaultValue); +}; +} // namespace OHOS::Rosen + +#endif \ No newline at end of file diff --git a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.cpp b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.cpp index 612138e987..0a3762b8e1 100644 --- a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.cpp +++ b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.cpp @@ -23,6 +23,7 @@ #include "pipeline/rs_uni_render_judgement.h" #include "hgm_config_callback_manager.h" #include "hgm_core.h" +#include "hgm_energy_consumption_policy.h" #include "hgm_log.h" #include "parameters.h" #include "rs_trace.h" @@ -45,6 +46,8 @@ namespace { constexpr uint32_t FIRST_FRAME_TIME_OUT = 50000000; // 50ms constexpr uint32_t SCENE_BEFORE_XML = 1; constexpr uint32_t SCENE_AFTER_TOUCH = 3; + constexpr uint64_t ENERGY_ASSURANCE_TASK_DELAY_TIME = 1000; //1s + const static std::string ENERGY_ASSURANCE_TASK_ID = "ENERGY_ASSURANCE_TASK_ID"; // CAUTION: with priority const std::string VOTER_NAME[] = { "VOTER_THERMAL", @@ -69,6 +72,8 @@ void HgmFrameRateManager::Init(sptr rsController, auto& hgmCore = HgmCore::Instance(); curRefreshRateMode_ = hgmCore.GetCurrentRefreshRateMode(); multiAppStrategy_.UpdateXmlConfigCache(); + HgmEnrtgyConsumptionPolicy::Instance().SetEnergyConsumptionConfig( + multiAppStrategy_.GetScreenSetting().animationPowerConfig); // hgm warning: get non active screenId in non-folding devices(from sceneboard) auto screenList = hgmCore.GetScreenIds(); @@ -85,6 +90,8 @@ void HgmFrameRateManager::Init(sptr rsController, curRefreshRateMode_ = configData->SettingModeId2XmlModeId(curRefreshRateMode_); } multiAppStrategy_.UpdateXmlConfigCache(); + HgmEnrtgyConsumptionPolicy::Instance().SetEnergyConsumptionConfig( + multiAppStrategy_.GetScreenSetting().animationPowerConfig); multiAppStrategy_.CalcVote(); HandleIdleEvent(ADD_VOTE); } @@ -744,6 +751,8 @@ void HgmFrameRateManager::HandleTouchEvent(pid_t pid, int32_t touchStatus, int32 if (touchStatus == TOUCH_DOWN || touchStatus == TOUCH_PULL_DOWN) { HGM_LOGI("[touch manager] down"); PolicyConfigData::StrategyConfig strategyRes; + HgmTaskHandleThread::Instance().RemoveEvent(ENERGY_ASSURANCE_TASK_ID); + HgmEnrtgyConsumptionPolicy::Instance().SetEnergyConsumptionAssuranceMode(false); if (multiAppStrategy_.GetFocusAppStrategyConfig(strategyRes) == EXEC_SUCCESS && strategyRes.dynamicMode != DynamicModeType::TOUCH_DISENABLED) { touchManager_.HandleTouchEvent(TouchEvent::DOWN_EVENT, ""); @@ -759,6 +768,8 @@ void HgmFrameRateManager::HandleTouchEvent(pid_t pid, int32_t touchStatus, int32 } if (touchCnt == LAST_TOUCH_CNT) { HGM_LOGI("[touch manager] up"); + auto task = []() { HgmEnrtgyConsumptionPolicy::Instance().SetEnergyConsumptionAssuranceMode(true); }; + HgmTaskHandleThread::Instance().PostEvent(ENERGY_ASSURANCE_TASK_ID, task, ENERGY_ASSURANCE_TASK_DELAY_TIME); touchManager_.HandleTouchEvent(TouchEvent::UP_EVENT, ""); } } else { @@ -786,6 +797,8 @@ void HgmFrameRateManager::HandleRefreshRateMode(int32_t refreshRateMode) curRefreshRateMode_ = refreshRateMode; DeliverRefreshRateVote({"VOTER_LTPO"}, REMOVE_VOTE); multiAppStrategy_.UpdateXmlConfigCache(); + HgmEnrtgyConsumptionPolicy::Instance().SetEnergyConsumptionConfig( + multiAppStrategy_.GetScreenSetting().animationPowerConfig); multiAppStrategy_.CalcVote(); HgmCore::Instance().SetLtpoConfig(); schedulePreferredFpsChange_ = true; @@ -829,6 +842,8 @@ void HgmFrameRateManager::HandleScreenPowerStatus(ScreenId id, ScreenPowerStatus curScreenStrategyId_ = "LTPO-DEFAULT"; } multiAppStrategy_.UpdateXmlConfigCache(); + HgmEnrtgyConsumptionPolicy::Instance().SetEnergyConsumptionConfig( + multiAppStrategy_.GetScreenSetting().animationPowerConfig); } multiAppStrategy_.CalcVote(); diff --git a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_task_handle_thread.cpp b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_task_handle_thread.cpp index 7ff6c9a672..50c493d635 100644 --- a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_task_handle_thread.cpp +++ b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_task_handle_thread.cpp @@ -41,4 +41,18 @@ bool HgmTaskHandleThread::PostSyncTask(const std::function& task) } return false; } + +void HgmTaskHandleThread::PostEvent(std::string eventId, const std::function& task, int64_t delayTime) +{ + if (handler_) { + handler_->PostTask(task, eventId, delayTime); + } +} + +void HgmTaskHandleThread::RemoveEvent(std::string eventId) +{ + if (handler_) { + handler_->RemoveTask(eventId); + } +} } diff --git a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_task_handle_thread.h b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_task_handle_thread.h index c7b14afed7..5141256b27 100644 --- a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_task_handle_thread.h +++ b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_task_handle_thread.h @@ -25,6 +25,8 @@ public: const std::shared_ptr& GetRunner() const { return runner_; } void PostTask(const std::function& task, int64_t delayTime = 0); bool PostSyncTask(const std::function& task); + void PostEvent(std::string eventId, const std::function& task, int64_t delayTime = 0); + void RemoveEvent(std::string eventId); private: HgmTaskHandleThread(); diff --git a/rosen/modules/hyper_graphic_manager/core/utils/hgm_command.h b/rosen/modules/hyper_graphic_manager/core/utils/hgm_command.h index e5e700c941..7600a92843 100644 --- a/rosen/modules/hyper_graphic_manager/core/utils/hgm_command.h +++ b/rosen/modules/hyper_graphic_manager/core/utils/hgm_command.h @@ -136,6 +136,8 @@ public: std::unordered_map gameSceneList; DynamicSettingMap animationDynamicSettings; DynamicSettingMap aceSceneDynamicSettings; + // + std::unordered_map animationPowerConfig; }; // <"-1", ScreenSetting> using ScreenConfig = std::unordered_map; diff --git a/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp b/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp index d8b1436a20..1b1672cd14 100644 --- a/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp @@ -29,6 +29,7 @@ #include "benchmarks/file_utils.h" #include "delegate/rs_functional_delegate.h" #include "hgm_core.h" +#include "hgm_energy_consumption_policy.h" #include "hgm_frame_rate_manager.h" #include "include/core/SkGraphics.h" #include "include/gpu/GrDirectContext.h" @@ -1696,6 +1697,7 @@ void RSMainThread::ProcessHgmFrameRate(uint64_t timestamp) RS_TRACE_FUNC(); if (rsFrameRateLinker_ != nullptr) { rsCurrRange_.type_ = RS_ANIMATION_FRAME_RATE_TYPE; + HgmEnrtgyConsumptionPolicy::Instance().GetAnimationIdleFps(rsCurrRange_); rsFrameRateLinker_->SetExpectedRange(rsCurrRange_); RS_TRACE_NAME_FMT("rsCurrRange = (%d, %d, %d)", rsCurrRange_.min_, rsCurrRange_.max_, rsCurrRange_.preferred_); } @@ -2740,6 +2742,7 @@ void RSMainThread::Animate(uint64_t timestamp) RS_LOGD("RSMainThread::Animate end, animating nodes remains, has window animation: %{public}d", curWinAnim); if (needRequestNextVsync) { + HgmEnrtgyConsumptionPolicy::Instance().StatisticAnimationTime(timestamp / NS_PER_MS); if (!rsVSyncDistributor_->IsDVsyncOn()) { RequestNextVSync("animate", timestamp_); } else { diff --git a/rosen/modules/render_service_base/BUILD.gn b/rosen/modules/render_service_base/BUILD.gn index d7bfee0990..7325d68ae2 100644 --- a/rosen/modules/render_service_base/BUILD.gn +++ b/rosen/modules/render_service_base/BUILD.gn @@ -589,6 +589,8 @@ ohos_shared_library("librender_service_base") { } } + sources = [ "src/common/rs_common_hook.cpp" ] + all_dependent_configs = [ ":render_service_base_all_deps_config" ] public_configs = [ ":render_service_base_all_deps_config" ] diff --git a/rosen/modules/render_service_base/include/common/rs_common_hook.h b/rosen/modules/render_service_base/include/common/rs_common_hook.h new file mode 100644 index 0000000000..8cd1685f1c --- /dev/null +++ b/rosen/modules/render_service_base/include/common/rs_common_hook.h @@ -0,0 +1,32 @@ +/* + * 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 RS_COMMON_HOOK_H +#define RS_COMMON_HOOK_H + +#include + +namespace OHOS::Rosen { +class RsCommonHook { +public: + static RsCommonHook& Instance(); + void RegisterStartNewAnimationListener(std::function listener); + void OnStartNewAnimation(); + +private: + std::function startNewAniamtionFunc_ = nullptr; +}; +} // namespace OHOS::Rosen +#endif \ No newline at end of file diff --git a/rosen/modules/render_service_base/src/command/rs_animation_command.cpp b/rosen/modules/render_service_base/src/command/rs_animation_command.cpp index d1a8476a8a..05699ec497 100644 --- a/rosen/modules/render_service_base/src/command/rs_animation_command.cpp +++ b/rosen/modules/render_service_base/src/command/rs_animation_command.cpp @@ -21,6 +21,7 @@ #include "animation/rs_render_interactive_implict_animator.h" #include "animation/rs_render_particle.h" #include "common/rs_common_def.h" +#include "common/rs_common_hook.h" #include "modifier/rs_render_modifier.h" #include "modifier/rs_render_property.h" #include "platform/common/rs_log.h" @@ -56,6 +57,7 @@ void AnimationCommandHelper::CreateAnimation( if (node == nullptr) { return; } + RsCommonHook::Instance().OnStartNewAnimation(); node->GetAnimationManager().AddAnimation(animation); auto modifier = node->GetModifier(animation->GetPropertyId()); if (modifier != nullptr) { @@ -79,6 +81,7 @@ void AnimationCommandHelper::CreateParticleAnimation( if (node == nullptr) { return; } + RsCommonHook::Instance().OnStartNewAnimation(); auto propertyId = animation->GetPropertyId(); node->GetAnimationManager().AddAnimation(animation); auto property = std::make_shared>( diff --git a/rosen/modules/render_service_base/src/common/rs_common_hook.cpp b/rosen/modules/render_service_base/src/common/rs_common_hook.cpp new file mode 100644 index 0000000000..2536c04517 --- /dev/null +++ b/rosen/modules/render_service_base/src/common/rs_common_hook.cpp @@ -0,0 +1,36 @@ +/* + * 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 "common/rs_common_hook.h" + +namespace OHOS::Rosen { +RsCommonHook& RsCommonHook::Instance() +{ + static RsCommonHook rch; + return rch; +} + +void RsCommonHook::RegisterStartNewAnimationListener(std::function listener) +{ + startNewAniamtionFunc_ = listener; +} + +void RsCommonHook::OnStartNewAnimation() +{ + if (startNewAniamtionFunc_) { + startNewAniamtionFunc_(); + } +} +} // namespace OHOS::Rosen \ No newline at end of file diff --git a/rosen/modules/render_service_base/test/unittest/animation/BUILD.gn b/rosen/modules/render_service_base/test/unittest/animation/BUILD.gn index d9624f766d..7b180b7617 100644 --- a/rosen/modules/render_service_base/test/unittest/animation/BUILD.gn +++ b/rosen/modules/render_service_base/test/unittest/animation/BUILD.gn @@ -47,6 +47,7 @@ ohos_unittest("RSRenderAnimationTest") { configs = [ ":rs_render_animation_test_config" ] deps = [ + "../../../../render_service_base:librender_service_base", "../../../../render_service_base:render_service_base_src", "//foundation/window/window_manager/wm:libwm", "//third_party/googletest:gtest_main", diff --git a/rosen/modules/render_service_base/test/unittest/render/BUILD.gn b/rosen/modules/render_service_base/test/unittest/render/BUILD.gn index 1db968c545..078392bf4b 100644 --- a/rosen/modules/render_service_base/test/unittest/render/BUILD.gn +++ b/rosen/modules/render_service_base/test/unittest/render/BUILD.gn @@ -25,6 +25,7 @@ ohos_unittest("RSRenderTest") { configs = [ ":rs_render_test_config" ] deps = [ + "$graphic_2d_root/rosen/modules/render_service_base:librender_service_base", "$graphic_2d_root/rosen/modules/render_service_base:render_service_base_src", "$third_party_path/googletest:gtest_main", "$window_base_path/wm:libwm", diff --git a/rosen/test/hyper_graphic_manager/native_display_soloist_test/BUILD.gn b/rosen/test/hyper_graphic_manager/native_display_soloist_test/BUILD.gn index ae6b39e698..0871b9c81e 100644 --- a/rosen/test/hyper_graphic_manager/native_display_soloist_test/BUILD.gn +++ b/rosen/test/hyper_graphic_manager/native_display_soloist_test/BUILD.gn @@ -32,6 +32,7 @@ ohos_unittest("native_display_soloist_test") { deps = [ "$graphic_2d_root/rosen/modules/hyper_graphic_manager/core/native_display_soloist:libnative_display_soloist", + "$graphic_2d_root/rosen/modules/render_service_base:librender_service_base", "$graphic_2d_root/rosen/modules/render_service_base:render_service_base_src", "$graphic_2d_root/utils/test_header:test_header", ] diff --git a/rosen/test/hyper_graphic_manager/unittest/BUILD.gn b/rosen/test/hyper_graphic_manager/unittest/BUILD.gn index 68c7582139..98e727113b 100644 --- a/rosen/test/hyper_graphic_manager/unittest/BUILD.gn +++ b/rosen/test/hyper_graphic_manager/unittest/BUILD.gn @@ -31,6 +31,7 @@ ohos_unittest("hyper_graphic_manager_test") { } sources = [ + "hgm_energy_consumption_policy_test.cpp", "hgm_frame_rate_manager_test.cpp", "hgm_idle_detector_test.cpp", "hgm_lru_cache_test.cpp", @@ -52,6 +53,7 @@ ohos_unittest("hyper_graphic_manager_test") { deps = [ "$graphic_2d_root/rosen/modules/hyper_graphic_manager:libhyper_graphic_manager", + "$graphic_2d_root/rosen/modules/render_service_base:librender_service_base", "$graphic_2d_root/rosen/modules/render_service_base:render_service_base_src", "$graphic_2d_root/utils/test_header:test_header", ] diff --git a/rosen/test/hyper_graphic_manager/unittest/hgm_energy_consumption_policy_test.cpp b/rosen/test/hyper_graphic_manager/unittest/hgm_energy_consumption_policy_test.cpp new file mode 100644 index 0000000000..31c19cf97f --- /dev/null +++ b/rosen/test/hyper_graphic_manager/unittest/hgm_energy_consumption_policy_test.cpp @@ -0,0 +1,232 @@ +/* + * 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 + +#include "hgm_energy_consumption_policy.h" + +#include "common/rs_common_hook.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Rosen { +constexpr int DEFAULT_MAX_FPS = 120; +constexpr int IDLE_FPS = 60; + +class HgmEnrtgyConsumptionPolicyTest : public testing::Test { +public: + static void SetUpTestCase() {} + static void TearDownTestCase() {} + void SetUp() {} + void TearDown() {} + void SetConfigEnable(std::string isEnable); + void SetIdleStateEnable(bool isIdle); +}; + +void HgmEnrtgyConsumptionPolicyTest::SetConfigEnable(std::string isEnable) +{ + std::unordered_map animationPowerConfig = { { "animation_ltpo_power_enable", isEnable }, + { "animation_idle_fps", "60" }, { "animation_idle_duration", "2000" } }; + HgmEnrtgyConsumptionPolicy::Instance().SetEnergyConsumptionConfig(animationPowerConfig); +} + +void HgmEnrtgyConsumptionPolicyTest::SetIdleStateEnable(bool isIdle) +{ + HgmEnrtgyConsumptionPolicy::Instance().SetEnergyConsumptionAssuranceMode(isIdle); +} + +/** + * @tc.name: SetEnergyConsumptionConfigTest1 + * @tc.desc: test results of SetEnergyConsumptionConfigTest1 + * @tc.type: FUNC + * @tc.require: issuesIA96Q3 + */ +HWTEST_F(HgmEnrtgyConsumptionPolicyTest, SetEnergyConsumptionConfigTest1, TestSize.Level1) +{ + SetConfigEnable("true"); +} + +/** + * @tc.name: SetEnergyConsumptionConfigTest2 + * @tc.desc: test results of SetEnergyConsumptionConfigTest2 + * @tc.type: FUNC + * @tc.require: issuesIA96Q3 + */ +HWTEST_F(HgmEnrtgyConsumptionPolicyTest, SetEnergyConsumptionConfigTest2, TestSize.Level1) +{ + SetConfigEnable("false"); +} + +/** + * @tc.name: SetEnergyConsumptionAssuranceModeTest1 + * @tc.desc: test results of SetEnergyConsumptionAssuranceModeTest1 + * @tc.type: FUNC + * @tc.require: issuesIA96Q3 + */ +HWTEST_F(HgmEnrtgyConsumptionPolicyTest, SetEnergyConsumptionAssuranceModeTest1, TestSize.Level1) +{ + SetConfigEnable("true"); + SetIdleStateEnable(true); + SetIdleStateEnable(false); +} + +/** + * @tc.name: SetEnergyConsumptionAssuranceModeTest2 + * @tc.desc: test results of SetEnergyConsumptionAssuranceModeTest2 + * @tc.type: FUNC + * @tc.require: issuesIA96Q3 + */ +HWTEST_F(HgmEnrtgyConsumptionPolicyTest, SetEnergyConsumptionAssuranceModeTest2, TestSize.Level1) +{ + SetConfigEnable("true"); + SetIdleStateEnable(true); + SetIdleStateEnable(true); +} + +/** + * @tc.name: SetEnergyConsumptionAssuranceModeTest3 + * @tc.desc: test results of SetEnergyConsumptionAssuranceModeTest3 + * @tc.type: FUNC + * @tc.require: issuesIA96Q3 + */ +HWTEST_F(HgmEnrtgyConsumptionPolicyTest, SetEnergyConsumptionAssuranceModeTest3, TestSize.Level1) +{ + SetConfigEnable("false"); + SetIdleStateEnable(false); + SetIdleStateEnable(true); +} + +/** + * @tc.name: StatisticAnimationTimeTest1 + * @tc.desc: test results of StatisticAnimationTimeTest1 + * @tc.type: FUNC + * @tc.require: issuesIA96Q3 + */ +HWTEST_F(HgmEnrtgyConsumptionPolicyTest, StatisticAnimationTimeTest1, TestSize.Level1) +{ + SetConfigEnable("false"); + SetIdleStateEnable(false); + uint64_t currentTime = 1719544264071; + HgmEnrtgyConsumptionPolicy::Instance().StatisticAnimationTime(currentTime); +} + +/** + * @tc.name: StatisticAnimationTimeTest2 + * @tc.desc: test results of StatisticAnimationTimeTest2 + * @tc.type: FUNC + * @tc.require: issuesIA96Q3 + */ +HWTEST_F(HgmEnrtgyConsumptionPolicyTest, StatisticAnimationTimeTest2, TestSize.Level1) +{ + SetConfigEnable("true"); + SetIdleStateEnable(false); + uint64_t currentTime = 1719544264071; + HgmEnrtgyConsumptionPolicy::Instance().StatisticAnimationTime(currentTime); +} + +/** + * @tc.name: StatisticAnimationTimeTest3 + * @tc.desc: test results of StatisticAnimationTimeTest3 + * @tc.type: FUNC + * @tc.require: issuesIA96Q3 + */ +HWTEST_F(HgmEnrtgyConsumptionPolicyTest, StatisticAnimationTimeTest3, TestSize.Level1) +{ + SetConfigEnable("true"); + SetIdleStateEnable(true); + uint64_t currentTime = 1719544264071; + HgmEnrtgyConsumptionPolicy::Instance().StatisticAnimationTime(currentTime); +} + +/** + * @tc.name: StartNewAnimationTest1 + * @tc.desc: test results of StartNewAnimationTest1 + * @tc.type: FUNC + * @tc.require: issuesIA96Q3 + */ +HWTEST_F(HgmEnrtgyConsumptionPolicyTest, StartNewAnimationTest1, TestSize.Level1) +{ + SetConfigEnable("true"); + HgmEnrtgyConsumptionPolicy::Instance().StartNewAnimation(); +} + +/** + * @tc.name: StartNewAnimationTest2 + * @tc.desc: test results of StartNewAnimationTest2 + * @tc.type: FUNC + * @tc.require: issuesIA96Q3 + */ +HWTEST_F(HgmEnrtgyConsumptionPolicyTest, StartNewAnimationTest2, TestSize.Level1) +{ + SetConfigEnable("true"); + RsCommonHook::Instance().OnStartNewAnimation(); +} + +/** + * @tc.name: GetAnimationIdleFpsTest1 + * @tc.desc: test results of GetAnimationIdleFpsTest1 + * @tc.type: FUNC + * @tc.require: issuesIA96Q3 + */ +HWTEST_F(HgmEnrtgyConsumptionPolicyTest, GetAnimationIdleFpsTest1, TestSize.Level1) +{ + SetConfigEnable("false"); + FrameRateRange rsRange = { DEFAULT_MAX_FPS, DEFAULT_MAX_FPS, DEFAULT_MAX_FPS }; + HgmEnrtgyConsumptionPolicy::Instance().GetAnimationIdleFps(rsRange); + ASSERT_EQ(rsRange.max_, DEFAULT_MAX_FPS); + ASSERT_EQ(rsRange.min_, DEFAULT_MAX_FPS); + ASSERT_EQ(rsRange.preferred_, DEFAULT_MAX_FPS); +} + +/** + * @tc.name: GetAnimationIdleFpsTest2 + * @tc.desc: test results of GetAnimationIdleFpsTest2 + * @tc.type: FUNC + * @tc.require: issuesIA96Q3 + */ +HWTEST_F(HgmEnrtgyConsumptionPolicyTest, GetAnimationIdleFpsTest2, TestSize.Level1) +{ + SetConfigEnable("true"); + HgmEnrtgyConsumptionPolicy::Instance().lastAnimationTimestamp_ = 1719544264071; + HgmEnrtgyConsumptionPolicy::Instance().firstAnimationTimestamp_ = 1719544263071; + FrameRateRange rsRange = { DEFAULT_MAX_FPS, DEFAULT_MAX_FPS, DEFAULT_MAX_FPS }; + HgmEnrtgyConsumptionPolicy::Instance().GetAnimationIdleFps(rsRange); + ASSERT_EQ(rsRange.max_, DEFAULT_MAX_FPS); + ASSERT_EQ(rsRange.min_, DEFAULT_MAX_FPS); + ASSERT_EQ(rsRange.preferred_, DEFAULT_MAX_FPS); +} + +/** + * @tc.name: GetAnimationIdleFpsTest3 + * @tc.desc: test results of GetAnimationIdleFpsTest3 + * @tc.type: FUNC + * @tc.require: issuesIA96Q3 + */ +HWTEST_F(HgmEnrtgyConsumptionPolicyTest, GetAnimationIdleFpsTest3, TestSize.Level1) +{ + SetConfigEnable("true"); + HgmEnrtgyConsumptionPolicy::Instance().lastAnimationTimestamp_ = 1719544264071; + HgmEnrtgyConsumptionPolicy::Instance().firstAnimationTimestamp_ = 1719544261071; + FrameRateRange rsRange = { DEFAULT_MAX_FPS, DEFAULT_MAX_FPS, DEFAULT_MAX_FPS }; + HgmEnrtgyConsumptionPolicy::Instance().GetAnimationIdleFps(rsRange); + ASSERT_EQ(rsRange.max_, IDLE_FPS); + ASSERT_EQ(rsRange.min_, IDLE_FPS); + ASSERT_EQ(rsRange.preferred_, IDLE_FPS); +} + +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/rosen/test/render_service/render_service_base/unittest/common/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/common/BUILD.gn index 3d56737daf..ba416b0cf1 100644 --- a/rosen/test/render_service/render_service_base/unittest/common/BUILD.gn +++ b/rosen/test/render_service/render_service_base/unittest/common/BUILD.gn @@ -25,6 +25,7 @@ ohos_unittest("RSRenderServiceBaseCommonTest") { "rs_background_thread_test.cpp", "rs_color_test.cpp", "rs_common_def_test.cpp", + "rs_common_hook_test.cpp", "rs_common_tools_test.cpp", "rs_obj_abs_geometry_test.cpp", "rs_occlusion_region_test.cpp", @@ -59,6 +60,7 @@ ohos_unittest("RSRenderServiceBaseCommonTest") { public_deps = [ "$graphic_2d_root/rosen/modules/2d_graphics:2d_graphics" ] } deps = [ + "../../../../../modules/render_service_base:librender_service_base", "../../../../../modules/render_service_base:render_service_base_src", "//third_party/googletest:gtest_main", ] diff --git a/rosen/test/render_service/render_service_base/unittest/common/rs_common_hook_test.cpp b/rosen/test/render_service/render_service_base/unittest/common/rs_common_hook_test.cpp new file mode 100644 index 0000000000..0bbc7898d8 --- /dev/null +++ b/rosen/test/render_service/render_service_base/unittest/common/rs_common_hook_test.cpp @@ -0,0 +1,72 @@ +/* + * 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 "gtest/gtest.h" + +#include "common/rs_common_hook.h" +using namespace testing; +using namespace testing::ext; + +namespace OHOS::Rosen { +class RsCommonHookTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void RsCommonHookTest::SetUpTestCase() {} +void RsCommonHookTest::TearDownTestCase() {} +void RsCommonHookTest::SetUp() {} +void RsCommonHookTest::TearDown() {} + +/** + * @tc.name: RegisterStartNewAnimationListenerTest + * @tc.desc: test results of RegisterStartNewAnimationListenerTest + * @tc.type: FUNC + * @tc.require: issuesIA96Q3 + */ +HWTEST_F(RsCommonHookTest, RegisterStartNewAnimationListenerTest, TestSize.Level1) +{ + auto callback = []() {}; + RsCommonHook::Instance().RegisterStartNewAnimationListener(callback); +} + +/** + * @tc.name: OnStartNewAnimationTest1 + * @tc.desc: test results of OnStartNewAnimationTest1 + * @tc.type:FUNC + * @tc.require: issuesIA96Q3 + */ +HWTEST_F(RsCommonHookTest, OnStartNewAnimationTest1, TestSize.Level1) +{ + auto callback = []() {}; + RsCommonHook::Instance().RegisterStartNewAnimationListener(callback); + RsCommonHook::Instance().OnStartNewAnimation(); +} + +/** + * @tc.name: OnStartNewAnimationTest2 + * @tc.desc: test results of OnStartNewAnimationTest2 + * @tc.type:FUNC + * @tc.require: issuesIA96Q3 + */ +HWTEST_F(RsCommonHookTest, OnStartNewAnimationTest2, TestSize.Level1) +{ + RsCommonHook::Instance().RegisterStartNewAnimationListener(nullptr); + RsCommonHook::Instance().OnStartNewAnimation(); +} +} // namespace OHOS::Rosen \ No newline at end of file diff --git a/rosen/test/render_service/render_service_base/unittest/luminance/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/luminance/BUILD.gn index e4919516ac..d8e156c57d 100644 --- a/rosen/test/render_service/render_service_base/unittest/luminance/BUILD.gn +++ b/rosen/test/render_service/render_service_base/unittest/luminance/BUILD.gn @@ -41,6 +41,7 @@ ohos_unittest("RSRenderServiceBaseLuminanceTest") { ] deps = [ + "$graphic_2d_root/rosen/modules/render_service_base:librender_service_base", "$graphic_2d_root/rosen/modules/render_service_base:render_service_base_src", "//third_party/googletest:gtest_main", ] diff --git a/rosen/test/render_service/render_service_base/unittest/memory/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/memory/BUILD.gn index 02f81626c1..9c015a5c29 100644 --- a/rosen/test/render_service/render_service_base/unittest/memory/BUILD.gn +++ b/rosen/test/render_service/render_service_base/unittest/memory/BUILD.gn @@ -59,6 +59,7 @@ ohos_unittest("RSRenderServiceBaseMemoryTest") { ] deps = [ + "$graphic_2d_root/rosen/modules/render_service_base:librender_service_base", "$graphic_2d_root/rosen/modules/render_service_base:render_service_base_src", "//third_party/googletest:gtest_main", ] diff --git a/rosen/test/render_service/render_service_base/unittest/modifier/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/modifier/BUILD.gn index 77f71f54a9..6be0af1b66 100644 --- a/rosen/test/render_service/render_service_base/unittest/modifier/BUILD.gn +++ b/rosen/test/render_service/render_service_base/unittest/modifier/BUILD.gn @@ -43,6 +43,7 @@ ohos_unittest("RSRenderServiceBaseModifierTest") { ] deps = [ + "../../../../../modules/render_service_base:librender_service_base", "../../../../../modules/render_service_base:render_service_base_src", "//third_party/googletest:gtest_main", ] diff --git a/rosen/test/render_service/render_service_base/unittest/offscreen_render/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/offscreen_render/BUILD.gn index 1ab7e14f0d..0245b078e6 100644 --- a/rosen/test/render_service/render_service_base/unittest/offscreen_render/BUILD.gn +++ b/rosen/test/render_service/render_service_base/unittest/offscreen_render/BUILD.gn @@ -42,6 +42,7 @@ ohos_unittest("RSRenderServiceBaseOffscreenRenderTest") { ] deps = [ + "../../../../../modules/render_service_base:librender_service_base", "../../../../../modules/render_service_base:render_service_base_src", "//third_party/googletest:gtest_main", ] diff --git a/rosen/test/render_service/render_service_base/unittest/params/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/params/BUILD.gn index 2e84d43676..5fd1133619 100644 --- a/rosen/test/render_service/render_service_base/unittest/params/BUILD.gn +++ b/rosen/test/render_service/render_service_base/unittest/params/BUILD.gn @@ -47,6 +47,7 @@ ohos_unittest("RSRenderServiceBaseParamsTest") { ] deps = [ + "$graphic_2d_root/rosen/modules/render_service_base:librender_service_base", "$graphic_2d_root/rosen/modules/render_service_base:librender_service_base_static", "//third_party/googletest:gtest_main", ] diff --git a/rosen/test/render_service/render_service_base/unittest/property/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/property/BUILD.gn index d6fd2e1a33..1eab30f08a 100644 --- a/rosen/test/render_service/render_service_base/unittest/property/BUILD.gn +++ b/rosen/test/render_service/render_service_base/unittest/property/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("RSRenderServiceBasePropertyTest") { ] deps = [ + "$graphic_2d_root/rosen/modules/render_service_base:librender_service_base", "$graphic_2d_root/rosen/modules/render_service_base:librender_service_base_static", "//third_party/googletest:gtest_main", ] diff --git a/rosen/test/render_service/render_service_base/unittest/render/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/render/BUILD.gn index 6b54e0edd0..0e03ac8fc9 100644 --- a/rosen/test/render_service/render_service_base/unittest/render/BUILD.gn +++ b/rosen/test/render_service/render_service_base/unittest/render/BUILD.gn @@ -75,6 +75,7 @@ ohos_unittest("RSRenderServiceBaseRenderTest") { ] deps = [ + "../../../../../modules/render_service_base:librender_service_base", "../../../../../modules/render_service_base:render_service_base_src", "//third_party/googletest:gtest_main", ] diff --git a/rosen/test/render_service/render_service_base/unittest/transaction/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/transaction/BUILD.gn index d8100604f0..0ce247fc67 100644 --- a/rosen/test/render_service/render_service_base/unittest/transaction/BUILD.gn +++ b/rosen/test/render_service/render_service_base/unittest/transaction/BUILD.gn @@ -48,6 +48,7 @@ ohos_unittest("RSRenderServiceBaseTransactionTest") { ] deps = [ + "../../../../../modules/render_service_base:librender_service_base", "../../../../../modules/render_service_base:render_service_base_src", "//third_party/googletest:gtest_main", ] From 05a9b69e8e01c9ddd9cdcfca8cdbd697d311f02e Mon Sep 17 00:00:00 2001 From: luhan Date: Tue, 2 Jul 2024 09:32:07 +0800 Subject: [PATCH 160/247] =?UTF-8?q?=E4=BF=9D=E6=8C=81=E4=B8=AD=E9=97=B4?= =?UTF-8?q?=E7=9C=81=E7=95=A5=E5=8F=B7=E4=B8=8E=E5=BC=80=E5=A4=B4=E6=9C=AB?= =?UTF-8?q?=E5=B0=BE=E8=A1=8C=E4=B8=BA=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: luhan Change-Id: I2de8f4ebd1a30005b0033a796b89b0bd4837b41d --- .../rosen_text/export/rosen_text/typography_style.h | 1 - .../drawing_ndk/src/drawing_text_typography.cpp | 9 --------- rosen/modules/texgine/export/texgine/typography_style.h | 1 - 3 files changed, 11 deletions(-) diff --git a/rosen/modules/2d_engine/rosen_text/export/rosen_text/typography_style.h b/rosen/modules/2d_engine/rosen_text/export/rosen_text/typography_style.h index 79c28227fa..4ab238fc97 100644 --- a/rosen/modules/2d_engine/rosen_text/export/rosen_text/typography_style.h +++ b/rosen/modules/2d_engine/rosen_text/export/rosen_text/typography_style.h @@ -105,7 +105,6 @@ struct TypographyStyle { bool customTextStyle = false; TextHeightBehavior textHeightBehavior = TextHeightBehavior::ALL; bool hintingIsOn = false; - bool ellipsizedForNDK = false; }; } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/2d_graphics/drawing_ndk/src/drawing_text_typography.cpp b/rosen/modules/2d_graphics/drawing_ndk/src/drawing_text_typography.cpp index a25f0617c8..e2258a542f 100644 --- a/rosen/modules/2d_graphics/drawing_ndk/src/drawing_text_typography.cpp +++ b/rosen/modules/2d_graphics/drawing_ndk/src/drawing_text_typography.cpp @@ -1094,14 +1094,6 @@ void OH_Drawing_SetTypographyTextEllipsisModal(OH_Drawing_TypographyStyle* style #else ConvertToOriginalText(style)->ellipsisModal = rosenEllipsisModal; #endif - if (!ConvertToOriginalText(style)->ellipsizedForNDK) { - #ifndef USE_GRAPHIC_TEXT_GINE - ConvertToOriginalText(style)->ellipsis_ = TypographyStyle::ELLIPSIS; - #else - ConvertToOriginalText(style)->ellipsis = TypographyStyle::ELLIPSIS; - #endif - ConvertToOriginalText(style)->ellipsizedForNDK = true; - } } double OH_Drawing_TypographyGetLineHeight(OH_Drawing_Typography* typography, int lineNumber) @@ -1875,7 +1867,6 @@ void OH_Drawing_SetTypographyTextEllipsis(OH_Drawing_TypographyStyle* style, con #else ConvertToOriginalText(style)->ellipsis = u16Ellipsis; #endif - ConvertToOriginalText(style)->ellipsizedForNDK = true; } void OH_Drawing_TextStyleSetBackgroundRect(OH_Drawing_TextStyle* style, const OH_Drawing_RectStyle_Info* rectStyleInfo, diff --git a/rosen/modules/texgine/export/texgine/typography_style.h b/rosen/modules/texgine/export/texgine/typography_style.h index 7191c594f3..54c7fd9501 100644 --- a/rosen/modules/texgine/export/texgine/typography_style.h +++ b/rosen/modules/texgine/export/texgine/typography_style.h @@ -78,7 +78,6 @@ struct TypographyStyle { * @brief Returns the default TextStyle. */ TextStyle ConvertToTextStyle() const; - bool ellipsizedForNDK = false; }; } // namespace TextEngine } // namespace Rosen From 7539a8c09d8d1c90b082110a7bcf21ce89117b90 Mon Sep 17 00:00:00 2001 From: 15549494042 Date: Tue, 2 Jul 2024 14:27:43 +0800 Subject: [PATCH 161/247] add pointer color invert ipc interface Singed-off-by:dongzhengkuan@huawei.com Signed-off-by: 15549494042 --- .../pipeline/rs_render_service_connection.cpp | 6 +-- .../transaction/rs_render_service_client.h | 2 +- .../ohos/rs_render_service_client.cpp | 2 +- .../test/unittest/rs_interfaces_test.cpp | 48 ++++++++----------- .../rsrenderserviceconnection_fuzzer.cpp | 2 +- 5 files changed, 25 insertions(+), 35 deletions(-) diff --git a/rosen/modules/render_service/core/pipeline/rs_render_service_connection.cpp b/rosen/modules/render_service/core/pipeline/rs_render_service_connection.cpp index ea291c9626..43c36bae6e 100644 --- a/rosen/modules/render_service/core/pipeline/rs_render_service_connection.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_render_service_connection.cpp @@ -31,6 +31,7 @@ #include "drawable/rs_canvas_drawing_render_node_drawable.h" #include "pipeline/parallel_render/rs_sub_thread_manager.h" #include "pipeline/rs_canvas_drawing_render_node.h" +#include "pipeline/rs_pointer_render_manager.h" #include "pipeline/rs_realtime_refresh_rate_manager.h" #include "pipeline/rs_render_frame_rate_linker_map.h" #include "pipeline/rs_render_node_gc.h" @@ -44,7 +45,6 @@ #include "pipeline/rs_uifirst_manager.h" #include "pipeline/rs_uni_render_judgement.h" #include "pipeline/rs_uni_ui_capture.h" -#include "pipeline/rs_pointer_render_manager.h" #include "pixel_map_from_surface.h" #include "platform/common/rs_log.h" #include "platform/common/rs_system_properties.h" @@ -481,14 +481,12 @@ bool RSRenderServiceConnection::Set2DRenderCtrl(bool enable) int32_t RSRenderServiceConnection::SetPointerColorInversionConfig(float darkBuffer, float brightBuffer, int64_t interval) { - std::lock_guard lock(mutex_); RSPointerRenderManager::GetInstance().SetPointerColorInversionConfig(darkBuffer, brightBuffer, interval); return StatusCode::SUCCESS; } int32_t RSRenderServiceConnection::SetPointerColorInversionEnabled(bool enable) { - std::lock_guard lock(mutex_); RSPointerRenderManager::GetInstance().SetPointerColorInversionEnabled(enable); return StatusCode::SUCCESS; } @@ -496,7 +494,6 @@ int32_t RSRenderServiceConnection::SetPointerColorInversionEnabled(bool enable) int32_t RSRenderServiceConnection::RegisterPointerLuminanceChangeCallback( sptr callback) { - std::lock_guard lock(mutex_); if (!callback) { RS_LOGE("RSRenderServiceConnection::RegisterPointerLuminanceChangeCallback: callback is nullptr"); return StatusCode::INVALID_ARGUMENTS; @@ -507,7 +504,6 @@ int32_t RSRenderServiceConnection::RegisterPointerLuminanceChangeCallback( int32_t RSRenderServiceConnection::UnRegisterPointerLuminanceChangeCallback() { - std::lock_guard lock(mutex_); RSPointerRenderManager::GetInstance().UnRegisterPointerLuminanceChangeCallback(remotePid_); return StatusCode::SUCCESS; } diff --git a/rosen/modules/render_service_base/include/transaction/rs_render_service_client.h b/rosen/modules/render_service_base/include/transaction/rs_render_service_client.h index bdc54d120b..4d4dc81c96 100644 --- a/rosen/modules/render_service_base/include/transaction/rs_render_service_client.h +++ b/rosen/modules/render_service_base/include/transaction/rs_render_service_client.h @@ -28,8 +28,8 @@ #include "ipc_callbacks/buffer_available_callback.h" #include "ipc_callbacks/iapplication_agent.h" -#include "ipc_callbacks/screen_change_callback.h" #include "ipc_callbacks/pointer_luminance_change_callback.h" +#include "ipc_callbacks/screen_change_callback.h" #include "ipc_callbacks/surface_capture_callback.h" #include "memory/rs_memory_graphic.h" #ifdef NEW_RENDER_CONTEXT diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_client.cpp b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_client.cpp index 29f258f6db..e8d1cd8937 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_client.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_client.cpp @@ -25,9 +25,9 @@ #include "command/rs_command.h" #include "command/rs_node_showing_command.h" +#include "ipc_callbacks/pointer_luminance_callback_stub.h" #include "ipc_callbacks/rs_surface_occlusion_change_callback_stub.h" #include "ipc_callbacks/screen_change_callback_stub.h" -#include "ipc_callbacks/pointer_luminance_callback_stub.h" #include "ipc_callbacks/surface_capture_callback_stub.h" #include "ipc_callbacks/buffer_available_callback_stub.h" #include "ipc_callbacks/buffer_clear_callback_stub.h" diff --git a/rosen/modules/render_service_client/test/unittest/rs_interfaces_test.cpp b/rosen/modules/render_service_client/test/unittest/rs_interfaces_test.cpp index cde37e7d92..df4ee896d1 100644 --- a/rosen/modules/render_service_client/test/unittest/rs_interfaces_test.cpp +++ b/rosen/modules/render_service_client/test/unittest/rs_interfaces_test.cpp @@ -420,15 +420,13 @@ HWTEST_F(RSInterfacesTest, GetScreenSupportedModes002, Function | SmallTest | Le EXPECT_EQ(supportedScreenModes.size(), 0); } -/* -* Function: SetPointerColorInversionConfig -* Type: Function -* Rank: Important(2) -* EnvConditions: N/A -* CaseDescription: 1. call SetPointerColorInversionConfig -* 2. check -*/ -HWTEST_F(RSInterfacesTest, SetPointerColorInversionConfig001, Function | SmallTest | Level2) +/** + * @tc.name: SetPointerColorInversionConfig001 + * @tc.desc: set pointer color inversion config function. + * @tc.type: FUNC + * @tc.require: Issue #IA8DQ6 + */ +HWTEST_F(RSInterfacesTest, SetPointerColorInversionConfig001, TestSize.Level1) { float darkBuffer = 0.5; float brightBuffer = 0.5; @@ -437,29 +435,25 @@ HWTEST_F(RSInterfacesTest, SetPointerColorInversionConfig001, Function | SmallTe EXPECT_EQ(ret, StatusCode::SUCCESS); } -/* -* Function: SetPointerColorInversionEnabled -* Type: Function -* Rank: Important(2) -* EnvConditions: N/A -* CaseDescription: 1. call SetPointerColorInversionEnabled -* 2. check -*/ -HWTEST_F(RSInterfacesTest, SetPointerColorInversionEnabled001, Function | SmallTest | Level2) +/** + * @tc.name: SetPointerColorInversionEnabled001 + * @tc.desc: set pointer color inversion enabled function. + * @tc.type: FUNC + * @tc.require: Issue #IA8DQ6 + */ +HWTEST_F(RSInterfacesTest, SetPointerColorInversionEnabled001, TestSize.Level1) { int32_t ret = rsInterfaces->SetPointerColorInversionEnabled(false); EXPECT_EQ(ret, StatusCode::SUCCESS); } -/* -* Function: RegisterPointerLuminanceChangeCallback -* Type: Function -* Rank: Important(2) -* EnvConditions: N/A -* CaseDescription: 1. call RegisterPointerLuminanceChangeCallback -* 2. check -*/ -HWTEST_F(RSInterfacesTest, RegisterPointerLuminanceChangeCallback001, Function | SmallTest | Level2) +/** + * @tc.name: RegisterPointerLuminanceChangeCallback001 + * @tc.desc: set pointer color inversion enabled function. + * @tc.type: FUNC + * @tc.require: Issue #IA8DQ6 + */ +HWTEST_F(RSInterfacesTest, RegisterPointerLuminanceChangeCallback001, TestSize.Level1) { int32_t ret = rsInterfaces->RegisterPointerLuminanceChangeCallback([](int32_t brightness) -> void {}); EXPECT_EQ(ret, StatusCode::SUCCESS); diff --git a/rosen/test/render_service/render_service/fuzztest/rsrenderserviceconnection_fuzzer/rsrenderserviceconnection_fuzzer.cpp b/rosen/test/render_service/render_service/fuzztest/rsrenderserviceconnection_fuzzer/rsrenderserviceconnection_fuzzer.cpp index f34d618977..0be34f1bed 100644 --- a/rosen/test/render_service/render_service/fuzztest/rsrenderserviceconnection_fuzzer/rsrenderserviceconnection_fuzzer.cpp +++ b/rosen/test/render_service/render_service/fuzztest/rsrenderserviceconnection_fuzzer/rsrenderserviceconnection_fuzzer.cpp @@ -30,8 +30,8 @@ #include "message_parcel.h" #include "securec.h" -#include "ipc_callbacks/rs_occlusion_change_callback_stub.h" #include "ipc_callbacks/pointer_luminance_callback_stub.h" +#include "ipc_callbacks/rs_occlusion_change_callback_stub.h" #include "pipeline/rs_render_service.h" #include "pipeline/rs_render_service_connection.h" #include "platform/ohos/rs_render_service_connect_hub.cpp" From eb785e68cc2199069661433b47c4a5e009f6f9e3 Mon Sep 17 00:00:00 2001 From: 15549494042 Date: Tue, 2 Jul 2024 14:33:46 +0800 Subject: [PATCH 162/247] add pointer color invert ipc interface Singed-off-by:dongzhengkuan@huawei.com Signed-off-by: 15549494042 --- .../test/unittest/rs_interfaces_test.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/rosen/modules/render_service_client/test/unittest/rs_interfaces_test.cpp b/rosen/modules/render_service_client/test/unittest/rs_interfaces_test.cpp index df4ee896d1..29d7cbc132 100644 --- a/rosen/modules/render_service_client/test/unittest/rs_interfaces_test.cpp +++ b/rosen/modules/render_service_client/test/unittest/rs_interfaces_test.cpp @@ -449,7 +449,7 @@ HWTEST_F(RSInterfacesTest, SetPointerColorInversionEnabled001, TestSize.Level1) /** * @tc.name: RegisterPointerLuminanceChangeCallback001 - * @tc.desc: set pointer color inversion enabled function. + * @tc.desc: register pointer luminance change callback function. * @tc.type: FUNC * @tc.require: Issue #IA8DQ6 */ @@ -459,15 +459,13 @@ HWTEST_F(RSInterfacesTest, RegisterPointerLuminanceChangeCallback001, TestSize.L EXPECT_EQ(ret, StatusCode::SUCCESS); } -/* -* Function: UnRegisterPointerLuminanceChangeCallback -* Type: Function -* Rank: Important(2) -* EnvConditions: N/A -* CaseDescription: 1. call UnRegisterPointerLuminanceChangeCallback -* 2. check -*/ -HWTEST_F(RSInterfacesTest, UnRegisterPointerLuminanceChangeCallback, Function | SmallTest | Level2) +/** + * @tc.name: UnRegisterPointerLuminanceChangeCallback001 + * @tc.desc: unregister pointer luminance change callback function. + * @tc.type: FUNC + * @tc.require: Issue #IA8DQ6 + */ +HWTEST_F(RSInterfacesTest, UnRegisterPointerLuminanceChangeCallback001, TestSize.Level1) { int32_t ret = rsInterfaces->UnRegisterPointerLuminanceChangeCallback(); EXPECT_EQ(ret, StatusCode::SUCCESS); From 3232d6f8ae969a01eb9e6ca33a28a5df66ca8bf5 Mon Sep 17 00:00:00 2001 From: chengwenfeng Date: Tue, 2 Jul 2024 07:05:11 +0000 Subject: [PATCH 163/247] fix: Add Animation Power Solution Signed-off-by: chengwenfeng --- .../frame_rate_manager/hgm_energy_consumption_policy.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_energy_consumption_policy.cpp b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_energy_consumption_policy.cpp index 6a7aca2e60..392b1d32b9 100644 --- a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_energy_consumption_policy.cpp +++ b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_energy_consumption_policy.cpp @@ -96,7 +96,7 @@ void HgmEnrtgyConsumptionPolicy::SetEnergyConsumptionAssuranceMode(bool isEnergy void HgmEnrtgyConsumptionPolicy::StatisticAnimationTime(uint64_t timestamp) { std::lock_guard lock(mutex_); - if (isAnimationEnergyAssuranceEnable_ || !isEnergyConsumptionAssuranceMode_) { + if (!isAnimationEnergyAssuranceEnable_ || !isEnergyConsumptionAssuranceMode_) { return; } lastAnimationTimestamp_ = timestamp; @@ -105,7 +105,7 @@ void HgmEnrtgyConsumptionPolicy::StatisticAnimationTime(uint64_t timestamp) void HgmEnrtgyConsumptionPolicy::StartNewAnimation() { std::lock_guard lock(mutex_); - if (isAnimationEnergyAssuranceEnable_ || !isEnergyConsumptionAssuranceMode_) { + if (!isAnimationEnergyAssuranceEnable_ || !isEnergyConsumptionAssuranceMode_) { return; } firstAnimationTimestamp_ = HgmCore::Instance().GetCurrentTimestamp() / NS_PER_MS; @@ -115,7 +115,7 @@ void HgmEnrtgyConsumptionPolicy::StartNewAnimation() void HgmEnrtgyConsumptionPolicy::GetAnimationIdleFps(FrameRateRange& rsRange) { std::lock_guard lock(mutex_); - if (isAnimationEnergyAssuranceEnable_ || !isEnergyConsumptionAssuranceMode_) { + if (!isAnimationEnergyAssuranceEnable_ || !isEnergyConsumptionAssuranceMode_) { return; } if (lastAnimationTimestamp_ > firstAnimationTimestamp_ && From 868f8f360bf930e79f86d4166ab9bc795dba338d Mon Sep 17 00:00:00 2001 From: tttaaaooo Date: Tue, 2 Jul 2024 16:24:59 +0800 Subject: [PATCH 164/247] fixed opinc chagne state err. Signed-off-by: tttaaaooo --- .../core/pipeline/rs_uni_render_visitor.cpp | 6 ++---- .../include/params/rs_render_params.h | 2 +- .../src/params/rs_render_params.cpp | 11 ++++++++--- .../src/pipeline/rs_render_node_autocache.cpp | 6 +----- .../drawable/rs_render_node_drawable_test.cpp | 4 ++-- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp index abeb4975e6..3d6516fc65 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp @@ -1535,6 +1535,7 @@ void RSUniRenderVisitor::QuickPrepareCanvasRenderNode(RSCanvasRenderNode& node) if (isDrawingCacheEnabled_) { node.UpdateDrawingCacheInfoBeforeChildren(isScreenRotationAnimating_); } + node.OpincQuickMarkStableNode(unchangeMarkInApp_, unchangeMarkEnable_); RectI prepareClipRect = prepareClipRect_; dirtyFlag_ = @@ -1542,7 +1543,6 @@ void RSUniRenderVisitor::QuickPrepareCanvasRenderNode(RSCanvasRenderNode& node) // update prepare clip before children UpdatePrepareClip(node); node.UpdateCurCornerRadius(curCornerRadius_, curSurfaceNode_ != nullptr); - node.OpincQuickMarkStableNode(unchangeMarkInApp_, unchangeMarkEnable_); // 1. Recursively traverse child nodes if above curSurfaceNode and subnode need draw bool isSubTreeNeedPrepare = !curSurfaceNode_ || node.IsSubTreeNeedPrepare(filterInGlobal_) || @@ -2525,9 +2525,7 @@ void RSUniRenderVisitor::PostPrepare(RSRenderNode& node, bool subTreeSkipped) } if (auto nodeParent = node.GetParent().lock()) { nodeParent->UpdateChildUifirstSupportFlag(node.GetUifirstSupportFlag()); - if (unchangeMarkEnable_) { - nodeParent->OpincUpdateNodeSupportFlag(node.OpincGetNodeSupportFlag()); - } + nodeParent->OpincUpdateNodeSupportFlag(node.OpincGetNodeSupportFlag()); } if (node.GetSharedTransitionParam() && node.GetRenderProperties().GetSandBox()) { node.GetStagingRenderParams()->SetAlpha(curAlpha_); diff --git a/rosen/modules/render_service_base/include/params/rs_render_params.h b/rosen/modules/render_service_base/include/params/rs_render_params.h index c354040833..dbb8d211a3 100644 --- a/rosen/modules/render_service_base/include/params/rs_render_params.h +++ b/rosen/modules/render_service_base/include/params/rs_render_params.h @@ -133,7 +133,7 @@ public: void OpincUpdateRootFlag(bool suggestFlag); bool OpincGetRootFlag() const; - void OpincSetCacheChangeFlag(bool state); + void OpincSetCacheChangeFlag(bool state, bool lastFrameSynced); bool OpincGetCacheChangeState(); bool OpincGetCachedMark(); void OpincSetCachedMark(bool mark); diff --git a/rosen/modules/render_service_base/src/params/rs_render_params.cpp b/rosen/modules/render_service_base/src/params/rs_render_params.cpp index 0d64570510..df79afbacb 100644 --- a/rosen/modules/render_service_base/src/params/rs_render_params.cpp +++ b/rosen/modules/render_service_base/src/params/rs_render_params.cpp @@ -282,10 +282,15 @@ bool RSRenderParams::OpincGetRootFlag() const return isOpincRootFlag_; } -void RSRenderParams::OpincSetCacheChangeFlag(bool state) +void RSRenderParams::OpincSetCacheChangeFlag(bool state, bool lastFrameSynced) { - isOpincStateChanged_ = state; - needSync_ = true; + if (lastFrameSynced) { + isOpincStateChanged_ = state; + needSync_ = true; + } else { + needSync_ = needSync_ || (isOpincStateChanged_ || (isOpincStateChanged_ != state)); + isOpincStateChanged_ = isOpincStateChanged_ || state; + } } bool RSRenderParams::OpincGetCacheChangeState() diff --git a/rosen/modules/render_service_base/src/pipeline/rs_render_node_autocache.cpp b/rosen/modules/render_service_base/src/pipeline/rs_render_node_autocache.cpp index 416a967a40..3657b36aa3 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_render_node_autocache.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_render_node_autocache.cpp @@ -167,9 +167,6 @@ void RSRenderNode::SetCacheStateByRetrytime() void RSRenderNode::NodeCacheStateReset(NodeCacheState nodeCacheState) { - if (nodeCacheState_ == nodeCacheState) { - return; - } nodeCacheState_ = nodeCacheState; unchangeCount_ = 0; isUnchangeMarkInApp_ = false; @@ -178,8 +175,7 @@ void RSRenderNode::NodeCacheStateReset(NodeCacheState nodeCacheState) SetCacheStateByRetrytime(); isOpincRootFlag_ = false; } - SetDirty(); - stagingRenderParams_->OpincSetCacheChangeFlag(true); + stagingRenderParams_->OpincSetCacheChangeFlag(true, lastFrameSynced_); isOpincRootFlag_ = false; stagingRenderParams_->OpincUpdateRootFlag(false); } diff --git a/rosen/test/render_service/render_service/unittest/drawable/rs_render_node_drawable_test.cpp b/rosen/test/render_service/render_service/unittest/drawable/rs_render_node_drawable_test.cpp index 3e5d99eea0..e692619970 100644 --- a/rosen/test/render_service/render_service/unittest/drawable/rs_render_node_drawable_test.cpp +++ b/rosen/test/render_service/render_service/unittest/drawable/rs_render_node_drawable_test.cpp @@ -108,12 +108,12 @@ HWTEST_F(RSRenderNodeDrawableTest, PreDrawableCacheState, TestSize.Level1) auto drawable = RSRenderNodeDrawableTest::CreateDrawable(); RSRenderParams params(RSRenderNodeDrawableTest::id); - params.OpincSetCacheChangeFlag(true); + params.OpincSetCacheChangeFlag(true, true); drawable->isOpincRootNode_ = true; bool isOpincDropNodeExt = true; ASSERT_TRUE(drawable->PreDrawableCacheState(params, isOpincDropNodeExt)); - params.OpincSetCacheChangeFlag(false); + params.OpincSetCacheChangeFlag(false, true); drawable->isOpincRootNode_ = false; isOpincDropNodeExt = false; ASSERT_FALSE(drawable->PreDrawableCacheState(params, isOpincDropNodeExt)); From b482e63df29e90735543657c5c1a68d065ed2a60 Mon Sep 17 00:00:00 2001 From: chenlushen Date: Mon, 1 Jul 2024 20:04:50 +0800 Subject: [PATCH 165/247] fix producer surface change bugs in virtual screen & clear roi region in buffer Signed-off-by: chenlushen Change-Id: I81d2a5b9ba7f505a7f2fb8a460a3092238864fee --- .../rs_display_render_node_drawable.cpp | 9 +++++++ .../rs_uni_render_virtual_processor.cpp | 9 ++++--- .../rs_uni_render_virtual_processor.h | 7 ++--- .../core/screen_manager/rs_screen.cpp | 10 +++++++ .../core/screen_manager/rs_screen.h | 3 +++ .../core/screen_manager/rs_screen_manager.cpp | 16 ++++++++++++ .../core/screen_manager/rs_screen_manager.h | 4 +++ .../include/pipeline/rs_display_render_node.h | 15 ++++++----- .../screen_manager/rs_screen_manager_test.cpp | 26 +++++++++++++++++++ .../screen_manager/rs_screen_test.cpp | 16 ++++++++++++ 10 files changed, 103 insertions(+), 12 deletions(-) diff --git a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp index a17bc142d9..f4ed1a6901 100644 --- a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp @@ -523,6 +523,9 @@ void RSDisplayRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) if (!uniParam->IsVirtualDirtyDfxEnabled()) { expandProcessor->SetDirtyInfo(damageRegionRects); } + } else { + std::vector emptyRects = {}; + expandProcessor->SetRoiRegionToCodec(emptyRects); } rsDirtyRectsDfx.SetVirtualDirtyRects(damageRegionRects, screenInfo); DrawExpandScreen(*expandProcessor); @@ -729,6 +732,9 @@ void RSDisplayRenderNodeDrawable::DrawMirrorScreen(std::shared_ptrGetCanvasMatrix()); rsDirtyRectsDfx.SetVirtualDirtyRects(dirtyRects, params.GetScreenInfo()); + } else { + std::vector emptyRects = {}; + virtualProcesser->SetRoiRegionToCodec(emptyRects); } processor->ProcessDisplaySurface(*mirroredNode); uniParam->SetOpDropped(isOpDropped); @@ -848,6 +854,9 @@ void RSDisplayRenderNodeDrawable::DrawMirror(std::shared_ptrGetTotalMatrix()); std::vector dirtyRects = CalculateVirtualDirty(*displayNodeSp, virtualProcesser, params, matrix); rsDirtyRectsDfx.SetVirtualDirtyRects(dirtyRects, params.GetScreenInfo()); + } else { + std::vector emptyRects = {}; + virtualProcesser->SetRoiRegionToCodec(emptyRects); } std::shared_ptr cacheImageProcessed = GetCacheImageFromMirrorNode(mirroredNode); diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_virtual_processor.cpp b/rosen/modules/render_service/core/pipeline/rs_uni_render_virtual_processor.cpp index 993be3f283..e04771dd14 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_virtual_processor.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_virtual_processor.cpp @@ -77,12 +77,15 @@ bool RSUniRenderVirtualProcessor::Init(RSDisplayRenderNode& node, int32_t offset } #endif if (renderFrame_ == nullptr) { - auto rsSurface = node.GetVirtualSurface(); - if (rsSurface == nullptr) { + uint64_t pSurfaceUniqueId = producerSurface_->GetUniqueId(); + auto rsSurface = node.GetVirtualSurface(pSurfaceUniqueId); + if (rsSurface == nullptr || screenManager->GetAndResetVirtualSurfaceUpdateFlag(node.GetScreenId())) { RS_LOGD("RSUniRenderVirtualProcessor::Init Make rssurface from producer Screen(id %{public}" PRIu64 ")", node.GetScreenId()); + RS_TRACE_NAME_FMT("RSUniRenderVirtualProcessor::Init Make rssurface from producer Screen(id %" PRIu64 ")", + node.GetScreenId()); rsSurface = renderEngine_->MakeRSSurface(producerSurface_, forceCPU_); - node.SetVirtualSurface(rsSurface); + node.SetVirtualSurface(rsSurface, pSurfaceUniqueId); } #ifdef NEW_RENDER_CONTEXT renderFrame_ = renderEngine_->RequestFrame( diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_virtual_processor.h b/rosen/modules/render_service/core/pipeline/rs_uni_render_virtual_processor.h index d106a04c9c..b093ab6a47 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_virtual_processor.h +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_virtual_processor.h @@ -29,7 +29,7 @@ struct RoiRegionInfo { }; struct RoiRegions { - uint32_t regionCnt; + uint32_t regionCnt = 0; RoiRegionInfo regions[ROI_REGIONS_MAX_CNT]; }; @@ -73,12 +73,13 @@ public: { return canvasMatrix_; } - void SetDirtyInfo(std::vector& damageRegion_); + void SetDirtyInfo(std::vector& damageRegion); int32_t GetBufferAge() const; + // when virtual screen partial refresh closed, use this function to reset RoiRegion in buffer + GSError SetRoiRegionToCodec(std::vector& damageRegion); private: void CanvasInit(RSDisplayRenderNode& node); void OriginScreenRotation(ScreenRotation screenRotation, float width, float height); - GSError SetRoiRegionToCodec(std::vector& damageRegion); sptr producerSurface_; std::unique_ptr renderFrame_; diff --git a/rosen/modules/render_service/core/screen_manager/rs_screen.cpp b/rosen/modules/render_service/core/screen_manager/rs_screen.cpp index aca6723f2f..54b9b46b07 100644 --- a/rosen/modules/render_service/core/screen_manager/rs_screen.cpp +++ b/rosen/modules/render_service/core/screen_manager/rs_screen.cpp @@ -419,6 +419,16 @@ sptr RSScreen::GetProducerSurface() const void RSScreen::SetProducerSurface(sptr producerSurface) { producerSurface_ = producerSurface; + isVirtualSurfaceUpdateFlag_ = true; +} + +bool RSScreen::GetAndResetVirtualSurfaceUpdateFlag() +{ + if (isVirtualSurfaceUpdateFlag_) { + isVirtualSurfaceUpdateFlag_ = false; + return true; + } + return false; } void RSScreen::ModeInfoDump(std::string& dumpString) diff --git a/rosen/modules/render_service/core/screen_manager/rs_screen.h b/rosen/modules/render_service/core/screen_manager/rs_screen.h index 97590da761..b0377097ec 100644 --- a/rosen/modules/render_service/core/screen_manager/rs_screen.h +++ b/rosen/modules/render_service/core/screen_manager/rs_screen.h @@ -67,6 +67,7 @@ public: virtual std::shared_ptr GetOutput() const = 0; virtual sptr GetProducerSurface() const = 0; virtual void SetProducerSurface(sptr producerSurface) = 0; + virtual bool GetAndResetVirtualSurfaceUpdateFlag() = 0; virtual void DisplayDump(int32_t screenIndex, std::string& dumpString) = 0; virtual void SurfaceDump(int32_t screenIndex, std::string& dumpString) = 0; virtual void FpsDump(int32_t screenIndex, std::string& dumpString, std::string& arg) = 0; @@ -146,6 +147,7 @@ public: std::shared_ptr GetOutput() const override; sptr GetProducerSurface() const override; void SetProducerSurface(sptr producerSurface) override; + bool GetAndResetVirtualSurfaceUpdateFlag() override; void DisplayDump(int32_t screenIndex, std::string& dumpString) override; void SurfaceDump(int32_t screenIndex, std::string& dumpString) override; void FpsDump(int32_t screenIndex, std::string& dumpString, std::string& arg) override; @@ -214,6 +216,7 @@ private: int32_t screenBacklightLevel_ = INVALID_BACKLIGHT_VALUE; bool isVirtual_ = true; + bool isVirtualSurfaceUpdateFlag_ = false; std::shared_ptr hdiOutput_; // has value if the screen is physical std::unique_ptr hdiScreen_; // has value if the screen is physical std::vector supportedModes_; diff --git a/rosen/modules/render_service/core/screen_manager/rs_screen_manager.cpp b/rosen/modules/render_service/core/screen_manager/rs_screen_manager.cpp index 6a0ac479ab..14413e6322 100644 --- a/rosen/modules/render_service/core/screen_manager/rs_screen_manager.cpp +++ b/rosen/modules/render_service/core/screen_manager/rs_screen_manager.cpp @@ -998,6 +998,22 @@ int32_t RSScreenManager::SetVirtualScreenSurface(ScreenId id, sptr surf return SUCCESS; } +bool RSScreenManager::GetAndResetVirtualSurfaceUpdateFlag(ScreenId id) +{ + std::lock_guard lock(mutex_); + auto virtualScreen = screens_.find(id); + if (virtualScreen == screens_.end()) { + RS_LOGW("RSScreenManager %{public}s: There is no screen for id %{public}" PRIu64 ".", __func__, id); + return false; + } + if (virtualScreen->second != nullptr) { + return virtualScreen->second->GetAndResetVirtualSurfaceUpdateFlag(); + } else { + RS_LOGW("RSScreenManager %{public}s: Null screen for id %{public}" PRIu64 ".", __func__, id); + return false; + } +} + void RSScreenManager::RemoveVirtualScreen(ScreenId id) { std::lock_guard lock(mutex_); diff --git a/rosen/modules/render_service/core/screen_manager/rs_screen_manager.h b/rosen/modules/render_service/core/screen_manager/rs_screen_manager.h index 8d92854190..f2235edd18 100644 --- a/rosen/modules/render_service/core/screen_manager/rs_screen_manager.h +++ b/rosen/modules/render_service/core/screen_manager/rs_screen_manager.h @@ -82,6 +82,8 @@ public: virtual int32_t SetVirtualScreenSurface(ScreenId id, sptr surface) = 0; + virtual bool GetAndResetVirtualSurfaceUpdateFlag(ScreenId id) = 0; + virtual void RemoveVirtualScreen(ScreenId id) = 0; virtual void SetScreenActiveMode(ScreenId id, uint32_t modeId) = 0; @@ -274,6 +276,8 @@ public: int32_t SetVirtualScreenSurface(ScreenId id, sptr surface) override; + bool GetAndResetVirtualSurfaceUpdateFlag(ScreenId id) override; + void RemoveVirtualScreen(ScreenId id) override; void SetScreenActiveMode(ScreenId id, uint32_t modeId) override; diff --git a/rosen/modules/render_service_base/include/pipeline/rs_display_render_node.h b/rosen/modules/render_service_base/include/pipeline/rs_display_render_node.h index b56913c2a2..c7553b557b 100644 --- a/rosen/modules/render_service_base/include/pipeline/rs_display_render_node.h +++ b/rosen/modules/render_service_base/include/pipeline/rs_display_render_node.h @@ -170,26 +170,28 @@ public: { return surface_; } - void SetVirtualSurface(std::shared_ptr& virtualSurface) + void SetVirtualSurface(std::shared_ptr& virtualSurface, uint64_t pSurfaceUniqueId) { virtualSurface_ = virtualSurface; + virtualSurfaceUniqueId_ = pSurfaceUniqueId; } - std::shared_ptr GetVirtualSurface() + std::shared_ptr GetVirtualSurface(uint64_t pSurfaceUniqueId) { - return virtualSurface_; + return virtualSurfaceUniqueId_ != pSurfaceUniqueId ? nullptr : virtualSurface_; } #else std::shared_ptr GetRSSurface() const { return surface_; } - void SetVirtualSurface(std::shared_ptr& virtualSurface) + void SetVirtualSurface(std::shared_ptr& virtualSurface, uint64_t pSurfaceUniqueId) { virtualSurface_ = virtualSurface; + virtualSurfaceUniqueId_ = pSurfaceUniqueId; } - std::shared_ptr GetVirtualSurface() + std::shared_ptr GetVirtualSurface(uint64_t pSurfaceUniqueId) { - return virtualSurface_; + return virtualSurfaceUniqueId_ != pSurfaceUniqueId ? nullptr : virtualSurface_; } #endif // Use in vulkan parallel rendering @@ -474,6 +476,7 @@ private: std::shared_ptr surface_; std::shared_ptr virtualSurface_; #endif + uint64_t virtualSurfaceUniqueId_ = 0; bool surfaceCreated_ { false }; bool hasFingerprint_ = false; #ifndef ROSEN_CROSS_PLATFORM diff --git a/rosen/test/render_service/render_service/unittest/screen_manager/rs_screen_manager_test.cpp b/rosen/test/render_service/render_service/unittest/screen_manager/rs_screen_manager_test.cpp index 988395c1ee..41251346f9 100644 --- a/rosen/test/render_service/render_service/unittest/screen_manager/rs_screen_manager_test.cpp +++ b/rosen/test/render_service/render_service/unittest/screen_manager/rs_screen_manager_test.cpp @@ -424,6 +424,32 @@ HWTEST_F(RSScreenManagerTest, GetProducerSurface_001, TestSize.Level1) sleep(1); } +/* + * @tc.name: GetAndResetVirtualSurfaceUpdateFlag_001 + * @tc.desc: Test get virtualSurface update flag correctly + * @tc.type: FUNC + * @tc.require: issueIA9QG0 + */ +HWTEST_F(RSScreenManagerTest, GetAndResetVirtualSurfaceUpdateFlag_001, TestSize.Level1) +{ + auto screenManager = CreateOrGetScreenManager(); + ASSERT_NE(nullptr, screenManager); + std::string name = "virtualScreen01"; + uint32_t width = 480; + uint32_t height = 320; + + auto csurface = IConsumerSurface::Create(); + ASSERT_NE(csurface, nullptr); + auto producer = csurface->GetProducer(); + auto psurface = Surface::CreateSurfaceAsProducer(producer); + ASSERT_NE(psurface, nullptr); + + auto id = screenManager->CreateVirtualScreen(name, width, height, psurface); + ASSERT_NE(INVALID_SCREEN_ID, id); + + ASSERT_EQ(screenManager->GetAndResetVirtualSurfaceUpdateFlag(id), false); +} + /* * @tc.name: ProcessScreenHotPlugEvents_001 * @tc.desc: Test ProcessScreenHotPlugEvents diff --git a/rosen/test/render_service/render_service/unittest/screen_manager/rs_screen_test.cpp b/rosen/test/render_service/render_service/unittest/screen_manager/rs_screen_test.cpp index e0f819e866..83ae79a5fd 100644 --- a/rosen/test/render_service/render_service/unittest/screen_manager/rs_screen_test.cpp +++ b/rosen/test/render_service/render_service/unittest/screen_manager/rs_screen_test.cpp @@ -131,6 +131,22 @@ HWTEST_F(RSScreenTest, SetScreenBacklight_001, testing::ext::TestSize.Level1) ASSERT_EQ(virtualScreen->GetScreenBacklight(), INVALID_BACKLIGHT_VALUE); } +/* + * @tc.name: GetAndResetVirtualSurfaceUpdateFlag_001 + * @tc.desc: Test get virtualSurface update flag correctly + * @tc.type: FUNC + * @tc.require: issueIA9QG0 + */ +HWTEST_F(RSScreenTest, GetAndResetVirtualSurfaceUpdateFlag_001, testing::ext::TestSize.Level1) +{ + VirtualScreenConfigs config; + auto virtualScreen = std::make_unique(config); + virtualScreen->isVirtualSurfaceUpdateFlag_ = true; + ASSERT_EQ(virtualScreen->GetAndResetVirtualSurfaceUpdateFlag(), true); + virtualScreen->isVirtualSurfaceUpdateFlag_ = false; + ASSERT_EQ(virtualScreen->GetAndResetVirtualSurfaceUpdateFlag(), false); +} + /* * @tc.name: GetScreenSupportedColorGamuts_001 * @tc.desc: GetScreenSupportedColorGamuts Test From 19bda1d2a1e23e274005fb80049213d2f27206a2 Mon Sep 17 00:00:00 2001 From: liuwei793 Date: Tue, 2 Jul 2024 16:22:28 +0800 Subject: [PATCH 166/247] add0702 Signed-off-by: liuwei793 Change-Id: I4c40bad18ba0e791a7be7e72439222b03cd47f7d --- .../rsbackgroundthread_fuzzer.cpp | 92 +++++++++++++++++++ .../rscolorpicker_fuzzer.cpp | 72 ++++++++++++--- .../rsdisplaynodecommand_fuzzer.cpp | 74 ++++++++++++++- 3 files changed, 226 insertions(+), 12 deletions(-) diff --git a/rosen/test/render_service/render_service_base/fuzztest/rsbackgroundthread_fuzzer/rsbackgroundthread_fuzzer.cpp b/rosen/test/render_service/render_service_base/fuzztest/rsbackgroundthread_fuzzer/rsbackgroundthread_fuzzer.cpp index 7d936e06d9..f61e55ff58 100755 --- a/rosen/test/render_service/render_service_base/fuzztest/rsbackgroundthread_fuzzer/rsbackgroundthread_fuzzer.cpp +++ b/rosen/test/render_service/render_service_base/fuzztest/rsbackgroundthread_fuzzer/rsbackgroundthread_fuzzer.cpp @@ -77,6 +77,89 @@ bool DoPostSyncTask(const uint8_t* data, size_t size) RSBackgroundThread::Instance().PostSyncTask([]() {}); return true; } +#if defined(RS_ENABLE_UNI_RENDER) && (defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK)) +#ifdef RS_ENABLE_GL +bool DoCreateShareEglContext(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + RSBackgroundThread::Instance().CreateShareEglContext(); + +#if defined(ACE_ENABLE_GL) || defined(RS_ENABLE_GL) + RSBackgroundThread::Instance().CreateShareEglContext(); + RSBackgroundThread::Instance().renderContext_ = new RenderContext(); + delete RSBackgroundThread::Instance().renderContext_; + RSBackgroundThread::Instance().renderContext_ = nullptr; +#endif + return true; +} +#endif +bool DoInitRenderContext(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + RenderContext* context = new RenderContext(); + RSBackgroundThread::Instance().InitRenderContext(context); + return true; +} +bool DoGetShareGPUContext(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + RSBackgroundThread::Instance().GetShareGPUContext(); + return true; +} +bool DoCreateShareGPUContext(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + RSBackgroundThread::Instance().GetShareGPUContext(); +#ifdef RS_ENABLE_GL + RSBackgroundThread::Instance().GetShareGPUContext(); +#endif +#ifdef RS_ENABLE_VK + RSBackgroundThread::Instance().GetShareGPUContext(); +#endif + return true; +} +bool DoCleanGrResource(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + RSBackgroundThread::Instance().CleanGrResource(); + return true; +} +#endif } // namespace Rosen } // namespace OHOS @@ -86,5 +169,14 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) /* Run your code on data */ OHOS::Rosen::DoPostTask(data, size); // PostTask OHOS::Rosen::DoPostSyncTask(data, size); // PostSyncTask +#if defined(RS_ENABLE_UNI_RENDER) && (defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK)) +#ifdef RS_ENABLE_GL + OHOS::Rosen::DoCreateShareEglContext(data, size); // CreateShareEglContext +#endif + OHOS::Rosen::DoInitRenderContext(data, size); // InitRenderContext + OHOS::Rosen::DoGetShareGPUContext(data, size); // GetShareGPUContext + OHOS::Rosen::DoCreateShareGPUContext(data, size); // CreateShareGPUContext + OHOS::Rosen::DoCleanGrResource(data, size); // CleanGrResource +#endif return 0; } diff --git a/rosen/test/render_service/render_service_base/fuzztest/rscolorpicker_fuzzer/rscolorpicker_fuzzer.cpp b/rosen/test/render_service/render_service_base/fuzztest/rscolorpicker_fuzzer/rscolorpicker_fuzzer.cpp index 30cc4fe68b..d7aeea1f7f 100755 --- a/rosen/test/render_service/render_service_base/fuzztest/rscolorpicker_fuzzer/rscolorpicker_fuzzer.cpp +++ b/rosen/test/render_service/render_service_base/fuzztest/rscolorpicker_fuzzer/rscolorpicker_fuzzer.cpp @@ -31,13 +31,17 @@ namespace OHOS { namespace Rosen { using namespace Drawing; -auto pixmap = std::make_shared(); -auto rsColorPicker = std::make_shared(pixmap); namespace { const uint8_t* g_data = nullptr; size_t g_size = 0; size_t g_pos; +int g_two = 240; +int g_three = 300; +int g_one = 180; +int g_six = 361; +int g_sixty = 60; +int g_zero = 120; } // namespace template @@ -66,7 +70,9 @@ bool DoCreateColorPicker(const uint8_t* data, size_t size) g_data = data; g_size = size; g_pos = 0; + auto pixmap = std::make_shared(); + auto rsColorPicker = std::make_shared(pixmap); uint32_t werrorCodeidth = GetData(); double coordinates = GetData(); RSColorPicker::CreateColorPicker(pixmap, werrorCodeidth); @@ -84,6 +90,8 @@ bool DoGetLargestProportionColor(const uint8_t* data, size_t size) g_size = size; g_pos = 0; + auto pixmap = std::make_shared(); + auto rsColorPicker = std::make_shared(pixmap); uint32_t color = GetData(); rsColorPicker->GetLargestProportionColor(color); return true; @@ -99,6 +107,8 @@ bool DoGetHighestSaturationColor(const uint8_t* data, size_t size) g_size = size; g_pos = 0; + auto pixmap = std::make_shared(); + auto rsColorPicker = std::make_shared(pixmap); uint32_t color = GetData(); rsColorPicker->GetHighestSaturationColor(color); return true; @@ -114,8 +124,15 @@ bool DoGetAverageColor(const uint8_t* data, size_t size) g_size = size; g_pos = 0; + auto pixmap = std::make_shared(); + auto rsColorPicker = std::make_shared(pixmap); uint32_t color = GetData(); rsColorPicker->GetAverageColor(color); + rsColorPicker->featureColors_.push_back({ 0, 1 }); + rsColorPicker->GetAverageColor(color); + rsColorPicker->featureColors_.clear(); + rsColorPicker->featureColors_.push_back({ 0, 0 }); + rsColorPicker->GetAverageColor(color); return true; } bool DoIsBlackOrWhiteOrGrayColor(const uint8_t* data, size_t size) @@ -129,6 +146,8 @@ bool DoIsBlackOrWhiteOrGrayColor(const uint8_t* data, size_t size) g_size = size; g_pos = 0; + auto pixmap = std::make_shared(); + auto rsColorPicker = std::make_shared(pixmap); uint32_t color = GetData(); rsColorPicker->IsBlackOrWhiteOrGrayColor(color); return true; @@ -144,6 +163,8 @@ bool DoIsEquals(const uint8_t* data, size_t size) g_size = size; g_pos = 0; + auto pixmap = std::make_shared(); + auto rsColorPicker = std::make_shared(pixmap); double val1 = GetData(); double val2 = GetData(); rsColorPicker->IsEquals(val1, val2); @@ -161,6 +182,8 @@ bool DoRGB2HSV(const uint8_t* data, size_t size) g_size = size; g_pos = 0; + auto pixmap = std::make_shared(); + auto rsColorPicker = std::make_shared(pixmap); uint32_t rgb = GetData(); rsColorPicker->RGB2HSV(rgb); return true; @@ -177,11 +200,24 @@ bool DoAdjustHSVToDefinedIterval(const uint8_t* data, size_t size) g_size = size; g_pos = 0; + auto pixmap = std::make_shared(); + auto rsColorPicker = std::make_shared(pixmap); HSV color; color.h = GetData(); color.s = GetData(); color.v = GetData(); + color.h = g_six; + rsColorPicker->AdjustHSVToDefinedIterval(color); + color.h = -1; + rsColorPicker->AdjustHSVToDefinedIterval(color); + color.s = 101.f; + rsColorPicker->AdjustHSVToDefinedIterval(color); + color.s = -1.f; + rsColorPicker->AdjustHSVToDefinedIterval(color); + color.v = 101.f; + rsColorPicker->AdjustHSVToDefinedIterval(color); + color.v = -1.f; rsColorPicker->AdjustHSVToDefinedIterval(color); return true; } @@ -196,11 +232,25 @@ bool DoHSVtoRGB(const uint8_t* data, size_t size) g_size = size; g_pos = 0; + auto pixmap = std::make_shared(); + auto rsColorPicker = std::make_shared(pixmap); HSV color; color.h = GetData(); color.s = GetData(); color.v = GetData(); rsColorPicker->HSVtoRGB(color); + color.h = 0; + rsColorPicker->HSVtoRGB(color); + color.h = g_sixty; + rsColorPicker->HSVtoRGB(color); + color.h = g_zero; + rsColorPicker->HSVtoRGB(color); + color.h = g_one; + rsColorPicker->HSVtoRGB(color); + color.h = g_two; + rsColorPicker->HSVtoRGB(color); + color.h = g_three; + rsColorPicker->HSVtoRGB(color); return true; } } // namespace Rosen @@ -210,14 +260,14 @@ bool DoHSVtoRGB(const uint8_t* data, size_t size) extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ - OHOS::Rosen::DoCreateColorPicker(data, size); // CreateColorPicker - OHOS::Rosen::DoGetLargestProportionColor(data, size); // GetLargestProportionColor - OHOS::Rosen::DoGetHighestSaturationColor(data, size); // GetHighestSaturationColor - OHOS::Rosen::DoGetAverageColor(data, size); // GetAverageColor - OHOS::Rosen::DoIsBlackOrWhiteOrGrayColor(data, size); // IsBlackOrWhiteOrGrayColor - OHOS::Rosen::DoIsEquals(data, size); // IsEquals - OHOS::Rosen::DoRGB2HSV(data, size); // RGB2HSV - OHOS::Rosen::DoAdjustHSVToDefinedIterval(data, size); // AdjustHSVToDefinedIterval - OHOS::Rosen::DoHSVtoRGB(data, size); // HSVtoRGB + OHOS::Rosen::DoCreateColorPicker(data, size); + OHOS::Rosen::DoGetLargestProportionColor(data, size); + OHOS::Rosen::DoGetHighestSaturationColor(data, size); + OHOS::Rosen::DoGetAverageColor(data, size); + OHOS::Rosen::DoIsBlackOrWhiteOrGrayColor(data, size); + OHOS::Rosen::DoIsEquals(data, size); + OHOS::Rosen::DoRGB2HSV(data, size); + OHOS::Rosen::DoAdjustHSVToDefinedIterval(data, size); + OHOS::Rosen::DoHSVtoRGB(data, size); return 0; } diff --git a/rosen/test/render_service/render_service_base/fuzztest/rsdisplaynodecommand_fuzzer/rsdisplaynodecommand_fuzzer.cpp b/rosen/test/render_service/render_service_base/fuzztest/rsdisplaynodecommand_fuzzer/rsdisplaynodecommand_fuzzer.cpp index 124c67cfc5..db4083f5a7 100755 --- a/rosen/test/render_service/render_service_base/fuzztest/rsdisplaynodecommand_fuzzer/rsdisplaynodecommand_fuzzer.cpp +++ b/rosen/test/render_service/render_service_base/fuzztest/rsdisplaynodecommand_fuzzer/rsdisplaynodecommand_fuzzer.cpp @@ -27,6 +27,8 @@ namespace { const uint8_t* g_data = nullptr; size_t g_size = 0; size_t g_pos; +int g_two = 2; +int g_five = 5; } // namespace /* @@ -85,6 +87,74 @@ bool DoDisplayNode(const uint8_t* data, size_t size) DisplayNodeCommandHelper::SetRogSize(*context, id, rogWidth, rogHeight); return true; } +bool DoSetDisplayMode(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + RSContext context; + NodeId id = static_cast(1); + RSDisplayNodeConfig config { 0, false, 0 }; + DisplayNodeCommandHelper::SetDisplayMode(context, id, config); + + DisplayNodeCommandHelper::Create(context, id, config); + DisplayNodeCommandHelper::SetDisplayMode(context, id, config); + + config.isMirrored = true; + DisplayNodeCommandHelper::SetDisplayMode(context, id, config); + + NodeId mirrorNodeId = static_cast(2); + config.mirrorNodeId = mirrorNodeId; + DisplayNodeCommandHelper::Create(context, mirrorNodeId, config); + DisplayNodeCommandHelper::SetDisplayMode(context, id, config); + return true; +} +bool DoSetBootAnimation(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + RSContext context; + NodeId id = static_cast(1); + RSDisplayNodeConfig config { 0, true, 0 }; + DisplayNodeCommandHelper::Create(context, id, config); + DisplayNodeCommandHelper::SetBootAnimation(context, id, true); + DisplayNodeCommandHelper::SetBootAnimation(context, g_five, true); + return true; +} +bool DoSetScbNodePid(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + RSContext context; + NodeId id = static_cast(1); + std::vector oldScbPids = {}; + int32_t currentScbPid = -1; + DisplayNodeCommandHelper::SetScbNodePid(context, id, oldScbPids, currentScbPid); + oldScbPids.push_back(1); + oldScbPids.push_back(g_two); + DisplayNodeCommandHelper::SetScbNodePid(context, id, oldScbPids, currentScbPid); + return true; +} } // namespace Rosen } // namespace OHOS @@ -93,6 +163,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ OHOS::Rosen::DoDisplayNode(data, size); + OHOS::Rosen::DoSetDisplayMode(data, size); + OHOS::Rosen::DoSetBootAnimation(data, size); + OHOS::Rosen::DoSetScbNodePid(data, size); return 0; } - From cc691cc5d12a97b3576147d0c66ef9462eaa0e3d Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 1 Jul 2024 15:04:28 +0800 Subject: [PATCH 167/247] bugfix of memoryleak of Drawing::matrix Signed-off-by: jason Change-Id: I6b2f87b19644e4ec0a9c39d5effd4ffe995bcaf5 --- .../src/platform/ohos/rs_marshalling_helper.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_marshalling_helper.cpp b/rosen/modules/render_service_base/src/platform/ohos/rs_marshalling_helper.cpp index 93a127f1f4..91ec02437f 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_marshalling_helper.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_marshalling_helper.cpp @@ -568,6 +568,10 @@ bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, Drawing::Matrix& val) val.SetMatrix(data[Drawing::Matrix::SCALE_X], data[Drawing::Matrix::SKEW_X], data[Drawing::Matrix::TRANS_X], data[Drawing::Matrix::SKEW_Y], data[Drawing::Matrix::SCALE_Y], data[Drawing::Matrix::TRANS_Y], data[Drawing::Matrix::PERSP_0], data[Drawing::Matrix::PERSP_1], data[Drawing::Matrix::PERSP_2]); + if (isMalloc) { + free(static_cast(const_cast(data))); + data = nullptr; + } return true; } From 2d9815cc60e22ca22f3cc4696d26064d5c7edb96 Mon Sep 17 00:00:00 2001 From: w00661663 Date: Tue, 2 Jul 2024 04:38:29 +0000 Subject: [PATCH 168/247] particle codecheck Signed-off-by: w00661663 Change-Id: I47142f2d68a055e8b4ac4ebea9a5ab088b5bae07 --- .../include/animation/rs_render_particle.h | 21 +- .../include/render/rs_particles_drawable.h | 2 + .../src/animation/rs_particle_noise_field.cpp | 6 +- .../src/animation/rs_render_particle.cpp | 102 +++----- .../rs_render_particle_animation.cpp | 4 +- .../animation/rs_render_particle_effector.cpp | 242 +++++++++++------- .../animation/rs_render_particle_emitter.cpp | 6 +- .../animation/rs_render_particle_system.cpp | 12 +- .../platform/ohos/rs_marshalling_helper.cpp | 62 ++++- .../src/render/rs_particles_drawable.cpp | 65 +++-- .../render_service_client/core/ui/rs_node.cpp | 6 + .../animation/rs_render_particle_test.cpp | 126 ++------- 12 files changed, 344 insertions(+), 310 deletions(-) diff --git a/rosen/modules/render_service_base/include/animation/rs_render_particle.h b/rosen/modules/render_service_base/include/animation/rs_render_particle.h index 1eb9dc41d3..84d39d9a6b 100644 --- a/rosen/modules/render_service_base/include/animation/rs_render_particle.h +++ b/rosen/modules/render_service_base/include/animation/rs_render_particle.h @@ -276,6 +276,14 @@ public: float GetSpinStartValue(); float GetSpinEndValue(); const ParticleUpdator& GetSpinUpdator(); + + const std::vector>>& GetAcceValChangeOverLife(); + const std::vector>>& GetAcceAngChangeOverLife(); + const std::vector>>& GetOpacityChangeOverLife(); + const std::vector>>& GetScaleChangeOverLife(); + const std::vector>>& GetSpinChangeOverLife(); + const std::vector>>& GetColorChangeOverLife(); + float GetSpinRandomStart() const; float GetSpinRandomEnd() const; size_t GetImageIndex() const; @@ -348,19 +356,6 @@ public: int64_t GetActiveTime(); const std::shared_ptr& GetParticleRenderParams(); - const ParticleUpdator& GetAccelerationValueUpdator(); - const ParticleUpdator& GetAccelerationAngleUpdator(); - const ParticleUpdator& GetColorUpdator(); - const ParticleUpdator& GetOpacityUpdator(); - const ParticleUpdator& GetScaleUpdator(); - const ParticleUpdator& GetSpinUpdator(); - const std::vector>>& GetAcceValChangeOverLife(); - const std::vector>>& GetAcceAngChangeOverLife(); - const std::vector>>& GetOpacityChangeOverLife(); - const std::vector>>& GetScaleChangeOverLife(); - const std::vector>>& GetSpinChangeOverLife(); - const std::vector>>& GetColorChangeOverLife(); - size_t GetImageIndex() const; // Other methods diff --git a/rosen/modules/render_service_base/include/render/rs_particles_drawable.h b/rosen/modules/render_service_base/include/render/rs_particles_drawable.h index 8d573e12f5..5cd74de49b 100644 --- a/rosen/modules/render_service_base/include/render/rs_particles_drawable.h +++ b/rosen/modules/render_service_base/include/render/rs_particles_drawable.h @@ -37,6 +37,8 @@ private: const std::shared_ptr& particle, Vector2f position, float opacity, float scale); void CaculateImageAtlsArry(Drawing::Canvas& canvas, const std::shared_ptr& particle, Vector2f position, float opacity, float scale); + void DrawImageFill(Drawing::Canvas& canvas, const std::shared_ptr& particle, + Vector2f position, float opacity, float scale); void DrawParticles(Drawing::Canvas& canvas); void DrawCircle(Drawing::Canvas& canvas); void DrawImages(Drawing::Canvas& canvas); diff --git a/rosen/modules/render_service_base/src/animation/rs_particle_noise_field.cpp b/rosen/modules/render_service_base/src/animation/rs_particle_noise_field.cpp index 139364cc97..d204c03845 100644 --- a/rosen/modules/render_service_base/src/animation/rs_particle_noise_field.cpp +++ b/rosen/modules/render_service_base/src/animation/rs_particle_noise_field.cpp @@ -71,7 +71,11 @@ float ParticleNoiseField::CalculateDistanceToRectangleEdge( return 0.f; } // The smallest value of t, which is the first time the particle will reach the boundary. - float tEdge = *std::min_element(times.begin(), times.end()); + float tEdge = 0.f; + if (times.size() != 0) { + tEdge = *std::min_element(times.begin(), times.end()); + } + // Calculates the distance to the border. float distance = std::sqrt(std::pow(tEdge * direction.x_, 2) + std::pow(tEdge * direction.y_, 2)); return distance; diff --git a/rosen/modules/render_service_base/src/animation/rs_render_particle.cpp b/rosen/modules/render_service_base/src/animation/rs_render_particle.cpp index aebf041c95..9e4a30ecef 100644 --- a/rosen/modules/render_service_base/src/animation/rs_render_particle.cpp +++ b/rosen/modules/render_service_base/src/animation/rs_render_particle.cpp @@ -283,6 +283,36 @@ const ParticleUpdator& ParticleRenderParams::GetSpinUpdator() return spin_.updator_; } +const std::vector>>& ParticleRenderParams::GetAcceValChangeOverLife() +{ + return acceleration_.accelerationValue_.valChangeOverLife_; +} + +const std::vector>>& ParticleRenderParams::GetAcceAngChangeOverLife() +{ + return acceleration_.accelerationAngle_.valChangeOverLife_; +} + +const std::vector>>& ParticleRenderParams::GetOpacityChangeOverLife() +{ + return opacity_.valChangeOverLife_; +} + +const std::vector>>& ParticleRenderParams::GetScaleChangeOverLife() +{ + return scale_.valChangeOverLife_; +} + +const std::vector>>& ParticleRenderParams::GetSpinChangeOverLife() +{ + return spin_.valChangeOverLife_; +} + +const std::vector>>& ParticleRenderParams::GetColorChangeOverLife() +{ + return color_.valChangeOverLife_; +} + float ParticleRenderParams::GetSpinRandomStart() const { return spin_.random_.start_; @@ -341,7 +371,9 @@ void ParticleRenderParams::SetImageIndex(size_t imageIndex) RSRenderParticle::RSRenderParticle(const std::shared_ptr& particleParams) : particleParams_(particleParams) { - InitProperty(); + if (particleParams_ != nullptr) { + InitProperty(); + } } // Set methods @@ -576,66 +608,6 @@ const std::shared_ptr& RSRenderParticle::GetParticleRender return particleParams_; } -const ParticleUpdator& RSRenderParticle::GetAccelerationValueUpdator() -{ - return particleParams_->acceleration_.accelerationValue_.updator_; -} - -const ParticleUpdator& RSRenderParticle::GetAccelerationAngleUpdator() -{ - return particleParams_->acceleration_.accelerationAngle_.updator_; -} - -const ParticleUpdator& RSRenderParticle::GetColorUpdator() -{ - return particleParams_->color_.updator_; -} - -const ParticleUpdator& RSRenderParticle::GetOpacityUpdator() -{ - return particleParams_->opacity_.updator_; -} - -const ParticleUpdator& RSRenderParticle::GetScaleUpdator() -{ - return particleParams_->scale_.updator_; -} - -const ParticleUpdator& RSRenderParticle::GetSpinUpdator() -{ - return particleParams_->spin_.updator_; -} - -const std::vector>>& RSRenderParticle::GetAcceValChangeOverLife() -{ - return particleParams_->acceleration_.accelerationValue_.valChangeOverLife_; -} - -const std::vector>>& RSRenderParticle::GetAcceAngChangeOverLife() -{ - return particleParams_->acceleration_.accelerationAngle_.valChangeOverLife_; -} - -const std::vector>>& RSRenderParticle::GetOpacityChangeOverLife() -{ - return particleParams_->opacity_.valChangeOverLife_; -} - -const std::vector>>& RSRenderParticle::GetScaleChangeOverLife() -{ - return particleParams_->scale_.valChangeOverLife_; -} - -const std::vector>>& RSRenderParticle::GetSpinChangeOverLife() -{ - return particleParams_->spin_.valChangeOverLife_; -} - -const std::vector>>& RSRenderParticle::GetColorChangeOverLife() -{ - return particleParams_->color_.valChangeOverLife_; -} - size_t RSRenderParticle::GetImageIndex() const { return imageIndex_; @@ -643,6 +615,9 @@ size_t RSRenderParticle::GetImageIndex() const void RSRenderParticle::InitProperty() { + if (particleParams_ == nullptr) { + return; + } position_ = CalculateParticlePosition( particleParams_->GetEmitShape(), particleParams_->GetEmitPosition(), particleParams_->GetEmitSize()); @@ -696,7 +671,7 @@ bool RSRenderParticle::IsAlive() const return false; } - if (particleParams_->GetLifeTimeStartValue() == (-1 * NS_PER_MS) && + if (particleParams_ != nullptr && particleParams_->GetLifeTimeStartValue() == (-1 * NS_PER_MS) && particleParams_->GetLifeTimeEndValue() == (-1 * NS_PER_MS)) { return true; } @@ -723,6 +698,9 @@ float RSRenderParticle::GetRandomValue(float min, float max) void RSRenderParticle::SetColor() { + if (particleParams_ == nullptr) { + return; + } if (particleParams_->GetColorDistribution() == DistributionType::GAUSSIAN) { auto& colorStart = particleParams_->GetColorStartValue(); auto& colorEnd = particleParams_->GetColorEndValue(); diff --git a/rosen/modules/render_service_base/src/animation/rs_render_particle_animation.cpp b/rosen/modules/render_service_base/src/animation/rs_render_particle_animation.cpp index 3074b2142a..7357fdae6e 100644 --- a/rosen/modules/render_service_base/src/animation/rs_render_particle_animation.cpp +++ b/rosen/modules/render_service_base/src/animation/rs_render_particle_animation.cpp @@ -113,7 +113,9 @@ void RSRenderParticleAnimation::UpdateNoiseField(const std::shared_ptrUpdateNoiseField(particleNoiseFields); + if (particleSystem_) { + particleSystem_->UpdateNoiseField(particleNoiseFields); + } } void RSRenderParticleAnimation::OnAttach() diff --git a/rosen/modules/render_service_base/src/animation/rs_render_particle_effector.cpp b/rosen/modules/render_service_base/src/animation/rs_render_particle_effector.cpp index 018410c755..946a90b6ed 100644 --- a/rosen/modules/render_service_base/src/animation/rs_render_particle_effector.cpp +++ b/rosen/modules/render_service_base/src/animation/rs_render_particle_effector.cpp @@ -40,7 +40,9 @@ Vector4 RSRenderParticleEffector::CalculateColorInt(const std::shared_p colorInt.data_[i] += static_cast(colorF.data_[i]); colorF.data_[i] -= std::floor(colorF.data_[i]); } - particle->SetRedF(colorF.data_[i]); + if (particle != nullptr) { + particle->SetRedF(colorF.data_[i]); + } colorInt.data_[i] = std::clamp(colorInt.data_[i], 0, UINT8_MAX); } } @@ -51,24 +53,26 @@ void RSRenderParticleEffector::UpdateCurveValue( float& value, const std::vector>>& valChangeOverLife, int64_t activeTime) { for (size_t i = 0; i < valChangeOverLife.size(); i++) { - int startTime = valChangeOverLife[i]->startMillis_; - int endTime = valChangeOverLife[i]->endMillis_; - if (activeTime < startTime || activeTime > endTime) { - continue; - } - float startValue = valChangeOverLife[i]->fromValue_; - float endValue = valChangeOverLife[i]->toValue_; + if (valChangeOverLife[i] != nullptr) { + int startTime = valChangeOverLife[i]->startMillis_; + int endTime = valChangeOverLife[i]->endMillis_; + if (activeTime < startTime || activeTime > endTime) { + continue; + } + float startValue = valChangeOverLife[i]->fromValue_; + float endValue = valChangeOverLife[i]->toValue_; #ifdef ENABLE_RUST - value = generate_value(startValue, endValue, startTime, endTime, activeTime); + value = generate_value(startValue, endValue, startTime, endTime, activeTime); #else - if (endTime - startTime > 0) { - float t = static_cast(activeTime - startTime) / static_cast(endTime - startTime); - auto& interpolator = valChangeOverLife[i]->interpolator_; - t = (interpolator != nullptr) ? interpolator->Interpolate(t) : t; - value = startValue * (1.0f - t) + endValue * t; - } + if (endTime - startTime > 0) { + float t = static_cast(activeTime - startTime) / static_cast(endTime - startTime); + auto& interpolator = valChangeOverLife[i]->interpolator_; + t = (interpolator != nullptr) ? interpolator->Interpolate(t) : t; + value = startValue * (1.0f - t) + endValue * t; + } #endif - break; + break; + } } } @@ -76,102 +80,127 @@ void RSRenderParticleEffector::UpdateColorCurveValue( Color& color, const std::vector>>& valChangeOverLife, int64_t activeTime) { for (size_t i = 0; i < valChangeOverLife.size(); i++) { - int startTime = valChangeOverLife[i]->startMillis_; - int endTime = valChangeOverLife[i]->endMillis_; - if (activeTime < startTime || activeTime > endTime) { - continue; + if (valChangeOverLife[i] != nullptr) { + int startTime = valChangeOverLife[i]->startMillis_; + int endTime = valChangeOverLife[i]->endMillis_; + if (activeTime < startTime || activeTime > endTime) { + continue; + } + if (endTime - startTime > 0) { + Color startValue = valChangeOverLife[i]->fromValue_; + Color endValue = valChangeOverLife[i]->toValue_; + float t = static_cast(activeTime - startTime) / static_cast(endTime - startTime); + auto& interpolator = valChangeOverLife[i]->interpolator_; + t = (interpolator != nullptr) ? interpolator->Interpolate(t) : t; + color = RSRenderParticle::Lerp(startValue, endValue, t); + } + color = Color(color.AsRgbaInt()); + break; } - if (endTime - startTime > 0) { - Color startValue = valChangeOverLife[i]->fromValue_; - Color endValue = valChangeOverLife[i]->toValue_; - float t = static_cast(activeTime - startTime) / static_cast(endTime - startTime); - auto& interpolator = valChangeOverLife[i]->interpolator_; - t = (interpolator != nullptr) ? interpolator->Interpolate(t) : t; - color = RSRenderParticle::Lerp(startValue, endValue, t); - } - color = Color(color.AsRgbaInt()); - break; } } void RSRenderParticleEffector::UpdateColor(const std::shared_ptr& particle, float deltaTime) { - if (particle->GetParticleType() == ParticleType::IMAGES) { + if (particle == nullptr || particle->GetParticleType() == ParticleType::IMAGES) { return; } - auto colorUpdator = particle->GetColorUpdator(); Color color = particle->GetColor(); - if (colorUpdator == ParticleUpdator::RANDOM) { - auto colorInt = Vector4(color.GetRed(), color.GetGreen(), color.GetBlue(), color.GetAlpha()); - auto colorSpeed = Vector4f( - particle->GetRedSpeed(), particle->GetGreenSpeed(), particle->GetBlueSpeed(), particle->GetAlphaSpeed()); - auto colorF = Vector4f(particle->GetRedF(), particle->GetGreenF(), particle->GetBlueF(), particle->GetAlphaF()); - colorInt = CalculateColorInt(particle, colorInt, colorF, colorSpeed, deltaTime); - color.SetRed(colorInt.x_); - color.SetGreen(colorInt.y_); - color.SetBlue(colorInt.z_); - color.SetAlpha(colorInt.w_); - } else if (colorUpdator == ParticleUpdator::CURVE) { - int64_t activeTime = particle->GetActiveTime() / NS_PER_MS; - auto& valChangeOverLife = particle->GetColorChangeOverLife(); - UpdateColorCurveValue(color, valChangeOverLife, activeTime); + auto particleRenderParams = particle->GetParticleRenderParams(); + if (particleRenderParams != nullptr) { + auto colorUpdator = particleRenderParams->GetColorUpdator(); + if (colorUpdator == ParticleUpdator::RANDOM) { + auto colorInt = Vector4(color.GetRed(), color.GetGreen(), color.GetBlue(), color.GetAlpha()); + auto colorSpeed = Vector4f(particle->GetRedSpeed(), particle->GetGreenSpeed(), particle->GetBlueSpeed(), + particle->GetAlphaSpeed()); + auto colorF = + Vector4f(particle->GetRedF(), particle->GetGreenF(), particle->GetBlueF(), particle->GetAlphaF()); + colorInt = CalculateColorInt(particle, colorInt, colorF, colorSpeed, deltaTime); + color.SetRed(colorInt.x_); + color.SetGreen(colorInt.y_); + color.SetBlue(colorInt.z_); + color.SetAlpha(colorInt.w_); + } else if (colorUpdator == ParticleUpdator::CURVE) { + int64_t activeTime = particle->GetActiveTime() / NS_PER_MS; + auto& valChangeOverLife = particleRenderParams->GetColorChangeOverLife(); + UpdateColorCurveValue(color, valChangeOverLife, activeTime); + } } + particle->SetColor(color); } void RSRenderParticleEffector::UpdateOpacity(const std::shared_ptr& particle, float deltaTime) { - auto opacityUpdator = particle->GetOpacityUpdator(); + if (particle == nullptr) { + return; + } auto opacity = particle->GetOpacity(); - if (opacityUpdator == ParticleUpdator::RANDOM) { - auto opacitySpeed = particle->GetOpacitySpeed(); - if (opacity <= 0 && opacitySpeed <= 0) { - particle->SetIsDead(); - return; + auto particleRenderParams = particle->GetParticleRenderParams(); + if (particleRenderParams != nullptr) { + auto opacityUpdator = particleRenderParams->GetOpacityUpdator(); + if (opacityUpdator == ParticleUpdator::RANDOM) { + auto opacitySpeed = particle->GetOpacitySpeed(); + if (opacity <= 0 && opacitySpeed <= 0) { + particle->SetIsDead(); + return; + } + if (opacity >= 1.0 && opacitySpeed >= 0.f) { + return; + } + opacity += opacitySpeed * deltaTime; + opacity = std::clamp(opacity, 0.f, 1.f); + } else if (opacityUpdator == ParticleUpdator::CURVE) { + int64_t activeTime = particle->GetActiveTime() / NS_PER_MS; + auto& valChangeOverLife = particleRenderParams->GetOpacityChangeOverLife(); + UpdateCurveValue(opacity, valChangeOverLife, activeTime); } - if (opacity >= 1.0 && opacitySpeed >= 0.f) { - return; - } - opacity += opacitySpeed * deltaTime; - opacity = std::clamp(opacity, 0.f, 1.f); - } else if (opacityUpdator == ParticleUpdator::CURVE) { - int64_t activeTime = particle->GetActiveTime() / NS_PER_MS; - auto& valChangeOverLife = particle->GetOpacityChangeOverLife(); - UpdateCurveValue(opacity, valChangeOverLife, activeTime); } particle->SetOpacity(opacity); } void RSRenderParticleEffector::UpdateScale(const std::shared_ptr& particle, float deltaTime) { - auto scaleUpdator = particle->GetScaleUpdator(); + if (particle == nullptr) { + return; + } auto scale = particle->GetScale(); - if (scaleUpdator == ParticleUpdator::RANDOM) { - auto scaleSpeed = particle->GetScaleSpeed(); - if (scale <= 0 && scaleSpeed <= 0) { - particle->SetIsDead(); - return; + auto particleRenderParams = particle->GetParticleRenderParams(); + if (particleRenderParams != nullptr) { + auto scaleUpdator = particleRenderParams->GetScaleUpdator(); + if (scaleUpdator == ParticleUpdator::RANDOM) { + auto scaleSpeed = particle->GetScaleSpeed(); + if (scale <= 0 && scaleSpeed <= 0) { + particle->SetIsDead(); + return; + } + scale += scaleSpeed * deltaTime; + } else if (scaleUpdator == ParticleUpdator::CURVE) { + int64_t activeTime = particle->GetActiveTime() / NS_PER_MS; + auto& valChangeOverLife = particleRenderParams->GetScaleChangeOverLife(); + UpdateCurveValue(scale, valChangeOverLife, activeTime); } - scale += scaleSpeed * deltaTime; - } else if (scaleUpdator == ParticleUpdator::CURVE) { - int64_t activeTime = particle->GetActiveTime() / NS_PER_MS; - auto& valChangeOverLife = particle->GetScaleChangeOverLife(); - UpdateCurveValue(scale, valChangeOverLife, activeTime); } particle->SetScale(scale); } void RSRenderParticleEffector::UpdateSpin(const std::shared_ptr& particle, float deltaTime) { - auto spinUpdator = particle->GetSpinUpdator(); + if (particle == nullptr) { + return; + } auto spin = particle->GetSpin(); - if (spinUpdator == ParticleUpdator::RANDOM) { - auto spinSpeed = particle->GetSpinSpeed(); - spin += spinSpeed * deltaTime; - } else if (spinUpdator == ParticleUpdator::CURVE) { - int64_t activeTime = particle->GetActiveTime() / NS_PER_MS; - auto& valChangeOverLife = particle->GetSpinChangeOverLife(); - UpdateCurveValue(spin, valChangeOverLife, activeTime); + auto particleRenderParams = particle->GetParticleRenderParams(); + if (particleRenderParams != nullptr) { + auto spinUpdator = particleRenderParams->GetSpinUpdator(); + if (spinUpdator == ParticleUpdator::RANDOM) { + auto spinSpeed = particle->GetSpinSpeed(); + spin += spinSpeed * deltaTime; + } else if (spinUpdator == ParticleUpdator::CURVE) { + int64_t activeTime = particle->GetActiveTime() / NS_PER_MS; + auto& valChangeOverLife = particleRenderParams->GetSpinChangeOverLife(); + UpdateCurveValue(spin, valChangeOverLife, activeTime); + } } particle->SetSpin(spin); } @@ -179,15 +208,21 @@ void RSRenderParticleEffector::UpdateSpin(const std::shared_ptr& particle, float deltaTime) { + if (particle == nullptr) { + return; + } auto accelerationAngle = particle->GetAccelerationAngle(); - auto acceAngleUpdator = particle->GetAccelerationAngleUpdator(); - if (acceAngleUpdator == ParticleUpdator::RANDOM) { - float acceAngleSpeed = particle->GetAccelerationAngleSpeed(); - accelerationAngle += acceAngleSpeed * deltaTime; - } else if (acceAngleUpdator == ParticleUpdator::CURVE) { - int64_t activeTime = particle->GetActiveTime() / NS_PER_MS; - auto& valChangeOverLife = particle->GetAcceAngChangeOverLife(); - UpdateCurveValue(accelerationAngle, valChangeOverLife, activeTime); + auto particleRenderParams = particle->GetParticleRenderParams(); + if (particleRenderParams != nullptr) { + auto acceAngleUpdator = particleRenderParams->GetAccelerationAngleUpdator(); + if (acceAngleUpdator == ParticleUpdator::RANDOM) { + float acceAngleSpeed = particle->GetAccelerationAngleSpeed(); + accelerationAngle += acceAngleSpeed * deltaTime; + } else if (acceAngleUpdator == ParticleUpdator::CURVE) { + int64_t activeTime = particle->GetActiveTime() / NS_PER_MS; + auto& valChangeOverLife = particleRenderParams->GetAcceAngChangeOverLife(); + UpdateCurveValue(accelerationAngle, valChangeOverLife, activeTime); + } } particle->SetAccelerationAngle(accelerationAngle); } @@ -195,15 +230,21 @@ void RSRenderParticleEffector::UpdateAccelerationAngle( void RSRenderParticleEffector::UpdateAccelerationValue( const std::shared_ptr& particle, float deltaTime) { + if (particle == nullptr) { + return; + } auto accelerationValue = particle->GetAccelerationValue(); - auto acceValueUpdator = particle->GetAccelerationValueUpdator(); - if (acceValueUpdator == ParticleUpdator::RANDOM) { - float acceValueSpeed = particle->GetAccelerationValueSpeed(); - accelerationValue += acceValueSpeed * deltaTime; - } else if (acceValueUpdator == ParticleUpdator::CURVE) { - int64_t activeTime = particle->GetActiveTime() / NS_PER_MS; - auto& valChangeOverLife = particle->GetAcceValChangeOverLife(); - UpdateCurveValue(accelerationValue, valChangeOverLife, activeTime); + auto particleRenderParams = particle->GetParticleRenderParams(); + if (particleRenderParams != nullptr) { + auto acceValueUpdator = particleRenderParams->GetAccelerationValueUpdator(); + if (acceValueUpdator == ParticleUpdator::RANDOM) { + float acceValueSpeed = particle->GetAccelerationValueSpeed(); + accelerationValue += acceValueSpeed * deltaTime; + } else if (acceValueUpdator == ParticleUpdator::CURVE) { + int64_t activeTime = particle->GetActiveTime() / NS_PER_MS; + auto& valChangeOverLife = particleRenderParams->GetAcceValChangeOverLife(); + UpdateCurveValue(accelerationValue, valChangeOverLife, activeTime); + } } particle->SetAccelerationValue(accelerationValue); } @@ -211,6 +252,9 @@ void RSRenderParticleEffector::UpdateAccelerationValue( void RSRenderParticleEffector::UpdatePosition(const std::shared_ptr& particle, const std::shared_ptr& particleNoiseFields, float deltaTime) { + if (particle == nullptr) { + return; + } auto position = particle->GetPosition(); auto fieldForce = Vector2f(0.f, 0.f); if (particleNoiseFields != nullptr) { @@ -239,6 +283,9 @@ void RSRenderParticleEffector::UpdatePosition(const std::shared_ptr& particle, int64_t deltaTime) { + if (particle == nullptr) { + return; + } int64_t activeTime = particle->GetActiveTime(); activeTime += deltaTime; particle->SetActiveTime(activeTime); @@ -248,6 +295,9 @@ void RSRenderParticleEffector::UpdateActiveTime(const std::shared_ptr& particle, const std::shared_ptr& particleNoiseFields, int64_t deltaTime) { + if (particle == nullptr) { + return; + } float dt = static_cast(deltaTime) / NS_TO_S; UpdateAccelerationValue(particle, dt); UpdateAccelerationAngle(particle, dt); diff --git a/rosen/modules/render_service_base/src/animation/rs_render_particle_emitter.cpp b/rosen/modules/render_service_base/src/animation/rs_render_particle_emitter.cpp index 0ecb13266b..459fe3693f 100644 --- a/rosen/modules/render_service_base/src/animation/rs_render_particle_emitter.cpp +++ b/rosen/modules/render_service_base/src/animation/rs_render_particle_emitter.cpp @@ -28,6 +28,10 @@ RSRenderParticleEmitter::RSRenderParticleEmitter(std::shared_ptrGetParticleType(); auto opacityUpdater = particleParams_->GetOpacityUpdator(); auto scaleUpdater = particleParams_->GetScaleUpdator(); @@ -67,7 +71,7 @@ void RSRenderParticleEmitter::PreEmit() void RSRenderParticleEmitter::EmitParticle(int64_t deltaTime) { PreEmit(); - if (emitFinish_ == true) { + if (particleParams_ == nullptr || emitFinish_ == true) { return; } auto emitRate = std::min(particleParams_->GetEmitRate(), MAX_EMIT_RATE); diff --git a/rosen/modules/render_service_base/src/animation/rs_render_particle_system.cpp b/rosen/modules/render_service_base/src/animation/rs_render_particle_system.cpp index 705c22df36..c2525077c1 100644 --- a/rosen/modules/render_service_base/src/animation/rs_render_particle_system.cpp +++ b/rosen/modules/render_service_base/src/animation/rs_render_particle_system.cpp @@ -30,12 +30,14 @@ void RSRenderParticleSystem::CreateEmitter() size_t index = 0; for (size_t iter = 0; iter < particlesRenderParams_.size(); iter++) { auto& particleRenderParams = particlesRenderParams_[iter]; - if (particleRenderParams->GetParticleType() == ParticleType::IMAGES) { - particleRenderParams->SetImageIndex(index++); - auto& image = particleRenderParams->GetParticleImage(); - imageVector_.push_back(image); + if (particleRenderParams != nullptr) { + if (particleRenderParams->GetParticleType() == ParticleType::IMAGES) { + particleRenderParams->SetImageIndex(index++); + auto& image = particleRenderParams->GetParticleImage(); + imageVector_.push_back(image); + } + emitters_.push_back(std::make_shared(particleRenderParams)); } - emitters_.push_back(std::make_shared(particleRenderParams)); } } diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_marshalling_helper.cpp b/rosen/modules/render_service_base/src/platform/ohos/rs_marshalling_helper.cpp index 93a127f1f4..54aa6de21b 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_marshalling_helper.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_marshalling_helper.cpp @@ -573,7 +573,11 @@ bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, Drawing::Matrix& val) bool RSMarshallingHelper::Marshalling(Parcel& parcel, const std::shared_ptr& val) { - bool success = Marshalling(parcel, val->blurRadius_); + if (!val) { + ROSEN_LOGD("RSMarshallingHelper::Marshalling RSLinearGradientBlurPara is nullptr"); + return parcel.WriteInt32(-1); + } + bool success = parcel.WriteInt32(1) && Marshalling(parcel, val->blurRadius_); success = success && parcel.WriteUint32(static_cast(val->fractionStops_.size())); for (size_t i = 0; i < val->fractionStops_.size(); i++) { success = success && Marshalling(parcel, val->fractionStops_[i].first); @@ -585,6 +589,10 @@ bool RSMarshallingHelper::Marshalling(Parcel& parcel, const std::shared_ptr& val) { + if (parcel.ReadInt32() == -1) { + val = nullptr; + return true; + } float blurRadius; std::vector> fractionStops; GradientDirection direction = GradientDirection::NONE; @@ -645,7 +653,11 @@ bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, std::shared_ptr& val) { - bool success = Marshalling(parcel, val->emitterIndex_); + if (!val) { + ROSEN_LOGD("RSMarshallingHelper::Marshalling EmitterUpdater is nullptr"); + return parcel.WriteInt32(-1); + } + bool success = parcel.WriteInt32(1) && Marshalling(parcel, val->emitterIndex_); success = success && Marshalling(parcel, val->position_); success = success && Marshalling(parcel, val->emitSize_) ; success = success && Marshalling(parcel, val->emitRate_); @@ -654,6 +666,10 @@ bool RSMarshallingHelper::Marshalling(Parcel& parcel, const std::shared_ptr& val) { + if (parcel.ReadInt32() == -1) { + val = nullptr; + return true; + } int emitterIndex = 0; std::optional position = std::nullopt; std::optional emitSize = std::nullopt; @@ -699,7 +715,11 @@ bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, std::vector& val) { - bool success = Marshalling(parcel, val->fieldStrength_); + if (!val) { + ROSEN_LOGD("RSMarshallingHelper::Marshalling ParticleNoiseField is nullptr"); + return parcel.WriteInt32(-1); + } + bool success = parcel.WriteInt32(1) && Marshalling(parcel, val->fieldStrength_); success = success && Marshalling(parcel, val->fieldShape_); success = success && Marshalling(parcel, val->fieldSize_.x_) && Marshalling(parcel, val->fieldSize_.y_); success = success && Marshalling(parcel, val->fieldCenter_.x_) && Marshalling(parcel, val->fieldCenter_.y_); @@ -710,6 +730,10 @@ bool RSMarshallingHelper::Marshalling(Parcel& parcel, const std::shared_ptr& val) { + if (parcel.ReadInt32() == -1) { + val = nullptr; + return true; + } int fieldStrength = 0; ShapeType fieldShape = ShapeType::RECT; float fieldSizeX = 0.f; @@ -740,7 +764,11 @@ bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, std::shared_ptr& val) { - bool success = parcel.WriteUint32(static_cast(val->fields_.size())); + if (!val) { + ROSEN_LOGD("RSMarshallingHelper::Marshalling ParticleNoiseFields is nullptr"); + return parcel.WriteInt32(-1); + } + bool success = parcel.WriteInt32(1) && parcel.WriteUint32(static_cast(val->fields_.size())); for (size_t i = 0; i < val->fields_.size(); i++) { success = success && Marshalling(parcel, val->fields_[i]); } @@ -749,12 +777,20 @@ bool RSMarshallingHelper::Marshalling(Parcel& parcel, const std::shared_ptr& val) { + if (parcel.ReadInt32() == -1) { + val = nullptr; + return true; + } uint32_t size = parcel.ReadUint32(); bool success = true; if (size > PARTICLE_UPPER_LIMIT) { return false; } std::shared_ptr noiseFields = std::make_shared(); + if (!noiseFields) { + ROSEN_LOGE("RSMarshallingHelper::Unmarshalling Create ParticleNoiseFields fail"); + return false; + } for (size_t i = 0; i < size; i++) { std::shared_ptr ParticleNoiseField; success = success && Unmarshalling(parcel, ParticleNoiseField); @@ -859,6 +895,10 @@ bool RSMarshallingHelper::Marshalling(Parcel& parcel, const RenderParticleParaTy } else if (val.updator_ == ParticleUpdator::CURVE) { success = success && parcel.WriteUint32(static_cast(val.valChangeOverLife_.size())); for (size_t i = 0; i < val.valChangeOverLife_.size(); i++) { + if (val.valChangeOverLife_[i] == nullptr || val.valChangeOverLife_[i]->interpolator_ == nullptr) { + ROSEN_LOGE("RSMarshallingHelper::Unmarshalling RenderParticleParaType fail cause nullptr"); + return false; + } success = success && Marshalling(parcel, val.valChangeOverLife_[i]->fromValue_); success = success && Marshalling(parcel, val.valChangeOverLife_[i]->toValue_); success = success && Marshalling(parcel, val.valChangeOverLife_[i]->startMillis_); @@ -924,6 +964,10 @@ bool RSMarshallingHelper::Marshalling(Parcel& parcel, const RenderParticleColorP } else if (val.updator_ == ParticleUpdator::CURVE) { success = success && parcel.WriteUint32(static_cast(val.valChangeOverLife_.size())); for (size_t i = 0; i < val.valChangeOverLife_.size(); i++) { + if (val.valChangeOverLife_[i] == nullptr || val.valChangeOverLife_[i]->interpolator_ == nullptr) { + ROSEN_LOGE("RSMarshallingHelper::Unmarshalling RenderParticleColorParaType fail cause nullptr"); + return false; + } success = success && Marshalling(parcel, val.valChangeOverLife_[i]->fromValue_); success = success && Marshalling(parcel, val.valChangeOverLife_[i]->toValue_); success = success && Marshalling(parcel, val.valChangeOverLife_[i]->startMillis_); @@ -988,7 +1032,11 @@ bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, RenderParticleColorParaT bool RSMarshallingHelper::Marshalling(Parcel& parcel, const std::shared_ptr& val) { - bool success = Marshalling(parcel, val->emitterConfig_); + if (!val) { + ROSEN_LOGD("RSMarshallingHelper::Marshalling ParticleRenderParams is nullptr"); + return parcel.WriteInt32(-1); + } + bool success = parcel.WriteInt32(1) && Marshalling(parcel, val->emitterConfig_); success = success && Marshalling(parcel, val->velocity_); success = success && Marshalling(parcel, val->acceleration_.accelerationValue_); success = success && Marshalling(parcel, val->acceleration_.accelerationAngle_); @@ -1001,6 +1049,10 @@ bool RSMarshallingHelper::Marshalling(Parcel& parcel, const std::shared_ptr& val) { + if (parcel.ReadInt32() == -1) { + val = nullptr; + return true; + } EmitterConfig emitterConfig; ParticleVelocity velocity; RenderParticleParaType accelerationValue; diff --git a/rosen/modules/render_service_base/src/render/rs_particles_drawable.cpp b/rosen/modules/render_service_base/src/render/rs_particles_drawable.cpp index 6d4c88b24b..f8fd86d1d6 100644 --- a/rosen/modules/render_service_base/src/render/rs_particles_drawable.cpp +++ b/rosen/modules/render_service_base/src/render/rs_particles_drawable.cpp @@ -75,6 +75,9 @@ Drawing::RSXform RSParticlesDrawable::MakeRSXform(Vector2f center, Vector2f posi void RSParticlesDrawable::CaculatePointAtlsArry( const std::shared_ptr& particle, Vector2f position, float opacity, float scale) { + if (particle == nullptr) { + return; + } if (circleImage_ == nullptr) { circleImage_ = MakeCircleImage(DEFAULT_RADIUS); } @@ -92,18 +95,25 @@ void RSParticlesDrawable::CaculatePointAtlsArry( void RSParticlesDrawable::CaculateImageAtlsArry(Drawing::Canvas& canvas, const std::shared_ptr& particle, Vector2f position, float opacity, float scale) { - auto imageSize = particle->GetImageSize(); - auto spin = particle->GetSpin(); - auto imageIndex = particle->GetImageIndex(); + if (particle == nullptr) { + return; + } auto image = particle->GetImage(); + if (image == nullptr) { + return; + } auto pixelmap = image->GetPixelMap(); + if (pixelmap == nullptr) { + return; + } + auto imageIndex = particle->GetImageIndex(); if (imageIndex >= imageCount_) { return; } + auto imageSize = particle->GetImageSize(); + auto spin = particle->GetSpin(); float left = position.x_; float top = position.y_; - float right = position.x_ + imageSize.x_ * scale; - float bottom = position.y_ + imageSize.y_ * scale; float width = imageSize.x_; float height = imageSize.y_; RectF destRect(left, top, width, height); @@ -121,22 +131,41 @@ void RSParticlesDrawable::CaculateImageAtlsArry(Drawing::Canvas& canvas, imageColors_[imageIndex].push_back(Drawing::Color(color.AsArgbInt()).CastToColorQuad()); count_[imageIndex]++; } else { - canvas.Save(); - canvas.Translate(position.x_, position.y_); - canvas.Rotate(spin, imageSize.x_ * scale / DOUBLE, imageSize.y_ * scale / DOUBLE); - image->SetScale(scale); - image->SetImageRepeat(0); - Drawing::Rect rect { left, top, right, bottom }; - Drawing::Brush brush; - brush.SetAntiAlias(true); - brush.SetAlphaF(opacity); - canvas.AttachBrush(brush); - image->CanvasDrawImage(canvas, rect, Drawing::SamplingOptions(), false); - canvas.DetachBrush(); - canvas.Restore(); + DrawImageFill(canvas, particle, position, opacity, scale); } } +void RSParticlesDrawable::DrawImageFill(Drawing::Canvas& canvas, const std::shared_ptr& particle, + Vector2f position, float opacity, float scale) +{ + if (particle == nullptr) { + return; + } + auto image = particle->GetImage(); + if (image == nullptr) { + return; + } + auto imageSize = particle->GetImageSize(); + auto spin = particle->GetSpin(); + float left = position.x_; + float top = position.y_; + float right = position.x_ + imageSize.x_ * scale; + float bottom = position.y_ + imageSize.y_ * scale; + canvas.Save(); + canvas.Translate(position.x_, position.y_); + canvas.Rotate(spin, imageSize.x_ * scale / DOUBLE, imageSize.y_ * scale / DOUBLE); + image->SetScale(scale); + image->SetImageRepeat(0); + Drawing::Rect rect { left, top, right, bottom }; + Drawing::Brush brush; + brush.SetAntiAlias(true); + brush.SetAlphaF(opacity); + canvas.AttachBrush(brush); + image->CanvasDrawImage(canvas, rect, Drawing::SamplingOptions(), false); + canvas.DetachBrush(); + canvas.Restore(); +} + void RSParticlesDrawable::Draw(Drawing::Canvas& canvas, std::shared_ptr bounds) { if (particles_.empty()) { diff --git a/rosen/modules/render_service_client/core/ui/rs_node.cpp b/rosen/modules/render_service_client/core/ui/rs_node.cpp index ce157cfabf..6d4f00fc48 100755 --- a/rosen/modules/render_service_client/core/ui/rs_node.cpp +++ b/rosen/modules/render_service_client/core/ui/rs_node.cpp @@ -1007,8 +1007,14 @@ void RSNode::SetParticleParams(std::vector& particleParams, cons SetParticleDrawRegion(particleParams); auto property = std::make_shared(); + if (property == nullptr) { + return; + } auto propertyId = property->GetId(); auto uiAnimation = std::make_shared(); + if (uiAnimation == nullptr) { + return; + } auto animationId = uiAnimation->GetId(); AddAnimation(uiAnimation); if (finishCallback != nullptr) { diff --git a/rosen/test/render_service/render_service_base/unittest/animation/rs_render_particle_test.cpp b/rosen/test/render_service/render_service_base/unittest/animation/rs_render_particle_test.cpp index 873f580384..066391de7b 100644 --- a/rosen/test/render_service/render_service_base/unittest/animation/rs_render_particle_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/animation/rs_render_particle_test.cpp @@ -669,101 +669,16 @@ HWTEST_F(RSRenderParticleTest, GetParticleRenderParamsTest, Level1) ASSERT_EQ(res, res); } -/** - * @tc.name: GetAccelerationValueUpdatorTest - * @tc.desc: test results of GetAccelerationValueUpdator - * @tc.type: FUNC - */ -HWTEST_F(RSRenderParticleTest, GetAccelerationValueUpdatorTest, Level1) -{ - auto particleParams = std::make_shared(); - RSRenderParticle rsRenderParticle(particleParams); - ParticleUpdator part; - part = rsRenderParticle.GetAccelerationValueUpdator(); - ASSERT_EQ(part, part); -} - -/** - * @tc.name: GetAccelerationAngleUpdatorTest - * @tc.desc: test results of GetAccelerationAngleUpdator - * @tc.type: FUNC - */ -HWTEST_F(RSRenderParticleTest, GetAccelerationAngleUpdatorTest, Level1) -{ - auto particleParams = std::make_shared(); - RSRenderParticle rsRenderParticle(particleParams); - ParticleUpdator part; - part = rsRenderParticle.GetAccelerationAngleUpdator(); - ASSERT_EQ(part, part); -} - -/** - * @tc.name: GetColorUpdatorTest - * @tc.desc: test results of GetColorUpdator - * @tc.type: FUNC - */ -HWTEST_F(RSRenderParticleTest, GetColorUpdatorTest, Level1) -{ - auto particleParams = std::make_shared(); - RSRenderParticle rsRenderParticle(particleParams); - ParticleUpdator part; - part = rsRenderParticle.GetColorUpdator(); - ASSERT_EQ(part, part); -} - -/** - * @tc.name: GetOpacityUpdatorTest - * @tc.desc: test results of GetOpacityUpdator - * @tc.type: FUNC - */ -HWTEST_F(RSRenderParticleTest, GetOpacityUpdatorTest, Level1) -{ - auto particleParams = std::make_shared(); - RSRenderParticle rsRenderParticle(particleParams); - ParticleUpdator part; - part = rsRenderParticle.GetOpacityUpdator(); - ASSERT_EQ(part, part); -} - -/** - * @tc.name: GetScaleUpdatorTest - * @tc.desc: test results of GetScaleUpdator - * @tc.type: FUNC - */ -HWTEST_F(RSRenderParticleTest, GetScaleUpdatorTest, Level1) -{ - auto particleParams = std::make_shared(); - RSRenderParticle rsRenderParticle(particleParams); - ParticleUpdator part; - part = rsRenderParticle.GetScaleUpdator(); - ASSERT_EQ(part, part); -} - -/** - * @tc.name: GetSpinUpdatorTest - * @tc.desc: test results of GetSpinUpdator - * @tc.type: FUNC - */ -HWTEST_F(RSRenderParticleTest, GetSpinUpdatorTest, Level1) -{ - auto particleParams = std::make_shared(); - RSRenderParticle rsRenderParticle(particleParams); - ParticleUpdator part; - part = rsRenderParticle.GetSpinUpdator(); - ASSERT_EQ(part, part); -} - /** * @tc.name: GetAcceValChangeOverLifeTest * @tc.desc: test results of GetAcceValChangeOverLife * @tc.type: FUNC */ -HWTEST_F(RSRenderParticleTest, GetAcceValChangeOverLifeTest, Level1) +HWTEST_F(ParticleRenderParamsTest, GetAcceValChangeOverLifeTest, Level1) { - auto particleParams = std::make_shared(); - RSRenderParticle rsRenderParticle(particleParams); + ParticleRenderParams particleRenderParams; std::vector>> res; - res = rsRenderParticle.GetAcceValChangeOverLife(); + res = particleRenderParams.GetAcceValChangeOverLife(); ASSERT_EQ(res, res); } @@ -772,12 +687,11 @@ HWTEST_F(RSRenderParticleTest, GetAcceValChangeOverLifeTest, Level1) * @tc.desc: test results of GetAcceAngChangeOverLife * @tc.type: FUNC */ -HWTEST_F(RSRenderParticleTest, GetAcceAngChangeOverLifeTest, Level1) +HWTEST_F(ParticleRenderParamsTest, GetAcceAngChangeOverLifeTest, Level1) { - auto particleParams = std::make_shared(); - RSRenderParticle rsRenderParticle(particleParams); + ParticleRenderParams particleRenderParams; std::vector>> res; - res = rsRenderParticle.GetAcceAngChangeOverLife(); + res = particleRenderParams.GetAcceAngChangeOverLife(); ASSERT_EQ(res, res); } @@ -786,12 +700,11 @@ HWTEST_F(RSRenderParticleTest, GetAcceAngChangeOverLifeTest, Level1) * @tc.desc: test results of GetOpacityChangeOverLife * @tc.type: FUNC */ -HWTEST_F(RSRenderParticleTest, GetOpacityChangeOverLifeTest, Level1) +HWTEST_F(ParticleRenderParamsTest, GetOpacityChangeOverLifeTest, Level1) { - auto particleParams = std::make_shared(); - RSRenderParticle rsRenderParticle(particleParams); + ParticleRenderParams particleRenderParams; std::vector>> res; - res = rsRenderParticle.GetOpacityChangeOverLife(); + res = particleRenderParams.GetOpacityChangeOverLife(); ASSERT_EQ(res, res); } @@ -800,12 +713,11 @@ HWTEST_F(RSRenderParticleTest, GetOpacityChangeOverLifeTest, Level1) * @tc.desc: test results of GetScaleChangeOverLife * @tc.type: FUNC */ -HWTEST_F(RSRenderParticleTest, GetScaleChangeOverLifeTest, Level1) +HWTEST_F(ParticleRenderParamsTest, GetScaleChangeOverLifeTest, Level1) { - auto particleParams = std::make_shared(); - RSRenderParticle rsRenderParticle(particleParams); + ParticleRenderParams particleRenderParams; std::vector>> res; - res = rsRenderParticle.GetScaleChangeOverLife(); + res = particleRenderParams.GetScaleChangeOverLife(); ASSERT_EQ(res, res); } @@ -814,12 +726,11 @@ HWTEST_F(RSRenderParticleTest, GetScaleChangeOverLifeTest, Level1) * @tc.desc: test results of GetSpinChangeOverLife * @tc.type: FUNC */ -HWTEST_F(RSRenderParticleTest, GetSpinChangeOverLifeTest, Level1) +HWTEST_F(ParticleRenderParamsTest, GetSpinChangeOverLifeTest, Level1) { - auto particleParams = std::make_shared(); - RSRenderParticle rsRenderParticle(particleParams); + ParticleRenderParams particleRenderParams; std::vector>> res; - res = rsRenderParticle.GetSpinChangeOverLife(); + res = particleRenderParams.GetSpinChangeOverLife(); ASSERT_EQ(res, res); } @@ -828,12 +739,11 @@ HWTEST_F(RSRenderParticleTest, GetSpinChangeOverLifeTest, Level1) * @tc.desc: test results of GetColorChangeOverLife * @tc.type: FUNC */ -HWTEST_F(RSRenderParticleTest, GetColorChangeOverLifeTest, Level1) +HWTEST_F(ParticleRenderParamsTest, GetColorChangeOverLifeTest, Level1) { - auto particleParams = std::make_shared(); - RSRenderParticle rsRenderParticle(particleParams); + ParticleRenderParams particleRenderParams; std::vector>> res; - res = rsRenderParticle.GetColorChangeOverLife(); + res = particleRenderParams.GetColorChangeOverLife(); ASSERT_EQ(res, res); } From 0de96d8cd79ac1f99edcf8f014716bc64a42ce77 Mon Sep 17 00:00:00 2001 From: nobody2020 Date: Tue, 2 Jul 2024 20:57:18 +0800 Subject: [PATCH 169/247] Resize aot progress info text Signed-off-by: nobody2020 --- frameworks/bootanimation/src/boot_compile_progress.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/bootanimation/src/boot_compile_progress.cpp b/frameworks/bootanimation/src/boot_compile_progress.cpp index f26d1f3681..0c3f10e3ce 100644 --- a/frameworks/bootanimation/src/boot_compile_progress.cpp +++ b/frameworks/bootanimation/src/boot_compile_progress.cpp @@ -46,7 +46,7 @@ namespace { constexpr const float OFFSET_Y_PERCENT = 0.85f; constexpr const float HEIGHT_PERCENT = 0.05f; constexpr const int TEXT_BLOB_OFFSET = 5; - constexpr const int FONT_SIZE = 48; + constexpr const int FONT_SIZE = 40; constexpr const int32_t MAX_RETRY_TIMES = 5; constexpr const int32_t WAIT_MS = 500; constexpr const int32_t WAITING_BMS_TIMEOUT = 30; From e00d12088c5fd0c1fcbd8a77d8104870887bbdd8 Mon Sep 17 00:00:00 2001 From: yangfan479 Date: Mon, 1 Jul 2024 22:13:55 +0800 Subject: [PATCH 170/247] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangfan479 --- .../rs_display_render_node_drawable.cpp | 10 ++- .../parallel_render/rs_sub_thread.cpp | 17 ++++- .../core/pipeline/rs_base_render_engine.cpp | 2 + .../core/pipeline/rs_base_render_engine.h | 1 + .../core/pipeline/rs_main_thread.cpp | 62 ++++++++++++++----- .../core/pipeline/rs_uifirst_manager.cpp | 4 +- .../core/pipeline/rs_uni_render_engine.cpp | 3 + .../core/pipeline/rs_uni_render_engine.h | 4 +- .../core/pipeline/rs_uni_render_util.cpp | 34 +++++----- .../core/pipeline/rs_uni_render_visitor.cpp | 14 ++++- .../core/pipeline/rs_vk_image_manager.cpp | 8 +++ .../src/pipeline/rs_render_node.cpp | 4 +- .../property/rs_color_picker_cache_task.cpp | 4 +- 13 files changed, 120 insertions(+), 47 deletions(-) diff --git a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp index a17bc142d9..41100d8de3 100644 --- a/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_display_render_node_drawable.cpp @@ -202,7 +202,7 @@ static std::vector MergeDirtyHistoryInVirtual(RSDisplayRenderNode& displa { auto params = static_cast(displayNode.GetRenderParams().get()); auto& renderThreadParams = RSUniRenderThread::Instance().GetRSRenderThreadParams(); - if (!renderThreadParams) { + if (!renderThreadParams || !params) { return {}; } auto& curAllSurfaceDrawables = params->GetAllMainAndLeashSurfaceDrawables(); @@ -1278,6 +1278,10 @@ void RSDisplayRenderNodeDrawable::DrawHardwareEnabledNodes(Drawing::Canvas& canv void RSDisplayRenderNodeDrawable::SwitchColorFilter(RSPaintFilterCanvas& canvas) const { const auto& renderEngine = RSUniRenderThread::Instance().GetRenderEngine(); + if (!renderEngine) { + RS_LOGE("RSDisplayRenderNodeDrawable::SwitchColorFilter renderEngine is null"); + return; + } ColorFilterMode colorFilterMode = renderEngine->GetColorFilterMode(); if (colorFilterMode == ColorFilterMode::INVERT_COLOR_DISABLE_MODE || colorFilterMode >= ColorFilterMode::DALTONIZATION_NORMAL_MODE) { @@ -1307,7 +1311,9 @@ void RSDisplayRenderNodeDrawable::SwitchColorFilter(RSPaintFilterCanvas& canvas) void RSDisplayRenderNodeDrawable::SetHighContrastIfEnabled(RSPaintFilterCanvas& canvas) const { const auto& renderEngine = RSUniRenderThread::Instance().GetRenderEngine(); - canvas.SetHighContrast(renderEngine->IsHighContrastEnabled()); + if (renderEngine) { + canvas.SetHighContrast(renderEngine->IsHighContrastEnabled()); + } } void RSDisplayRenderNodeDrawable::FindHardwareEnabledNodes() diff --git a/rosen/modules/render_service/core/pipeline/parallel_render/rs_sub_thread.cpp b/rosen/modules/render_service/core/pipeline/parallel_render/rs_sub_thread.cpp index d185db84b6..c343e1a3d1 100644 --- a/rosen/modules/render_service/core/pipeline/parallel_render/rs_sub_thread.cpp +++ b/rosen/modules/render_service/core/pipeline/parallel_render/rs_sub_thread.cpp @@ -152,9 +152,12 @@ void RSSubThread::DestroyShareEglContext() void RSSubThread::RenderCache(const std::shared_ptr& threadTask) { RS_TRACE_NAME("RSSubThread::RenderCache"); - if (threadTask == nullptr || threadTask->GetTaskSize() == 0) { - RS_LOGE("RSSubThread::RenderCache threadTask == nullptr %p || threadTask->GetTaskSize() == 0 %d", - threadTask.get(), int(threadTask->GetTaskSize())); + if (threadTask == nullptr) { + RS_LOGE("RSSubThread::RenderCache threadTask is nullptr"); + return; + } + if (threadTask->GetTaskSize() == 0) { + RS_LOGE("RSSubThread::RenderCache no task"); return; } if (grContext_ == nullptr) { @@ -322,6 +325,10 @@ std::shared_ptr RSSubThread::CreateShareGrContext() void RSSubThread::DrawableCacheWithSkImage(DrawableV2::RSSurfaceRenderNodeDrawable* nodeDrawable) { + if (!nodeDrawable) { + RS_LOGE("RSSubThread::DrawableCacheWithSkImage nodeDrawable is nullptr"); + return; + } auto cacheSurface = nodeDrawable->GetCacheSurface(threadIndex_, true); if (!cacheSurface || nodeDrawable->NeedInitCacheSurface()) { DrawableV2::RSSurfaceRenderNodeDrawable::ClearCacheSurfaceFunc func = std::bind( @@ -362,6 +369,10 @@ void RSSubThread::DrawableCacheWithSkImage(DrawableV2::RSSurfaceRenderNodeDrawab void RSSubThread::DrawableCacheWithDma(DrawableV2::RSSurfaceRenderNodeDrawable* nodeDrawable) { RS_TRACE_NAME("DrawableCacheWithDma"); + if (!nodeDrawable) { + RS_LOGE("RSSubThread::DrawableCache nodeDrawable is nullptr"); + return; + } if (!nodeDrawable->IsSurfaceCreated()) { nodeDrawable->CreateSurface(); } diff --git a/rosen/modules/render_service/core/pipeline/rs_base_render_engine.cpp b/rosen/modules/render_service/core/pipeline/rs_base_render_engine.cpp index 3ea274c805..de3e09c1c5 100644 --- a/rosen/modules/render_service/core/pipeline/rs_base_render_engine.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_base_render_engine.cpp @@ -478,6 +478,7 @@ void RSBaseRenderEngine::DrawDisplayNodeWithParams(RSPaintFilterCanvas& canvas, void RSBaseRenderEngine::SetColorFilterMode(ColorFilterMode mode) { + std::lock_guard lock(colorFilterMutex_); uint32_t uMode = static_cast(mode); uint32_t uInvertMode = static_cast(ColorFilterMode::INVERT_COLOR_ENABLE_MODE); uint32_t ucolorFilterMode = static_cast(colorFilterMode_); @@ -532,6 +533,7 @@ void RSBaseRenderEngine::SetColorFilterMode(ColorFilterMode mode) ColorFilterMode RSBaseRenderEngine::GetColorFilterMode() { + std::lock_guard lock(colorFilterMutex_); return colorFilterMode_; } diff --git a/rosen/modules/render_service/core/pipeline/rs_base_render_engine.h b/rosen/modules/render_service/core/pipeline/rs_base_render_engine.h index 01b02a00d2..b17858a34d 100644 --- a/rosen/modules/render_service/core/pipeline/rs_base_render_engine.h +++ b/rosen/modules/render_service/core/pipeline/rs_base_render_engine.h @@ -258,6 +258,7 @@ public: protected: void DrawImage(RSPaintFilterCanvas& canvas, BufferDrawParam& params); + static inline std::mutex colorFilterMutex_; static inline ColorFilterMode colorFilterMode_ = ColorFilterMode::COLOR_FILTER_END; private: diff --git a/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp b/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp index d8b1436a20..8e58ddac31 100644 --- a/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp @@ -750,6 +750,10 @@ void RSMainThread::SubScribeSystemAbility() std::string strTid = std::to_string(gettid()); saStatusChangeListener_ = new (std::nothrow)VSyncSystemAbilityListener(threadName, strUid, strPid, strTid); + if (saStatusChangeListener_ == nullptr) { + RS_LOGE("RSMainThread::SubScribeSystemAbility new VSyncSystemAbilityListener failed"); + return; + } int32_t ret = systemAbilityManager->SubscribeSystemAbility(RES_SCHED_SYS_ABILITY_ID, saStatusChangeListener_); if (ret != ERR_OK) { RS_LOGE("%{public}s subscribe system ability %{public}d failed.", __func__, RES_SCHED_SYS_ABILITY_ID); @@ -1246,7 +1250,7 @@ void RSMainThread::ConsumeAndUpdateAllNodes() surfaceNode->SetContentDirty(); doDirectComposition_ = false; RS_OPTIONAL_TRACE_NAME_FMT( - "rs debug: name %s, id %llu, buffer consumed and not HardwareEnabledType", + "rs debug: name %s, id %" PRIu64", buffer consumed and not HardwareEnabledType", surfaceNode->GetName().c_str(), surfaceNode->GetId()); } if (isUniRender_ && surfaceNode->IsCurrentFrameBufferConsumed()) { @@ -1254,7 +1258,7 @@ void RSMainThread::ConsumeAndUpdateAllNodes() surfaceNode->GetPreBuffer().buffer); if (surfaceNode->GetBufferSizeChanged()) { doDirectComposition_ = false; - RS_OPTIONAL_TRACE_NAME_FMT("rs debug: name %s, id %llu, surfaceNode buffer size changed", + RS_OPTIONAL_TRACE_NAME_FMT("rs debug: name %s, id %" PRIu64", surfaceNode buffer size changed", surfaceNode->GetName().c_str(), surfaceNode->GetId()); } } @@ -1264,7 +1268,7 @@ void RSMainThread::ConsumeAndUpdateAllNodes() " SetContentDirty for UIFirst assigning to subthread"); surfaceNode->SetContentDirty(); doDirectComposition_ = false; - RS_OPTIONAL_TRACE_NAME_FMT("rs debug: name %s, id %llu, pc uifirst on", + RS_OPTIONAL_TRACE_NAME_FMT("rs debug: name %s, id %" PRIu64", pc uifirst on", surfaceNode->GetName().c_str(), surfaceNode->GetId()); } } @@ -1300,6 +1304,9 @@ void RSMainThread::ConsumeAndUpdateAllNodes() bool RSMainThread::CheckSubThreadNodeStatusIsDoing(NodeId appNodeId) const { for (auto& node : subThreadNodes_) { + if (node == nullptr) { + continue; + } if (node->GetCacheSurfaceProcessedStatus() != CacheProcessStatus::DOING) { continue; } @@ -1334,7 +1341,7 @@ void RSMainThread::CollectInfoForHardwareComposer() if (!surfaceNode->GetDoDirectComposition()) { doDirectComposition_ = false; - RS_OPTIONAL_TRACE_NAME_FMT("rs debug: name %s, id %llu, node GetDoDirectComposition is false", + RS_OPTIONAL_TRACE_NAME_FMT("rs debug: name %s, id %" PRIu64", node GetDoDirectComposition is false", surfaceNode->GetName().c_str(), surfaceNode->GetId()); surfaceNode->SetDoDirectComposition(true); } @@ -1343,8 +1350,8 @@ void RSMainThread::CollectInfoForHardwareComposer() if (surfaceNode->IsCurrentFrameBufferConsumed()) { surfaceNode->UpdateHardwareDisabledState(true); doDirectComposition_ = false; - RS_OPTIONAL_TRACE_NAME_FMT("rs debug: name %s, id %llu, node not on the tree and buffer consumed", - surfaceNode->GetName().c_str(), surfaceNode->GetId()); + RS_OPTIONAL_TRACE_NAME_FMT("rs debug: name %s, id %" PRIu64", node not on the tree " + "and buffer consumed", surfaceNode->GetName().c_str(), surfaceNode->GetId()); } return; } @@ -1381,7 +1388,7 @@ void RSMainThread::CollectInfoForHardwareComposer() surfaceNode->SetContentDirty(); doDirectComposition_ = false; RS_OPTIONAL_TRACE_NAME_FMT( - "rs debug: name %s, id %llu, isLastFrameHwcEnabled not enabled and buffer consumed", + "rs debug: name %s, id %" PRIu64", isLastFrameHwcEnabled not enabled and buffer consumed", surfaceNode->GetName().c_str(), surfaceNode->GetId()); } else { if (surfaceNode->GetAncoForceDoDirect()) { @@ -1396,7 +1403,7 @@ void RSMainThread::CollectInfoForHardwareComposer() surfaceNode->SetContentDirty(); surfaceNode->SetHwcDelayDirtyFlag(false); doDirectComposition_ = false; - RS_OPTIONAL_TRACE_NAME_FMT("rs debug: name %s, id %llu, HwcDelayDirtyFlag is true", + RS_OPTIONAL_TRACE_NAME_FMT("rs debug: name %s, id %" PRIu64", HwcDelayDirtyFlag is true", surfaceNode->GetName().c_str(), surfaceNode->GetId()); } } @@ -1410,6 +1417,9 @@ void RSMainThread::CollectInfoForHardwareComposer() bool RSMainThread::IsLastFrameUIFirstEnabled(NodeId appNodeId) const { for (auto& node : subThreadNodes_) { + if (node == nullptr) { + continue; + } if (node->IsAppWindow()) { if (node->GetId() == appNodeId) { return true; @@ -1432,7 +1442,11 @@ void RSMainThread::CheckIfHardwareForcedDisabled() bool hasColorFilter = colorFilterMode >= ColorFilterMode::INVERT_COLOR_ENABLE_MODE && colorFilterMode <= ColorFilterMode::INVERT_DALTONIZATION_TRITANOMALY_MODE; std::shared_ptr rootNode = context_->GetGlobalRootRenderNode(); - bool isMultiDisplay = rootNode && rootNode->GetChildrenCount() > 1; + if (rootNode == nullptr) { + RS_LOGE("RSMainThread::CheckIfHardwareForcedDisabled rootNode is nullptr"); + return; + } + bool isMultiDisplay = rootNode->GetChildrenCount() > 1; // check all children of global root node, and only disable hardware composer // in case node's composite type is UNI_RENDER_EXPAND_COMPOSITE @@ -1588,7 +1602,7 @@ bool RSMainThread::WaitUntilDisplayNodeBufferReleased(RSDisplayRenderNode& node) { std::unique_lock lock(displayNodeBufferReleasedMutex_); displayNodeBufferReleased_ = false; // prevent spurious wakeup of condition variable - if (node.GetConsumer()->QueryIfBufferAvailable()) { + if (node.GetConsumer() != nullptr && node.GetConsumer()->QueryIfBufferAvailable()) { return true; } return displayNodeBufferReleasedCond_.wait_until(lock, std::chrono::system_clock::now() + @@ -1699,7 +1713,7 @@ void RSMainThread::ProcessHgmFrameRate(uint64_t timestamp) rsFrameRateLinker_->SetExpectedRange(rsCurrRange_); RS_TRACE_NAME_FMT("rsCurrRange = (%d, %d, %d)", rsCurrRange_.min_, rsCurrRange_.max_, rsCurrRange_.preferred_); } - if (!frameRateMgr_) { + if (!frameRateMgr_ || !rsVSyncDistributor_) { return; } DvsyncInfo info; @@ -1726,8 +1740,10 @@ bool RSMainThread::GetParallelCompositionEnabled() void RSMainThread::SetFrameIsRender(bool isRender) { - markRenderFlag_ = true; - rsVSyncDistributor_->SetFrameIsRender(isRender); + if (rsVSyncDistributor_ != nullptr) { + markRenderFlag_ = true; + rsVSyncDistributor_->SetFrameIsRender(isRender); + } } void RSMainThread::ColorPickerRequestVsyncIfNeed() @@ -1923,6 +1939,10 @@ bool RSMainThread::DoDirectComposition(std::shared_ptr rootNod return false; } sptr screenManager = CreateOrGetScreenManager(); + if (screenManager == nullptr) { + RS_LOGE("RSMainThread::DoDirectComposition screenManager is nullptr"); + return false; + } auto screenInfo = screenManager->QueryScreenInfo(displayNode->GetScreenId()); if (screenInfo.state != ScreenState::HDI_OUTPUT_ENABLE) { RS_LOGE("RSMainThread::DoDirectComposition: ScreenState error!"); @@ -3564,11 +3584,15 @@ void RSMainThread::UpdateRogSizeIfNeeded() auto child = rootNode->GetFirstChild(); if (child != nullptr && child->IsInstanceOf()) { auto displayNode = child->ReinterpretCastTo(); - if (displayNode) { - auto screenManager_ = CreateOrGetScreenManager(); - screenManager_->SetRogScreenResolution( - displayNode->GetScreenId(), displayNode->GetRogWidth(), displayNode->GetRogHeight()); + if (displayNode == nullptr) { + return; } + auto screenManager_ = CreateOrGetScreenManager(); + if (screenManager_ == nullptr) { + return; + } + screenManager_->SetRogScreenResolution( + displayNode->GetScreenId(), displayNode->GetRogWidth(), displayNode->GetRogHeight()); } } @@ -3612,6 +3636,10 @@ void RSMainThread::UpdateUIFirstSwitch() return; } auto screenManager_ = CreateOrGetScreenManager(); + if (!screenManager_) { + RSUifirstManager::Instance().SetUiFirstSwitch(isUiFirstOn_); + return; + } uint32_t actualScreensNum = screenManager_->GetActualScreensNum(); if (deviceType_ != DeviceType::PC) { if (hasProtectedLayer_) { diff --git a/rosen/modules/render_service/core/pipeline/rs_uifirst_manager.cpp b/rosen/modules/render_service/core/pipeline/rs_uifirst_manager.cpp index 74e8e9d280..53104e5a50 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uifirst_manager.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uifirst_manager.cpp @@ -364,11 +364,11 @@ void RSUifirstManager::DoPurgePendingPostNodes(std::unordered_map(drawable->GetRenderParams().get()); - if (!surfaceParams) { + auto node = it->second; + if (!surfaceParams || !node) { ++it; continue; } - auto node = it->second; bool staticContent = node->GetLastFrameUifirstFlag() == MultiThreadCacheType::ARKTS_CARD ? node->GetForceUpdateByUifirst() : drawable->IsCurFrameStatic(deviceType); if (drawable->HasCachedTexture() && (staticContent || CheckVisibleDirtyRegionIsEmpty(node)) && diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_engine.cpp b/rosen/modules/render_service/core/pipeline/rs_uni_render_engine.cpp index 6cbbc4e17f..0301b42e17 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_engine.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_engine.cpp @@ -51,6 +51,9 @@ GraphicColorGamut RSUniRenderEngine::ComputeTargetColorGamut(const std::vectorGetBuffer(); if (buffer == nullptr) { RS_LOGW("RSUniRenderEngine::ComputeTargetColorGamut The buffer of layer is nullptr"); diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_engine.h b/rosen/modules/render_service/core/pipeline/rs_uni_render_engine.h index dfdd81abd9..fa7b6b601d 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_engine.h +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_engine.h @@ -31,13 +31,13 @@ public: PreProcessFunc preProcess, PostProcessFunc postProcess) override; void DrawLayers(RSPaintFilterCanvas& canvas, const std::vector& layers, bool forceCPU, const ScreenInfo& screenInfo = {}) override; - void DrawHdiLayerWithParams(RSPaintFilterCanvas& canvas, const LayerInfoPtr& layer, - BufferDrawParam& params); void DrawUIFirstCacheWithParams(RSPaintFilterCanvas& canvas, BufferDrawParam& params) override; private: #ifdef USE_VIDEO_PROCESSING_ENGINE GraphicColorGamut ComputeTargetColorGamut(const std::vector& layers); #endif + void DrawHdiLayerWithParams(RSPaintFilterCanvas& canvas, const LayerInfoPtr& layer, + BufferDrawParam& params); }; } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_util.cpp b/rosen/modules/render_service/core/pipeline/rs_uni_render_util.cpp index 80937b2a83..2d8c64a06a 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_util.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_util.cpp @@ -59,15 +59,10 @@ void RSUniRenderUtil::MergeDirtyHistory(std::shared_ptr& no bool useAlignedDirtyRegion, bool renderParallel) { auto params = static_cast(node->GetRenderParams().get()); - if (!params && renderParallel) { - RS_LOGE("RSUniRenderUtil::MergeDirtyHistory params is nullptr"); - return; - } - - if (!renderParallel) { - MergeDirtyHistoryForNode(node, bufferAge, params, useAlignedDirtyRegion); - } else { + if (renderParallel) { MergeDirtyHistoryForDrawable(node, bufferAge, params, useAlignedDirtyRegion); + } else { + MergeDirtyHistoryForNode(node, bufferAge, params, useAlignedDirtyRegion); } } @@ -82,7 +77,8 @@ void RSUniRenderUtil::MergeDirtyHistoryForNode(std::shared_ptrIsAppWindow()) { continue; } - RS_OPTIONAL_TRACE_NAME_FMT("RSUniRenderUtil::MergeDirtyHistory for surfaceNode %lu", surfaceNode->GetId()); + RS_OPTIONAL_TRACE_NAME_FMT("RSUniRenderUtil::MergeDirtyHistory for surfaceNode %" PRIu64"", + surfaceNode->GetId()); auto surfaceDirtyManager = surfaceNode->GetDirtyManager(); if (!surfaceDirtyManager->SetBufferAge(bufferAge)) { ROSEN_LOGE("RSUniRenderUtil::MergeDirtyHistory with invalid buffer age %{public}d", bufferAge); @@ -98,6 +94,10 @@ void RSUniRenderUtil::MergeDirtyHistoryForNode(std::shared_ptr& node, int32_t bufferAge, RSDisplayRenderParams* params, bool useAlignedDirtyRegion) { + if (!params) { + RS_LOGE("RSUniRenderUtil::MergeDirtyHistoryForDrawable params is nullptr"); + return; + } auto& curAllSurfaceDrawables = params->GetAllMainAndLeashSurfaceDrawables(); // update all child surfacenode history for (auto it = curAllSurfaceDrawables.rbegin(); it != curAllSurfaceDrawables.rend(); ++it) { @@ -109,7 +109,8 @@ void RSUniRenderUtil::MergeDirtyHistoryForDrawable(std::shared_ptrIsAppWindow()) { continue; } - RS_OPTIONAL_TRACE_NAME_FMT("RSUniRenderUtil::MergeDirtyHistory for surfaceNode %lu", surfaceParams->GetId()); + RS_OPTIONAL_TRACE_NAME_FMT("RSUniRenderUtil::MergeDirtyHistory for surfaceNode %" PRIu64"", + surfaceParams->GetId()); auto surfaceDirtyManager = surfaceNodeDrawable->GetSyncDirtyManager(); if (!surfaceDirtyManager) { continue; @@ -245,8 +246,9 @@ void RSUniRenderUtil::SetAllSurfaceGlobalDityRegion( void RSUniRenderUtil::MergeDirtyHistoryInVirtual(RSDisplayRenderNode& displayNode, int32_t bufferAge, bool renderParallel) { + (void)renderParallel; auto params = static_cast(displayNode.GetRenderParams().get()); - if (!params && renderParallel) { + if (!params) { RS_LOGE("RSUniRenderUtil::MergeDirtyHistory params is nullptr"); return; } @@ -260,7 +262,8 @@ void RSUniRenderUtil::MergeDirtyHistoryInVirtual(RSDisplayRenderNode& displayNod if (surfaceParams == nullptr || !surfaceParams->IsAppWindow()) { continue; } - RS_OPTIONAL_TRACE_NAME_FMT("RSUniRenderUtil::MergeDirtyHistory for surfaceNode %lu", surfaceParams->GetId()); + RS_OPTIONAL_TRACE_NAME_FMT("RSUniRenderUtil::MergeDirtyHistory for surfaceNode %" PRIu64"", + surfaceParams->GetId()); auto surfaceDirtyManager = surfaceNodeDrawable->GetSyncDirtyManager(); if (!surfaceDirtyManager) { continue; @@ -810,7 +813,7 @@ bool RSUniRenderUtil::IsNodeAssignSubThread(std::shared_ptr if (deviceType != DeviceType::PC && node->IsLeashWindow()) { isNeedAssignToSubThread = (node->IsScale() || node->IsScaleInPreFrame() || ROSEN_EQ(node->GetGlobalAlpha(), 0.0f) || node->GetForceUIFirst()) && !node->HasFilter(); - RS_TRACE_NAME_FMT("Assign info: name[%s] id[%lu]" + RS_TRACE_NAME_FMT("Assign info: name[%s] id[%" PRIu64"]" " status:%d filter:%d isScale:%d isScalePreFrame:%d forceUIFirst:%d isNeedAssign:%d", node->GetName().c_str(), node->GetId(), node->GetCacheSurfaceProcessedStatus(), node->HasFilter(), node->IsScale(), node->IsScaleInPreFrame(), node->GetForceUIFirst(), isNeedAssignToSubThread); @@ -900,8 +903,8 @@ void RSUniRenderUtil::AssignMainThreadNode(std::listGetDeviceType() == DeviceType::PC) { - RS_TRACE_NAME_FMT("AssignMainThread: name: %s, id: %lu, [HasTransparentSurface: %d, ChildHasVisibleFilter: %d," - "HasFilter: %d, QueryIfAllHwcChildrenForceDisabledByFilter: %d]", + RS_TRACE_NAME_FMT("AssignMainThread: name: %s, id: %" PRIu64", [HasTransparentSurface: %d, " + "ChildHasVisibleFilter: %d, HasFilter: %d, QueryIfAllHwcChildrenForceDisabledByFilter: %d]", node->GetName().c_str(), node->GetId(), node->GetHasTransparentSurface(), node->ChildHasVisibleFilter(), node->HasFilter(), node->QueryIfAllHwcChildrenForceDisabledByFilter()); @@ -1628,7 +1631,6 @@ void RSUniRenderUtil::OptimizedFlushAndSubmit(std::shared_ptr& semaphoreInfo.flags = 0; VkSemaphore semaphore; vkContext.vkCreateSemaphore(vkContext.GetDevice(), &semaphoreInfo, nullptr, &semaphore); - RS_TRACE_NAME_FMT("VkSemaphore %p", semaphore); GrBackendSemaphore backendSemaphore; backendSemaphore.initVulkan(semaphore); diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp index abeb4975e6..db61706d29 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_visitor.cpp @@ -1410,6 +1410,10 @@ void RSUniRenderVisitor::UpdateNodeVisibleRegion(RSSurfaceRenderNode& node) void RSUniRenderVisitor::CalculateOcclusion(RSSurfaceRenderNode& node) { + if (!curDisplayNode_) { + RS_LOGE("RSUniRenderVisitor::CalculateOcclusion curDisplayNode is nullptr"); + return; + } // CheckAndUpdateOpaqueRegion only in mainWindow auto parent = RSBaseRenderNode::ReinterpretCast(node.GetParent().lock()); auto isFocused = node.IsFocusedNode(currentFocusedNodeId_) || @@ -2141,6 +2145,10 @@ void RSUniRenderVisitor::UpdateSurfaceDirtyAndGlobalDirty() std::for_each(curMainAndLeashSurfaces.rbegin(), curMainAndLeashSurfaces.rend(), [this, &accumulatedDirtyRegion, &hasMainAndLeashSurfaceDirty](RSBaseRenderNode::SharedPtr& nodePtr) { auto surfaceNode = RSBaseRenderNode::ReinterpretCast(nodePtr); + if (!surfaceNode) { + RS_LOGE("RSUniRenderVisitor::UpdateSurfaceDirtyAndGlobalDirty surfaceNode is nullptr"); + return; + } auto dirtyManager = surfaceNode->GetDirtyManager(); RSMainThread::Instance()->GetContext().AddPendingSyncNode(nodePtr); // 0. update hwc node dirty region and create layer @@ -2148,7 +2156,7 @@ void RSUniRenderVisitor::UpdateSurfaceDirtyAndGlobalDirty() // 1. calculate abs dirtyrect and update partialRenderParams // currently only sync visible region info surfaceNode->UpdatePartialRenderParams(); - if (dirtyManager->IsCurrentFrameDirty()) { + if (dirtyManager && dirtyManager->IsCurrentFrameDirty()) { hasMainAndLeashSurfaceDirty = true; } // 2. check surface node dirtyrect need merge into displayDirtyManager @@ -6207,6 +6215,10 @@ void RSUniRenderVisitor::ScaleMirrorIfNeed(RSDisplayRenderNode& node, bool canva { auto screenManager = CreateOrGetScreenManager(); auto mirrorNode = node.GetMirrorSource().lock(); + if (!screenManager || !mirrorNode) { + RS_LOGE("RSUniRenderVisitor::ScaleMirrorIfNeed screenManager or mirrorNode is nullptr"); + return; + } auto mainScreenInfo = screenManager->QueryScreenInfo(mirrorNode->GetScreenId()); auto mainWidth = static_cast(mainScreenInfo.width); auto mainHeight = static_cast(mainScreenInfo.height); diff --git a/rosen/modules/render_service/core/pipeline/rs_vk_image_manager.cpp b/rosen/modules/render_service/core/pipeline/rs_vk_image_manager.cpp index 333248e5a1..4c12efeb8f 100644 --- a/rosen/modules/render_service/core/pipeline/rs_vk_image_manager.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_vk_image_manager.cpp @@ -46,6 +46,10 @@ NativeVkImageRes::~NativeVkImageRes() std::shared_ptr NativeVkImageRes::Create(sptr buffer) { + if (buffer == nullptr) { + ROSEN_LOGE("NativeVkImageRes::Create buffer is nullptr"); + return nullptr; + } auto width = buffer->GetSurfaceBufferWidth(); auto height = buffer->GetSurfaceBufferHeight(); NativeWindowBuffer* nativeWindowBuffer = CreateNativeWindowBufferFromSurfaceBuffer(&buffer); @@ -69,6 +73,10 @@ std::shared_ptr RSVkImageManager::MapVkImageFromSurfaceBuffer( const sptr& acquireFence, pid_t threadIndex) { + if (buffer == nullptr) { + ROSEN_LOGE("RSVkImageManager::MapVkImageFromSurfaceBuffer buffer is nullptr"); + return nullptr; + } WaitAcquireFence(acquireFence); std::lock_guard lock(opMutex_); auto bufferId = buffer->GetSeqNum(); diff --git a/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp b/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp index 6462384651..ca93d54671 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_render_node.cpp @@ -1310,8 +1310,8 @@ bool RSRenderNode::UpdateDrawRectAndDirtyRegion(RSDirtyRegionManager& dirtyManag // currently CheckAndUpdateGeoTrans without dirty check auto& geoPtr = properties.boundsGeo_; // selfdrawing node's geo may not dirty when its dirty region changes - if (CheckAndUpdateGeoTrans(geoPtr) || accumGeoDirty || properties.geoDirty_ || isSelfDrawingNode_ || - selfDrawRectChanged) { + if (geoPtr && (CheckAndUpdateGeoTrans(geoPtr) || accumGeoDirty || properties.geoDirty_ || + isSelfDrawingNode_ || selfDrawRectChanged)) { absDrawRect_ = geoPtr->MapAbsRect(selfDrawRect_); if (isSelfDrawingNode_) { selfDrawingNodeAbsDirtyRect_ = geoPtr->MapAbsRect(selfDrawingNodeDirtyRect_); diff --git a/rosen/modules/render_service_base/src/property/rs_color_picker_cache_task.cpp b/rosen/modules/render_service_base/src/property/rs_color_picker_cache_task.cpp index a61172f0b0..00b4d078a6 100644 --- a/rosen/modules/render_service_base/src/property/rs_color_picker_cache_task.cpp +++ b/rosen/modules/render_service_base/src/property/rs_color_picker_cache_task.cpp @@ -146,8 +146,8 @@ bool RSColorPickerCacheTask::GpuScaleImage(std::shared_ptr bool RSColorPickerCacheTask::Render() { - RS_TRACE_NAME_FMT("RSColorPickerCacheTask::Render:%p", this); - ROSEN_LOGD("RSColorPickerCacheTask::Render:%{public}p", this); + RS_TRACE_NAME_FMT("RSColorPickerCacheTask::Render"); + ROSEN_LOGD("RSColorPickerCacheTask::Render"); if (cacheSurface_ == nullptr) { SetStatus(CacheProcessStatus::WAITING); ROSEN_LOGE("RSColorPickerCacheTask cacheSurface is null"); From 8210981037f64622e2b2b05cb08cd71ef1b9e2a1 Mon Sep 17 00:00:00 2001 From: wangwei Date: Wed, 3 Jul 2024 09:44:02 +0800 Subject: [PATCH 171/247] ww Signed-off-by: wangwei --- .../BUILD.gn | 153 +++++++++--------- .../corpus/init | 13 ++ ...eipcinterfacecodeaccessverifier_fuzzer.cpp | 2 + .../corpus/init | 13 ++ .../rsrenderservicestub_fuzzer/corpus/init | 13 ++ .../rsrenderservicestub_fuzzer.cpp | 36 ++++- .../rstransaction_fuzzer.cpp | 53 +++++- 7 files changed, 203 insertions(+), 80 deletions(-) diff --git a/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/BUILD.gn b/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/BUILD.gn index 7482f126cd..9df7c01bdc 100755 --- a/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/BUILD.gn +++ b/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/BUILD.gn @@ -1,77 +1,78 @@ -# 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 +# 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -module_output_path = "graphic_2d/graphic_2d" - -##############################fuzztest########################################## -ohos_fuzztest("RSIrenderServiceIpcInterfaceCodeAccessVerifierFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "../../../../../test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer" - include_dirs = [ - "../../../../../rosen/modules/platform/ipc_core", - "../../../../../rosen/modules/platform", - "../../../../../modules/hyper_graphic_manager/core/config", - "../../../../../modules/render_service/core", - "../../../../../modules/render_service_base/src", - "../../../../../test/include", - ] - deps = [ - "../../../../../modules/2d_graphics:2d_graphics", - "../../../../../modules/composer:libcomposer", - "../../../../../modules/render_service:librender_service", - "../../../../../modules/render_service_base:librender_service_base", - "../../../../../modules/render_service_client:librender_service_client", - ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - "-Dprivate=public", - "-Dprotected=public", - ] - - sources = [ "rsirenderserviceipcinterfacecodeaccessverifier_fuzzer.cpp" ] - - external_deps = [ - "ability_base:base", - "ability_base:want", - "ability_runtime:abilitykit_native", - "ability_runtime:app_manager", - "c_utils:utils", - "common_event_service:cesfwk_core", - "common_event_service:cesfwk_innerkits", - "hilog:libhilog", - "ipc:ipc_core", - "safwk:system_ability_fwk", - "samgr:samgr_proxy", - ] - - if (defined(global_parts_info) && defined(global_parts_info.sensors_sensor)) { - external_deps += [ "sensor:sensor_interface_native" ] - } -} -############################################################################### -group("fuzztest") { - testonly = true - deps = [] - deps += [ - # deps file - ":RSIrenderServiceIpcInterfaceCodeAccessVerifierFuzzTest", - ] -} -############################################################################### + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +module_output_path = "graphic_2d/graphic_2d" + +##############################fuzztest########################################## +ohos_fuzztest("RSIrenderServiceIpcInterfaceCodeAccessVerifierFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "../../../../../test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer" + include_dirs = [ + "../../../../../rosen/modules/platform/ipc_core", + "../../../../../rosen/modules/platform", + "../../../../../modules/hyper_graphic_manager/core/config", + "../../../../../modules/render_service/core", + "../../../../../modules/render_service_base/src", + "../../../../../test/include", + ] + deps = [ + "../../../../../modules/2d_graphics:2d_graphics", + "../../../../../modules/composer:libcomposer", + "../../../../../modules/render_service:librender_service", + "../../../../../modules/render_service_base:librender_service_base", + "../../../../../modules/render_service_client:librender_service_client", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + sources = [ "rsirenderserviceipcinterfacecodeaccessverifier_fuzzer.cpp" ] + + external_deps = [ + "ability_base:base", + "ability_base:want", + "ability_runtime:abilitykit_native", + "ability_runtime:app_manager", + "c_utils:utils", + "common_event_service:cesfwk_core", + "common_event_service:cesfwk_innerkits", + "hilog:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + + if (defined(global_parts_info) && defined(global_parts_info.sensors_sensor)) { + external_deps += [ "sensor:sensor_interface_native" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":RSIrenderServiceIpcInterfaceCodeAccessVerifierFuzzTest", + ] +} +############################################################################### diff --git a/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/corpus/init b/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/corpus/init index 6b7212c8a6..e7c3fecd8d 100755 --- a/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/corpus/init +++ b/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/corpus/init @@ -1 +1,14 @@ +# 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. + FUZZ \ No newline at end of file diff --git a/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer.cpp b/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer.cpp index fb6532980b..ea8db6b37d 100755 --- a/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer.cpp +++ b/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer.cpp @@ -65,7 +65,9 @@ bool RSIRenderServiceInterfaceCodeAccessVerifierFuzztest(const uint8_t* data, si uint32_t times = GetData(); PermissionType permission = PermissionType::CAPTURE_SCREEN; verifier.permissionRSIRenderServiceInterfaceMappings_.emplace(code, permission); + verifier.permissionRSIRenderServiceInterfaceMappings_.emplace(code + 1, "unknown"); verifier.AddRSIRenderServiceConnectionInterfaceCodePermission(); + verifier.accessRSIRenderServiceInterfaceTimesRestrictions_.emplace(code, code); verifier.IsAccessTimesVerificationPassed(code, times); #endif return true; diff --git a/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/corpus/init b/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/corpus/init index 6b7212c8a6..e7c3fecd8d 100755 --- a/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/corpus/init +++ b/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/corpus/init @@ -1 +1,14 @@ +# 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. + FUZZ \ No newline at end of file diff --git a/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/corpus/init b/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/corpus/init index 6b7212c8a6..e7c3fecd8d 100755 --- a/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/corpus/init +++ b/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/corpus/init @@ -1 +1,14 @@ +# 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. + FUZZ \ No newline at end of file diff --git a/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/rsrenderservicestub_fuzzer.cpp b/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/rsrenderservicestub_fuzzer.cpp index 8079e966b1..606cc506e5 100755 --- a/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/rsrenderservicestub_fuzzer.cpp +++ b/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/rsrenderservicestub_fuzzer.cpp @@ -17,13 +17,17 @@ #include #include +#include #include #include #include +#include #include #include "platform/ohos/rs_irender_service.h" #include "platform/ohos/rs_irender_service_ipc_interface_code_access_verifier.h" +#include "platform/ohos/rs_render_service_connect_hub.cpp" +#include "platform/ohos/rs_render_service_proxy.h" #include "pipeline/rs_render_service.h" #include "transaction/rs_render_service_stub.h" @@ -87,6 +91,7 @@ bool RSRenderServiceStubFuzztest002(const uint8_t* data, size_t size) MessageParcel data1; MessageParcel reply; MessageOption option; + data1.WriteInterfaceToken(RSIRenderService::GetDescriptor()); stub->OnRemoteRequest(code, data1, reply, option); return true; } @@ -102,12 +107,40 @@ bool RSRenderServiceStubFuzztest003(const uint8_t* data, size_t size) g_pos = 0; // get data - uint32_t code = static_cast(RSIRenderServiceInterfaceCode::CREATE_CONNECTION); + uint32_t code = GetData(); sptr stub = new RSRenderService(); + sptr token = new IRemoteStub(); MessageParcel data1; MessageParcel reply; MessageOption option; data1.WriteInterfaceToken(RSIRenderService::GetDescriptor()); + data1.WriteRemoteObject(token->AsObject()); + stub->OnRemoteRequest(code, data1, reply, option); + return true; +} + +bool RSRenderServiceStubFuzztest004(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + // initialize + DATA = data; + g_size = size; + g_pos = 0; + + // get data + uint32_t code = GetData(); + auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + auto remoteObject = samgr->GetSystemAbility(RENDER_SERVICE); + sptr renderService = iface_cast(remoteObject); + sptr stub = new RSRenderService(); + sptr token = new IRemoteStub(); + sptr conn = renderService->CreateConnection(token); + MessageOption option; + MessageParcel data1; + MessageParcel reply; + data1.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor()); stub->OnRemoteRequest(code, data1, reply, option); return true; } @@ -121,5 +154,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) OHOS::Rosen::RSRenderServiceStubFuzztest001(data, size); OHOS::Rosen::RSRenderServiceStubFuzztest002(data, size); OHOS::Rosen::RSRenderServiceStubFuzztest003(data, size); + OHOS::Rosen::RSRenderServiceStubFuzztest004(data, size); return 0; } \ No newline at end of file diff --git a/rosen/test/render_service/render_service/fuzztest/rstransaction_fuzzer/rstransaction_fuzzer.cpp b/rosen/test/render_service/render_service/fuzztest/rstransaction_fuzzer/rstransaction_fuzzer.cpp index 6341178055..d1aad9f95e 100644 --- a/rosen/test/render_service/render_service/fuzztest/rstransaction_fuzzer/rstransaction_fuzzer.cpp +++ b/rosen/test/render_service/render_service/fuzztest/rstransaction_fuzzer/rstransaction_fuzzer.cpp @@ -19,7 +19,7 @@ #include #include -#include "platform/ohos/rs_irender_service_ipc_interface_code_access_verifier.h" +#include "platform/ohos/rs_irender_service_connection_ipc_interface_code_access_verifier.h" #include "transaction/rs_render_service_connection_stub.h" namespace OHOS { @@ -46,7 +46,7 @@ T GetData() return object; } -bool RSIRenderServiceConnectionIpcInterFaceCodeAccessVerifierFuzztest(const uint8_t* data, size_t size) +bool RSIRenderServiceConnectionIpcInterFaceCodeAccessVerifierFuzztest001(const uint8_t* data, size_t size) { if (data == nullptr) { return false; @@ -69,6 +69,52 @@ bool RSIRenderServiceConnectionIpcInterFaceCodeAccessVerifierFuzztest(const uint return true; } +bool RSIRenderServiceConnectionIpcInterFaceCodeAccessVerifierFuzztest002(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + // initialize + DATA = data; + g_size = size; + g_pos = 0; + + // get data + RSIRenderServiceConnectionInterfaceCodeAccessVerifier verifier; + uint32_t code = static_cast( + RSIRenderServiceConnectionInterfaceCodeAccessVerifier::CodeEnumType::SET_REFRESH_RATE_MODE); + verifier.IsExclusiveVerificationPassed(code); + code = static_cast( + RSIRenderServiceConnectionInterfaceCodeAccessVerifier::CodeEnumType::GET_SHOW_REFRESH_RATE_ENABLED); + verifier.IsExclusiveVerificationPassed(code); + code = static_cast( + RSIRenderServiceConnectionInterfaceCodeAccessVerifier::CodeEnumType::SET_SHOW_REFRESH_RATE_ENABLED); + verifier.IsExclusiveVerificationPassed(code); + code = static_cast( + RSIRenderServiceConnectionInterfaceCodeAccessVerifier::CodeEnumType::TAKE_SURFACE_CAPTURE); + verifier.IsExclusiveVerificationPassed(code); + code = static_cast( + RSIRenderServiceConnectionInterfaceCodeAccessVerifier::CodeEnumType::GET_MEMORY_GRAPHICS); + verifier.IsExclusiveVerificationPassed(code); + code = static_cast( + RSIRenderServiceConnectionInterfaceCodeAccessVerifier::CodeEnumType::SET_SCREEN_POWER_STATUS); + verifier.IsExclusiveVerificationPassed(code); +#ifdef RS_ENABLE_VK + code = static_cast(RSIRenderServiceConnectionInterfaceCodeAccessVerifier::CodeEnumType::SET_2D_RENDER_CTRL); + verifier.IsExclusiveVerificationPassed(code); +#endif +#ifdef ENABLE_IPC_SECURITY + uint32_t times = GetData(); + PermissionType permission = PermissionType::CAPTURE_SCREEN; + verifier.permissionRSIRenderServiceInterfaceMappings_.emplace(code, permission); + verifier.permissionRSIRenderServiceInterfaceMappings_.emplace(code + 1, "unknown"); + verifier.AddRSIRenderServiceConnectionInterfaceCodePermission(); + verifier.accessRSIRenderServiceInterfaceTimesRestrictions_.emplace(code, code); + verifier.IsAccessTimesVerificationPassed(code, times); +#endif + return true; +} + } // namespace Rosen } // namespace OHOS @@ -76,6 +122,7 @@ bool RSIRenderServiceConnectionIpcInterFaceCodeAccessVerifierFuzztest(const uint extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ - OHOS::Rosen::RSIRenderServiceConnectionIpcInterFaceCodeAccessVerifierFuzztest(data, size); + OHOS::Rosen::RSIRenderServiceConnectionIpcInterFaceCodeAccessVerifierFuzztest001(data, size); + OHOS::Rosen::RSIRenderServiceConnectionIpcInterFaceCodeAccessVerifierFuzztest002(data, size); return 0; } From 63951a04b964bd5cf6480e493ed416641f680349 Mon Sep 17 00:00:00 2001 From: balingbaling Date: Thu, 27 Jun 2024 17:23:45 +0800 Subject: [PATCH 172/247] Signed-off-by: balingbaling Change-Id: I03a37f451c4194c6e27430b6078a19541ea1663b Change-Id: Ibc989c789bfbcd16e66120bd6acde80ae06a3d87 --- .../core/pipeline/rs_uni_render_processor.cpp | 10 ++-------- .../core/pipeline/rs_uni_render_processor.h | 2 +- .../include/pipeline/rs_display_render_node.h | 10 ++++++++++ .../src/pipeline/rs_display_render_node.cpp | 13 +++++++++++++ 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_processor.cpp b/rosen/modules/render_service/core/pipeline/rs_uni_render_processor.cpp index a9f519142d..c29eeb4713 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_processor.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_processor.cpp @@ -56,7 +56,7 @@ void RSUniRenderProcessor::PostProcess() { uniComposerAdapter_->CommitLayers(layers_); if (!isPhone_) { - MultiLayersPerf(layerNum); + MultiLayersPerf(layerNum_); } RS_LOGD("RSUniRenderProcessor::PostProcess layers_:%{public}zu", layers_.size()); } @@ -182,13 +182,7 @@ void RSUniRenderProcessor::ProcessDisplaySurface(RSDisplayRenderNode& node) layer->SetLayerMaskInfo(HdiLayerInfo::LayerMask::LAYER_MASK_NORMAL); } layers_.emplace_back(layer); - for (auto surface : node.GetCurAllSurfaces()) { - auto surfaceNode = RSBaseRenderNode::ReinterpretCast(surface); - if (!surfaceNode || !surfaceNode->GetOcclusionVisible() || surfaceNode->IsLeashWindow()) { - continue; - } - layerNum++; - } + layerNum_ = node.GetSurfaceCountForMultiLayersPerf(); RSUniRenderThread::Instance().SetAcquireFence(node.GetAcquireFence()); } diff --git a/rosen/modules/render_service/core/pipeline/rs_uni_render_processor.h b/rosen/modules/render_service/core/pipeline/rs_uni_render_processor.h index ce47181016..06a1cea9e7 100644 --- a/rosen/modules/render_service/core/pipeline/rs_uni_render_processor.h +++ b/rosen/modules/render_service/core/pipeline/rs_uni_render_processor.h @@ -47,7 +47,7 @@ private: sptr& prebuffer, const sptr& consumer, const sptr& acquireFence); std::unique_ptr uniComposerAdapter_; std::vector layers_; - size_t layerNum = 0; + size_t layerNum_ = 0; bool isPhone_ = false; }; } // namespace Rosen diff --git a/rosen/modules/render_service_base/include/pipeline/rs_display_render_node.h b/rosen/modules/render_service_base/include/pipeline/rs_display_render_node.h index b56913c2a2..d59e8e228a 100644 --- a/rosen/modules/render_service_base/include/pipeline/rs_display_render_node.h +++ b/rosen/modules/render_service_base/include/pipeline/rs_display_render_node.h @@ -406,6 +406,12 @@ public: return iter->second; } + // Use in MultiLayersPerf + int GetSurfaceCountForMultiLayersPerf() const + { + return surfaceCountForMultiLayersPerf_; + } + const std::vector& GetLastSurfaceIds() const { return lastSurfaceIds_; } @@ -449,6 +455,7 @@ private: explicit RSDisplayRenderNode( NodeId id, const RSDisplayNodeConfig& config, const std::weak_ptr& context = {}); void InitRenderParams() override; + void HandleCurMainAndLeashSurfaceNodes(); // vector of sufacenodes will records dirtyregions by itself std::vector curMainAndLeashSurfaceNodes_; CompositeType compositeType_ { HARDWARE_COMPOSITE }; @@ -500,6 +507,9 @@ private: // Use in vulkan parallel rendering bool isParallelDisplayNode_ = false; + // Use in MultiLayersPerf + int surfaceCountForMultiLayersPerf_ = 0; + std::map> dirtySurfaceNodeMap_; // support multiscreen diff --git a/rosen/modules/render_service_base/src/pipeline/rs_display_render_node.cpp b/rosen/modules/render_service_base/src/pipeline/rs_display_render_node.cpp index b14db113ec..278e9bdc46 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_display_render_node.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_display_render_node.cpp @@ -184,6 +184,19 @@ void RSDisplayRenderNode::OnSync() dirtyManager_->OnSync(syncDirtyManager_); displayParams->SetNeedSync(true); RSRenderNode::OnSync(); + HandleCurMainAndLeashSurfaceNodes(); +} + +void RSDisplayRenderNode::HandleCurMainAndLeashSurfaceNodes() +{ + surfaceCountForMultiLayersPerf_ = 0; + for (const auto surface : curMainAndLeashSurfaceNodes_) { + auto surfaceNode = RSBaseRenderNode::ReinterpretCast(surface); + if (!surfaceNode || surfaceNode->IsLeashWindow()) { + continue; + } + surfaceCountForMultiLayersPerf_++; + } curMainAndLeashSurfaceNodes_.clear(); } From d473fb829f9e53dcd09096c0cb71276467063ebb Mon Sep 17 00:00:00 2001 From: wangwei Date: Wed, 3 Jul 2024 09:58:18 +0800 Subject: [PATCH 173/247] ww Signed-off-by: wangwei --- .../BUILD.gn | 153 +++++++++--------- .../rsrenderservicestub_fuzzer/BUILD.gn | 153 +++++++++--------- .../rstransaction_fuzzer.cpp | 3 +- 3 files changed, 156 insertions(+), 153 deletions(-) diff --git a/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/BUILD.gn b/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/BUILD.gn index c13982c734..14ec2a218a 100755 --- a/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/BUILD.gn +++ b/rosen/test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer/BUILD.gn @@ -1,77 +1,78 @@ -# 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 +# 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -module_output_path = "graphic_2d/graphic_2d" - -##############################fuzztest########################################## -ohos_fuzztest("RSRenderServiceSecurityUtilsFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "../../../../../test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer" - include_dirs = [ - "../../../../../rosen/modules/platform/ipc_core", - "../../../../../rosen/modules/platform", - "../../../../../modules/hyper_graphic_manager/core/config", - "../../../../../modules/render_service/core", - "../../../../../modules/render_service_base/src", - "../../../../../test/include", - ] - deps = [ - "../../../../../modules/2d_graphics:2d_graphics", - "../../../../../modules/composer:libcomposer", - "../../../../../modules/render_service:librender_service", - "../../../../../modules/render_service_base:librender_service_base", - "../../../../../modules/render_service_client:librender_service_client", - ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - "-Dprivate=public", - "-Dprotected=public", - ] - - sources = [ "rsrenderservicesecurityutils_fuzzer.cpp" ] - - external_deps = [ - "ability_base:base", - "ability_base:want", - "ability_runtime:abilitykit_native", - "ability_runtime:app_manager", - "c_utils:utils", - "common_event_service:cesfwk_core", - "common_event_service:cesfwk_innerkits", - "hilog:libhilog", - "ipc:ipc_core", - "safwk:system_ability_fwk", - "samgr:samgr_proxy", - ] - - if (defined(global_parts_info) && defined(global_parts_info.sensors_sensor)) { - external_deps += [ "sensor:sensor_interface_native" ] - } -} -############################################################################### -group("fuzztest") { - testonly = true - deps = [] - deps += [ - # deps file - ":RSRenderServiceSecurityUtilsFuzzTest", - ] -} -############################################################################### + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +module_output_path = "graphic_2d/graphic_2d" + +##############################fuzztest########################################## +ohos_fuzztest("RSRenderServiceSecurityUtilsFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "../../../../../test/render_service/render_service/fuzztest/rsrenderservicesecurityutils_fuzzer" + include_dirs = [ + "../../../../../rosen/modules/platform/ipc_core", + "../../../../../rosen/modules/platform", + "../../../../../modules/hyper_graphic_manager/core/config", + "../../../../../modules/render_service/core", + "../../../../../modules/render_service_base/src", + "../../../../../test/include", + ] + deps = [ + "../../../../../modules/2d_graphics:2d_graphics", + "../../../../../modules/composer:libcomposer", + "../../../../../modules/render_service:librender_service", + "../../../../../modules/render_service_base:librender_service_base", + "../../../../../modules/render_service_client:librender_service_client", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + sources = [ "rsrenderservicesecurityutils_fuzzer.cpp" ] + + external_deps = [ + "ability_base:base", + "ability_base:want", + "ability_runtime:abilitykit_native", + "ability_runtime:app_manager", + "c_utils:utils", + "common_event_service:cesfwk_core", + "common_event_service:cesfwk_innerkits", + "hilog:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + + if (defined(global_parts_info) && defined(global_parts_info.sensors_sensor)) { + external_deps += [ "sensor:sensor_interface_native" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":RSRenderServiceSecurityUtilsFuzzTest", + ] +} +############################################################################### diff --git a/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/BUILD.gn b/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/BUILD.gn index a9f0a20547..723eb95664 100755 --- a/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/BUILD.gn +++ b/rosen/test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer/BUILD.gn @@ -1,77 +1,78 @@ -# 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 +# 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -module_output_path = "graphic_2d/graphic_2d" - -##############################fuzztest########################################## -ohos_fuzztest("RSRenderServiceStubFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "../../../../../test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer" - include_dirs = [ - "../../../../../rosen/modules/platform/ipc_core", - "../../../../../rosen/modules/platform", - "../../../../../modules/hyper_graphic_manager/core/config", - "../../../../../modules/render_service/core", - "../../../../../modules/render_service_base/src", - "../../../../../test/include", - ] - deps = [ - "../../../../../modules/2d_graphics:2d_graphics", - "../../../../../modules/composer:libcomposer", - "../../../../../modules/render_service:librender_service", - "../../../../../modules/render_service_base:librender_service_base", - "../../../../../modules/render_service_client:librender_service_client", - ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - "-Dprivate=public", - "-Dprotected=public", - ] - - sources = [ "rsrenderservicestub_fuzzer.cpp" ] - - external_deps = [ - "ability_base:base", - "ability_base:want", - "ability_runtime:abilitykit_native", - "ability_runtime:app_manager", - "c_utils:utils", - "common_event_service:cesfwk_core", - "common_event_service:cesfwk_innerkits", - "hilog:libhilog", - "ipc:ipc_core", - "safwk:system_ability_fwk", - "samgr:samgr_proxy", - ] - - if (defined(global_parts_info) && defined(global_parts_info.sensors_sensor)) { - external_deps += [ "sensor:sensor_interface_native" ] - } -} -############################################################################### -group("fuzztest") { - testonly = true - deps = [] - deps += [ - # deps file - ":RSRenderServiceStubFuzzTest", - ] -} -############################################################################### + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +module_output_path = "graphic_2d/graphic_2d" + +##############################fuzztest########################################## +ohos_fuzztest("RSRenderServiceStubFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "../../../../../test/render_service/render_service/fuzztest/rsrenderservicestub_fuzzer" + include_dirs = [ + "../../../../../rosen/modules/platform/ipc_core", + "../../../../../rosen/modules/platform", + "../../../../../modules/hyper_graphic_manager/core/config", + "../../../../../modules/render_service/core", + "../../../../../modules/render_service_base/src", + "../../../../../test/include", + ] + deps = [ + "../../../../../modules/2d_graphics:2d_graphics", + "../../../../../modules/composer:libcomposer", + "../../../../../modules/render_service:librender_service", + "../../../../../modules/render_service_base:librender_service_base", + "../../../../../modules/render_service_client:librender_service_client", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + sources = [ "rsrenderservicestub_fuzzer.cpp" ] + + external_deps = [ + "ability_base:base", + "ability_base:want", + "ability_runtime:abilitykit_native", + "ability_runtime:app_manager", + "c_utils:utils", + "common_event_service:cesfwk_core", + "common_event_service:cesfwk_innerkits", + "hilog:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + + if (defined(global_parts_info) && defined(global_parts_info.sensors_sensor)) { + external_deps += [ "sensor:sensor_interface_native" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":RSRenderServiceStubFuzzTest", + ] +} +############################################################################### diff --git a/rosen/test/render_service/render_service/fuzztest/rstransaction_fuzzer/rstransaction_fuzzer.cpp b/rosen/test/render_service/render_service/fuzztest/rstransaction_fuzzer/rstransaction_fuzzer.cpp index d1aad9f95e..a3f70ff3dc 100644 --- a/rosen/test/render_service/render_service/fuzztest/rstransaction_fuzzer/rstransaction_fuzzer.cpp +++ b/rosen/test/render_service/render_service/fuzztest/rstransaction_fuzzer/rstransaction_fuzzer.cpp @@ -100,7 +100,8 @@ bool RSIRenderServiceConnectionIpcInterFaceCodeAccessVerifierFuzztest002(const u RSIRenderServiceConnectionInterfaceCodeAccessVerifier::CodeEnumType::SET_SCREEN_POWER_STATUS); verifier.IsExclusiveVerificationPassed(code); #ifdef RS_ENABLE_VK - code = static_cast(RSIRenderServiceConnectionInterfaceCodeAccessVerifier::CodeEnumType::SET_2D_RENDER_CTRL); + code = static_cast( + RSIRenderServiceConnectionInterfaceCodeAccessVerifier::CodeEnumType::SET_2D_RENDER_CTRL); verifier.IsExclusiveVerificationPassed(code); #endif #ifdef ENABLE_IPC_SECURITY From 1189238dd21ae8a5aad6ff427ae732e0e7f09c85 Mon Sep 17 00:00:00 2001 From: g00649947 Date: Tue, 2 Jul 2024 21:21:12 +0800 Subject: [PATCH 174/247] optimize foreground effect performance Signed-off-by: g00649947 --- .../include/property/rs_properties.h | 1 + .../render/rs_foreground_effect_filter.h | 4 +- .../src/property/rs_properties.cpp | 5 +- .../render/rs_foreground_effect_filter.cpp | 49 +++++++++---------- .../rs_foreground_effect_filter_test.cpp | 2 +- 5 files changed, 32 insertions(+), 29 deletions(-) diff --git a/rosen/modules/render_service_base/include/property/rs_properties.h b/rosen/modules/render_service_base/include/property/rs_properties.h index 8df9b2d6e5..d7b1b06035 100644 --- a/rosen/modules/render_service_base/include/property/rs_properties.h +++ b/rosen/modules/render_service_base/include/property/rs_properties.h @@ -711,6 +711,7 @@ private: static const bool FilterCacheEnabled; #endif static const bool IS_UNI_RENDER; + static const bool FOREGROUND_FILTER_ENABLED; std::unique_ptr sandbox_ = nullptr; diff --git a/rosen/modules/render_service_base/include/render/rs_foreground_effect_filter.h b/rosen/modules/render_service_base/include/render/rs_foreground_effect_filter.h index d7da954d4e..abb31cecdd 100644 --- a/rosen/modules/render_service_base/include/render/rs_foreground_effect_filter.h +++ b/rosen/modules/render_service_base/include/render/rs_foreground_effect_filter.h @@ -43,7 +43,7 @@ public: const Drawing::Rect& src, const Drawing::Rect& dst) const override; void PreProcess(std::shared_ptr image) override {}; void PostProcess(Drawing::Canvas& canvas) override {}; - float GetDirtyExtension(); + float GetDirtyExtension() const; std::shared_ptr Compose( const std::shared_ptr& other) const override @@ -58,7 +58,7 @@ private: float radiusByPasses_{}; float unit_{}; - std::shared_ptr blurEffect_; + std::shared_ptr blurBuilder_ = nullptr; static constexpr float BASE_BLUR_SCALE = 0.5f; // base downSample radio static constexpr uint32_t MAX_PASSES_LARGE_RADIUS = 7; diff --git a/rosen/modules/render_service_base/src/property/rs_properties.cpp b/rosen/modules/render_service_base/src/property/rs_properties.cpp index 7d280dd40b..351e56edb8 100644 --- a/rosen/modules/render_service_base/src/property/rs_properties.cpp +++ b/rosen/modules/render_service_base/src/property/rs_properties.cpp @@ -214,6 +214,7 @@ const bool RSProperties::FilterCacheEnabled = false; #endif const bool RSProperties::IS_UNI_RENDER = RSUniRenderJudgement::IsUniRender(); +const bool RSProperties::FOREGROUND_FILTER_ENABLED = RSSystemProperties::GetForegroundFilterEnabled(); RSProperties::RSProperties() { @@ -4115,7 +4116,9 @@ void RSProperties::UpdateFilter() filter_.reset(); } - UpdateForegroundFilter(); + if (FOREGROUND_FILTER_ENABLED) { + UpdateForegroundFilter(); + } needFilter_ = backgroundFilter_ != nullptr || filter_ != nullptr || useEffect_ || IsLightUpEffectValid() || IsDynamicLightUpValid() || greyCoef_.has_value() || linearGradientBlurPara_ != nullptr || diff --git a/rosen/modules/render_service_base/src/render/rs_foreground_effect_filter.cpp b/rosen/modules/render_service_base/src/render/rs_foreground_effect_filter.cpp index 20eff8b0b5..f24f1a645f 100644 --- a/rosen/modules/render_service_base/src/render/rs_foreground_effect_filter.cpp +++ b/rosen/modules/render_service_base/src/render/rs_foreground_effect_filter.cpp @@ -49,6 +49,7 @@ bool RSForegroundEffectFilter::IsValid() const void RSForegroundEffectFilter::MakeForegroundEffect() { + static std::shared_ptr blurEffect_ = nullptr; std::string blurString( R"( uniform shader imageInput; @@ -68,12 +69,15 @@ void RSForegroundEffectFilter::MakeForegroundEffect() } )"); - auto blurEffect = Drawing::RuntimeEffect::CreateForShader(blurString); - if (!blurEffect) { - ROSEN_LOGE("RSForegroundEffect::RuntimeShader blurEffect create failed"); - return; + if (blurEffect_ == nullptr) { + blurEffect_ = Drawing::RuntimeEffect::CreateForShader(blurString); + if (blurEffect_ == nullptr) { + ROSEN_LOGE("RSForegroundEffect::RuntimeShader blurEffect create failed"); + } + } + if (blurEffect_ != nullptr) { + blurBuilder_ = std::make_shared(blurEffect_); } - blurEffect_ = std::move(blurEffect); } void RSForegroundEffectFilter::ComputeParamter(int radius) @@ -119,7 +123,7 @@ void RSForegroundEffectFilter::ComputePassesAndUnit() unit_ = std::ceil(radiusByPasses_ * blurScale_) + unitPadding; } -float RSForegroundEffectFilter::GetDirtyExtension() +float RSForegroundEffectFilter::GetDirtyExtension() const { if (ROSEN_EQ(blurScale_, 0.0f)) { ROSEN_LOGD("RSForegroundEffectFilter::GetDirtyExtension blurRadius is 0.0"); @@ -131,7 +135,7 @@ float RSForegroundEffectFilter::GetDirtyExtension() void RSForegroundEffectFilter::ApplyForegroundEffect(Drawing::Canvas& canvas, const std::shared_ptr& image, const ForegroundEffectParam& param) const { - if (!blurEffect_ || !image || image->GetWidth() == 0 || image->GetHeight() == 0) { + if (!blurBuilder_ || !image || image->GetWidth() == 0 || image->GetHeight() == 0) { ROSEN_LOGE("RSForegroundEffectFilter::shader error"); return; } @@ -153,37 +157,32 @@ void RSForegroundEffectFilter::ApplyForegroundEffect(Drawing::Canvas& canvas, blurMatrix.PostScale(scaleW, scaleH); Drawing::SamplingOptions linear(Drawing::FilterMode::LINEAR, Drawing::MipmapMode::NONE); - Drawing::RuntimeShaderBuilder blurBuilder(blurEffect_); - blurBuilder.SetChild("imageInput", Drawing::ShaderEffect::CreateImageShader(*image, Drawing::TileMode::DECAL, + blurBuilder_->SetChild("imageInput", Drawing::ShaderEffect::CreateImageShader(*image, Drawing::TileMode::DECAL, Drawing::TileMode::DECAL, linear, blurMatrix)); - blurBuilder.SetUniform("in_blurOffset", radiusByPasses_ * blurScale_, radiusByPasses_ * blurScale_); + blurBuilder_->SetUniform("in_blurOffset", radiusByPasses_ * blurScale_, radiusByPasses_ * blurScale_); - auto scaledInfoGeo = Drawing::ImageInfo(std::ceil(width * blurScale_) + EXPAND_UNIT_NUM * unit_, - std::ceil(height * blurScale_) + EXPAND_UNIT_NUM * unit_, imgInfo.GetColorType(), + float extension = static_cast(std::ceil(GetDirtyExtension() * blurScale_)); + float halfExtension = 0.5 * extension; + auto scaledInfoGeo = Drawing::ImageInfo(std::ceil(width * blurScale_) + extension, + std::ceil(height * blurScale_) + extension, imgInfo.GetColorType(), imgInfo.GetAlphaType(), imgInfo.GetColorSpace()); Drawing::Matrix blurMatrixGeo; - blurMatrixGeo.Translate(MOVE_UNIT_NUM * unit_, MOVE_UNIT_NUM * unit_); + blurMatrixGeo.Translate(halfExtension, halfExtension); - std::shared_ptr tmpBlur(blurBuilder.MakeImage( + std::shared_ptr tmpBlur(blurBuilder_->MakeImage( canvas.GetGPUContext().get(), &blurMatrixGeo, scaledInfoGeo, false)); // And now we'll build our chain of scaled blur stages for (auto i = 1; i < numberOfPasses_; i++) { - auto scaledInfoGeoIter = Drawing::ImageInfo(tmpBlur->GetWidth() + EXPAND_UNIT_NUM * unit_, - tmpBlur->GetHeight() + EXPAND_UNIT_NUM * unit_, - imgInfo.GetColorType(), imgInfo.GetAlphaType(), imgInfo.GetColorSpace()); - Drawing::Matrix matrixGeoIter; - matrixGeoIter.Translate(MOVE_UNIT_NUM * unit_, MOVE_UNIT_NUM * unit_); - const float stepScale = static_cast(i) * blurScale_; - blurBuilder.SetChild("imageInput", Drawing::ShaderEffect::CreateImageShader(*tmpBlur, Drawing::TileMode::DECAL, - Drawing::TileMode::DECAL, linear, Drawing::Matrix())); - blurBuilder.SetUniform("in_blurOffset", radiusByPasses_ * stepScale, radiusByPasses_ * stepScale); + blurBuilder_->SetChild("imageInput", Drawing::ShaderEffect::CreateImageShader(*tmpBlur, + Drawing::TileMode::DECAL, Drawing::TileMode::DECAL, linear, Drawing::Matrix())); + blurBuilder_->SetUniform("in_blurOffset", radiusByPasses_ * stepScale, radiusByPasses_ * stepScale); - tmpBlur = blurBuilder.MakeImage(canvas.GetGPUContext().get(), &matrixGeoIter, scaledInfoGeoIter, false); + tmpBlur = blurBuilder_->MakeImage(canvas.GetGPUContext().get(), nullptr, scaledInfoGeo, false); } Drawing::Matrix blurMatrixInv; - blurMatrixInv.Translate(-MOVE_UNIT_NUM * unit_ * numberOfPasses_, -MOVE_UNIT_NUM * unit_ * numberOfPasses_); + blurMatrixInv.Translate(-halfExtension, -halfExtension); if (ROSEN_EQ(scaleW, 0.0f) || ROSEN_EQ(scaleH, 0.0f)) { ROSEN_LOGD("RSForegroundEffectFilter scaleW or scaleH is 0"); return; diff --git a/rosen/test/render_service/render_service_base/unittest/render/rs_foreground_effect_filter_test.cpp b/rosen/test/render_service/render_service_base/unittest/render/rs_foreground_effect_filter_test.cpp index e2e6f1e604..c9dba409c0 100644 --- a/rosen/test/render_service/render_service_base/unittest/render/rs_foreground_effect_filter_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/render/rs_foreground_effect_filter_test.cpp @@ -49,7 +49,7 @@ HWTEST_F(RSForegroundEffectFilterTest, MakeForegroundEffectTest, TestSize.Level1 { auto rsForegroundEffectFilter = std::make_shared(1.0f); rsForegroundEffectFilter->MakeForegroundEffect(); - EXPECT_NE(rsForegroundEffectFilter->blurEffect_, nullptr); + EXPECT_NE(rsForegroundEffectFilter->blurBuilder_, nullptr); } /** From 783b13536fee5503ca251d002bebd210de283f32 Mon Sep 17 00:00:00 2001 From: sqwlly Date: Tue, 2 Jul 2024 09:09:34 +0000 Subject: [PATCH 175/247] =?UTF-8?q?=E9=83=A8=E4=BB=B6=E7=8B=AC=E7=AB=8B?= =?UTF-8?q?=E5=8C=96=E6=95=B4=E6=94=B9=EF=BC=8C=E4=B8=8D=E9=80=9A=E8=BF=87?= =?UTF-8?q?surface=20Signed-off-by:=20s30029175=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: sqwlly Change-Id: I065d5afee64747959f4373ce3cc3f6d76fb58620 --- rosen/modules/render_service_base/BUILD.gn | 1 + rosen/modules/render_service_client/BUILD.gn | 1 + 2 files changed, 2 insertions(+) diff --git a/rosen/modules/render_service_base/BUILD.gn b/rosen/modules/render_service_base/BUILD.gn index f1f944ff69..f81a79d57d 100644 --- a/rosen/modules/render_service_base/BUILD.gn +++ b/rosen/modules/render_service_base/BUILD.gn @@ -21,6 +21,7 @@ config("export_config") { cflags_cc = [ "-std=c++17" ] defines = rs_common_define + defines += gpu_defines } if (!is_mingw && !is_mac && !is_cross_platform) { diff --git a/rosen/modules/render_service_client/BUILD.gn b/rosen/modules/render_service_client/BUILD.gn index 51225fb9b6..c60c74754c 100644 --- a/rosen/modules/render_service_client/BUILD.gn +++ b/rosen/modules/render_service_client/BUILD.gn @@ -32,6 +32,7 @@ config("render_service_client_config") { "//foundation/multimedia/image_framework/interfaces/innerkits/include", ] } + defines += gpu_defines } template("render_service_client_source_set") { From faffc06921d101eb85e12145177cfdc91b98d5b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E6=80=9D=E8=BF=9C?= Date: Wed, 3 Jul 2024 10:54:29 +0800 Subject: [PATCH 176/247] =?UTF-8?q?=E6=96=B0=E5=A2=9EImageFit=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周思远 --- .../include/render/rs_image.h | 8 +++++ .../src/render/rs_image.cpp | 33 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/rosen/modules/render_service_base/include/render/rs_image.h b/rosen/modules/render_service_base/include/render/rs_image.h index aa13542f67..bcd6b9df84 100644 --- a/rosen/modules/render_service_base/include/render/rs_image.h +++ b/rosen/modules/render_service_base/include/render/rs_image.h @@ -71,6 +71,14 @@ enum class ImageFit { NONE, SCALE_DOWN, TOP_LEFT, + TOP, + TOP_RIGHT, + LEFT, + CENTER, + RIGHT, + BOTTOM_LEFT, + BOTTOM, + BOTTOM_RIGHT, COVER_TOP_LEFT, }; diff --git a/rosen/modules/render_service_base/src/render/rs_image.cpp b/rosen/modules/render_service_base/src/render/rs_image.cpp index 04b2c3bd01..daf384e04f 100644 --- a/rosen/modules/render_service_base/src/render/rs_image.cpp +++ b/rosen/modules/render_service_base/src/render/rs_image.cpp @@ -35,6 +35,7 @@ namespace OHOS { namespace Rosen { namespace { constexpr int32_t CORNER_SIZE = 4; +constexpr float CENTER_ALIGNED_FACTOR = 2.f; } RSImage::~RSImage() @@ -163,6 +164,38 @@ RectF ApplyImageFitSwitch(ImageParameter &imageParameter, ImageFit imageFit_, Re case ImageFit::TOP_LEFT: tempRectF.SetAll(0.f, 0.f, imageParameter.srcW, imageParameter.srcH); return tempRectF; + case ImageFit::TOP: + tempRectF.SetAll((imageParameter.dstW - imageParameter.srcW) / CENTER_ALIGNED_FACTOR, 0.f, + imageParameter.srcW, imageParameter.srcH); + return tempRectF; + case ImageFit::TOP_RIGHT: + tempRectF.SetAll(imageParameter.dstW - imageParameter.srcW, 0.f, imageParameter.srcW, imageParameter.srcH); + return tempRectF; + case ImageFit::LEFT: + tempRectF.SetAll(0.f, (imageParameter.dstH - imageParameter.srcH) / CENTER_ALIGNED_FACTOR, + imageParameter.srcW, imageParameter.srcH); + return tempRectF; + case ImageFit::CENTER: + tempRectF.SetAll((imageParameter.dstW - imageParameter.srcW) / CENTER_ALIGNED_FACTOR, + (imageParameter.dstH - imageParameter.srcH) / CENTER_ALIGNED_FACTOR, + imageParameter.srcW, imageParameter.srcH); + return tempRectF; + case ImageFit::RIGHT: + tempRectF.SetAll(imageParameter.dstW - imageParameter.srcW, + (imageParameter.dstH - imageParameter.srcH) / CENTER_ALIGNED_FACTOR, + imageParameter.srcW, imageParameter.srcH); + return tempRectF; + case ImageFit::BOTTOM_LEFT: + tempRectF.SetAll(0.f, imageParameter.dstH - imageParameter.srcH, imageParameter.srcW, imageParameter.srcH); + return tempRectF; + case ImageFit::BOTTOM: + tempRectF.SetAll((imageParameter.dstW - imageParameter.srcW) / CENTER_ALIGNED_FACTOR, + imageParameter.dstH - imageParameter.srcH, imageParameter.srcW, imageParameter.srcH); + return tempRectF; + case ImageFit::BOTTOM_RIGHT: + tempRectF.SetAll(imageParameter.dstW - imageParameter.srcW, imageParameter.dstH - imageParameter.srcH, + imageParameter.srcW, imageParameter.srcH); + return tempRectF; case ImageFit::FILL: break; case ImageFit::NONE: From 230fff395947df3e4c8b03387535de2c73fa16ee Mon Sep 17 00:00:00 2001 From: zzvscx Date: Wed, 3 Jul 2024 11:01:16 +0800 Subject: [PATCH 177/247] =?UTF-8?q?frameRateVoteInfoVec=E5=8A=A0=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zzvscx Change-Id: I713c7d4c702bd60f495798bad7097924e0831c39 --- .../core/frame_rate_manager/hgm_frame_rate_manager.cpp | 1 + .../core/frame_rate_manager/hgm_frame_rate_manager.h | 1 + 2 files changed, 2 insertions(+) diff --git a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.cpp b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.cpp index 612138e987..0c9de8cee2 100644 --- a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.cpp +++ b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.cpp @@ -316,6 +316,7 @@ void HgmFrameRateManager::ReportHiSysEvent(const VoteInfo& frameRateVoteInfo) if (frameRateVoteInfo.voterName.empty()) { return; } + std::lock_guard locker(frameRateVoteInfoMutex_); bool needAdd = frameRateVoteInfoVec_.empty() || frameRateVoteInfoVec_.back().second != frameRateVoteInfo; if (frameRateVoteInfoVec_.size() >= REPORT_VOTER_INFO_LIMIT) { std::string msg; diff --git a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.h b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.h index 735d526b64..87c6a01009 100644 --- a/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.h +++ b/rosen/modules/hyper_graphic_manager/core/frame_rate_manager/hgm_frame_rate_manager.h @@ -224,6 +224,7 @@ private: std::unordered_set gameScenes_; std::mutex cleanPidCallbackMutex_; std::unordered_map> cleanPidCallback_; + std::mutex frameRateVoteInfoMutex_; // FORMAT: std::vector> frameRateVoteInfoVec_; From eeb140bd3b2777bd8fd9ee598028058c50d2de6b Mon Sep 17 00:00:00 2001 From: wangwei Date: Wed, 3 Jul 2024 11:37:52 +0800 Subject: [PATCH 178/247] ww Signed-off-by: wangwei --- .../BUILD.gn | 4 ++-- .../project.xml | 2 +- .../rsirenderserviceipcinterfacecodeaccessverifier_fuzzer.cpp | 2 +- .../rsirenderserviceipcinterfacecodeaccessverifier_fuzzer.h | 2 +- .../fuzztest/rsrenderservicesecurityutils_fuzzer/BUILD.gn | 4 ++-- .../fuzztest/rsrenderservicesecurityutils_fuzzer/project.xml | 2 +- .../rsrenderservicesecurityutils_fuzzer.cpp | 2 +- .../rsrenderservicesecurityutils_fuzzer.h | 2 +- .../fuzztest/rsrenderservicestub_fuzzer/BUILD.gn | 4 ++-- .../fuzztest/rsrenderservicestub_fuzzer/project.xml | 2 +- .../rsrenderservicestub_fuzzer/rsrenderservicestub_fuzzer.cpp | 4 ++-- .../rsrenderservicestub_fuzzer/rsrenderservicestub_fuzzer.h | 2 +- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/BUILD.gn b/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/BUILD.gn index 9df7c01bdc..d783d8ba62 100755 --- a/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/BUILD.gn +++ b/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# 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 @@ -9,7 +9,7 @@ # 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. +# limitations under the License. #####################hydra-fuzz################### import("//build/config/features.gni") diff --git a/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/project.xml b/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/project.xml index c14caf653d..61d63a0715 100755 --- a/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/project.xml +++ b/rosen/test/render_service/render_service/fuzztest/rsirenderserviceipcinterfacecodeaccessverifier_fuzzer/project.xml @@ -1,5 +1,5 @@ -