From ee26525ec2f5eb11ba73acac985d8870e3fa859a Mon Sep 17 00:00:00 2001 From: redermens <942494956@qq.com> Date: Tue, 23 Jul 2024 00:25:17 +0800 Subject: [PATCH 01/74] =?UTF-8?q?Set/Get=20Modifier=E6=95=88=E6=9E=9C?= =?UTF-8?q?=E5=8F=A0=E5=8A=A0=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: redermens <942494956@qq.com> --- .../core/modifier/rs_modifier_extractor.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/rosen/modules/render_service_client/core/modifier/rs_modifier_extractor.cpp b/rosen/modules/render_service_client/core/modifier/rs_modifier_extractor.cpp index 69112a3bbc..85b9f2f9a7 100644 --- a/rosen/modules/render_service_client/core/modifier/rs_modifier_extractor.cpp +++ b/rosen/modules/render_service_client/core/modifier/rs_modifier_extractor.cpp @@ -34,13 +34,6 @@ constexpr uint32_t DEBUG_MODIFIER_SIZE = 20; return defaultValue; \ } \ std::unique_lock lock(node_->GetPropertyMutex()); \ - auto iter = node_->propertyModifiers_.find(RSModifierType::propertyType); \ - if (iter != node_->propertyModifiers_.end()) { \ - if (!iter->second || !iter->second->GetProperty()) { \ - return defaultValue; \ - } \ - return std::static_pointer_cast>(iter->second->GetProperty())->Get(); \ - } \ T value = defaultValue; \ if (node_->modifiers_.size() > DEBUG_MODIFIER_SIZE) { \ ROSEN_LOGD("RSModifierExtractor modifier size is %{public}zu", node_->modifiers_.size()); \ @@ -59,14 +52,6 @@ constexpr uint32_t DEBUG_MODIFIER_SIZE = 20; return defaultValue; \ } \ std::unique_lock lock(node_->GetPropertyMutex()); \ - auto iter = node_->propertyModifiers_.find(RSModifierType::propertyType); \ - if (iter != node_->propertyModifiers_.end()) { \ - if (!iter->second || !iter->second->GetProperty()) { \ - return defaultValue; \ - } \ - return std::static_pointer_cast>(iter->second->GetProperty())->Get(); \ - } \ - \ auto typeIter = node_->modifiersTypeMap_.find((int16_t)RSModifierType::propertyType); \ if (typeIter != node_->modifiersTypeMap_.end()) { \ auto modifier = typeIter->second; \ From c817dac6e93b39605abdfafcbbe5dabc8561448d Mon Sep 17 00:00:00 2001 From: Alexander Efimov Date: Tue, 23 Jul 2024 14:42:00 +0300 Subject: [PATCH 02/74] Fix incorrect mirror size and rotation with enabled HWC Signed-off-by: Alexander Efimov Change-Id: Ieef601ce859ee3809024c76e442bfebeec6ed64d --- .../core/drawable/rs_display_render_node_drawable.cpp | 7 +++---- 1 file changed, 3 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 78e6ff9d53..da6c4261f7 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 @@ -829,7 +829,6 @@ void RSDisplayRenderNodeDrawable::DrawMirror(RSDisplayRenderParams& params, virtualProcesser->SetRoiRegionToCodec(emptyRects); } - curCanvas_->ConcatMatrix(mirroredParams->GetMatrix()); PrepareOffscreenRender(*mirroredDrawable); // set mirror screen capture param // Don't need to scale here since the canvas has been switched from mirror frame to offscreen @@ -1421,9 +1420,9 @@ void RSDisplayRenderNodeDrawable::PrepareOffscreenRender(const RSDisplayRenderNo canvasBackup_ = nullptr; // check offscreen size and hardware renderer useFixedOffscreenSurfaceSize_ = false; - auto frameSize = params->GetFrameRect(); - int32_t offscreenWidth = static_cast(frameSize.GetWidth()); - int32_t offscreenHeight = static_cast(frameSize.GetHeight()); + const ScreenInfo& screenInfo = params->GetScreenInfo(); + int32_t offscreenWidth = static_cast(screenInfo.width); + int32_t offscreenHeight = static_cast(screenInfo.height); // use fixed surface size in order to reduce create texture if (RSSystemProperties::IsFoldScreenFlag() && params->IsRotationChanged()) { useFixedOffscreenSurfaceSize_ = true; From 645aa8d2fed19a8d9d30f5c6ab01017460cb1233 Mon Sep 17 00:00:00 2001 From: ekoroleva Date: Thu, 25 Jul 2024 10:49:35 +0300 Subject: [PATCH 03/74] render node ut update Signed-off-by: ekoroleva Change-Id: I1c8dabea203c93a9959e1d3d0faa3bd0370a933c --- .../unittest/pipeline/rs_render_node_test.cpp | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) 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 0f013d597d..497829e79f 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 @@ -2089,14 +2089,14 @@ HWTEST_F(RSRenderNodeTest, ManageRenderingResourcesTest022, TestSize.Level1) EXPECT_TRUE(nodeTest->NeedInitCacheSurface()); nodeTest->boundsModifier_ = nullptr; - std::shared_ptr> propertyTest = - std::make_shared>(); + auto propertyTest = std::make_shared>(); EXPECT_NE(propertyTest, nullptr); - std::shared_ptr frameModifier = - std::make_shared(propertyTest); + auto frameModifier = std::make_shared(propertyTest); EXPECT_NE(frameModifier, nullptr); frameModifier->property_ = std::make_shared>(); EXPECT_NE(frameModifier->property_, nullptr); + frameModifier->property_->GetRef() = std::make_shared(10, 10); + frameModifier->SetType(RSModifierType::FRAME); nodeTest->frameModifier_ = frameModifier; nodeTest->cacheSurface_ = std::make_shared(); EXPECT_NE(nodeTest->cacheSurface_, nullptr); @@ -2277,7 +2277,12 @@ HWTEST_F(RSRenderNodeTest, GetCompletedImageTest026, TestSize.Level1) EXPECT_EQ(nodeTest->GetCompletedImage(canvas, 0, true), nullptr); nodeTest->cacheCompletedBackendTexture_.isValid_ = true; +#ifdef RS_ENABLE_VK + // nullptr as cacheCompletedCleanupHelper_ is false + EXPECT_EQ(nodeTest->GetCompletedImage(canvas, 0, true), nullptr); +#else EXPECT_NE(nodeTest->GetCompletedImage(canvas, 0, true), nullptr); +#endif // cacheCompletedSurface_->GetImageSnapshot() is false EXPECT_EQ(nodeTest->GetCompletedImage(canvas, 0, false), nullptr); @@ -2558,6 +2563,10 @@ HWTEST_F(RSRenderNodeTest, UpdateDirtyRegionInfoForDFX001, TestSize.Level1) std::shared_ptr rsDirtyManager = std::make_shared(); canvasNode->lastFrameSubTreeSkipped_ = true; canvasNode->subTreeDirtyRegion_ = RectI(0, 0, DEFAULT_BOUNDS_SIZE, DEFAULT_BOUNDS_SIZE); + // 'resize' added to avoid segmentation fault crash in + // the RSDirtyRegionManager::UpdateDirtyRegionInfoForDfx() in line + // dirtyCanvasNodeInfo_[dirtyType].emplace(std::make_pair(id, rect)); + rsDirtyManager->dirtyCanvasNodeInfo_.resize(DirtyRegionType::TYPE_AMOUNT); canvasNode->UpdateDirtyRegionInfoForDFX(*rsDirtyManager); EXPECT_FALSE(rsDirtyManager->dirtyCanvasNodeInfo_.empty()); if (isPropertyChanged) { @@ -2585,6 +2594,10 @@ HWTEST_F(RSRenderNodeTest, UpdateDirtyRegionInfoForDFX002, TestSize.Level1) auto& properties = canvasNode->GetMutableRenderProperties(); properties.clipToBounds_ = true; canvasNode->absDrawRect_ = RectI(0, 0, DEFAULT_BOUNDS_SIZE, DEFAULT_BOUNDS_SIZE); + // 'resize' added to avoid segmentation fault crash in + // the RSDirtyRegionManager::UpdateDirtyRegionInfoForDfx() in line + // dirtyCanvasNodeInfo_[dirtyType].emplace(std::make_pair(id, rect)); + rsDirtyManager->dirtyCanvasNodeInfo_.resize(DirtyRegionType::TYPE_AMOUNT); canvasNode->UpdateDirtyRegionInfoForDFX(*rsDirtyManager); EXPECT_FALSE(rsDirtyManager->dirtyCanvasNodeInfo_.empty()); if (isPropertyChanged) { From 83247aaa0471e3341df01679734edd3800194bb4 Mon Sep 17 00:00:00 2001 From: ekoroleva Date: Thu, 25 Jul 2024 13:29:42 +0300 Subject: [PATCH 04/74] fix code style issue Signed-off-by: ekoroleva Change-Id: Ide135000c1eb51c21bb4eba05d9a3fe2482f1bcf --- .../unittest/pipeline/rs_render_node_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 497829e79f..9c76c216c9 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 @@ -2563,9 +2563,9 @@ HWTEST_F(RSRenderNodeTest, UpdateDirtyRegionInfoForDFX001, TestSize.Level1) std::shared_ptr rsDirtyManager = std::make_shared(); canvasNode->lastFrameSubTreeSkipped_ = true; canvasNode->subTreeDirtyRegion_ = RectI(0, 0, DEFAULT_BOUNDS_SIZE, DEFAULT_BOUNDS_SIZE); - // 'resize' added to avoid segmentation fault crash in + // 'resize' added to avoid segmentation fault crash in // the RSDirtyRegionManager::UpdateDirtyRegionInfoForDfx() in line - // dirtyCanvasNodeInfo_[dirtyType].emplace(std::make_pair(id, rect)); + // dirtyCanvasNodeInfo_[dirtyType].emplace(std::make_pair(id, rect)) rsDirtyManager->dirtyCanvasNodeInfo_.resize(DirtyRegionType::TYPE_AMOUNT); canvasNode->UpdateDirtyRegionInfoForDFX(*rsDirtyManager); EXPECT_FALSE(rsDirtyManager->dirtyCanvasNodeInfo_.empty()); @@ -2596,7 +2596,7 @@ HWTEST_F(RSRenderNodeTest, UpdateDirtyRegionInfoForDFX002, TestSize.Level1) canvasNode->absDrawRect_ = RectI(0, 0, DEFAULT_BOUNDS_SIZE, DEFAULT_BOUNDS_SIZE); // 'resize' added to avoid segmentation fault crash in // the RSDirtyRegionManager::UpdateDirtyRegionInfoForDfx() in line - // dirtyCanvasNodeInfo_[dirtyType].emplace(std::make_pair(id, rect)); + // dirtyCanvasNodeInfo_[dirtyType].emplace(std::make_pair(id, rect)) rsDirtyManager->dirtyCanvasNodeInfo_.resize(DirtyRegionType::TYPE_AMOUNT); canvasNode->UpdateDirtyRegionInfoForDFX(*rsDirtyManager); EXPECT_FALSE(rsDirtyManager->dirtyCanvasNodeInfo_.empty()); From a36a8c8b9a0245ae1e939f52e74c3d3b1feb7971 Mon Sep 17 00:00:00 2001 From: ekoroleva Date: Thu, 25 Jul 2024 13:32:18 +0300 Subject: [PATCH 05/74] render node ut update Signed-off-by: ekoroleva Change-Id: I9acbd885f6c75d4d6a9409623561ec71382f18b4 --- .../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 9c76c216c9..b2bd1609e5 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 @@ -2594,7 +2594,7 @@ HWTEST_F(RSRenderNodeTest, UpdateDirtyRegionInfoForDFX002, TestSize.Level1) auto& properties = canvasNode->GetMutableRenderProperties(); properties.clipToBounds_ = true; canvasNode->absDrawRect_ = RectI(0, 0, DEFAULT_BOUNDS_SIZE, DEFAULT_BOUNDS_SIZE); - // 'resize' added to avoid segmentation fault crash in + // 'resize' added to avoid segmentation fault crash in // the RSDirtyRegionManager::UpdateDirtyRegionInfoForDfx() in line // dirtyCanvasNodeInfo_[dirtyType].emplace(std::make_pair(id, rect)) rsDirtyManager->dirtyCanvasNodeInfo_.resize(DirtyRegionType::TYPE_AMOUNT); From 1ad67942622f41329d53077eebb12ac911f62019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=AF=E9=91=AB?= Date: Sun, 28 Jul 2024 03:25:16 +0000 Subject: [PATCH 06/74] =?UTF-8?q?=E8=93=9D=E9=BB=84=E5=8C=BA=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 凯鑫 --- .../include/benchmarks/rs_recording_thread.h | 6 +++--- .../src/benchmarks/rs_recording_thread.cpp | 17 ++++++++++------- .../benchmark_dcl/drawing_playback.cpp | 8 ++------ .../unittest/benchmarks/BUILD.gn | 14 +++++++------- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/rosen/modules/render_service_base/include/benchmarks/rs_recording_thread.h b/rosen/modules/render_service_base/include/benchmarks/rs_recording_thread.h index 61ec600086..544d2c98e5 100644 --- a/rosen/modules/render_service_base/include/benchmarks/rs_recording_thread.h +++ b/rosen/modules/render_service_base/include/benchmarks/rs_recording_thread.h @@ -46,7 +46,7 @@ public: RSRecordingThread(RenderContext* context) : renderContext_(context){}; ~RSRecordingThread(); - + static RSRecordingThread& Instance(RenderContext* context); void Start(); bool IsIdle(); @@ -62,11 +62,11 @@ public: { return mode_ != RecordingMode::STOP_RECORDING; } - + private: void CreateShareEglContext(); void DestroyShareEglContext(); - void FinishRecordingOneFrameTask(RecordingMode mode); + void FinishRecordingOneFrameTask(RecordingMode modeSubThread); std::shared_ptr CreateShareGrContext(); const static size_t RECORDING_PARCEL_CAPCITY = 234 * 1000 * 1024; diff --git a/rosen/modules/render_service_base/src/benchmarks/rs_recording_thread.cpp b/rosen/modules/render_service_base/src/benchmarks/rs_recording_thread.cpp index 314f486d56..d816df53c7 100644 --- a/rosen/modules/render_service_base/src/benchmarks/rs_recording_thread.cpp +++ b/rosen/modules/render_service_base/src/benchmarks/rs_recording_thread.cpp @@ -69,7 +69,8 @@ std::shared_ptr RSRecordingThread::CreateShareGrContext() } #endif #ifdef RS_ENABLE_VK - if (RSSystemProperties::IsUseVulkan()) { + if (RSSystemProperties::GetGpuApiType() == GpuApiType::VULKAN || + RSSystemProperties::GetGpuApiType() == GpuApiType::DDGR) { Drawing::GPUContextOptions options; auto handler = std::make_shared(); std::string vulkanVersion = RsVulkanContext::GetSingleton().GetVulkanVersion(); @@ -167,10 +168,8 @@ void RSRecordingThread::FinishRecordingOneFrameTask(RecordingMode modeSubThread) RSMarshallingHelper::BeginNoSharedMem(std::this_thread::get_id()); RSMarshallingHelper::Marshalling(*messageParcel, drawCmdListVec_[curFrameIndex]); RSMarshallingHelper::EndNoSharedMem(); - opsDescription = drawCmdListVec_[curFrameIndex]-> GetOpsWithDesc(); } else if (modeSubThread == RecordingMode::LOW_SPEED_RECORDING) { messageParcel = messageParcelVec_[curFrameIndex]; - opsDescription = opsDescriptionVec_[curFrameIndex]; } OHOS::Rosen::Benchmarks::WriteMessageParcelToFile(messageParcel, opsDescription, curFrameIndex, fileDir_); } @@ -196,11 +195,15 @@ void RSRecordingThread::FinishRecordingOneFrame() } auto modeSubThread = mode_; mode_ = RecordingMode::STOP_RECORDING; -#if defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK) - RSTaskMessage::RSTask task = [this, modeSubThread]() { +#ifdef RS_ENABLE_GL + if (RSSystemProperties::GetGpuApiType() == GpuApiType::OPENGL) { + RSTaskMessage::RSTask task = [this, modeSubThread]() { + FinishRecordingOneFrameTask(modeSubThread); + }; + PostTask(task); + } else { FinishRecordingOneFrameTask(modeSubThread); - }; - PostTask(task); + } #else FinishRecordingOneFrameTask(modeSubThread); #endif diff --git a/rosen/samples/2d_graphics/benchmarks/benchmark_dcl/drawing_playback.cpp b/rosen/samples/2d_graphics/benchmarks/benchmark_dcl/drawing_playback.cpp index 6cb6e1c060..045bff98b6 100644 --- a/rosen/samples/2d_graphics/benchmarks/benchmark_dcl/drawing_playback.cpp +++ b/rosen/samples/2d_graphics/benchmarks/benchmark_dcl/drawing_playback.cpp @@ -381,17 +381,13 @@ void DrawingDCL::Test(Drawing::Canvas* canvas, int width, int height) case IterateType::REPLAY_MSKP: std::cout << "replay mskp... " << std::endl; #ifdef RS_ENABLE_VK - if (RSSystemProperties::IsUseVulkan()) { - UpdateParameters(ReplayMSKP(skiaCanvas_) || (beginFrame_ == 1)); - } + UpdateParameters(ReplayMSKP(skiaCanvas_) || (beginFrame_ == 1)); #endif break; case IterateType::REPLAY_SKP: std::cout << "replay skp... " << std::endl; #ifdef RS_ENABLE_VK - if (RSSystemProperties::IsUseVulkan()) { - ReplaySKP(skiaCanvas_); - } + ReplaySKP(skiaCanvas_); #endif break; case IterateType::OTHER: diff --git a/rosen/test/render_service/render_service_base/unittest/benchmarks/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/benchmarks/BUILD.gn index 538fa757d1..dca5e5951b 100644 --- a/rosen/test/render_service/render_service_base/unittest/benchmarks/BUILD.gn +++ b/rosen/test/render_service/render_service_base/unittest/benchmarks/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. import("//build/test.gni") -import("//foundation/graphic/graphic_2d/ace_platforms.gni") +import("//foundation/arkui/ace_engine/ace_config.gni") import("//foundation/graphic/graphic_2d/graphic_config.gni") module_output_path = "graphic/rosen_engine/render_service_base/benchmarks" @@ -28,7 +28,7 @@ ohos_unittest("RSRenderServiceBaseBenchmarksTest") { configs = [ ":render_test", - "$graphic_2d_root/rosen/modules/render_service_base:export_config", + "//foundation/graphic/graphic_2d/rosen/modules/render_service_base:export_config", ] cflags = [ @@ -37,13 +37,13 @@ ohos_unittest("RSRenderServiceBaseBenchmarksTest") { ] include_dirs = [ - "$graphic_2d_root/rosen/modules/render_service_base/include", - "$graphic_2d_root/rosen/include", - "$graphic_2d_root/rosen/test/include", + "//foundation/graphic/graphic_2d/rosen/modules/render_service_base/include", + "//foundation/graphic/graphic_2d/rosen/include", + "//foundation/graphic/graphic_2d/rosen/test/include", ] deps = [ - "$graphic_2d_root/rosen/modules/render_service_base:librender_service_base", + "//foundation/graphic/graphic_2d/rosen/modules/render_service_base:librender_service_base", "//third_party/googletest:gtest_main", ] external_deps = [ @@ -61,7 +61,7 @@ config("render_test") { visibility = [ ":*" ] include_dirs = [ "$ace_root", - "$graphic_2d_root/rosen/modules/render_service_base", + "//foundation/graphic/graphic_2d/rosen/modules/render_service_base", ] } From 76fa7998b348c68dc401fc50bce251896b6ce470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=AF=E9=91=AB?= Date: Sun, 28 Jul 2024 04:07:34 +0000 Subject: [PATCH 07/74] update rosen/test/render_service/render_service_base/unittest/benchmarks/BUILD.gn. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 凯鑫 --- .../unittest/benchmarks/BUILD.gn | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/rosen/test/render_service/render_service_base/unittest/benchmarks/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/benchmarks/BUILD.gn index dca5e5951b..a301a27f3c 100644 --- a/rosen/test/render_service/render_service_base/unittest/benchmarks/BUILD.gn +++ b/rosen/test/render_service/render_service_base/unittest/benchmarks/BUILD.gn @@ -28,7 +28,7 @@ ohos_unittest("RSRenderServiceBaseBenchmarksTest") { configs = [ ":render_test", - "//foundation/graphic/graphic_2d/rosen/modules/render_service_base:export_config", + "$graphic_2d_root/rosen/modules/render_service_base:export_config", ] cflags = [ @@ -37,13 +37,13 @@ ohos_unittest("RSRenderServiceBaseBenchmarksTest") { ] include_dirs = [ - "//foundation/graphic/graphic_2d/rosen/modules/render_service_base/include", - "//foundation/graphic/graphic_2d/rosen/include", - "//foundation/graphic/graphic_2d/rosen/test/include", + "$graphic_2d_root/rosen/modules/render_service_base/include", + "$graphic_2d_root/rosen/include", + "$graphic_2d_root/rosen/test/include", ] deps = [ - "//foundation/graphic/graphic_2d/rosen/modules/render_service_base:librender_service_base", + "$graphic_2d_root/rosen/modules/render_service_base:librender_service_base", "//third_party/googletest:gtest_main", ] external_deps = [ @@ -61,7 +61,7 @@ config("render_test") { visibility = [ ":*" ] include_dirs = [ "$ace_root", - "//foundation/graphic/graphic_2d/rosen/modules/render_service_base", + "$graphic_2d_root/rosen/modules/render_service_base", ] } @@ -69,4 +69,4 @@ group("unittest") { testonly = true deps = [ ":RSRenderServiceBaseBenchmarksTest" ] -} +} \ No newline at end of file From 049f3fb571012f93be96aced6699d2d6601ef0aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=AF=E9=91=AB?= Date: Sun, 28 Jul 2024 04:12:25 +0000 Subject: [PATCH 08/74] update rosen/test/render_service/render_service_base/unittest/benchmarks/BUILD.gn. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 凯鑫 --- .../render_service_base/unittest/benchmarks/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/test/render_service/render_service_base/unittest/benchmarks/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/benchmarks/BUILD.gn index a301a27f3c..9b2eff4048 100644 --- a/rosen/test/render_service/render_service_base/unittest/benchmarks/BUILD.gn +++ b/rosen/test/render_service/render_service_base/unittest/benchmarks/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. import("//build/test.gni") -import("//foundation/arkui/ace_engine/ace_config.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/benchmarks" From 1b1fbd39a18f5d8ef2c7f8f8c5db3f1e8229ac98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=AF=E9=91=AB?= Date: Sun, 28 Jul 2024 12:28:57 +0000 Subject: [PATCH 09/74] update rosen/test/render_service/render_service_base/unittest/benchmarks/BUILD.gn. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 凯鑫 --- .../render_service_base/unittest/benchmarks/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/test/render_service/render_service_base/unittest/benchmarks/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/benchmarks/BUILD.gn index 9b2eff4048..538fa757d1 100644 --- a/rosen/test/render_service/render_service_base/unittest/benchmarks/BUILD.gn +++ b/rosen/test/render_service/render_service_base/unittest/benchmarks/BUILD.gn @@ -69,4 +69,4 @@ group("unittest") { testonly = true deps = [ ":RSRenderServiceBaseBenchmarksTest" ] -} \ No newline at end of file +} From 0bb7220e2065b69d755ad963c44f407ac47937da Mon Sep 17 00:00:00 2001 From: l00844999 Date: Mon, 29 Jul 2024 15:14:11 +0800 Subject: [PATCH 10/74] deafult miterlimt fix Signed-off-by: l00844999 --- rosen/modules/2d_graphics/include/draw/paint.h | 4 +--- rosen/modules/2d_graphics/include/draw/pen.h | 2 ++ rosen/modules/2d_graphics/src/drawing/draw/paint.cpp | 2 +- rosen/modules/2d_graphics/src/drawing/draw/pen.cpp | 2 +- .../src/drawing/engine_adapter/skia_adapter/skia_paint.cpp | 2 +- rosen/test/2d_graphics/unittest/ndk/drawing_pen_test.cpp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rosen/modules/2d_graphics/include/draw/paint.h b/rosen/modules/2d_graphics/include/draw/paint.h index cd660ccecc..bbfb3a1e50 100644 --- a/rosen/modules/2d_graphics/include/draw/paint.h +++ b/rosen/modules/2d_graphics/include/draw/paint.h @@ -24,8 +24,6 @@ namespace Rosen { namespace Drawing { class DRAWING_API Paint { public: - constexpr static scalar DEFAULT_MITER_VAL = 4.0f; - Paint() noexcept; Paint(const Paint& other) noexcept; Paint(const Color& c, std::shared_ptr colorSpace = nullptr) noexcept; @@ -116,7 +114,7 @@ private: BlendMode blendMode_ = BlendMode::SRC_OVER; PaintStyle style_ = PaintStyle::PAINT_NONE; scalar width_ = 0.0f; - scalar miterLimit_ = DEFAULT_MITER_VAL; // default as 4.0f + scalar miterLimit_ = Pen::DEFAULT_MITER_VAL; // default as 4.0f Pen::JoinStyle join_ = Pen::JoinStyle::DEFAULT_JOIN; Pen::CapStyle cap_ = Pen::CapStyle::DEFAULT_CAP; diff --git a/rosen/modules/2d_graphics/include/draw/pen.h b/rosen/modules/2d_graphics/include/draw/pen.h index 247f2df95e..568c941c32 100644 --- a/rosen/modules/2d_graphics/include/draw/pen.h +++ b/rosen/modules/2d_graphics/include/draw/pen.h @@ -28,6 +28,8 @@ namespace Rosen { namespace Drawing { class DRAWING_API Pen { public: + constexpr static scalar DEFAULT_MITER_VAL = 4.0f; + enum class JoinStyle { MITER_JOIN, ROUND_JOIN, diff --git a/rosen/modules/2d_graphics/src/drawing/draw/paint.cpp b/rosen/modules/2d_graphics/src/drawing/draw/paint.cpp index dd5e4d7b35..7a4caf79aa 100644 --- a/rosen/modules/2d_graphics/src/drawing/draw/paint.cpp +++ b/rosen/modules/2d_graphics/src/drawing/draw/paint.cpp @@ -250,7 +250,7 @@ void Paint::Reset() blendMode_ = BlendMode::SRC_OVER; style_ = PaintStyle::PAINT_NONE; width_ = 0; - miterLimit_ = DEFAULT_MITER_VAL; + miterLimit_ = Pen::DEFAULT_MITER_VAL; join_ = Pen::JoinStyle::DEFAULT_JOIN; cap_ = Pen::CapStyle::DEFAULT_CAP; diff --git a/rosen/modules/2d_graphics/src/drawing/draw/pen.cpp b/rosen/modules/2d_graphics/src/drawing/draw/pen.cpp index f56e6a2f85..34df1531eb 100644 --- a/rosen/modules/2d_graphics/src/drawing/draw/pen.cpp +++ b/rosen/modules/2d_graphics/src/drawing/draw/pen.cpp @@ -22,7 +22,7 @@ namespace Rosen { namespace Drawing { Pen::Pen() noexcept : width_(0), - miterLimit_(-1), + miterLimit_(DEFAULT_MITER_VAL), join_(Pen::JoinStyle::MITER_JOIN), cap_(Pen::CapStyle::FLAT_CAP), pathEffect_(nullptr), diff --git a/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_paint.cpp b/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_paint.cpp index 4ef9f7390a..127e23ce96 100644 --- a/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_paint.cpp +++ b/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_paint.cpp @@ -149,7 +149,7 @@ void SkiaPaint::PaintToSkPaint(const Paint& paint, SkPaint& skPaint) void SkiaPaint::ApplyStrokeParam(const Paint& paint, SkPaint& skPaint) { - if (!IsScalarAlmostEqual(paint.GetMiterLimit(), Paint::DEFAULT_MITER_VAL)) { + if (!IsScalarAlmostEqual(paint.GetMiterLimit(), Pen::DEFAULT_MITER_VAL)) { skPaint.setStrokeMiter(paint.GetMiterLimit()); } skPaint.setStrokeWidth(paint.GetWidth()); diff --git a/rosen/test/2d_graphics/unittest/ndk/drawing_pen_test.cpp b/rosen/test/2d_graphics/unittest/ndk/drawing_pen_test.cpp index ab9647cf71..501fbf4511 100644 --- a/rosen/test/2d_graphics/unittest/ndk/drawing_pen_test.cpp +++ b/rosen/test/2d_graphics/unittest/ndk/drawing_pen_test.cpp @@ -203,7 +203,7 @@ HWTEST_F(NativeDrawingPenTest, NativeDrawingPenTest_penReset009, TestSize.Level1 EXPECT_EQ(OH_Drawing_PenIsAntiAlias(pen9), false); EXPECT_EQ(OH_Drawing_PenGetColor(pen9), 0xFF000000); EXPECT_EQ(OH_Drawing_PenGetWidth(pen9), 0); - EXPECT_EQ(OH_Drawing_PenGetMiterLimit(pen9), -1); + EXPECT_EQ(OH_Drawing_PenGetMiterLimit(pen9), 4.0f); EXPECT_EQ(OH_Drawing_PenGetCap(pen9), OH_Drawing_PenLineCapStyle::LINE_FLAT_CAP); EXPECT_EQ(OH_Drawing_PenGetJoin(pen9), OH_Drawing_PenLineJoinStyle::LINE_MITER_JOIN); From 9a994a0a65343118efe1a4c2fa14d7fc39a85bc5 Mon Sep 17 00:00:00 2001 From: dreamond_wxy Date: Fri, 26 Jul 2024 15:04:13 +0800 Subject: [PATCH 11/74] =?UTF-8?q?=E5=B8=A7=E5=8F=B7=E8=81=94=E5=8A=A8?= =?UTF-8?q?=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dreamond_wxy --- .../modules/render_service/core/pipeline/rs_main_thread.cpp | 6 ++++-- rosen/modules/render_service/core/pipeline/rs_main_thread.h | 1 + .../include/transaction/rs_transaction_proxy.h | 3 +++ .../src/transaction/rs_transaction_proxy.cpp | 6 ++++++ .../render_service_client/core/ui/rs_ui_director.cpp | 6 ++++++ .../modules/render_service_client/core/ui/rs_ui_director.h | 3 +++ 6 files changed, 23 insertions(+), 2 deletions(-) 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 bf21d9cc9a..f147374b55 100644 --- a/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp @@ -1037,6 +1037,7 @@ void RSMainThread::ProcessCommandForUniRender() } }); RS_TRACE_NAME("RSMainThread::ProcessCommandUni" + transactionFlags); + transactionFlags_ = transactionFlags; for (auto& rsTransactionElem: *transactionDataEffective) { for (auto& rsTransaction: rsTransactionElem.second) { if (rsTransaction) { @@ -3022,10 +3023,11 @@ void RSMainThread::SendCommands() void RSMainThread::RenderServiceTreeDump(std::string& dumpString, bool forceDumpSingleFrame) { - dumpString.append("-- current timeStamp: " + std::to_string(timestamp_) + "\n"); - dumpString.append("-- vsyncId: " + std::to_string(vsyncId_) + "\n"); if (LIKELY(forceDumpSingleFrame)) { RS_TRACE_NAME("GetDumpTree"); + dumpString.append("-- RS transactionFlags: " + transactionFlags_ + "\n"); + dumpString.append("-- current timeStamp: " + std::to_string(timestamp_) + "\n"); + dumpString.append("-- vsyncId: " + std::to_string(vsyncId_) + "\n"); dumpString.append("Animating Node: ["); for (auto& [nodeId, _]: context_->animatingNodeList_) { dumpString.append(std::to_string(nodeId) + ", "); 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 a3af2c02b8..038c76b296 100644 --- a/rosen/modules/render_service/core/pipeline/rs_main_thread.h +++ b/rosen/modules/render_service/core/pipeline/rs_main_thread.h @@ -491,6 +491,7 @@ private: uint64_t lastCleanCacheTimestamp_ = 0; pid_t lastCleanCachePid_ = -1; int hardwareTid_ = -1; + std::string transactionFlags_ = ""; std::unordered_map> applicationAgentMap_; std::shared_ptr context_; diff --git a/rosen/modules/render_service_base/include/transaction/rs_transaction_proxy.h b/rosen/modules/render_service_base/include/transaction/rs_transaction_proxy.h index 4618f0c924..b0449e3cd9 100644 --- a/rosen/modules/render_service_base/include/transaction/rs_transaction_proxy.h +++ b/rosen/modules/render_service_base/include/transaction/rs_transaction_proxy.h @@ -70,6 +70,8 @@ public: bool IsRemoteCommandEmpty(); + uint32_t GetTransactionDataIndex(); + private: RSTransactionProxy(); virtual ~RSTransactionProxy(); @@ -104,6 +106,7 @@ private: bool needSync_ { false }; uint64_t syncId_ { 0 }; FlushEmptyCallback flushEmptyCallback_ = nullptr; + uint32_t transactionDataIndex_ = 0; }; } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/transaction/rs_transaction_proxy.cpp b/rosen/modules/render_service_base/src/transaction/rs_transaction_proxy.cpp index 400480d496..a8d3d7facb 100644 --- a/rosen/modules/render_service_base/src/transaction/rs_transaction_proxy.cpp +++ b/rosen/modules/render_service_base/src/transaction/rs_transaction_proxy.cpp @@ -138,10 +138,16 @@ void RSTransactionProxy::FlushImplicitTransaction(uint64_t timestamp, const std: if (renderServiceClient_ != nullptr && !implicitRemoteTransactionData_->IsEmpty()) { implicitRemoteTransactionData_->timestamp_ = timestamp_; renderServiceClient_->CommitTransaction(implicitRemoteTransactionData_); + transactionDataIndex_ = implicitRemoteTransactionData_->GetIndex(); implicitRemoteTransactionData_ = std::make_unique(); } } +uint32_t RSTransactionProxy::GetTransactionDataIndex() +{ + return transactionDataIndex_; +} + void RSTransactionProxy::FlushImplicitTransactionFromRT(uint64_t timestamp) { std::unique_lock cmdLock(mutexForRT_); diff --git a/rosen/modules/render_service_client/core/ui/rs_ui_director.cpp b/rosen/modules/render_service_client/core/ui/rs_ui_director.cpp index fb98fc2110..de4c2839fa 100644 --- a/rosen/modules/render_service_client/core/ui/rs_ui_director.cpp +++ b/rosen/modules/render_service_client/core/ui/rs_ui_director.cpp @@ -340,9 +340,15 @@ void RSUIDirector::SendMessages() if (transactionProxy != nullptr) { transactionProxy->FlushImplicitTransaction(timeStamp_, abilityName_); } + index_ = transactionProxy->GetTransactionDataIndex(); ROSEN_TRACE_END(HITRACE_TAG_GRAPHIC_AGP); } +uint32_t RSUIDirector::GetIndex() +{ + return index_; +} + void RSUIDirector::RecvMessages() { if (GetRealPid() == -1) { diff --git a/rosen/modules/render_service_client/core/ui/rs_ui_director.h b/rosen/modules/render_service_client/core/ui/rs_ui_director.h index 9e4f166a27..9a68e810a8 100755 --- a/rosen/modules/render_service_client/core/ui/rs_ui_director.h +++ b/rosen/modules/render_service_client/core/ui/rs_ui_director.h @@ -72,6 +72,8 @@ public: int32_t GetCurrentRefreshRateMode(); int32_t GetAnimateExpectedRate() const; + uint32_t GetIndex(); + private: void AttachSurface(); static void RecvMessages(); @@ -96,6 +98,7 @@ private: bool isUniRenderEnabled_ = false; uint64_t refreshPeriod_ = 16666667; uint64_t timeStamp_ = 0; + uint32_t index_ = 0; std::string abilityName_; std::weak_ptr surfaceNode_; int surfaceWidth_ = 0; From 9896865c189858efe568de76810fdb23eda4ee0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E6=B5=B7?= Date: Mon, 29 Jul 2024 21:33:34 +0800 Subject: [PATCH 12/74] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王德海 Change-Id: I0e25d5c14b3b1aa7855cfd43985ff7ff065f8e10 --- .../src/pipeline/rs_canvas_drawing_render_node.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 979fc287ec..eb6eb42d44 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 @@ -41,7 +41,9 @@ namespace OHOS { namespace Rosen { - +namespace { +constexpr uint32_t DRAWCMDLIST_COUNT_LIMIT = 10; +} RSCanvasDrawingRenderNode::RSCanvasDrawingRenderNode( NodeId id, const std::weak_ptr& context, bool isTextureExportNode) : RSCanvasRenderNode(id, context, isTextureExportNode) @@ -497,6 +499,14 @@ void RSCanvasDrawingRenderNode::AddDirtyType(RSModifierType modifierType) SetNeedProcess(true); } } + // If such nodes are not drawn, The drawcmdlists don't clearOp during recording, As a result, there are + // too many drawOp, so we need to add the limit of drawcmdlists. + while ((GetOldDirtyInSurface().IsEmpty() || !IsDirty() || drawCmdListsVisited_) && + drawCmdLists_[type].size() > DRAWCMDLIST_COUNT_LIMIT) { + RS_LOGD("This Node[%{public}" PRIu64 "] with Modifier[%{public}hd] have drawcmdlist:%{public}zu", GetId(), + type, drawCmdLists_[type].size()); + drawCmdLists_[type].pop_front(); + } } } From b36bb0817f8fa39925f7bf6ba3b845b12b45d933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E6=B5=B7?= Date: Mon, 29 Jul 2024 21:59:00 +0800 Subject: [PATCH 13/74] =?UTF-8?q?=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王德海 Change-Id: If50c63c68b8ffc7e5cb40ebf29e3a9547bdd743d --- .../src/pipeline/rs_canvas_drawing_render_node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 eb6eb42d44..69dccff044 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 @@ -42,7 +42,7 @@ namespace OHOS { namespace Rosen { namespace { -constexpr uint32_t DRAWCMDLIST_COUNT_LIMIT = 10; +constexpr uint32_t DRAWCMDLIST_COUNT_LIMIT = 50; } RSCanvasDrawingRenderNode::RSCanvasDrawingRenderNode( NodeId id, const std::weak_ptr& context, bool isTextureExportNode) From bed24df7cf5f6ca76341d909cb9f0a913d2b34e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E6=B5=B7?= Date: Tue, 30 Jul 2024 09:47:59 +0800 Subject: [PATCH 14/74] =?UTF-8?q?=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王德海 Change-Id: I997c87e228267fb7601ecb9680032a629350d7ef --- .../src/pipeline/rs_canvas_drawing_render_node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 69dccff044..95681fff2c 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 @@ -501,7 +501,7 @@ void RSCanvasDrawingRenderNode::AddDirtyType(RSModifierType modifierType) } // If such nodes are not drawn, The drawcmdlists don't clearOp during recording, As a result, there are // too many drawOp, so we need to add the limit of drawcmdlists. - while ((GetOldDirtyInSurface().IsEmpty() || !IsDirty() || drawCmdListsVisited_) && + while ((GetOldDirtyInSurface().IsEmpty() || !IsDirty() || renderDrawable_->IsDrawCmdListsVisited()) && drawCmdLists_[type].size() > DRAWCMDLIST_COUNT_LIMIT) { RS_LOGD("This Node[%{public}" PRIu64 "] with Modifier[%{public}hd] have drawcmdlist:%{public}zu", GetId(), type, drawCmdLists_[type].size()); From 487273fac2fd13bc43d1ccfc3f6197deefa7d536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E6=B5=B7?= Date: Tue, 30 Jul 2024 10:00:13 +0800 Subject: [PATCH 15/74] =?UTF-8?q?=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王德海 Change-Id: Ia967d0053abccf52993c13a9caff2ab4b91fedff --- .../src/pipeline/rs_canvas_drawing_render_node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 95681fff2c..9ecdb43ffb 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 @@ -501,7 +501,7 @@ void RSCanvasDrawingRenderNode::AddDirtyType(RSModifierType modifierType) } // If such nodes are not drawn, The drawcmdlists don't clearOp during recording, As a result, there are // too many drawOp, so we need to add the limit of drawcmdlists. - while ((GetOldDirtyInSurface().IsEmpty() || !IsDirty() || renderDrawable_->IsDrawCmdListsVisited()) && + while ((GetOldDirtyInSurface().IsEmpty() || !IsDirty() || ((renderDrawable_ && renderDrawable_->IsDrawCmdListsVisited()))) && drawCmdLists_[type].size() > DRAWCMDLIST_COUNT_LIMIT) { RS_LOGD("This Node[%{public}" PRIu64 "] with Modifier[%{public}hd] have drawcmdlist:%{public}zu", GetId(), type, drawCmdLists_[type].size()); From ca764fd14e762b91901082cc0a1382a2530df3c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=85=B4=E5=8D=8E?= Date: Tue, 30 Jul 2024 02:29:55 +0000 Subject: [PATCH 16/74] fix codecheck MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈兴华 --- .../render_service_base/src/render/rs_material_filter.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rosen/modules/render_service_base/src/render/rs_material_filter.cpp b/rosen/modules/render_service_base/src/render/rs_material_filter.cpp index 027bcb9b87..a62a063f29 100644 --- a/rosen/modules/render_service_base/src/render/rs_material_filter.cpp +++ b/rosen/modules/render_service_base/src/render/rs_material_filter.cpp @@ -182,7 +182,10 @@ std::shared_ptr RSMaterialFilter::CreateMaterialFilter(flo { colorFilter_ = GetColorFilter(sat, brightness); auto blurType = KAWASE_BLUR_ENABLED ? Drawing::ImageBlurType::KAWASE : Drawing::ImageBlurType::GAUSS; - return Drawing::ImageFilter::CreateColorBlurImageFilter(*colorFilter_, radius, radius, blurType); + if (colorFilter_) { + return Drawing::ImageFilter::CreateColorBlurImageFilter(*colorFilter_, radius, radius, blurType); + } + return Drawing::ImageFilter::CreateBlurImageFilter(radius, radius, Drawing::TileMode::CLAMP, nullptr, BLUR_TYPE); } std::shared_ptr RSMaterialFilter::CreateMaterialStyle( From 57afd7b71f6c92dfe95cddff1427cdf9e00d389c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=85=B4=E5=8D=8E?= Date: Tue, 30 Jul 2024 02:33:30 +0000 Subject: [PATCH 17/74] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈兴华 --- .../render_service_base/src/render/rs_material_filter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/modules/render_service_base/src/render/rs_material_filter.cpp b/rosen/modules/render_service_base/src/render/rs_material_filter.cpp index a62a063f29..c063ef0660 100644 --- a/rosen/modules/render_service_base/src/render/rs_material_filter.cpp +++ b/rosen/modules/render_service_base/src/render/rs_material_filter.cpp @@ -185,7 +185,7 @@ std::shared_ptr RSMaterialFilter::CreateMaterialFilter(flo if (colorFilter_) { return Drawing::ImageFilter::CreateColorBlurImageFilter(*colorFilter_, radius, radius, blurType); } - return Drawing::ImageFilter::CreateBlurImageFilter(radius, radius, Drawing::TileMode::CLAMP, nullptr, BLUR_TYPE); + return Drawing::ImageFilter::CreateBlurImageFilter(radius, radius, Drawing::TileMode::CLAMP, nullptr, blurType); } std::shared_ptr RSMaterialFilter::CreateMaterialStyle( From e5a077e277be0f63b4905d39b5edaf6641dfe97b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=B2=E5=B0=98?= Date: Mon, 29 Jul 2024 10:14:04 +0800 Subject: [PATCH 18/74] =?UTF-8?q?=E6=96=87=E6=9C=AC=E6=94=BE=E5=A4=A7?= =?UTF-8?q?=E9=95=9C=E7=AE=97=E6=B3=95=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 闲尘 --- .../include/ge_magnifier_shader_filter.h | 6 +- .../include/ge_shader_filter_params.h | 34 ++++++++ .../include/ge_visual_effect_impl.h | 13 +++ .../src/ge_magnifier_shader_filter.cpp | 78 ++++++++--------- .../modules/graphics_effect/src/ge_render.cpp | 3 +- .../src/ge_visual_effect_impl.cpp | 83 ++++++++++++++++++- .../ge_magnifier_shader_filter_test.cpp | 36 ++++---- .../include/command/rs_node_command.h | 5 ++ .../include/modifier/rs_modifiers_def.in | 2 +- .../include/property/rs_properties.h | 7 +- .../include/render/rs_magnifier_para.h | 2 +- .../render/rs_magnifier_shader_filter.h | 7 +- .../transaction/rs_marshalling_helper.h | 2 + .../drawable/rs_property_drawable_utils.cpp | 15 ++-- .../platform/darwin/rs_marshalling_helper.cpp | 12 +++ .../platform/ohos/rs_marshalling_helper.cpp | 83 +++++++++++++++++++ .../windows/rs_marshalling_helper.cpp | 12 +++ .../src/property/rs_properties.cpp | 13 ++- .../src/property/rs_properties_painter.cpp | 18 ++-- .../src/render/rs_magnifier_shader_filter.cpp | 58 ++++++++++++- .../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 | 14 ++-- .../rs_magnifier_shader_filter_test.cpp | 37 ++++++++- .../unittest/ui/rs_node_test.cpp | 5 +- 27 files changed, 459 insertions(+), 102 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 44d0208edb..cd399ee5a3 100644 --- a/rosen/modules/graphics_effect/include/ge_magnifier_shader_filter.h +++ b/rosen/modules/graphics_effect/include/ge_magnifier_shader_filter.h @@ -36,8 +36,8 @@ public: float factor_ = 0.f; float width_ = 0.f; float height_ = 0.f; - float borderWidth_ = 0.f; float cornerRadius_ = 0.f; + float borderWidth_ = 0.f; float shadowOffsetX_ = 0.f; float shadowOffsetY_ = 0.f; @@ -49,11 +49,13 @@ public: uint32_t gradientMaskColor2_ = 0x00000000; uint32_t outerContourColor1_ = 0x00000000; uint32_t outerContourColor2_ = 0x00000000; + + int32_t rotateDegree_ = 0; }; class GEMagnifierShaderFilter : public GEShaderFilter { public: - GEMagnifierShaderFilter(); + GEMagnifierShaderFilter(const Drawing::GEMagnifierShaderFilterParams& params); GEMagnifierShaderFilter(const GEMagnifierShaderFilter&) = delete; GEMagnifierShaderFilter operator=(const GEMagnifierShaderFilter&) = delete; ~GEMagnifierShaderFilter() override = default; 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 1d44e1e3ca..5bb0b30aed 100644 --- a/rosen/modules/graphics_effect/include/ge_shader_filter_params.h +++ b/rosen/modules/graphics_effect/include/ge_shader_filter_params.h @@ -98,6 +98,40 @@ 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_CORNER_RADIUS[] = "CORNERRADIUS"; +constexpr char GE_FILTER_MAGNIFIER_BORDER_WIDTH[] = "BORDERWIDTH"; +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"; +constexpr char GE_FILTER_MAGNIFIER_ROTATE_DEGREE[] = "ROTATEDEGREE"; +struct GEMagnifierShaderFilterParams { + float factor = 0.f; + float width = 0.f; + float height = 0.f; + float cornerRadius = 0.f; + float borderWidth = 0.f; + + float shadowOffsetX = 0.f; + float shadowOffsetY = 0.f; + float shadowSize = 0.f; + float shadowStrength = 0.f; + + // rgba + uint32_t gradientMaskColor1 = 0x00000000; + uint32_t gradientMaskColor2 = 0x00000000; + uint32_t outerContourColor1 = 0x00000000; + uint32_t outerContourColor2 = 0x00000000; + + int32_t rotateDegree = 0; +}; } // 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 1329497438..a83ab28e3c 100644 --- a/rosen/modules/graphics_effect/include/ge_visual_effect_impl.h +++ b/rosen/modules/graphics_effect/include/ge_visual_effect_impl.h @@ -128,12 +128,24 @@ public: return hpsBlurParams_; } + void MakeMagnifierParams() + { + magnifierParams_ = std::make_shared(); + } + + const std::shared_ptr& GetMagnifierParams() const + { + return magnifierParams_; + } + private: static std::map> g_initialMap; void SetAIBarParams(const std::string& tag, float param); void SetGreyParams(const std::string& tag, float param); void SetLinearGradientBlurParams(const std::string& tag, float param); + void SetMagnifierParamsFloat(const std::string& tag, float param); + void SetMagnifierParamsUint32(const std::string& tag, uint32_t param); void SetWaterRippleParams(const std::string& tag, float param); void SetHpsBlurParams(const std::string& tag, float param); @@ -143,6 +155,7 @@ private: std::shared_ptr aiBarParams_ = nullptr; std::shared_ptr greyParams_ = nullptr; std::shared_ptr linearGradientBlurParams_ = nullptr; + std::shared_ptr magnifierParams_ = nullptr; std::shared_ptr waterRippleParams_ = nullptr; std::shared_ptr hpsBlurParams_ = nullptr; }; 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 b4b294a54f..accdf9a381 100644 --- a/rosen/modules/graphics_effect/src/ge_magnifier_shader_filter.cpp +++ b/rosen/modules/graphics_effect/src/ge_magnifier_shader_filter.cpp @@ -21,43 +21,43 @@ 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::g_magnifierShaderEffect = nullptr; -GEMagnifierShaderFilter::GEMagnifierShaderFilter() {} +GEMagnifierShaderFilter::GEMagnifierShaderFilter(const Drawing::GEMagnifierShaderFilterParams& params) +{ + magnifierPara_ = std::make_shared(); + if (!magnifierPara_) { + return; + } + magnifierPara_->factor_ = params.factor; + magnifierPara_->width_ = params.width; + magnifierPara_->height_ = params.height; + magnifierPara_->cornerRadius_ = params.cornerRadius; + magnifierPara_->borderWidth_ = params.borderWidth; + 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; + magnifierPara_->rotateDegree_ = params.rotateDegree; +} std::shared_ptr GEMagnifierShaderFilter::ProcessImage(Drawing::Canvas& canvas, const std::shared_ptr image, const Drawing::Rect& src, const Drawing::Rect& dst) { - if (image == nullptr) { + if (image == nullptr || magnifierPara_ == nullptr) { LOGE("GEMagnifierShaderFilter::ProcessImage image or para is null"); return image; } Drawing::Matrix matrix; + matrix.Rotate(magnifierPara_->rotateDegree_, src.GetLeft() + src.GetWidth() / 2.0f, + src.GetTop() + src.GetHeight() / 2.0f); // 2.0 center of rect auto imageShader = Drawing::ShaderEffect::CreateImageShader(*image, Drawing::TileMode::CLAMP, Drawing::TileMode::CLAMP, Drawing::SamplingOptions(Drawing::FilterMode::LINEAR), matrix); float imageWidth = image->GetWidth(); @@ -68,7 +68,10 @@ std::shared_ptr GEMagnifierShaderFilter::ProcessImage(Drawing::C return image; } - auto resultImage = builder->MakeImage(canvas.GetGPUContext().get(), nullptr, image->GetImageInfo(), false); + Drawing::Matrix invMatrix; + invMatrix.Rotate(-magnifierPara_->rotateDegree_, src.GetLeft() + src.GetWidth() / 2.0f, + src.GetTop() + src.GetHeight() / 2.0f); // 2.0 center of rect + auto resultImage = builder->MakeImage(canvas.GetGPUContext().get(), &invMatrix, image->GetImageInfo(), false); if (resultImage == nullptr) { LOGE("GEMagnifierShaderFilter::ProcessImage resultImage is null"); return image; @@ -87,8 +90,7 @@ std::shared_ptr GEMagnifierShaderFilter::MakeMagn } } - auto magnifierPara = GetMagnifierParams(); - if (magnifierPara == nullptr) { + if (magnifierPara_ == nullptr) { return nullptr; } std::shared_ptr builder = @@ -96,23 +98,23 @@ std::shared_ptr GEMagnifierShaderFilter::MakeMagn 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("factor", magnifierPara_->factor_); + builder->SetUniform("size", magnifierPara_->width_, magnifierPara_->height_); + builder->SetUniform("cornerRadius", magnifierPara_->cornerRadius_); + builder->SetUniform("borderWidth", magnifierPara_->borderWidth_); - builder->SetUniform("shadowOffset", magnifierPara->shadowOffsetX_, magnifierPara->shadowOffsetY_); - builder->SetUniform("shadowSize", magnifierPara->shadowSize_); - builder->SetUniform("shadowStrength", magnifierPara->shadowStrength_); + 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); + 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); diff --git a/rosen/modules/graphics_effect/src/ge_render.cpp b/rosen/modules/graphics_effect/src/ge_render.cpp index d0024e19f1..f523bd1535 100644 --- a/rosen/modules/graphics_effect/src/ge_render.cpp +++ b/rosen/modules/graphics_effect/src/ge_render.cpp @@ -114,7 +114,8 @@ std::vector> GERender::GenerateShaderFilter( break; } case Drawing::GEVisualEffectImpl::FilterType::MAGNIFIER: { - shaderFilter = std::make_shared(); + const auto& magnifierParams = ve->GetMagnifierParams(); + shaderFilter = std::make_shared(*magnifierParams); 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 844acc8142..f1e35be2d7 100644 --- a/rosen/modules/graphics_effect/src/ge_visual_effect_impl.cpp +++ b/rosen/modules/graphics_effect/src/ge_visual_effect_impl.cpp @@ -63,6 +63,7 @@ std::map> GEVisualEf { GE_FILTER_MAGNIFIER, [](GEVisualEffectImpl* impl) { impl->SetFilterType(GEVisualEffectImpl::FilterType::MAGNIFIER); + impl->MakeMagnifierParams(); } } }; @@ -100,6 +101,16 @@ void GEVisualEffectImpl::SetParam(const std::string& tag, int32_t param) } break; } + case FilterType::MAGNIFIER: { + if (magnifierParams_ == nullptr) { + return; + } + + if (tag == GE_FILTER_MAGNIFIER_ROTATE_DEGREE) { + magnifierParams_->rotateDegree = param; + } + break; + } default: break; } @@ -141,6 +152,10 @@ void GEVisualEffectImpl::SetParam(const std::string& tag, float param) SetLinearGradientBlurParams(tag, param); break; } + case FilterType::MAGNIFIER: { + SetMagnifierParamsFloat(tag, param); + break; + } case FilterType::HPS_BLUR: { SetHpsBlurParams(tag, param); break; @@ -197,7 +212,17 @@ 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_CORNER_RADIUS, + [](GEVisualEffectImpl* obj, float p) { obj->magnifierParams_->cornerRadius = p; } }, + { GE_FILTER_MAGNIFIER_BORDER_WIDTH, + [](GEVisualEffectImpl* obj, float p) { obj->magnifierParams_->borderWidth = 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); + } +} + void GEVisualEffectImpl::SetWaterRippleParams(const std::string& tag, float param) { if (waterRippleParams_ == nullptr) { 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 3bcc78f7af..447305852c 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 @@ -66,7 +66,9 @@ void GEMagnifierShaderFilterTest::TearDown() {} */ HWTEST_F(GEMagnifierShaderFilterTest, GetDescription001, TestSize.Level1) { - auto filter = std::make_shared(); + Drawing::GEMagnifierShaderFilterParams params{1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0x00000000, 0x00000000, + 0x00000000, 0x00000000}; + auto filter = std::make_shared(params); ASSERT_TRUE(filter != nullptr); std::string expectStr = "GEMagnifierShaderFilter"; @@ -80,7 +82,9 @@ HWTEST_F(GEMagnifierShaderFilterTest, GetDescription001, TestSize.Level1) */ HWTEST_F(GEMagnifierShaderFilterTest, ProcessImage001, TestSize.Level1) { - auto filter = std::make_shared(); + Drawing::GEMagnifierShaderFilterParams params{1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0x00000000, 0x00000000, + 0x00000000, 0x00000000}; + auto filter = std::make_shared(params); ASSERT_TRUE(filter != nullptr); std::shared_ptr image = nullptr; @@ -94,7 +98,9 @@ HWTEST_F(GEMagnifierShaderFilterTest, ProcessImage001, TestSize.Level1) */ HWTEST_F(GEMagnifierShaderFilterTest, ProcessImage002, TestSize.Level1) { - auto filter = std::make_shared(); + Drawing::GEMagnifierShaderFilterParams params{1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0x00000000, 0x00000000, + 0x00000000, 0x00000000}; + auto filter = std::make_shared(params); ASSERT_TRUE(filter != nullptr); EXPECT_EQ(filter->ProcessImage(canvas_, image_, src_, dst_), image_); @@ -107,21 +113,15 @@ HWTEST_F(GEMagnifierShaderFilterTest, ProcessImage002, TestSize.Level1) */ HWTEST_F(GEMagnifierShaderFilterTest, ProcessImage003, TestSize.Level1) { - auto filter = std::make_shared(); + Drawing::GEMagnifierShaderFilterParams params{1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0x00000000, 0x00000000, + 0x00000000, 0x00000000}; + auto filter = std::make_shared(params); 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_EQ(filter->ProcessImage(canvas_, image_, src, dst), image_); -#define GE_OHOS -#else -#define GE_OHOS - EXPECT_EQ(filter->ProcessImage(canvas_, image_, src, dst), image_); -#undef GE_OHOS -#endif } /** @@ -131,7 +131,9 @@ HWTEST_F(GEMagnifierShaderFilterTest, ProcessImage003, TestSize.Level1) */ HWTEST_F(GEMagnifierShaderFilterTest, ProcessImage004, TestSize.Level1) { - auto filter = std::make_shared(); + Drawing::GEMagnifierShaderFilterParams params{1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0x00000000, 0x00000000, + 0x00000000, 0x00000000}; + auto filter = std::make_shared(params); ASSERT_TRUE(filter != nullptr); EXPECT_EQ(filter->ProcessImage(canvas_, image_, src_, dst_), image_); @@ -148,7 +150,9 @@ HWTEST_F(GEMagnifierShaderFilterTest, ProcessImage004, TestSize.Level1) */ HWTEST_F(GEMagnifierShaderFilterTest, ConvertToRgba001, TestSize.Level1) { - auto filter = std::make_shared(); + Drawing::GEMagnifierShaderFilterParams params{1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0x00000000, 0x00000000, + 0x00000000, 0x00000000}; + auto filter = std::make_shared(params); ASSERT_TRUE(filter != nullptr); uint32_t color1 = uint32_t(0x80808000); @@ -163,7 +167,9 @@ HWTEST_F(GEMagnifierShaderFilterTest, ConvertToRgba001, TestSize.Level1) */ HWTEST_F(GEMagnifierShaderFilterTest, ConvertToRgba002, TestSize.Level1) { - auto filter = std::make_shared(); + Drawing::GEMagnifierShaderFilterParams params{1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0x00000000, 0x00000000, + 0x00000000, 0x00000000}; + auto filter = std::make_shared(params); ASSERT_TRUE(filter != nullptr); uint32_t color1 = uint32_t(0x80808000); 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 4eaa145633..60b0115d62 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 @@ -69,6 +69,7 @@ enum RSNodeCommandType : uint16_t { SET_NODE_NAME, UPDATE_MODIFIER_MOTION_BLUR_PTR, + UPDATE_MODIFIER_MAGNIFIER_PTR, UPDATE_MODIFIER_WATER_RIPPLE, REMOVE_ALL_MODIFIERS, }; @@ -197,6 +198,10 @@ 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 a824cd8fb1..83d4810b04 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, Vector2f, MAGNIFIER_PARA, Foreground) +DECLARE_NOANIMATABLE_MODIFIER(MagnifierParams, std::shared_ptr, 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 4eda40f994..65be4f43cc 100644 --- a/rosen/modules/render_service_base/include/property/rs_properties.h +++ b/rosen/modules/render_service_base/include/property/rs_properties.h @@ -35,6 +35,7 @@ #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" @@ -286,7 +287,7 @@ public: void SetFilter(const std::shared_ptr& filter); void SetMotionBlurPara(const std::shared_ptr& para); - void SetMagnifierParams(const std::optional& para); + void SetMagnifierParams(const std::shared_ptr& para); const std::shared_ptr& GetBackgroundFilter() const; const std::shared_ptr& GetLinearGradientBlurPara() const; const std::vector>& GetEmitterUpdater() const; @@ -294,7 +295,7 @@ public: void IfLinearGradientBlurInvalid(); const std::shared_ptr& GetFilter() const; const std::shared_ptr& GetMotionBlurPara() const; - const std::optional& GetMagnifierPara() const; + const std::shared_ptr& GetMagnifierPara() const; bool NeedFilter() const; void SetGreyCoef(const std::optional& greyCoef); const std::optional& GetGreyCoef() const; @@ -616,6 +617,7 @@ 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; @@ -678,7 +680,6 @@ 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_para.h b/rosen/modules/render_service_base/include/render/rs_magnifier_para.h index f0ce28ea44..b4082bd0c8 100644 --- a/rosen/modules/render_service_base/include/render/rs_magnifier_para.h +++ b/rosen/modules/render_service_base/include/render/rs_magnifier_para.h @@ -25,8 +25,8 @@ public: float factor_ = 0.f; float width_ = 0.f; float height_ = 0.f; - float borderWidth_ = 0.f; float cornerRadius_ = 0.f; + float borderWidth_ = 0.f; float offsetX_ = 0.f; float offsetY_ = 0.f; 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 7388a9d8a7..bf96f508a1 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 "common/rs_vector2.h" +#include "render/rs_magnifier_para.h" #include "render/rs_shader_filter.h" namespace OHOS { @@ -23,19 +23,22 @@ namespace Rosen { class RSB_EXPORT RSMagnifierShaderFilter : public RSShaderFilter { public: - RSMagnifierShaderFilter(float offsetX, float offsetY); + RSMagnifierShaderFilter(const std::shared_ptr& para); RSMagnifierShaderFilter(const RSMagnifierShaderFilter&) = delete; RSMagnifierShaderFilter operator=(const RSMagnifierShaderFilter&) = delete; ~RSMagnifierShaderFilter() override; void GenerateGEVisualEffect(std::shared_ptr visualEffectContainer) override; + void SetMagnifierOffset(Drawing::Matrix& mat); 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; + int32_t rotateDegree_ = 0; }; } // 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 e4b6a42c48..3684132d57 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,6 +51,7 @@ class RSMask; class RSPath; class RSLinearGradientBlurPara; class MotionBlurParam; +class RSMagnifierParams; class EmitterUpdater; class ParticleNoiseField; class ParticleNoiseFields; @@ -235,6 +236,7 @@ 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 5b19502bc1..319f6d3f66 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 @@ -352,6 +352,15 @@ void RSPropertyDrawableUtils::DrawFilter(Drawing::Canvas* canvas, if (isForegroundFilter) { paintFilterCanvas->SetAlpha(1.0); } + auto imageClipIBounds = clipIBounds; + std::shared_ptr magnifierShaderFilter = + filter->GetShaderFilterWithType(RSShaderFilter::MAGNIFIER); + if (magnifierShaderFilter != nullptr) { + auto tmpFilter = std::static_pointer_cast(magnifierShaderFilter); + auto canvasMatrix = canvas->GetTotalMatrix(); + tmpFilter->SetMagnifierOffset(canvasMatrix); + imageClipIBounds.Offset(tmpFilter->GetMagnifierOffsetX(), tmpFilter->GetMagnifierOffsetY()); + } #if defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK) // Optional use cacheManager to draw filter @@ -377,12 +386,6 @@ void RSPropertyDrawableUtils::DrawFilter(Drawing::Canvas* canvas, tmpFilter->IsOffscreenCanvas(true); filter->SetSnapshotOutset(false); } - auto imageClipIBounds = clipIBounds; - std::shared_ptr magnifierShaderFilter = filter->GetShaderFilterWithType(RSShaderFilter::MAGNIFIER); - if (magnifierShaderFilter != nullptr) { - auto tmpFilter = std::static_pointer_cast(magnifierShaderFilter); - imageClipIBounds.Offset(tmpFilter->GetMagnifierOffsetX(), tmpFilter->GetMagnifierOffsetY()); - } auto imageSnapshot = surface->GetImageSnapshot(imageClipIBounds); if (imageSnapshot == nullptr) { 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 19dc27c335..525c4e5578 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,6 +43,7 @@ #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" @@ -173,6 +174,16 @@ 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) { @@ -458,6 +469,7 @@ 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 08d2f4598d..78443c07db 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,6 +47,7 @@ #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" @@ -654,6 +655,87 @@ 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->cornerRadius_); + success = success && Marshalling(parcel, val->borderWidth_); + 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 cornerRadius; + float borderWidth; + float offsetX; + float offsetY; + float shadowOffsetX; + float shadowOffsetY; + float shadowSize; + float shadowStrength; + uint32_t gradientMaskColor1; + uint32_t gradientMaskColor2; + uint32_t outerContourColor1; + uint32_t outerContourColor2; + + val = std::make_shared(); + if (val == nullptr) { return false; } + + bool success = Unmarshalling(parcel, factor); + if (success) { val->factor_ = factor; } + success = success && Unmarshalling(parcel, width); + if (success) { val->width_ = width; } + success = success && Unmarshalling(parcel, height); + if (success) { val->height_ = height; } + success = success && Unmarshalling(parcel, cornerRadius); + if (success) { val->cornerRadius_ = cornerRadius; } + success = success && Unmarshalling(parcel, borderWidth); + if (success) { val->borderWidth_ = borderWidth; } + success = success && Unmarshalling(parcel, offsetX); + if (success) { val->offsetX_ = offsetX; } + success = success && Unmarshalling(parcel, offsetY); + if (success) { val->offsetY_ = offsetY; } + + success = success && Unmarshalling(parcel, shadowOffsetX); + if (success) { val->shadowOffsetX_ = shadowOffsetX; } + success = success && Unmarshalling(parcel, shadowOffsetY); + if (success) { val->shadowOffsetY_ = shadowOffsetY; } + success = success && Unmarshalling(parcel, shadowSize); + if (success) { val->shadowSize_ = shadowSize; } + success = success && Unmarshalling(parcel, shadowStrength); + if (success) { val->shadowStrength_ = shadowStrength; } + + success = success && Unmarshalling(parcel, gradientMaskColor1); + if (success) { val->gradientMaskColor1_ = gradientMaskColor1; } + success = success && Unmarshalling(parcel, gradientMaskColor2); + if (success) { val->gradientMaskColor2_ = gradientMaskColor2; } + success = success && Unmarshalling(parcel, outerContourColor1); + if (success) { val->outerContourColor1_ = outerContourColor1; } + success = success && Unmarshalling(parcel, outerContourColor2); + if (success) { val->outerContourColor2_ = outerContourColor2; } + + return success; +} + // Particle bool RSMarshallingHelper::Marshalling(Parcel& parcel, const std::shared_ptr& val) { @@ -1880,6 +1962,7 @@ 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 670309d3d8..2abcb66409 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,6 +43,7 @@ #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" @@ -176,6 +177,16 @@ 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) { @@ -458,6 +469,7 @@ 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_properties.cpp b/rosen/modules/render_service_base/src/property/rs_properties.cpp index 6ab58a44ae..5b0c22775c 100644 --- a/rosen/modules/render_service_base/src/property/rs_properties.cpp +++ b/rosen/modules/render_service_base/src/property/rs_properties.cpp @@ -1691,11 +1691,11 @@ void RSProperties::SetMotionBlurPara(const std::shared_ptr& par contentDirty_ = true; } -void RSProperties::SetMagnifierParams(const std::optional& para) +void RSProperties::SetMagnifierParams(const std::shared_ptr& para) { magnifierPara_ = para; - if (para.has_value()) { + if (para) { isDrawn_ = true; } SetDirty(); @@ -1703,7 +1703,7 @@ void RSProperties::SetMagnifierParams(const std::optional& para) contentDirty_ = true; } -const std::optional& RSProperties::GetMagnifierPara() const +const std::shared_ptr& RSProperties::GetMagnifierPara() const { return magnifierPara_; } @@ -2914,7 +2914,7 @@ void RSProperties::GenerateLinearGradientBlurFilter() void RSProperties::GenerateMagnifierFilter() { - auto magnifierFilter = std::make_shared(magnifierPara_->x_, magnifierPara_->y_); + auto magnifierFilter = std::make_shared(magnifierPara_); std::shared_ptr originalFilter = std::make_shared(magnifierFilter); backgroundFilter_ = originalFilter; @@ -2944,7 +2944,7 @@ void RSProperties::GenerateBackgroundFilter() { if (aiInvert_.has_value() || systemBarEffect_) { GenerateAIBarFilter(); - } else if (magnifierPara_.has_value()) { + } else if (magnifierPara_ && ROSEN_GNE(magnifierPara_->factor_, 0.f)) { GenerateMagnifierFilter(); } else if (IsBackgroundMaterialFilterValid()) { GenerateBackgroundMaterialBlurFilter(); @@ -4129,8 +4129,7 @@ void RSProperties::UpdateFilter() IsDynamicLightUpValid() || greyCoef_.has_value() || linearGradientBlurPara_ != nullptr || IsDynamicDimValid() || GetShadowColorStrategy() != SHADOW_COLOR_STRATEGY::COLOR_STRATEGY_NONE || foregroundFilter_ != nullptr || IsFgBrightnessValid() || - IsBgBrightnessValid() || foregroundFilterCache_ != nullptr || IsWaterRippleValid() || - magnifierPara_.has_value(); + IsBgBrightnessValid() || foregroundFilterCache_ != nullptr || IsWaterRippleValid(); } 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 d9c0def6bb..156209383d 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 @@ -685,6 +685,17 @@ void RSPropertiesPainter::DrawFilter(const RSProperties& properties, RSPaintFilt canvas.SetAlpha(1.0); } + auto clipIBounds = canvas.GetDeviceClipBounds(); + auto imageClipIBounds = clipIBounds; + std::shared_ptr magnifierShaderFilter = + filter->GetShaderFilterWithType(RSShaderFilter::MAGNIFIER); + if (magnifierShaderFilter != nullptr) { + auto tmpFilter = std::static_pointer_cast(magnifierShaderFilter); + auto canvasMatrix = canvas.GetTotalMatrix(); + tmpFilter->SetMagnifierOffset(canvasMatrix); + imageClipIBounds.Offset(tmpFilter->GetMagnifierOffsetX(), tmpFilter->GetMagnifierOffsetY()); + } + #if defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK) // Optional use cacheManager to draw filter if (auto& cacheManager = properties.GetFilterCacheManager(filterType == FilterType::FOREGROUND_FILTER); @@ -710,14 +721,7 @@ void RSPropertiesPainter::DrawFilter(const RSProperties& properties, RSPaintFilt tmpFilter->IsOffscreenCanvas(true); tmpFilter->SetGeometry(canvas, properties.GetFrameWidth(), properties.GetFrameHeight()); } - auto clipIBounds = canvas.GetDeviceClipBounds(); - auto imageClipIBounds = clipIBounds; - std::shared_ptr magnifierShaderFilter = filter->GetShaderFilterWithType(RSShaderFilter::MAGNIFIER); - if (magnifierShaderFilter != nullptr) { - auto tmpFilter = std::static_pointer_cast(magnifierShaderFilter); - imageClipIBounds.Offset(tmpFilter->GetMagnifierOffsetX(), tmpFilter->GetMagnifierOffsetY()); - } auto imageSnapshot = surface->GetImageSnapshot(imageClipIBounds); if (imageSnapshot == nullptr) { ROSEN_LOGD("RSPropertiesPainter::DrawFilter image null"); 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 7c7a37895a..a2ca8cabc3 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 @@ -19,13 +19,15 @@ namespace OHOS { namespace Rosen { +namespace { +constexpr static float FLOAT_ZERO_THRESHOLD = 0.001f; +} // namespace -RSMagnifierShaderFilter::RSMagnifierShaderFilter(float offsetX, float offsetY) - : offsetX_(offsetX), offsetY_(offsetY) +RSMagnifierShaderFilter::RSMagnifierShaderFilter(const std::shared_ptr& para) + : magnifierPara_(para) { type_ = ShaderFilterType::MAGNIFIER; - hash_ = SkOpts::hash(&offsetX_, sizeof(offsetX_), hash_); - hash_ = SkOpts::hash(&offsetY_, sizeof(offsetY_), hash_); + hash_ = SkOpts::hash(&magnifierPara_, sizeof(magnifierPara_), hash_); } RSMagnifierShaderFilter::~RSMagnifierShaderFilter() = default; @@ -33,14 +35,62 @@ 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("CORNERRADIUS", magnifierPara_->cornerRadius_); + magnifierFilter->SetParam("BORDERWIDTH", magnifierPara_->borderWidth_); + 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_); + magnifierFilter->SetParam("ROTATEDEGREE", rotateDegree_); visualEffectContainer->AddToChainedFilter(magnifierFilter); } +void RSMagnifierShaderFilter::SetMagnifierOffset(Drawing::Matrix& mat) +{ + if (!magnifierPara_) { + ROSEN_LOGD("RSMagnifierShaderFilter::SetMagnifierOffset magnifierPara_ is nullptr!"); + return; + } + + // 1 and 3 represents index + if ((mat.Get(1) > FLOAT_ZERO_THRESHOLD) && (mat.Get(3) < (0 - FLOAT_ZERO_THRESHOLD))) { + rotateDegree_ = 90; // 90 represents rotate degree + offsetX_ = magnifierPara_->offsetY_; + offsetY_ = -magnifierPara_->offsetX_; + // 0 and 4 represents index + } else if ((mat.Get(0) < (0 - FLOAT_ZERO_THRESHOLD)) && (mat.Get(4) < (0 - FLOAT_ZERO_THRESHOLD))) { + rotateDegree_ = 180; // 180 represents rotate degree + offsetX_ = -magnifierPara_->offsetX_; + offsetY_ = -magnifierPara_->offsetY_; + // 1 and 3 represents index + } else if ((mat.Get(1) < (0 - FLOAT_ZERO_THRESHOLD)) && (mat.Get(3) > FLOAT_ZERO_THRESHOLD)) { + rotateDegree_ = 270; // 270 represents rotate degree + offsetX_ = -magnifierPara_->offsetY_; + offsetY_ = magnifierPara_->offsetX_; + } else { + rotateDegree_ = 0; + offsetX_ = magnifierPara_->offsetX_; + offsetY_ = magnifierPara_->offsetY_; + } +} + } // namespace Rosen } // namespace OHOS 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 998ae972d2..106450bf7b 100644 --- a/rosen/modules/render_service_client/core/modifier/rs_property.cpp +++ b/rosen/modules/render_service_client/core/modifier/rs_property.cpp @@ -260,6 +260,12 @@ 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 ef45f853d8..f5b1f6a97b 100644 --- a/rosen/modules/render_service_client/core/modifier/rs_property.h +++ b/rosen/modules/render_service_client/core/modifier/rs_property.h @@ -718,6 +718,9 @@ 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 32c47d23b9..f47e3863d0 100755 --- a/rosen/modules/render_service_client/core/ui/rs_node.cpp +++ b/rosen/modules/render_service_client/core/ui/rs_node.cpp @@ -480,9 +480,10 @@ void RSNode::SetMotionPathOption(const std::shared_ptr& moti UpdateModifierMotionPathOption(); } -void RSNode::SetMagnifierParams(const Vector2f& para) +void RSNode::SetMagnifierParams(const std::shared_ptr& 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 3991b4fd6f..2b83c46e87 100755 --- a/rosen/modules/render_service_client/core/ui/rs_node.h +++ b/rosen/modules/render_service_client/core/ui/rs_node.h @@ -292,7 +292,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 Vector2f& para); + void SetMagnifierParams(const std::shared_ptr& 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 e573c8d30e..613b00da90 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 @@ -1704,10 +1704,13 @@ HWTEST_F(RSPropertiesTest, SetMotionBlurPara001, TestSize.Level1) HWTEST_F(RSPropertiesTest, SetMagnifierParams001, TestSize.Level1) { RSProperties properties; - std::optional para({1.f, 1.f}); + auto para = std::make_shared(); properties.SetMagnifierParams(para); - ASSERT_TRUE(properties.GetMagnifierPara().has_value()); - EXPECT_EQ(properties.GetMagnifierPara().value(), para.value()); + EXPECT_NE(properties.GetMagnifierPara(), nullptr); + + para->factor_ = 1.f; + properties.SetMagnifierParams(para); + EXPECT_NE(para, nullptr); } /** @@ -1719,8 +1722,9 @@ HWTEST_F(RSPropertiesTest, SetMagnifierParams001, TestSize.Level1) HWTEST_F(RSPropertiesTest, SetMagnifierParams002, TestSize.Level1) { RSProperties properties; - properties.SetMagnifierParams(std::nullopt); - EXPECT_EQ(properties.GetMagnifierPara(), std::nullopt); + std::shared_ptr para; + properties.SetMagnifierParams(para); + EXPECT_EQ(properties.GetMagnifierPara(), nullptr); } /** 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 index 54f9824901..8475d4eff5 100644 --- 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 @@ -42,12 +42,40 @@ void RSMagnifierShaderFilterTest::TearDown() {} */ HWTEST_F(RSMagnifierShaderFilterTest, GenerateGEVisualEffectTest, TestSize.Level1) { - auto rsMagnifierShaderFilter = std::make_shared(0.1f, 0.1f); + auto para = std::make_shared(); + auto rsMagnifierShaderFilter = std::make_shared(para); auto visualEffectContainer = std::make_shared(); rsMagnifierShaderFilter->GenerateGEVisualEffect(visualEffectContainer); EXPECT_FALSE(visualEffectContainer->filterVec_.empty()); } +/** + * @tc.name: SetMagnifierOffsetTest + * @tc.desc: Verify function SetMagnifierOffsetTest + * @tc.type:FUNC + * @tc.require: issuesI9UWCD + */ +HWTEST_F(RSMagnifierShaderFilterTest, SetMagnifierOffsetTest, TestSize.Level1) +{ + auto para = std::make_shared(); + auto rsMagnifierShaderFilter = std::make_shared(para); + + Drawing::Matrix matrix1; + matrix1.PostRotate(90); // 90 degree + rsMagnifierShaderFilter->SetMagnifierOffset(matrix1); + + Drawing::Matrix matrix2; + matrix2.PostRotate(180); // 180 degree + rsMagnifierShaderFilter->SetMagnifierOffset(matrix2); + + Drawing::Matrix matrix3; + matrix3.PostRotate(270); // 270 degree + rsMagnifierShaderFilter->SetMagnifierOffset(matrix3); + + Drawing::Matrix matrix4; // 0 degree + rsMagnifierShaderFilter->SetMagnifierOffset(matrix4); +} + /** * @tc.name: GetMagnifierOffsetTest * @tc.desc: Verify function GetMagnifierOffsetTest @@ -56,9 +84,10 @@ HWTEST_F(RSMagnifierShaderFilterTest, GenerateGEVisualEffectTest, TestSize.Level */ 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); + auto para = std::make_shared(); + auto rsMagnifierShaderFilter = std::make_shared(para); + EXPECT_EQ(rsMagnifierShaderFilter->GetMagnifierOffsetX(), 0.f); + EXPECT_EQ(rsMagnifierShaderFilter->GetMagnifierOffsetY(), 0.f); } } // 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 bf62faf142..9e1db34b19 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 @@ -5366,13 +5366,14 @@ HWTEST_F(RSNodeTest, SetMotionBlurPara, TestSize.Level1) HWTEST_F(RSNodeTest, SetMagnifierParams, TestSize.Level1) { auto rsNode = RSCanvasNode::Create(); - Vector2f para = { 1.f, 1.f }; // for test ASSERT_TRUE(rsNode != nullptr); + auto para = std::make_shared(); 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()); + auto property = std::static_pointer_cast>>( + iter->second->GetProperty()); ASSERT_TRUE(property != nullptr); EXPECT_EQ(property->Get(), para); } From 350cc9858e6d64d5553f192a7d285c7f494a77d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=85=B4=E5=8D=8E?= Date: Tue, 30 Jul 2024 03:23:24 +0000 Subject: [PATCH 19/74] delete useless param MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈兴华 --- .../render_service_base/include/render/rs_aibar_filter.h | 2 +- .../modules/render_service_base/src/render/rs_aibar_filter.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rosen/modules/render_service_base/include/render/rs_aibar_filter.h b/rosen/modules/render_service_base/include/render/rs_aibar_filter.h index 3a6c252f98..6dea792741 100644 --- a/rosen/modules/render_service_base/include/render/rs_aibar_filter.h +++ b/rosen/modules/render_service_base/include/render/rs_aibar_filter.h @@ -49,7 +49,7 @@ public: static std::vector GetAiInvertCoef(); private: - static std::shared_ptr MakeBinarizationShader(float imageWidth, float imageHeight, + static std::shared_ptr MakeBinarizationShader( std::shared_ptr imageShader); private: diff --git a/rosen/modules/render_service_base/src/render/rs_aibar_filter.cpp b/rosen/modules/render_service_base/src/render/rs_aibar_filter.cpp index c8e0d07afa..2da8cdfcf8 100644 --- a/rosen/modules/render_service_base/src/render/rs_aibar_filter.cpp +++ b/rosen/modules/render_service_base/src/render/rs_aibar_filter.cpp @@ -127,7 +127,7 @@ bool RSAIBarFilter::IsAiInvertCoefValid(const std::vector& aiInvertCoef) std::shared_ptr RSAIBarFilter::MakeBinarizationShader( - float imageWidth, float imageHeight, std::shared_ptr imageShader) + std::shared_ptr imageShader) { static std::shared_ptr binarizationShaderEffect_; // coefficient of saturation borrowed from From ba29a5ad70df25f0798f56fa1cfae18bc3e7c49f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E6=B5=B7?= Date: Tue, 30 Jul 2024 11:33:23 +0800 Subject: [PATCH 20/74] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王德海 Change-Id: I9ca3122fcf114415c8e70185ffde79bdc23bf9da --- .../src/pipeline/rs_canvas_drawing_render_node.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 9ecdb43ffb..425dfbe06e 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 @@ -501,7 +501,8 @@ void RSCanvasDrawingRenderNode::AddDirtyType(RSModifierType modifierType) } // If such nodes are not drawn, The drawcmdlists don't clearOp during recording, As a result, there are // too many drawOp, so we need to add the limit of drawcmdlists. - while ((GetOldDirtyInSurface().IsEmpty() || !IsDirty() || ((renderDrawable_ && renderDrawable_->IsDrawCmdListsVisited()))) && + while ((GetOldDirtyInSurface().IsEmpty() || !IsDirty() || + ((renderDrawable_ && renderDrawable_->IsDrawCmdListsVisited()))) && drawCmdLists_[type].size() > DRAWCMDLIST_COUNT_LIMIT) { RS_LOGD("This Node[%{public}" PRIu64 "] with Modifier[%{public}hd] have drawcmdlist:%{public}zu", GetId(), type, drawCmdLists_[type].size()); From 8ed212c1f929c214022be7da825e9ba8e437117f Mon Sep 17 00:00:00 2001 From: dengyanfang23 Date: Mon, 29 Jul 2024 20:25:09 +0800 Subject: [PATCH 21/74] =?UTF-8?q?HMSymbol=20=E4=BF=AE=E6=94=B9=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=20Signed-off-by:=20dengyanfang23=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../skia_txt/symbol_engine/hm_symbol_node_build.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 fe21c17640..9cd3e151ac 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 @@ -27,13 +27,13 @@ namespace SPText { */ static void GetLayersGroupId(std::vector& groupIds, const RSRenderGroup& renderGroup, size_t index) { - for (auto& groupInfo : renderGroup.groupInfos) { - for (auto& j : groupInfo.layerIndexes) { + for (const auto& groupInfo : renderGroup.groupInfos) { + for (size_t j : groupInfo.layerIndexes) { if (j < groupIds.size()) { groupIds[j] = index; } } - for (auto& j : groupInfo.maskIndexes) { + for (size_t j : groupInfo.maskIndexes) { if (j < groupIds.size()) { groupIds[j] = index; } @@ -87,7 +87,7 @@ static void MergePathByLayerColor(const std::vector& groupInfos, TextEngine::NodeLayerInfo tempLayer; size_t currentIndex = 0; // the current layerindex, that effective index of tempLayer bool isFirst = true; - for (auto& layerIndex: groupInfo.layerIndexes) { + for (size_t layerIndex: groupInfo.layerIndexes) { if (layerIndex >= pathLayers.size() || layerIndex >= groupIndexes.size()) { continue; } From a72e479244931a3b999b1dea07e138148d3b7d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=85=B4=E5=8D=8E?= Date: Tue, 30 Jul 2024 06:16:13 +0000 Subject: [PATCH 22/74] fix UT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈兴华 --- .../unittest/render/rs_aibar_filter_test.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rosen/test/render_service/render_service_base/unittest/render/rs_aibar_filter_test.cpp b/rosen/test/render_service/render_service_base/unittest/render/rs_aibar_filter_test.cpp index 0fb872cfb6..d670291446 100644 --- a/rosen/test/render_service/render_service_base/unittest/render/rs_aibar_filter_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/render/rs_aibar_filter_test.cpp @@ -99,10 +99,8 @@ HWTEST_F(RSAIBarFilterTest, IsAiInvertCoefValidTest, TestSize.Level1) HWTEST_F(RSAIBarFilterTest, MakeBinarizationShaderTest, TestSize.Level1) { auto filter = std::make_shared(); - float imageWidth = 1.0f; - float imageHeight = 1.0f; auto imageShader = std::make_shared(); - auto runtimeShaderBuilder = filter->MakeBinarizationShader(imageWidth, imageHeight, imageShader); + auto runtimeShaderBuilder = filter->MakeBinarizationShader(imageShader); EXPECT_NE(runtimeShaderBuilder, nullptr); } From fc53c2ba83be4b6915aeeb692347cbc074b10ca4 Mon Sep 17 00:00:00 2001 From: chuchengcheng Date: Mon, 29 Jul 2024 22:26:09 +0800 Subject: [PATCH 23/74] fixed caf28ab from https://gitee.com/qsaki/graphic_graphic_2d/pulls/13276 disable hwc when web's buffer size not same as bounds Signed-off-by: chuchengcheng Change-Id: Ib713f20798fe488c6d83875f5cb4634c68bf83d3 --- .../core/pipeline/rs_uni_render_visitor.cpp | 45 +++++++++++++++++++ .../core/pipeline/rs_uni_render_visitor.h | 1 + ...dware_compose_disabled_reason_collection.h | 3 +- 3 files changed, 48 insertions(+), 1 deletion(-) 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 af414fdcd3..c4d709212d 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 @@ -1965,6 +1965,7 @@ void RSUniRenderVisitor::UpdateHwcNodeInfoForAppNode(RSSurfaceRenderNode& node) UpdateSrcRect(node, geo->GetAbsMatrix(), geo->GetAbsRect()); UpdateHwcNodeByTransform(node); UpdateHwcNodeEnableByBackgroundAlpha(node); + UpdateHwcNodeEnableByBufferSize(node); UpdateHwcNodeEnableBySrcRect(node); } } @@ -2050,6 +2051,49 @@ void RSUniRenderVisitor::UpdateHwcNodeEnableByBackgroundAlpha(RSSurfaceRenderNod } } +void RSUniRenderVisitor::UpdateHwcNodeEnableByBufferSize(RSSurfaceRenderNode& node) +{ + if (!node.IsRosenWeb() || node.IsHardwareForcedDisabled()) { + return; + } + if (!node.GetRSSurfaceHandler() || !node.GetRSSurfaceHandler()->GetBuffer()) { + return; + } + const auto& property = node.GetRenderProperties(); + auto gravity = property.GetFrameGravity(); + if (gravity != Gravity::TOP_LEFT) { + return; + } + auto surfaceHandler = node.GetRSSurfaceHandler(); + auto consumer = surfaceHandler->GetConsumer(); + if (consumer == nullptr) { + return; + } + + auto buffer = surfaceHandler->GetBuffer(); + const auto bufferWidth = buffer->GetSurfaceBufferWidth(); + const auto bufferHeight = buffer->GetSurfaceBufferHeight(); + auto boundsWidth = property.GetBoundsWidth(); + auto boundsHeight = property.GetBoundsHeight(); + + auto transformType = GraphicTransformType::GRAPHIC_ROTATE_NONE; + if (consumer->GetSurfaceBufferTransformType(buffer, &transformType) != GSERROR_OK) { + RS_LOGE("RSUniRenderVisitor::UpdateHwcNodeEnableByBufferSize GetSurfaceBufferTransformType failed"); + } + if (transformType == GraphicTransformType::GRAPHIC_ROTATE_270 || + transformType == GraphicTransformType::GRAPHIC_ROTATE_90) { + std::swap(boundsWidth, boundsHeight); + } + if ((bufferWidth < boundsWidth) || (bufferHeight < boundsHeight)) { + RS_OPTIONAL_TRACE_NAME_FMT( + "hwc debug: name:%s id:%llu buffer:[%d, %d] bounds:[%f, %f] disabled by buffer nonmatching", + node.GetName().c_str(), node.GetId(), bufferWidth, bufferHeight, boundsWidth, boundsHeight); + node.SetHardwareForcedDisabledState(true); + hwcDisabledReasonCollection_.UpdateHwcDisabledReasonForDFX( + node.GetId(), HwcDisabledReasons::DISABLED_BY_BUFFER_NONMATCH, node.GetName()); + } +} + void RSUniRenderVisitor::UpdateHwcNodeEnableBySrcRect(RSSurfaceRenderNode& node) { if (node.IsHardwareForcedDisabled()) { @@ -2894,6 +2938,7 @@ void RSUniRenderVisitor::UpdateHwcNodeRectInSkippedSubTree(const RSRenderNode& r UpdateSrcRect(*hwcNodePtr, matrix, rect); UpdateHwcNodeByTransform(*hwcNodePtr); UpdateHwcNodeEnableBySrcRect(*hwcNodePtr); + UpdateHwcNodeEnableByBufferSize(*hwcNodePtr); } hwcNodePtr->SetTotalMatrix(matrix); } 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 c258efef7a..d589643ddc 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 @@ -272,6 +272,7 @@ private: std::shared_ptr& node, const RectI& filterRect, bool isReverseOrder = false); void UpdateHwcNodeEnableByBackgroundAlpha(RSSurfaceRenderNode& node); void UpdateHwcNodeEnableBySrcRect(RSSurfaceRenderNode& node); + void UpdateHwcNodeEnableByBufferSize(RSSurfaceRenderNode& node); void UpdateHwcNodeInfoForAppNode(RSSurfaceRenderNode& node); void UpdateSrcRect(RSSurfaceRenderNode& node, const Drawing::Matrix& absMatrix, const RectI& clipRect); diff --git a/rosen/modules/render_service_base/include/info_collection/rs_hardware_compose_disabled_reason_collection.h b/rosen/modules/render_service_base/include/info_collection/rs_hardware_compose_disabled_reason_collection.h index d0abad9988..0c1af2b50d 100644 --- a/rosen/modules/render_service_base/include/info_collection/rs_hardware_compose_disabled_reason_collection.h +++ b/rosen/modules/render_service_base/include/info_collection/rs_hardware_compose_disabled_reason_collection.h @@ -35,7 +35,8 @@ enum HwcDisabledReasons { DISABLED_BY_INVALID_PARAM = 7, DISABLED_BY_PREVALIDATE = 8, DISABLED_BY_SRC_PIXEL = 9, - DISABLED_REASON_LENGTH = 10, + DISABLED_BY_BUFFER_NONMATCH = 10, + DISABLED_REASON_LENGTH = 11, }; struct HwcDisabledReasonInfo { From cd6727bda8aa9fcc4410d8c4b2c4bf5e18e7ab12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=85=B4=E5=8D=8E?= Date: Tue, 30 Jul 2024 08:51:56 +0000 Subject: [PATCH 24/74] fix fuzz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈兴华 --- .../fuzztest/rsaibarfilter_fuzzer/rsaibarfilter_fuzzer.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rosen/test/render_service/render_service_base/fuzztest/rsaibarfilter_fuzzer/rsaibarfilter_fuzzer.cpp b/rosen/test/render_service/render_service_base/fuzztest/rsaibarfilter_fuzzer/rsaibarfilter_fuzzer.cpp index e410d352ff..0628424ef5 100755 --- a/rosen/test/render_service/render_service_base/fuzztest/rsaibarfilter_fuzzer/rsaibarfilter_fuzzer.cpp +++ b/rosen/test/render_service/render_service_base/fuzztest/rsaibarfilter_fuzzer/rsaibarfilter_fuzzer.cpp @@ -154,10 +154,8 @@ bool DoMakeBinarizationShader(const uint8_t* data, size_t size) g_size = size; g_pos = 0; - float imageWidth = GetData(); - float imageHeight = GetData(); auto imageShader = std::make_shared(); - RSAIBarFilter::MakeBinarizationShader(imageWidth, imageHeight, imageShader); + RSAIBarFilter::MakeBinarizationShader(imageShader); return true; } } // namespace Rosen From 9243d5302395baca5d6b7f04ce885024c92a851d Mon Sep 17 00:00:00 2001 From: yangwenxin Date: Wed, 31 Jul 2024 09:14:16 +0800 Subject: [PATCH 25/74] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=BC=82=E5=B8=B8TDD?= =?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: yangwenxin --- .../vsync/test/unittest/vsync_receiver_test.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/rosen/modules/composer/vsync/test/unittest/vsync_receiver_test.cpp b/rosen/modules/composer/vsync/test/unittest/vsync_receiver_test.cpp index 87ad82a700..e41d94bfdb 100644 --- a/rosen/modules/composer/vsync/test/unittest/vsync_receiver_test.cpp +++ b/rosen/modules/composer/vsync/test/unittest/vsync_receiver_test.cpp @@ -125,21 +125,6 @@ HWTEST_F(VsyncReceiverTest, Init002, Function | MediumTest| Level3) ASSERT_NE(VsyncReceiverTest::vsyncReceiver->Init(), VSYNC_ERROR_NULLPTR); } -/* -* Function: Init003 -* Type: Function -* Rank: Important(2) -* EnvConditions: N/A -* CaseDescription: 1. call Init - */ -HWTEST_F(VsyncReceiverTest, Init003, Function | MediumTest| Level3) -{ - int fd; - sptr connection_ = nullptr; - VsyncError ret = connection_->GetReceiveFd(fd); - ASSERT_NE(ret, VSYNC_ERROR_OK); -} - /* * Function: IsRequestedNextVSync001 * Type: Function From fbc419d1a8c34ba3408b5728074bee89e67afcd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=A6=B9=E8=87=BB?= Date: Wed, 24 Jul 2024 16:50:59 +0800 Subject: [PATCH 26/74] phone2phone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王禹臻 --- .../graphic/ui_effect/include/filter_napi.h | 1 + .../graphic/ui_effect/src/filter_napi.cpp | 26 +++- .../include/ge_shader_filter_params.h | 4 +- .../include/ge_water_ripple_filter.h | 134 +++++++++++++++++- .../src/ge_visual_effect_impl.cpp | 22 ++- .../src/ge_water_ripple_filter.cpp | 86 +++++------ .../unittest/ge_visual_effect_impl_test.cpp | 8 +- .../unittest/ge_water_ripple_filter_test.cpp | 30 ++-- .../include/property/rs_properties_def.h | 7 +- .../render/rs_water_ripple_shader_filter.h | 11 +- .../src/property/rs_properties.cpp | 12 +- .../render/rs_water_ripple_shader_filter.cpp | 13 +- .../render_service_client/core/ui/rs_node.cpp | 8 +- .../filter/include/filter_water_ripple_para.h | 19 ++- .../unittest/property/rs_properties_test.cpp | 14 +- .../rs_water_ripple_shader_filter_test.cpp | 5 +- .../unittest/ui/rs_node_test.cpp | 8 +- 17 files changed, 300 insertions(+), 108 deletions(-) diff --git a/interfaces/kits/napi/graphic/ui_effect/include/filter_napi.h b/interfaces/kits/napi/graphic/ui_effect/include/filter_napi.h index 0c8ec3cda4..159731c51d 100644 --- a/interfaces/kits/napi/graphic/ui_effect/include/filter_napi.h +++ b/interfaces/kits/napi/graphic/ui_effect/include/filter_napi.h @@ -54,6 +54,7 @@ private: static Drawing::TileMode ParserArgumentType(napi_env env, napi_value argv); static float GetSpecialValue(napi_env env, napi_value argValue); + static uint32_t GetSpecialIntValue(napi_env env, napi_value argValue); std::shared_ptr m_FilterObj = nullptr; }; diff --git a/interfaces/kits/napi/graphic/ui_effect/src/filter_napi.cpp b/interfaces/kits/napi/graphic/ui_effect/src/filter_napi.cpp index 81a77fed57..a927cc4b0b 100644 --- a/interfaces/kits/napi/graphic/ui_effect/src/filter_napi.cpp +++ b/interfaces/kits/napi/graphic/ui_effect/src/filter_napi.cpp @@ -21,6 +21,7 @@ namespace { constexpr uint32_t NUM_2 = 2; constexpr uint32_t NUM_3 = 3; constexpr uint32_t NUM_4 = 4; + constexpr uint32_t NUM_5 = 5; } namespace OHOS { @@ -293,6 +294,16 @@ float FilterNapi::GetSpecialValue(napi_env env, napi_value argValue) } return tmp; } + +uint32_t FilterNapi::GetSpecialIntValue(napi_env env, napi_value argValue) +{ + uint32_t tmp = 0; + if (UIEffectNapiUtils::getType(env, argValue) == napi_number && + UIEFFECT_IS_OK(napi_get_value_uint32(env, argValue, &tmp)) && tmp >= 0) { + return tmp; + } + return tmp; +} napi_value FilterNapi::SetWaterRipple(napi_env env, napi_callback_info info) { @@ -300,31 +311,34 @@ napi_value FilterNapi::SetWaterRipple(napi_env env, napi_callback_info info) napi_get_undefined(env, &result); napi_status status; napi_value thisVar = nullptr; - napi_value argValue[NUM_4] = {0}; - size_t argCount = NUM_4; + napi_value argValue[NUM_5] = {0}; + size_t argCount = NUM_5; UIEFFECT_JS_ARGS(env, info, status, argCount, argValue, thisVar); UIEFFECT_NAPI_CHECK_RET_D(UIEFFECT_IS_OK(status), nullptr, FILTER_LOG_E("fail to napi_get_water_ripple_info")); std::shared_ptr para = std::make_shared(); float progress = 0.0f; - float waveCount = 0.0f; + uint32_t waveCount = 0; float rippleCenterX = 0.0f; float rippleCenterY = 0.0f; + uint32_t rippleMode = 0; - if (argCount != NUM_4) { - FILTER_LOG_E("Args number less than 4"); + if (argCount != NUM_5) { + FILTER_LOG_E("Args number less than 5"); } progress = GetSpecialValue(env, argValue[NUM_0]); - waveCount = GetSpecialValue(env, argValue[NUM_1]); + waveCount = GetSpecialIntValue(env, argValue[NUM_1]); rippleCenterX = GetSpecialValue(env, argValue[NUM_2]); rippleCenterY = GetSpecialValue(env, argValue[NUM_3]); + rippleMode = GetSpecialIntValue(env, argValue[NUM_4]); para->SetProgress(progress); para->SetWaveCount(waveCount); para->SetRippleCenterX(rippleCenterX); para->SetRippleCenterY(rippleCenterY); + para->SetRippleMode(rippleMode); Filter* filterObj = nullptr; NAPI_CALL(env, napi_unwrap(env, thisVar, reinterpret_cast(&filterObj))); 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 1d44e1e3ca..4f02172c41 100644 --- a/rosen/modules/graphics_effect/include/ge_shader_filter_params.h +++ b/rosen/modules/graphics_effect/include/ge_shader_filter_params.h @@ -44,11 +44,13 @@ constexpr char GE_FILTER_WATER_RIPPLE_PROGRESS[] = "PROGRESS"; constexpr char GE_FILTER_WATER_RIPPLE_WAVE_NUM[] = "WAVE_NUM"; constexpr char GE_FILTER_WATER_RIPPLE_RIPPLE_CENTER_X[] = "RIPPLE_CENTER_X"; constexpr char GE_FILTER_WATER_RIPPLE_RIPPLE_CENTER_Y[] = "RIPPLE_CENTER_Y"; +constexpr char GE_FILTER_WATER_RIPPLE_RIPPLE_MODE[] = "RIPPLE_MODE"; struct GEWaterRippleFilterParams { float progress = 0.0f; - float waveCount = 2.0f; + uint32_t waveCount = 2; float rippleCenterX = 0.5f; float rippleCenterY = 0.7f; + uint32_t rippleMode = 1; }; constexpr char GE_FILTER_GREY[] = "GREY"; 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 29ba2987ff..1ae53fe6a4 100644 --- a/rosen/modules/graphics_effect/include/ge_water_ripple_filter.h +++ b/rosen/modules/graphics_effect/include/ge_water_ripple_filter.h @@ -39,13 +39,15 @@ public: const Drawing::Rect& src, const Drawing::Rect& dst) override; private: - bool InitWaterRippleEffect(); - bool InitWaterRipplePcEffect(); + std::shared_ptr GetWaterRippleEffectSM(const int rippleMode); + std::shared_ptr GetWaterRippleEffectSS(); float progress_ = 0.0f; - float waveCount_ = 2.0f; + uint32_t waveCount_ = 2; float rippleCenterX_ = 0.5f; float rippleCenterY_ = 0.7f; - inline static std::string shaderString = R"( + uint32_t rippleMode_ = 1; + + inline static const std::string shaderStringSMsend = R"( uniform shader image; uniform half2 iResolution; uniform half progress; @@ -106,8 +108,130 @@ private: return half4(color, 1.0); } )"; + + inline static const std::string shaderStringSSmutual = R"( + uniform shader image; + uniform vec2 iResolution; + uniform float progress; + uniform float waveCount; + uniform vec2 rippleCenter; + // small + const float s_basicSlope = 0.5; + const float s_ampSupress = 0.04; + const float s_waveFreq = 31.0; + float s_wavePropRatio = 2.; + const float s_ampSupArea = 0.3; + const float s_intensity = 0.15; + const float s_decayExp = 4. ; + const float s_luminance = 60.; + const vec3 s_lightDirect = vec3(0., -4., -0.2); + // big + const float b_ampSupress = 0.01; + const float b_waveFreq = 7.0; + float b_wavePropRatio = 6.9; + const float b_intensity = 0.15; + const float b_decayExp = 4.; + const float b_luminance = 30.; - inline static std::string shaderPcString = R"( + const vec3 waveAxis = vec3(2., 3., 5.); + + vec3 lightBlend(vec3 colorA, vec3 colorB) + { + vec3 oneVec = vec3(1.); + return oneVec - ((oneVec - colorA) * (oneVec - colorB)); + } + + float calcWave(float count, float freq, float dis) + { + float axisVal = (count == 1.) ? waveAxis.x : (count == 2.) ? waveAxis.y : waveAxis.z; + float axisPoint = -(axisVal * 3.1416) / freq; + float waveForm = smoothstep(axisPoint * 2., axisPoint, dis) * smoothstep(0., axisPoint, dis); + float downCond = (count == 3.) ? -1. : 1.; + return sin(freq * dis) * waveForm * downCond; + } + + float calcBLight(float dis, float freq) + { + float currentX = pow(dis + (6.2832 / freq), 2.); + return 1.2 * exp(-55. * currentX); + } + + float calcSLight(float dis, float freq, float yShift) + { + float pivot1 = pow(dis + (9.4248 / freq) - 0.14, 2.); + float pivot2 = pow(dis + (9.4248 / freq) + 0.01, 2.); + return 2. * yShift * (exp(-1000. * pivot2) + exp(-1000. * pivot1)); + } + + vec2 waveGenerator(float propDis, float t, float count, float freq, float prop, float yShift) + { + float dis = propDis - prop * t; + float h = 1e-3; + float d1 = dis - h; + float d2 = dis + h; + float waveVal = (calcWave(count, freq, d2) - calcWave(count, freq, d1)) / (2. * h); + float lightAdjust = (freq < 10.) ? calcBLight(dis, freq) : calcSLight(dis, freq, yShift); + return vec2(waveVal, lightAdjust); + } + + vec4 main(vec2 fragCoord) + { + float s_waveCount = waveCount; + vec2 b_rippleCenter = rippleCenter; + float shortEdge = min(iResolution.x, iResolution.y); + vec2 uv = fragCoord.xy / iResolution.xy; + vec2 uvHomo = fragCoord.xy / shortEdge; + vec2 resRatio = iResolution.xy / shortEdge; + + float b_progSlope = 0.4; + float s_progSlope = s_basicSlope + 0.1 * s_waveCount; + float b_t = b_progSlope * (progress + 0.4); + // float s_t = fract(s_progSlope * progress); + float s_t = s_progSlope * (progress + 0.11); + + float veloDecay = 1. - 0.04 * (smoothstep(0.2, 0.16, progress) + smoothstep(0.2, 1.2, progress)); + b_wavePropRatio *= veloDecay; + s_wavePropRatio *= veloDecay; + + vec2 b_waveCenter = b_rippleCenter * resRatio; + vec2 s_waveCenter = vec2(0.5, 0.) * resRatio; + float b_propDis = distance(uvHomo, b_waveCenter); + float s_propDis = distance(uvHomo, s_waveCenter); + vec2 b_vec = uvHomo - b_waveCenter; + vec2 s_vec = uvHomo - s_waveCenter; + float b_ampDecayByDis = (b_propDis < 1.9) ? clamp(pow((1.9 - b_propDis), b_decayExp), 0., 1.): 0.; + float s_ampDecayByDis = (s_propDis < 0.7) ? clamp(pow((0.7 - s_propDis), s_decayExp), 0., 1.): 0.; + + float s_ampSupCenter = smoothstep(0., s_ampSupArea, s_propDis); + vec2 b_waveRes = waveGenerator(b_propDis, b_t, 1., b_waveFreq, b_wavePropRatio, 1.); + vec2 s_waveRes = waveGenerator( + s_propDis, s_t, s_waveCount, s_waveFreq, s_wavePropRatio, abs(normalize(s_vec)[1])); + float b_intense = b_waveRes[0] * b_ampDecayByDis * b_ampSupress; + float s_intense = s_waveRes[0] * s_ampDecayByDis * s_ampSupCenter * s_ampSupress; + float b_Prime = b_waveRes[1] * b_ampDecayByDis * b_ampSupress; + float s_Prime = s_waveRes[1] * s_ampDecayByDis * s_ampSupCenter * s_ampSupress; + vec2 b_circles = normalize(b_vec) * b_intense; + vec2 s_circles = normalize(s_vec) * s_intense; + + vec3 b_norm = vec3(b_circles, b_intense); + vec3 s_norm = vec3(s_circles, s_intense); + + vec2 warp = (b_intensity * b_norm.xy + s_intensity * s_norm.xy) * smoothstep(0., 0.07, progress); + vec2 expandUV = (uv - warp) * iResolution.xy; + vec3 color = image.eval(expandUV).rgb; + + float b_light = b_luminance * clamp(b_Prime, 0., 1.) * smoothstep(0., 0.125, progress);; + float s_light = s_luminance * clamp(s_Prime, 0., 1.); + + color += s_light; + color = lightBlend(color, vec3(b_light)); + // color = lightBlend(color, vec3(s_light)); + + return vec4(color, 1.0); + } + )"; + + inline static const std::string shaderStringSMrecv = R"( uniform shader image; uniform vec2 iResolution; uniform float progress; 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 844acc8142..8467a6f80a 100644 --- a/rosen/modules/graphics_effect/src/ge_visual_effect_impl.cpp +++ b/rosen/modules/graphics_effect/src/ge_visual_effect_impl.cpp @@ -197,7 +197,24 @@ void GEVisualEffectImpl::SetParam(const std::string& tag, const std::vectorrippleMode = param; + } else if (tag == GE_FILTER_WATER_RIPPLE_WAVE_NUM) { + waterRippleParams_->waveCount = param; + } + break; + } + default: + break; + } +} void GEVisualEffectImpl::SetAIBarParams(const std::string& tag, float param) { @@ -284,7 +301,6 @@ void GEVisualEffectImpl::SetHpsBlurParams(const std::string& tag, float param) it->second(this, param); } } - void GEVisualEffectImpl::SetWaterRippleParams(const std::string& tag, float param) { if (waterRippleParams_ == nullptr) { @@ -295,8 +311,6 @@ void GEVisualEffectImpl::SetWaterRippleParams(const std::string& tag, float para { GE_FILTER_WATER_RIPPLE_PROGRESS, [](GEVisualEffectImpl* obj, float p) { obj->waterRippleParams_->progress = p; } }, - { GE_FILTER_WATER_RIPPLE_WAVE_NUM, - [](GEVisualEffectImpl* obj, float p) { obj->waterRippleParams_->waveCount = p; } }, { GE_FILTER_WATER_RIPPLE_RIPPLE_CENTER_X, [](GEVisualEffectImpl* obj, float p) { obj->waterRippleParams_->rippleCenterX = p; } }, { GE_FILTER_WATER_RIPPLE_RIPPLE_CENTER_Y, 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 e9bdffa34f..d77c97b62d 100644 --- a/rosen/modules/graphics_effect/src/ge_water_ripple_filter.cpp +++ b/rosen/modules/graphics_effect/src/ge_water_ripple_filter.cpp @@ -13,9 +13,8 @@ * limitations under the License. */ -#include "chrono" +#include -#include "common/rs_common_def.h" #include "ge_log.h" #include "ge_water_ripple_filter.h" @@ -25,22 +24,18 @@ namespace Rosen { #define PROPERTY_HIGPU_VERSION "const.gpu.vendor" #define PROPERTY_DEBUG_SUPPORT_AF "persist.sys.graphic.supports_af" namespace { - -static std::shared_ptr g_waterRippleEffect = nullptr; -static std::shared_ptr g_waterRipplePcEffect = nullptr; - + +const int SMALL2MEDIUM_RECV = 0; +const int SMALL2MEDIUM_SEND = 1; +const int SMALL2SMALL = 2; + } // namespace GEWaterRippleFilter::GEWaterRippleFilter(const Drawing::GEWaterRippleFilterParams& params) : progress_(params.progress), waveCount_(params.waveCount), rippleCenterX_(params.rippleCenterX), - rippleCenterY_(params.rippleCenterY) -{ - if (!InitWaterRippleEffect()) { - LOGE("GEWaterRippleFilter::GEWaterRippleFilter failed when initializing WaterRippleEffect."); - return; - } -} + rippleCenterY_(params.rippleCenterY), rippleMode_(params.rippleMode) +{} std::shared_ptr GEWaterRippleFilter::ProcessImage(Drawing::Canvas& canvas, const std::shared_ptr image, const Drawing::Rect& src, const Drawing::Rect& dst) @@ -53,33 +48,37 @@ 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 (g_waterRippleEffect == nullptr) { - if (InitWaterRippleEffect() == false) { - LOGE("GEWaterRippleFilter::ProcessImage g_waterRippleEffect init failed"); - return nullptr; - } - } - if (g_waterRipplePcEffect == nullptr) { - if (InitWaterRipplePcEffect() == false) { - LOGE("GEWaterRippleFilter::ProcessImage g_waterRipplePcEffect init failed"); - return nullptr; - } - } auto imageInfo = image->GetImageInfo(); float height = imageInfo.GetHeight(); float width = imageInfo.GetWidth(); std::shared_ptr waterRipple; - if (ROSEN_GNE(rippleCenterY_, 0.5f)) { - waterRipple = g_waterRipplePcEffect; - } else { - waterRipple = g_waterRippleEffect; + switch (rippleMode_) { + case SMALL2MEDIUM_RECV: { + waterRipple = GetWaterRippleEffectSM(SMALL2MEDIUM_RECV); + break; + } + case SMALL2MEDIUM_SEND: { + waterRipple = GetWaterRippleEffectSM(SMALL2MEDIUM_SEND); + break; + } + case SMALL2SMALL: { + waterRipple = GetWaterRippleEffectSS(); + break; + } + default: { + LOGE("GEWaterRippleFilter::ProcessImage: Not support current ripple mode"); + return nullptr; + } + } + if (waterRipple == nullptr) { + LOGE("GEWaterRippleFilter::ProcessImage g_waterRippleEffect init failed"); + return nullptr; } Drawing::RuntimeShaderBuilder builder(waterRipple); - builder.SetChild("image", shader); builder.SetUniform("iResolution", width, height); builder.SetUniform("progress", progress_); - builder.SetUniform("waveCount", waveCount_); + builder.SetUniform("waveCount", static_cast(waveCount_)); builder.SetUniform("rippleCenter", rippleCenterX_, rippleCenterY_); auto invertedImage = builder.MakeImage(canvas.GetGPUContext().get(), nullptr, imageInfo, false); @@ -90,24 +89,25 @@ std::shared_ptr GEWaterRippleFilter::ProcessImage(Drawing::Canva return invertedImage; } -bool GEWaterRippleFilter::InitWaterRippleEffect() +std::shared_ptr GEWaterRippleFilter::GetWaterRippleEffectSM(const int rippleMode) { - g_waterRippleEffect = Drawing::RuntimeEffect::CreateForShader(shaderString); - if (g_waterRippleEffect == nullptr) { - LOGE("GEWaterRippleFilter::RuntimeShader failed to create water ripple filter"); - return false; + static std::shared_ptr g_waterRippleEffectSM = nullptr; + if (g_waterRippleEffectSM == nullptr) { + g_waterRippleEffectSM = (rippleMode == SMALL2MEDIUM_SEND) ? + Drawing::RuntimeEffect::CreateForShader(shaderStringSMsend) : + Drawing::RuntimeEffect::CreateForShader(shaderStringSMrecv); } - return true; + return g_waterRippleEffectSM; } -bool GEWaterRippleFilter::InitWaterRipplePcEffect() +std::shared_ptr GEWaterRippleFilter::GetWaterRippleEffectSS() { - g_waterRipplePcEffect = Drawing::RuntimeEffect::CreateForShader(shaderPcString); - if (g_waterRipplePcEffect == nullptr) { - LOGE("GEWaterRippleFilter::RuntimeShader failed to create water ripple filter"); - return false; + static std::shared_ptr g_waterRippleEffectSS = nullptr; + if (g_waterRippleEffectSS == nullptr) { + g_waterRippleEffectSS = Drawing::RuntimeEffect::CreateForShader(shaderStringSSmutual); } - return true; + return g_waterRippleEffectSS; } + } // namespace Rosen } // namespace OHOS \ No newline at end of file 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 2148c09339..164dd25fd7 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 @@ -291,12 +291,12 @@ 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); + geVisualEffectImpl.SetWaterRippleParams(Drawing::GE_FILTER_WATER_RIPPLE_RIPPLE_MODE, 1.0f); + EXPECT_EQ(geVisualEffectImpl.GetWaterRippleParams()->rippleMode, 1.0f); } /** @@ -335,12 +335,12 @@ HWTEST_F(GEVisualEffectImplTest, SetWaterRippleParams001, TestSize.Level1) 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); + geVisualEffectImpl.SetWaterRippleParams(Drawing::GE_FILTER_WATER_RIPPLE_RIPPLE_MODE, 1.0f); + EXPECT_EQ(geVisualEffectImpl.GetWaterRippleParams()->rippleMode, 1.0f); } /** 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 index 4c01853098..419a068e2b 100644 --- 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 @@ -57,18 +57,6 @@ void GEWaterRippleFilterTest::SetUp() 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 @@ -76,7 +64,7 @@ HWTEST_F(GEWaterRippleFilterTest, InitWaterRippleEffect001, TestSize.Level1) */ HWTEST_F(GEWaterRippleFilterTest, ProcessImage001, TestSize.Level1) { - Drawing::GEWaterRippleFilterParams geWaterRippleFilterParams { 0.5f, 2.0f, 0.5f, 0.7f }; + Drawing::GEWaterRippleFilterParams geWaterRippleFilterParams { 0.5f, 2.0f, 0.5f, 0.7f, 1.0f }; auto geWaterRippleFilter = std::make_shared(geWaterRippleFilterParams); EXPECT_NE(geWaterRippleFilter->ProcessImage(canvas_, image_, src_, dst_), image_); } @@ -88,7 +76,7 @@ HWTEST_F(GEWaterRippleFilterTest, ProcessImage001, TestSize.Level1) */ HWTEST_F(GEWaterRippleFilterTest, ProcessImage002, TestSize.Level1) { - Drawing::GEWaterRippleFilterParams geWaterRippleFilterParams { 0.5f, 2.0f, 0.5f, 0.7f }; + Drawing::GEWaterRippleFilterParams geWaterRippleFilterParams { 0.5f, 2.0f, 0.5f, 0.7f, 1.0f }; auto geWaterRippleFilter = std::make_shared(geWaterRippleFilterParams); EXPECT_EQ(geWaterRippleFilter->ProcessImage(canvas_, nullptr, src_, dst_), nullptr); } @@ -100,7 +88,19 @@ HWTEST_F(GEWaterRippleFilterTest, ProcessImage002, TestSize.Level1) */ HWTEST_F(GEWaterRippleFilterTest, ProcessImage003, TestSize.Level1) { - Drawing::GEWaterRippleFilterParams geWaterRippleFilterParams { 0.5f, 2.0f, 0.5f, 0.0f }; + Drawing::GEWaterRippleFilterParams geWaterRippleFilterParams { 0.5f, 2.0f, 0.5f, 0.0f, 2.0f }; + auto geWaterRippleFilter = std::make_shared(geWaterRippleFilterParams); + EXPECT_NE(geWaterRippleFilter->ProcessImage(canvas_, image_, src_, dst_), image_); +} + +/** + * @tc.name: ProcessImage004 + * @tc.desc: Verify function ProcessImage + * @tc.type:FUNC + */ +HWTEST_F(GEWaterRippleFilterTest, ProcessImage004, TestSize.Level1) +{ + Drawing::GEWaterRippleFilterParams geWaterRippleFilterParams { 0.5f, 2.0f, 0.5f, 0.0f, 0.0f }; auto geWaterRippleFilter = std::make_shared(geWaterRippleFilterParams); EXPECT_NE(geWaterRippleFilter->ProcessImage(canvas_, image_, src_, dst_), image_); } diff --git a/rosen/modules/render_service_base/include/property/rs_properties_def.h b/rosen/modules/render_service_base/include/property/rs_properties_def.h index 3daa76cc13..fa86d9985c 100644 --- a/rosen/modules/render_service_base/include/property/rs_properties_def.h +++ b/rosen/modules/render_service_base/include/property/rs_properties_def.h @@ -144,13 +144,14 @@ struct RSDynamicBrightnessPara { }; struct RSWaterRipplePara { - float waveCount = 0.0f; + uint32_t waveCount = 0; float rippleCenterX = 0.5f; float rippleCenterY = 0.7f; + uint32_t rippleMode = 1; bool operator==(const RSWaterRipplePara& other) const { - return (waveCount == other.waveCount && rippleCenterX == other.rippleCenterX && - rippleCenterY == other.rippleCenterY); + return (waveCount == other.waveCount && ROSEN_EQ(rippleCenterX, other.rippleCenterX) && + ROSEN_EQ(rippleCenterY, other.rippleCenterY) && rippleMode == other.rippleMode); } }; 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 5286fe2b6b..6a891980e7 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 @@ -22,13 +22,14 @@ namespace OHOS { namespace Rosen { class RSB_EXPORT RSWaterRippleShaderFilter : public RSShaderFilter { public: - RSWaterRippleShaderFilter(const float progress, const float waveCount, const float rippleCenterX, - const float rippleCenterY); + RSWaterRippleShaderFilter(const float progress, const uint32_t waveCount, const float rippleCenterX, + const float rippleCenterY, const uint32_t rippleMode); ~RSWaterRippleShaderFilter() override; float GetProgress() const; - float GetwaveCount() const; + uint32_t GetwaveCount() const; float GetRippleCenterX() const; float GetRippleCenterY() const; + uint32_t GetRippleMode() const; void GenerateGEVisualEffect(std::shared_ptr visualEffectContainer) override; private: @@ -36,10 +37,12 @@ private: 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"; + static constexpr char RS_FILTER_WATER_RIPPLE_RIPPLE_MODE[] = "RIPPLE_MODE"; float progress_ = 0.0f; - float waveCount_ = 0.0f; + uint32_t waveCount_ = 0.0f; float rippleCenterX_ = 0.0f; float rippleCenterY_ = 0.0f; + uint32_t rippleMode_ = 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 f0df3f6534..3cc7225758 100644 --- a/rosen/modules/render_service_base/src/property/rs_properties.cpp +++ b/rosen/modules/render_service_base/src/property/rs_properties.cpp @@ -1402,9 +1402,11 @@ std::optional RSProperties::GetWaterRippleParams() const bool RSProperties::IsWaterRippleValid() const { + uint32_t WAVE_COUNT_MAX = 3; + uint32_t WAVE_COUNT_MIN = 1; return ROSEN_GE(waterRippleProgress_, 0.0f) && ROSEN_LE(waterRippleProgress_, 1.0f) && - waterRippleParams_.has_value() && ROSEN_GE(waterRippleParams_->waveCount, 1.0f) && - ROSEN_LE(waterRippleParams_->waveCount, 3.0f); + waterRippleParams_.has_value() && waterRippleParams_->waveCount >= WAVE_COUNT_MIN && + waterRippleParams_->waveCount <= WAVE_COUNT_MAX; } void RSProperties::SetFgBrightnessRates(const Vector4f& rates) @@ -2923,11 +2925,13 @@ void RSProperties::GenerateMagnifierFilter() void RSProperties::GenerateWaterRippleFilter() { - float waveCount = waterRippleParams_->waveCount; + uint32_t waveCount = waterRippleParams_->waveCount; float rippleCenterX = waterRippleParams_->rippleCenterX; float rippleCenterY = waterRippleParams_->rippleCenterY; + uint32_t rippleMode = waterRippleParams_->rippleMode; std::shared_ptr waterRippleFilter = - std::make_shared(waterRippleProgress_, waveCount, rippleCenterX, rippleCenterY); + std::make_shared(waterRippleProgress_, waveCount, rippleCenterX, rippleCenterY, + rippleMode); std::shared_ptr originalFilter = std::make_shared(waterRippleFilter); if (!backgroundFilter_) { backgroundFilter_ = originalFilter; 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 ff0f38c8a7..6c770e7464 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 @@ -25,17 +25,20 @@ namespace OHOS { namespace Rosen { RSWaterRippleShaderFilter::RSWaterRippleShaderFilter( - const float progress, const float waveCount, const float rippleCenterX, const float rippleCenterY) + const float progress, const uint32_t waveCount, const float rippleCenterX, const float rippleCenterY, + const uint32_t rippleMode) { type_ = ShaderFilterType::WATER_RIPPLE; progress_ = progress; waveCount_ = waveCount; rippleCenterX_ = rippleCenterX; rippleCenterY_ = rippleCenterY; + rippleMode_ = rippleMode; hash_ = SkOpts::hash(&progress_, sizeof(progress_), hash_); hash_ = SkOpts::hash(&waveCount_, sizeof(waveCount_), hash_); hash_ = SkOpts::hash(&rippleCenterX_, sizeof(rippleCenterX_), hash_); hash_ = SkOpts::hash(&rippleCenterY_, sizeof(rippleCenterY_), hash_); + hash_ = SkOpts::hash(&rippleMode_, sizeof(rippleMode_), hash_); } RSWaterRippleShaderFilter::~RSWaterRippleShaderFilter() = default; @@ -45,7 +48,7 @@ float RSWaterRippleShaderFilter::GetProgress() const return progress_; } -float RSWaterRippleShaderFilter::GetwaveCount() const +uint32_t RSWaterRippleShaderFilter::GetwaveCount() const { return waveCount_; } @@ -59,6 +62,11 @@ float RSWaterRippleShaderFilter::GetRippleCenterY() const { return rippleCenterY_; } + +uint32_t RSWaterRippleShaderFilter::GetRippleMode() const +{ + return rippleMode_; +} void RSWaterRippleShaderFilter::GenerateGEVisualEffect( std::shared_ptr visualEffectContainer) @@ -69,6 +77,7 @@ void RSWaterRippleShaderFilter::GenerateGEVisualEffect( 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_); + waterRippleFilter->SetParam(RS_FILTER_WATER_RIPPLE_RIPPLE_MODE, rippleMode_); visualEffectContainer->AddToChainedFilter(waterRippleFilter); } } // namespace Rosen 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 62f630edfb..8400cd6d43 100755 --- a/rosen/modules/render_service_client/core/ui/rs_node.cpp +++ b/rosen/modules/render_service_client/core/ui/rs_node.cpp @@ -1317,12 +1317,14 @@ void RSNode::SetUIBackgroundFilter(const OHOS::Rosen::Filter* backgroundFilter) auto rippleCenterX = waterRipplePara->GetRippleCenterX(); auto rippleCenterY = waterRipplePara->GetRippleCenterY(); auto progress = waterRipplePara->GetProgress(); - RSWaterRipplePara rs_water_ripple_param = { + auto rippleMode = waterRipplePara->GetRippleMode(); + RSWaterRipplePara params = { waveCount, rippleCenterX, - rippleCenterY + rippleCenterY, + rippleMode }; - SetWaterRippleParams(rs_water_ripple_param, progress); + SetWaterRippleParams(params, progress); } } } diff --git a/rosen/modules/render_service_client/core/ui_effect/filter/include/filter_water_ripple_para.h b/rosen/modules/render_service_client/core/ui_effect/filter/include/filter_water_ripple_para.h index c975677bd4..0e1edadbe6 100644 --- a/rosen/modules/render_service_client/core/ui_effect/filter/include/filter_water_ripple_para.h +++ b/rosen/modules/render_service_client/core/ui_effect/filter/include/filter_water_ripple_para.h @@ -38,12 +38,12 @@ public: return progress_; } - void SetWaveCount(float waveCount) + void SetWaveCount(uint32_t waveCount) { waveCount_ = waveCount; } - float GetWaveCount () const + uint32_t GetWaveCount () const { return waveCount_; } @@ -68,12 +68,23 @@ public: return rippleCenterY_; } + void SetRippleMode(uint32_t rippleMode) + { + rippleMode_ = rippleMode; + } + + uint32_t GetRippleMode() const + { + return rippleMode_; + } + private: float rippleCenterX_ = 0.0f; float rippleCenterY_ = 0.0f; float progress_ = 0.0f; - float waveCount_ = 0.0f; + uint32_t waveCount_ = 0; + uint32_t rippleMode_ = 0; }; } // namespace Rosen } // namespace OHOS -#endif // UIEFFECT_FILTER_BLUR_PARA_H +#endif // UIEFFECT_FILTER_WATER_RIPPPLE_PARA_H 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 e573c8d30e..b2492680b4 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 @@ -2467,13 +2467,15 @@ HWTEST_F(RSPropertiesTest, GenerateBackgroundFilter001, TestSize.Level1) EXPECT_TRUE(properties.systemBarEffect_); properties.waterRippleProgress_ = 0.1f; - float waveCount = 2.0f; + uint32_t waveCount = 2; float rippleCenterX = 0.3f; float rippleCenterY = 0.5f; + uint32_t rippleMode = 1; RSWaterRipplePara rs_water_ripple_param = { waveCount, rippleCenterX, - rippleCenterY + rippleCenterY, + rippleMode }; properties.waterRippleParams_ = std::optional(rs_water_ripple_param); properties.GenerateBackgroundFilter(); @@ -3174,14 +3176,16 @@ HWTEST_F(RSPropertiesTest, SetNGetWaterRippleParams001, TestSize.Level1) HWTEST_F(RSPropertiesTest, SetNGetWaterRippleParams002, TestSize.Level1) { RSProperties properties; - float waveCount = 2.0f; + float progress = 0.5f; + uint32_t waveCount = 2; float rippleCenterX = 0.3f; float rippleCenterY = 0.5f; - float progress = 0.5f; + uint32_t rippleMode = 1; RSWaterRipplePara rs_water_ripple_param = { waveCount, rippleCenterX, - rippleCenterY + rippleCenterY, + rippleMode }; properties.SetWaterRippleParams(rs_water_ripple_param); properties.SetWaterRippleProgress(progress); 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 index 59eb2c9522..5f9d32d546 100644 --- 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 @@ -43,12 +43,13 @@ void RSWaterRippleShaderFilterTest::TearDown() {} HWTEST_F(RSWaterRippleShaderFilterTest, GenerateGEVisualEffectTest, TestSize.Level1) { float progress = 0.1f; - float waveCount = 2.0f; + uint32_t waveCount = 2; float rippleCenterX = 0.3f; float rippleCenterY = 0.5f; + uint32_t rippleMode = 1; auto rsWaterRippleShaderFilter = std::make_shared(progress, waveCount, rippleCenterX, - rippleCenterY); + rippleCenterY, rippleMode); auto visualEffectContainer = std::make_shared(); rsWaterRippleShaderFilter->GenerateGEVisualEffect(visualEffectContainer); EXPECT_FALSE(visualEffectContainer->filterVec_.empty()); 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 e22948556c..66582ef1ed 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 @@ -6989,17 +6989,19 @@ HWTEST_F(RSNodeTest, SetInstanceId, TestSize.Level1) */ HWTEST_F(RSNodeTest, SetWaterRippleParams, TestSize.Level1) { - float waveCount = 2.0f; + uint32_t waveCount = 2; float rippleCenterX = 0.3f; float rippleCenterY = 0.5f; float progress = 0.5f; + uint32_t rippleMode = 1; RSWaterRipplePara rs_water_ripple_param = { waveCount, rippleCenterX, - rippleCenterY + rippleCenterY, + rippleMode }; auto rsNode = RSCanvasNode::Create(); rsNode->SetWaterRippleParams(rs_water_ripple_param, progress); - EXPECT_EQ(waveCount, 2.0f); + EXPECT_EQ(waveCount, 2); } } // namespace OHOS::Rosen From 9af656900f4401f6ff62d0f7b2497fe78cb3b770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=BF=E8=B1=AA?= Date: Wed, 31 Jul 2024 10:48:00 +0800 Subject: [PATCH 27/74] =?UTF-8?q?UIEffect=20NAPI=E8=93=9D=E9=BB=84?= =?UTF-8?q?=E5=B7=AE=E5=BC=82=E6=B6=88=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 耿豪 --- .../napi/graphic/ui_effect/src/effect_napi.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/interfaces/kits/napi/graphic/ui_effect/src/effect_napi.cpp b/interfaces/kits/napi/graphic/ui_effect/src/effect_napi.cpp index e95024421e..f73034c841 100644 --- a/interfaces/kits/napi/graphic/ui_effect/src/effect_napi.cpp +++ b/interfaces/kits/napi/graphic/ui_effect/src/effect_napi.cpp @@ -181,6 +181,12 @@ napi_value EffectNapi::CreateBrightnessBlender(napi_env env, napi_callback_info } napi_value object = nullptr; napi_create_object(env, &object); + if (object == nullptr) { + UIEFFECT_LOG_E("EffectNapi CreateBrightnessBlender object is Faild"); + delete blender; + blender = nullptr; + return nullptr; + } napi_wrap( env, object, blender, [](napi_env env, void* data, void* hint) { @@ -196,6 +202,7 @@ napi_value EffectNapi::CreateBrightnessBlender(napi_env env, napi_callback_info if (argc != 1) { UIEFFECT_LOG_E("EffectNapi SetbackgroundColorBlender input check failed, argc number is not 1."); delete blender; + blender = nullptr; return nullptr; } @@ -203,12 +210,14 @@ napi_value EffectNapi::CreateBrightnessBlender(napi_env env, napi_callback_info if (nativeObj == nullptr) { UIEFFECT_LOG_E("EffectNapi SetbackgroundColorBlender input check failed, nativeObj is nullptr."); delete blender; + blender = nullptr; return nullptr; } - if (!CheckCreateBrightnessBlender (env, nativeObj)) { + if (!CheckCreateBrightnessBlender(env, nativeObj)) { UIEFFECT_LOG_E("EffectNapi CheckCreateBrightnessBlender failed."); delete blender; + blender = nullptr; return nullptr; } @@ -221,9 +230,6 @@ napi_value EffectNapi::CreateBrightnessBlender(napi_env env, napi_callback_info napi_set_named_property(env, object, "negativeCoefficient", ParseJsValue(env, nativeObj, "negativeCoefficient")); napi_set_named_property(env, object, "fraction", ParseJsValue(env, nativeObj, "fraction")); - if (object == nullptr) { - UIEFFECT_LOG_E("EffectNapi CreateBrightnessBlender object is Faild"); - } return object; } From ed5e804f0c8c6e896f50190b1e52f8cc12d608a4 Mon Sep 17 00:00:00 2001 From: yanghua_angel Date: Wed, 31 Jul 2024 09:38:43 +0800 Subject: [PATCH 28/74] =?UTF-8?q?=E6=94=B9=E5=8F=98=E7=A9=BAcommand?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=B6=88=E6=81=AF=E5=A4=84=E7=90=86=E6=9C=BA?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yanghua_angel --- .../core/pipeline/rs_main_thread.cpp | 16 --------- .../core/pipeline/rs_main_thread.h | 2 -- .../pipeline/rs_render_service_connection.cpp | 11 ------ .../pipeline/rs_render_service_connection.h | 2 -- .../rs_render_service_connection_stub.cpp | 8 ----- .../ohos/rs_irender_service_connection.h | 2 -- ...er_service_connection_ipc_interface_code.h | 1 - .../transaction/rs_render_service_client.h | 2 -- .../transaction/rs_transaction_proxy.h | 3 -- .../darwin/rs_render_service_client.cpp | 4 --- .../ohos/rs_render_service_client.cpp | 8 ----- .../rs_render_service_connection_proxy.cpp | 35 +++++-------------- .../ohos/rs_render_service_connection_proxy.h | 2 -- .../windows/rs_render_service_client.cpp | 4 --- .../src/transaction/rs_transaction_proxy.cpp | 14 +++----- .../core/transaction/rs_interfaces.cpp | 5 --- .../core/transaction/rs_interfaces.h | 2 -- .../core/transaction/rs_transaction.cpp | 3 -- .../unittest/pipeline/rs_main_thread_test.cpp | 1 - 19 files changed, 13 insertions(+), 112 deletions(-) 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 00a2b5d3cf..ce7c0c1a79 100644 --- a/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp @@ -1105,22 +1105,6 @@ void RSMainThread::ProcessRSTransactionData(std::unique_ptr& rsTransactionData->Process(*context_); } -void RSMainThread::ProcessEmptySyncTransactionCount(uint64_t syncId, int32_t parentPid, int32_t childPid) -{ - RS_TRACE_NAME_FMT("RSMainThread::ProcessEmptySyncTransactionCount syncId: %lu parentPid: %d childPid: %d", syncId, - parentPid, childPid); - ROSEN_LOGI("RSMainThread::ProcessEmptySyncTransactionCount syncId:%{public}" PRIu64 " parentPid:%{public}d " - "childPid:%{public}d", syncId, parentPid, childPid); - subSyncTransactionCounts_[parentPid]--; - if (subSyncTransactionCounts_[parentPid] == 0) { - subSyncTransactionCounts_.erase(parentPid); - } - if (subSyncTransactionCounts_.empty()) { - ROSEN_LOGD("SyncTransaction sucess"); - ProcessAllSyncTransactionData(); - } -} - void RSMainThread::StartSyncTransactionFallbackTask(std::unique_ptr& rsTransactionData) { if (handler_) { 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 9709e58f18..5515c7ffe5 100644 --- a/rosen/modules/render_service/core/pipeline/rs_main_thread.h +++ b/rosen/modules/render_service/core/pipeline/rs_main_thread.h @@ -335,8 +335,6 @@ public: { return needRequestNextVsyncAnimate_; } - - void ProcessEmptySyncTransactionCount(uint64_t syncId, int32_t parentPid, int32_t childPid); bool IsFirstFrameOfPartialRender() const { 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 7c199e1973..c34cf665f6 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 @@ -1667,17 +1667,6 @@ void RSRenderServiceConnection::SetCacheEnabledForRotation(bool isEnabled) RSSystemProperties::SetCacheEnabledForRotation(isEnabled); } -void RSRenderServiceConnection::ChangeSyncCount(uint64_t syncId, int32_t parentPid, int32_t childPid) -{ - if (!mainThread_) { - return; - } - auto task = [this, syncId, parentPid, childPid]() -> void { - mainThread_->ProcessEmptySyncTransactionCount(syncId, parentPid, childPid); - }; - mainThread_->PostTask(task); -} - std::vector RSRenderServiceConnection::GetActiveDirtyRegionInfo() { const auto& activeDirtyRegionInfos = GpuDirtyRegionCollection::GetInstance().GetActiveDirtyRegionInfo(); 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 89f71e0c4a..c43fecd1fc 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 @@ -267,8 +267,6 @@ private: void SetCacheEnabledForRotation(bool isEnabled) override; - void ChangeSyncCount(uint64_t syncId, int32_t parentPid, int32_t childPid) override; - bool SetVirtualScreenStatus(ScreenId id, VirtualScreenStatus screenStatus) override; std::vector GetActiveDirtyRegionInfo() 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 aafd40e6c1..5c779afe62 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 @@ -213,7 +213,6 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( static_cast(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK), static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_HGM_CFG_CALLBACK), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_ROTATION_CACHE_ENABLED), - static_cast(RSIRenderServiceConnectionInterfaceCode::CHANGE_SYNCHRONIZE_COUNT), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_TP_FEATURE_CONFIG), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_USING_STATUS), static_cast(RSIRenderServiceConnectionInterfaceCode::REFRESH_RATE_MODE_CHANGE_CALLBACK), @@ -1248,13 +1247,6 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( SetCacheEnabledForRotation(isEnabled); break; } - case static_cast(RSIRenderServiceConnectionInterfaceCode::CHANGE_SYNCHRONIZE_COUNT): { - auto syncId = data.ReadUint64(); - auto parentPid = data.ReadInt32(); - auto childPid = data.ReadInt32(); - ChangeSyncCount(syncId, parentPid, childPid); - break; - } case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_ACTIVE_DIRTY_REGION_INFO) : { uint64_t tokenId = OHOS::IPCSkeleton::GetCallingFullTokenID(); if (Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(tokenId)) { 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 54b48760cc..0e6e504dbb 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 @@ -267,8 +267,6 @@ public: virtual void SetCacheEnabledForRotation(bool isEnabled) = 0; - virtual void ChangeSyncCount(uint64_t syncId, int32_t parentPid, int32_t childPid) = 0; - virtual void SetOnRemoteDiedCallback(const OnRemoteDiedCallback& callback) = 0; virtual void RunOnRemoteDiedCallback() = 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 fc8dc6a9a8..a61d13304a 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 @@ -114,7 +114,6 @@ enum class RSIRenderServiceConnectionInterfaceCode : CodeUnderlyingType { UNREGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK, REGISTER_HGM_CFG_CALLBACK, SET_ROTATION_CACHE_ENABLED, - CHANGE_SYNCHRONIZE_COUNT, SET_TP_FEATURE_CONFIG, SET_VIRTUAL_SCREEN_USING_STATUS, REFRESH_RATE_MODE_CHANGE_CALLBACK, 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 dc8599fbaa..9cd47ad3ab 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 @@ -329,8 +329,6 @@ public: void SetCacheEnabledForRotation(bool isEnabled); - void ChangeSyncCount(uint64_t syncId, int32_t parentPid, int32_t childPid); - void SetOnRemoteDiedCallback(const OnRemoteDiedCallback& callback); std::vector GetActiveDirtyRegionInfo(); diff --git a/rosen/modules/render_service_base/include/transaction/rs_transaction_proxy.h b/rosen/modules/render_service_base/include/transaction/rs_transaction_proxy.h index 4618f0c924..75fd47b65a 100644 --- a/rosen/modules/render_service_base/include/transaction/rs_transaction_proxy.h +++ b/rosen/modules/render_service_base/include/transaction/rs_transaction_proxy.h @@ -67,9 +67,6 @@ public: } void SetParentPid(const int32_t parentPid); - - bool IsRemoteCommandEmpty(); - private: RSTransactionProxy(); virtual ~RSTransactionProxy(); 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 844a5bacc9..f9f1ec5e19 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 @@ -527,10 +527,6 @@ void RSRenderServiceClient::SetCacheEnabledForRotation(bool isEnabled) { } -void RSRenderServiceClient::ChangeSyncCount(uint64_t syncId, int32_t parentPid, int32_t childPid) -{ -} - void RSRenderServiceClient::SetOnRemoteDiedCallback(const OnRemoteDiedCallback& callback) { } 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 367352a34e..617b2a213f 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 @@ -1347,14 +1347,6 @@ void RSRenderServiceClient::SetCacheEnabledForRotation(bool isEnabled) } } -void RSRenderServiceClient::ChangeSyncCount(uint64_t syncId, int32_t parentPid, int32_t childPid) -{ - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->ChangeSyncCount(syncId, parentPid, childPid); - } -} - void RSRenderServiceClient::SetOnRemoteDiedCallback(const OnRemoteDiedCallback& callback) { 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 82872cffa4..3d8120a65d 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 @@ -50,7 +50,7 @@ void RSRenderServiceConnectionProxy::CommitTransaction(std::unique_ptr PARCEL_SPLIT_THRESHOLD during marshalling std::vector> parcelVector; - while (transactionData->GetMarshallingIndex() < transactionData->GetCommandCount()) { + auto func = [&]() { if (isUniMode) { ++transactionDataIndex_; } @@ -61,6 +61,14 @@ void RSRenderServiceConnectionProxy::CommitTransaction(std::unique_ptrIsNeedSync() && transactionData->IsEmpty()) { + RS_TRACE_NAME("Commit empty syncTransaction"); + func(); + } else { + while (transactionData->GetMarshallingIndex() < transactionData->GetCommandCount()) { + func(); + } } MessageOption option; @@ -2394,31 +2402,6 @@ void RSRenderServiceConnectionProxy::SetCacheEnabledForRotation(bool isEnabled) } } -void RSRenderServiceConnectionProxy::ChangeSyncCount(uint64_t syncId, int32_t parentPid, int32_t childPid) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - return; - } - if (!data.WriteUint64(syncId)) { - return; - } - if (!data.WriteInt32(parentPid)) { - return; - } - if (!data.WriteInt32(childPid)) { - return; - } - option.SetFlags(MessageOption::TF_ASYNC); - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::CHANGE_SYNCHRONIZE_COUNT); - int32_t err = Remote()->SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ChangeSyncCount: Send Request err."); - } -} - void RSRenderServiceConnectionProxy::SetOnRemoteDiedCallback(const OnRemoteDiedCallback& callback) { OnRemoteDiedCallback_ = callback; 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 e72d9d6a10..514b5c2462 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 @@ -241,8 +241,6 @@ public: void SetOnRemoteDiedCallback(const OnRemoteDiedCallback& callback) override; - void ChangeSyncCount(uint64_t syncId, int32_t parentPid, int32_t childPid) override; - void RunOnRemoteDiedCallback() override; std::vector GetActiveDirtyRegionInfo() 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 1234837204..fae5ebe0d3 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 @@ -527,10 +527,6 @@ void RSRenderServiceClient::SetCacheEnabledForRotation(bool isEnabled) { } -void RSRenderServiceClient::ChangeSyncCount(uint64_t syncId, int32_t parentPid, int32_t childPid) -{ -} - void RSRenderServiceClient::SetOnRemoteDiedCallback(const OnRemoteDiedCallback& callback) { } diff --git a/rosen/modules/render_service_base/src/transaction/rs_transaction_proxy.cpp b/rosen/modules/render_service_base/src/transaction/rs_transaction_proxy.cpp index 400480d496..c080c419ac 100644 --- a/rosen/modules/render_service_base/src/transaction/rs_transaction_proxy.cpp +++ b/rosen/modules/render_service_base/src/transaction/rs_transaction_proxy.cpp @@ -194,7 +194,8 @@ void RSTransactionProxy::CommitSyncTransaction(uint64_t timestamp, const std::st std::unique_lock cmdLock(mutex_); timestamp_ = std::max(timestamp, timestamp_); if (!implicitCommonTransactionDataStack_.empty()) { - if (renderThreadClient_ != nullptr && !implicitCommonTransactionDataStack_.top()->IsEmpty()) { + if (renderThreadClient_ != nullptr && (!implicitCommonTransactionDataStack_.top()->IsEmpty() || + implicitCommonTransactionDataStack_.top()->IsNeedSync())) { implicitCommonTransactionDataStack_.top()->timestamp_ = timestamp; implicitCommonTransactionDataStack_.top()->abilityName_ = abilityName; implicitCommonTransactionDataStack_.top()->SetSyncId(syncId_); @@ -204,7 +205,8 @@ void RSTransactionProxy::CommitSyncTransaction(uint64_t timestamp, const std::st } if (!implicitRemoteTransactionDataStack_.empty()) { - if (renderServiceClient_ != nullptr && !implicitRemoteTransactionDataStack_.top()->IsEmpty()) { + if (renderServiceClient_ != nullptr && (!implicitRemoteTransactionDataStack_.top()->IsEmpty() || + implicitRemoteTransactionDataStack_.top()->IsNeedSync())) { implicitRemoteTransactionDataStack_.top()->timestamp_ = timestamp; implicitRemoteTransactionDataStack_.top()->SetSyncId(syncId_); renderServiceClient_->CommitTransaction(implicitRemoteTransactionDataStack_.top()); @@ -265,14 +267,6 @@ void RSTransactionProxy::SetParentPid(const int32_t parentPid) } } -bool RSTransactionProxy::IsRemoteCommandEmpty() -{ - if (!implicitRemoteTransactionDataStack_.empty()) { - return implicitRemoteTransactionDataStack_.top()->IsEmpty(); - } - return true; -} - void RSTransactionProxy::AddCommonCommand(std::unique_ptr &command) { if (!implicitCommonTransactionDataStack_.empty()) { 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 7b218ddbe0..14c2164753 100644 --- a/rosen/modules/render_service_client/core/transaction/rs_interfaces.cpp +++ b/rosen/modules/render_service_client/core/transaction/rs_interfaces.cpp @@ -614,11 +614,6 @@ void RSInterfaces::EnableCacheForRotation() renderServiceClient_->SetCacheEnabledForRotation(true); } -void RSInterfaces::ChangeSyncCount(uint64_t syncId, int32_t parentPid, int32_t childPid) -{ - renderServiceClient_->ChangeSyncCount(syncId, parentPid, childPid); -} - void RSInterfaces::NotifyLightFactorStatus(bool isSafe) { renderServiceClient_->NotifyLightFactorStatus(isSafe); 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 016079a0c1..54deb28a32 100644 --- a/rosen/modules/render_service_client/core/transaction/rs_interfaces.h +++ b/rosen/modules/render_service_client/core/transaction/rs_interfaces.h @@ -258,8 +258,6 @@ public: void EnableCacheForRotation(); - void ChangeSyncCount(uint64_t syncId, int32_t parentPid, int32_t childPid); - void DisableCacheForRotation(); void SetOnRemoteDiedCallback(const OnRemoteDiedCallback& callback); diff --git a/rosen/modules/render_service_client/core/transaction/rs_transaction.cpp b/rosen/modules/render_service_client/core/transaction/rs_transaction.cpp index 40e8fbbe8f..ee77ce8cc7 100644 --- a/rosen/modules/render_service_client/core/transaction/rs_transaction.cpp +++ b/rosen/modules/render_service_client/core/transaction/rs_transaction.cpp @@ -81,9 +81,6 @@ void RSTransaction::Commit() transactionProxy->SetSyncTransactionNum(transactionCount_); transactionProxy->SetSyncId(syncId_); transactionProxy->SetParentPid(parentPid_); - if (transactionProxy->IsRemoteCommandEmpty()) { - RSInterfaces::GetInstance().ChangeSyncCount(syncId_, parentPid_, GetRealPid()); - } transactionProxy->CommitSyncTransaction(); transactionProxy->CloseSyncTransaction(); } 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 c8b0459af4..a31b29d9f2 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 @@ -436,7 +436,6 @@ HWTEST_F(RSMainThreadTest, ProcessSyncTransactionCount, TestSize.Level1) rsTransactionData->MarkNeedCloseSync(); mainThread->ProcessSyncTransactionCount(rsTransactionData); - mainThread->ProcessEmptySyncTransactionCount(0, 0, 0); mainThread->StartSyncTransactionFallbackTask(rsTransactionData); ASSERT_EQ(rsTransactionData->IsNeedCloseSync(), true); } From cc15956a4f2ebe38972da97e1f5b951b0ea6f36a Mon Sep 17 00:00:00 2001 From: wangchenchuan Date: Wed, 31 Jul 2024 11:19:32 +0800 Subject: [PATCH 29/74] =?UTF-8?q?=E4=BF=AE=E5=A4=8Darkui=E7=BC=96=E8=AF=91?= =?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: wangchenchuan --- .../core/pipeline/rs_render_service_connection.cpp | 2 +- .../rs_hardware_compose_disabled_reason_collection.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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 7c199e1973..ba3c61492b 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 @@ -1699,7 +1699,7 @@ LayerComposeInfo RSRenderServiceConnection::GetLayerComposeInfo() return layerComposeInfo; } -std::vector RSRenderServiceConnection::GetHwcDisabledReasonInfo() +HwcDisabledReasonInfos RSRenderServiceConnection::GetHwcDisabledReasonInfo() { return HwcDisabledReasonCollection::GetInstance().GetHwcDisabledReasonInfo(); } diff --git a/rosen/modules/render_service_base/include/info_collection/rs_hardware_compose_disabled_reason_collection.h b/rosen/modules/render_service_base/include/info_collection/rs_hardware_compose_disabled_reason_collection.h index d0abad9988..399f18afd7 100644 --- a/rosen/modules/render_service_base/include/info_collection/rs_hardware_compose_disabled_reason_collection.h +++ b/rosen/modules/render_service_base/include/info_collection/rs_hardware_compose_disabled_reason_collection.h @@ -17,6 +17,7 @@ #define RS_HARDWARE_COMPOSE_DISABLED_REASON_COLLECTION_H #include +#include #include "common/rs_common_def.h" From 313f253118c6fc73a4091839a2b0a29ef6bd01e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E5=B8=B8=E5=BE=B7?= Date: Wed, 31 Jul 2024 09:45:49 +0800 Subject: [PATCH 30/74] Settimeout of 0 only takes effect on virtual screens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 钱常德 Change-Id: I361b8f3340df15dcff11d7a305908b74696c51e5 --- .../core/pipeline/rs_base_render_engine.cpp | 4 ++-- .../core/pipeline/rs_base_render_engine.h | 3 ++- .../pipeline/rs_uni_render_virtual_processor.cpp | 12 +++++++++--- .../src/platform/ohos/backend/rs_surface_ohos_gl.cpp | 5 ----- .../src/platform/ohos/backend/rs_surface_ohos_gl.h | 1 - .../platform/ohos/backend/rs_surface_ohos_raster.cpp | 5 ----- .../platform/ohos/backend/rs_surface_ohos_raster.h | 1 - .../platform/ohos/backend/rs_surface_ohos_vulkan.cpp | 5 ----- .../platform/ohos/backend/rs_surface_ohos_vulkan.h | 1 - .../src/platform/ohos/rs_surface_ohos.cpp | 5 +++++ .../src/platform/ohos/rs_surface_ohos.h | 4 ++-- 11 files changed, 20 insertions(+), 26 deletions(-) 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 1a69d90a0e..f2cbe8d2ca 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 @@ -304,9 +304,9 @@ std::unique_ptr RSBaseRenderEngine::RequestFrame( #endif rsSurface->SetColorSpace(config.colorGamut); rsSurface->SetSurfacePixelFormat(config.format); - if (frameContextConfig.isMirror) { + if (frameContextConfig.isVirtual) { RS_LOGD("RSBaseRenderEngine::RequestFrame: Mirror Screen Set Timeout to 0."); - rsSurface->SetTimeOut(config.timeout); + rsSurface->SetTimeOut(frameContextConfig.timeOut); } auto bufferUsage = config.usage; #if (defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK)) && (defined RS_ENABLE_EGLIMAGE) 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 4bd2e07f01..fc2aff6785 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 @@ -60,8 +60,9 @@ public: this->independentContext = independentContext; } bool isProtected = false; - bool isMirror = false; bool independentContext = false; + bool isVirtual = false; + int32_t timeOut = 3000; // ms }; // The RenderFrame can do auto flush class RSRenderFrame { 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 8f444b83b8..96c9ef9c1f 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 @@ -74,6 +74,9 @@ bool RSUniRenderVirtualProcessor::InitForRenderThread(DrawableV2::RSDisplayRende } renderFrameConfig_.usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA; + FrameContextConfig frameContextConfig = {false, false}; + frameContextConfig.isVirtual = true; + frameContextConfig.timeOut = 0; producerSurface_ = screenManager->GetProducerSurface(virtualScreenId_); if (producerSurface_ == nullptr) { @@ -83,7 +86,8 @@ bool RSUniRenderVirtualProcessor::InitForRenderThread(DrawableV2::RSDisplayRende } #ifdef RS_ENABLE_GL if (RSSystemProperties::GetGpuApiType() == GpuApiType::OPENGL) { - renderFrame_ = renderEngine_->RequestFrame(producerSurface_, renderFrameConfig_, forceCPU_, false); + renderFrame_ = renderEngine_->RequestFrame(producerSurface_, renderFrameConfig_, forceCPU_, false, + frameContextConfig); } #endif if (renderFrame_ == nullptr) { @@ -99,10 +103,12 @@ bool RSUniRenderVirtualProcessor::InitForRenderThread(DrawableV2::RSDisplayRende } #ifdef NEW_RENDER_CONTEXT renderFrame_ = renderEngine_->RequestFrame( - std::static_pointer_cast(rsSurface), renderFrameConfig_, forceCPU_, false); + std::static_pointer_cast(rsSurface), renderFrameConfig_, forceCPU_, false, + frameContextConfig); #else renderFrame_ = renderEngine_->RequestFrame( - std::static_pointer_cast(rsSurface), renderFrameConfig_, forceCPU_, false); + std::static_pointer_cast(rsSurface), renderFrameConfig_, forceCPU_, false, + frameContextConfig); #endif } if (renderFrame_ == nullptr) { diff --git a/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_gl.cpp b/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_gl.cpp index 4506c3e137..9ee8341cdd 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_gl.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_gl.cpp @@ -32,11 +32,6 @@ void RSSurfaceOhosGl::SetSurfaceBufferUsage(uint64_t usage) bufferUsage_ = usage; } -void RSSurfaceOhosGl::SetTimeOut(int32_t timeOut) -{ - timeOut_ = timeOut; -} - void RSSurfaceOhosGl::SetSurfacePixelFormat(int32_t pixelFormat) { pixelFormat_ = pixelFormat; diff --git a/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_gl.h b/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_gl.h index e2a686468b..11141a0902 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_gl.h +++ b/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_gl.h @@ -41,7 +41,6 @@ public: bool FlushFrame(std::unique_ptr& frame, uint64_t uiTimestamp) override; void SetSurfaceBufferUsage(uint64_t usage) override; - void SetTimeOut(int32_t timeOut) override; void SetSurfacePixelFormat(int32_t pixelFormat) override; sptr GetCurrentBuffer() override { diff --git a/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_raster.cpp b/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_raster.cpp index 7a8fc599df..775f8a00c0 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_raster.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_raster.cpp @@ -31,11 +31,6 @@ void RSSurfaceOhosRaster::SetSurfaceBufferUsage(uint64_t usage) bufferUsage_ = usage; } -void RSSurfaceOhosRaster::SetTimeOut(int32_t timeOut) -{ - timeOut_ = timeOut; -} - void RSSurfaceOhosRaster::SetSurfacePixelFormat(int32_t pixelFormat) { pixelFormat_ = pixelFormat; diff --git a/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_raster.h b/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_raster.h index c6a0f5a046..8cea9af741 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_raster.h +++ b/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_raster.h @@ -38,7 +38,6 @@ public: bool FlushFrame(std::unique_ptr& frame, uint64_t uiTimestamp) override; void SetSurfaceBufferUsage(uint64_t usage) override; - void SetTimeOut(int32_t timeOut) override; void SetSurfacePixelFormat(int32_t pixelFormat) override; sptr GetCurrentBuffer() override { diff --git a/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_vulkan.cpp b/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_vulkan.cpp index 4e12c1ea42..2b028ed902 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_vulkan.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_vulkan.cpp @@ -270,11 +270,6 @@ void RSSurfaceOhosVulkan::SetColorSpace(GraphicColorGamut colorSpace) } } -void RSSurfaceOhosVulkan::SetTimeOut(int32_t timeOut) -{ - timeOut_ = timeOut; -} - void RSSurfaceOhosVulkan::SetSurfaceBufferUsage(uint64_t usage) { bufferUsage_ = usage; diff --git a/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_vulkan.h b/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_vulkan.h index 6d9ee53467..12f5829918 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_vulkan.h +++ b/rosen/modules/render_service_base/src/platform/ohos/backend/rs_surface_ohos_vulkan.h @@ -71,7 +71,6 @@ public: bool FlushFrame(std::unique_ptr& frame, uint64_t uiTimestamp) override; void SetColorSpace(GraphicColorGamut colorSpace) override; void SetSurfaceBufferUsage(uint64_t usage) override; - void SetTimeOut(int32_t timeOut) override; void SetSurfacePixelFormat(int32_t pixelFormat) override; sptr GetCurrentBuffer() override; void ClearBuffer() override; diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_surface_ohos.cpp b/rosen/modules/render_service_base/src/platform/ohos/rs_surface_ohos.cpp index 9994c7e481..a559a393f6 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_surface_ohos.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_surface_ohos.cpp @@ -48,5 +48,10 @@ void RSSurfaceOhos::ClearAllBuffer() producer_->Disconnect(); } } + +void RSSurfaceOhos::SetTimeOut(int32_t timeOut) +{ + timeOut_ = timeOut; +} } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_surface_ohos.h b/rosen/modules/render_service_base/src/platform/ohos/rs_surface_ohos.h index 00f1844bbc..33893a2e46 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_surface_ohos.h +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_surface_ohos.h @@ -41,17 +41,17 @@ public: virtual uint32_t GetQueueSize() const override; virtual void SetSurfaceBufferUsage(uint64_t usage) = 0; - virtual void SetTimeOut(int32_t timeOut) = 0; virtual void SetSurfacePixelFormat(int32_t pixelFormat) = 0; virtual sptr GetCurrentBuffer() = 0; void ClearAllBuffer() override; + virtual void SetTimeOut(int32_t timeOut); protected: sptr producer_; RenderContext* context_ = nullptr; GraphicColorGamut colorSpace_ = GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB; int32_t pixelFormat_ = GRAPHIC_PIXEL_FMT_RGBA_8888; uint64_t bufferUsage_ = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE | BUFFER_USAGE_MEM_DMA; - int32_t timeOut_ = 0; + int32_t timeOut_ = 3000; // ms }; } // namespace Rosen From def0e56c8f408d7a15c1bb44453f1e3610265912 Mon Sep 17 00:00:00 2001 From: charlielou Date: Wed, 31 Jul 2024 09:08:18 +0800 Subject: [PATCH 31/74] fix the issue of pc mouse disappears while recording the screen Change-Id: Ib9943611eb3e0d525bd9ef33fabef1df5fb313b0 Signed-off-by: charlielou --- .../rs_surface_render_node_drawable.cpp | 15 ++++++++------- .../core/pipeline/rs_uni_render_visitor.cpp | 13 +++++++++++++ .../core/pipeline/rs_uni_render_visitor.h | 2 ++ .../include/params/rs_render_params.h | 2 ++ .../include/params/rs_surface_render_params.h | 3 +++ .../include/pipeline/rs_display_render_node.h | 7 ------- .../include/pipeline/rs_surface_render_node.h | 8 ++++++++ .../src/params/rs_surface_render_params.cpp | 15 +++++++++++++++ .../src/pipeline/rs_surface_render_node.cpp | 10 ++++++++++ .../pipeline/rs_display_render_node_test.cpp | 17 ----------------- .../pipeline/rs_surface_render_node_test.cpp | 17 +++++++++++++++++ 11 files changed, 78 insertions(+), 31 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 6534ad47ad..a6c15ca551 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 @@ -313,16 +313,17 @@ void RSSurfaceRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) } Drawing::Region curSurfaceDrawRegion = CalculateVisibleRegion(*uniParam, *surfaceParams, *this, isUiFirstNode); // when surfacenode named "CapsuleWindow", cache the current canvas as SkImage for screen recording - auto ancestorDrawableTmp = surfaceParams->GetAncestorDisplayDrawable().lock(); - if (ancestorDrawableTmp == nullptr) { - RS_LOGE("ancestorDrawable is nullptr"); + auto ancestorDrawableTmp = + std::static_pointer_cast(surfaceParams->GetAncestorDisplayDrawable().lock()); + if (UNLIKELY(ancestorDrawableTmp == nullptr || ancestorDrawableTmp->GetRenderParams() == nullptr)) { + RS_LOGE("ancestorDrawable/renderParams is nullptr"); return; } - auto curDisplayDrawable = std::static_pointer_cast(ancestorDrawableTmp); // To be deleted after captureWindow being deleted - if (surfaceParams->GetName().find("CapsuleWindow") != std::string::npos) { - CacheImgForCapture(*rscanvas, *curDisplayDrawable); - RSUniRenderThread::Instance().GetRSRenderThreadParams()->SetRootIdOfCaptureWindow(curDisplayDrawable->GetId()); + if (surfaceParams->GetName().find("CapsuleWindow") != std::string::npos && + !ancestorDrawableTmp->GetRenderParams()->IsRotationChanged()) { + CacheImgForCapture(*rscanvas, *ancestorDrawableTmp); + uniParam->SetRootIdOfCaptureWindow(surfaceParams->GetRootIdOfCaptureWindow()); } if (!isUiFirstNode) { 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 8a5e2fe427..6812c54b43 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 @@ -1420,6 +1420,7 @@ void RSUniRenderVisitor::QuickPrepareSurfaceRenderNode(RSSurfaceRenderNode& node dirtyFlag_ = dirtyFlag; PrepareForUIFirstNode(node); + PrepareForCapsuleWindowNode(node); node.OpincSetInAppStateEnd(unchangeMarkInApp_); ResetCurSurfaceInfoAsUpperSurfaceParent(node); curCornerRadius_ = curCornerRadius; @@ -1428,6 +1429,18 @@ void RSUniRenderVisitor::QuickPrepareSurfaceRenderNode(RSSurfaceRenderNode& node node.SetNeedOffscreen(isScreenRotationAnimating_); } +void RSUniRenderVisitor::PrepareForCapsuleWindowNode(RSSurfaceRenderNode& node) +{ + if (UNLIKELY(!curDisplayNode_)) { + RS_LOGE("RSUniRenderVisitor::PrepareForCapsuleWindowNode curDisplayNode is nullptr"); + return; + } + if (node.GetName().find("CapsuleWindow") == std::string::npos) { + return; + } + node.SetRootIdOfCaptureWindow(FindInstanceChildOfDisplay(node.GetParent().lock())); +} + void RSUniRenderVisitor::PrepareForUIFirstNode(RSSurfaceRenderNode& node) { MultiThreadCacheType lastFlag = node.GetLastFrameUifirstFlag(); 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 da329265bf..7b6ad33c45 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 @@ -293,6 +293,8 @@ private: void UpdateHwcNodeDirtyRegionAndCreateLayer(std::shared_ptr& node); void UpdateHwcNodeEnable(); void PrevalidateHwcNode(); + + void PrepareForCapsuleWindowNode(RSSurfaceRenderNode& node); // use in QuickPrepareSurfaceRenderNode, update SurfaceRenderNode's uiFirst status void PrepareForUIFirstNode(RSSurfaceRenderNode& node); 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 f235705599..1290724ed2 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 @@ -273,6 +273,8 @@ public: // virtual display params virtual DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr GetMirrorSourceDrawable(); virtual bool GetSecurityDisplay() const { return true; } + virtual void SetRootIdOfCaptureWindow(NodeId rootIdOfCaptureWindow) {}; + virtual NodeId GetRootIdOfCaptureWindow() const { return INVALID_NODEID; } // canvas drawing node virtual bool IsNeedProcess() const { return true; } virtual void SetNeedProcess(bool isNeedProcess) {} 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 d28500e8b7..59ea6cf990 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 @@ -410,6 +410,8 @@ public: return false; } + void SetRootIdOfCaptureWindow(NodeId rootIdOfCaptureWindow) override; + NodeId GetRootIdOfCaptureWindow() const override; protected: private: bool isMainWindowType_ = false; @@ -483,6 +485,7 @@ private: Drawing::Matrix totalMatrix_; float globalAlpha_ = 1.0f; bool hasFingerprint_ = false; + NodeId rootIdOfCaptureWindow_ = INVALID_NODEID; friend class RSSurfaceRenderNode; friend class RSUniRenderProcessor; friend class RSUniRenderThread; 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 f22698d7a7..76fb6a26a0 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 @@ -281,12 +281,6 @@ public: void SetOffScreenCacheImgForCapture(std::shared_ptr offScreenCacheImgForCapture) { offScreenCacheImgForCapture_ = offScreenCacheImgForCapture; } - NodeId GetRootIdOfCaptureWindow() { - return rootIdOfCaptureWindow_; - } - void SetRootIdOfCaptureWindow(NodeId rootIdOfCaptureWindow) { - rootIdOfCaptureWindow_ = rootIdOfCaptureWindow; - } void SetMainAndLeashSurfaceDirty(bool isDirty); @@ -432,7 +426,6 @@ private: // Use in screen recording optimization std::shared_ptr offScreenCacheImgForCapture_ = nullptr; - NodeId rootIdOfCaptureWindow_ = INVALID_NODEID; // Use in vulkan parallel rendering bool isParallelDisplayNode_ = false; 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 994e1ea53f..88849e4e20 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 @@ -1185,6 +1185,12 @@ public: { dirtyStatus_ = containerDirty ? NodeDirty::DIRTY : dirtyStatus_; } + + NodeId GetRootIdOfCaptureWindow() { + return rootIdOfCaptureWindow_; + } + void SetRootIdOfCaptureWindow(NodeId rootIdOfCaptureWindow); + protected: void OnSync() override; void OnSkipSync() override; @@ -1445,6 +1451,8 @@ private: bool isHardwareForcedByBackgroundAlpha_ = false; + NodeId rootIdOfCaptureWindow_ = INVALID_NODEID; + // UIExtension record, inline static std::unordered_map secUIExtensionNodes_ = {}; friend class SurfaceNodeCommandHelper; 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 4aec4dbce4..e93fa4d4c4 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 @@ -391,6 +391,7 @@ void RSSurfaceRenderParams::OnSync(const std::unique_ptr& target targetSurfaceParams->totalMatrix_ = totalMatrix_; targetSurfaceParams->globalAlpha_ = globalAlpha_; targetSurfaceParams->hasFingerprint_ = hasFingerprint_; + targetDisplayParams->rootIdOfCaptureWindow_ = rootIdOfCaptureWindow_; RSRenderParams::OnSync(target); } @@ -431,4 +432,18 @@ const Occlusion::Region& RSSurfaceRenderParams::GetOpaqueRegion() const { return opaqueRegion_; } + +void RSSurfaceRenderParams::SetRootIdOfCaptureWindow(NodeId rootIdOfCaptureWindow) +{ + if (rootIdOfCaptureWindow_ == rootIdOfCaptureWindow) { + return; + } + needSync_ = true; + rootIdOfCaptureWindow_ = rootIdOfCaptureWindow; +} + +NodeId RSSurfaceRenderParams::GetRootIdOfCaptureWindow() const +{ + return rootIdOfCaptureWindow_; +} } // namespace OHOS::Rosen 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 841e8c10c7..21b0092df1 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 @@ -2712,5 +2712,15 @@ const std::unordered_map& RSSurfaceRenderNode::GetSecUIExtension { return secUIExtensionNodes_; } + +void RSSurfaceRenderNode::SetRootIdOfCaptureWindow(NodeId rootIdOfCaptureWindow) +{ + rootIdOfCaptureWindow_ = rootIdOfCaptureWindow; + if (stagingRenderParams_ == nullptr) { + RS_LOGE("%{public}s displayParams is nullptr", __func__); + return; + } + stagingRenderParams_->SetRootIdOfCaptureWindow(rootIdOfCaptureWindow); +} } // namespace Rosen } // namespace OHOS diff --git a/rosen/test/render_service/render_service_base/unittest/pipeline/rs_display_render_node_test.cpp b/rosen/test/render_service/render_service_base/unittest/pipeline/rs_display_render_node_test.cpp index 63c8cde311..fe3b10fa9f 100644 --- a/rosen/test/render_service/render_service_base/unittest/pipeline/rs_display_render_node_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/pipeline/rs_display_render_node_test.cpp @@ -252,23 +252,6 @@ HWTEST_F(RSDisplayRenderNodeTest, GetBootAnimationTest, TestSize.Level1) ASSERT_FALSE(node->GetBootAnimation()); } -/** - * @tc.name: SetRootIdOfCaptureWindow - * @tc.desc: test results of SetRootIdOfCaptureWindow - * @tc.type:FUNC - * @tc.require:issueI981R9 - */ -HWTEST_F(RSDisplayRenderNodeTest, SetRootIdOfCaptureWindow, TestSize.Level2) -{ - auto childNode = std::make_shared(id, context); - auto displayNode = std::make_shared(id + 1, config, context); - ASSERT_NE(childNode, nullptr); - ASSERT_NE(displayNode, nullptr); - - displayNode->SetRootIdOfCaptureWindow(childNode->GetId()); - ASSERT_EQ(displayNode->GetRootIdOfCaptureWindow(), childNode->GetId()); -} - /** * @tc.name: CollectSurface * @tc.desc: test results of CollectSurface diff --git a/rosen/test/render_service/render_service_base/unittest/pipeline/rs_surface_render_node_test.cpp b/rosen/test/render_service/render_service_base/unittest/pipeline/rs_surface_render_node_test.cpp index 940bf27927..fd5a044753 100644 --- a/rosen/test/render_service/render_service_base/unittest/pipeline/rs_surface_render_node_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/pipeline/rs_surface_render_node_test.cpp @@ -2486,5 +2486,22 @@ HWTEST_F(RSSurfaceRenderNodeTest, GetSkipDraw001, TestSize.Level2) ASSERT_FALSE(node->GetSkipDraw()); } + +/** + * @tc.name: SetRootIdOfCaptureWindow + * @tc.desc: test results of SetRootIdOfCaptureWindow + * @tc.type:FUNC + * @tc.require:issueI981R9 + */ +HWTEST_F(RSSurfaceRenderNodeTest, SetRootIdOfCaptureWindow, TestSize.Level2) +{ + auto rsContext = std::make_shared(); + auto node = std::make_shared(id, rsContext); + node->SetRootIdOfCaptureWindow(childNode->GetId()); + ASSERT_EQ(node->GetRootIdOfCaptureWindow(), childNode->GetId()); + node->InitRenderParams(); + node->SetRootIdOfCaptureWindow(childNode->GetId()); + ASSERT_EQ(node->StagingRenderParams()->GetRootIdOfCaptureWindow(), childNode->GetId()); +} } // namespace Rosen } // namespace OHOS \ No newline at end of file From 00f185ea64ee27776204907b34d7924876039c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A5=BC=E6=88=90=E6=9E=97?= Date: Wed, 31 Jul 2024 06:58:46 +0000 Subject: [PATCH 32/74] update rosen/modules/render_service_base/src/params/rs_surface_render_params.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 楼成林 --- .../render_service_base/src/params/rs_surface_render_params.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e93fa4d4c4..9d9978a514 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 @@ -391,7 +391,7 @@ void RSSurfaceRenderParams::OnSync(const std::unique_ptr& target targetSurfaceParams->totalMatrix_ = totalMatrix_; targetSurfaceParams->globalAlpha_ = globalAlpha_; targetSurfaceParams->hasFingerprint_ = hasFingerprint_; - targetDisplayParams->rootIdOfCaptureWindow_ = rootIdOfCaptureWindow_; + targetSurfaceParams->rootIdOfCaptureWindow_ = rootIdOfCaptureWindow_; RSRenderParams::OnSync(target); } From 817cf64844f97d101433678085e12d11eae9c309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A5=BC=E6=88=90=E6=9E=97?= Date: Wed, 31 Jul 2024 07:00:54 +0000 Subject: [PATCH 33/74] update rosen/modules/render_service_base/include/params/rs_render_params.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 楼成林 --- .../render_service_base/include/params/rs_render_params.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1290724ed2..9d7aa6e23c 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 @@ -273,7 +273,7 @@ public: // virtual display params virtual DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr GetMirrorSourceDrawable(); virtual bool GetSecurityDisplay() const { return true; } - virtual void SetRootIdOfCaptureWindow(NodeId rootIdOfCaptureWindow) {}; + virtual void SetRootIdOfCaptureWindow(NodeId rootIdOfCaptureWindow) {} virtual NodeId GetRootIdOfCaptureWindow() const { return INVALID_NODEID; } // canvas drawing node virtual bool IsNeedProcess() const { return true; } From a8fa8fb1966b80620064c3ca0ff54a700b1c6cc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A5=BC=E6=88=90=E6=9E=97?= Date: Wed, 31 Jul 2024 07:14:18 +0000 Subject: [PATCH 34/74] update rsdisplayrendernode_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 楼成林 --- .../rsdisplayrendernode_fuzzer/rsdisplayrendernode_fuzzer.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/rosen/test/render_service/render_service_base/fuzztest/rsdisplayrendernode_fuzzer/rsdisplayrendernode_fuzzer.cpp b/rosen/test/render_service/render_service_base/fuzztest/rsdisplayrendernode_fuzzer/rsdisplayrendernode_fuzzer.cpp index 4355df2f64..5dbfe9728c 100755 --- a/rosen/test/render_service/render_service_base/fuzztest/rsdisplayrendernode_fuzzer/rsdisplayrendernode_fuzzer.cpp +++ b/rosen/test/render_service/render_service_base/fuzztest/rsdisplayrendernode_fuzzer/rsdisplayrendernode_fuzzer.cpp @@ -145,8 +145,6 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) auto cacheImgForCapture = std::make_shared(); rsDisplayRenderNode.GetOffScreenCacheImgForCapture(); rsDisplayRenderNode.SetOffScreenCacheImgForCapture(cacheImgForCapture); - rsDisplayRenderNode.GetRootIdOfCaptureWindow(); - rsDisplayRenderNode.SetRootIdOfCaptureWindow(id); rsDisplayRenderNode.GetDirtySurfaceNodeMap(); rsDisplayRenderNode.ClearSurfaceSrcRect(); rsDisplayRenderNode.ClearSurfaceDstRect(); From 69ee6c64f31a5f358280d860126a2a2f87a03fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A5=BC=E6=88=90=E6=9E=97?= Date: Wed, 31 Jul 2024 07:29:24 +0000 Subject: [PATCH 35/74] update rs_surface_render_node_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 楼成林 --- .../unittest/pipeline/rs_surface_render_node_test.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rosen/test/render_service/render_service_base/unittest/pipeline/rs_surface_render_node_test.cpp b/rosen/test/render_service/render_service_base/unittest/pipeline/rs_surface_render_node_test.cpp index fd5a044753..d08af48a7b 100644 --- a/rosen/test/render_service/render_service_base/unittest/pipeline/rs_surface_render_node_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/pipeline/rs_surface_render_node_test.cpp @@ -2497,11 +2497,12 @@ HWTEST_F(RSSurfaceRenderNodeTest, SetRootIdOfCaptureWindow, TestSize.Level2) { auto rsContext = std::make_shared(); auto node = std::make_shared(id, rsContext); - node->SetRootIdOfCaptureWindow(childNode->GetId()); - ASSERT_EQ(node->GetRootIdOfCaptureWindow(), childNode->GetId()); + auto rootId = id + 1; + node->SetRootIdOfCaptureWindow(rootId); + ASSERT_EQ(node->GetRootIdOfCaptureWindow(), rootId); node->InitRenderParams(); - node->SetRootIdOfCaptureWindow(childNode->GetId()); - ASSERT_EQ(node->StagingRenderParams()->GetRootIdOfCaptureWindow(), childNode->GetId()); + node->SetRootIdOfCaptureWindow(rootId); + ASSERT_EQ(node->GetStagingRenderParams()->GetRootIdOfCaptureWindow(), rootId); } } // namespace Rosen } // namespace OHOS \ No newline at end of file From 1f441b5878779212f360237d6f518bff0fcf7d69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A5=BC=E6=88=90=E6=9E=97?= Date: Wed, 31 Jul 2024 07:30:52 +0000 Subject: [PATCH 36/74] update rs_surface_render_node_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 楼成林 --- .../unittest/pipeline/rs_surface_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_surface_render_node_test.cpp b/rosen/test/render_service/render_service_base/unittest/pipeline/rs_surface_render_node_test.cpp index d08af48a7b..23492141d5 100644 --- a/rosen/test/render_service/render_service_base/unittest/pipeline/rs_surface_render_node_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/pipeline/rs_surface_render_node_test.cpp @@ -2497,7 +2497,7 @@ HWTEST_F(RSSurfaceRenderNodeTest, SetRootIdOfCaptureWindow, TestSize.Level2) { auto rsContext = std::make_shared(); auto node = std::make_shared(id, rsContext); - auto rootId = id + 1; + auto rootId = id + 1; // 1 : generate a rootId for CaptureWindow node->SetRootIdOfCaptureWindow(rootId); ASSERT_EQ(node->GetRootIdOfCaptureWindow(), rootId); node->InitRenderParams(); From 363379a56996b372a182aab21ec4d5007f43a38c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A5=BC=E6=88=90=E6=9E=97?= Date: Wed, 31 Jul 2024 07:34:33 +0000 Subject: [PATCH 37/74] update rosen/modules/render_service_base/include/pipeline/rs_surface_render_node.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 楼成林 --- .../include/pipeline/rs_surface_render_node.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 88849e4e20..a7f5502337 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 @@ -1186,7 +1186,8 @@ public: dirtyStatus_ = containerDirty ? NodeDirty::DIRTY : dirtyStatus_; } - NodeId GetRootIdOfCaptureWindow() { + NodeId GetRootIdOfCaptureWindow() + { return rootIdOfCaptureWindow_; } void SetRootIdOfCaptureWindow(NodeId rootIdOfCaptureWindow); From 15cd5964b5b8d489b712432239704f01df3b0a9d Mon Sep 17 00:00:00 2001 From: y30043241 Date: Wed, 31 Jul 2024 15:34:54 +0800 Subject: [PATCH 38/74] =?UTF-8?q?DisplayNodeCommandFuzzTest=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: y30043241 --- .../fuzztest/rsdisplaynodecommand_fuzzer/project.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rosen/test/render_service/render_service_base/fuzztest/rsdisplaynodecommand_fuzzer/project.xml b/rosen/test/render_service/render_service_base/fuzztest/rsdisplaynodecommand_fuzzer/project.xml index 61d63a0715..3ddbf0bc3a 100755 --- a/rosen/test/render_service/render_service_base/fuzztest/rsdisplaynodecommand_fuzzer/project.xml +++ b/rosen/test/render_service/render_service_base/fuzztest/rsdisplaynodecommand_fuzzer/project.xml @@ -18,8 +18,8 @@ 1000 - 300 + 30 - 4096 + 8192 From 86446cd3a1c4512d8b0e2e44fbeae0fa39f3bf02 Mon Sep 17 00:00:00 2001 From: Xu Xianmin Date: Wed, 31 Jul 2024 16:59:42 +0800 Subject: [PATCH 39/74] Fix useeffect fallback Signed-off-by: Xu Xianmin --- .../src/drawable/rs_property_drawable_background.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rosen/modules/render_service_base/src/drawable/rs_property_drawable_background.cpp b/rosen/modules/render_service_base/src/drawable/rs_property_drawable_background.cpp index 5f87af4f1c..aaa41572d1 100644 --- a/rosen/modules/render_service_base/src/drawable/rs_property_drawable_background.cpp +++ b/rosen/modules/render_service_base/src/drawable/rs_property_drawable_background.cpp @@ -695,12 +695,15 @@ Drawing::RecordingCanvas::DrawFunc RSUseEffectDrawable::CreateDrawFunc() const if (!drawable) { return; } - RS_TRACE_NAME_FMT("RSPropertyDrawableUtils::DrawUseEffect Generate effectData"); + RS_TRACE_NAME_FMT("RSPropertyDrawableUtils::DrawUseEffect Fallback"); + RSAutoCanvasRestore arc(paintFilterCanvas, RSPaintFilterCanvas::SaveType::kEnv); bool disableFilterCache = paintFilterCanvas->GetDisableFilterCache(); paintFilterCanvas->SetDisableFilterCache(true); int8_t index = drawable->drawCmdIndex_.backgroundFilterIndex_; drawable->DrawImpl(*paintFilterCanvas, *rect, index); paintFilterCanvas->SetDisableFilterCache(disableFilterCache); + RSPropertyDrawableUtils::DrawUseEffect(paintFilterCanvas); + return; } RSPropertyDrawableUtils::DrawUseEffect(paintFilterCanvas); }; From 99399638a6918f64bc8e1f80c0ad3d02c640fa5e Mon Sep 17 00:00:00 2001 From: ltxmlSN Date: Wed, 31 Jul 2024 20:01:10 +0800 Subject: [PATCH 40/74] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E7=8E=87=E6=98=BE=E7=A4=BA=E7=9A=84=E5=AE=89=E5=85=A8=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: ltxmlSN --- .../rs_realtime_refresh_rate_manager.cpp | 5 ++-- .../rs_realtime_refresh_rate_manager_test.cpp | 26 +++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/rosen/modules/render_service/core/pipeline/rs_realtime_refresh_rate_manager.cpp b/rosen/modules/render_service/core/pipeline/rs_realtime_refresh_rate_manager.cpp index c0295a3f4c..cdbdbb275d 100644 --- a/rosen/modules/render_service/core/pipeline/rs_realtime_refresh_rate_manager.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_realtime_refresh_rate_manager.cpp @@ -33,6 +33,7 @@ RSRealtimeRefreshRateManager& RSRealtimeRefreshRateManager::Instance() void RSRealtimeRefreshRateManager::SetShowRefreshRateEnabled(bool enable) { + std::unique_lock threadLock(threadMutex_); if (enableState_ == enable) { return; } @@ -46,9 +47,9 @@ void RSRealtimeRefreshRateManager::SetShowRefreshRateEnabled(bool enable) uint32_t lastRefreshRate = 0; uint32_t lastRealtimeRefreshRate = 0; currRealtimeRefreshRate_ = 1; + std::mutex condMutex; while (enableState_) { - std::unique_lock lock(threadMutex_); - + std::unique_lock lock(condMutex); auto st = std::chrono::steady_clock::now(); realtimeFrameCount_ = 0; threadCondVar_.wait_for(lock, NS_FPS_SHOW_INTERVAL_); diff --git a/rosen/test/render_service/render_service/unittest/pipeline/rs_realtime_refresh_rate_manager_test.cpp b/rosen/test/render_service/render_service/unittest/pipeline/rs_realtime_refresh_rate_manager_test.cpp index fe71f33f01..c67bc9395d 100644 --- a/rosen/test/render_service/render_service/unittest/pipeline/rs_realtime_refresh_rate_manager_test.cpp +++ b/rosen/test/render_service/render_service/unittest/pipeline/rs_realtime_refresh_rate_manager_test.cpp @@ -57,6 +57,28 @@ HWTEST_F(RSRealtimeRefreshRateManagerTest, EnableStatus001, TestSize.Level1) ASSERT_EQ(ret, false); } +/** + * @tc.name: EnableStatus002 + * @tc.desc: test RSRealtimeRefreshRateManagerTest.EnableStatus002 + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(RSRealtimeRefreshRateManagerTest, EnableStatus002, TestSize.Level1) +{ + auto& instance = RSRealtimeRefreshRateManager::Instance(); + uint32_t threadNums = 100; + std::vector thds; + for (int i = 0; i < threadNums; i++) { + thds.emplace_back(std::thread([&] () { instance.SetShowRefreshRateEnabled(true); })); + thds.emplace_back(std::thread([&] () { instance.SetShowRefreshRateEnabled(false); })); + } + for (auto &thd : thds) { + if (thd.joinable()) { + thd.join(); + } + } +} + /** * @tc.name: RSInterface001 * @tc.desc: test RSRealtimeRefreshRateManagerTest.RSInterface001 @@ -69,11 +91,11 @@ HWTEST_F(RSRealtimeRefreshRateManagerTest, RSInterface001, TestSize.Level1) instance.SetShowRefreshRateEnabled(true); bool ret = instance.GetShowRefreshRateEnabled(); - ASSERT_EQ(ret, true); + ASSERT_EQ(ret, false); instance.SetShowRefreshRateEnabled(true); ret = instance.GetShowRefreshRateEnabled(); - ASSERT_EQ(ret, true); + ASSERT_EQ(ret, false); instance.SetShowRefreshRateEnabled(false); ret = instance.GetShowRefreshRateEnabled(); From 932c598ea58ce3dd8a228f091fb7c7bc5e25e929 Mon Sep 17 00:00:00 2001 From: zzvscx Date: Tue, 30 Jul 2024 16:40:41 +0800 Subject: [PATCH 41/74] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=A7=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=89=93=E7=82=B9=E6=95=B0=E6=8D=AE=E5=BC=82=E5=B8=B8?= =?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: zzvscx Change-Id: Ia6770980243a43ab04f51c7aa010eec369737157 --- .../hgm_frame_rate_manager.cpp | 70 ++++++++++--------- .../hgm_frame_rate_manager.h | 3 +- .../rs_render_service_connection_proxy.cpp | 1 + 3 files changed, 40 insertions(+), 34 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 81540d5aa0..609d29d0c9 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 @@ -1044,38 +1044,36 @@ void HgmFrameRateManager::DeliverRefreshRateVote(const VoteInfo& voteInfo, bool } } -bool HgmFrameRateManager::MergeRangeByPriority(VoteRange& rangeRes, const VoteRange& curVoteRange) +std::pair HgmFrameRateManager::MergeRangeByPriority(VoteRange& rangeRes, const VoteRange& curVoteRange) { auto &[min, max] = rangeRes; auto &[minTemp, maxTemp] = curVoteRange; + bool needMergeVoteInfo = false; if (minTemp > min) { min = minTemp; if (min >= max) { min = max; - return true; + return {true, needMergeVoteInfo}; } } if (maxTemp < max) { max = maxTemp; + needMergeVoteInfo = true; if (min >= max) { max = min; - return true; + return {true, needMergeVoteInfo}; } } if (min == max) { - return true; + return {true, needMergeVoteInfo}; } - return false; + return {false, needMergeVoteInfo}; } bool HgmFrameRateManager::MergeLtpo2IdleVote( std::vector::iterator &voterIter, VoteInfo& resultVoteInfo, VoteRange &mergedVoteRange) { bool mergeSuccess = false; - auto log = [](std::string voter, pid_t pid, uint32_t minTemp, uint32_t maxTemp) { - RS_TRACE_NAME_FMT("Process voter:%s(pid:%d), value:[%d-%d] skip", voter.c_str(), pid, minTemp, maxTemp); - HGM_LOGI("Process:%{public}s(%{public}d):[%{public}d, %{public}d] skip", voter.c_str(), pid, minTemp, maxTemp); - }; // [VOTER_LTPO, VOTER_IDLE) for (; voterIter != voters_.end() - 1; voterIter++) { if (voteRecord_.find(*voterIter) == voteRecord_.end()) { @@ -1088,27 +1086,23 @@ bool HgmFrameRateManager::MergeLtpo2IdleVote( VoteInfo curVoteInfo = vec.back(); if (!multiAppStrategy_.CheckPidValid(curVoteInfo.pid)) { - log(curVoteInfo.voterName, curVoteInfo.pid, curVoteInfo.min, curVoteInfo.max); + ProcessVoteLog(curVoteInfo, true); continue; } if (curVoteInfo.voterName == "VOTER_VIDEO") { auto foregroundPidApp = multiAppStrategy_.GetForegroundPidApp(); if (foregroundPidApp.find(curVoteInfo.pid) == foregroundPidApp.end()) { - log(curVoteInfo.voterName, curVoteInfo.pid, curVoteInfo.min, curVoteInfo.max); + ProcessVoteLog(curVoteInfo, true); continue; } auto configData = HgmCore::Instance().GetPolicyConfigData(); if (configData != nullptr && configData->videoFrameRateList_.find( foregroundPidApp[curVoteInfo.pid].second) == configData->videoFrameRateList_.end()) { - log(curVoteInfo.voterName, curVoteInfo.pid, curVoteInfo.min, curVoteInfo.max); + ProcessVoteLog(curVoteInfo, true); continue; } } - RS_TRACE_NAME_FMT("Process voter:%s(pid:%d), value:[%d-%d]", - curVoteInfo.voterName.c_str(), curVoteInfo.pid, curVoteInfo.min, curVoteInfo.max); - // FORMAT voter(pid):[min,max] - HGM_LOGI("Process: %{public}s(%{public}d):[%{public}d, %{public}d]", - curVoteInfo.voterName.c_str(), curVoteInfo.pid, curVoteInfo.min, curVoteInfo.max); + ProcessVoteLog(curVoteInfo, false); if (mergeSuccess) { mergedVoteRange.first = mergedVoteRange.first > curVoteInfo.min ? mergedVoteRange.first : curVoteInfo.min; if (curVoteInfo.max >= mergedVoteRange.second) { @@ -1127,8 +1121,10 @@ bool HgmFrameRateManager::MergeLtpo2IdleVote( VoteInfo HgmFrameRateManager::ProcessRefreshRateVote() { if (!isRefreshNeed_) { - RS_TRACE_NAME_FMT("Process nothing, lastVoteInfo: %s[%d, %d]", - lastVoteInfo_.voterName.c_str(), lastVoteInfo_.min, lastVoteInfo_.max); + const auto& packages = multiAppStrategy_.GetPackages(); + RS_TRACE_NAME_FMT("Process nothing, lastVoteInfo: %s[%d, %d] curPackage: %s, touchState: %d", + lastVoteInfo_.voterName.c_str(), lastVoteInfo_.min, lastVoteInfo_.max, + packages.empty() ? "" : packages.front().c_str(), touchManager_.GetState()); return lastVoteInfo_; } UpdateVoteRule(); @@ -1140,9 +1136,14 @@ VoteInfo HgmFrameRateManager::ProcessRefreshRateVote() auto &[min, max] = voteRange; for (auto voterIter = voters_.begin(); voterIter != voters_.end(); voterIter++) { - if (*voterIter == "VOTER_LTPO") { - VoteRange info; - if (MergeLtpo2IdleVote(voterIter, resultVoteInfo, info) && MergeRangeByPriority(voteRange, info)) { + VoteRange range; + VoteInfo info; + if (*voterIter == "VOTER_LTPO" && MergeLtpo2IdleVote(voterIter, info, range)) { + auto [mergeVoteRange, mergeVoteInfo] = MergeRangeByPriority(voteRange, range); + if (mergeVoteInfo) { + resultVoteInfo.Merge(info); + } + if (mergeVoteRange) { break; } } @@ -1153,22 +1154,17 @@ VoteInfo HgmFrameRateManager::ProcessRefreshRateVote() } VoteInfo curVoteInfo = voteRecord_[voter].back(); if ((voter == "VOTER_GAMES" && !gameScenes_.empty()) || !multiAppStrategy_.CheckPidValid(curVoteInfo.pid)) { - RS_TRACE_NAME_FMT("Process voter:%s(pid:%d), value:[%d-%d] skip", - curVoteInfo.voterName.c_str(), curVoteInfo.pid, curVoteInfo.min, curVoteInfo.max); - HGM_LOGI("Process: %{public}s(%{public}d):[%{public}d, %{public}d] skip", - curVoteInfo.voterName.c_str(), curVoteInfo.pid, curVoteInfo.min, curVoteInfo.max); + ProcessVoteLog(curVoteInfo, true); continue; } - - RS_TRACE_NAME_FMT("Process voter:%s(pid:%d), value:[%d-%d]", - curVoteInfo.voterName.c_str(), curVoteInfo.pid, curVoteInfo.min, curVoteInfo.max); - HGM_LOGI("Process: %{public}s(%{public}d):[%{public}d, %{public}d]", - curVoteInfo.voterName.c_str(), curVoteInfo.pid, curVoteInfo.min, curVoteInfo.max); - if (MergeRangeByPriority(voteRange, {curVoteInfo.min, curVoteInfo.max})) { + ProcessVoteLog(curVoteInfo, false); + auto [mergeVoteRange, mergeVoteInfo] = MergeRangeByPriority(voteRange, {curVoteInfo.min, curVoteInfo.max}); + if (mergeVoteInfo) { resultVoteInfo.Merge(curVoteInfo); + } + if (mergeVoteRange) { break; } - resultVoteInfo.Merge(curVoteInfo); } isRefreshNeed_ = false; HGM_LOGI("Process: Strategy:%{public}s Screen:%{public}d Mode:%{public}d -- VoteResult:{%{public}d-%{public}d}", @@ -1333,5 +1329,13 @@ void HgmFrameRateManager::ExitEnergyConsumptionAssuranceMode() HgmEnergyConsumptionPolicy::Instance().SetAnimationEnergyConsumptionAssuranceMode(false); HgmEnergyConsumptionPolicy::Instance().SetUiEnergyConsumptionAssuranceMode(false); } + +void HgmFrameRateManager::ProcessVoteLog(const VoteInfo& curVoteInfo, bool isSkip) +{ + RS_TRACE_NAME_FMT("Process voter:%s(pid:%d), value:[%d-%d] skip: %s", + curVoteInfo.voterName.c_str(), curVoteInfo.pid, curVoteInfo.min, curVoteInfo.max, isSkip ? "true" : "false"); + HGM_LOGI("Process: %{public}s(%{public}d):[%{public}d, %{public}d] skip: %{public}s", + curVoteInfo.voterName.c_str(), curVoteInfo.pid, curVoteInfo.min, curVoteInfo.max, isSkip ? "true" : "false"); +} } // namespace Rosen } // namespace OHOS \ No newline at end of file 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 b319c439c9..119086986b 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 @@ -168,7 +168,7 @@ public: isNeedUpdateAppOffset_ = isNeedUpdateAppOffset; } - static bool MergeRangeByPriority(VoteRange& rangeRes, const VoteRange& curVoteRange); + static std::pair MergeRangeByPriority(VoteRange& rangeRes, const VoteRange& curVoteRange); void CheckPackageInConfigList(std::unordered_map> foregroundPidAppMap); private: void Reset(); @@ -204,6 +204,7 @@ private: void UpdateEnergyConsumptionConfig(); void EnterEnergyConsumptionAssuranceMode(); void ExitEnergyConsumptionAssuranceMode(); + static void ProcessVoteLog(const VoteInfo& curVoteInfo, bool isSkip); uint32_t currRefreshRate_ = 0; uint32_t controllerRate_ = 0; 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 814eeddcb5..c807773e73 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 @@ -740,6 +740,7 @@ void RSRenderServiceConnectionProxy::SyncFrameRateRange(FrameRateLinkerId id, co if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { ROSEN_LOGE("RSRenderServiceProxy failed to get descriptor"); + return; } option.SetFlags(MessageOption::TF_SYNC); From d4fab32498d4c5a2e2589b8e0e59b16d40951a82 Mon Sep 17 00:00:00 2001 From: tanyuhang Date: Thu, 1 Aug 2024 09:30:06 +0800 Subject: [PATCH 42/74] 0801add_render_service_tdd Signed-off-by: tanyuhang --- .../unittest/modifier/BUILD.gn | 1 + .../modifier/rs_property_modifier_test.cpp | 262 ++++++++++++++++++ .../unittest/ui/rs_frame_rate_policy_test.cpp | 2 +- .../unittest/ui/rs_node_test.cpp | 84 ++++++ .../unittest/ui/rs_ui_director_test.cpp | 2 +- 5 files changed, 349 insertions(+), 2 deletions(-) create mode 100644 rosen/test/render_service/render_service_client/unittest/modifier/rs_property_modifier_test.cpp diff --git a/rosen/test/render_service/render_service_client/unittest/modifier/BUILD.gn b/rosen/test/render_service/render_service_client/unittest/modifier/BUILD.gn index 0de9ee0b87..3f31b8e5fe 100755 --- a/rosen/test/render_service/render_service_client/unittest/modifier/BUILD.gn +++ b/rosen/test/render_service/render_service_client/unittest/modifier/BUILD.gn @@ -25,6 +25,7 @@ ohos_unittest("RSRenderServiceClientModifierTest") { "rs_modifier_extractor_test.cpp", "rs_modifier_manager_test.cpp", "rs_modifier_test.cpp", + "rs_property_modifier_test.cpp", "rs_property_test.cpp", ] diff --git a/rosen/test/render_service/render_service_client/unittest/modifier/rs_property_modifier_test.cpp b/rosen/test/render_service/render_service_client/unittest/modifier/rs_property_modifier_test.cpp new file mode 100644 index 0000000000..bbd4ef87d3 --- /dev/null +++ b/rosen/test/render_service/render_service_client/unittest/modifier/rs_property_modifier_test.cpp @@ -0,0 +1,262 @@ +/* + * Copyright (c) 2021-2023 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 +#include "gtest/gtest.h" +#include "modifier/rs_property.h" +#include "modifier/rs_property_modifier.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS::Rosen { +class RSPropertyModifierTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; + + const Vector2f INITIAL_VALUE_2F = Vector2f(0.f, 0.f); + const Vector4f INITIAL_VALUE_4F = Vector4f(0.f, 0.f, 0.f, 0.f); +}; + +void RSPropertyModifierTest::SetUpTestCase() {} +void RSPropertyModifierTest::TearDownTestCase() {} +void RSPropertyModifierTest::SetUp() {} +void RSPropertyModifierTest::TearDown() {} + +/** + * @tc.name: GetModifierType + * @tc.desc: RSEnvForegroundColorModifier Test + * @tc.type: FUNC + */ +HWTEST_F(RSPropertyModifierTest, GetModifierType, TestSize.Level1) +{ + std::shared_ptr property = std::make_shared(); + ASSERT_NE(property, nullptr); + std::shared_ptr colorModifier = + std::make_shared(property); + ASSERT_NE(colorModifier, nullptr); + RSModifierType ModifierType = colorModifier->GetModifierType(); + EXPECT_EQ(ModifierType, RSModifierType::ENV_FOREGROUND_COLOR); +} + +/** + * @tc.name: CreateRenderModifier + * @tc.desc: RSEnvForegroundColorModifier Test + * @tc.type: FUNC + */ +HWTEST_F(RSPropertyModifierTest, CreateRenderModifier, TestSize.Level1) +{ + std::shared_ptr property = std::make_shared(); + ASSERT_NE(property, nullptr); + std::shared_ptr colorModifier = + std::make_shared(property); + ASSERT_NE(colorModifier, nullptr); + auto res = colorModifier->CreateRenderModifier(); + EXPECT_NE(res, nullptr); +} + +/** + * @tc.name: GetModifierType02 + * @tc.desc: RSEnvForegroundColorStrategyModifier Test + * @tc.type: FUNC + */ +HWTEST_F(RSPropertyModifierTest, GetModifierType02, TestSize.Level1) +{ + std::shared_ptr property = std::make_shared(); + ASSERT_NE(property, nullptr); + std::shared_ptr colorStrategyModifier = + std::make_shared(property); + ASSERT_NE(colorStrategyModifier, nullptr); + RSModifierType res = colorStrategyModifier->GetModifierType(); + EXPECT_EQ(res, RSModifierType::ENV_FOREGROUND_COLOR_STRATEGY); +} + +/** + * @tc.name: CreateRenderModifier02 + * @tc.desc: RSEnvForegroundColorStrategyModifier Test + * @tc.type: FUNC + */ +HWTEST_F(RSPropertyModifierTest, CreateRenderModifier02, TestSize.Level1) +{ + std::shared_ptr property = std::make_shared(); + ASSERT_NE(property, nullptr); + std::shared_ptr colorStrategyModifier = + std::make_shared(property); + ASSERT_NE(colorStrategyModifier, nullptr); + auto renderModifier = colorStrategyModifier->CreateRenderModifier(); + EXPECT_NE(renderModifier, nullptr); +} + +/** + * @tc.name: Apply01 + * @tc.desc: RSBoundsModifier/RSBoundsSizeModifier/RSBoundsPositionModifier + * @tc.type: FUNC + */ +HWTEST_F(RSPropertyModifierTest, Apply01, TestSize.Level1) +{ + std::shared_ptr geometry = std::make_shared(); + ASSERT_NE(geometry, nullptr); + + auto property = std::make_shared>(INITIAL_VALUE_4F); + ASSERT_NE(property, nullptr); + std::shared_ptr boundsModifier = std::make_shared(property); + ASSERT_NE(boundsModifier, nullptr); + boundsModifier->Apply(geometry); + + auto property02 = std::make_shared>(INITIAL_VALUE_2F); + ASSERT_NE(property02, nullptr); + std::shared_ptr boundsSizeModifier = std::make_shared(property02); + ASSERT_NE(boundsSizeModifier, nullptr); + boundsSizeModifier->Apply(geometry); + + auto property03 = std::make_shared>(INITIAL_VALUE_2F); + ASSERT_NE(property03, nullptr); + std::shared_ptr boundsPositionModifier = + std::make_shared(property03); + ASSERT_NE(boundsPositionModifier, nullptr); + boundsPositionModifier->Apply(geometry); + EXPECT_EQ(geometry->x_, 0.f); + EXPECT_EQ(geometry->y_, 0.f); + EXPECT_EQ(geometry->z_, 0.f); + EXPECT_EQ(geometry->width_, 0.f); + EXPECT_EQ(geometry->height_, 0.f); +} + +/** + * @tc.name: Apply02 + * @tc.desc: RSPivotModifier/RSPivotZModifier/RSQuaternionModifier + * @tc.type: FUNC + */ +HWTEST_F(RSPropertyModifierTest, Apply02, TestSize.Level1) +{ + std::shared_ptr geometry = std::make_shared(); + ASSERT_NE(geometry, nullptr); + + auto property = std::make_shared>(INITIAL_VALUE_2F); + ASSERT_NE(property, nullptr); + std::shared_ptr pivotModifier = std::make_shared(property); + ASSERT_NE(pivotModifier, nullptr); + pivotModifier->Apply(geometry); + + auto property02 = std::make_shared>(0.f); + ASSERT_NE(property02, nullptr); + std::shared_ptr pivotZModifier = std::make_shared(property02); + ASSERT_NE(pivotZModifier, nullptr); + pivotZModifier->Apply(geometry); + + Quaternion value = Quaternion(0, 0, 0, 0); + auto property03 = std::make_shared>(value); + ASSERT_NE(property03, nullptr); + std::shared_ptr quaternionModifier = std::make_shared(property03); + ASSERT_NE(quaternionModifier, nullptr); + quaternionModifier->Apply(geometry); + EXPECT_EQ(geometry->z_, 0.f); +} + +/** + * @tc.name: Apply03 + * @tc.desc: RSRotationModifier/RSRotationXModifier/RSRotationYModifier + * @tc.type: FUNC + */ +HWTEST_F(RSPropertyModifierTest, Apply03, TestSize.Level1) +{ + std::shared_ptr geometry = std::make_shared(); + ASSERT_NE(geometry, nullptr); + + auto property = std::make_shared>(0.f); + ASSERT_NE(property, nullptr); + std::shared_ptr rotationModifier = std::make_shared(property); + ASSERT_NE(rotationModifier, nullptr); + rotationModifier->Apply(geometry); + + auto property02 = std::make_shared>(0.f); + ASSERT_NE(property02, nullptr); + std::shared_ptr rotationXModifier = std::make_shared(property02); + ASSERT_NE(rotationXModifier, nullptr); + rotationXModifier->Apply(geometry); + + auto property03 = std::make_shared>(0.f); + ASSERT_NE(property03, nullptr); + std::shared_ptr rotationYModifier = std::make_shared(property03); + ASSERT_NE(rotationYModifier, nullptr); + rotationYModifier->Apply(geometry); + EXPECT_EQ(geometry->z_, 0.f); +} + +/** + * @tc.name: Apply04 + * @tc.desc: RSCameraDistanceModifier/RSScaleModifier/RSSkewModifier + * @tc.type: FUNC + */ +HWTEST_F(RSPropertyModifierTest, Apply04, TestSize.Level1) +{ + std::shared_ptr geometry = std::make_shared(); + ASSERT_NE(geometry, nullptr); + + auto property = std::make_shared>(0.f); + ASSERT_NE(property, nullptr); + std::shared_ptr cameraDistanceModifier = + std::make_shared(property); + ASSERT_NE(cameraDistanceModifier, nullptr); + cameraDistanceModifier->Apply(geometry); + + auto property02 = std::make_shared>(INITIAL_VALUE_2F); + ASSERT_NE(property02, nullptr); + std::shared_ptr scaleModifier = std::make_shared(property02); + ASSERT_NE(scaleModifier, nullptr); + scaleModifier->Apply(geometry); + + auto property03 = std::make_shared>(INITIAL_VALUE_2F); + ASSERT_NE(property03, nullptr); + std::shared_ptr skewModifier = std::make_shared(property03); + ASSERT_NE(skewModifier, nullptr); + skewModifier->Apply(geometry); + EXPECT_EQ(geometry->z_, 0.f); +} + +/** + * @tc.name: Apply05 + * @tc.desc: RSPerspModifier/RSTranslateModifier/RSTranslateZModifier + * @tc.type: FUNC + */ +HWTEST_F(RSPropertyModifierTest, Apply05, TestSize.Level1) +{ + std::shared_ptr geometry = std::make_shared(); + ASSERT_NE(geometry, nullptr); + + std::shared_ptr property = std::make_shared>(INITIAL_VALUE_2F); + ASSERT_NE(property, nullptr); + std::shared_ptr perspModifier = std::make_shared(property); + ASSERT_NE(perspModifier, nullptr); + perspModifier->Apply(geometry); + + std::shared_ptr property02 = std::make_shared>(INITIAL_VALUE_2F); + ASSERT_NE(property02, nullptr); + std::shared_ptr translateModifier = std::make_shared(property02); + ASSERT_NE(translateModifier, nullptr); + translateModifier->Apply(geometry); + + std::shared_ptr property03 = std::make_shared>(0.f); + ASSERT_NE(property03, nullptr); + std::shared_ptr translateZModifier = std::make_shared(property03); + ASSERT_NE(translateZModifier, nullptr); + translateZModifier->Apply(geometry); + EXPECT_EQ(geometry->z_, 0.f); +} +} // namespace OHOS::Rosen \ No newline at end of file diff --git a/rosen/test/render_service/render_service_client/unittest/ui/rs_frame_rate_policy_test.cpp b/rosen/test/render_service/render_service_client/unittest/ui/rs_frame_rate_policy_test.cpp index c59d802e56..49d628c912 100644 --- a/rosen/test/render_service/render_service_client/unittest/ui/rs_frame_rate_policy_test.cpp +++ b/rosen/test/render_service/render_service_client/unittest/ui/rs_frame_rate_policy_test.cpp @@ -128,7 +128,7 @@ HWTEST_F(RSFrameRatePolicyTest, GetRefreshRateModeName, TestSize.Level1) { auto instance = RSFrameRatePolicy::GetInstance(); int32_t res = instance->GetRefreshRateModeName(); - EXPECT_TRUE(res == 0); + EXPECT_TRUE(res == -1); } /** 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 bf62faf142..58f007c1f8 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 @@ -6985,4 +6985,88 @@ HWTEST_F(RSNodeTest, SetWaterRippleParams, TestSize.Level1) rsNode->SetWaterRippleParams(rs_water_ripple_param, progress); EXPECT_EQ(waveCount, 2.0f); } + +/** + * @tc.name: IsGeometryDirty + * @tc.desc: test results of IsGeometryDirty + * @tc.type: FUNC + */ +HWTEST_F(RSNodeTest, IsGeometryDirty, TestSize.Level1) +{ + auto rsNode = RSCanvasNode::Create(); + ASSERT_TRUE(rsNode != nullptr); + bool res = rsNode->IsGeometryDirty(); + EXPECT_EQ(res, false); +} + +/** + * @tc.name: IsAppearanceDirty + * @tc.desc: test results of IsAppearanceDirty + * @tc.type: FUNC + */ +HWTEST_F(RSNodeTest, IsAppearanceDirty, TestSize.Level1) +{ + auto rsNode = RSCanvasNode::Create(); + ASSERT_TRUE(rsNode != nullptr); + bool res = rsNode->IsAppearanceDirty(); + EXPECT_EQ(res, false); +} + +/** + * @tc.name: MarkDirty + * @tc.desc: test results of MarkDirty + * @tc.type: FUNC + */ +HWTEST_F(RSNodeTest, MarkDirty, TestSize.Level1) +{ + auto rsNode = RSCanvasNode::Create(); + ASSERT_TRUE(rsNode != nullptr); + rsNode->MarkDirty(NodeDirtyType::GEOMETRY, true); + EXPECT_EQ(rsNode->dirtyType_, 1); + + rsNode->MarkDirty(NodeDirtyType::GEOMETRY, false); + EXPECT_EQ(rsNode->dirtyType_, 0); +} + +/** + * @tc.name: UpdateLocalGeometry + * @tc.desc: test results of UpdateLocalGeometry + * @tc.type: FUNC + */ +HWTEST_F(RSNodeTest, UpdateLocalGeometry, TestSize.Level1) +{ + auto rsNode = RSCanvasNode::Create(); + ASSERT_TRUE(rsNode != nullptr); + rsNode->MarkDirty(NodeDirtyType::GEOMETRY, true); + + rsNode->modifiers_.clear(); + ASSERT_TRUE(rsNode->modifiers_.empty()); + auto value = Vector4f(100.f); + auto prop = std::make_shared>(value); + auto modifier = std::make_shared(prop); + rsNode->modifiers_[0] = modifier; + ASSERT_TRUE(!rsNode->modifiers_.empty()); + rsNode->UpdateLocalGeometry(); +} + +/** + * @tc.name: UpdateGlobalGeometry + * @tc.desc: test results of UpdateGlobalGeometry + * @tc.type: FUNC + */ +HWTEST_F(RSNodeTest, UpdateGlobalGeometry, TestSize.Level1) +{ + auto rsNode = RSCanvasNode::Create(); + ASSERT_TRUE(rsNode != nullptr); + rsNode->UpdateGlobalGeometry(nullptr); + + std::shared_ptr parentGlobalGeometry = std::make_shared(); + ASSERT_NE(parentGlobalGeometry, nullptr); + rsNode->localGeometry_ = parentGlobalGeometry; + rsNode->UpdateGlobalGeometry(parentGlobalGeometry); + + rsNode->globalGeometry_ = parentGlobalGeometry; + rsNode->UpdateGlobalGeometry(parentGlobalGeometry); + EXPECT_NE(rsNode->GetGlobalGeometry(), nullptr); +} } // namespace OHOS::Rosen diff --git a/rosen/test/render_service/render_service_client/unittest/ui/rs_ui_director_test.cpp b/rosen/test/render_service/render_service_client/unittest/ui/rs_ui_director_test.cpp index cb2a13d836..41ccc76ac8 100755 --- a/rosen/test/render_service/render_service_client/unittest/ui/rs_ui_director_test.cpp +++ b/rosen/test/render_service/render_service_client/unittest/ui/rs_ui_director_test.cpp @@ -291,7 +291,7 @@ HWTEST_F(RSUIDirectorTest, GetCurrentRefreshRateMode, TestSize.Level1) std::shared_ptr director = RSUIDirector::Create(); ASSERT_TRUE(director != nullptr); int32_t res = director->GetCurrentRefreshRateMode(); - ASSERT_TRUE(res == 0); + ASSERT_TRUE(res == -1); } /** From 47d08997ff2da611cd6be06d930e5a63b3e18f63 Mon Sep 17 00:00:00 2001 From: sunqizhen Date: Tue, 30 Jul 2024 15:32:25 +0800 Subject: [PATCH 43/74] =?UTF-8?q?=E4=BF=AE=E5=A4=8DNode-Drawable=E8=A7=A3?= =?UTF-8?q?=E8=80=A6=E5=BC=95=E8=B5=B7=E7=9A=84TDD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: sunqizhen --- .../pipeline/rs_base_render_engine_test.cpp | 5 +- .../pipeline/rs_base_render_util_test.cpp | 1 + .../pipeline/rs_divided_render_util_test.cpp | 8 ++- .../pipeline/rs_hardware_thread_test.cpp | 1 + .../rs_render_service_listener_test.cpp | 5 +- .../rs_render_service_visitor_test.cpp | 5 +- .../pipeline/rs_surface_capture_task_test.cpp | 8 ++- .../pipeline/rs_uni_render_util_test.cpp | 67 +++++++++++++------ .../rs_uni_render_virtual_processor_test.cpp | 11 +-- .../pipeline/rs_uni_ui_capture_test.cpp | 7 +- 10 files changed, 86 insertions(+), 32 deletions(-) diff --git a/rosen/test/render_service/render_service/unittest/pipeline/rs_base_render_engine_test.cpp b/rosen/test/render_service/render_service/unittest/pipeline/rs_base_render_engine_test.cpp index 94991a6b7f..61b2c5092b 100644 --- a/rosen/test/render_service/render_service/unittest/pipeline/rs_base_render_engine_test.cpp +++ b/rosen/test/render_service/render_service/unittest/pipeline/rs_base_render_engine_test.cpp @@ -31,7 +31,10 @@ public: void TearDown() override; }; -void RSBaseRenderEngineUnitTest::SetUpTestCase() {} +void RSBaseRenderEngineUnitTest::SetUpTestCase() +{ + RSTestUtil::InitRenderNodeGC(); +} void RSBaseRenderEngineUnitTest::TearDownTestCase() {} void RSBaseRenderEngineUnitTest::SetUp() {} void RSBaseRenderEngineUnitTest::TearDown() {} diff --git a/rosen/test/render_service/render_service/unittest/pipeline/rs_base_render_util_test.cpp b/rosen/test/render_service/render_service/unittest/pipeline/rs_base_render_util_test.cpp index d0f1905ffc..d137f04f76 100644 --- a/rosen/test/render_service/render_service/unittest/pipeline/rs_base_render_util_test.cpp +++ b/rosen/test/render_service/render_service/unittest/pipeline/rs_base_render_util_test.cpp @@ -100,6 +100,7 @@ void RSBaseRenderUtilTest::SetUpTestCase() { RSSurfaceRenderNodeConfig config; node_ = std::make_shared(config); + RSTestUtil::InitRenderNodeGC(); } void RSBaseRenderUtilTest::TearDownTestCase() diff --git a/rosen/test/render_service/render_service/unittest/pipeline/rs_divided_render_util_test.cpp b/rosen/test/render_service/render_service/unittest/pipeline/rs_divided_render_util_test.cpp index 3c77d8e3e0..1af7da7752 100644 --- a/rosen/test/render_service/render_service/unittest/pipeline/rs_divided_render_util_test.cpp +++ b/rosen/test/render_service/render_service/unittest/pipeline/rs_divided_render_util_test.cpp @@ -30,7 +30,10 @@ public: void TearDown() override; }; -void RSDividedRenderUtilTest::SetUpTestCase() {} +void RSDividedRenderUtilTest::SetUpTestCase() +{ + RSTestUtil::InitRenderNodeGC(); +} void RSDividedRenderUtilTest::TearDownTestCase() {} void RSDividedRenderUtilTest::SetUp() {} void RSDividedRenderUtilTest::TearDown() {} @@ -45,6 +48,7 @@ HWTEST_F(RSDividedRenderUtilTest, CreateBufferDrawParam001, TestSize.Level1) { RSSurfaceRenderNodeConfig config; std::shared_ptr node = std::make_shared(config); + node->InitRenderParams(); Drawing::Matrix matrix = Drawing::Matrix(); matrix.SetMatrix(1, 0, 0, 0, 1, 0, 0, 0, 1); auto param = RSDividedRenderUtil::CreateBufferDrawParam(*node, true); @@ -66,7 +70,7 @@ HWTEST_F(RSDividedRenderUtilTest, CreateBufferDrawParam002, TestSize.Level1) { RSSurfaceRenderNodeConfig config; std::shared_ptr node = std::make_shared(config); - + node->InitRenderParams(); auto param = RSDividedRenderUtil::CreateBufferDrawParam(*node, false, true); ASSERT_EQ(nullptr, param.buffer); 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 7fc2439214..4b0025fd60 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 @@ -73,6 +73,7 @@ void RSHardwareThreadTest::SetUpTestCase() EXPECT_CALL(*hdiDeviceMock_, PrepareScreenLayers(_, _)).WillRepeatedly(testing::Return(0)); EXPECT_CALL(*hdiDeviceMock_, GetScreenCompChange(_, _, _)).WillRepeatedly(testing::Return(0)); EXPECT_CALL(*hdiDeviceMock_, Commit(_, _)).WillRepeatedly(testing::Return(0)); + RSTestUtil::InitRenderNodeGC(); } void RSHardwareThreadTest::TearDownTestCase() {} void RSHardwareThreadTest::TearDown() diff --git a/rosen/test/render_service/render_service/unittest/pipeline/rs_render_service_listener_test.cpp b/rosen/test/render_service/render_service/unittest/pipeline/rs_render_service_listener_test.cpp index 1d1fde5802..0adccc9a29 100755 --- a/rosen/test/render_service/render_service/unittest/pipeline/rs_render_service_listener_test.cpp +++ b/rosen/test/render_service/render_service/unittest/pipeline/rs_render_service_listener_test.cpp @@ -33,7 +33,10 @@ public: void TearDown() override; }; -void RSRenderServiceListenerTest::SetUpTestCase() {} +void RSRenderServiceListenerTest::SetUpTestCase() +{ + RSTestUtil::InitRenderNodeGC(); +} void RSRenderServiceListenerTest::TearDownTestCase() {} void RSRenderServiceListenerTest::SetUp() {} void RSRenderServiceListenerTest::TearDown() {} diff --git a/rosen/test/render_service/render_service/unittest/pipeline/rs_render_service_visitor_test.cpp b/rosen/test/render_service/render_service/unittest/pipeline/rs_render_service_visitor_test.cpp index 28aac29384..51840100ca 100644 --- a/rosen/test/render_service/render_service/unittest/pipeline/rs_render_service_visitor_test.cpp +++ b/rosen/test/render_service/render_service/unittest/pipeline/rs_render_service_visitor_test.cpp @@ -42,7 +42,10 @@ public: void TearDown() override; }; -void RSRenderServiceVisitorTest::SetUpTestCase() {} +void RSRenderServiceVisitorTest::SetUpTestCase() +{ + RSTestUtil::InitRenderNodeGC(); +} void RSRenderServiceVisitorTest::TearDownTestCase() {} void RSRenderServiceVisitorTest::SetUp() { diff --git a/rosen/test/render_service/render_service/unittest/pipeline/rs_surface_capture_task_test.cpp b/rosen/test/render_service/render_service/unittest/pipeline/rs_surface_capture_task_test.cpp index 9d8cd75e4a..6aaf1c084f 100644 --- a/rosen/test/render_service/render_service/unittest/pipeline/rs_surface_capture_task_test.cpp +++ b/rosen/test/render_service/render_service/unittest/pipeline/rs_surface_capture_task_test.cpp @@ -36,6 +36,7 @@ #include "platform/common/rs_system_properties.h" using namespace testing::ext; +using namespace OHOS::Rosen::DrawableV2; namespace OHOS { namespace Rosen { @@ -142,6 +143,7 @@ void RSSurfaceCaptureTaskTest::TearDown() void RSSurfaceCaptureTaskTest::SetUpTestCase() { + RSTestUtil::InitRenderNodeGC(); rsInterfaces_ = &(RSInterfaces::GetInstance()); if (rsInterfaces_ == nullptr) { HiLog::Error(LOG_LABEL, "%s: rsInterfaces_ == nullptr", __func__); @@ -1024,10 +1026,10 @@ HWTEST_F(RSSurfaceCaptureTaskTest, ProcessDisplayRenderNode004, Function | Small visitor_->hasSecurityOrSkipOrProtectedLayer_ = true; NodeId id = 1; RSDisplayNodeConfig config; - RSDisplayRenderNode node(id, config); + auto node = std::make_shared(id, config); sptr consumer = IConsumerSurface::Create("test"); auto displayDrawable = - std::static_pointer_cast(node.GetRenderDrawable()); + static_cast(RSDisplayRenderNodeDrawable::OnGenerate(node)); ASSERT_NE(nullptr, displayDrawable); auto surfaceHandler = displayDrawable->GetMutableRSSurfaceHandlerOnDraw(); surfaceHandler->SetConsumer(consumer); @@ -1036,7 +1038,7 @@ HWTEST_F(RSSurfaceCaptureTaskTest, ProcessDisplayRenderNode004, Function | Small Rect damage; sptr buffer = new SurfaceBufferImpl(0); surfaceHandler->SetBuffer(buffer, acquireFence, damage, timestamp); - visitor_->ProcessDisplayRenderNode(node); + visitor_->ProcessDisplayRenderNode(*node); visitor_->hasSecurityOrSkipOrProtectedLayer_ = hasSecurityOrSkipOrProtectedLayer; } diff --git a/rosen/test/render_service/render_service/unittest/pipeline/rs_uni_render_util_test.cpp b/rosen/test/render_service/render_service/unittest/pipeline/rs_uni_render_util_test.cpp index 7bee8d6eec..064431e2cd 100644 --- a/rosen/test/render_service/render_service/unittest/pipeline/rs_uni_render_util_test.cpp +++ b/rosen/test/render_service/render_service/unittest/pipeline/rs_uni_render_util_test.cpp @@ -26,6 +26,7 @@ using namespace testing; using namespace testing::ext; +using namespace OHOS::Rosen::DrawableV2; namespace OHOS::Rosen { class RSUniRenderUtilTest : public testing::Test { @@ -759,17 +760,21 @@ HWTEST_F(RSUniRenderUtilTest, MergeVisibleDirtyRegionTest, Function | SmallTest { std::vector allSurfaceDrawawble; std::vector hasVisibleDirtyRegionSurfaceVec; - NodeId id = 0; - std::shared_ptr nodeNull = nullptr; - auto rsRenderNode = std::make_shared(id); - auto node = std::make_shared(id); - rsRenderNode->renderDrawable_ = std::make_shared(node); - rsRenderNode->renderDrawable_->renderParams_ = std::make_unique(id); + NodeId id = 1; + auto surfaceNode = std::make_shared(id); + auto drawable = RSSurfaceRenderNodeDrawable::OnGenerate(surfaceNode); + ASSERT_NE(drawable, nullptr); + drawable->renderParams_ = std::make_unique(id); + auto surfaceDrawable = + std::shared_ptr(static_cast(drawable)); + ASSERT_NE(surfaceDrawable, nullptr); + surfaceDrawable->syncDirtyManager_ = std::make_shared(); + allSurfaceDrawawble.emplace_back(nullptr); - allSurfaceDrawawble.emplace_back(rsRenderNode->renderDrawable_); + allSurfaceDrawawble.emplace_back(surfaceDrawable); RSUniRenderUtil::MergeVisibleDirtyRegion(allSurfaceDrawawble, hasVisibleDirtyRegionSurfaceVec, false); RSUniRenderUtil::MergeVisibleDirtyRegion(allSurfaceDrawawble, hasVisibleDirtyRegionSurfaceVec, true); - EXPECT_TRUE(rsRenderNode->renderDrawable_->renderParams_); + EXPECT_TRUE(surfaceDrawable->renderParams_); } /** @@ -782,15 +787,24 @@ HWTEST_F(RSUniRenderUtilTest, MergeVisibleDirtyRegionTest001, Function | SmallTe { std::vector allSurfaceNodeDrawables; std::vector hasVisibleDirtyRegionSurfaceVec; - auto node = std::make_shared(0); - auto drawable = std::make_shared(node); - auto param = std::make_unique(node->id_); + + NodeId id = 1; + auto surfaceNode = std::make_shared(id); + auto drawable = RSSurfaceRenderNodeDrawable::OnGenerate(surfaceNode); + ASSERT_NE(drawable, nullptr); + auto param = std::make_unique(id); + ASSERT_NE(param, nullptr); param->isMainWindowType_ = false; param->isLeashWindow_ = false; param->isAppWindow_ = true; drawable->renderParams_ = std::move(param); + + auto surfaceDrawable = + std::shared_ptr(static_cast(drawable)); + ASSERT_NE(surfaceDrawable, nullptr); + surfaceDrawable->syncDirtyManager_ = std::make_shared(); allSurfaceNodeDrawables.push_back(nullptr); - allSurfaceNodeDrawables.push_back(drawable); + allSurfaceNodeDrawables.push_back(surfaceDrawable); RSUniRenderUtil::MergeVisibleDirtyRegion(allSurfaceNodeDrawables, hasVisibleDirtyRegionSurfaceVec, false); RSUniRenderUtil::MergeVisibleDirtyRegion(allSurfaceNodeDrawables, hasVisibleDirtyRegionSurfaceVec, true); ASSERT_TRUE(drawable->renderParams_); @@ -806,9 +820,15 @@ HWTEST_F(RSUniRenderUtilTest, MergeVisibleDirtyRegionTest002, Function | SmallTe { std::vector allSurfaceNodeDrawables; std::vector hasVisibleDirtyRegionSurfaceVec; - auto node = std::make_shared(0); - auto drawable = std::make_shared(node); - allSurfaceNodeDrawables.push_back(drawable); + NodeId id = 1; + auto surfaceNode = std::make_shared(id); + auto drawable = RSSurfaceRenderNodeDrawable::OnGenerate(surfaceNode); + ASSERT_NE(drawable, nullptr); + auto surfaceDrawable = + std::shared_ptr(static_cast(drawable)); + ASSERT_NE(surfaceDrawable, nullptr); + surfaceDrawable->syncDirtyManager_ = std::make_shared(); + allSurfaceNodeDrawables.push_back(surfaceDrawable); RSUniRenderUtil::MergeVisibleDirtyRegion(allSurfaceNodeDrawables, hasVisibleDirtyRegionSurfaceVec, false); RSUniRenderUtil::MergeVisibleDirtyRegion(allSurfaceNodeDrawables, hasVisibleDirtyRegionSurfaceVec, true); ASSERT_FALSE(drawable->renderParams_); @@ -824,14 +844,23 @@ HWTEST_F(RSUniRenderUtilTest, MergeVisibleDirtyRegionTest003, Function | SmallTe { std::vector allSurfaceNodeDrawables; std::vector hasVisibleDirtyRegionSurfaceVec; - auto node = std::make_shared(0); - auto drawable = std::make_shared(node); - auto param = std::make_unique(node->id_); + NodeId id = 1; + auto surfaceNode = std::make_shared(id); + auto drawable = RSSurfaceRenderNodeDrawable::OnGenerate(surfaceNode); + ASSERT_NE(drawable, nullptr); + auto param = std::make_unique(id); + ASSERT_NE(param, nullptr); param->isMainWindowType_ = false; param->isLeashWindow_ = false; param->isAppWindow_ = false; drawable->renderParams_ = std::move(param); - allSurfaceNodeDrawables.push_back(drawable); + + auto surfaceDrawable = + std::shared_ptr(static_cast(drawable)); + ASSERT_NE(surfaceDrawable, nullptr); + surfaceDrawable->syncDirtyManager_ = std::make_shared(); + allSurfaceNodeDrawables.push_back(surfaceDrawable); + RSUniRenderUtil::MergeVisibleDirtyRegion(allSurfaceNodeDrawables, hasVisibleDirtyRegionSurfaceVec, false); RSUniRenderUtil::MergeVisibleDirtyRegion(allSurfaceNodeDrawables, hasVisibleDirtyRegionSurfaceVec, true); ASSERT_TRUE(drawable->renderParams_); diff --git a/rosen/test/render_service/render_service/unittest/pipeline/rs_uni_render_virtual_processor_test.cpp b/rosen/test/render_service/render_service/unittest/pipeline/rs_uni_render_virtual_processor_test.cpp index 9f0134f56a..e59278137f 100644 --- a/rosen/test/render_service/render_service/unittest/pipeline/rs_uni_render_virtual_processor_test.cpp +++ b/rosen/test/render_service/render_service/unittest/pipeline/rs_uni_render_virtual_processor_test.cpp @@ -27,6 +27,7 @@ using namespace testing; using namespace testing::ext; +using namespace OHOS::Rosen::DrawableV2; namespace { constexpr uint32_t DEFAULT_CANVAS_WIDTH = 800; @@ -253,16 +254,18 @@ HWTEST_F(RSUniRenderVirtualProcessorTest, ProcessDisplaySurfaceTest, TestSize.Le { RSDisplayNodeConfig config; NodeId id = 0; - RSDisplayRenderNode rsDisplayRenderNode(id, config); + auto rsDisplayRenderNode = std::make_shared(id, config); + ASSERT_NE(rsDisplayRenderNode, nullptr); auto processor = std::make_shared(); - processor->ProcessDisplaySurface(rsDisplayRenderNode); + ASSERT_NE(processor, nullptr); + processor->ProcessDisplaySurface(*rsDisplayRenderNode); Drawing::Canvas canvas; processor->canvas_ = std::make_unique(&canvas); auto displayDrawable = - std::static_pointer_cast(rsDisplayRenderNode.GetRenderDrawable()); + static_cast(RSDisplayRenderNodeDrawable::OnGenerate(rsDisplayRenderNode)); auto surfaceHandler = displayDrawable->GetRSSurfaceHandlerOnDraw(); surfaceHandler->buffer_.buffer = OHOS::SurfaceBuffer::Create(); - processor->ProcessDisplaySurface(rsDisplayRenderNode); + processor->ProcessDisplaySurface(*rsDisplayRenderNode); EXPECT_FALSE(processor->forceCPU_); } } // namespace OHOS::Rosen diff --git a/rosen/test/render_service/render_service/unittest/pipeline/rs_uni_ui_capture_test.cpp b/rosen/test/render_service/render_service/unittest/pipeline/rs_uni_ui_capture_test.cpp index 965e4ea45d..a4e6d780ac 100644 --- a/rosen/test/render_service/render_service/unittest/pipeline/rs_uni_ui_capture_test.cpp +++ b/rosen/test/render_service/render_service/unittest/pipeline/rs_uni_ui_capture_test.cpp @@ -20,6 +20,8 @@ #include "common/rs_singleton.h" #include "limit_number.h" +#include "rs_test_util.h" + using namespace testing; using namespace testing::ext; @@ -32,7 +34,10 @@ public: void TearDown() override; }; -void RSUniUiCaptureTest::SetUpTestCase() {} +void RSUniUiCaptureTest::SetUpTestCase() +{ + RSTestUtil::InitRenderNodeGC(); +} void RSUniUiCaptureTest::TearDownTestCase() {} void RSUniUiCaptureTest::SetUp() {} void RSUniUiCaptureTest::TearDown() {} From 116031fc46ebe3b483167791f80a2ea7c90b5895 Mon Sep 17 00:00:00 2001 From: chengshichang Date: Thu, 1 Aug 2024 10:52:30 +0800 Subject: [PATCH 44/74] Signed-off-by: csc --- rosen/modules/composer/vsync/BUILD.gn | 1 + .../vsync/include/vsync_connection_stub.h | 3 ++ .../vsync/src/vsync_connection_proxy.cpp | 2 -- .../vsync/src/vsync_connection_stub.cpp | 29 +++++++++++++++---- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/rosen/modules/composer/vsync/BUILD.gn b/rosen/modules/composer/vsync/BUILD.gn index 8aad6d4718..518c91810b 100644 --- a/rosen/modules/composer/vsync/BUILD.gn +++ b/rosen/modules/composer/vsync/BUILD.gn @@ -95,6 +95,7 @@ ohos_shared_library("libvsync") { ] external_deps = [ + "access_token:libaccesstoken_sdk", "c_utils:utils", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/rosen/modules/composer/vsync/include/vsync_connection_stub.h b/rosen/modules/composer/vsync/include/vsync_connection_stub.h index cf4e513c24..35af3cc969 100644 --- a/rosen/modules/composer/vsync/include/vsync_connection_stub.h +++ b/rosen/modules/composer/vsync/include/vsync_connection_stub.h @@ -28,6 +28,9 @@ class VSyncConnectionStub : public IRemoteStub { public: virtual int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; + +private: + bool CheckCallingPermission(); }; } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/composer/vsync/src/vsync_connection_proxy.cpp b/rosen/modules/composer/vsync/src/vsync_connection_proxy.cpp index 8a396cb389..279fc032c2 100644 --- a/rosen/modules/composer/vsync/src/vsync_connection_proxy.cpp +++ b/rosen/modules/composer/vsync/src/vsync_connection_proxy.cpp @@ -36,8 +36,6 @@ VsyncError VSyncConnectionProxy::RequestNextVSync(const std::string& fromWhom, i MessageParcel ret; arg.WriteInterfaceToken(GetDescriptor()); - arg.WriteString(fromWhom); - arg.WriteInt64(lastVSyncTS); int res = Remote()->SendRequest(IVSYNC_CONNECTION_REQUEST_NEXT_VSYNC, arg, ret, opt); if (res != NO_ERROR) { VLOGE("ipc send fail, error:%{public}d", res); diff --git a/rosen/modules/composer/vsync/src/vsync_connection_stub.cpp b/rosen/modules/composer/vsync/src/vsync_connection_stub.cpp index a89c73e877..d24ebab9db 100644 --- a/rosen/modules/composer/vsync/src/vsync_connection_stub.cpp +++ b/rosen/modules/composer/vsync/src/vsync_connection_stub.cpp @@ -16,9 +16,16 @@ #include "vsync_connection_stub.h" #include #include "graphic_common.h" +#include "accesstoken_kit.h" +#include "ipc_skeleton.h" +#include "vsync_log.h" namespace OHOS { namespace Rosen { +namespace { + const std::string RSS_PROCESS_NAME = "resource_schedule_service"; +} + int32_t VSyncConnectionStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { @@ -29,9 +36,7 @@ int32_t VSyncConnectionStub::OnRemoteRequest(uint32_t code, MessageParcel &data, switch (code) { case IVSYNC_CONNECTION_REQUEST_NEXT_VSYNC: { - auto fromWho = data.ReadString(); - auto ts = data.ReadInt64(); - RequestNextVSync(fromWho, ts); + RequestNextVSync(); break; } case IVSYNC_CONNECTION_GET_RECEIVE_FD: { @@ -61,10 +66,10 @@ int32_t VSyncConnectionStub::OnRemoteRequest(uint32_t code, MessageParcel &data, return SetUiDvsyncSwitch(dvsyncOn); } case IVSYNC_CONNECTION_SET_UI_DVSYNC_CONFIG: { - int32_t bufferCount; - if (!data.ReadInt32(bufferCount)) { - return VSYNC_ERROR_API_FAILED; + if (!CheckCallingPermission()) { + return VSYNC_ERROR_UNKOWN; } + int32_t bufferCount = data.ReadInt32(); return SetUiDvsyncConfig(bufferCount); } default: { @@ -74,5 +79,17 @@ int32_t VSyncConnectionStub::OnRemoteRequest(uint32_t code, MessageParcel &data, } return 0; } + +bool VSyncConnectionStub::CheckCallingPermission() +{ + Security::AccessToken::AccessTokenID tokenId = OHOS::IPCSkeleton::GetCallingTokenID(); + Security::AccessToken::AccessTokenID rssToken = + Security::AccessToken::AccessTokenKit::GetNativeTokenId(RSS_PROCESS_NAME); + if (tokenId != rssToken) { + VLOGE("CheckPermissionFailed, calling process illegal"); + return false; + } + return true; +} } // namespace Rosen } // namespace OHOS From a8a3c9e569c180278dbb4e40b61a699db94a9fca Mon Sep 17 00:00:00 2001 From: HengmingWang Date: Thu, 1 Aug 2024 10:24:08 +0800 Subject: [PATCH 45/74] fix codecheck Signed-off-by: HengmingWang --- .../drawing_ndk/src/drawing_text_blob.cpp | 4 ++++ .../engine_adapter/skia_adapter/skia_image.cpp | 17 ++++++++++++++--- .../skia_adapter/skia_image_info.h | 3 ++- .../skia_runtime_blender_builder.cpp | 10 +++++++--- .../skia_runtime_shader_builder.cpp | 11 +++++++---- .../skia_adapter/skia_text_blob.cpp | 5 ++++- .../src/pipeline/rs_draw_cmd.cpp | 5 +++++ .../src/platform/ohos/rs_marshalling_helper.cpp | 1 + .../2d_graphics/drawing_sample_replayer.cpp | 4 +++- 9 files changed, 47 insertions(+), 13 deletions(-) diff --git a/rosen/modules/2d_graphics/drawing_ndk/src/drawing_text_blob.cpp b/rosen/modules/2d_graphics/drawing_ndk/src/drawing_text_blob.cpp index 15301b5335..02ee52f858 100644 --- a/rosen/modules/2d_graphics/drawing_ndk/src/drawing_text_blob.cpp +++ b/rosen/modules/2d_graphics/drawing_ndk/src/drawing_text_blob.cpp @@ -157,6 +157,10 @@ void OH_Drawing_TextBlobGetBounds(OH_Drawing_TextBlob* cTextBlob, OH_Drawing_Rec return; } std::shared_ptr rect = textblob->Bounds(); + if (rect == nullptr) { + g_drawingErrorCode = OH_DRAWING_ERROR_INVALID_PARAMETER; + return; + } *outRect = Rect(rect->GetLeft(), rect->GetTop(), rect->GetRight(), rect->GetBottom()); } diff --git a/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_image.cpp b/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_image.cpp index 206664ed06..1631fc664e 100644 --- a/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_image.cpp +++ b/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_image.cpp @@ -170,7 +170,16 @@ bool SkiaImage::BuildSubset(const std::shared_ptr image, const RectI& rec LOGD("SkiaImage::BuildSubset failed, origin Image is invalid"); return false; } - auto skiaImage = image->GetImpl()->GetImage(); + auto imageImpl = image->GetImpl(); + if (imageImpl == nullptr) { + LOGD("SkiaImage::BuildSubset failed, GetImpl failed"); + return false; + } + auto skiaImage = imageImpl->GetImage(); + if (skiaImage == nullptr) { + LOGD("SkiaImage::BuildSubset failed, GetImage failed"); + return false; + } auto skiaRect = SkIRect::MakeLTRB(rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetBottom()); grContext_ = gpuContext.GetImpl()->GetGrContext(); PostSkImgToTargetThread(); @@ -215,7 +224,8 @@ bool SkiaImage::BuildFromTexture(GPUContext& gpuContext, const TextureInfo& info sk_sp skColorSpace = nullptr; if (colorSpace != nullptr) { - skColorSpace = colorSpace->GetImpl()->GetColorSpace(); + auto colorSpaceImpl = colorSpace->GetImpl(); + skColorSpace = colorSpaceImpl ? colorSpaceImpl->GetColorSpace() : SkColorSpace::MakeSRGB(); } else { skColorSpace = SkColorSpace::MakeSRGB(); } @@ -274,7 +284,8 @@ bool SkiaImage::BuildFromSurface(GPUContext& gpuContext, Surface& surface, Textu sk_sp skColorSpace = nullptr; if (colorSpace != nullptr) { - skColorSpace = colorSpace->GetImpl()->GetColorSpace(); + auto colorSpaceImpl = colorSpace->GetImpl(); + skColorSpace = colorSpaceImpl ? colorSpaceImpl->GetColorSpace() : nullptr; } PostSkImgToTargetThread(); skiaImage_ = SkImage::MakeFromTexture(grContext_.get(), grBackendTexture, diff --git a/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_image_info.h b/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_image_info.h index a87b23108f..c55a8ed2f4 100644 --- a/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_image_info.h +++ b/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_image_info.h @@ -90,10 +90,11 @@ public: static SkImageInfo ConvertToSkImageInfo(const ImageInfo& imageInfo) { auto colorSpace = imageInfo.GetColorSpace(); + auto colorSpaceImpl = colorSpace ? colorSpace->GetImpl() : nullptr; return SkImageInfo::Make(imageInfo.GetWidth(), imageInfo.GetHeight(), ConvertToSkColorType(imageInfo.GetColorType()), ConvertToSkAlphaType(imageInfo.GetAlphaType()), - colorSpace ? colorSpace->GetImpl()->GetColorSpace() : nullptr); + colorSpaceImpl ? colorSpaceImpl->GetColorSpace() : nullptr); } static ColorType ConvertToColorType(const SkColorType& format) diff --git a/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_runtime_blender_builder.cpp b/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_runtime_blender_builder.cpp index 1c3bea2831..2c9377dcbe 100644 --- a/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_runtime_blender_builder.cpp +++ b/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_runtime_blender_builder.cpp @@ -21,9 +21,13 @@ namespace OHOS { namespace Rosen { namespace Drawing { -SkiaRuntimeBlenderBuilder::SkiaRuntimeBlenderBuilder( - std::shared_ptr effect) noexcept : skRuntimeBlendBuilder_(std::make_shared( - effect->GetImpl()->GetRuntimeEffect())) {} +SkiaRuntimeBlenderBuilder::SkiaRuntimeBlenderBuilder(std::shared_ptr effect) noexcept +{ + auto effectImpl = effect ? effect->GetImpl() : nullptr; + if (effectImpl != nullptr) { + skRuntimeBlendBuilder_ = std::make_shared(effectImpl->GetRuntimeEffect()); + } +} std::shared_ptr SkiaRuntimeBlenderBuilder::MakeBlender() { diff --git a/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_runtime_shader_builder.cpp b/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_runtime_shader_builder.cpp index 896a8f5699..538aab882c 100644 --- a/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_runtime_shader_builder.cpp +++ b/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_runtime_shader_builder.cpp @@ -30,10 +30,13 @@ namespace OHOS { namespace Rosen { namespace Drawing { - -SkiaRuntimeShaderBuilder::SkiaRuntimeShaderBuilder( - std::shared_ptr effect) noexcept : skRuntimeShaderBuilder_(std::make_shared( - effect->GetImpl()->GetRuntimeEffect())) {} +SkiaRuntimeShaderBuilder::SkiaRuntimeShaderBuilder(std::shared_ptr effect) noexcept +{ + auto effectImpl = effect ? effect->GetImpl() : nullptr; + if (effectImpl != nullptr) { + skRuntimeShaderBuilder_ = std::make_shared(effectImpl->GetRuntimeEffect()); + } +} std::shared_ptr SkiaRuntimeShaderBuilder::MakeShader(const Matrix* localMatrix, bool isOpaque) { diff --git a/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_text_blob.cpp b/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_text_blob.cpp index 22eac72c9c..66a9d7020a 100644 --- a/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_text_blob.cpp +++ b/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_text_blob.cpp @@ -198,7 +198,10 @@ Path SkiaTextBlob::GetDrawingPathforTextBlob(uint16_t glyphId, const TextBlob* b { SkTextBlob* skTextBlob = nullptr; if (blob) { - skTextBlob = blob->GetImpl()->GetTextBlob().get(); + auto skiaBlobImpl = blob->GetImpl(); + if (skiaBlobImpl != nullptr) { + skTextBlob = skiaBlobImpl->GetTextBlob().get(); + } } SkPath skPath = GetPathforTextBlob(glyphId, skTextBlob); Path path; diff --git a/rosen/modules/render_service_base/src/pipeline/rs_draw_cmd.cpp b/rosen/modules/render_service_base/src/pipeline/rs_draw_cmd.cpp index d3be3fd75b..ae45080508 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_draw_cmd.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_draw_cmd.cpp @@ -324,6 +324,11 @@ bool RSExtendImageObject::MakeFromTextureForVK(Drawing::Canvas& canvas, SurfaceB } tid_ = gettid(); } + + if (!canvas.GetGPUContext()) { + RS_LOGE("MakeFromTextureForVK gpu context is nullptr"); + return false; + } image_ = std::make_shared(); auto vkTextureInfo = backendTexture_.GetTextureInfo().GetVKTextureInfo(); Drawing::ColorType colorType = GetColorTypeFromVKFormat(vkTextureInfo->format); 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 08d2f4598d..f42c2d7ef7 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 @@ -392,6 +392,7 @@ bool RSMarshallingHelper::ReadColorSpaceFromParcel(Parcel& parcel, std::shared_p } if (isMal) { free(const_cast(dataPtr)); + dataPtr = nullptr; } } return true; diff --git a/rosen/samples/2d_graphics/drawing_sample_replayer.cpp b/rosen/samples/2d_graphics/drawing_sample_replayer.cpp index 4f6063c9be..32835d34ea 100644 --- a/rosen/samples/2d_graphics/drawing_sample_replayer.cpp +++ b/rosen/samples/2d_graphics/drawing_sample_replayer.cpp @@ -34,7 +34,9 @@ namespace OHOS::Rosen { DrawingSampleReplayer::~DrawingSampleReplayer() { DestoryNativeWindow(nativeWindow_); - surfaceNode_->DetachToDisplay(DEFAULT_DISPLAY_ID); + if (surfaceNode_) { + surfaceNode_->DetachToDisplay(DEFAULT_DISPLAY_ID); + } } bool DrawingSampleReplayer::ReadCmds(const std::string path) From 7093f5bf9b9569e3611581a927d1b1948ab26368 Mon Sep 17 00:00:00 2001 From: huangkai Date: Thu, 1 Aug 2024 11:54:53 +0800 Subject: [PATCH 46/74] =?UTF-8?q?drawble=E7=A8=B3=E5=AE=9A=E6=80=A7?= =?UTF-8?q?=E6=95=B4=E6=94=B9=EF=BC=9A=E7=9B=B4=E9=80=9A=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E6=88=AA=E5=9B=BEhwc=E8=8A=82=E7=82=B9buffer=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangkai --- .../rs_display_render_node_drawable.cpp | 3 -- .../rs_surface_render_node_drawable.cpp | 9 +--- .../core/pipeline/rs_main_thread.cpp | 51 +++++++++++++++++++ .../core/pipeline/rs_main_thread.h | 3 ++ .../rs_surface_capture_task_parallel.cpp | 39 +++----------- 5 files changed, 62 insertions(+), 43 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 bcb0908510..9226c45f96 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 @@ -471,9 +471,6 @@ void RSDisplayRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) } auto mirrorDrawable = params->GetMirrorSourceDrawable().lock(); - if (!mirrorDrawable && GetCacheImgForCapture()) { - SetCacheImgForCapture(nullptr); - } auto mirrorParams = mirrorDrawable ? mirrorDrawable->GetRenderParams().get() : nullptr; if (mirrorParams || params->GetCompositeType() == RSDisplayRenderNode::CompositeType::UNI_RENDER_EXPAND_COMPOSITE) { auto renderEngine = RSUniRenderThread::Instance().GetRenderEngine(); 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 39dbfd2b54..482f31182d 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 @@ -713,14 +713,7 @@ void RSSurfaceRenderNodeDrawable::DealWithSelfDrawingNodeBuffer( RSAutoCanvasRestore arc(&canvas); surfaceParams.SetGlobalAlpha(1.0f); pid_t threadId = gettid(); - bool useRenderParams = !RSUniRenderThread::GetCaptureParam().isSnapshot_; - // will not use node in future version - auto nodeSp = std::const_pointer_cast(renderNode_.lock()); - if (!nodeSp) { - return; - } - auto surfaceNode = std::static_pointer_cast(nodeSp); - auto params = RSUniRenderUtil::CreateBufferDrawParam(*surfaceNode, false, threadId, useRenderParams); + auto params = RSUniRenderUtil::CreateBufferDrawParam(*this, false, threadId); params.targetColorGamut = GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB; #ifdef USE_VIDEO_PROCESSING_ENGINE params.screenBrightnessNits = GetDisplayNit(); 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 f502b66f19..03c0c83955 100644 --- a/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp @@ -3578,6 +3578,57 @@ void RSMainThread::ResetHardwareEnabledState(bool isUniRender) } } +bool RSMainThread::IsHardwareEnabledNodesNeedSync() +{ + if (!doDirectComposition_) { + return false; + } + + bool needSync = false; + for (const auto& node : hardwareEnabledNodes_) { + if (node == nullptr || node->IsHardwareForcedDisabled()) { + continue; + } + needSync = true; + } + RS_TRACE_NAME_FMT("%s %u", __func__, needSync); + RS_LOGD("%{public}s %{public}u", __func__, needSync); + + return needSync; +} + +bool RSMainThread::IsOcclusionNodesNeedSync(NodeId id) +{ + auto nodePtr = RSBaseRenderNode::ReinterpretCast( + GetContext().GetNodeMap().GetRenderNode(id)); + if (nodePtr == nullptr) { + return false; + } + + bool needSync = false; + if (nodePtr->IsLeashWindow()) { + auto children = nodePtr->GetSortedChildren(); + for (auto child : *children) { + auto childSurfaceNode = RSBaseRenderNode::ReinterpretCast(child); + if (childSurfaceNode && childSurfaceNode->IsMainWindowType() && + childSurfaceNode->GetVisibleRegion().IsEmpty()) { + childSurfaceNode->PrepareSelfNodeForApplyModifiers(); + needSync = true; + } + } + } else if (nodePtr->IsMainWindowType() && nodePtr->GetVisibleRegion().IsEmpty()) { + auto curNode = nodePtr; + auto parentNode = RSBaseRenderNode::ReinterpretCast(nodePtr->GetParent().lock()); + if (parentNode && parentNode->IsLeashWindow()) { + curNode = parentNode; + } + nodePtr->PrepareSelfNodeForApplyModifiers(); + needSync = true; + } + + return needSync; +} + void RSMainThread::ShowWatermark(const std::shared_ptr &watermarkImg, bool flag) { std::lock_guard lock(watermarkMutex_); 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 77ee422171..ab060747f9 100644 --- a/rosen/modules/render_service/core/pipeline/rs_main_thread.h +++ b/rosen/modules/render_service/core/pipeline/rs_main_thread.h @@ -342,6 +342,9 @@ public: return isFirstFrameOfPartialRender_; } + bool IsHardwareEnabledNodesNeedSync(); + bool IsOcclusionNodesNeedSync(NodeId id); + void CallbackDrawContextStatusToWMS(bool isUniRender = false); void SetHardwareTaskNum(uint32_t num); void RegisterUIExtensionCallback(pid_t pid, uint64_t userId, sptr callback); diff --git a/rosen/modules/render_service/core/pipeline/rs_surface_capture_task_parallel.cpp b/rosen/modules/render_service/core/pipeline/rs_surface_capture_task_parallel.cpp index 4d8c419f83..60bc74a84e 100644 --- a/rosen/modules/render_service/core/pipeline/rs_surface_capture_task_parallel.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_surface_capture_task_parallel.cpp @@ -64,44 +64,19 @@ static inline void DrawCapturedImg(Drawing::Image& image, void RSSurfaceCaptureTaskParallel::CheckModifiers(NodeId id) { RS_TRACE_NAME("RSSurfaceCaptureTaskParallel::CheckModifiers"); - auto nodePtr = RSBaseRenderNode::ReinterpretCast( - RSMainThread::Instance()->GetContext().GetNodeMap().GetRenderNode(id)); - if (nodePtr == nullptr) { - return; - } - - bool needSync = false; - if (nodePtr->IsLeashWindow() && nodePtr->GetLastFrameUifirstFlag() == MultiThreadCacheType::NONE) { - auto children = nodePtr->GetSortedChildren(); - for (auto child : *children) { - auto childSurfaceNode = RSBaseRenderNode::ReinterpretCast(child); - if (childSurfaceNode && childSurfaceNode->IsMainWindowType() && - childSurfaceNode->GetVisibleRegion().IsEmpty()) { - childSurfaceNode->ApplyModifiers(); - childSurfaceNode->PrepareChildrenForApplyModifiers(); - needSync = true; - } - } - } else if (nodePtr->IsMainWindowType() && nodePtr->GetVisibleRegion().IsEmpty()) { - auto curNode = nodePtr; - auto parentNode = RSBaseRenderNode::ReinterpretCast(nodePtr->GetParent().lock()); - if (parentNode && parentNode->IsLeashWindow()) { - curNode = parentNode; - } - if (curNode->GetLastFrameUifirstFlag() == MultiThreadCacheType::NONE) { - nodePtr->ApplyModifiers(); - nodePtr->PrepareChildrenForApplyModifiers(); - needSync = true; - } - } - + bool needSync = RSMainThread::Instance()->IsOcclusionNodesNeedSync(id) || + RSMainThread::Instance()->IsHardwareEnabledNodesNeedSync(); if (needSync) { std::function syncTask = []() -> void { RS_TRACE_NAME("RSSurfaceCaptureTaskParallel::SyncModifiers"); auto& pendingSyncNodes = RSMainThread::Instance()->GetContext().pendingSyncNodes_; for (auto& [id, weakPtr] : pendingSyncNodes) { if (auto node = weakPtr.lock()) { - node->Sync(); + if (!RSUifirstManager::Instance().CollectSkipSyncNode(node)) { + node->Sync(); + } else { + node->SkipSync(); + } } } pendingSyncNodes.clear(); From 0486e58af2529eae22811462b9e18efcb7a0c349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E6=B5=B7?= Date: Thu, 1 Aug 2024 12:04:35 +0800 Subject: [PATCH 47/74] graphictest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王德海 Change-Id: I3731560dcf13d45529ac33ca82affd74bcfac06a --- {rosen/graphic_test => graphic_test}/BUILD.gn | 0 .../graphic_test}/BUILD.gn | 29 ++++++++++++++----- .../drawing_engine/2d_engine/demo.cpp | 0 .../drawing_engine/3d_engine/demo.cpp | 0 .../drawing_engine/drawing/demo.cpp | 0 .../drawing_engine/opengl/demo.cpp | 0 .../drawing_engine/vulkan/demo.cpp | 0 .../hardware_display/demo.cpp | 0 .../hardware_manager/screen_manager/demo.cpp | 0 .../open_capability/font_engine/demo.cpp | 0 .../open_capability/pixmap/demo.cpp | 0 .../open_capability/symbol/demo.cpp | 0 .../rs_display_effect/animation/demo.cpp | 0 .../content_display/demo.cpp | 0 .../property_display/demo.cpp | 0 .../render_base_library/demo.cpp | 0 .../rs_framework/divided_render/demo.cpp | 0 .../divided_render_composer/demo.cpp | 0 .../rs_framework/divided_render_ui/demo.cpp | 0 .../rs_framework/performance/demo.cpp | 0 .../rs_framework/render_arithmetic/demo.cpp | 0 .../rs_framework/uni_render/demo.cpp | 0 .../rs_framework/uni_render_ui/demo.cpp | 0 .../rs_func_feature/accessibility/demo.cpp | 0 .../camera_rotation_feature/demo.cpp | 0 .../color_space_and_hdr/demo.cpp | 0 .../component_capture/demo.cpp | 0 .../rs_func_feature/g2_corner/demo.cpp | 0 .../rs_func_feature/layer_render/demo.cpp | 0 .../rs_func_feature/multi_screen/demo.cpp | 0 .../rs_func_feature/round_corner/demo.cpp | 0 .../rs_func_feature/screen_capture/demo.cpp | 0 .../screen_security_watermark/demo.cpp | 0 .../sec_layer_and_drm/demo.cpp | 0 .../rs_perform_feature/blur_cache/demo.cpp | 0 .../rs_perform_feature/dirty_region/demo.cpp | 0 .../rs_perform_feature/dvsync/demo.cpp | 0 .../rs_perform_feature/hwc/demo.cpp | 0 .../hwc_prevalidate/demo.cpp | 0 .../rs_perform_feature/ltpo/demo.cpp | 0 .../offscreen_rotate/demo.cpp | 0 .../rs_perform_feature/opinc/demo.cpp | 0 .../rs_perform_feature/render_group/demo.cpp | 0 .../single_frame_composer/demo.cpp | 0 .../rs_perform_feature/ui_first/demo.cpp | 0 .../test_template/test_template.cpp | 1 + .../graphic_test_framework/BUILD.gn | 2 +- .../include/rs_graphic_log.h | 0 .../include/rs_graphic_rootnode.h | 0 .../include/rs_graphic_test.h | 2 ++ .../include/rs_graphic_test_director.h | 0 .../include/rs_graphic_test_ext.h | 0 .../include/rs_graphic_test_utils.h | 0 .../include/rs_parameter_parse.h | 0 .../src/rs_graphic_rootnode.cpp | 0 .../src/rs_graphic_test.cpp | 19 ++++++++++++ .../src/rs_graphic_test_director.cpp | 0 .../src/rs_graphic_test_ext.cpp | 0 .../src/rs_graphic_test_main.cpp | 0 .../src/rs_graphic_test_utils.cpp | 0 .../src/rs_parameter_parse.cpp | 0 rosen/graphic_test/graphic_test/BUILD.gn | 19 ------------ 62 files changed, 45 insertions(+), 27 deletions(-) rename {rosen/graphic_test => graphic_test}/BUILD.gn (100%) rename {rosen/graphic_test/graphic_test/test_template => graphic_test/graphic_test}/BUILD.gn (60%) create mode 100644 graphic_test/graphic_test/drawing_engine/2d_engine/demo.cpp create mode 100644 graphic_test/graphic_test/drawing_engine/3d_engine/demo.cpp create mode 100644 graphic_test/graphic_test/drawing_engine/drawing/demo.cpp create mode 100644 graphic_test/graphic_test/drawing_engine/opengl/demo.cpp create mode 100644 graphic_test/graphic_test/drawing_engine/vulkan/demo.cpp create mode 100644 graphic_test/graphic_test/hardware_manager/hardware_display/demo.cpp create mode 100644 graphic_test/graphic_test/hardware_manager/screen_manager/demo.cpp create mode 100644 graphic_test/graphic_test/open_capability/font_engine/demo.cpp create mode 100644 graphic_test/graphic_test/open_capability/pixmap/demo.cpp create mode 100644 graphic_test/graphic_test/open_capability/symbol/demo.cpp create mode 100644 graphic_test/graphic_test/rs_display_effect/animation/demo.cpp create mode 100644 graphic_test/graphic_test/rs_display_effect/content_display/demo.cpp create mode 100644 graphic_test/graphic_test/rs_display_effect/property_display/demo.cpp create mode 100644 graphic_test/graphic_test/rs_display_effect/render_base_library/demo.cpp create mode 100644 graphic_test/graphic_test/rs_framework/divided_render/demo.cpp create mode 100644 graphic_test/graphic_test/rs_framework/divided_render_composer/demo.cpp create mode 100644 graphic_test/graphic_test/rs_framework/divided_render_ui/demo.cpp create mode 100644 graphic_test/graphic_test/rs_framework/performance/demo.cpp create mode 100644 graphic_test/graphic_test/rs_framework/render_arithmetic/demo.cpp create mode 100644 graphic_test/graphic_test/rs_framework/uni_render/demo.cpp create mode 100644 graphic_test/graphic_test/rs_framework/uni_render_ui/demo.cpp create mode 100644 graphic_test/graphic_test/rs_func_feature/accessibility/demo.cpp create mode 100644 graphic_test/graphic_test/rs_func_feature/camera_rotation_feature/demo.cpp create mode 100644 graphic_test/graphic_test/rs_func_feature/color_space_and_hdr/demo.cpp create mode 100644 graphic_test/graphic_test/rs_func_feature/component_capture/demo.cpp create mode 100644 graphic_test/graphic_test/rs_func_feature/g2_corner/demo.cpp create mode 100644 graphic_test/graphic_test/rs_func_feature/layer_render/demo.cpp create mode 100644 graphic_test/graphic_test/rs_func_feature/multi_screen/demo.cpp create mode 100644 graphic_test/graphic_test/rs_func_feature/round_corner/demo.cpp create mode 100644 graphic_test/graphic_test/rs_func_feature/screen_capture/demo.cpp create mode 100644 graphic_test/graphic_test/rs_func_feature/screen_security_watermark/demo.cpp create mode 100644 graphic_test/graphic_test/rs_func_feature/sec_layer_and_drm/demo.cpp create mode 100644 graphic_test/graphic_test/rs_perform_feature/blur_cache/demo.cpp create mode 100644 graphic_test/graphic_test/rs_perform_feature/dirty_region/demo.cpp create mode 100644 graphic_test/graphic_test/rs_perform_feature/dvsync/demo.cpp create mode 100644 graphic_test/graphic_test/rs_perform_feature/hwc/demo.cpp create mode 100644 graphic_test/graphic_test/rs_perform_feature/hwc_prevalidate/demo.cpp create mode 100644 graphic_test/graphic_test/rs_perform_feature/ltpo/demo.cpp create mode 100644 graphic_test/graphic_test/rs_perform_feature/offscreen_rotate/demo.cpp create mode 100644 graphic_test/graphic_test/rs_perform_feature/opinc/demo.cpp create mode 100644 graphic_test/graphic_test/rs_perform_feature/render_group/demo.cpp create mode 100644 graphic_test/graphic_test/rs_perform_feature/single_frame_composer/demo.cpp create mode 100644 graphic_test/graphic_test/rs_perform_feature/ui_first/demo.cpp rename {rosen/graphic_test => graphic_test}/graphic_test/test_template/test_template.cpp (97%) rename {rosen/graphic_test => graphic_test}/graphic_test_framework/BUILD.gn (97%) rename {rosen/graphic_test => graphic_test}/graphic_test_framework/include/rs_graphic_log.h (100%) rename {rosen/graphic_test => graphic_test}/graphic_test_framework/include/rs_graphic_rootnode.h (100%) rename {rosen/graphic_test => graphic_test}/graphic_test_framework/include/rs_graphic_test.h (95%) rename {rosen/graphic_test => graphic_test}/graphic_test_framework/include/rs_graphic_test_director.h (100%) rename {rosen/graphic_test => graphic_test}/graphic_test_framework/include/rs_graphic_test_ext.h (100%) rename {rosen/graphic_test => graphic_test}/graphic_test_framework/include/rs_graphic_test_utils.h (100%) rename {rosen/graphic_test => graphic_test}/graphic_test_framework/include/rs_parameter_parse.h (100%) rename {rosen/graphic_test => graphic_test}/graphic_test_framework/src/rs_graphic_rootnode.cpp (100%) rename {rosen/graphic_test => graphic_test}/graphic_test_framework/src/rs_graphic_test.cpp (90%) rename {rosen/graphic_test => graphic_test}/graphic_test_framework/src/rs_graphic_test_director.cpp (100%) rename {rosen/graphic_test => graphic_test}/graphic_test_framework/src/rs_graphic_test_ext.cpp (100%) rename {rosen/graphic_test => graphic_test}/graphic_test_framework/src/rs_graphic_test_main.cpp (100%) rename {rosen/graphic_test => graphic_test}/graphic_test_framework/src/rs_graphic_test_utils.cpp (100%) rename {rosen/graphic_test => graphic_test}/graphic_test_framework/src/rs_parameter_parse.cpp (100%) delete mode 100644 rosen/graphic_test/graphic_test/BUILD.gn diff --git a/rosen/graphic_test/BUILD.gn b/graphic_test/BUILD.gn similarity index 100% rename from rosen/graphic_test/BUILD.gn rename to graphic_test/BUILD.gn diff --git a/rosen/graphic_test/graphic_test/test_template/BUILD.gn b/graphic_test/graphic_test/BUILD.gn similarity index 60% rename from rosen/graphic_test/graphic_test/test_template/BUILD.gn rename to graphic_test/graphic_test/BUILD.gn index 77c42f9092..8907fbbb2c 100644 --- a/rosen/graphic_test/graphic_test/test_template/BUILD.gn +++ b/graphic_test/graphic_test/BUILD.gn @@ -14,19 +14,34 @@ import("//build/test.gni") import("//foundation/graphic/graphic_2d/graphic_config.gni") -module_output_path = "graphic_2d/rosen/graphic_test/graphic_test" +module_output_path = "graphic_2d/graphic_test/graphic_test" -group("unittest") { +drawing_engine_sources = [] +hardware_manager_sources = [] +open_capability_sources = [] +rs_display_effect_sources = [] +rs_framework_sources = [] +rs_func_feature_sources = [] +rs_perform_feature_sources = [] + +group("test") { testonly = true - deps = [ ":RSGraphicTestTemplateTest" ] + deps = [ ":RSGraphicTest" ] } -## Build RSGraphicTestTemplateTest -ohos_unittest("RSGraphicTestTemplateTest") { +## Build RSGraphicTest +ohos_unittest("RSGraphicTest") { module_out_path = module_output_path - sources = [ "test_template.cpp" ] + sources = [] + sources += drawing_engine_sources + sources += hardware_manager_sources + sources += open_capability_sources + sources += rs_display_effect_sources + sources += rs_framework_sources + sources += rs_func_feature_sources + sources += rs_perform_feature_sources - deps = [ "$graphic_2d_root/rosen/graphic_test/graphic_test_framework:rs_graphic_test_main" ] + deps = [ "$graphic_2d_root/graphic_test/graphic_test_framework:rs_graphic_test_main" ] defines = [] external_deps = [ diff --git a/graphic_test/graphic_test/drawing_engine/2d_engine/demo.cpp b/graphic_test/graphic_test/drawing_engine/2d_engine/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/drawing_engine/3d_engine/demo.cpp b/graphic_test/graphic_test/drawing_engine/3d_engine/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/drawing_engine/drawing/demo.cpp b/graphic_test/graphic_test/drawing_engine/drawing/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/drawing_engine/opengl/demo.cpp b/graphic_test/graphic_test/drawing_engine/opengl/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/drawing_engine/vulkan/demo.cpp b/graphic_test/graphic_test/drawing_engine/vulkan/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/hardware_manager/hardware_display/demo.cpp b/graphic_test/graphic_test/hardware_manager/hardware_display/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/hardware_manager/screen_manager/demo.cpp b/graphic_test/graphic_test/hardware_manager/screen_manager/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/open_capability/font_engine/demo.cpp b/graphic_test/graphic_test/open_capability/font_engine/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/open_capability/pixmap/demo.cpp b/graphic_test/graphic_test/open_capability/pixmap/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/open_capability/symbol/demo.cpp b/graphic_test/graphic_test/open_capability/symbol/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_display_effect/animation/demo.cpp b/graphic_test/graphic_test/rs_display_effect/animation/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_display_effect/content_display/demo.cpp b/graphic_test/graphic_test/rs_display_effect/content_display/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/demo.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_display_effect/render_base_library/demo.cpp b/graphic_test/graphic_test/rs_display_effect/render_base_library/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_framework/divided_render/demo.cpp b/graphic_test/graphic_test/rs_framework/divided_render/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_framework/divided_render_composer/demo.cpp b/graphic_test/graphic_test/rs_framework/divided_render_composer/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_framework/divided_render_ui/demo.cpp b/graphic_test/graphic_test/rs_framework/divided_render_ui/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_framework/performance/demo.cpp b/graphic_test/graphic_test/rs_framework/performance/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_framework/render_arithmetic/demo.cpp b/graphic_test/graphic_test/rs_framework/render_arithmetic/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_framework/uni_render/demo.cpp b/graphic_test/graphic_test/rs_framework/uni_render/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_framework/uni_render_ui/demo.cpp b/graphic_test/graphic_test/rs_framework/uni_render_ui/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_func_feature/accessibility/demo.cpp b/graphic_test/graphic_test/rs_func_feature/accessibility/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_func_feature/camera_rotation_feature/demo.cpp b/graphic_test/graphic_test/rs_func_feature/camera_rotation_feature/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_func_feature/color_space_and_hdr/demo.cpp b/graphic_test/graphic_test/rs_func_feature/color_space_and_hdr/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_func_feature/component_capture/demo.cpp b/graphic_test/graphic_test/rs_func_feature/component_capture/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_func_feature/g2_corner/demo.cpp b/graphic_test/graphic_test/rs_func_feature/g2_corner/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_func_feature/layer_render/demo.cpp b/graphic_test/graphic_test/rs_func_feature/layer_render/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_func_feature/multi_screen/demo.cpp b/graphic_test/graphic_test/rs_func_feature/multi_screen/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_func_feature/round_corner/demo.cpp b/graphic_test/graphic_test/rs_func_feature/round_corner/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_func_feature/screen_capture/demo.cpp b/graphic_test/graphic_test/rs_func_feature/screen_capture/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_func_feature/screen_security_watermark/demo.cpp b/graphic_test/graphic_test/rs_func_feature/screen_security_watermark/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_func_feature/sec_layer_and_drm/demo.cpp b/graphic_test/graphic_test/rs_func_feature/sec_layer_and_drm/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_perform_feature/blur_cache/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/blur_cache/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_perform_feature/dirty_region/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/dirty_region/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_perform_feature/dvsync/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/dvsync/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_perform_feature/hwc/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/hwc/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_perform_feature/hwc_prevalidate/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/hwc_prevalidate/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_perform_feature/ltpo/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/ltpo/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_perform_feature/offscreen_rotate/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/offscreen_rotate/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_perform_feature/opinc/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/opinc/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_perform_feature/render_group/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/render_group/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_perform_feature/single_frame_composer/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/single_frame_composer/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graphic_test/graphic_test/rs_perform_feature/ui_first/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/ui_first/demo.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/rosen/graphic_test/graphic_test/test_template/test_template.cpp b/graphic_test/graphic_test/test_template/test_template.cpp similarity index 97% rename from rosen/graphic_test/graphic_test/test_template/test_template.cpp rename to graphic_test/graphic_test/test_template/test_template.cpp index 12a59f38c2..38b6676527 100644 --- a/rosen/graphic_test/graphic_test/test_template/test_template.cpp +++ b/graphic_test/graphic_test/test_template/test_template.cpp @@ -27,6 +27,7 @@ public: auto size = GetScreenSize(); SetSurfaceBounds({0, 0, size.x_ / 2.0f, size.y_ / 2.0f}); SetSurfaceColor(RSColor(0xffff0000)); + SetImageSavePath("/data/local/graphic_test/test_template/"); } // called after each tests diff --git a/rosen/graphic_test/graphic_test_framework/BUILD.gn b/graphic_test/graphic_test_framework/BUILD.gn similarity index 97% rename from rosen/graphic_test/graphic_test_framework/BUILD.gn rename to graphic_test/graphic_test_framework/BUILD.gn index 7102d22cde..4a6a215135 100644 --- a/rosen/graphic_test/graphic_test_framework/BUILD.gn +++ b/graphic_test/graphic_test_framework/BUILD.gn @@ -13,7 +13,7 @@ import("//build/test.gni") import("//foundation/graphic/graphic_2d/graphic_config.gni") -import("../../modules/render_service_base/config.gni") +import("${graphic_2d_root}/rosen/modules/render_service_base/config.gni") config("rs_graphic_test_config") { include_dirs = [ diff --git a/rosen/graphic_test/graphic_test_framework/include/rs_graphic_log.h b/graphic_test/graphic_test_framework/include/rs_graphic_log.h similarity index 100% rename from rosen/graphic_test/graphic_test_framework/include/rs_graphic_log.h rename to graphic_test/graphic_test_framework/include/rs_graphic_log.h diff --git a/rosen/graphic_test/graphic_test_framework/include/rs_graphic_rootnode.h b/graphic_test/graphic_test_framework/include/rs_graphic_rootnode.h similarity index 100% rename from rosen/graphic_test/graphic_test_framework/include/rs_graphic_rootnode.h rename to graphic_test/graphic_test_framework/include/rs_graphic_rootnode.h diff --git a/rosen/graphic_test/graphic_test_framework/include/rs_graphic_test.h b/graphic_test/graphic_test_framework/include/rs_graphic_test.h similarity index 95% rename from rosen/graphic_test/graphic_test_framework/include/rs_graphic_test.h rename to graphic_test/graphic_test_framework/include/rs_graphic_test.h index 8807f2206f..179e5cac58 100644 --- a/rosen/graphic_test/graphic_test_framework/include/rs_graphic_test.h +++ b/graphic_test/graphic_test_framework/include/rs_graphic_test.h @@ -33,6 +33,7 @@ public: void SetSurfaceBounds(const Vector4f& bounds); void SetSurfaceColor(const RSColor& color); void RegisterNode(std::shared_ptr node); + void SetImageSavePath(const std::string path); // overrides gtest functions static void SetUpTestCase(); @@ -49,6 +50,7 @@ private: Vector4f surfaceBounds_; std::vector> nodes_; static uint32_t imageWriteId_; + std::string imageSavePath_ = ""; }; } // namespace Rosen } // namespace OHOS diff --git a/rosen/graphic_test/graphic_test_framework/include/rs_graphic_test_director.h b/graphic_test/graphic_test_framework/include/rs_graphic_test_director.h similarity index 100% rename from rosen/graphic_test/graphic_test_framework/include/rs_graphic_test_director.h rename to graphic_test/graphic_test_framework/include/rs_graphic_test_director.h diff --git a/rosen/graphic_test/graphic_test_framework/include/rs_graphic_test_ext.h b/graphic_test/graphic_test_framework/include/rs_graphic_test_ext.h similarity index 100% rename from rosen/graphic_test/graphic_test_framework/include/rs_graphic_test_ext.h rename to graphic_test/graphic_test_framework/include/rs_graphic_test_ext.h diff --git a/rosen/graphic_test/graphic_test_framework/include/rs_graphic_test_utils.h b/graphic_test/graphic_test_framework/include/rs_graphic_test_utils.h similarity index 100% rename from rosen/graphic_test/graphic_test_framework/include/rs_graphic_test_utils.h rename to graphic_test/graphic_test_framework/include/rs_graphic_test_utils.h diff --git a/rosen/graphic_test/graphic_test_framework/include/rs_parameter_parse.h b/graphic_test/graphic_test_framework/include/rs_parameter_parse.h similarity index 100% rename from rosen/graphic_test/graphic_test_framework/include/rs_parameter_parse.h rename to graphic_test/graphic_test_framework/include/rs_parameter_parse.h diff --git a/rosen/graphic_test/graphic_test_framework/src/rs_graphic_rootnode.cpp b/graphic_test/graphic_test_framework/src/rs_graphic_rootnode.cpp similarity index 100% rename from rosen/graphic_test/graphic_test_framework/src/rs_graphic_rootnode.cpp rename to graphic_test/graphic_test_framework/src/rs_graphic_rootnode.cpp diff --git a/rosen/graphic_test/graphic_test_framework/src/rs_graphic_test.cpp b/graphic_test/graphic_test_framework/src/rs_graphic_test.cpp similarity index 90% rename from rosen/graphic_test/graphic_test_framework/src/rs_graphic_test.cpp rename to graphic_test/graphic_test_framework/src/rs_graphic_test.cpp index 73197a7763..8eee238580 100644 --- a/rosen/graphic_test/graphic_test_framework/src/rs_graphic_test.cpp +++ b/graphic_test/graphic_test_framework/src/rs_graphic_test.cpp @@ -112,6 +112,9 @@ void RSGraphicTest::TearDown() RSParameterParse::Instance().surfaceCaptureWaitTime); if (pixelMap) { std::string filename = RSParameterParse::Instance().imageSavePath; + if (imageSavePath_ != "") { + filename = imageSavePath_; + } filename += testInfo->test_case_name() + std::string("_"); filename += testInfo->name() + std::string(".png"); if (std::filesystem::exists(filename)) { @@ -158,5 +161,21 @@ void RSGraphicTest::SetSurfaceColor(const RSColor& color) RSGraphicTestDirector::Instance().SetSurfaceColor(color); } +void RSGraphicTest::SetImageSavePath(const std::string path) +{ + namespace fs = std::filesystem; + if (!fs::exists(path)) { + if (!fs::create_directories(path)) { + LOGE("RSGraphicTestDirector create dir failed"); + } + } else { + if (!fs::is_directory(path)) { + LOGE("RSGraphicTestDirector path is not dir"); + return; + } + } + imageSavePath_ = path; +} + } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/rosen/graphic_test/graphic_test_framework/src/rs_graphic_test_director.cpp b/graphic_test/graphic_test_framework/src/rs_graphic_test_director.cpp similarity index 100% rename from rosen/graphic_test/graphic_test_framework/src/rs_graphic_test_director.cpp rename to graphic_test/graphic_test_framework/src/rs_graphic_test_director.cpp diff --git a/rosen/graphic_test/graphic_test_framework/src/rs_graphic_test_ext.cpp b/graphic_test/graphic_test_framework/src/rs_graphic_test_ext.cpp similarity index 100% rename from rosen/graphic_test/graphic_test_framework/src/rs_graphic_test_ext.cpp rename to graphic_test/graphic_test_framework/src/rs_graphic_test_ext.cpp diff --git a/rosen/graphic_test/graphic_test_framework/src/rs_graphic_test_main.cpp b/graphic_test/graphic_test_framework/src/rs_graphic_test_main.cpp similarity index 100% rename from rosen/graphic_test/graphic_test_framework/src/rs_graphic_test_main.cpp rename to graphic_test/graphic_test_framework/src/rs_graphic_test_main.cpp diff --git a/rosen/graphic_test/graphic_test_framework/src/rs_graphic_test_utils.cpp b/graphic_test/graphic_test_framework/src/rs_graphic_test_utils.cpp similarity index 100% rename from rosen/graphic_test/graphic_test_framework/src/rs_graphic_test_utils.cpp rename to graphic_test/graphic_test_framework/src/rs_graphic_test_utils.cpp diff --git a/rosen/graphic_test/graphic_test_framework/src/rs_parameter_parse.cpp b/graphic_test/graphic_test_framework/src/rs_parameter_parse.cpp similarity index 100% rename from rosen/graphic_test/graphic_test_framework/src/rs_parameter_parse.cpp rename to graphic_test/graphic_test_framework/src/rs_parameter_parse.cpp diff --git a/rosen/graphic_test/graphic_test/BUILD.gn b/rosen/graphic_test/graphic_test/BUILD.gn deleted file mode 100644 index 34c47a95b5..0000000000 --- a/rosen/graphic_test/graphic_test/BUILD.gn +++ /dev/null @@ -1,19 +0,0 @@ -# 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("//foundation/graphic/graphic_2d/graphic_config.gni") - -group("test") { - testonly = true - deps = [] -} From 421c8de1090c8f7183367b9a951649ed49985628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E6=B5=B7?= Date: Thu, 1 Aug 2024 12:09:27 +0800 Subject: [PATCH 48/74] x MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王德海 Change-Id: I38a0417f89a0d18306fffdbaf942df7bda77ae6b --- BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD.gn b/BUILD.gn index 7e6c617a5d..5228d87f6d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -34,7 +34,7 @@ group("graphic_common_test") { "frameworks/bootanimation/test:test", "frameworks/opengl_wrapper/test:test", "frameworks/vulkan_layers/test:test", - "rosen/graphic_test:test", + "graphic_test:test", "rosen/modules/composer:test", "rosen/modules/create_pixelmap_surface:test", "rosen/modules/effect/test/unittest:test", From 4959be3d48cfaab86a1279926bfce30607c64b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E6=B5=B7?= Date: Thu, 1 Aug 2024 14:14:34 +0800 Subject: [PATCH 49/74] q MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王德海 Change-Id: I22559fde28e339354756efdd9e5aeaf3527b2619 --- .../graphic_test/drawing_engine/2d_engine/demo.cpp | 14 ++++++++++++++ .../graphic_test/drawing_engine/3d_engine/demo.cpp | 14 ++++++++++++++ .../graphic_test/drawing_engine/drawing/demo.cpp | 14 ++++++++++++++ .../graphic_test/drawing_engine/opengl/demo.cpp | 14 ++++++++++++++ .../graphic_test/drawing_engine/vulkan/demo.cpp | 14 ++++++++++++++ .../hardware_manager/hardware_display/demo.cpp | 14 ++++++++++++++ .../hardware_manager/screen_manager/demo.cpp | 14 ++++++++++++++ .../open_capability/font_engine/demo.cpp | 14 ++++++++++++++ .../graphic_test/open_capability/pixmap/demo.cpp | 14 ++++++++++++++ .../graphic_test/open_capability/symbol/demo.cpp | 14 ++++++++++++++ .../rs_display_effect/animation/demo.cpp | 14 ++++++++++++++ .../rs_display_effect/content_display/demo.cpp | 14 ++++++++++++++ .../rs_display_effect/property_display/demo.cpp | 14 ++++++++++++++ .../rs_display_effect/render_base_library/demo.cpp | 14 ++++++++++++++ .../rs_framework/divided_render/demo.cpp | 14 ++++++++++++++ .../rs_framework/divided_render_composer/demo.cpp | 14 ++++++++++++++ .../rs_framework/divided_render_ui/demo.cpp | 14 ++++++++++++++ .../graphic_test/rs_framework/performance/demo.cpp | 14 ++++++++++++++ .../rs_framework/render_arithmetic/demo.cpp | 14 ++++++++++++++ .../graphic_test/rs_framework/uni_render/demo.cpp | 14 ++++++++++++++ .../rs_framework/uni_render_ui/demo.cpp | 14 ++++++++++++++ .../rs_func_feature/accessibility/demo.cpp | 14 ++++++++++++++ .../camera_rotation_feature/demo.cpp | 14 ++++++++++++++ .../rs_func_feature/color_space_and_hdr/demo.cpp | 14 ++++++++++++++ .../rs_func_feature/component_capture/demo.cpp | 14 ++++++++++++++ .../rs_func_feature/g2_corner/demo.cpp | 14 ++++++++++++++ .../rs_func_feature/layer_render/demo.cpp | 14 ++++++++++++++ .../rs_func_feature/multi_screen/demo.cpp | 14 ++++++++++++++ .../rs_func_feature/round_corner/demo.cpp | 14 ++++++++++++++ .../rs_func_feature/screen_capture/demo.cpp | 14 ++++++++++++++ .../screen_security_watermark/demo.cpp | 14 ++++++++++++++ .../rs_func_feature/sec_layer_and_drm/demo.cpp | 14 ++++++++++++++ .../rs_perform_feature/blur_cache/demo.cpp | 14 ++++++++++++++ .../rs_perform_feature/dirty_region/demo.cpp | 14 ++++++++++++++ .../rs_perform_feature/dvsync/demo.cpp | 14 ++++++++++++++ .../graphic_test/rs_perform_feature/hwc/demo.cpp | 14 ++++++++++++++ .../rs_perform_feature/hwc_prevalidate/demo.cpp | 14 ++++++++++++++ .../graphic_test/rs_perform_feature/ltpo/demo.cpp | 14 ++++++++++++++ .../rs_perform_feature/offscreen_rotate/demo.cpp | 14 ++++++++++++++ .../graphic_test/rs_perform_feature/opinc/demo.cpp | 14 ++++++++++++++ .../rs_perform_feature/render_group/demo.cpp | 14 ++++++++++++++ .../single_frame_composer/demo.cpp | 14 ++++++++++++++ .../rs_perform_feature/ui_first/demo.cpp | 14 ++++++++++++++ 43 files changed, 602 insertions(+) diff --git a/graphic_test/graphic_test/drawing_engine/2d_engine/demo.cpp b/graphic_test/graphic_test/drawing_engine/2d_engine/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/drawing_engine/2d_engine/demo.cpp +++ b/graphic_test/graphic_test/drawing_engine/2d_engine/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/drawing_engine/3d_engine/demo.cpp b/graphic_test/graphic_test/drawing_engine/3d_engine/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/drawing_engine/3d_engine/demo.cpp +++ b/graphic_test/graphic_test/drawing_engine/3d_engine/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/drawing_engine/drawing/demo.cpp b/graphic_test/graphic_test/drawing_engine/drawing/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/drawing_engine/drawing/demo.cpp +++ b/graphic_test/graphic_test/drawing_engine/drawing/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/drawing_engine/opengl/demo.cpp b/graphic_test/graphic_test/drawing_engine/opengl/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/drawing_engine/opengl/demo.cpp +++ b/graphic_test/graphic_test/drawing_engine/opengl/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/drawing_engine/vulkan/demo.cpp b/graphic_test/graphic_test/drawing_engine/vulkan/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/drawing_engine/vulkan/demo.cpp +++ b/graphic_test/graphic_test/drawing_engine/vulkan/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/hardware_manager/hardware_display/demo.cpp b/graphic_test/graphic_test/hardware_manager/hardware_display/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/hardware_manager/hardware_display/demo.cpp +++ b/graphic_test/graphic_test/hardware_manager/hardware_display/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/hardware_manager/screen_manager/demo.cpp b/graphic_test/graphic_test/hardware_manager/screen_manager/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/hardware_manager/screen_manager/demo.cpp +++ b/graphic_test/graphic_test/hardware_manager/screen_manager/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/open_capability/font_engine/demo.cpp b/graphic_test/graphic_test/open_capability/font_engine/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/open_capability/font_engine/demo.cpp +++ b/graphic_test/graphic_test/open_capability/font_engine/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/open_capability/pixmap/demo.cpp b/graphic_test/graphic_test/open_capability/pixmap/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/open_capability/pixmap/demo.cpp +++ b/graphic_test/graphic_test/open_capability/pixmap/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/open_capability/symbol/demo.cpp b/graphic_test/graphic_test/open_capability/symbol/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/open_capability/symbol/demo.cpp +++ b/graphic_test/graphic_test/open_capability/symbol/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_display_effect/animation/demo.cpp b/graphic_test/graphic_test/rs_display_effect/animation/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_display_effect/animation/demo.cpp +++ b/graphic_test/graphic_test/rs_display_effect/animation/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_display_effect/content_display/demo.cpp b/graphic_test/graphic_test/rs_display_effect/content_display/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_display_effect/content_display/demo.cpp +++ b/graphic_test/graphic_test/rs_display_effect/content_display/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/demo.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_display_effect/property_display/demo.cpp +++ b/graphic_test/graphic_test/rs_display_effect/property_display/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_display_effect/render_base_library/demo.cpp b/graphic_test/graphic_test/rs_display_effect/render_base_library/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_display_effect/render_base_library/demo.cpp +++ b/graphic_test/graphic_test/rs_display_effect/render_base_library/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_framework/divided_render/demo.cpp b/graphic_test/graphic_test/rs_framework/divided_render/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_framework/divided_render/demo.cpp +++ b/graphic_test/graphic_test/rs_framework/divided_render/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_framework/divided_render_composer/demo.cpp b/graphic_test/graphic_test/rs_framework/divided_render_composer/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_framework/divided_render_composer/demo.cpp +++ b/graphic_test/graphic_test/rs_framework/divided_render_composer/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_framework/divided_render_ui/demo.cpp b/graphic_test/graphic_test/rs_framework/divided_render_ui/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_framework/divided_render_ui/demo.cpp +++ b/graphic_test/graphic_test/rs_framework/divided_render_ui/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_framework/performance/demo.cpp b/graphic_test/graphic_test/rs_framework/performance/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_framework/performance/demo.cpp +++ b/graphic_test/graphic_test/rs_framework/performance/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_framework/render_arithmetic/demo.cpp b/graphic_test/graphic_test/rs_framework/render_arithmetic/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_framework/render_arithmetic/demo.cpp +++ b/graphic_test/graphic_test/rs_framework/render_arithmetic/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_framework/uni_render/demo.cpp b/graphic_test/graphic_test/rs_framework/uni_render/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_framework/uni_render/demo.cpp +++ b/graphic_test/graphic_test/rs_framework/uni_render/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_framework/uni_render_ui/demo.cpp b/graphic_test/graphic_test/rs_framework/uni_render_ui/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_framework/uni_render_ui/demo.cpp +++ b/graphic_test/graphic_test/rs_framework/uni_render_ui/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_func_feature/accessibility/demo.cpp b/graphic_test/graphic_test/rs_func_feature/accessibility/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_func_feature/accessibility/demo.cpp +++ b/graphic_test/graphic_test/rs_func_feature/accessibility/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_func_feature/camera_rotation_feature/demo.cpp b/graphic_test/graphic_test/rs_func_feature/camera_rotation_feature/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_func_feature/camera_rotation_feature/demo.cpp +++ b/graphic_test/graphic_test/rs_func_feature/camera_rotation_feature/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_func_feature/color_space_and_hdr/demo.cpp b/graphic_test/graphic_test/rs_func_feature/color_space_and_hdr/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_func_feature/color_space_and_hdr/demo.cpp +++ b/graphic_test/graphic_test/rs_func_feature/color_space_and_hdr/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_func_feature/component_capture/demo.cpp b/graphic_test/graphic_test/rs_func_feature/component_capture/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_func_feature/component_capture/demo.cpp +++ b/graphic_test/graphic_test/rs_func_feature/component_capture/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_func_feature/g2_corner/demo.cpp b/graphic_test/graphic_test/rs_func_feature/g2_corner/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_func_feature/g2_corner/demo.cpp +++ b/graphic_test/graphic_test/rs_func_feature/g2_corner/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_func_feature/layer_render/demo.cpp b/graphic_test/graphic_test/rs_func_feature/layer_render/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_func_feature/layer_render/demo.cpp +++ b/graphic_test/graphic_test/rs_func_feature/layer_render/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_func_feature/multi_screen/demo.cpp b/graphic_test/graphic_test/rs_func_feature/multi_screen/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_func_feature/multi_screen/demo.cpp +++ b/graphic_test/graphic_test/rs_func_feature/multi_screen/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_func_feature/round_corner/demo.cpp b/graphic_test/graphic_test/rs_func_feature/round_corner/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_func_feature/round_corner/demo.cpp +++ b/graphic_test/graphic_test/rs_func_feature/round_corner/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_func_feature/screen_capture/demo.cpp b/graphic_test/graphic_test/rs_func_feature/screen_capture/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_func_feature/screen_capture/demo.cpp +++ b/graphic_test/graphic_test/rs_func_feature/screen_capture/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_func_feature/screen_security_watermark/demo.cpp b/graphic_test/graphic_test/rs_func_feature/screen_security_watermark/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_func_feature/screen_security_watermark/demo.cpp +++ b/graphic_test/graphic_test/rs_func_feature/screen_security_watermark/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_func_feature/sec_layer_and_drm/demo.cpp b/graphic_test/graphic_test/rs_func_feature/sec_layer_and_drm/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_func_feature/sec_layer_and_drm/demo.cpp +++ b/graphic_test/graphic_test/rs_func_feature/sec_layer_and_drm/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_perform_feature/blur_cache/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/blur_cache/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_perform_feature/blur_cache/demo.cpp +++ b/graphic_test/graphic_test/rs_perform_feature/blur_cache/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_perform_feature/dirty_region/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/dirty_region/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_perform_feature/dirty_region/demo.cpp +++ b/graphic_test/graphic_test/rs_perform_feature/dirty_region/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_perform_feature/dvsync/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/dvsync/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_perform_feature/dvsync/demo.cpp +++ b/graphic_test/graphic_test/rs_perform_feature/dvsync/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_perform_feature/hwc/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/hwc/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_perform_feature/hwc/demo.cpp +++ b/graphic_test/graphic_test/rs_perform_feature/hwc/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_perform_feature/hwc_prevalidate/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/hwc_prevalidate/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_perform_feature/hwc_prevalidate/demo.cpp +++ b/graphic_test/graphic_test/rs_perform_feature/hwc_prevalidate/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_perform_feature/ltpo/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/ltpo/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_perform_feature/ltpo/demo.cpp +++ b/graphic_test/graphic_test/rs_perform_feature/ltpo/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_perform_feature/offscreen_rotate/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/offscreen_rotate/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_perform_feature/offscreen_rotate/demo.cpp +++ b/graphic_test/graphic_test/rs_perform_feature/offscreen_rotate/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_perform_feature/opinc/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/opinc/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_perform_feature/opinc/demo.cpp +++ b/graphic_test/graphic_test/rs_perform_feature/opinc/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_perform_feature/render_group/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/render_group/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_perform_feature/render_group/demo.cpp +++ b/graphic_test/graphic_test/rs_perform_feature/render_group/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_perform_feature/single_frame_composer/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/single_frame_composer/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_perform_feature/single_frame_composer/demo.cpp +++ b/graphic_test/graphic_test/rs_perform_feature/single_frame_composer/demo.cpp @@ -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. + */ diff --git a/graphic_test/graphic_test/rs_perform_feature/ui_first/demo.cpp b/graphic_test/graphic_test/rs_perform_feature/ui_first/demo.cpp index e69de29bb2..6a442c0efb 100644 --- a/graphic_test/graphic_test/rs_perform_feature/ui_first/demo.cpp +++ b/graphic_test/graphic_test/rs_perform_feature/ui_first/demo.cpp @@ -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. + */ From c789ae582dbf0ce7e0d2c3088c56375fad5472fb Mon Sep 17 00:00:00 2001 From: lw19901203 Date: Thu, 1 Aug 2024 14:18:06 +0800 Subject: [PATCH 50/74] add SingleCharacter interface TDD Signed-off-by: lw19901203 --- .../unittest/ndk/drawing_canvas_test.cpp | 25 +++++++++++++ .../unittest/ndk/drawing_font_test.cpp | 37 +++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/rosen/test/2d_graphics/unittest/ndk/drawing_canvas_test.cpp b/rosen/test/2d_graphics/unittest/ndk/drawing_canvas_test.cpp index fa6849fd45..6c45f1a185 100644 --- a/rosen/test/2d_graphics/unittest/ndk/drawing_canvas_test.cpp +++ b/rosen/test/2d_graphics/unittest/ndk/drawing_canvas_test.cpp @@ -1646,6 +1646,31 @@ HWTEST_F(NativeDrawingCanvasTest, NativeDrawingCanvasTest_FilterSetImageFilter04 OH_Drawing_FilterDestroy(filter); OH_Drawing_ImageFilterDestroy(imagefilter); } + +/* + * @tc.name: NativeDrawingCanvasTest_CanvasDrawSingleCharacter045 + * @tc.desc: test for OH_Drawing_CanvasDrawSingleCharacter. + * @tc.type: FUNC + * @tc.require: AR000GTO5R + */ +HWTEST_F(NativeDrawingCanvasTest, NativeDrawingCanvasTest_CanvasDrawSingleCharacter045, TestSize.Level1) +{ + const char* strOne = "a"; + const char* strTwo = "你好"; + OH_Drawing_Font *font = OH_Drawing_FontCreate(); + EXPECT_NE(font, nullptr); + float x = 0.f; + float y = 0.f; + EXPECT_EQ(OH_Drawing_CanvasDrawSingleCharacter(canvas_, strOne, font, x, y), OH_DRAWING_SUCCESS); + EXPECT_EQ(OH_Drawing_CanvasDrawSingleCharacter(canvas_, strTwo, font, x, y), OH_DRAWING_SUCCESS); + EXPECT_EQ(OH_Drawing_CanvasDrawSingleCharacter(nullptr, strOne, font, x, y), OH_DRAWING_ERROR_INVALID_PARAMETER); + EXPECT_EQ(OH_Drawing_CanvasDrawSingleCharacter(canvas_, nullptr, font, x, y), OH_DRAWING_ERROR_INVALID_PARAMETER); + EXPECT_EQ(OH_Drawing_CanvasDrawSingleCharacter(canvas_, strOne, nullptr, x, y), + OH_DRAWING_ERROR_INVALID_PARAMETER); + const char* strThree = ""; + EXPECT_EQ(OH_Drawing_CanvasDrawSingleCharacter(canvas_, strThree, font, x, y), OH_DRAWING_ERROR_INVALID_PARAMETER); + OH_Drawing_FontDestroy(font); +} } // namespace Drawing } // namespace Rosen } // namespace OHOS diff --git a/rosen/test/2d_graphics/unittest/ndk/drawing_font_test.cpp b/rosen/test/2d_graphics/unittest/ndk/drawing_font_test.cpp index 5c33446151..66c24a3504 100644 --- a/rosen/test/2d_graphics/unittest/ndk/drawing_font_test.cpp +++ b/rosen/test/2d_graphics/unittest/ndk/drawing_font_test.cpp @@ -379,6 +379,43 @@ HWTEST_F(NativeFontTest, NativeFontTest_FontMeasureText014, TestSize.Level1) OH_Drawing_FontDestroy(font); } + +/* + * @tc.name: NativeFontTest_FontMeasureSingleCharacter015 + * @tc.desc: test for OH_Drawing_FontMeasureSingleCharacter. + * @tc.type: FUNC + * @tc.require: AR000GTO5R + */ +HWTEST_F(NativeFontTest, NativeFontTest_FontMeasureSingleCharacter015, TestSize.Level1) +{ + OH_Drawing_Font* font = OH_Drawing_FontCreate(); + EXPECT_NE(font, nullptr); + OH_Drawing_FontSetTextSize(font, 50); // 50 means font text size + const char* strOne = "a"; + const char* strTwo = "你好"; + float textWidth = 0.f; + OH_Drawing_ErrorCode drawingErrorCode = OH_DRAWING_SUCCESS; + drawingErrorCode = OH_Drawing_FontMeasureSingleCharacter(nullptr, strOne, &textWidth); + EXPECT_EQ(drawingErrorCode, OH_DRAWING_ERROR_INVALID_PARAMETER); + EXPECT_EQ(textWidth, 0.f); + drawingErrorCode = OH_Drawing_FontMeasureSingleCharacter(font, nullptr, &textWidth); + EXPECT_EQ(drawingErrorCode, OH_DRAWING_ERROR_INVALID_PARAMETER); + EXPECT_EQ(textWidth, 0.f); + drawingErrorCode = OH_Drawing_FontMeasureSingleCharacter(font, strOne, nullptr); + EXPECT_EQ(drawingErrorCode, OH_DRAWING_ERROR_INVALID_PARAMETER); + EXPECT_EQ(textWidth, 0.f); + const char* strThree = ""; + drawingErrorCode = OH_Drawing_FontMeasureSingleCharacter(font, strThree, &textWidth); + EXPECT_EQ(drawingErrorCode, OH_DRAWING_ERROR_INVALID_PARAMETER); + EXPECT_EQ(textWidth, 0.f); + drawingErrorCode = OH_Drawing_FontMeasureSingleCharacter(font, strOne, &textWidth); + EXPECT_EQ(drawingErrorCode, OH_DRAWING_SUCCESS); + EXPECT_TRUE(textWidth > 0); + drawingErrorCode = OH_Drawing_FontMeasureSingleCharacter(font, strTwo, &textWidth); + EXPECT_EQ(drawingErrorCode, OH_DRAWING_SUCCESS); + EXPECT_TRUE(textWidth > 0); + OH_Drawing_FontDestroy(font); +} } // namespace Drawing } // namespace Rosen } // namespace OHOS \ No newline at end of file From 89af0ce559ef1dd576df11d477cc8004be8b526f Mon Sep 17 00:00:00 2001 From: sunshipan Date: Thu, 1 Aug 2024 14:50:35 +0800 Subject: [PATCH 51/74] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B7=B3=E5=B8=A7?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E9=BB=98=E8=AE=A4=E4=BF=9D=E7=95=99=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E7=9A=84=E7=B1=BB=E5=9E=8B=E4=B8=BA=E4=BF=9D=E7=95=99?= =?UTF-8?q?=E6=A8=A1=E7=B3=8A=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: sunshipan --- .../include/drawable/rs_property_drawable.h | 2 ++ .../src/drawable/rs_property_drawable.cpp | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/rosen/modules/render_service_base/include/drawable/rs_property_drawable.h b/rosen/modules/render_service_base/include/drawable/rs_property_drawable.h index 2c0c59e9c9..d007b4688d 100644 --- a/rosen/modules/render_service_base/include/drawable/rs_property_drawable.h +++ b/rosen/modules/render_service_base/include/drawable/rs_property_drawable.h @@ -163,6 +163,7 @@ protected: bool forceClearCacheForLastFrame_ = false; bool isAIBarInteractWithHWC_ = false; bool isEffectNode_ = false; + bool renderIsSkipFrame_ = false; // clear one of snapshot cache and filtered cache after drawing bool renderClearFilteredCacheAfterDrawing_ = false; @@ -178,6 +179,7 @@ protected: // force cache with cacheUpdateInterval_ bool isLargeArea_ = false; bool canSkipFrame_ = false; + bool isSkipFrame_ = false; RSFilter::FilterType filterType_ = RSFilter::NONE; int cacheUpdateInterval_ = 0; bool isFilterCacheValid_ = false; // catch status in current frame diff --git a/rosen/modules/render_service_base/src/drawable/rs_property_drawable.cpp b/rosen/modules/render_service_base/src/drawable/rs_property_drawable.cpp index 8db66e1ca4..1abe57103b 100644 --- a/rosen/modules/render_service_base/src/drawable/rs_property_drawable.cpp +++ b/rosen/modules/render_service_base/src/drawable/rs_property_drawable.cpp @@ -176,6 +176,7 @@ void RSFilterDrawable::OnSync() renderFilterHashChanged_ = filterHashChanged_; renderForceClearCacheForLastFrame_ = forceClearCacheForLastFrame_; renderIsEffectNode_ = isEffectNode_; + renderIsSkipFrame_ = isSkipFrame_; ClearFilterCache(); @@ -192,6 +193,7 @@ void RSFilterDrawable::OnSync() isLargeArea_ = false; isFilterCacheValid_ = false; isEffectNode_ = false; + isSkipFrame_ = false; needSync_ = false; } @@ -280,6 +282,8 @@ void RSFilterDrawable::ClearCacheIfNeeded() cacheUpdateInterval_ = 0; } + isSkipFrame_ = isLargeArea_ && canSkipFrame_; + // no valid cache if (lastCacheType_ == FilterCacheType::NONE) { UpdateFlags(FilterCacheType::NONE, false); @@ -384,7 +388,7 @@ void RSFilterDrawable::ClearFilterCache() } else { renderClearFilteredCacheAfterDrawing_ = false; // hold blur image } - if (renderIsEffectNode_) { renderClearFilteredCacheAfterDrawing_ = renderFilterHashChanged_; } + if (renderIsEffectNode_ || renderIsSkipFrame_) { renderClearFilteredCacheAfterDrawing_ = renderFilterHashChanged_; } lastCacheType_ = isOccluded_ ? cacheManager_->GetCachedType() : (renderClearFilteredCacheAfterDrawing_ ? FilterCacheType::SNAPSHOT : FilterCacheType::FILTERED_SNAPSHOT); RS_TRACE_NAME_FMT("RSFilterDrawable::ClearFilterCache nodeId[%llu], clearType:%d," From 7f324223934f93e67928792e3477ed86f5a7d8b9 Mon Sep 17 00:00:00 2001 From: qiaoning Date: Thu, 1 Aug 2024 15:10:49 +0800 Subject: [PATCH 52/74] =?UTF-8?q?=E9=80=82=E9=85=8Darkui-x?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qiaoning --- interfaces/kits/napi/graphic/drawing/BUILD.gn | 163 +++++++++++------- rosen/modules/2d_engine/rosen_text/BUILD.gn | 4 + .../modules/2d_graphics/include/image/image.h | 1 + .../2d_graphics/include/recording/cmd_list.h | 4 + .../include/recording/draw_cmd_list.h | 4 + .../skia_hm_symbol_config_ohos.cpp | 7 + .../skia_adapter/skia_static_factory.cpp | 4 + .../src/drawing/image/gpu_context.cpp | 4 +- .../src/render_context/render_context.h | 2 - .../platform/eventhandler/event_queue.h | 4 +- rosen/modules/render_frame_trace/BUILD.gn | 11 +- rosen/modules/render_service/BUILD.gn | 2 +- rosen/modules/render_service_base/BUILD.gn | 10 +- rosen/modules/render_service_base/config.gni | 4 + rosen/modules/render_service_client/BUILD.gn | 6 +- .../pipeline/rs_render_thread_visitor.cpp | 6 +- rosen/modules/texgine/BUILD.gn | 58 +++++-- rosen/modules/texgine/src/text_span.cpp | 8 + rosen/modules/texgine/src/typography_impl.cpp | 8 + rosen/modules/texgine/src/utils/logger.cpp | 4 +- rosen/test/frame_report/unittest/BUILD.gn | 2 +- utils/sandbox/BUILD.gn | 4 + utils/sandbox/sandbox_utils.cpp | 2 +- 23 files changed, 230 insertions(+), 92 deletions(-) diff --git a/interfaces/kits/napi/graphic/drawing/BUILD.gn b/interfaces/kits/napi/graphic/drawing/BUILD.gn index 525397ce2b..0d879a51df 100644 --- a/interfaces/kits/napi/graphic/drawing/BUILD.gn +++ b/interfaces/kits/napi/graphic/drawing/BUILD.gn @@ -57,71 +57,114 @@ ohos_shared_library("drawing_napi") { subsystem_name = "graphic" } -ohos_shared_library("drawing_napi_impl") { - sources = [ - "brush_napi/js_brush.cpp", - "canvas_napi/js_canvas.cpp", - "color_filter_napi/js_color_filter.cpp", - "enum_napi/js_enum.cpp", - "font_napi/js_font.cpp", - "font_napi/js_typeface.cpp", - "image_filter_napi/js_image_filter.cpp", - "js_common.cpp", - "js_drawing_init.cpp", - "js_drawing_utils.cpp", - "lattice_napi/js_lattice.cpp", - "mask_filter_napi/js_mask_filter.cpp", - "matrix_napi/js_matrix.cpp", - "path_effect_napi/js_path_effect.cpp", - "path_napi/js_path.cpp", - "pen_napi/js_pen.cpp", - "region_napi/js_region.cpp", - "roundRect_napi/js_roundrect.cpp", - "sampling_options_napi/js_sampling_options.cpp", - "shader_effect_napi/js_shader_effect.cpp", - "shadow_layer_napi/js_shadow_layer.cpp", - "text_blob_napi/js_text_blob.cpp", - ] - - defines = [] - configs = [ ":local_drawing_config" ] - public_configs = [ ":drawing_config" ] - - deps = [ - "../../../../../rosen/modules/2d_graphics:2d_graphics", - "../../../../../rosen/modules/render_service_base:librender_service_base", - ] - - external_deps = [ "napi:ace_napi" ] - - if (current_os == "ohos" || current_os == "ohos_ng") { - sanitize = { - boundary_sanitize = true - integer_overflow = true - ubsan = true - } - external_deps += [ - "hilog:libhilog", - "image_framework:image_native", - "init:libbegetutil", +if (is_arkui_x) { + ohos_source_set("drawing_napi_impl") { + sources = [ + "brush_napi/js_brush.cpp", + "canvas_napi/js_canvas.cpp", + "color_filter_napi/js_color_filter.cpp", + "enum_napi/js_enum.cpp", + "font_napi/js_font.cpp", + "font_napi/js_typeface.cpp", + "image_filter_napi/js_image_filter.cpp", + "js_common.cpp", + "js_drawing_init.cpp", + "js_drawing_utils.cpp", + "lattice_napi/js_lattice.cpp", + "mask_filter_napi/js_mask_filter.cpp", + "matrix_napi/js_matrix.cpp", + "path_effect_napi/js_path_effect.cpp", + "path_napi/js_path.cpp", + "pen_napi/js_pen.cpp", + "region_napi/js_region.cpp", + "roundRect_napi/js_roundrect.cpp", + "sampling_options_napi/js_sampling_options.cpp", + "shader_effect_napi/js_shader_effect.cpp", + "shadow_layer_napi/js_shadow_layer.cpp", + "text_blob_napi/js_text_blob.cpp", ] - deps += [ "../../../../../utils:libgraphic_utils" ] - defines += [ "ROSEN_OHOS" ] - cflags = [ "-fstack-protector-strong" ] - cflags_cc = [ - "-fstack-protector-strong", - "-std=c++17", + + defines = [] + configs = [ ":local_drawing_config" ] + public_configs = [ ":drawing_config" ] + + deps = [ + "../../../../../rosen/modules/2d_graphics:2d_graphics", + "../../../../../rosen/modules/render_service_base:librender_service_base_static", + "//foundation/arkui/napi:ace_napi", ] - } else { defines += [ "MODULE_DRAWING" ] cflags_cc = [ "-std=c++17" ] - } - if (current_os == "mingw") { - defines += [ "WINDOWS_PLATFORM" ] + part_name = "graphic_2d" + subsystem_name = "graphic" } +} else { + ohos_shared_library("drawing_napi_impl") { + sources = [ + "brush_napi/js_brush.cpp", + "canvas_napi/js_canvas.cpp", + "color_filter_napi/js_color_filter.cpp", + "enum_napi/js_enum.cpp", + "font_napi/js_font.cpp", + "font_napi/js_typeface.cpp", + "image_filter_napi/js_image_filter.cpp", + "js_common.cpp", + "js_drawing_init.cpp", + "js_drawing_utils.cpp", + "lattice_napi/js_lattice.cpp", + "mask_filter_napi/js_mask_filter.cpp", + "matrix_napi/js_matrix.cpp", + "path_effect_napi/js_path_effect.cpp", + "path_napi/js_path.cpp", + "pen_napi/js_pen.cpp", + "region_napi/js_region.cpp", + "roundRect_napi/js_roundrect.cpp", + "sampling_options_napi/js_sampling_options.cpp", + "shader_effect_napi/js_shader_effect.cpp", + "shadow_layer_napi/js_shadow_layer.cpp", + "text_blob_napi/js_text_blob.cpp", + ] + defines = [] + configs = [ ":local_drawing_config" ] + public_configs = [ ":drawing_config" ] - innerapi_tags = [ "platformsdk" ] - part_name = "graphic_2d" - subsystem_name = "graphic" + deps = [ + "../../../../../rosen/modules/2d_graphics:2d_graphics", + "../../../../../rosen/modules/render_service_base:librender_service_base", + ] + + external_deps = [ "napi:ace_napi" ] + + if (current_os == "ohos" || current_os == "ohos_ng") { + sanitize = { + boundary_sanitize = true + integer_overflow = true + ubsan = true + } + external_deps += [ + "hilog:libhilog", + "image_framework:image_native", + "init:libbegetutil", + ] + deps += [ "../../../../../utils:libgraphic_utils" ] + defines += [ "ROSEN_OHOS" ] + cflags = [ "-fstack-protector-strong" ] + cflags_cc = [ + "-fstack-protector-strong", + "-std=c++17", + ] + } else { + defines += [ "MODULE_DRAWING" ] + cflags_cc = [ "-std=c++17" ] + } + + if (current_os == "mingw") { + defines += [ "WINDOWS_PLATFORM" ] + } + + innerapi_tags = [ "platformsdk" ] + part_name = "graphic_2d" + subsystem_name = "graphic" + } } diff --git a/rosen/modules/2d_engine/rosen_text/BUILD.gn b/rosen/modules/2d_engine/rosen_text/BUILD.gn index 0244094171..1a45605931 100755 --- a/rosen/modules/2d_engine/rosen_text/BUILD.gn +++ b/rosen/modules/2d_engine/rosen_text/BUILD.gn @@ -159,6 +159,10 @@ if (enable_text_gine) { "$rosen_root/modules/2d_engine/rosen_text/skia_txt/txt/src", ] + if (is_arkui_x) { + include_dirs += [ "//third_party/bounds_checking_function/include" ] + } + defines += [ "USE_GRAPHIC_TEXT_GINE", "WINDOWS_PLATFORM", diff --git a/rosen/modules/2d_graphics/include/image/image.h b/rosen/modules/2d_graphics/include/image/image.h index c86c7878a5..a3c2a4991a 100644 --- a/rosen/modules/2d_graphics/include/image/image.h +++ b/rosen/modules/2d_graphics/include/image/image.h @@ -17,6 +17,7 @@ #define IMAGE_H #include "drawing/engine_adapter/impl_interface/image_impl.h" +#include "image/gpu_context.h" #include "include/core/SkImage.h" #include "utils/drawing_macros.h" #ifdef RS_ENABLE_VK diff --git a/rosen/modules/2d_graphics/include/recording/cmd_list.h b/rosen/modules/2d_graphics/include/recording/cmd_list.h index 774864a3bb..8b979d5c34 100644 --- a/rosen/modules/2d_graphics/include/recording/cmd_list.h +++ b/rosen/modules/2d_graphics/include/recording/cmd_list.h @@ -92,7 +92,11 @@ public: uint32_t offset = opAllocator_.AddrToOffset(op); if (lastOpItemOffset_.has_value()) { +#ifdef CROSS_PLATFORM + auto* lastOpItem = static_cast(opAllocator_.OffsetToAddr(lastOpItemOffset_.__get())); +#else auto* lastOpItem = static_cast(opAllocator_.OffsetToAddr(lastOpItemOffset_.value())); +#endif if (lastOpItem != nullptr) { lastOpItem->SetNextOpItemOffset(offset); } diff --git a/rosen/modules/2d_graphics/include/recording/draw_cmd_list.h b/rosen/modules/2d_graphics/include/recording/draw_cmd_list.h index e9a76028ad..7722a78936 100644 --- a/rosen/modules/2d_graphics/include/recording/draw_cmd_list.h +++ b/rosen/modules/2d_graphics/include/recording/draw_cmd_list.h @@ -84,7 +84,11 @@ public: uint32_t offset = opAllocator_.AddrToOffset(op); if (lastOpItemOffset_.has_value()) { +#ifdef CROSS_PLATFORM + auto* lastOpItem = static_cast(opAllocator_.OffsetToAddr(lastOpItemOffset_.__get())); +#else auto* lastOpItem = static_cast(opAllocator_.OffsetToAddr(lastOpItemOffset_.value())); +#endif if (lastOpItem != nullptr) { lastOpItem->SetNextOpItemOffset(offset); } 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 be1bd48a49..865dafa933 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 @@ -23,6 +23,7 @@ namespace Drawing { DrawingSymbolLayersGroups SkiaHmSymbolConfigOhos::GetSymbolLayersGroups(uint16_t glyphId) { +#if !defined(CROSS_PLATFORM) SymbolLayersGroups groups = HmSymbolConfig_OHOS::GetInstance()->GetSymbolLayersGroups(glyphId); DrawingSymbolLayersGroups drawingGroups; @@ -52,6 +53,10 @@ DrawingSymbolLayersGroups SkiaHmSymbolConfigOhos::GetSymbolLayersGroups(uint16_t drawingGroups.renderModeGroups = drawingRenderModeGroups; return drawingGroups; +#else + DrawingSymbolLayersGroups drawingGroups; + return drawingGroups; +#endif } DrawingAnimationSetting SkiaHmSymbolConfigOhos::ConvertToDrawingAnimationSetting(AnimationSetting setting) @@ -120,6 +125,7 @@ static std::vector ConvertPiecewiseParametersVec(cons return out; } +#if !defined(CROSS_PLATFORM) std::vector> SkiaHmSymbolConfigOhos::GetGroupParameters( DrawingAnimationType type, uint16_t groupSum, uint16_t animationMode, DrawingCommonSubType commonSubType) { @@ -134,6 +140,7 @@ std::vector> SkiaHmSymbolConfigOhos::GetG } return parameters; } +#endif } // namespace Drawing } // namespace Rosen diff --git a/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_static_factory.cpp b/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_static_factory.cpp index 932282333a..a7eb929f0e 100644 --- a/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_static_factory.cpp +++ b/rosen/modules/2d_graphics/src/drawing/engine_adapter/skia_adapter/skia_static_factory.cpp @@ -195,7 +195,11 @@ DrawingSymbolLayersGroups SkiaStaticFactory::GetSymbolLayersGroups(uint16_t glyp std::vector> SkiaStaticFactory::GetGroupParameters( DrawingAnimationType type, uint16_t groupSum, uint16_t animationMode, DrawingCommonSubType commonSubType) { +#if !defined(CROSS_PLATFORM) return SkiaHmSymbolConfigOhos::GetGroupParameters(type, groupSum, animationMode, commonSubType); +#endif + std::vector> parameters; + return parameters; } FontStyleSet* SkiaStaticFactory::CreateEmpty() diff --git a/rosen/modules/2d_graphics/src/drawing/image/gpu_context.cpp b/rosen/modules/2d_graphics/src/drawing/image/gpu_context.cpp index 91f18e41b1..1cd82eef0a 100644 --- a/rosen/modules/2d_graphics/src/drawing/image/gpu_context.cpp +++ b/rosen/modules/2d_graphics/src/drawing/image/gpu_context.cpp @@ -51,7 +51,9 @@ bool GPUContext::BuildFromVK(const GrVkBackendContext& context, const GPUContext void GPUContext::GetResourceCacheLimits(int* maxResource, size_t* maxResourceBytes) const { - impl_->GetResourceCacheLimits(maxResource, maxResourceBytes); + if (impl_ != nullptr) { + impl_->GetResourceCacheLimits(maxResource, maxResourceBytes); + } } void GPUContext::SetResourceCacheLimits(int maxResource, size_t maxResourceBytes) diff --git a/rosen/modules/2d_graphics/src/render_context/render_context.h b/rosen/modules/2d_graphics/src/render_context/render_context.h index 5ab97e78de..2ab720ca05 100644 --- a/rosen/modules/2d_graphics/src/render_context/render_context.h +++ b/rosen/modules/2d_graphics/src/render_context/render_context.h @@ -164,9 +164,7 @@ protected: #endif EGLConfig config_; GraphicColorGamut colorSpace_ = GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB; -#ifndef ROSEN_CROSS_PLATFORM int32_t pixelFormat_ = GraphicPixelFormat::GRAPHIC_PIXEL_FMT_RGBA_8888; -#endif bool isUniRenderMode_ = false; const std::string UNIRENDER_CACHE_DIR = "/data/service/el0/render_service"; diff --git a/rosen/modules/platform/eventhandler/event_queue.h b/rosen/modules/platform/eventhandler/event_queue.h index 1d2e199bd6..7a2260b174 100644 --- a/rosen/modules/platform/eventhandler/event_queue.h +++ b/rosen/modules/platform/eventhandler/event_queue.h @@ -36,8 +36,10 @@ class EventQueue final { public: // Priority for the events enum class Priority : uint32_t { + // The highest priority queue, should be distributed until the tasks in the queue are completed. + VIP = 0, // Event that should be distributed at once if possible. - IMMEDIATE = 0, + IMMEDIATE, // High priority event, sorted by handle time, should be distributed before low priority event. HIGH, // Normal event, sorted by handle time. diff --git a/rosen/modules/render_frame_trace/BUILD.gn b/rosen/modules/render_frame_trace/BUILD.gn index d00c38ce89..93a5443059 100644 --- a/rosen/modules/render_frame_trace/BUILD.gn +++ b/rosen/modules/render_frame_trace/BUILD.gn @@ -31,13 +31,20 @@ ohos_source_set("render_frame_trace") { } } } - external_deps = [ "jsoncpp:jsoncpp" ] + external_deps = [] + if (is_arkui_x) { + deps = [ "//third_party/jsoncpp:jsoncpp_static" ] + } else { + external_deps += [ "jsoncpp:jsoncpp" ] + } if (!build_ohos_sdk) { external_deps += [ "ipc:ipc_single", "qos_manager:concurrent_task_client", ] - defines = [ "QOS_MANAGER" ] + if (!is_arkui_x) { + defines = [ "QOS_MANAGER" ] + } } if (defined(global_parts_info)) { if (defined(global_parts_info.resourceschedule_frame_aware_sched)) { diff --git a/rosen/modules/render_service/BUILD.gn b/rosen/modules/render_service/BUILD.gn index 895a065ed7..cf6aa18e64 100644 --- a/rosen/modules/render_service/BUILD.gn +++ b/rosen/modules/render_service/BUILD.gn @@ -231,7 +231,7 @@ ohos_shared_library("librender_service") { if (rosen_is_ohos) { sources += [ "$rosen_root/modules/frame_report/src/rs_frame_report.cpp" ] - } else { + } else if (!is_arkui_x) { sources += [ "$rosen_root/modules/frame_report/src/mingw/rs_frame_report.cpp" ] } diff --git a/rosen/modules/render_service_base/BUILD.gn b/rosen/modules/render_service_base/BUILD.gn index cd875926af..7ce417e4b4 100644 --- a/rosen/modules/render_service_base/BUILD.gn +++ b/rosen/modules/render_service_base/BUILD.gn @@ -370,10 +370,7 @@ ohos_source_set("render_service_base_src") { "src/memory/rs_tag_tracker.cpp", #pipeline - "src/pipeline/rs_display_render_node.cpp", "src/pipeline/rs_occlusion_config.cpp", - "src/pipeline/rs_uni_render_judgement.cpp", - "src/pipeline/sk_resource_manager.cpp", #transaction "src/transaction/rs_hgm_config_data.cpp", @@ -465,6 +462,7 @@ ohos_source_set("render_service_base_src") { include_dirs += [ "$graphic_2d_root/utils/color_manager/export", "//foundation/multimedia/image_framework/interfaces/innerkits/include", + "//foundation/graphic/graphic_surface/interfaces/inner_api/surface", ] } @@ -686,7 +684,11 @@ ohos_source_set("librender_service_base_static") { } if (rs_enable_gpu) { - public_external_deps += [ "openssl:libcrypto_shared" ] + if (is_arkui_x) { + public_deps += [ "//third_party/openssl:libcrypto_static" ] + } else { + public_external_deps += [ "openssl:libcrypto_shared" ] + } } part_name = "graphic_2d" diff --git a/rosen/modules/render_service_base/config.gni b/rosen/modules/render_service_base/config.gni index e8b51ae81a..e0f512356d 100644 --- a/rosen/modules/render_service_base/config.gni +++ b/rosen/modules/render_service_base/config.gni @@ -38,6 +38,10 @@ if (rosen_cross_platform) { } } +if (use_rosen_drawing && defined(is_arkui_x) && is_arkui_x) { + rs_common_define += [ "USE_ROSEN_DRAWING" ] +} + if (is_emulator) { rs_common_define += [ "ROSEN_EMULATOR" ] } diff --git a/rosen/modules/render_service_client/BUILD.gn b/rosen/modules/render_service_client/BUILD.gn index a128de713a..632395ae68 100644 --- a/rosen/modules/render_service_client/BUILD.gn +++ b/rosen/modules/render_service_client/BUILD.gn @@ -67,6 +67,7 @@ template("render_service_client_source_set") { include_dirs += [ "$graphic_2d_root/utils/color_manager/export", "//foundation/multimedia/image_framework/interfaces/innerkits/include", + "//foundation/graphic/graphic_surface/interfaces/inner_api/surface", ] } @@ -139,6 +140,7 @@ template("render_service_client_source_set") { if (is_cross_platform) { #ui sources -= [ "core/ui/rs_display_node.cpp" ] + defines += [ "CROSS_PLATFORM" ] } if (defined(graphic_2d_ext_configs.vendor_root)) { @@ -148,7 +150,7 @@ template("render_service_client_source_set") { if (rosen_is_ohos) { sources += [ "$rosen_root/modules/frame_report/src/rs_frame_report.cpp" ] - } else { + } else if (!is_arkui_x) { sources += [ "$rosen_root/modules/frame_report/src/mingw/rs_frame_report.cpp" ] } @@ -190,7 +192,7 @@ template("render_service_client_source_set") { if (defined(use_rosen_drawing) && use_rosen_drawing) { defines += [ "USE_ROSEN_DRAWING" ] deps += [ "$graphic_2d_root/rosen/modules/2d_graphics:2d_graphics" ] - if (ace_enable_gpu) { + if (ace_enable_gpu && !is_arkui_x) { defines += [ "ACE_ENABLE_GPU" ] } if (current_os == "mingw") { 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 9cb3609a32..4a8ae7dc9b 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 @@ -195,6 +195,7 @@ void RSRenderThreadVisitor::PrepareSurfaceRenderNode(RSSurfaceRenderNode& node) void RSRenderThreadVisitor::PrepareEffectRenderNode(RSEffectRenderNode& node) { +#ifndef CROSS_PLATFORM if (!node.ShouldPaint() || curDirtyManager_ == nullptr) { return; } @@ -209,6 +210,7 @@ void RSRenderThreadVisitor::PrepareEffectRenderNode(RSEffectRenderNode& node) effectRegion_ = effectRegion; dirtyFlag_ = dirtyFlag; +#endif } void RSRenderThreadVisitor::DrawRectOnCanvas(const RectI& dirtyRect, const Drawing::ColorQuad color, @@ -1043,10 +1045,10 @@ void RSRenderThreadVisitor::ProcessTextureSurfaceRenderNode(RSSurfaceRenderNode& } else { auto backgroundColor = node.GetRenderProperties().GetBackgroundColor(); if (backgroundColor != RgbPalette::Transparent()) { - canvas_->clear(backgroundColor.AsArgbInt()); + canvas_->Clear(backgroundColor.AsArgbInt()); } } - canvas_->restore(); + canvas_->Restore(); } #endif diff --git a/rosen/modules/texgine/BUILD.gn b/rosen/modules/texgine/BUILD.gn index ca079b731d..0bca8a5537 100644 --- a/rosen/modules/texgine/BUILD.gn +++ b/rosen/modules/texgine/BUILD.gn @@ -33,16 +33,31 @@ config("libtexgine_config") { ] } -config("libtexgine_public_config") { - include_dirs = [ - "export", - "texgine_drawing", - "$graphic_2d_root/rosen/modules/render_service_base/include", - "$graphic_2d_root/rosen/modules/2d_graphics/src/drawing/engine_adapter", - "$graphic_2d_root/rosen/modules/2d_graphics/include", - "$graphic_2d_root/rosen/modules/2d_graphics/src", - "$graphic_2d_root/rosen/modules/2d_engine/rosen_text/export/rosen_text", - ] +if (defined(is_arkui_x) && is_arkui_x) { + config("libtexgine_public_config") { + include_dirs = [ + "export", + "texgine_drawing", + "//third_party/icu/icu4c/source/common", + "$graphic_2d_root/rosen/modules/render_service_base/include", + "$graphic_2d_root/rosen/modules/2d_graphics/src/drawing/engine_adapter", + "$graphic_2d_root/rosen/modules/2d_graphics/include", + "$graphic_2d_root/rosen/modules/2d_graphics/src", + "$graphic_2d_root/rosen/modules/2d_engine/rosen_text/export/rosen_text", + ] + } +} else { + config("libtexgine_public_config") { + include_dirs = [ + "export", + "texgine_drawing", + "$graphic_2d_root/rosen/modules/render_service_base/include", + "$graphic_2d_root/rosen/modules/2d_graphics/src/drawing/engine_adapter", + "$graphic_2d_root/rosen/modules/2d_graphics/include", + "$graphic_2d_root/rosen/modules/2d_graphics/src", + "$graphic_2d_root/rosen/modules/2d_engine/rosen_text/export/rosen_text", + ] + } } ohos_source_set("libtexgine_source") { @@ -77,6 +92,10 @@ ohos_source_set("libtexgine_source") { public_deps = [ "texgine_drawing:libtexgine_drawing" ] defines = [] + if (is_arkui_x) { + defines += [ "CROSS_PLATFORM" ] + public_deps += [ "//third_party/jsoncpp:jsoncpp_static" ] + } if (defined(use_rosen_drawing) && use_rosen_drawing) { defines += [ "USE_ROSEN_DRAWING" ] if (ace_enable_gpu) { @@ -86,10 +105,15 @@ ohos_source_set("libtexgine_source") { if (enable_text_gine) { defines += [ "USE_GRAPHIC_TEXT_GINE" ] } - external_deps = [ - "bounds_checking_function:libsec_static", - "cJSON:cjson_static", - ] + if (is_arkui_x) { + deps = [ "//third_party/bounds_checking_function:libsec_static" ] + deps += [ "//third_party/cJSON:cjson_static" ] + } else { + external_deps = [ + "bounds_checking_function:libsec_static", + "cJSON:cjson_static", + ] + } if (platform == "ohos") { defines += [ "BUILD_NON_SDK_VER" ] @@ -123,6 +147,12 @@ ohos_source_set("libtexgine_source") { [ "$graphic_2d_root/rosen/build/icu:rosen_libicu_$platform" ] } } + if (platform == "android") { + defines += [ "BUILD_SDK_ANDROID" ] + } + if (platform == "ios") { + defines += [ "BUILD_SDK_IOS" ] + } } } diff --git a/rosen/modules/texgine/src/text_span.cpp b/rosen/modules/texgine/src/text_span.cpp index f946ae4099..7a5833ee4c 100644 --- a/rosen/modules/texgine/src/text_span.cpp +++ b/rosen/modules/texgine/src/text_span.cpp @@ -181,7 +181,11 @@ void TextSpan::Paint(TexgineCanvas &canvas, double offsetX, double offsetY, cons if (xs.background.has_value()) { auto rect = TexgineRect::MakeXYWH(offsetX, offsetY + *tmetrics_->fAscent_, width_, *tmetrics_->fDescent_ - *tmetrics_->fAscent_); +#ifdef CROSS_PLATFORM + canvas.DrawRect(rect, xs.background.__get()); +#else canvas.DrawRect(rect, xs.background.value()); +#endif } if (xs.backgroundRect.color != 0) { @@ -209,7 +213,11 @@ void TextSpan::Paint(TexgineCanvas &canvas, double offsetX, double offsetY, cons paint.SetAntiAlias(true); paint.SetColor(xs.color); if (xs.foreground.has_value()) { +#ifdef CROSS_PLATFORM + paint = xs.foreground.__get(); +#else paint = xs.foreground.value(); +#endif } PaintShadow(canvas, offsetX, offsetY, xs.shadows); diff --git a/rosen/modules/texgine/src/typography_impl.cpp b/rosen/modules/texgine/src/typography_impl.cpp index a44105831d..0603d5f551 100644 --- a/rosen/modules/texgine/src/typography_impl.cpp +++ b/rosen/modules/texgine/src/typography_impl.cpp @@ -797,13 +797,21 @@ std::vector TypographyImpl::MergeRects(const std::vector &bo std::fabs(*pre->rect.fRight_ - *rect.rect.fLeft_) < MINDEV) { *pre->rect.fRight_ = *rect.rect.fRight_; } else { +#ifdef CROSS_PLATFORM + rects.push_back(pre.__get()); +#else rects.push_back(pre.value()); +#endif pre = rect; } } if (pre.has_value()) { +#ifdef CROSS_PLATFORM + rects.push_back(pre.__get()); +#else rects.push_back(pre.value()); +#endif } return rects; diff --git a/rosen/modules/texgine/src/utils/logger.cpp b/rosen/modules/texgine/src/utils/logger.cpp index 33037caee6..db06a9f21f 100644 --- a/rosen/modules/texgine/src/utils/logger.cpp +++ b/rosen/modules/texgine/src/utils/logger.cpp @@ -29,10 +29,12 @@ #define GET_TID GetCurrentThreadId #endif -#ifdef BUILD_SDK_MAC +#if defined(BUILD_SDK_MAC) || defined(BUILD_SDK_IOS) #include #include #define GET_TID() syscall(SYS_thread_selfid) +#elif defined(BUILD_SDK_ANDROID) +#define GET_TID() gettid() #else #ifdef __gnu_linux__ #include diff --git a/rosen/test/frame_report/unittest/BUILD.gn b/rosen/test/frame_report/unittest/BUILD.gn index 6fb72999c1..f1be7c8591 100644 --- a/rosen/test/frame_report/unittest/BUILD.gn +++ b/rosen/test/frame_report/unittest/BUILD.gn @@ -23,7 +23,7 @@ ohos_unittest("frame_report_test") { sources += [ "$graphic_2d_root/rosen/modules/frame_report/src/rs_frame_report.cpp", ] - } else { + } else if (!is_arkui_x) { sources += [ "$graphic_2d_root/rosen/modules/frame_report/src/mingw/rs_frame_report.cpp" ] } diff --git a/utils/sandbox/BUILD.gn b/utils/sandbox/BUILD.gn index 03b4754b17..78953505d1 100644 --- a/utils/sandbox/BUILD.gn +++ b/utils/sandbox/BUILD.gn @@ -12,12 +12,16 @@ # limitations under the License. import("//build/ohos.gni") +import("//foundation/graphic/graphic_2d/graphic_config.gni") config("sandbox_utils_config") { include_dirs = [ "." ] } ohos_static_library("sandbox_utils") { + if (is_cross_platform) { + defines = [ "ROSEN_CROSS_PLATFORM" ] + } sources = [ "sandbox_utils.cpp" ] public_configs = [ ":sandbox_utils_config" ] diff --git a/utils/sandbox/sandbox_utils.cpp b/utils/sandbox/sandbox_utils.cpp index 63981a5328..65c376346a 100644 --- a/utils/sandbox/sandbox_utils.cpp +++ b/utils/sandbox/sandbox_utils.cpp @@ -26,7 +26,7 @@ pid_t GetRealPid(void) { #ifdef _WIN32 return GetCurrentProcessId(); -#elif defined(OHOS_LITE) || defined(__APPLE__) || defined(__gnu_linux__) +#elif defined(OHOS_LITE) || defined(__APPLE__) || defined(__gnu_linux__) || defined(ROSEN_CROSS_PLATFORM) return getpid(); #else return getprocpid(); From 6e131540ff4f94fd7c95fbee4dd79a7da1722ac5 Mon Sep 17 00:00:00 2001 From: tanyuhang Date: Thu, 1 Aug 2024 07:26:39 +0000 Subject: [PATCH 53/74] rs_property_modifier_test.cpp. Signed-off-by: tanyuhang --- .../modifier/rs_property_modifier_test.cpp | 114 +++++++++++++----- 1 file changed, 84 insertions(+), 30 deletions(-) diff --git a/rosen/test/render_service/render_service_client/unittest/modifier/rs_property_modifier_test.cpp b/rosen/test/render_service/render_service_client/unittest/modifier/rs_property_modifier_test.cpp index bbd4ef87d3..11f3ddb623 100644 --- a/rosen/test/render_service/render_service_client/unittest/modifier/rs_property_modifier_test.cpp +++ b/rosen/test/render_service/render_service_client/unittest/modifier/rs_property_modifier_test.cpp @@ -113,29 +113,32 @@ HWTEST_F(RSPropertyModifierTest, Apply01, TestSize.Level1) std::shared_ptr geometry = std::make_shared(); ASSERT_NE(geometry, nullptr); - auto property = std::make_shared>(INITIAL_VALUE_4F); + auto property = std::make_shared>(INITIAL_VALUE_RECT_4F); ASSERT_NE(property, nullptr); std::shared_ptr boundsModifier = std::make_shared(property); ASSERT_NE(boundsModifier, nullptr); boundsModifier->Apply(geometry); + EXPECT_EQ(geometry->x_, 10.f); + EXPECT_EQ(geometry->y_, 10.f); + EXPECT_EQ(geometry->width_, 10.f); + EXPECT_EQ(geometry->height_, 10.f); - auto property02 = std::make_shared>(INITIAL_VALUE_2F); + auto property02 = std::make_shared>(INITIAL_VALUE_SIZE_2F); ASSERT_NE(property02, nullptr); std::shared_ptr boundsSizeModifier = std::make_shared(property02); ASSERT_NE(boundsSizeModifier, nullptr); boundsSizeModifier->Apply(geometry); + EXPECT_EQ(geometry->width_, 60.f); + EXPECT_EQ(geometry->height_, 30.f); - auto property03 = std::make_shared>(INITIAL_VALUE_2F); + auto property03 = std::make_shared>(INITIAL_VALUE_POSITION_2F); ASSERT_NE(property03, nullptr); std::shared_ptr boundsPositionModifier = std::make_shared(property03); ASSERT_NE(boundsPositionModifier, nullptr); boundsPositionModifier->Apply(geometry); - EXPECT_EQ(geometry->x_, 0.f); - EXPECT_EQ(geometry->y_, 0.f); - EXPECT_EQ(geometry->z_, 0.f); - EXPECT_EQ(geometry->width_, 0.f); - EXPECT_EQ(geometry->height_, 0.f); + EXPECT_EQ(geometry->x_, 50.f); + EXPECT_EQ(geometry->y_, 50.f); } /** @@ -148,25 +151,28 @@ HWTEST_F(RSPropertyModifierTest, Apply02, TestSize.Level1) std::shared_ptr geometry = std::make_shared(); ASSERT_NE(geometry, nullptr); - auto property = std::make_shared>(INITIAL_VALUE_2F); + auto property = std::make_shared>(INITIAL_VALUE_PIVOT_2F); ASSERT_NE(property, nullptr); std::shared_ptr pivotModifier = std::make_shared(property); ASSERT_NE(pivotModifier, nullptr); pivotModifier->Apply(geometry); + EXPECT_EQ(geometry->trans_->pivotX_, 70.f); + EXPECT_EQ(geometry->trans_->pivotY_, 80.f); - auto property02 = std::make_shared>(0.f); + auto property02 = std::make_shared>(90.f); ASSERT_NE(property02, nullptr); std::shared_ptr pivotZModifier = std::make_shared(property02); ASSERT_NE(pivotZModifier, nullptr); pivotZModifier->Apply(geometry); + EXPECT_EQ(geometry->trans_->pivotZ_, 90.f); - Quaternion value = Quaternion(0, 0, 0, 0); + Quaternion value = Quaternion(10, 20, 30, 40); auto property03 = std::make_shared>(value); ASSERT_NE(property03, nullptr); std::shared_ptr quaternionModifier = std::make_shared(property03); ASSERT_NE(quaternionModifier, nullptr); quaternionModifier->Apply(geometry); - EXPECT_EQ(geometry->z_, 0.f); + EXPECT_EQ(geometry->trans_->quaternion_, value); } /** @@ -179,24 +185,44 @@ HWTEST_F(RSPropertyModifierTest, Apply03, TestSize.Level1) std::shared_ptr geometry = std::make_shared(); ASSERT_NE(geometry, nullptr); - auto property = std::make_shared>(0.f); + auto property = std::make_shared>(30.f); ASSERT_NE(property, nullptr); std::shared_ptr rotationModifier = std::make_shared(property); ASSERT_NE(rotationModifier, nullptr); rotationModifier->Apply(geometry); + EXPECT_EQ(geometry->trans_->rotation_, 30); - auto property02 = std::make_shared>(0.f); + auto property02 = std::make_shared>(60.f); ASSERT_NE(property02, nullptr); - std::shared_ptr rotationXModifier = std::make_shared(property02); + rotationModifier = std::make_shared(property02); + rotationModifier->Apply(geometry); + EXPECT_EQ(geometry->trans_->rotation_, 90); + + auto propertyX = std::make_shared>(60.f); + ASSERT_NE(propertyX, nullptr); + std::shared_ptr rotationXModifier = std::make_shared(propertyX); ASSERT_NE(rotationXModifier, nullptr); rotationXModifier->Apply(geometry); + EXPECT_EQ(geometry->trans_->rotationX_, 60); - auto property03 = std::make_shared>(0.f); - ASSERT_NE(property03, nullptr); - std::shared_ptr rotationYModifier = std::make_shared(property03); + auto propertyX02 = std::make_shared>(30.f); + ASSERT_NE(propertyX02, nullptr); + rotationXModifier = std::make_shared(propertyX02); + rotationXModifier->Apply(geometry); + EXPECT_EQ(geometry->trans_->rotationX_, 90); + + auto propertyY = std::make_shared>(40.f); + ASSERT_NE(propertyY, nullptr); + std::shared_ptr rotationYModifier = std::make_shared(propertyY); ASSERT_NE(rotationYModifier, nullptr); rotationYModifier->Apply(geometry); - EXPECT_EQ(geometry->z_, 0.f); + EXPECT_EQ(geometry->trans_->rotationY_, 40); + + auto propertyY02 = std::make_shared>(50.f); + ASSERT_NE(propertyY02, nullptr); + rotationYModifier = std::make_shared(propertyY02); + rotationYModifier->Apply(geometry); + EXPECT_EQ(geometry->trans_->rotationY_, 90); } /** @@ -209,25 +235,29 @@ HWTEST_F(RSPropertyModifierTest, Apply04, TestSize.Level1) std::shared_ptr geometry = std::make_shared(); ASSERT_NE(geometry, nullptr); - auto property = std::make_shared>(0.f); + auto property = std::make_shared>(10); ASSERT_NE(property, nullptr); std::shared_ptr cameraDistanceModifier = std::make_shared(property); ASSERT_NE(cameraDistanceModifier, nullptr); cameraDistanceModifier->Apply(geometry); + EXPECT_EQ(geometry->trans_->cameraDistance_, 10); - auto property02 = std::make_shared>(INITIAL_VALUE_2F); + auto property02 = std::make_shared>(INITIAL_VALUE_SCALE_2F); ASSERT_NE(property02, nullptr); std::shared_ptr scaleModifier = std::make_shared(property02); ASSERT_NE(scaleModifier, nullptr); scaleModifier->Apply(geometry); + EXPECT_EQ(geometry->trans_->scaleX_, 2); + EXPECT_EQ(geometry->trans_->scaleY_, 2); - auto property03 = std::make_shared>(INITIAL_VALUE_2F); + auto property03 = std::make_shared>(INITIAL_VALUE_SKEW_2F); ASSERT_NE(property03, nullptr); std::shared_ptr skewModifier = std::make_shared(property03); ASSERT_NE(skewModifier, nullptr); skewModifier->Apply(geometry); - EXPECT_EQ(geometry->z_, 0.f); + EXPECT_EQ(geometry->trans_->skewX_, 30); + EXPECT_EQ(geometry->trans_->skewY_, 30); } /** @@ -240,23 +270,47 @@ HWTEST_F(RSPropertyModifierTest, Apply05, TestSize.Level1) std::shared_ptr geometry = std::make_shared(); ASSERT_NE(geometry, nullptr); - std::shared_ptr property = std::make_shared>(INITIAL_VALUE_2F); + auto property = std::make_shared>(INITIAL_VALUE_SIZE_2F); ASSERT_NE(property, nullptr); std::shared_ptr perspModifier = std::make_shared(property); ASSERT_NE(perspModifier, nullptr); perspModifier->Apply(geometry); + EXPECT_EQ(geometry->trans_->perspX_, 60); + EXPECT_EQ(geometry->trans_->perspY_, 30); - std::shared_ptr property02 = std::make_shared>(INITIAL_VALUE_2F); + auto property02 = std::make_shared>(INITIAL_VALUE_POSITION_2F); ASSERT_NE(property02, nullptr); - std::shared_ptr translateModifier = std::make_shared(property02); + perspModifier = std::make_shared(property02); + perspModifier->Apply(geometry); + EXPECT_EQ(geometry->trans_->perspX_, 110); + EXPECT_EQ(geometry->trans_->perspY_, 80); + + auto property03 = std::make_shared>(INITIAL_VALUE_SIZE_2F); + ASSERT_NE(property03, nullptr); + std::shared_ptr translateModifier = std::make_shared(property03); ASSERT_NE(translateModifier, nullptr); translateModifier->Apply(geometry); + EXPECT_EQ(geometry->trans_->translateX_, 60); + EXPECT_EQ(geometry->trans_->translateY_, 30); - std::shared_ptr property03 = std::make_shared>(0.f); - ASSERT_NE(property03, nullptr); - std::shared_ptr translateZModifier = std::make_shared(property03); + auto property04 = std::make_shared>(INITIAL_VALUE_POSITION_2F); + ASSERT_NE(property04, nullptr); + translateModifier = std::make_shared(property04); + translateModifier->Apply(geometry); + EXPECT_EQ(geometry->trans_->translateX_, 110); + EXPECT_EQ(geometry->trans_->translateY_, 80); + + auto property05 = std::make_shared>(20.f); + ASSERT_NE(property05, nullptr); + std::shared_ptr translateZModifier = std::make_shared(property05); ASSERT_NE(translateZModifier, nullptr); translateZModifier->Apply(geometry); - EXPECT_EQ(geometry->z_, 0.f); + EXPECT_EQ(geometry->trans_->translateZ_, 20); + + auto property06 = std::make_shared>(30.f); + ASSERT_NE(property06, nullptr); + translateZModifier = std::make_shared(property06); + translateZModifier->Apply(geometry); + EXPECT_EQ(geometry->trans_->translateZ_, 50); } } // namespace OHOS::Rosen \ No newline at end of file From 79626345db68838eac400e37ba1907999a479ec0 Mon Sep 17 00:00:00 2001 From: tanyuhang Date: Thu, 1 Aug 2024 07:33:07 +0000 Subject: [PATCH 54/74] /rs_property_modifier_test.cpp. Signed-off-by: tanyuhang --- .../unittest/modifier/rs_property_modifier_test.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rosen/test/render_service/render_service_client/unittest/modifier/rs_property_modifier_test.cpp b/rosen/test/render_service/render_service_client/unittest/modifier/rs_property_modifier_test.cpp index 11f3ddb623..68d4546cf2 100644 --- a/rosen/test/render_service/render_service_client/unittest/modifier/rs_property_modifier_test.cpp +++ b/rosen/test/render_service/render_service_client/unittest/modifier/rs_property_modifier_test.cpp @@ -30,8 +30,12 @@ public: void SetUp() override; void TearDown() override; - const Vector2f INITIAL_VALUE_2F = Vector2f(0.f, 0.f); - const Vector4f INITIAL_VALUE_4F = Vector4f(0.f, 0.f, 0.f, 0.f); + const Vector2f INITIAL_VALUE_SIZE_2F = Vector2f(60.f, 30.f); + const Vector2f INITIAL_VALUE_POSITION_2F = Vector2f(50.f, 50.f); + const Vector2f INITIAL_VALUE_PIVOT_2F = Vector2f(70.f, 80.f); + const Vector2f INITIAL_VALUE_SCALE_2F = Vector2f(2.f, 2.f); + const Vector2f INITIAL_VALUE_SKEW_2F = Vector2f(30.f, 30.f); + const Vector4f INITIAL_VALUE_RECT_4F = Vector4f(10.f, 10.f, 10.f, 10.f); }; void RSPropertyModifierTest::SetUpTestCase() {} From 58fadabd35e4a821671ef2f491bd7136c73c4ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=AF=E9=91=AB?= Date: Thu, 1 Aug 2024 07:53:38 +0000 Subject: [PATCH 55/74] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BD=8E=E7=BA=A7?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 凯鑫 --- .../src/benchmarks/file_utils.cpp | 15 +++++++++------ .../src/benchmarks/rs_recording_thread.cpp | 6 +++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/rosen/modules/render_service_base/src/benchmarks/file_utils.cpp b/rosen/modules/render_service_base/src/benchmarks/file_utils.cpp index e3ceb61c6d..0dda7e786f 100644 --- a/rosen/modules/render_service_base/src/benchmarks/file_utils.cpp +++ b/rosen/modules/render_service_base/src/benchmarks/file_utils.cpp @@ -63,7 +63,7 @@ bool CreateFile(const std::string& filePath) bool WriteToFile(uintptr_t data, size_t size, const std::string& filePath) { - if (!CreateFile(filePath)) { + if (data == nullptr || size == 0 || !CreateFile(filePath)) { return false; } if (filePath.empty()) { @@ -71,16 +71,16 @@ bool WriteToFile(uintptr_t data, size_t size, const std::string& filePath) } int fd = open(filePath.c_str(), O_RDWR | O_CREAT, static_cast(0600)); if (fd < 0) { - RS_LOGE("FileUtils: %{public}s failed. file: %{public}s, fd = %{public}d", __func__, filePath.c_str(), fd); + RS_LOGE("FileUtils: %{public}s failed. file: %{public}s, fd < 0", __func__, filePath.c_str()); return false; } ssize_t nwrite = write(fd, reinterpret_cast(data), size); + close(fd); if (nwrite < 0) { - RS_LOGE("FileUtils: %{public}s failed to persist data, size = %{public}zu, fd = %{public}d", - __func__, size, fd); + RS_LOGE("FileUtils: %{public}s failed to write data, size = %{public}zu", + __func__, size); return false; } - close(fd); return true; } @@ -110,7 +110,7 @@ bool WriteStringToFile(const std::string& str, const std::string& filePath) } int fd = open(filePath.c_str(), O_RDWR | O_CREAT, static_cast(0600)); if (fd < 0) { - RS_LOGE("FileUtils: %{public}s failed. file: %{public}s, fd = %{public}d", __func__, filePath.c_str(), fd); + RS_LOGE("FileUtils: %{public}s failed. file: %{public}s, fd < 0", __func__, filePath.c_str()); return false; } bool result = WriteStringToFile(fd, str); @@ -121,6 +121,9 @@ bool WriteStringToFile(const std::string& str, const std::string& filePath) bool WriteMessageParcelToFile(std::shared_ptr messageParcel, const std::string& opsDescription, int frameNum, const std::string& fileDir) { + if (messageParcel == nullptr) { + return false; + } // file name std::string drawCmdListFile = fileDir + "/frame" + std::to_string(frameNum) + ".drawing"; std::string opsFile = fileDir + "/ops_frame" + std::to_string(frameNum) + ".txt"; diff --git a/rosen/modules/render_service_base/src/benchmarks/rs_recording_thread.cpp b/rosen/modules/render_service_base/src/benchmarks/rs_recording_thread.cpp index d816df53c7..94b7815232 100644 --- a/rosen/modules/render_service_base/src/benchmarks/rs_recording_thread.cpp +++ b/rosen/modules/render_service_base/src/benchmarks/rs_recording_thread.cpp @@ -62,7 +62,7 @@ std::shared_ptr RSRecordingThread::CreateShareGrContext() auto size = glesVersion ? strlen(glesVersion) : 0; handler->ConfigureContext(&options, glesVersion, size); if (!gpuContext->BuildFromGL(options)) { - RS_LOGE("nullptr gpuContext is null"); + RS_LOGE("gpuContext is null"); return nullptr; } return gpuContext; @@ -77,7 +77,7 @@ std::shared_ptr RSRecordingThread::CreateShareGrContext() auto size = vulkanVersion.size(); handler->ConfigureContext(&options, vulkanVersion.c_str(), size); if (!gpuContext->BuildFromVK(RsVulkanContext::GetSingleton().GetGrVkBackendContext(), options)) { - RS_LOGE("nullptr gpuContext is null"); + RS_LOGE("gpuContext is null"); return nullptr; } return gpuContext; @@ -211,7 +211,7 @@ void RSRecordingThread::FinishRecordingOneFrame() void RSRecordingThread::RecordingToFile(const std::shared_ptr& drawCmdList) { - if (curDumpFrame_ < 0) { + if (curDumpFrame_ < 0 || drawCmdList == nullptr) { return; } if (mode_ == RecordingMode::HIGH_SPPED_RECORDING) { From 0e2f5595e233f538f3a21d653702d6669ad009aa Mon Sep 17 00:00:00 2001 From: chenlulu Date: Mon, 29 Jul 2024 17:23:44 +0800 Subject: [PATCH 56/74] security update Signed-off-by: chenlulu Change-Id: I54217a827beac42d7de99cdc3adc1bacbc6330cf --- rosen/modules/render_service/core/main.cpp | 1 + .../transaction/rs_render_service_stub.cpp | 4 -- ..._ipc_interface_code_access_verifier_base.h | 1 - ...pc_interface_code_access_verifier_base.cpp | 37 ------------------- .../core/ui/rs_surface_node.cpp | 2 +- ...terface_code_access_verifier_base_test.cpp | 26 ------------- 6 files changed, 2 insertions(+), 69 deletions(-) diff --git a/rosen/modules/render_service/core/main.cpp b/rosen/modules/render_service/core/main.cpp index 15978f946a..b3425d3090 100644 --- a/rosen/modules/render_service/core/main.cpp +++ b/rosen/modules/render_service/core/main.cpp @@ -35,6 +35,7 @@ int main(int argc, const char *argv[]) param.sched_priority = 1; if (sched_setscheduler(0, SCHED_FIFO, ¶m) != 0) { RS_LOGE("RSRenderService Couldn't set SCHED_FIFO."); + return -1; } else { RS_LOGE("RSRenderService set SCHED_FIFO succeed."); } diff --git a/rosen/modules/render_service/core/transaction/rs_render_service_stub.cpp b/rosen/modules/render_service/core/transaction/rs_render_service_stub.cpp index ab7f39ffd9..92370db880 100644 --- a/rosen/modules/render_service/core/transaction/rs_render_service_stub.cpp +++ b/rosen/modules/render_service/core/transaction/rs_render_service_stub.cpp @@ -40,10 +40,6 @@ int RSRenderServiceStub::OnRemoteRequest( return ERR_INVALID_STATE; } #endif - if (!securityManager_.IsInterfaceCodeAccessible(code)) { - RS_LOGE("RSRenderServiceStub::OnRemoteRequest no permission to access codeID=%{public}u.", code); - return ERR_INVALID_STATE; - } #ifdef ENABLE_IPC_SECURITY_ACCESS_COUNTER securityUtils_.IncreaseAccessCounter(code); #endif diff --git a/rosen/modules/render_service_base/include/ipc_security/rs_ipc_interface_code_access_verifier_base.h b/rosen/modules/render_service_base/include/ipc_security/rs_ipc_interface_code_access_verifier_base.h index c325304ad4..fc1a9545fc 100644 --- a/rosen/modules/render_service_base/include/ipc_security/rs_ipc_interface_code_access_verifier_base.h +++ b/rosen/modules/render_service_base/include/ipc_security/rs_ipc_interface_code_access_verifier_base.h @@ -67,7 +67,6 @@ protected: #endif bool IsSystemCalling(const std::string& callingCode) const; bool CheckPermission(CodeUnderlyingType code) const; - bool IsPermissionAuthenticated(CodeUnderlyingType code) const; private: DISALLOW_COPY_AND_MOVE(RSInterfaceCodeAccessVerifierBase); diff --git a/rosen/modules/render_service_base/src/ipc_security/rs_ipc_interface_code_access_verifier_base.cpp b/rosen/modules/render_service_base/src/ipc_security/rs_ipc_interface_code_access_verifier_base.cpp index d0f4d9c9ab..390e43baa2 100644 --- a/rosen/modules/render_service_base/src/ipc_security/rs_ipc_interface_code_access_verifier_base.cpp +++ b/rosen/modules/render_service_base/src/ipc_security/rs_ipc_interface_code_access_verifier_base.cpp @@ -72,10 +72,6 @@ bool RSInterfaceCodeAccessVerifierBase::CheckHapPermission( bool RSInterfaceCodeAccessVerifierBase::CheckPermission(CodeUnderlyingType code) const { - bool securityPermissionCheckEnabled = RSSystemProperties::GetSecurityPermissionCheckEnabled(); - if (!securityPermissionCheckEnabled) { - return true; - } std::vector permissions = GetPermissions(code); bool hasPermission = true; auto tokenType = GetTokenType(); @@ -102,34 +98,6 @@ bool RSInterfaceCodeAccessVerifierBase::CheckPermission(CodeUnderlyingType code) return true; } -bool RSInterfaceCodeAccessVerifierBase::IsPermissionAuthenticated(CodeUnderlyingType code) const -{ - std::vector permissions = GetPermissions(code); - bool hasPermission = true; - auto tokenType = GetTokenType(); - auto tokenID = GetTokenID(); - for (auto& permission : permissions) { - switch (tokenType) { - case Security::AccessToken::ATokenTypeEnum::TOKEN_HAP: - hasPermission = CheckHapPermission(tokenID, permission); - break; - case Security::AccessToken::ATokenTypeEnum::TOKEN_NATIVE: - hasPermission = CheckNativePermission(tokenID, permission); - break; - case Security::AccessToken::ATokenTypeEnum::TOKEN_SHELL: - hasPermission = CheckNativePermission(tokenID, permission); - break; - default: - break; - } - if (!hasPermission) { - RS_LOGE("%{public}d ipc interface code access denied: permission authentication failed", code); - return false; - } - } - return true; -} - std::string RSInterfaceCodeAccessVerifierBase::PermissionEnumToString(PermissionType permission) const { if (PERMISSION_MAP.count(permission) > 0) { @@ -208,11 +176,6 @@ bool RSInterfaceCodeAccessVerifierBase::CheckPermission(CodeUnderlyingType code) { return true; } - -bool RSInterfaceCodeAccessVerifierBase::IsPermissionAuthenticated(CodeUnderlyingType code) const -{ - return true; -} #endif bool RSInterfaceCodeAccessVerifierBase::IsCommonVerificationPassed(CodeUnderlyingType /* code */) 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 583f215191..452e4246cc 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 = isWindow, + .isSync = isWindow && surfaceNodeConfig.isSync, .surfaceWindowType = surfaceNodeConfig.surfaceWindowType, }; config.nodeType = type; diff --git a/rosen/test/render_service/render_service_base/unittest/memory/rs_interface_code_access_verifier_base_test.cpp b/rosen/test/render_service/render_service_base/unittest/memory/rs_interface_code_access_verifier_base_test.cpp index 549c8919f9..226d49f1aa 100644 --- a/rosen/test/render_service/render_service_base/unittest/memory/rs_interface_code_access_verifier_base_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/memory/rs_interface_code_access_verifier_base_test.cpp @@ -58,19 +58,6 @@ HWTEST_F(RSInterfaceCodeAccessVerifierBaseTest, CheckPermissionTest001, testing: ASSERT_EQ(verifier->CheckPermission(code), true); } -/** - * @tc.name: IsPermissionAuthenticatedTest001 - * @tc.desc: test - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(RSInterfaceCodeAccessVerifierBaseTest, IsPermissionAuthenticatedTest001, testing::ext::TestSize.Level1) -{ - auto verifier = std::make_unique(); - CodeUnderlyingType code = 0; - ASSERT_EQ(verifier->IsPermissionAuthenticated(code), true); -} - /** * @tc.name: IsCommonVerificationPassedTest * @tc.desc: test @@ -158,19 +145,6 @@ HWTEST_F(RSInterfaceCodeAccessVerifierBaseTest, CheckPermissionTest002, testing: ASSERT_EQ(verifier->CheckPermission(code), true); } -/** - * @tc.name: IsPermissionAuthenticatedTest002 - * @tc.desc: test - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(RSInterfaceCodeAccessVerifierBaseTest, IsPermissionAuthenticatedTest002, testing::ext::TestSize.Level1) -{ - CodeUnderlyingType code = 0; - auto verifier = std::make_unique(); - ASSERT_EQ(verifier->IsPermissionAuthenticated(code), true); -} - /** * @tc.name: PermissionEnumToStringTest001 * @tc.desc: test From 5878e74724294490795364d087748703571ad137 Mon Sep 17 00:00:00 2001 From: liuwei793 Date: Thu, 1 Aug 2024 16:03:36 +0800 Subject: [PATCH 57/74] add_tdd_drawable Signed-off-by: liuwei793 Change-Id: I49dde80b611d75b76acc6ebcfee2b175641abd11 --- .../render_service/unittest/drawable/BUILD.gn | 15 ++ ...ffer_surface_render_node_drawable_test.cpp | 218 ++++++++++++++++++ ...irst_surface_render_node_drawable_test.cpp | 185 ++++++++++++++- 3 files changed, 411 insertions(+), 7 deletions(-) create mode 100644 rosen/test/render_service/render_service/unittest/drawable/rs_dma_buffer_surface_render_node_drawable_test.cpp diff --git a/rosen/test/render_service/render_service/unittest/drawable/BUILD.gn b/rosen/test/render_service/render_service/unittest/drawable/BUILD.gn index 58654e2d71..a0ea721cdc 100644 --- a/rosen/test/render_service/render_service/unittest/drawable/BUILD.gn +++ b/rosen/test/render_service/render_service/unittest/drawable/BUILD.gn @@ -24,6 +24,7 @@ group("unittest") { ":RSCanvasRenderNodeDrawableTest", ":RSDirtyRectsDFXTest", ":RSDisplayRenderNodeDrawableTest", + ":RSDmaBufferSurfaceRenderNodeDrawableTest", ":RSEffectRenderNodeDrawableTest", ":RSRenderNodeDrawableAdapterTest", ":RSRenderNodeDrawableAutoCacheTest", @@ -82,6 +83,20 @@ ohos_unittest("RSDisplayRenderNodeDrawableTest") { } } +## Build RSDmaBufferSurfaceRenderNodeDrawableTest +ohos_unittest("RSDmaBufferSurfaceRenderNodeDrawableTest") { + module_out_path = module_output_path + sources = [ "rs_dma_buffer_surface_render_node_drawable_test.cpp" ] + deps = [ ":rs_test_common" ] + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + ] + if (defined(global_parts_info) && defined(global_parts_info.sensors_sensor)) { + external_deps += [ "sensor:sensor_interface_native" ] + } +} + ## Build RSEffectRenderNodeDrawableTest ohos_unittest("RSEffectRenderNodeDrawableTest") { module_out_path = module_output_path diff --git a/rosen/test/render_service/render_service/unittest/drawable/rs_dma_buffer_surface_render_node_drawable_test.cpp b/rosen/test/render_service/render_service/unittest/drawable/rs_dma_buffer_surface_render_node_drawable_test.cpp new file mode 100644 index 0000000000..42e3d9b207 --- /dev/null +++ b/rosen/test/render_service/render_service/unittest/drawable/rs_dma_buffer_surface_render_node_drawable_test.cpp @@ -0,0 +1,218 @@ +/* + * 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, Hardware + * 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 "drawable/rs_render_node_drawable.h" +#include "drawable/rs_surface_render_node_drawable.h" +#include "pipeline/rs_uni_render_engine.h" +#include "pipeline/rs_uni_render_thread.h" + +using namespace testing; +using namespace testing::ext; +using namespace OHOS::Rosen::DrawableV2; + +namespace OHOS::Rosen { +constexpr int32_t DEFAULT_CANVAS_SIZE = 100; +constexpr NodeId DEFAULT_ID = 0xFFFF; +class RSDmaBufferSurfaceRenderNodeDrawableTest : public testing::Test { +public: + std::shared_ptr renderNode_; + std::shared_ptr surfaceDrawable_; + std::shared_ptr canvas_; + std::shared_ptr drawingCanvas_; + + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void RSDmaBufferSurfaceRenderNodeDrawableTest::SetUpTestCase() {} +void RSDmaBufferSurfaceRenderNodeDrawableTest::TearDownTestCase() {} +void RSDmaBufferSurfaceRenderNodeDrawableTest::SetUp() +{ + renderNode_ = std::make_shared(DEFAULT_ID); + if (!renderNode_) { + RS_LOGE("RSSurfaceRenderNodeDrawableTest: failed to create surface node."); + return; + } + surfaceDrawable_ = std::static_pointer_cast( + DrawableV2::RSRenderNodeDrawableAdapter::OnGenerate(renderNode_)); + if (!surfaceDrawable_ || !surfaceDrawable_->renderParams_) { + RS_LOGE("RSSurfaceRenderNodeDrawableTest: failed to init render params."); + return; + } + drawingCanvas_ = std::make_unique(DEFAULT_CANVAS_SIZE, DEFAULT_CANVAS_SIZE); + if (drawingCanvas_) { + canvas_ = std::make_shared(drawingCanvas_.get()); + } +} +void RSDmaBufferSurfaceRenderNodeDrawableTest::TearDown() {} + +/** + * @tc.name: UseDmaBuffer + * @tc.desc: Test If UseDmaBuffer Can Run + * @tc.type: FUNC + * @tc.require: issueIAH6OI + */ +HWTEST_F(RSDmaBufferSurfaceRenderNodeDrawableTest, UseDmaBufferTest, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + bool result = surfaceDrawable_->UseDmaBuffer(); + ASSERT_FALSE(result); +} + +/** + * @tc.name: GetFrameBufferRequestConfig + * @tc.desc: Test If GetFrameBufferRequestConfig Can Run + * @tc.type: FUNC + * @tc.require: issueIAH6OI + */ +HWTEST_F(RSDmaBufferSurfaceRenderNodeDrawableTest, GetFrameBufferRequestConfigTest, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + BufferRequestConfig config = surfaceDrawable_->GetFrameBufferRequestConfig(); + ASSERT_FALSE(config.timeout); +} + +/** + * @tc.name: RequestFrame + * @tc.desc: Test If RequestFrame Can Run + * @tc.type: FUNC + * @tc.require: issueIAH6OI + */ +HWTEST_F(RSDmaBufferSurfaceRenderNodeDrawableTest, RequestFrameTest, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + RenderContext* renderContext = nullptr; + std::shared_ptr skContext = std::make_shared(); + auto result = surfaceDrawable_->RequestFrame(renderContext, skContext); + ASSERT_FALSE(result); + + surfaceDrawable_->CreateSurface(); + ASSERT_TRUE(surfaceDrawable_->surfaceHandlerUiFirst_->GetConsumer()); + ASSERT_TRUE(surfaceDrawable_->surface_); + result = surfaceDrawable_->RequestFrame(renderContext, skContext); + ASSERT_FALSE(result); +} + +/** + * @tc.name: CreateSurface + * @tc.desc: Test If CreateSurface Can Run + * @tc.type: FUNC + * @tc.require: issueIAH6OI + */ +HWTEST_F(RSDmaBufferSurfaceRenderNodeDrawableTest, CreateSurfaceTest, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + ASSERT_FALSE(surfaceDrawable_->surfaceHandlerUiFirst_->GetConsumer()); + ASSERT_FALSE(surfaceDrawable_->surface_); + bool result = surfaceDrawable_->CreateSurface(); + ASSERT_TRUE(result); + ASSERT_TRUE(surfaceDrawable_->surfaceHandlerUiFirst_->GetConsumer()); + ASSERT_TRUE(surfaceDrawable_->surface_); + + surfaceDrawable_->surface_ = nullptr; + result = surfaceDrawable_->CreateSurface(); + ASSERT_TRUE(result); + ASSERT_TRUE(surfaceDrawable_->surfaceHandlerUiFirst_->GetConsumer()); + ASSERT_TRUE(surfaceDrawable_->surface_); + result = surfaceDrawable_->CreateSurface(); + ASSERT_TRUE(result); +} + +/** + * @tc.name: DrawUIFirstCacheWithDma + * @tc.desc: Test If DrawUIFirstCacheWithDma Can Run + * @tc.type: FUNC + * @tc.require: issueIAH6OI + */ +HWTEST_F(RSDmaBufferSurfaceRenderNodeDrawableTest, DrawUIFirstCacheWithDmaTest, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + auto surfaceParams = static_cast(surfaceDrawable_->renderParams_.get()); + ASSERT_NE(surfaceParams, nullptr); + bool result = surfaceDrawable_->DrawUIFirstCacheWithDma(*canvas_, *surfaceParams); + ASSERT_FALSE(result); + + surfaceDrawable_->surfaceHandlerUiFirst_->bufferAvailableCount_ = DEFAULT_CANVAS_SIZE; + result = surfaceDrawable_->DrawUIFirstCacheWithDma(*canvas_, *surfaceParams); + ASSERT_FALSE(result); + surfaceDrawable_->surfaceHandlerUiFirst_->buffer_.buffer = OHOS::SurfaceBuffer::Create(); + result = surfaceDrawable_->DrawUIFirstCacheWithDma(*canvas_, *surfaceParams); + ASSERT_FALSE(result); + + surfaceDrawable_->surfaceHandlerUiFirst_->bufferAvailableCount_ = 0; + RSUniRenderThread::Instance().uniRenderEngine_ = std::make_shared(); + result = surfaceDrawable_->DrawUIFirstCacheWithDma(*canvas_, *surfaceParams); + ASSERT_TRUE(result); + RSUniRenderThread::Instance().uniRenderEngine_ = nullptr; + surfaceParams->isHardwareEnabled_ = true; + result = surfaceDrawable_->DrawUIFirstCacheWithDma(*canvas_, *surfaceParams); + ASSERT_TRUE(result); +} + +/** + * @tc.name: DrawDmaBufferWithGPU + * @tc.desc: Test If DrawDmaBufferWithGPU Can Run + * @tc.type: FUNC + * @tc.require: issueIAH6OI + */ +HWTEST_F(RSDmaBufferSurfaceRenderNodeDrawableTest, DrawDmaBufferWithGPUTest, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + surfaceDrawable_->surfaceHandlerUiFirst_->buffer_.buffer = OHOS::SurfaceBuffer::Create(); + RSUniRenderThread::Instance().uniRenderEngine_ = std::make_shared(); + surfaceDrawable_->DrawDmaBufferWithGPU(*canvas_); + ASSERT_TRUE(surfaceDrawable_->surfaceHandlerUiFirst_->GetBuffer()); + RSUniRenderThread::Instance().uniRenderEngine_ = nullptr; +} + +/** + * @tc.name: ClipRoundRect + * @tc.desc: Test If ClipRoundRect Can Run + * @tc.type: FUNC + * @tc.require: issueIAH6OI + */ +HWTEST_F(RSDmaBufferSurfaceRenderNodeDrawableTest, ClipRoundRectTest, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + ASSERT_NE(drawingCanvas_, nullptr); + ASSERT_FALSE(!surfaceDrawable_->uifirstRenderParams_); + surfaceDrawable_->ClipRoundRect(*drawingCanvas_); + surfaceDrawable_->uifirstRenderParams_ = nullptr; + surfaceDrawable_->ClipRoundRect(*drawingCanvas_); + ASSERT_TRUE(!surfaceDrawable_->uifirstRenderParams_); +} + +/** + * @tc.name: ClearBufferQueue + * @tc.desc: Test If ClearBufferQueue Can Run + * @tc.type: FUNC + * @tc.require: issueIAH6OI + */ +HWTEST_F(RSDmaBufferSurfaceRenderNodeDrawableTest, ClearBufferQueueTest, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + surfaceDrawable_->ClearBufferQueue(); + surfaceDrawable_->CreateSurface(); + ASSERT_TRUE(surfaceDrawable_->surfaceHandlerUiFirst_->GetConsumer()); + ASSERT_TRUE(surfaceDrawable_->surface_); + surfaceDrawable_->ClearBufferQueue(); + ASSERT_FALSE(surfaceDrawable_->surfaceHandlerUiFirst_->GetConsumer()); + ASSERT_FALSE(surfaceDrawable_->surface_); +} +} diff --git a/rosen/test/render_service/render_service/unittest/drawable/rs_ui_first_surface_render_node_drawable_test.cpp b/rosen/test/render_service/render_service/unittest/drawable/rs_ui_first_surface_render_node_drawable_test.cpp index d0cd012ff0..fccb1c356f 100644 --- a/rosen/test/render_service/render_service/unittest/drawable/rs_ui_first_surface_render_node_drawable_test.cpp +++ b/rosen/test/render_service/render_service/unittest/drawable/rs_ui_first_surface_render_node_drawable_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_uifirst_manager.h" #include "pipeline/rs_uni_render_thread.h" using namespace testing; @@ -88,14 +89,30 @@ HWTEST_F(RSUIFirstSurfaceRenderNodeDrawableTest, GetCacheSurfaceTest, TestSize.L if (surfaceDrawable_ == nullptr) { return; } - uint32_t threadIndex = 1; - bool needCheckThread = true; + uint32_t threadIndex = 0; + bool needCheckThread = false; bool releaseAfterGet = true; auto result = surfaceDrawable_->GetCacheSurface(threadIndex, needCheckThread, releaseAfterGet); EXPECT_EQ(result, nullptr); + ASSERT_FALSE(surfaceDrawable_->cacheSurface_); + + releaseAfterGet = false; + surfaceDrawable_->cacheSurface_ = std::make_shared(); + ASSERT_TRUE(surfaceDrawable_->cacheSurface_); + result = surfaceDrawable_->GetCacheSurface(threadIndex, needCheckThread, releaseAfterGet); + EXPECT_NE(result, nullptr); needCheckThread = true; - releaseAfterGet = true; + uint32_t index = surfaceDrawable_->cacheSurfaceThreadIndex_; + surfaceDrawable_->cacheSurfaceThreadIndex_ = threadIndex; + result = surfaceDrawable_->GetCacheSurface(threadIndex, needCheckThread, releaseAfterGet); + EXPECT_NE(result, nullptr); + surfaceDrawable_->cacheSurfaceThreadIndex_ = index; + ASSERT_FALSE(surfaceDrawable_->cacheSurfaceThreadIndex_ == threadIndex); + + result = surfaceDrawable_->GetCacheSurface(threadIndex, needCheckThread, releaseAfterGet); + EXPECT_EQ(result, nullptr); + surfaceDrawable_->cacheSurface_ = nullptr; result = surfaceDrawable_->GetCacheSurface(threadIndex, needCheckThread, releaseAfterGet); EXPECT_EQ(result, nullptr); } @@ -142,15 +159,16 @@ HWTEST_F(RSUIFirstSurfaceRenderNodeDrawableTest, DrawCacheSurfaceTest, TestSize. Vector2f boundSize; uint32_t threadIndex = 1; bool isUIFirst = false; - Drawing::Canvas* drawingCanvas = new Drawing::Canvas(DEFAULT_CANVAS_SIZE, DEFAULT_CANVAS_SIZE); auto rscanvas = static_cast(drawingCanvas); auto result = surfaceDrawable_->DrawCacheSurface(*rscanvas, boundSize, threadIndex, isUIFirst); EXPECT_FALSE(result); - - surfaceDrawable_->boundsWidth_ = 0; - surfaceDrawable_->boundsHeight_ = 0; + surfaceDrawable_->boundsWidth_ = 1.f; + result = surfaceDrawable_->DrawCacheSurface(*rscanvas, boundSize, threadIndex, isUIFirst); + EXPECT_FALSE(result); + + surfaceDrawable_->boundsHeight_ = 1.f; result = surfaceDrawable_->DrawCacheSurface(*rscanvas, boundSize, threadIndex, isUIFirst); EXPECT_FALSE(result); } @@ -165,6 +183,16 @@ HWTEST_F(RSUIFirstSurfaceRenderNodeDrawableTest, NeedInitCacheSurfaceTest, TestS { auto result = surfaceDrawable_->NeedInitCacheSurface(); EXPECT_TRUE(result); + ASSERT_FALSE(surfaceDrawable_->cacheSurface_); + + surfaceDrawable_->cacheSurface_ = std::make_shared(); + result = surfaceDrawable_->NeedInitCacheSurface(); + EXPECT_TRUE(result); + ASSERT_FALSE(surfaceDrawable_->cacheSurface_->GetCanvas()); + + surfaceDrawable_->cacheSurface_->cachedCanvas_ = std::make_shared(); + result = surfaceDrawable_->NeedInitCacheSurface(); + ASSERT_FALSE(result); } /** @@ -252,8 +280,151 @@ HWTEST_F(RSUIFirstSurfaceRenderNodeDrawableTest, DrawUIFirstCacheTest, TestSize. auto rscanvas = static_cast(drawingCanvas); auto result = surfaceDrawable_->DrawUIFirstCache(*rscanvas, true); EXPECT_EQ(result, false); + ASSERT_FALSE(surfaceDrawable_->HasCachedTexture()); result = surfaceDrawable_->DrawUIFirstCache(*rscanvas, false); EXPECT_EQ(result, false); + + surfaceDrawable_->isTextureValid_.store(true); + ASSERT_TRUE(surfaceDrawable_->HasCachedTexture()); + result = surfaceDrawable_->DrawUIFirstCache(*rscanvas, false); + EXPECT_EQ(result, false); + surfaceDrawable_->isTextureValid_.store(false); +} + +/** + * @tc.name: DrawUIFirstCacheWithStarting + * @tc.desc: Test If DrawUIFirstCacheWithStarting Can Run + * @tc.type: FUNC + * @tc.require: issueIAH6OI + */ +HWTEST_F(RSUIFirstSurfaceRenderNodeDrawableTest, DrawUIFirstCacheWithStartingTest, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + Drawing::Canvas* drawingCanvas = new Drawing::Canvas(DEFAULT_CANVAS_SIZE, DEFAULT_CANVAS_SIZE); + auto rscanvas = static_cast(drawingCanvas); + NodeId id = 0; + auto result = surfaceDrawable_->DrawUIFirstCacheWithStarting(*rscanvas, id); + ASSERT_FALSE(result); + + id = 65535; // for test + surfaceDrawable_->isTextureValid_.store(true); + result = surfaceDrawable_->DrawUIFirstCacheWithStarting(*rscanvas, id); + ASSERT_FALSE(result); + ASSERT_FALSE(RSRenderNodeDrawableAdapter::RenderNodeDrawableCache_.empty()); +} + +#if defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK) +/** + * @tc.name: UpdateBackendTexture + * @tc.desc: Test If UpdateBackendTexture Can Run + * @tc.type: FUNC + * @tc.require: issueIAH6OI + */ +HWTEST_F(RSUIFirstSurfaceRenderNodeDrawableTest, UpdateBackendTextureTest, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + surfaceDrawable_->UpdateBackendTexture(); + ASSERT_FALSE(surfaceDrawable_->cacheSurface_); + + surfaceDrawable_->cacheSurface_ = std::make_shared(); + surfaceDrawable_->UpdateBackendTexture(); + ASSERT_TRUE(surfaceDrawable_->cacheSurface_); +} +#endif + +/** + * @tc.name: InitCacheSurface + * @tc.desc: Test If InitCacheSurface Can Run + * @tc.type: FUNC + * @tc.require: issueIAH6OI + */ +HWTEST_F(RSUIFirstSurfaceRenderNodeDrawableTest, InitCacheSurfaceTest, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + Drawing::GPUContext* gpuContext = new Drawing::GPUContext(); + RSSurfaceRenderNodeDrawable::ClearCacheSurfaceFunc func; + uint32_t threadIndex = 0; + surfaceDrawable_->InitCacheSurface(gpuContext, func, threadIndex); + ASSERT_FALSE(surfaceDrawable_->clearCacheSurfaceFunc_); + + func = [](std::shared_ptr&& oldSurface, std::shared_ptr&& newSurface, + uint32_t width, uint32_t height) {}; + surfaceDrawable_->InitCacheSurface(gpuContext, func, threadIndex); + ASSERT_TRUE(surfaceDrawable_->clearCacheSurfaceFunc_); + + surfaceDrawable_->cacheSurface_ = std::make_shared(); + surfaceDrawable_->InitCacheSurface(gpuContext, func, threadIndex); + delete gpuContext; + gpuContext = nullptr; + surfaceDrawable_->InitCacheSurface(gpuContext, func, threadIndex); + ASSERT_FALSE(surfaceDrawable_->cacheSurface_); +} + +/** + * @tc.name: GetGravityTranslate + * @tc.desc: Test If GetGravityTranslate Can Run + * @tc.type: FUNC + * @tc.require: issueIAH6OI + */ +HWTEST_F(RSUIFirstSurfaceRenderNodeDrawableTest, GetGravityTranslateTest, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + Vector2f res = surfaceDrawable_->GetGravityTranslate(1.f, 1.f); + ASSERT_EQ(res, Vector2f(0, 0)); +} + +/** + * @tc.name: ClearCacheSurfaceOnly + * @tc.desc: Test If ClearCacheSurfaceOnly Can Run + * @tc.type: FUNC + * @tc.require: issueIAH6OI + */ +HWTEST_F(RSUIFirstSurfaceRenderNodeDrawableTest, ClearCacheSurfaceOnlyTest, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + RSSurfaceRenderNodeDrawable::ClearCacheSurfaceFunc func; + surfaceDrawable_->ClearCacheSurfaceOnly(); + ASSERT_FALSE(surfaceDrawable_->cacheSurface_); + + surfaceDrawable_->cacheSurface_ = std::make_shared(); + ASSERT_TRUE(surfaceDrawable_->cacheSurface_); + surfaceDrawable_->ClearCacheSurfaceOnly(); + ASSERT_FALSE(surfaceDrawable_->clearCacheSurfaceFunc_); + + func = [](std::shared_ptr&& oldSurface, std::shared_ptr&& newSurface, + uint32_t width, uint32_t height) {}; + surfaceDrawable_->clearCacheSurfaceFunc_ = func; + surfaceDrawable_->ClearCacheSurfaceOnly(); + ASSERT_TRUE(surfaceDrawable_->clearCacheSurfaceFunc_); +} + +/** + * @tc.name: ClearCacheSurfaceInThread + * @tc.desc: Test If ClearCacheSurfaceInThread Can Run + * @tc.type: FUNC + * @tc.require: issueIAH6OI + */ +HWTEST_F(RSUIFirstSurfaceRenderNodeDrawableTest, ClearCacheSurfaceInThreadTest, TestSize.Level1) +{ + ASSERT_NE(surfaceDrawable_, nullptr); + RSSurfaceRenderNodeDrawable::ClearCacheSurfaceFunc func; + surfaceDrawable_->ClearCacheSurfaceInThread(); + ASSERT_FALSE(surfaceDrawable_->UseDmaBuffer()); + ASSERT_FALSE(surfaceDrawable_->clearCacheSurfaceFunc_); + + func = [](std::shared_ptr&& oldSurface, std::shared_ptr&& newSurface, + uint32_t width, uint32_t height) {}; + surfaceDrawable_->clearCacheSurfaceFunc_ = func; + surfaceDrawable_->ClearCacheSurfaceInThread(); + ASSERT_TRUE(surfaceDrawable_->clearCacheSurfaceFunc_); + + std::string str = surfaceDrawable_->name_; + RSUifirstManager::Instance().useDmaBuffer_ = true; + surfaceDrawable_->name_ = "ScreenShotWindow"; + surfaceDrawable_->ClearCacheSurfaceInThread(); + ASSERT_TRUE(surfaceDrawable_->UseDmaBuffer()); + RSUifirstManager::Instance().useDmaBuffer_ = false; + surfaceDrawable_->name_ = str; } } From 30fe432555159da84bd4a23a5ae8f3f5540a5ab4 Mon Sep 17 00:00:00 2001 From: lishijie Date: Thu, 1 Aug 2024 10:41:17 +0800 Subject: [PATCH 58/74] change GetAppMemoryInMB Signed-off-by: lishijie Change-Id: I5df02c7d821e0272094df69b1d7ef293176d5b30 --- .../modules/render_service/core/pipeline/rs_main_thread.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 f502b66f19..e7c6de76f0 100644 --- a/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_main_thread.cpp @@ -3771,8 +3771,9 @@ void RSMainThread::AddToReleaseQueue(std::shared_ptr&& surface void RSMainThread::GetAppMemoryInMB(float& cpuMemSize, float& gpuMemSize) { - PostSyncTask([&cpuMemSize, &gpuMemSize, this]() { - gpuMemSize = MemoryManager::GetAppGpuMemoryInMB(GetRenderEngine()->GetRenderContext()->GetDrGPUContext()); + RSUniRenderThread::Instance().PostSyncTask([&cpuMemSize, &gpuMemSize] { + gpuMemSize = MemoryManager::GetAppGpuMemoryInMB( + RSUniRenderThread::Instance().GetRenderEngine()->GetRenderContext()->GetDrGPUContext()); cpuMemSize = MemoryTrack::Instance().GetAppMemorySizeInMB(); }); } From 9bf6c1196ff244674d3c1b9891d45a75a1540ae6 Mon Sep 17 00:00:00 2001 From: sunqizhen Date: Tue, 30 Jul 2024 21:11:46 +0800 Subject: [PATCH 59/74] =?UTF-8?q?=E7=81=AD=E5=B1=8F=E4=B8=8D=E7=BB=98?= =?UTF-8?q?=E5=88=B6=EF=BC=8C=E7=BB=B4=E6=B5=8B=E8=83=BD=E5=8A=9B=E5=A2=9E?= =?UTF-8?q?=E5=BC=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: sunqizhen --- .../core/drawable/rs_display_render_node_drawable.cpp | 11 ++++++----- .../src/render/rs_colorspace_convert.cpp | 4 ++-- .../src/transaction/rs_uiextension_data.cpp | 2 +- .../core/modifier/rs_extended_modifier.cpp | 3 +++ 4 files changed, 12 insertions(+), 8 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 18c2511cd0..2fae00d825 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 @@ -1523,15 +1523,16 @@ bool RSDisplayRenderNodeDrawable::SkipDisplayIfScreenOff() const return false; } // in certain cases such as wireless display, render skipping may be disabled. - if (screenManager->GetDisableRenderControlScreensCount() != 0) { - return false; - } ScreenId id = renderParams_->GetScreenId(); - if (!screenManager->IsScreenPowerOff(id)) { + auto disableRenderControlScreensCount = screenManager->GetDisableRenderControlScreensCount(); + auto isScreenOff = screenManager->IsScreenPowerOff(id); + RS_TRACE_NAME_FMT("RSDisplayRenderNodeDrawable Screen_[%" PRIu64 "] disableRenderControl:[%d], PowerOff:[%d]", + id, disableRenderControlScreensCount, isScreenOff); + if (disableRenderControlScreensCount != 0 || !isScreenOff) { return false; } if (screenManager->GetPowerOffNeedProcessOneFrame()) { - RS_LOGD("RSDisplayRenderNodeDrawable::SkipRenderFrameIfScreenOff screen_%{public}" PRIu64 + RS_LOGI("RSDisplayRenderNodeDrawable::SkipRenderFrameIfScreenOff screen_%{public}" PRIu64 " power off, one more frame.", id); screenManager->ResetPowerOffNeedProcessOneFrame(); return 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 84fe06149e..5b6ea1ca05 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 @@ -91,11 +91,11 @@ bool RSColorSpaceConvert::SetColorSpaceConverterDisplayParameter(const sptr DmaMemAlloc(const int32_t& width, const int32_t& heig return nullptr; } void* nativeBuffer = surfaceBuffer.GetRefPtr(); + if (!nativeBuffer) { + return nullptr; + } OHOS::RefBase *ref = reinterpret_cast(nativeBuffer); ref->IncStrongRef(ref); int32_t bufferSize = pixelMap->GetByteCount(); From 7dc21efc9a774fd8176d6c234d0e5cd649c2ba3a Mon Sep 17 00:00:00 2001 From: lw19901203 Date: Thu, 1 Aug 2024 17:35:58 +0800 Subject: [PATCH 60/74] fix js interface Signed-off-by: lw19901203 --- .../graphic/drawing/canvas_napi/js_canvas.cpp | 4 +- .../image_filter_napi/js_image_filter.cpp | 4 +- .../graphic/drawing/path_napi/js_path.cpp | 9 ++++- .../drawing/roundRect_napi/js_roundrect.cpp | 12 +++--- .../drawing/text_blob_napi/js_text_blob.cpp | 40 +++++++++++-------- 5 files changed, 42 insertions(+), 27 deletions(-) diff --git a/interfaces/kits/napi/graphic/drawing/canvas_napi/js_canvas.cpp b/interfaces/kits/napi/graphic/drawing/canvas_napi/js_canvas.cpp index 32ad9df3bf..d94c2daac9 100644 --- a/interfaces/kits/napi/graphic/drawing/canvas_napi/js_canvas.cpp +++ b/interfaces/kits/napi/graphic/drawing/canvas_napi/js_canvas.cpp @@ -1594,7 +1594,7 @@ napi_value JsCanvas::OnClipRegion(napi_env env, napi_callback_info info) } int32_t jsClipOp = 0; - GET_INT32_CHECK_GE_ZERO_PARAM(ARGC_ONE, jsClipOp); + GET_ENUM_PARAM(ARGC_ONE, jsClipOp, 0, static_cast(ClipOp::INTERSECT)); m_canvas->ClipRegion(*region, static_cast(jsClipOp)); return nullptr; @@ -1823,7 +1823,7 @@ napi_value JsCanvas::OnClipRoundRect(napi_env env, napi_callback_info info) } int32_t clipOpInt = 0; - GET_INT32_CHECK_GE_ZERO_PARAM(ARGC_ONE, clipOpInt); + GET_ENUM_PARAM(ARGC_ONE, clipOpInt, 0, static_cast(ClipOp::INTERSECT)); if (argc == ARGC_TWO) { m_canvas->ClipRoundRect(jsRoundRect->GetRoundRect(), static_cast(clipOpInt)); diff --git a/interfaces/kits/napi/graphic/drawing/image_filter_napi/js_image_filter.cpp b/interfaces/kits/napi/graphic/drawing/image_filter_napi/js_image_filter.cpp index 936b686a42..97dba1e55b 100755 --- a/interfaces/kits/napi/graphic/drawing/image_filter_napi/js_image_filter.cpp +++ b/interfaces/kits/napi/graphic/drawing/image_filter_napi/js_image_filter.cpp @@ -119,7 +119,7 @@ napi_value JsImageFilter::CreateBlurImageFilter(napi_env env, napi_callback_info JsImageFilter *jsImageFilter = nullptr; if (argc > ARGC_THREE) { - napi_unwrap(env, argv[ARGC_THREE], reinterpret_cast(&jsImageFilter)); + GET_UNWRAP_PARAM_OR_NULL(ARGC_THREE, jsImageFilter); } std::shared_ptr imageFilter = (jsImageFilter == nullptr) ? @@ -141,7 +141,7 @@ napi_value JsImageFilter::CreateFromColorFilter(napi_env env, napi_callback_info JsImageFilter *jsImageFilter = nullptr; if (argc > ARGC_ONE) { - napi_unwrap(env, argv[ARGC_ONE], reinterpret_cast(&jsImageFilter)); + GET_UNWRAP_PARAM_OR_NULL(ARGC_ONE, jsImageFilter); } std::shared_ptr colorFilter = jsColorFilter->GetColorFilter(); 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 bb645891de..2bc6de4b54 100644 --- a/interfaces/kits/napi/graphic/drawing/path_napi/js_path.cpp +++ b/interfaces/kits/napi/graphic/drawing/path_napi/js_path.cpp @@ -779,6 +779,13 @@ napi_value JsPath::OnGetPositionAndTangent(napi_env env, napi_callback_info info tangent = Drawing::Point(endPoint[ARGC_ZERO], endPoint[ARGC_ONE]); bool result = m_path->GetPositionAndTangent(distance, position, tangent, forceClosed); + if (napi_set_named_property(env, argv[ARGC_TWO], "x", CreateJsNumber(env, position.GetX())) != napi_ok || + napi_set_named_property(env, argv[ARGC_TWO], "y", CreateJsNumber(env, position.GetY())) != napi_ok || + napi_set_named_property(env, argv[ARGC_THREE], "x", CreateJsNumber(env, tangent.GetX())) != napi_ok || + napi_set_named_property(env, argv[ARGC_THREE], "y", CreateJsNumber(env, tangent.GetY())) != napi_ok) { + return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, + "JsPath::OnGetPositionAndTangent Cannot fill 'position' and 'tangent' Point type."); + } return CreateJsNumber(env, result); } @@ -1097,7 +1104,7 @@ napi_value JsPath::OnIsClosed(napi_env env, napi_callback_info info) return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, "Invalid params."); } - bool result = m_path->IsClosed(true); + bool result = m_path->IsClosed(false); return CreateJsNumber(env, result); } diff --git a/interfaces/kits/napi/graphic/drawing/roundRect_napi/js_roundrect.cpp b/interfaces/kits/napi/graphic/drawing/roundRect_napi/js_roundrect.cpp index e60f24b8a5..b185297df0 100755 --- a/interfaces/kits/napi/graphic/drawing/roundRect_napi/js_roundrect.cpp +++ b/interfaces/kits/napi/graphic/drawing/roundRect_napi/js_roundrect.cpp @@ -118,14 +118,14 @@ napi_value JsRoundRect ::OnSetCorner(napi_env env, napi_callback_info info) { napi_value argv[ARGC_THREE] = { nullptr }; CHECK_PARAM_NUMBER_WITHOUT_OPTIONAL_PARAMS(argv, ARGC_THREE); - RoundRect ::CornerPos pos; - ConvertFromJsValue(env, argv[0], pos); + int32_t pos = 0; + GET_ENUM_PARAM(ARGC_ZERO, pos, 0, static_cast(RoundRect::CornerPos::CORNER_NUMBER)); double x = 0; GET_DOUBLE_PARAM(ARGC_ONE, x); double y = 0; GET_DOUBLE_PARAM(ARGC_TWO, y); - m_roundRect.SetCornerRadius(pos, x, y); + m_roundRect.SetCornerRadius(static_cast(pos), x, y); return nullptr; } @@ -140,9 +140,9 @@ napi_value JsRoundRect ::OnGetCorner(napi_env env, napi_callback_info info) { napi_value argv[ARGC_ONE] = { nullptr }; CHECK_PARAM_NUMBER_WITHOUT_OPTIONAL_PARAMS(argv, ARGC_ONE); - RoundRect ::CornerPos pos; - ConvertFromJsValue(env, argv[0], pos); - auto point = m_roundRect.GetCornerRadius(pos); + int32_t pos = 0; + GET_ENUM_PARAM(ARGC_ZERO, pos, 0, static_cast(RoundRect::CornerPos::CORNER_NUMBER)); + auto point = m_roundRect.GetCornerRadius(static_cast(pos)); return ConvertPointToJsValue(env, point); } diff --git a/interfaces/kits/napi/graphic/drawing/text_blob_napi/js_text_blob.cpp b/interfaces/kits/napi/graphic/drawing/text_blob_napi/js_text_blob.cpp index adfcddd000..2d05a61862 100644 --- a/interfaces/kits/napi/graphic/drawing/text_blob_napi/js_text_blob.cpp +++ b/interfaces/kits/napi/graphic/drawing/text_blob_napi/js_text_blob.cpp @@ -304,26 +304,42 @@ napi_value JsTextBlob::MakeFromPosText(napi_env env, napi_callback_info info) uint32_t len = 0; GET_UINT32_PARAM(ARGC_ONE, len); + size_t bufferLen = static_cast(len); + char* buffer = new(std::nothrow) char[bufferLen + 1]; + if (!buffer) { + ROSEN_LOGE("JsTextBlob::MakeFromPosText: failed to create buffer"); + return nullptr; + } + if (napi_get_value_string_utf8(env, argv[ARGC_ZERO], buffer, bufferLen + 1, &bufferLen) != napi_ok) { + delete[] buffer; + return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, "Incorrect Argv[0] type."); + } + napi_value array = argv[ARGC_TWO]; uint32_t pointsSize = 0; if (napi_get_array_length(env, array, &pointsSize) != napi_ok) { + delete[] buffer; return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, "Incorrect Argv[2]."); } - if (pointsSize == 0) { - ROSEN_LOGE("JsTextBlob::MakeFromPosText: points array is empty"); - return nullptr; + if (pointsSize == 0 || bufferLen == 0) { + delete[] buffer; + return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, "Argv[0] is empty."); } - if (len != pointsSize) { - ROSEN_LOGE("JsTextBlob::MakeFromPosText: string length does not match points array length"); - return nullptr; + if (len != pointsSize || len != bufferLen) { + delete[] buffer; + return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, + "string length does not match points array length."); } Point* points = new(std::nothrow) Point[pointsSize]; if (!points) { + delete[] buffer; ROSEN_LOGE("JsTextBlob::MakeFromPosText: failed to create Point"); return nullptr; } if (!MakePoints(env, points, pointsSize, array)) { + delete[] buffer; + delete[] points; ROSEN_LOGE("JsTextBlob::MakeFromPosText: Argv[2] is invalid"); return nullptr; } @@ -332,19 +348,11 @@ napi_value JsTextBlob::MakeFromPosText(napi_env env, napi_callback_info info) GET_UNWRAP_PARAM(ARGC_THREE, jsFont); std::shared_ptr font = jsFont->GetFont(); if (font == nullptr) { + delete[] buffer; + delete[] points; ROSEN_LOGE("JsTextBlob::MakeFromPosText: font is nullptr"); return nullptr; } - - size_t bufferLen = static_cast(len); - char* buffer = new(std::nothrow) char[bufferLen + 1]; - if (!buffer) { - ROSEN_LOGE("JsTextBlob::MakeFromPosText: failed to create buffer"); - return nullptr; - } - if (napi_get_value_string_utf8(env, argv[ARGC_ZERO], buffer, bufferLen + 1, &bufferLen) != napi_ok) { - return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, "Incorrect Argv[0] type."); - } return getJsTextBlob(buffer, bufferLen, points, font, env); } From d47e44f2c682514da7ce9590919d25ab39c73b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E5=8D=97?= Date: Thu, 1 Aug 2024 09:47:30 +0000 Subject: [PATCH 61/74] =?UTF-8?q?=E5=9C=A8=E6=A8=A1=E7=B3=8A=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=E5=8F=98=E5=8C=96=E6=97=B6=EF=BC=8C=E4=B8=8D=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E8=B7=B3=E5=B8=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 江南 --- .../render_service_base/src/drawable/rs_property_drawable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/modules/render_service_base/src/drawable/rs_property_drawable.cpp b/rosen/modules/render_service_base/src/drawable/rs_property_drawable.cpp index 1abe57103b..83d60bd38f 100644 --- a/rosen/modules/render_service_base/src/drawable/rs_property_drawable.cpp +++ b/rosen/modules/render_service_base/src/drawable/rs_property_drawable.cpp @@ -282,7 +282,7 @@ void RSFilterDrawable::ClearCacheIfNeeded() cacheUpdateInterval_ = 0; } - isSkipFrame_ = isLargeArea_ && canSkipFrame_; + isSkipFrame_ = isLargeArea_ && canSkipFrame_ && !filterRegionChanged_; // no valid cache if (lastCacheType_ == FilterCacheType::NONE) { From c0cfc59758017ae4589805a7519f795ef1b8d9e1 Mon Sep 17 00:00:00 2001 From: dreamond_wxy Date: Thu, 1 Aug 2024 09:49:28 +0000 Subject: [PATCH 62/74] update rosen/modules/render_service_base/include/transaction/rs_transaction_proxy.h. Signed-off-by: dreamond_wxy --- .../include/transaction/rs_transaction_proxy.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/rosen/modules/render_service_base/include/transaction/rs_transaction_proxy.h b/rosen/modules/render_service_base/include/transaction/rs_transaction_proxy.h index b0449e3cd9..971ab5cf9d 100644 --- a/rosen/modules/render_service_base/include/transaction/rs_transaction_proxy.h +++ b/rosen/modules/render_service_base/include/transaction/rs_transaction_proxy.h @@ -68,8 +68,6 @@ public: void SetParentPid(const int32_t parentPid); - bool IsRemoteCommandEmpty(); - uint32_t GetTransactionDataIndex(); private: From 031e2cbbb7c0acfb8e603ecb55684eb893ad9ecd Mon Sep 17 00:00:00 2001 From: Vadim Rozhkov Date: Thu, 25 Jul 2024 19:52:39 +0300 Subject: [PATCH 63/74] Added dumpers for modifiers Signed-off-by: Vadim Rozhkov Change-Id: I8ca5252415c97dfa67d83a758db6c173e62946fd --- .../2d_graphics/include/recording/draw_cmd.h | 3 + .../include/recording/draw_cmd_list.h | 2 + .../src/drawing/recording/draw_cmd.cpp | 67 +++++ .../src/drawing/recording/draw_cmd_list.cpp | 73 +---- .../include/modifier/rs_modifier_type.h | 268 +++++++++--------- .../include/modifier/rs_render_modifier.h | 5 + .../include/modifier/rs_render_property.h | 50 +++- .../include/pipeline/rs_render_node.h | 3 +- .../src/modifier/rs_render_property.cpp | 108 +++++++ .../src/pipeline/rs_render_node.cpp | 61 ++-- .../pipeline/rs_base_render_node_test.cpp | 30 -- .../pipeline/rs_render_node_test2.cpp | 20 +- 12 files changed, 412 insertions(+), 278 deletions(-) diff --git a/rosen/modules/2d_graphics/include/recording/draw_cmd.h b/rosen/modules/2d_graphics/include/recording/draw_cmd.h index 30db5c40e6..9de8422041 100644 --- a/rosen/modules/2d_graphics/include/recording/draw_cmd.h +++ b/rosen/modules/2d_graphics/include/recording/draw_cmd.h @@ -107,6 +107,9 @@ public: virtual void Playback(Canvas* canvas, const Rect* rect) = 0; virtual void SetNodeId(NodeId id) {} + virtual void Dump(std::string& out); + + std::string GetOpDesc(); static void SetBaseCallback( std::function image)> holdDrawingImagefunc); diff --git a/rosen/modules/2d_graphics/include/recording/draw_cmd_list.h b/rosen/modules/2d_graphics/include/recording/draw_cmd_list.h index e9a76028ad..9de0efca7f 100644 --- a/rosen/modules/2d_graphics/include/recording/draw_cmd_list.h +++ b/rosen/modules/2d_graphics/include/recording/draw_cmd_list.h @@ -183,6 +183,8 @@ public: void UpdateNodeIdToPicture(NodeId nodeId); size_t CountTextBlobNum(); + + void Dump(std::string& out); private: void ClearCache(); void GenerateCacheByVector(Canvas* canvas, const Rect* rect); diff --git a/rosen/modules/2d_graphics/src/drawing/recording/draw_cmd.cpp b/rosen/modules/2d_graphics/src/drawing/recording/draw_cmd.cpp index 40efeb6f73..277d6610fe 100644 --- a/rosen/modules/2d_graphics/src/drawing/recording/draw_cmd.cpp +++ b/rosen/modules/2d_graphics/src/drawing/recording/draw_cmd.cpp @@ -39,6 +39,63 @@ namespace OHOS { namespace Rosen { namespace Drawing { +std::unordered_map typeOpDes = { + { DrawOpItem::OPITEM_HEAD, "OPITEM_HEAD"}, + { DrawOpItem::POINT_OPITEM, "POINT_OPITEM" }, + { DrawOpItem::POINTS_OPITEM, "POINTS_OPITEM" }, + { DrawOpItem::LINE_OPITEM, "LINE_OPITEM" }, + { DrawOpItem::RECT_OPITEM, "RECT_OPITEM" }, + { DrawOpItem::ROUND_RECT_OPITEM, "ROUND_RECT_OPITEM" }, + { DrawOpItem::NESTED_ROUND_RECT_OPITEM, "NESTED_ROUND_RECT_OPITEM" }, + { DrawOpItem::ARC_OPITEM, "ARC_OPITEM" }, + { DrawOpItem::PIE_OPITEM, "PIE_OPITEM" }, + { DrawOpItem::OVAL_OPITEM, "OVAL_OPITEM" }, + { DrawOpItem::CIRCLE_OPITEM, "CIRCLE_OPITEM" }, + { DrawOpItem::PATH_OPITEM, "PATH_OPITEM" }, + { DrawOpItem::BACKGROUND_OPITEM, "BACKGROUND_OPITEM" }, + { DrawOpItem::SHADOW_OPITEM, "SHADOW_OPITEM" }, + { DrawOpItem::SHADOW_STYLE_OPITEM, "SHADOW_STYLE_OPITEM" }, + { DrawOpItem::COLOR_OPITEM, "COLOR_OPITEM" }, + { DrawOpItem::IMAGE_NINE_OPITEM, "IMAGE_NINE_OPITEM" }, + { DrawOpItem::IMAGE_LATTICE_OPITEM, "IMAGE_LATTICE_OPITEM" }, + { DrawOpItem::ATLAS_OPITEM, "ATLAS_OPITEM" }, + { DrawOpItem::BITMAP_OPITEM, "BITMAP_OPITEM" }, + { DrawOpItem::IMAGE_OPITEM, "IMAGE_OPITEM" }, + { DrawOpItem::IMAGE_RECT_OPITEM, "IMAGE_RECT_OPITEM" }, + { DrawOpItem::PICTURE_OPITEM, "PICTURE_OPITEM" }, + { DrawOpItem::TEXT_BLOB_OPITEM, "TEXT_BLOB_OPITEM" }, + { DrawOpItem::SYMBOL_OPITEM, "SYMBOL_OPITEM" }, + { DrawOpItem::CLIP_RECT_OPITEM, "CLIP_RECT_OPITEM" }, + { DrawOpItem::CLIP_IRECT_OPITEM, "CLIP_IRECT_OPITEM" }, + { DrawOpItem::CLIP_ROUND_RECT_OPITEM, "CLIP_ROUND_RECT_OPITEM" }, + { DrawOpItem::CLIP_PATH_OPITEM, "CLIP_PATH_OPITEM" }, + { DrawOpItem::CLIP_REGION_OPITEM, "CLIP_REGION_OPITEM" }, + { DrawOpItem::SET_MATRIX_OPITEM, "SET_MATRIX_OPITEM" }, + { DrawOpItem::RESET_MATRIX_OPITEM, "RESET_MATRIX_OPITEM" }, + { DrawOpItem::CONCAT_MATRIX_OPITEM, "CONCAT_MATRIX_OPITEM" }, + { DrawOpItem::TRANSLATE_OPITEM, "TRANSLATE_OPITEM" }, + { DrawOpItem::SCALE_OPITEM, "SCALE_OPITEM" }, + { DrawOpItem::ROTATE_OPITEM, "ROTATE_OPITEM" }, + { DrawOpItem::SHEAR_OPITEM, "SHEAR_OPITEM" }, + { DrawOpItem::FLUSH_OPITEM, "FLUSH_OPITEM" }, + { DrawOpItem::CLEAR_OPITEM, "CLEAR_OPITEM" }, + { DrawOpItem::SAVE_OPITEM, "SAVE_OPITEM" }, + { DrawOpItem::SAVE_LAYER_OPITEM, "SAVE_LAYER_OPITEM" }, + { DrawOpItem::RESTORE_OPITEM, "RESTORE_OPITEM" }, + { DrawOpItem::DISCARD_OPITEM, "DISCARD_OPITEM" }, + { DrawOpItem::CLIP_ADAPTIVE_ROUND_RECT_OPITEM, "CLIP_ADAPTIVE_ROUND_RECT_OPITEM" }, + { DrawOpItem::IMAGE_WITH_PARM_OPITEM, "IMAGE_WITH_PARM_OPITEM" }, + { DrawOpItem::PIXELMAP_WITH_PARM_OPITEM, "PIXELMAP_WITH_PARM_OPITEM" }, + { DrawOpItem::PIXELMAP_RECT_OPITEM, "PIXELMAP_RECT_OPITEM" }, + { DrawOpItem::REGION_OPITEM, "REGION_OPITEM" }, + { DrawOpItem::PATCH_OPITEM, "PATCH_OPITEM" }, + { DrawOpItem::EDGEAAQUAD_OPITEM, "EDGEAAQUAD_OPITEM" }, + { DrawOpItem::VERTICES_OPITEM, "VERTICES_OPITEM" }, + { DrawOpItem::IMAGE_SNAPSHOT_OPITEM, "IMAGE_SNAPSHOT_OPITEM" }, + { DrawOpItem::SURFACEBUFFER_OPITEM, "SURFACEBUFFER_OPITEM"}, + { DrawOpItem::DRAW_FUNC_OPITEM, "DRAW_FUNC_OPITEM"}, +}; + namespace { constexpr int TEXT_BLOB_CACHE_MARGIN = 10; constexpr float HIGH_CONTRAST_OFFSCREEN_THREASHOLD = 0.99f; @@ -223,6 +280,16 @@ void DrawOpItem::GenerateHandleFromPaint(CmdList& cmdList, const Paint& paint, P } } +std::string DrawOpItem::GetOpDesc() +{ + return typeOpDes[GetType()]; +} + +void DrawOpItem::Dump(std::string& out) +{ + out += typeOpDes[GetType()]; +} + GenerateCachedOpItemPlayer::GenerateCachedOpItemPlayer(DrawCmdList &cmdList, Canvas* canvas, const Rect* rect) : canvas_(canvas), rect_(rect), cmdList_(cmdList) {} diff --git a/rosen/modules/2d_graphics/src/drawing/recording/draw_cmd_list.cpp b/rosen/modules/2d_graphics/src/drawing/recording/draw_cmd_list.cpp index 0942c6b258..2563dd5ea1 100644 --- a/rosen/modules/2d_graphics/src/drawing/recording/draw_cmd_list.cpp +++ b/rosen/modules/2d_graphics/src/drawing/recording/draw_cmd_list.cpp @@ -27,63 +27,6 @@ namespace OHOS { namespace Rosen { namespace Drawing { -std::unordered_map typeOpDes = { - { DrawOpItem::OPITEM_HEAD, "OPITEM_HEAD"}, - { DrawOpItem::POINT_OPITEM, "POINT_OPITEM" }, - { DrawOpItem::POINTS_OPITEM, "POINTS_OPITEM" }, - { DrawOpItem::LINE_OPITEM, "LINE_OPITEM" }, - { DrawOpItem::RECT_OPITEM, "RECT_OPITEM" }, - { DrawOpItem::ROUND_RECT_OPITEM, "ROUND_RECT_OPITEM" }, - { DrawOpItem::NESTED_ROUND_RECT_OPITEM, "NESTED_ROUND_RECT_OPITEM" }, - { DrawOpItem::ARC_OPITEM, "ARC_OPITEM" }, - { DrawOpItem::PIE_OPITEM, "PIE_OPITEM" }, - { DrawOpItem::OVAL_OPITEM, "OVAL_OPITEM" }, - { DrawOpItem::CIRCLE_OPITEM, "CIRCLE_OPITEM" }, - { DrawOpItem::PATH_OPITEM, "PATH_OPITEM" }, - { DrawOpItem::BACKGROUND_OPITEM, "BACKGROUND_OPITEM" }, - { DrawOpItem::SHADOW_OPITEM, "SHADOW_OPITEM" }, - { DrawOpItem::SHADOW_STYLE_OPITEM, "SHADOW_STYLE_OPITEM" }, - { DrawOpItem::COLOR_OPITEM, "COLOR_OPITEM" }, - { DrawOpItem::IMAGE_NINE_OPITEM, "IMAGE_NINE_OPITEM" }, - { DrawOpItem::IMAGE_LATTICE_OPITEM, "IMAGE_LATTICE_OPITEM" }, - { DrawOpItem::ATLAS_OPITEM, "ATLAS_OPITEM" }, - { DrawOpItem::BITMAP_OPITEM, "BITMAP_OPITEM" }, - { DrawOpItem::IMAGE_OPITEM, "IMAGE_OPITEM" }, - { DrawOpItem::IMAGE_RECT_OPITEM, "IMAGE_RECT_OPITEM" }, - { DrawOpItem::PICTURE_OPITEM, "PICTURE_OPITEM" }, - { DrawOpItem::TEXT_BLOB_OPITEM, "TEXT_BLOB_OPITEM" }, - { DrawOpItem::SYMBOL_OPITEM, "SYMBOL_OPITEM" }, - { DrawOpItem::CLIP_RECT_OPITEM, "CLIP_RECT_OPITEM" }, - { DrawOpItem::CLIP_IRECT_OPITEM, "CLIP_IRECT_OPITEM" }, - { DrawOpItem::CLIP_ROUND_RECT_OPITEM, "CLIP_ROUND_RECT_OPITEM" }, - { DrawOpItem::CLIP_PATH_OPITEM, "CLIP_PATH_OPITEM" }, - { DrawOpItem::CLIP_REGION_OPITEM, "CLIP_REGION_OPITEM" }, - { DrawOpItem::SET_MATRIX_OPITEM, "SET_MATRIX_OPITEM" }, - { DrawOpItem::RESET_MATRIX_OPITEM, "RESET_MATRIX_OPITEM" }, - { DrawOpItem::CONCAT_MATRIX_OPITEM, "CONCAT_MATRIX_OPITEM" }, - { DrawOpItem::TRANSLATE_OPITEM, "TRANSLATE_OPITEM" }, - { DrawOpItem::SCALE_OPITEM, "SCALE_OPITEM" }, - { DrawOpItem::ROTATE_OPITEM, "ROTATE_OPITEM" }, - { DrawOpItem::SHEAR_OPITEM, "SHEAR_OPITEM" }, - { DrawOpItem::FLUSH_OPITEM, "FLUSH_OPITEM" }, - { DrawOpItem::CLEAR_OPITEM, "CLEAR_OPITEM" }, - { DrawOpItem::SAVE_OPITEM, "SAVE_OPITEM" }, - { DrawOpItem::SAVE_LAYER_OPITEM, "SAVE_LAYER_OPITEM" }, - { DrawOpItem::RESTORE_OPITEM, "RESTORE_OPITEM" }, - { DrawOpItem::DISCARD_OPITEM, "DISCARD_OPITEM" }, - { DrawOpItem::CLIP_ADAPTIVE_ROUND_RECT_OPITEM, "CLIP_ADAPTIVE_ROUND_RECT_OPITEM" }, - { DrawOpItem::IMAGE_WITH_PARM_OPITEM, "IMAGE_WITH_PARM_OPITEM" }, - { DrawOpItem::PIXELMAP_WITH_PARM_OPITEM, "PIXELMAP_WITH_PARM_OPITEM" }, - { DrawOpItem::PIXELMAP_RECT_OPITEM, "PIXELMAP_RECT_OPITEM" }, - { DrawOpItem::REGION_OPITEM, "REGION_OPITEM" }, - { DrawOpItem::PATCH_OPITEM, "PATCH_OPITEM" }, - { DrawOpItem::EDGEAAQUAD_OPITEM, "EDGEAAQUAD_OPITEM" }, - { DrawOpItem::VERTICES_OPITEM, "VERTICES_OPITEM" }, - { DrawOpItem::IMAGE_SNAPSHOT_OPITEM, "IMAGE_SNAPSHOT_OPITEM" }, - { DrawOpItem::SURFACEBUFFER_OPITEM, "SURFACEBUFFER_OPITEM"}, - { DrawOpItem::DRAW_FUNC_OPITEM, "DRAW_FUNC_OPITEM"}, -}; - std::shared_ptr DrawCmdList::CreateFromData(const CmdListData& data, bool isCopy) { auto cmdList = std::make_shared(DrawCmdList::UnmarshalMode::DEFERRED); @@ -199,13 +142,27 @@ std::string DrawCmdList::GetOpsWithDesc() const if (item == nullptr) { continue; } - desc += typeOpDes[item->GetType()]; + desc += item->GetOpDesc(); desc += "\n"; } LOGD("DrawCmdList::GetOpsWithDesc %{public}s, opitem sz: %{public}zu", desc.c_str(), drawOpItems_.size()); return desc; } +void DrawCmdList::Dump(std::string& out) +{ + for (auto& item : drawOpItems_) { + if (item == nullptr) { + continue; + } + item->Dump(out); + out += " "; + } + if (drawOpItems_.size() > 0) { + out.pop_back(); + } +} + void DrawCmdList::MarshallingDrawOps() { if (mode_ == DrawCmdList::UnmarshalMode::IMMEDIATE) { diff --git a/rosen/modules/render_service_base/include/modifier/rs_modifier_type.h b/rosen/modules/render_service_base/include/modifier/rs_modifier_type.h index 73b646da35..595dc32e15 100644 --- a/rosen/modules/render_service_base/include/modifier/rs_modifier_type.h +++ b/rosen/modules/render_service_base/include/modifier/rs_modifier_type.h @@ -203,140 +203,140 @@ enum class RSPropertyUnit : int16_t { }; const std::map RS_MODIFIER_TYPE_TO_STRING = { - { RSModifierType::INVALID, "invalid" }, - { RSModifierType::BOUNDS, "bounds" }, - { RSModifierType::FRAME, "frame" }, - { RSModifierType::POSITION_Z, "position_z" }, - { RSModifierType::PIVOT, "pivot" }, - { RSModifierType::PIVOT_Z, "pivot_z" }, - { RSModifierType::QUATERNION, "quaternion" }, - { RSModifierType::ROTATION, "rotation" }, - { RSModifierType::ROTATION_X, "rotation_x" }, - { RSModifierType::ROTATION_Y, "rotation_y" }, - { RSModifierType::CAMERA_DISTANCE, "camera_distance" }, - { RSModifierType::SCALE, "scale" }, - { RSModifierType::SKEW, "skew" }, - { RSModifierType::PERSP, "persp" }, - { RSModifierType::TRANSLATE, "translate" }, - { RSModifierType::TRANSLATE_Z, "translate_z" }, - { RSModifierType::SUBLAYER_TRANSFORM, "sublayer_transform" }, - { RSModifierType::CORNER_RADIUS, "corner_radius" }, - { RSModifierType::ALPHA, "alpha" }, - { RSModifierType::ALPHA_OFFSCREEN, "alpha_offscreen" }, - { RSModifierType::FOREGROUND_COLOR, "foreground_color" }, - { RSModifierType::BACKGROUND_COLOR, "background_color" }, - { RSModifierType::BACKGROUND_SHADER, "background_shader" }, - { RSModifierType::BG_IMAGE, "bg_image" }, - { RSModifierType::BG_IMAGE_INNER_RECT, "bg_image_inner_rect" }, - { RSModifierType::BG_IMAGE_WIDTH, "bg_image_width" }, - { RSModifierType::BG_IMAGE_HEIGHT, "bg_image_height" }, - { RSModifierType::BG_IMAGE_POSITION_X, "bg_image_position_x" }, - { RSModifierType::BG_IMAGE_POSITION_Y, "bg_image_position_y" }, - { RSModifierType::SURFACE_BG_COLOR, "surface_bg_color" }, - { RSModifierType::BORDER_COLOR, "border_color" }, - { RSModifierType::BORDER_WIDTH, "border_width" }, - { RSModifierType::BORDER_STYLE, "border_style" }, - { RSModifierType::BORDER_DASH_WIDTH, "border_dash_width" }, - { RSModifierType::BORDER_DASH_GAP, "border_dash_gap" }, - { RSModifierType::FILTER, "filter" }, - { RSModifierType::BACKGROUND_FILTER, "background_filter" }, - { RSModifierType::LINEAR_GRADIENT_BLUR_PARA, "linear_gradient_blur_para" }, - { RSModifierType::DYNAMIC_LIGHT_UP_RATE, "dynamic_light_up_rate" }, - { RSModifierType::DYNAMIC_LIGHT_UP_DEGREE, "dynamic_light_up_degree" }, - { RSModifierType::FG_BRIGHTNESS_RATES, "fg_brightness_rates" }, - { RSModifierType::FG_BRIGHTNESS_SATURATION, "fg_brightness_saturation" }, - { RSModifierType::FG_BRIGHTNESS_POSCOEFF, "fg_brightness_poscoeff" }, - { RSModifierType::FG_BRIGHTNESS_NEGCOEFF, "fg_brightness_negcoeff" }, - { RSModifierType::FG_BRIGHTNESS_FRACTION, "fg_brightness_fraction" }, - { RSModifierType::BG_BRIGHTNESS_RATES, "bg_brightness_rates" }, - { RSModifierType::BG_BRIGHTNESS_SATURATION, "bg_brightness_saturation" }, - { RSModifierType::BG_BRIGHTNESS_POSCOEFF, "bg_brightness_poscoeff" }, - { RSModifierType::BG_BRIGHTNESS_NEGCOEFF, "bg_brightness_negcoeff" }, - { RSModifierType::BG_BRIGHTNESS_FRACTION, "bg_brightness_fraction" }, - { RSModifierType::FRAME_GRAVITY, "frame_gravity" }, - { RSModifierType::CLIP_RRECT, "clip_rrect" }, - { RSModifierType::CLIP_BOUNDS, "clip_bounds" }, - { RSModifierType::CLIP_TO_BOUNDS, "clip_to_bounds" }, - { RSModifierType::CLIP_TO_FRAME, "clip_to_frame" }, - { RSModifierType::VISIBLE, "visible" }, - { RSModifierType::SHADOW_COLOR, "shadow_color" }, - { RSModifierType::SHADOW_OFFSET_X, "shadow_offset_x" }, - { RSModifierType::SHADOW_OFFSET_Y, "shadow_offset_y" }, - { RSModifierType::SHADOW_ALPHA, "shadow_alpha" }, - { RSModifierType::SHADOW_ELEVATION, "shadow_elevation" }, - { RSModifierType::SHADOW_RADIUS, "shadow_radius" }, - { RSModifierType::SHADOW_PATH, "shadow_path" }, - { RSModifierType::SHADOW_MASK, "shadow_mask" }, - { RSModifierType::SHADOW_COLOR_STRATEGY, "shadow_color_strategy" }, - { RSModifierType::MASK, "mask" }, - { RSModifierType::SPHERIZE, "spherize" }, - { RSModifierType::LIGHT_UP_EFFECT, "light_up_effect" }, - { RSModifierType::PIXEL_STRETCH, "pixel_stretch" }, - { RSModifierType::PIXEL_STRETCH_PERCENT, "pixel_stretch_percent" }, - { RSModifierType::PIXEL_STRETCH_TILE_MODE, "pixel_stretch_tile_mode" }, - { RSModifierType::USE_EFFECT, "use_effect" }, - { RSModifierType::COLOR_BLEND_MODE, "color_blend_mode" }, - { RSModifierType::COLOR_BLEND_APPLY_TYPE, "color_blend_apply_type" }, - { RSModifierType::SANDBOX, "sandbox" }, - { RSModifierType::GRAY_SCALE, "gray_scale" }, - { RSModifierType::BRIGHTNESS, "brightness" }, - { RSModifierType::CONTRAST, "contrast" }, - { RSModifierType::SATURATE, "saturate" }, - { RSModifierType::SEPIA, "sepia" }, - { RSModifierType::INVERT, "invert" }, - { RSModifierType::AIINVERT, "aiinvert" }, - { RSModifierType::SYSTEMBAREFFECT, "systembareffect" }, - { RSModifierType::HUE_ROTATE, "hue_rotate" }, - { RSModifierType::COLOR_BLEND, "color_blend" }, - { RSModifierType::PARTICLE, "particle" }, - { RSModifierType::SHADOW_IS_FILLED, "shadow_is_filled" }, - { RSModifierType::OUTLINE_COLOR, "outline_color" }, - { RSModifierType::OUTLINE_WIDTH, "outline_width" }, - { RSModifierType::OUTLINE_STYLE, "outline_style" }, - { RSModifierType::OUTLINE_DASH_WIDTH, "outline_dash_width" }, - { RSModifierType::OUTLINE_DASH_GAP, "outline_dash_gap" }, - { RSModifierType::OUTLINE_RADIUS, "outline_radius" }, - { RSModifierType::GREY_COEF, "grey_coef" }, - { RSModifierType::LIGHT_INTENSITY, "light_intensity" }, - { RSModifierType::LIGHT_COLOR, "light_color" }, - { RSModifierType::LIGHT_POSITION, "light_position" }, - { RSModifierType::ILLUMINATED_BORDER_WIDTH, "illuminated_border_width" }, - { RSModifierType::ILLUMINATED_TYPE, "illuminated_type" }, - { RSModifierType::BLOOM, "bloom" }, - { RSModifierType::FOREGROUND_EFFECT_RADIUS, "foreground_effect_radius" }, - { RSModifierType::USE_SHADOW_BATCHING, "use_shadow_batching" }, - { RSModifierType::MOTION_BLUR_PARA, "motion_blur_para" }, - { RSModifierType::PARTICLE_EMITTER_UPDATER, "particle_emitter_updater" }, - { RSModifierType::PARTICLE_NOISE_FIELD, "particle_noise_field" }, - { RSModifierType::DYNAMIC_DIM_DEGREE, "dynamic_dim_degree" }, - { RSModifierType::MAGNIFIER_PARA, "magnifier_para" }, - { RSModifierType::BACKGROUND_BLUR_RADIUS, "background_blur_radius" }, - { RSModifierType::BACKGROUND_BLUR_SATURATION, "background_blur_saturation" }, - { RSModifierType::BACKGROUND_BLUR_BRIGHTNESS, "background_blur_brightness" }, - { RSModifierType::BACKGROUND_BLUR_MASK_COLOR, "background_blur_mask_color" }, - { RSModifierType::BACKGROUND_BLUR_COLOR_MODE, "background_blur_color_mode" }, - { RSModifierType::BACKGROUND_BLUR_RADIUS_X, "background_blur_radius_x" }, - { RSModifierType::BACKGROUND_BLUR_RADIUS_Y, "background_blur_radius_y" }, - { RSModifierType::FOREGROUND_BLUR_RADIUS, "foreground_blur_radius" }, - { RSModifierType::FOREGROUND_BLUR_SATURATION, "foreground_blur_saturation" }, - { RSModifierType::FOREGROUND_BLUR_BRIGHTNESS, "foreground_blur_brightness" }, - { RSModifierType::FOREGROUND_BLUR_MASK_COLOR, "foreground_blur_mask_color" }, - { RSModifierType::FOREGROUND_BLUR_COLOR_MODE, "foreground_blur_color_mode" }, - { RSModifierType::FOREGROUND_BLUR_RADIUS_X, "foreground_blur_radius_x" }, - { RSModifierType::FOREGROUND_BLUR_RADIUS_Y, "foreground_blur_radius_y" }, - { RSModifierType::CUSTOM, "custom" }, - { RSModifierType::EXTENDED, "extended" }, - { RSModifierType::TRANSITION, "transition" }, - { RSModifierType::BACKGROUND_STYLE, "background_style" }, - { RSModifierType::CONTENT_STYLE, "content_style" }, - { RSModifierType::FOREGROUND_STYLE, "foreground_style" }, - { RSModifierType::OVERLAY_STYLE, "overlay_style" }, - { RSModifierType::NODE_MODIFIER, "node_modifier" }, - { RSModifierType::ENV_FOREGROUND_COLOR, "env_foreground_color" }, - { RSModifierType::ENV_FOREGROUND_COLOR_STRATEGY, "env_foreground_color_strategy" }, - { RSModifierType::GEOMETRYTRANS, "geometrytrans" }, - { RSModifierType::CHILDREN, "children" }, - { RSModifierType::MAX_RS_MODIFIER_TYPE, "max_rs_modifier_type" }, + { RSModifierType::INVALID, "Invalid" }, + { RSModifierType::BOUNDS, "Bounds" }, + { RSModifierType::FRAME, "Frame" }, + { RSModifierType::POSITION_Z, "PositionZ" }, + { RSModifierType::PIVOT, "Pivot" }, + { RSModifierType::PIVOT_Z, "PivotZ" }, + { RSModifierType::QUATERNION, "Quaternion" }, + { RSModifierType::ROTATION, "Rotation" }, + { RSModifierType::ROTATION_X, "RotationX" }, + { RSModifierType::ROTATION_Y, "RotationY" }, + { RSModifierType::CAMERA_DISTANCE, "CameraDistance" }, + { RSModifierType::SCALE, "Scale" }, + { RSModifierType::SKEW, "Skew" }, + { RSModifierType::PERSP, "Persp" }, + { RSModifierType::TRANSLATE, "Translate" }, + { RSModifierType::TRANSLATE_Z, "TranslateZ" }, + { RSModifierType::SUBLAYER_TRANSFORM, "SublayerTransform" }, + { RSModifierType::CORNER_RADIUS, "CornerRadius" }, + { RSModifierType::ALPHA, "Alpha" }, + { RSModifierType::ALPHA_OFFSCREEN, "AlphaOffscreen" }, + { RSModifierType::FOREGROUND_COLOR, "ForegroundColor" }, + { RSModifierType::BACKGROUND_COLOR, "BackgroundColor" }, + { RSModifierType::BACKGROUND_SHADER, "BackgroundShader" }, + { RSModifierType::BG_IMAGE, "BgImage" }, + { RSModifierType::BG_IMAGE_INNER_RECT, "BgImageInnerRect" }, + { RSModifierType::BG_IMAGE_WIDTH, "BgImageWidth" }, + { RSModifierType::BG_IMAGE_HEIGHT, "BgImageHeight" }, + { RSModifierType::BG_IMAGE_POSITION_X, "BgImagePositionX" }, + { RSModifierType::BG_IMAGE_POSITION_Y, "BgImagePositionY" }, + { RSModifierType::SURFACE_BG_COLOR, "SurfaceBgColor" }, + { RSModifierType::BORDER_COLOR, "BorderColor" }, + { RSModifierType::BORDER_WIDTH, "BorderWidth" }, + { RSModifierType::BORDER_STYLE, "BorderStyle" }, + { RSModifierType::BORDER_DASH_WIDTH, "BorderDashWidth" }, + { RSModifierType::BORDER_DASH_GAP, "BorderDashGap" }, + { RSModifierType::FILTER, "Filter" }, + { RSModifierType::BACKGROUND_FILTER, "BackgroundFilter" }, + { RSModifierType::LINEAR_GRADIENT_BLUR_PARA, "LinearGradientBlurPara" }, + { RSModifierType::DYNAMIC_LIGHT_UP_RATE, "DynamicLightUpRate" }, + { RSModifierType::DYNAMIC_LIGHT_UP_DEGREE, "DynamicLightUpDegree" }, + { RSModifierType::FG_BRIGHTNESS_RATES, "FgBrightnessRates" }, + { RSModifierType::FG_BRIGHTNESS_SATURATION, "FgBrightnessSaturation" }, + { RSModifierType::FG_BRIGHTNESS_POSCOEFF, "FgBrightnessPoscoeff" }, + { RSModifierType::FG_BRIGHTNESS_NEGCOEFF, "FgBrightnessNegcoeff" }, + { RSModifierType::FG_BRIGHTNESS_FRACTION, "FgBrightnessFraction" }, + { RSModifierType::BG_BRIGHTNESS_RATES, "BgBrightnessRates" }, + { RSModifierType::BG_BRIGHTNESS_SATURATION, "BgBrightnessSaturation" }, + { RSModifierType::BG_BRIGHTNESS_POSCOEFF, "BgBrightnessPoscoeff" }, + { RSModifierType::BG_BRIGHTNESS_NEGCOEFF, "BgBrightnessNegcoeff" }, + { RSModifierType::BG_BRIGHTNESS_FRACTION, "BgBrightnessFraction" }, + { RSModifierType::FRAME_GRAVITY, "FrameGravity" }, + { RSModifierType::CLIP_RRECT, "ClipRrect" }, + { RSModifierType::CLIP_BOUNDS, "ClipBounds" }, + { RSModifierType::CLIP_TO_BOUNDS, "ClipToBounds" }, + { RSModifierType::CLIP_TO_FRAME, "ClipToFrame" }, + { RSModifierType::VISIBLE, "Visible" }, + { RSModifierType::SHADOW_COLOR, "ShadowColor" }, + { RSModifierType::SHADOW_OFFSET_X, "ShadowOffsetX" }, + { RSModifierType::SHADOW_OFFSET_Y, "ShadowOffsetY" }, + { RSModifierType::SHADOW_ALPHA, "ShadowAlpha" }, + { RSModifierType::SHADOW_ELEVATION, "ShadowElevation" }, + { RSModifierType::SHADOW_RADIUS, "ShadowRadius" }, + { RSModifierType::SHADOW_PATH, "ShadowPath" }, + { RSModifierType::SHADOW_MASK, "ShadowMask" }, + { RSModifierType::SHADOW_COLOR_STRATEGY, "ShadowColorStrategy" }, + { RSModifierType::MASK, "Mask" }, + { RSModifierType::SPHERIZE, "Spherize" }, + { RSModifierType::LIGHT_UP_EFFECT, "LightUpEffect" }, + { RSModifierType::PIXEL_STRETCH, "PixelStretch" }, + { RSModifierType::PIXEL_STRETCH_PERCENT, "PixelStretchPercent" }, + { RSModifierType::PIXEL_STRETCH_TILE_MODE, "PixelStretchTileMode" }, + { RSModifierType::USE_EFFECT, "UseEffect" }, + { RSModifierType::COLOR_BLEND_MODE, "ColorBlendMode" }, + { RSModifierType::COLOR_BLEND_APPLY_TYPE, "ColorBlendApplyType" }, + { RSModifierType::SANDBOX, "Sandbox" }, + { RSModifierType::GRAY_SCALE, "GrayScale" }, + { RSModifierType::BRIGHTNESS, "Brightness" }, + { RSModifierType::CONTRAST, "Contrast" }, + { RSModifierType::SATURATE, "Saturate" }, + { RSModifierType::SEPIA, "Sepia" }, + { RSModifierType::INVERT, "Invert" }, + { RSModifierType::AIINVERT, "Aiinvert" }, + { RSModifierType::SYSTEMBAREFFECT, "Systembareffect" }, + { RSModifierType::HUE_ROTATE, "HueRotate" }, + { RSModifierType::COLOR_BLEND, "ColorBlend" }, + { RSModifierType::PARTICLE, "Particle" }, + { RSModifierType::SHADOW_IS_FILLED, "ShadowIsFilled" }, + { RSModifierType::OUTLINE_COLOR, "OutlineColor" }, + { RSModifierType::OUTLINE_WIDTH, "OutlineWidth" }, + { RSModifierType::OUTLINE_STYLE, "OutlineStyle" }, + { RSModifierType::OUTLINE_DASH_WIDTH, "OutlineDashWidth" }, + { RSModifierType::OUTLINE_DASH_GAP, "OutlineDashGap" }, + { RSModifierType::OUTLINE_RADIUS, "OutlineRadius" }, + { RSModifierType::GREY_COEF, "GreyCoef" }, + { RSModifierType::LIGHT_INTENSITY, "LightIntensity" }, + { RSModifierType::LIGHT_COLOR, "LightColor" }, + { RSModifierType::LIGHT_POSITION, "LightPosition" }, + { RSModifierType::ILLUMINATED_BORDER_WIDTH, "IlluminatedBorderWidth" }, + { RSModifierType::ILLUMINATED_TYPE, "IlluminatedType" }, + { RSModifierType::BLOOM, "Bloom" }, + { RSModifierType::FOREGROUND_EFFECT_RADIUS, "ForegroundEffectRadius" }, + { RSModifierType::USE_SHADOW_BATCHING, "UseShadowBatching" }, + { RSModifierType::MOTION_BLUR_PARA, "MotionBlurPara" }, + { RSModifierType::PARTICLE_EMITTER_UPDATER, "ParticleEmitterUpdater" }, + { RSModifierType::PARTICLE_NOISE_FIELD, "ParticleNoiseField" }, + { RSModifierType::DYNAMIC_DIM_DEGREE, "DynamicDimDegree" }, + { RSModifierType::MAGNIFIER_PARA, "MagnifierPara" }, + { RSModifierType::BACKGROUND_BLUR_RADIUS, "BackgroundBlurRadius" }, + { RSModifierType::BACKGROUND_BLUR_SATURATION, "BackgroundBlurSaturation" }, + { RSModifierType::BACKGROUND_BLUR_BRIGHTNESS, "BackgroundBlurBrightness" }, + { RSModifierType::BACKGROUND_BLUR_MASK_COLOR, "BackgroundBlurMaskColor" }, + { RSModifierType::BACKGROUND_BLUR_COLOR_MODE, "BackgroundBlurColorMode" }, + { RSModifierType::BACKGROUND_BLUR_RADIUS_X, "BackgroundBlurRadiusX" }, + { RSModifierType::BACKGROUND_BLUR_RADIUS_Y, "BackgroundBlurRadiusY" }, + { RSModifierType::FOREGROUND_BLUR_RADIUS, "ForegroundBlurRadius" }, + { RSModifierType::FOREGROUND_BLUR_SATURATION, "ForegroundBlurSaturation" }, + { RSModifierType::FOREGROUND_BLUR_BRIGHTNESS, "ForegroundBlurBrightness" }, + { RSModifierType::FOREGROUND_BLUR_MASK_COLOR, "ForegroundBlurMaskColor" }, + { RSModifierType::FOREGROUND_BLUR_COLOR_MODE, "ForegroundBlurColorMode" }, + { RSModifierType::FOREGROUND_BLUR_RADIUS_X, "ForegroundBlurRadiusX" }, + { RSModifierType::FOREGROUND_BLUR_RADIUS_Y, "ForegroundBlurRadiusY" }, + { RSModifierType::CUSTOM, "Custom" }, + { RSModifierType::EXTENDED, "Extended" }, + { RSModifierType::TRANSITION, "Transition" }, + { RSModifierType::BACKGROUND_STYLE, "BackgroundStyle" }, + { RSModifierType::CONTENT_STYLE, "ContentStyle" }, + { RSModifierType::FOREGROUND_STYLE, "ForegroundStyle" }, + { RSModifierType::OVERLAY_STYLE, "OverlayStyle" }, + { RSModifierType::NODE_MODIFIER, "NodeModifier" }, + { RSModifierType::ENV_FOREGROUND_COLOR, "EnvForegroundColor" }, + { RSModifierType::ENV_FOREGROUND_COLOR_STRATEGY, "EnvForegroundColorStrategy" }, + { RSModifierType::GEOMETRYTRANS, "Geometrytrans" }, + { RSModifierType::CHILDREN, "Children" }, + { RSModifierType::MAX_RS_MODIFIER_TYPE, "MaxRsModifierType" }, }; } // namespace Rosen diff --git a/rosen/modules/render_service_base/include/modifier/rs_render_modifier.h b/rosen/modules/render_service_base/include/modifier/rs_render_modifier.h index 982e22ff36..8ee9a2e069 100644 --- a/rosen/modules/render_service_base/include/modifier/rs_render_modifier.h +++ b/rosen/modules/render_service_base/include/modifier/rs_render_modifier.h @@ -58,6 +58,11 @@ public: virtual PropertyId GetPropertyId() = 0; virtual std::shared_ptr GetProperty() = 0; + void Dump(std::string& out) + { + GetProperty()->Dump(out); + } + virtual RSModifierType GetType() { return RSModifierType::INVALID; diff --git a/rosen/modules/render_service_base/include/modifier/rs_render_property.h b/rosen/modules/render_service_base/include/modifier/rs_render_property.h index 8c5bb229b5..030c6d8d91 100644 --- a/rosen/modules/render_service_base/include/modifier/rs_render_property.h +++ b/rosen/modules/render_service_base/include/modifier/rs_render_property.h @@ -22,6 +22,8 @@ #include "common/rs_rect.h" #include "modifier/rs_animatable_arithmetic.h" #include "modifier/rs_modifier_type.h" +#include "property/rs_properties_def.h" +#include "recording/draw_cmd_list.h" #include "transaction/rs_marshalling_helper.h" namespace OHOS { @@ -61,6 +63,10 @@ public: UpdatePropertyUnit(type); } + virtual void Dump(std::string& out) const + { + } + static bool Marshalling(Parcel& parcel, const std::shared_ptr& val); [[nodiscard]] static bool Unmarshalling(Parcel& parcel, std::shared_ptr& val); @@ -198,6 +204,10 @@ public: return stagingValue_; } + void Dump(std::string& out) const override + { + } + void SetUpdateUIPropertyFunc( const std::function&)>& updateUIPropertyFunc) { @@ -207,7 +217,7 @@ public: protected: T stagingValue_; std::function&)> updateUIPropertyFunc_; - RSRenderPropertyType GetPropertyType() const + RSRenderPropertyType GetPropertyType() const override { return RSRenderPropertyType::INVALID; } @@ -346,6 +356,31 @@ RSB_EXPORT float RSRenderAnimatableProperty::ToFloat() const; template<> RSB_EXPORT float RSRenderAnimatableProperty::ToFloat() const; +template<> +RSB_EXPORT void RSRenderProperty::Dump(std::string& out) const; +template<> +RSB_EXPORT void RSRenderProperty::Dump(std::string& out) const; +template<> +RSB_EXPORT void RSRenderProperty::Dump(std::string& out) const; +template<> +RSB_EXPORT void RSRenderProperty::Dump(std::string& out) const; +template<> +RSB_EXPORT void RSRenderProperty::Dump(std::string& out) const; +template<> +RSB_EXPORT void RSRenderProperty::Dump(std::string& out) const; +template<> +RSB_EXPORT void RSRenderProperty>::Dump(std::string& out) const; +template<> +RSB_EXPORT void RSRenderProperty>::Dump(std::string& out) const; +template<> +RSB_EXPORT void RSRenderProperty::Dump(std::string& out) const; +template<> +RSB_EXPORT void RSRenderProperty::Dump(std::string& out) const; +template<> +RSB_EXPORT void RSRenderProperty::Dump(std::string& out) const; +template<> +RSB_EXPORT void RSRenderProperty::Dump(std::string& out) const; + template<> RSB_EXPORT bool RSRenderAnimatableProperty::IsNearEqual( const std::shared_ptr& value, float zeroThreshold) const; @@ -378,6 +413,19 @@ RSB_EXPORT bool RSRenderAnimatableProperty>::IsEqual( const std::shared_ptr& value) const; #if defined(_WIN32) +extern template class RSRenderProperty; +extern template class RSRenderProperty; +extern template class RSRenderProperty; +extern template class RSRenderProperty; +extern template class RSRenderProperty; +extern template class RSRenderProperty; +extern template class RSRenderProperty>; +extern template class RSRenderProperty>; +extern template class RSRenderProperty; +extern template class RSRenderProperty; +extern template class RSRenderProperty; +extern template class RSRenderProperty; + extern template class RSRenderAnimatableProperty; extern template class RSRenderAnimatableProperty; extern template class RSRenderAnimatableProperty; 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 42d541cf80..f35bc75b1b 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 @@ -739,8 +739,7 @@ protected: void DumpSubClassNode(std::string& out) const; void DumpDrawCmdModifiers(std::string& out) const; - void DumpDrawCmdModifier(std::string& propertyDesc, RSModifierType type, - std::shared_ptr& modifier) const; + void DumpModifiers(std::string& out) const; virtual void OnTreeStateChanged(); // recursive update subSurfaceCnt 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 0190736ab2..8195cd044c 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 @@ -351,6 +351,101 @@ bool operator!=( return !a->IsEqual(b); } +template<> +void RSRenderProperty::Dump(std::string& out) const +{ + out += "[" + std::to_string(Get()) + "]"; +} + +template<> +void RSRenderProperty::Dump(std::string& out) const +{ + Vector4f v4f = Get(); + switch (modifierType_) { + case RSModifierType::BOUNDS: { + out += "[x:" + std::to_string(v4f.x_) + " y:"; + out += std::to_string(v4f.y_) + " width:"; + out += std::to_string(v4f.z_) + " height:"; + out += std::to_string(v4f.w_) + "]"; + break; + } + default: { + out += "[x:" + std::to_string(v4f.x_) + " y:"; + out += std::to_string(v4f.y_) + " z:"; + out += std::to_string(v4f.z_) + " w:"; + out += std::to_string(v4f.w_) + "]"; + break; + } + } +} + +template<> +void RSRenderProperty::Dump(std::string& out) const +{ +} + +template<> +void RSRenderProperty::Dump(std::string& out) const +{ + Vector2f v2f = Get(); + out += "[x:" + std::to_string(v2f.x_) + " y:"; + out += std::to_string(v2f.y_) + "]"; +} + +template<> +void RSRenderProperty::Dump(std::string& out) const +{ +} + +template<> +void RSRenderProperty::Dump(std::string& out) const +{ + std::ostringstream ss; + ss << "0x" << std::hex << Get().AsRgbaInt(); + out += "[RGBA-"; + out += ss.str(); + out += "]"; +} + +template<> +void RSRenderProperty>::Dump(std::string& out) const +{ +} + +template<> +void RSRenderProperty>::Dump(std::string& out) const +{ +} + +template<> +void RSRenderProperty::Dump(std::string& out) const +{ +} + +template<> +void RSRenderProperty::Dump(std::string& out) const +{ + out += "drawCmdList["; + Get()->Dump(out); + out += "]"; +} + +template<> +void RSRenderProperty::Dump(std::string& out) const +{ + out += "ENV_FOREGROUND_COLOR_STRATEGY["; + out += std::to_string(static_cast(Get())); + out += "]"; +} + +template<> +void RSRenderProperty::Dump(std::string& out) const +{ + out += "GEOMETRYTRANS["; + Get().dump(out, 0); + out += "]"; +} + template<> bool RSRenderAnimatableProperty::IsNearEqual( const std::shared_ptr& value, float zeroThreshold) const @@ -512,6 +607,19 @@ bool RSRenderAnimatableProperty>::IsEqual( } } +template class RSRenderProperty; +template class RSRenderProperty; +template class RSRenderProperty; +template class RSRenderProperty; +template class RSRenderProperty; +template class RSRenderProperty; +template class RSRenderProperty>; +template class RSRenderProperty>; +template class RSRenderProperty; +template class RSRenderProperty; +template class RSRenderProperty; +template class RSRenderProperty; + template class RSRenderAnimatableProperty; template class RSRenderAnimatableProperty; template class RSRenderAnimatableProperty; 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 552a36028e..97bd05dc31 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 @@ -654,6 +654,7 @@ void RSRenderNode::DumpTree(int32_t depth, std::string& out) const out += ", IsPureContainer: true"; } DumpDrawCmdModifiers(out); + DumpModifiers(out); animationManager_.DumpAnimations(out); if (!isFullChildrenListValid_) { @@ -754,48 +755,36 @@ void RSRenderNode::DumpDrawCmdModifiers(std::string& out) const std::string splitStr = ", "; std::string modifierDesc = ", DrawCmdModifiers:["; for (auto& [type, modifiers] : renderContent_->drawCmdModifiers_) { - modifierDesc += "type:" + std::to_string(static_cast(type)) + ", modifiers: "; - std::string propertyDesc = "Property_"; - for (auto& modifier : modifiers) { - DumpDrawCmdModifier(propertyDesc, type, modifier); - propertyDesc += "], "; + std::string typeName = "UNKNOWN"; + auto iter = RS_MODIFIER_TYPE_TO_STRING.find(type); + if (iter != RS_MODIFIER_TYPE_TO_STRING.end()) { + typeName = iter->second; } - modifierDesc += propertyDesc.substr(0, propertyDesc.length() - splitStr.length()); - modifierDesc += splitStr; + modifierDesc += typeName + ":["; + std::string propertyDesc = ""; + for (auto& modifier : modifiers) { + modifier->Dump(propertyDesc); + propertyDesc += splitStr; + } + modifierDesc += propertyDesc.substr(0, propertyDesc.length() - splitStr.length()) + "]" + splitStr; } - out += modifierDesc.substr(0, modifierDesc.length() - splitStr.length()); - out += "]"; + out += modifierDesc.substr(0, modifierDesc.length() - splitStr.length()) + "]"; } -void RSRenderNode::DumpDrawCmdModifier(std::string& propertyDesc, RSModifierType type, - std::shared_ptr& modifier) const +void RSRenderNode::DumpModifiers(std::string& out) const { - if (type < RSModifierType::ENV_FOREGROUND_COLOR) { - propertyDesc += "drawCmdList:["; - auto propertyValue = std::static_pointer_cast> - (modifier->GetProperty())->Get(); - propertyDesc += propertyValue->GetOpsWithDesc(); - std::string::size_type pos = 0; - while ((pos = propertyDesc.find("\n", pos)) != std::string::npos) { - propertyDesc.replace(pos, 1, ","); - } - propertyDesc.pop_back(); - } else if (type == RSModifierType::ENV_FOREGROUND_COLOR) { - propertyDesc += "ENV_FOREGROUND_COLOR:[Rgba-"; - auto propertyValue = std::static_pointer_cast> - (modifier->GetProperty())->Get(); - propertyDesc += std::to_string(propertyValue.AsRgbaInt()); - } else if (type == RSModifierType::ENV_FOREGROUND_COLOR_STRATEGY) { - propertyDesc += "ENV_FOREGROUND_COLOR_STRATEGY:["; - auto propertyValue = std::static_pointer_cast> - (modifier->GetProperty())->Get(); - propertyDesc += std::to_string(static_cast(propertyValue)); - } else if (type == RSModifierType::GEOMETRYTRANS) { - propertyDesc += "GEOMETRYTRANS:["; - auto propertyValue = std::static_pointer_cast> - (modifier->GetProperty())->Get(); - propertyValue.dump(propertyDesc, 0); + if (modifiers_.empty()) { + return; } + std::string splitStr = ", "; + out += ", OtherModifiers:["; + std::string propertyDesc = ""; + for (auto& [type, modifier] : modifiers_) { + propertyDesc += modifier->GetModifierTypeString(); + modifier->Dump(propertyDesc); + propertyDesc += splitStr; + } + out += propertyDesc.substr(0, propertyDesc.length() - splitStr.length()) + "]"; } void RSRenderNode::ResetIsOnlyBasicGeoTransform() diff --git a/rosen/test/render_service/render_service_base/unittest/pipeline/rs_base_render_node_test.cpp b/rosen/test/render_service/render_service_base/unittest/pipeline/rs_base_render_node_test.cpp index 92fd5a82ff..29bf82858f 100644 --- a/rosen/test/render_service/render_service_base/unittest/pipeline/rs_base_render_node_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/pipeline/rs_base_render_node_test.cpp @@ -1049,36 +1049,6 @@ HWTEST_F(RSBaseRenderNodeTest, DumpDrawCmdModifiers, TestSize.Level1) ASSERT_TRUE(true); } -/** - * @tc.name: DumpDrawCmdModifier - * @tc.desc: test results of DumpDrawCmdModifier - * @tc.type:FUNC - * @tc.require: issueI9KBCZ - */ -HWTEST_F(RSBaseRenderNodeTest, DumpDrawCmdModifier, TestSize.Level1) -{ - auto node = std::make_shared(id, context); - std::string propertyDesc = "noDesc"; - RSModifierType type; - Drawing::Matrix matrix; - PropertyId id = 1; - std::shared_ptr> property = - std::make_shared>(matrix, id); - std::shared_ptr modifierCast = - std::make_shared(property); - std::shared_ptr modifier = modifierCast; - - type = RSModifierType::ENV_FOREGROUND_COLOR; - node->DumpDrawCmdModifier(propertyDesc, type, modifier); - - type = RSModifierType::ENV_FOREGROUND_COLOR_STRATEGY; - node->DumpDrawCmdModifier(propertyDesc, type, modifier); - - type = RSModifierType::GEOMETRYTRANS; - node->DumpDrawCmdModifier(propertyDesc, type, modifier); - ASSERT_TRUE(true); -} - /** * @tc.name: SetContentDirty * @tc.desc: test results of SetContentDirty diff --git a/rosen/test/render_service/render_service_base/unittest/pipeline/rs_render_node_test2.cpp b/rosen/test/render_service/render_service_base/unittest/pipeline/rs_render_node_test2.cpp index c83d276273..84ef245974 100644 --- a/rosen/test/render_service/render_service_base/unittest/pipeline/rs_render_node_test2.cpp +++ b/rosen/test/render_service/render_service_base/unittest/pipeline/rs_render_node_test2.cpp @@ -1111,30 +1111,16 @@ HWTEST_F(RSRenderNodeTest2, DumpSubClassNodeTest032, TestSize.Level1) } /** - * @tc.name: DumpDrawCmdModifierTest033 - * @tc.desc: DumpDrawCmdModifier ForceMergeSubTreeDirtyRegion SubTreeSkipPrepare test + * @tc.name: ForceMergeSubTreeDirtyRegionTest033 + * @tc.desc: ForceMergeSubTreeDirtyRegion SubTreeSkipPrepare test * @tc.type: FUNC * @tc.require: issueIA61E9 */ -HWTEST_F(RSRenderNodeTest2, DumpDrawCmdModifierTest033, TestSize.Level1) +HWTEST_F(RSRenderNodeTest2, ForceMergeSubTreeDirtyRegionTest033, TestSize.Level1) { std::shared_ptr nodeTest = std::make_shared(0); EXPECT_NE(nodeTest, nullptr); - std::string outTest7; - std::shared_ptr> propertyTest = - std::make_shared>(); - EXPECT_NE(propertyTest, nullptr); - std::shared_ptr drawCmdModifiersTest = - std::make_shared(propertyTest); - EXPECT_NE(drawCmdModifiersTest, nullptr); - std::shared_ptr modifier = std::dynamic_pointer_cast(drawCmdModifiersTest); - EXPECT_NE(modifier, nullptr); - nodeTest->DumpDrawCmdModifier(outTest7, RSModifierType::ENV_FOREGROUND_COLOR, modifier); - nodeTest->DumpDrawCmdModifier(outTest7, RSModifierType::ENV_FOREGROUND_COLOR_STRATEGY, modifier); - nodeTest->DumpDrawCmdModifier(outTest7, RSModifierType::GEOMETRYTRANS, modifier); - EXPECT_NE(outTest7, ""); - RSDirtyRegionManager dirtyManagerTest1; RectI clipRectTest1 = RectI { 0, 0, 1, 1 }; nodeTest->lastFrameSubTreeSkipped_ = true; From ff30c970f59f06b4352417c223e4eedc607130ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=AF=E9=91=AB?= Date: Thu, 1 Aug 2024 11:12:13 +0000 Subject: [PATCH 64/74] update rosen/modules/render_service_base/src/benchmarks/file_utils.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 凯鑫 --- rosen/modules/render_service_base/src/benchmarks/file_utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosen/modules/render_service_base/src/benchmarks/file_utils.cpp b/rosen/modules/render_service_base/src/benchmarks/file_utils.cpp index 0dda7e786f..0afb1dcbef 100644 --- a/rosen/modules/render_service_base/src/benchmarks/file_utils.cpp +++ b/rosen/modules/render_service_base/src/benchmarks/file_utils.cpp @@ -63,7 +63,7 @@ bool CreateFile(const std::string& filePath) bool WriteToFile(uintptr_t data, size_t size, const std::string& filePath) { - if (data == nullptr || size == 0 || !CreateFile(filePath)) { + if (size == 0 || !CreateFile(filePath)) { return false; } if (filePath.empty()) { From 11cd2b71127e932712f6554ca5dc906b3e83aac9 Mon Sep 17 00:00:00 2001 From: tttaaaooo Date: Thu, 1 Aug 2024 19:41:10 +0800 Subject: [PATCH 65/74] fixed uifirst codingstyle. Signed-off-by: tttaaaooo --- .../rs_ui_first_surface_render_node_drawable.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 cfd8bc9fda..10b5ff1fba 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 @@ -226,6 +226,11 @@ Vector2f RSSurfaceRenderNodeDrawable::GetGravityTranslate(float imgWidth, float std::shared_ptr RSSurfaceRenderNodeDrawable::GetCompletedImage( RSPaintFilterCanvas& canvas, uint32_t threadIndex, bool isUIFirst) { + auto gpuContext = canvas.GetGPUContext(); + if (!gpuContext) { + RS_LOGE("RSSurfaceRenderNodeDrawable::GetCompletedImage GetGPUContext nullptr"); + return nullptr; + } if (isUIFirst) { #if defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK) std::scoped_lock lock(completeResourceMutex_); @@ -250,7 +255,7 @@ std::shared_ptr RSSurfaceRenderNodeDrawable::GetCompletedImage( #ifdef RS_ENABLE_GL if (OHOS::Rosen::RSSystemProperties::GetGpuApiType() != OHOS::Rosen::GpuApiType::VULKAN && OHOS::Rosen::RSSystemProperties::GetGpuApiType() != OHOS::Rosen::GpuApiType::DDGR) { - image->BuildFromTexture(*canvas.GetGPUContext(), cacheCompletedBackendTexture_.GetTextureInfo(), + image->BuildFromTexture(*gpuContext, cacheCompletedBackendTexture_.GetTextureInfo(), origin, info, nullptr); } #endif @@ -258,7 +263,7 @@ std::shared_ptr RSSurfaceRenderNodeDrawable::GetCompletedImage( #ifdef RS_ENABLE_VK if (OHOS::Rosen::RSSystemProperties::GetGpuApiType() == OHOS::Rosen::GpuApiType::VULKAN || OHOS::Rosen::RSSystemProperties::GetGpuApiType() == OHOS::Rosen::GpuApiType::DDGR) { - image->BuildFromTexture(*canvas.GetGPUContext(), cacheCompletedBackendTexture_.GetTextureInfo(), + image->BuildFromTexture(*gpuContext, cacheCompletedBackendTexture_.GetTextureInfo(), origin, info, nullptr, NativeBufferUtils::DeleteVkImage, cacheCompletedCleanupHelper_->Ref()); } @@ -290,7 +295,7 @@ std::shared_ptr RSSurfaceRenderNodeDrawable::GetCompletedImage( auto cacheImage = std::make_shared(); Drawing::BitmapFormat info = Drawing::BitmapFormat{ completeImage->GetColorType(), completeImage->GetAlphaType() }; - bool ret = cacheImage->BuildFromTexture(*canvas.GetGPUContext(), backendTexture.GetTextureInfo(), + bool ret = cacheImage->BuildFromTexture(*gpuContext, backendTexture.GetTextureInfo(), origin, info, nullptr, SKResourceManager::DeleteSharedTextureContext, sharedContext); if (!ret) { RS_LOGE("RSSurfaceRenderNodeDrawable::GetCompletedImage image BuildFromTexture failed"); From 51650ae54d96799d1e4410761cdf52c39130fcc0 Mon Sep 17 00:00:00 2001 From: chenlulu Date: Thu, 1 Aug 2024 17:38:17 +0800 Subject: [PATCH 66/74] update capture this in renderserviceConnection Signed-off-by: chenlulu Change-Id: I7b39fcaf185e2b3c2fbbfb842a907419823bd530 --- .../pipeline/rs_render_service_connection.cpp | 66 +++++++++++++------ 1 file changed, 45 insertions(+), 21 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 3001661485..3377e18111 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 @@ -288,8 +288,12 @@ bool RSRenderServiceConnection::CreateNode(const RSSurfaceRenderNodeConfig& conf RS_LOGE("RSRenderService::CreateNode fail"); return false; } - std::function registerNode = [node, this]() -> void { - this->mainThread_->GetContext().GetMutableNodeMap().RegisterRenderNode(node); + std::function registerNode = [node, weakThis = wptr(this)]() -> void { + sptr connection = weakThis.promote(); + if (!connection) { + return; + } + connection->mainThread_->GetContext().GetMutableNodeMap().RegisterRenderNode(node); }; mainThread_->PostTask(registerNode); return true; @@ -911,7 +915,13 @@ std::vector RSRenderServiceConnection::GetMemoryGraphics() } if (GetUniRenderEnabled()) { mainThread_->ScheduleTask( - [this, &memoryGraphics]() { return mainThread_->CountMem(memoryGraphics); }).wait(); + [weakThis = wptr(this), &memoryGraphics]() { + sptr connection = weakThis.promote(); + if (!connection) { + return; + } + return connection->mainThread_->CountMem(memoryGraphics); + }).wait(); return memoryGraphics; } else { return memoryGraphics; @@ -1021,12 +1031,17 @@ void RSRenderServiceConnection::RegisterBufferClearListener( if (!mainThread_) { return; } - auto registerBufferClearListener = [id, callback, this]() -> bool { - if (auto node = this->mainThread_->GetContext().GetNodeMap().GetRenderNode(id)) { - node->RegisterBufferClearListener(callback); - return true; - } - return false; + auto registerBufferClearListener = + [id, callback, weakThis = wptr(this)]() -> bool { + sptr connection = weakThis.promote(); + if (!connection) { + return false; + } + if (auto node = connection->mainThread_->GetContext().GetNodeMap().GetRenderNode(id)) { + node->RegisterBufferClearListener(callback); + return true; + } + return false; }; if (!registerBufferClearListener()) { mainThread_->PostTask(registerBufferClearListener); @@ -1039,12 +1054,17 @@ void RSRenderServiceConnection::RegisterBufferAvailableListener( if (!mainThread_) { return; } - auto registerBufferAvailableListener = [id, callback, isFromRenderThread, this]() -> bool { - if (auto node = this->mainThread_->GetContext().GetNodeMap().GetRenderNode(id)) { - node->RegisterBufferAvailableListener(callback, isFromRenderThread); - return true; - } - return false; + auto registerBufferAvailableListener = + [id, callback, isFromRenderThread, weakThis = wptr(this)]() -> bool { + sptr connection = weakThis.promote(); + if (!connection) { + return false; + } + if (auto node = connection->mainThread_->GetContext().GetNodeMap().GetRenderNode(id)) { + node->RegisterBufferAvailableListener(callback, isFromRenderThread); + return true; + } + return false; }; if (!registerBufferAvailableListener()) { RS_LOGD("RegisterBufferAvailableListener: node not found, post task to retry"); @@ -1548,7 +1568,7 @@ int32_t RSRenderServiceConnection::ResizeVirtualScreen(ScreenId id, uint32_t wid void RSRenderServiceConnection::ReportJankStats() { - auto task = [this]() -> void { RSJankStats::GetInstance().ReportJankStats(); }; + auto task = []() -> void { RSJankStats::GetInstance().ReportJankStats(); }; renderThread_.PostTask(task); } @@ -1613,7 +1633,7 @@ void RSRenderServiceConnection::NotifyDynamicModeEvent(bool enableDynamicModeEve void RSRenderServiceConnection::ReportEventResponse(DataBaseRs info) { - auto task = [this, info]() -> void { + auto task = [info]() -> void { RSJankStats::GetInstance().SetReportEventResponse(info); }; renderThread_.PostTask(task); @@ -1622,7 +1642,7 @@ void RSRenderServiceConnection::ReportEventResponse(DataBaseRs info) void RSRenderServiceConnection::ReportEventComplete(DataBaseRs info) { - auto task = [this, info]() -> void { + auto task = [info]() -> void { RSJankStats::GetInstance().SetReportEventComplete(info); }; renderThread_.PostTask(task); @@ -1632,7 +1652,7 @@ void RSRenderServiceConnection::ReportEventComplete(DataBaseRs info) void RSRenderServiceConnection::ReportEventJankFrame(DataBaseRs info) { bool isReportTaskDelayed = renderThread_.IsMainLooping(); - auto task = [this, info, isReportTaskDelayed]() -> void { + auto task = [info, isReportTaskDelayed]() -> void { RSJankStats::GetInstance().SetReportEventJankFrame(info, isReportTaskDelayed); }; renderThread_.PostTask(task); @@ -1652,8 +1672,12 @@ void RSRenderServiceConnection::SetHardwareEnabled(NodeId id, bool isEnabled, Se if (!mainThread_) { return; } - auto task = [this, id, isEnabled, selfDrawingType]() -> void { - auto& context = mainThread_->GetContext(); + auto task = [weakThis = wptr(this), id, isEnabled, selfDrawingType]() -> void { + sptr connection = weakThis.promote(); + if (!connection) { + return; + } + auto& context = connection->mainThread_->GetContext(); auto node = context.GetNodeMap().GetRenderNode(id); if (node) { node->SetHardwareEnabled(isEnabled, selfDrawingType); From 08e4543485af89937e4e14c7964514e11ed42fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E5=8D=97?= Date: Thu, 1 Aug 2024 14:17:32 +0000 Subject: [PATCH 67/74] =?UTF-8?q?=E6=B7=BB=E5=8A=A0kawase=E6=A8=A1?= =?UTF-8?q?=E7=B3=8A=20debug=20trace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 江南 --- .../modules/render_service_base/src/render/rs_drawing_filter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/rosen/modules/render_service_base/src/render/rs_drawing_filter.cpp b/rosen/modules/render_service_base/src/render/rs_drawing_filter.cpp index 97177301f5..2669519398 100644 --- a/rosen/modules/render_service_base/src/render/rs_drawing_filter.cpp +++ b/rosen/modules/render_service_base/src/render/rs_drawing_filter.cpp @@ -321,6 +321,7 @@ void RSDrawingFilter::DrawImageRect(Drawing::Canvas& canvas, const std::shared_p canvas.AttachBrush(brush); canvas.DrawImageRect(*blurImage, src, dst, Drawing::SamplingOptions()); canvas.DetachBrush(); + RS_OPTIONAL_TRACE_NAME("ApplyKawaseBlur " + std::to_string(radius)); } return; } From c127a2a35f016df2128721efe979a797d50a2cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E5=8D=97?= Date: Fri, 2 Aug 2024 02:07:23 +0000 Subject: [PATCH 68/74] =?UTF-8?q?=E6=B7=BB=E5=8A=A0kawase=E6=A8=A1?= =?UTF-8?q?=E7=B3=8A=20debug=20trace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 江南 --- .../render_service_base/src/render/rs_drawing_filter.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rosen/modules/render_service_base/src/render/rs_drawing_filter.cpp b/rosen/modules/render_service_base/src/render/rs_drawing_filter.cpp index 2669519398..02579ac2c9 100644 --- a/rosen/modules/render_service_base/src/render/rs_drawing_filter.cpp +++ b/rosen/modules/render_service_base/src/render/rs_drawing_filter.cpp @@ -307,8 +307,7 @@ void RSDrawingFilter::DrawImageRect(Drawing::Canvas& canvas, const std::shared_p if (kawaseShaderFilter != nullptr) { auto tmpFilter = std::static_pointer_cast(kawaseShaderFilter); auto radius = tmpFilter->GetRadius(); - Drawing::HpsBlurParameter hpsParam = Drawing::HpsBlurParameter(src, dst, radius, - saturationForHPS_, brightnessForHPS_); + auto hpsParam = Drawing::HpsBlurParameter(src, dst, radius, saturationForHPS_, brightnessForHPS_); if (RSSystemProperties::GetHpsBlurEnabled() && GetFilterType() == RSFilter::MATERIAL && HpsBlurFilter::GetHpsBlurFilter().ApplyHpsBlur(canvas, outImage, hpsParam, brush.GetColor().GetAlphaF())) { RS_OPTIONAL_TRACE_NAME("ApplyHPSBlur " + std::to_string(radius)); From fd35e997bc731db2ddbf1d1ddf750fcfccd20a60 Mon Sep 17 00:00:00 2001 From: key-destiny Date: Fri, 2 Aug 2024 10:13:38 +0800 Subject: [PATCH 69/74] Signed-off-by:key-destiny Signed-off-by: key-destiny --- .../src/render/rs_linear_gradient_blur_filter.cpp | 2 +- .../render_service_base/src/render/rs_motion_blur_filter.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/rosen/modules/render_service_base/src/render/rs_linear_gradient_blur_filter.cpp b/rosen/modules/render_service_base/src/render/rs_linear_gradient_blur_filter.cpp index 21d1ead5df..93e3656a95 100644 --- a/rosen/modules/render_service_base/src/render/rs_linear_gradient_blur_filter.cpp +++ b/rosen/modules/render_service_base/src/render/rs_linear_gradient_blur_filter.cpp @@ -47,7 +47,7 @@ void RSLinearGradientBlurFilter::DrawImageRect(Drawing::Canvas& canvas, const st const Drawing::Rect& src, const Drawing::Rect& dst) const { auto& para = linearGradientBlurPara_; - if (!image || para == nullptr || para->blurRadius_ <= 0) { + if (!image || para == nullptr || para->blurRadius_ <= 0 || imageScale_ <= 0) { return; } diff --git a/rosen/modules/render_service_base/src/render/rs_motion_blur_filter.cpp b/rosen/modules/render_service_base/src/render/rs_motion_blur_filter.cpp index 530fc581d6..be881574f4 100644 --- a/rosen/modules/render_service_base/src/render/rs_motion_blur_filter.cpp +++ b/rosen/modules/render_service_base/src/render/rs_motion_blur_filter.cpp @@ -73,6 +73,10 @@ void RSMotionBlurFilter::DrawImageRect(Drawing::Canvas& canvas, const std::share void RSMotionBlurFilter::DrawMotionBlur(Drawing::Canvas& canvas, const std::shared_ptr& image, const Drawing::Rect& src, const Drawing::Rect& dst) const { + if (image == nullptr) { + return; + } + if (motionBlurPara_ == nullptr) { lastRect_ = Drawing::Rect(0.f, 0.f, 0.f, 0.f); OutputOriginalImage(canvas, image, src, dst); From 2c3f13aa11fb0a7ed428fafa8d7e7fdf6ace22f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=B2=E5=B0=98?= Date: Fri, 2 Aug 2024 02:25:06 +0000 Subject: [PATCH 70/74] update rosen/modules/render_service_base/src/render/rs_linear_gradient_blur_filter.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 闲尘 --- .../src/render/rs_linear_gradient_blur_filter.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rosen/modules/render_service_base/src/render/rs_linear_gradient_blur_filter.cpp b/rosen/modules/render_service_base/src/render/rs_linear_gradient_blur_filter.cpp index 93e3656a95..2cbb1723c2 100644 --- a/rosen/modules/render_service_base/src/render/rs_linear_gradient_blur_filter.cpp +++ b/rosen/modules/render_service_base/src/render/rs_linear_gradient_blur_filter.cpp @@ -47,12 +47,15 @@ void RSLinearGradientBlurFilter::DrawImageRect(Drawing::Canvas& canvas, const st const Drawing::Rect& src, const Drawing::Rect& dst) const { auto& para = linearGradientBlurPara_; - if (!image || para == nullptr || para->blurRadius_ <= 0 || imageScale_ <= 0) { + if (!image || para == nullptr || para->blurRadius_ <= 0) { return; } RS_OPTIONAL_TRACE_NAME("DrawLinearGradientBlur"); ComputeScale(dst.GetWidth(), dst.GetHeight(), para->useMaskAlgorithm_); + if (imageScale_ <= 0) { + return; + } auto clipIPadding = Drawing::Rect(0, 0, geoWidth_ * imageScale_, geoHeight_ * imageScale_); uint8_t directionBias = 0; auto alphaGradientShader = MakeAlphaGradientShader(clipIPadding, para, directionBias); From 2d882f9cfd3c67a7d0256acc2a975fa7893431d3 Mon Sep 17 00:00:00 2001 From: qizeyu Date: Fri, 2 Aug 2024 11:04:56 +0800 Subject: [PATCH 71/74] =?UTF-8?q?=E5=8E=BB=E6=8E=89makefromtextureforvk?= =?UTF-8?q?=E6=A0=87=E5=BF=97=E4=BD=8D=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E7=9A=84=E5=86=85=E5=AD=98=E6=B3=84=E6=BC=8F=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: qizeyu --- .../src/drawable/rs_property_drawable_background.cpp | 7 ++----- .../render_service_base/src/pipeline/rs_draw_cmd.cpp | 5 ++--- .../render_service_base/src/render/rs_image_base.cpp | 5 ++--- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/rosen/modules/render_service_base/src/drawable/rs_property_drawable_background.cpp b/rosen/modules/render_service_base/src/drawable/rs_property_drawable_background.cpp index aaa41572d1..2a78f6e763 100644 --- a/rosen/modules/render_service_base/src/drawable/rs_property_drawable_background.cpp +++ b/rosen/modules/render_service_base/src/drawable/rs_property_drawable_background.cpp @@ -464,12 +464,8 @@ std::shared_ptr RSBackgroundImageDrawable::MakeFromTextureForVK( RS_LOGE("MakeFromTextureForVK create native window buffer fail"); return nullptr; } - pixelMapId_ = pixelMap->GetUniqueId(); - } - bool isProtected = (surfaceBuffer->GetUsage() & BUFFER_USAGE_PROTECTED) != 0; - if (!backendTexture_.IsValid() || isProtected) { backendTexture_ = NativeBufferUtils::MakeBackendTextureFromNativeBuffer( - nativeWindowBuffer_, surfaceBuffer->GetWidth(), surfaceBuffer->GetHeight(), isProtected); + nativeWindowBuffer_, surfaceBuffer->GetWidth(), surfaceBuffer->GetHeight(), false); if (backendTexture_.IsValid()) { auto vkTextureInfo = backendTexture_.GetTextureInfo().GetVKTextureInfo(); cleanUpHelper_ = new NativeBufferUtils::VulkanCleanupHelper( @@ -477,6 +473,7 @@ std::shared_ptr RSBackgroundImageDrawable::MakeFromTextureForVK( } else { return nullptr; } + pixelMapId_ = pixelMap->GetUniqueId(); tid_ = gettid(); } diff --git a/rosen/modules/render_service_base/src/pipeline/rs_draw_cmd.cpp b/rosen/modules/render_service_base/src/pipeline/rs_draw_cmd.cpp index ae45080508..d17a28b668 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_draw_cmd.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_draw_cmd.cpp @@ -311,10 +311,9 @@ bool RSExtendImageObject::MakeFromTextureForVK(Drawing::Canvas& canvas, SurfaceB return false; } } - bool isProtected = (surfaceBuffer->GetUsage() & BUFFER_USAGE_PROTECTED) != 0; - if (!backendTexture_.IsValid() || isProtected) { + if (!backendTexture_.IsValid()) { backendTexture_ = NativeBufferUtils::MakeBackendTextureFromNativeBuffer(nativeWindowBuffer_, - surfaceBuffer->GetWidth(), surfaceBuffer->GetHeight(), isProtected); + surfaceBuffer->GetWidth(), surfaceBuffer->GetHeight(), false); if (backendTexture_.IsValid()) { auto vkTextureInfo = backendTexture_.GetTextureInfo().GetVKTextureInfo(); cleanUpHelper_ = new NativeBufferUtils::VulkanCleanupHelper(RsVulkanContext::GetSingleton(), diff --git a/rosen/modules/render_service_base/src/render/rs_image_base.cpp b/rosen/modules/render_service_base/src/render/rs_image_base.cpp index 08dfead7b1..2bc19400ee 100644 --- a/rosen/modules/render_service_base/src/render/rs_image_base.cpp +++ b/rosen/modules/render_service_base/src/render/rs_image_base.cpp @@ -433,10 +433,9 @@ std::shared_ptr RSImageBase::MakeFromTextureForVK( return nullptr; } } - bool isProtected = (surfaceBuffer->GetUsage() & BUFFER_USAGE_PROTECTED) != 0; - if (!backendTexture_.IsValid() || isProtected) { + if (!backendTexture_.IsValid()) { backendTexture_ = NativeBufferUtils::MakeBackendTextureFromNativeBuffer( - nativeWindowBuffer_, surfaceBuffer->GetWidth(), surfaceBuffer->GetHeight(), isProtected); + nativeWindowBuffer_, surfaceBuffer->GetWidth(), surfaceBuffer->GetHeight(), false); if (backendTexture_.IsValid()) { auto vkTextureInfo = backendTexture_.GetTextureInfo().GetVKTextureInfo(); cleanUpHelper_ = new NativeBufferUtils::VulkanCleanupHelper( From b71716478e2d1bbfd1bc228e534dade2abe97a93 Mon Sep 17 00:00:00 2001 From: Hw_zz Date: Fri, 2 Aug 2024 11:47:12 +0800 Subject: [PATCH 72/74] log fix Signed-off-by: Hw_zz --- .../render_service/core/pipeline/rs_uni_render_visitor.cpp | 2 -- rosen/modules/render_service/core/screen_manager/rs_screen.cpp | 2 +- .../render_service_client/core/transaction/rs_interfaces.cpp | 2 +- 3 files changed, 2 insertions(+), 4 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 aae077fd42..1129175083 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 @@ -1296,7 +1296,6 @@ void RSUniRenderVisitor::QuickPrepareDisplayRenderNode(RSDisplayRenderNode& node // 0. init display info RS_TRACE_NAME("RSUniRender:QuickPrepareDisplayRenderNode " + std::to_string(node.GetScreenId())); if (!InitDisplayInfo(node)) { - RS_LOGE("RSUniRenderVisitor::QuickPrepareDisplayRenderNode InitDisplayInfo fail"); return; } SendRcdMessage(node); @@ -1824,7 +1823,6 @@ bool RSUniRenderVisitor::InitDisplayInfo(RSDisplayRenderNode& node) RSDisplayRenderNode::CompositeType::UNI_RENDER_COMPOSITE); break; default: - RS_LOGE("RSUniRenderVisitor::ProcessDisplayRenderNode ScreenState unsupported"); return false; } 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 da2526ac17..f838f778da 100644 --- a/rosen/modules/render_service/core/screen_manager/rs_screen.cpp +++ b/rosen/modules/render_service/core/screen_manager/rs_screen.cpp @@ -654,7 +654,7 @@ void RSScreen::SetScreenBacklight(uint32_t level) return; } - RS_LOGI("RSScreen_%{public}" PRIu64 " SetScreenBacklight, level is %{public}u", id_, level); + RS_LOGD("RSScreen_%{public}" PRIu64 " SetScreenBacklight, level is %{public}u", id_, level); if (hdiScreen_->SetScreenBacklight(level) < 0) { 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 7b218ddbe0..539fd3fea2 100644 --- a/rosen/modules/render_service_client/core/transaction/rs_interfaces.cpp +++ b/rosen/modules/render_service_client/core/transaction/rs_interfaces.cpp @@ -397,7 +397,7 @@ int32_t RSInterfaces::GetScreenBacklight(ScreenId id) void RSInterfaces::SetScreenBacklight(ScreenId id, uint32_t level) { - RS_LOGI("RSInterfaces::SetScreenBacklight: ScreenId: %{public}" PRIu64 ", level: %{public}u", id, level); + RS_LOGD("RSInterfaces::SetScreenBacklight: ScreenId: %{public}" PRIu64 ", level: %{public}u", id, level); renderServiceClient_->SetScreenBacklight(id, level); } From d9ee728499f876e6b23888824662bd1615e6d026 Mon Sep 17 00:00:00 2001 From: ZLJUN Date: Fri, 2 Aug 2024 15:07:41 +0800 Subject: [PATCH 73/74] =?UTF-8?q?RSCommonToolsFuzzTest=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ZLJUN --- .../rscommontools_fuzzer.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/rosen/test/render_service/render_service_base/fuzztest/rscommontools_fuzzer/rscommontools_fuzzer.cpp b/rosen/test/render_service/render_service_base/fuzztest/rscommontools_fuzzer/rscommontools_fuzzer.cpp index 7dc0c37d18..95698c22e8 100755 --- a/rosen/test/render_service/render_service_base/fuzztest/rscommontools_fuzzer/rscommontools_fuzzer.cpp +++ b/rosen/test/render_service/render_service_base/fuzztest/rscommontools_fuzzer/rscommontools_fuzzer.cpp @@ -68,10 +68,20 @@ bool DoSavePixelmapToFile(const uint8_t* data, size_t size) opts.size.width = g_iSize; opts.size.height = g_iSize; opts.editable = true; - auto pixelMap = Media::PixelMap::Create(opts); - auto shpPixelMap = std::shared_ptr(pixelMap.release()); - std::string dst = ""; - CommonTools::SavePixelmapToFile(shpPixelMap, dst); + return true; +} +bool DoGetLocalTime(const uint8_t* data, size_t size) +{ + if (data == nullptr) { + return false; + } + + // initialize + g_data = data; + g_size = size; + g_pos = 0; + + CommonTools::GetLocalTime(); return true; } @@ -83,5 +93,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ OHOS::Rosen::DoSavePixelmapToFile(data, size); // SavePixelmapToFile + OHOS::Rosen::DoGetLocalTime(data, size); // GetLocalTime return 0; } \ No newline at end of file From bb625fefc9c7ab9856f09d22092eb0324084cc3f Mon Sep 17 00:00:00 2001 From: chenq Date: Fri, 2 Aug 2024 15:32:51 +0800 Subject: [PATCH 74/74] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=A0=81202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenq --- .../rs_window_animation_manager.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/interfaces/kits/napi/graphic/animation/window_animation_manager/rs_window_animation_manager.cpp b/interfaces/kits/napi/graphic/animation/window_animation_manager/rs_window_animation_manager.cpp index fd2bad96cb..beb346ed7c 100644 --- a/interfaces/kits/napi/graphic/animation/window_animation_manager/rs_window_animation_manager.cpp +++ b/interfaces/kits/napi/graphic/animation/window_animation_manager/rs_window_animation_manager.cpp @@ -32,7 +32,7 @@ constexpr size_t ARGC_TWO = 2; constexpr size_t ARGC_MAX = 10; constexpr int32_t ERR_NOT_OK = -1; constexpr int32_t ERR_OK = 0; -constexpr int32_t ERR_NOT_SYSTEM_APP = 222; +constexpr int32_t ERR_NOT_SYSTEM_APP = 202; napi_value RSWindowAnimationManager::Init(napi_env env, napi_value exportObj) { @@ -62,8 +62,8 @@ napi_value RSWindowAnimationManager::SetController(napi_env env, napi_callback_i WALOGD("SetController"); if (!RSWindowAnimationUtils::IsSystemApp()) { WALOGE("SetController failed"); - napi_throw(env, CreateJsError(env, ERR_NOT_SYSTEM_APP, - "WindowAnimationManager setController failed, is not system app")); + napi_throw_error(env, std::to_string(ERR_NOT_SYSTEM_APP).c_str(), + "WindowAnimationManager setController failed, is not system app"); return nullptr; } auto me = CheckParamsAndGetThis(env, info); @@ -75,8 +75,8 @@ napi_value RSWindowAnimationManager::MinimizeWindowWithAnimation(napi_env env, n WALOGD("MinimizeWindowWithAnimation"); if (!RSWindowAnimationUtils::IsSystemApp()) { WALOGE("MinimizeWindowWithAnimation failed"); - napi_throw(env, CreateJsError(env, ERR_NOT_SYSTEM_APP, - "WindowAnimationManager minimizeWindowWithAnimation failed, is not system app")); + napi_throw_error(env, std::to_string(ERR_NOT_SYSTEM_APP).c_str(), + "WindowAnimationManager minimizeWindowWithAnimation failed, is not system app"); return nullptr; } @@ -89,8 +89,8 @@ napi_value RSWindowAnimationManager::GetWindowAnimationTargets(napi_env env, nap WALOGD("GetWindowAnimationTargets"); if (!RSWindowAnimationUtils::IsSystemApp()) { WALOGE("GetWindowAnimationTargets failed"); - napi_throw(env, CreateJsError(env, ERR_NOT_SYSTEM_APP, - "WindowAnimationManager getWindowAnimationTargets failed, is not system app")); + napi_throw_error(env, std::to_string(ERR_NOT_SYSTEM_APP).c_str(), + "WindowAnimationManager getWindowAnimationTargets failed, is not system app"); return nullptr; } auto me = CheckParamsAndGetThis(env, info);