已合并
fix watermark resource leak: clear disabled watermark entries instead of storing false #31074
LyBbq创建于 7月2日
fix watermark resource leak: clear disabled watermark entries instead of storing false #31074
已合并
共 4 个文件变更+15-1
| @@ -457,6 +457,7 @@ public: | |||
| 457 | void ClearCustomWatermarkEnabled(const std::string& name); | 457 | void ClearCustomWatermarkEnabled(const std::string& name); |
| 458 | const std::unordered_map<std::string, bool>& GetSurfaceWatermarkEnabledMap( | 458 | const std::unordered_map<std::string, bool>& GetSurfaceWatermarkEnabledMap( |
| 459 | SurfaceWatermarkType watermarkType) const; | 459 | SurfaceWatermarkType watermarkType) const; |
| 460 | + const std::unordered_map<std::string, bool>& GetWatermarksEnabledMap() const; | ||
| 460 | 461 | ||
| 461 | bool IsSystemWatermarkEmpty() const; | 462 | bool IsSystemWatermarkEmpty() const; |
| 462 | bool IsCustomWatermarkEmpty() const; | 463 | bool IsCustomWatermarkEmpty() const; |
| @@ -357,7 +357,11 @@ void SurfaceNodeCommandHelper::SetWatermarkEnabled(RSContext& context, NodeId no | |||
| 357 | const std::string& name, bool isEnabled) | 357 | const std::string& name, bool isEnabled) |
| 358 | { | 358 | { |
| 359 | if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId)) { | 359 | if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId)) { |
| 360 | - node->SetWatermarkEnabled(name, isEnabled); | 360 | + if (isEnabled) { |
| 361 | + node->SetWatermarkEnabled(name, isEnabled); | ||
| 362 | + } else { | ||
| 363 | + node->ClearWatermarkEnabled(name, SurfaceWatermarkType::SYSTEM_WATER_MARK); | ||
| 364 | + } | ||
| 361 | } | 365 | } |
| 362 | } | 366 | } |
| 363 | 367 | ||
| @@ -545,6 +545,11 @@ const std::unordered_map<std::string, bool>& RSSurfaceRenderParams::GetSurfaceWa | |||
| 545 | return (watermarkType == CUSTOM_WATER_MARK) ? customWatermarkHandles_ : systemWatermarkHandles_; | 545 | return (watermarkType == CUSTOM_WATER_MARK) ? customWatermarkHandles_ : systemWatermarkHandles_; |
| 546 | } | 546 | } |
| 547 | 547 | ||
| 548 | +const std::unordered_map<std::string, bool>& RSSurfaceRenderParams::GetWatermarksEnabledMap() const | ||
| 549 | +{ | ||
| 550 | + return systemWatermarkHandles_; | ||
| 551 | +} | ||
| 552 | + | ||
| 548 | bool RSSurfaceRenderParams::IsSystemWatermarkEmpty() const | 553 | bool RSSurfaceRenderParams::IsSystemWatermarkEmpty() const |
| 549 | { | 554 | { |
| 550 | return systemWatermarkHandles_.empty(); | 555 | return systemWatermarkHandles_.empty(); |
Mrosen/test/render_service/render_service_base/unittest/command/rs_surface_node_command_test.cpp+4-0
| @@ -138,6 +138,10 @@ HWTEST_F(RSSurfaceNodeCommandTest, SetWatermarkEnabledTest, TestSize.Level1) | |||
| 138 | ASSERT_NE(surfaceNode->stagingRenderParams_, nullptr); | 138 | ASSERT_NE(surfaceNode->stagingRenderParams_, nullptr); |
| 139 | auto surfaceParams = static_cast<RSSurfaceRenderParams*>(surfaceNode->stagingRenderParams_.get()); | 139 | auto surfaceParams = static_cast<RSSurfaceRenderParams*>(surfaceNode->stagingRenderParams_.get()); |
| 140 | ASSERT_NE(surfaceParams, nullptr); | 140 | ASSERT_NE(surfaceParams, nullptr); |
| 141 | + EXPECT_EQ(surfaceParams->GetWatermarksEnabledMap().at("test"), true); | ||
| 142 | + SurfaceNodeCommandHelper::SetWatermarkEnabled(context, nodeId, "test", false); | ||
| 143 | + auto watermarkMap = surfaceParams->GetWatermarksEnabledMap(); | ||
| 144 | + EXPECT_EQ(watermarkMap.find("test") == watermarkMap.end(), true); | ||
| 141 | } | 145 | } |
| 142 | 146 | ||
| 143 | /** | 147 | /** |