已合并
refactor(render_service): split IPC persistence into per-command transfer classes #32488
refactor(render_service): split IPC persistence into per-command transfer classes #32488
已合并
Niko-Yuan创建于 8月25日
共 91 个文件变更+5023-3504
@@ -228,8 +228,6 @@ ohos_shared_library("librender_service") {
228 "core/transaction/zidl/rs_connect_to_render_process_stub.cpp",228 "core/transaction/zidl/rs_connect_to_render_process_stub.cpp",
229 "main/render_process/rs_render_process.cpp",229 "main/render_process/rs_render_process.cpp",
230 "main/render_process/rs_render_process_agent.cpp",230 "main/render_process/rs_render_process_agent.cpp",
231- "main/render_process/transaction/ipc_persistence/rs_ipc_persistence_data.cpp",
232- "main/render_process/transaction/ipc_persistence/rs_ipc_persistence_manager.cpp",
233 "main/render_process/transaction/rs_service_to_render_connection.cpp",231 "main/render_process/transaction/rs_service_to_render_connection.cpp",
234 "main/render_process/transaction/zidl/rs_service_to_render_connection_proxy.cpp",232 "main/render_process/transaction/zidl/rs_service_to_render_connection_proxy.cpp",
235 "main/render_process/transaction/zidl/rs_service_to_render_connection_stub.cpp",233 "main/render_process/transaction/zidl/rs_service_to_render_connection_stub.cpp",
@@ -257,6 +255,21 @@ ohos_shared_library("librender_service") {
257 "screen_manager/rs_screen_thread_safe_property.cpp",255 "screen_manager/rs_screen_thread_safe_property.cpp",
258 ]256 ]
259 257 
258+ #ipc_persistence
259+ sources += [
260+ "main/render_process/transaction/ipc_persistence/rs_ipc_persistence_manager.cpp",
261+ ]
262+ 
263+ #transfers
264+ sources += [
265+ "main/render_process/transaction/zidl/transfers/rs_set_watermark_transfer.cpp",
266+ "main/render_process/transaction/zidl/transfers/rs_show_watermark_transfer.cpp",
267+ "main/render_process/transaction/zidl/transfers/rs_on_hwc_event_transfer.cpp",
268+ "main/render_process/transaction/zidl/transfers/rs_set_behind_window_filter_enabled_transfer.cpp",
269+ "main/render_process/transaction/zidl/transfers/rs_set_show_refresh_rate_enabled_transfer.cpp",
270+ "main/render_process/transaction/zidl/transfers/rs_self_drawing_node_rect_change_callback_transfer.cpp",
271+ ]
272+ 
260 #feature_cfg273 #feature_cfg
261 sources += [274 sources += [
262 "core/feature_cfg/feature_param/extend_feature/capture_base_param.cpp",275 "core/feature_cfg/feature_param/extend_feature/capture_base_param.cpp",
@@ -771,6 +784,8 @@ ohos_executable("render_service") {
771 include_dirs = [784 include_dirs = [
772 "core",785 "core",
773 "main",786 "main",
787+ "main/render_process/transaction/ipc_persistence",
788+ "main/render_process/transaction/zidl",
774 "$graphic_2d_root/interfaces/inner_api/common",789 "$graphic_2d_root/interfaces/inner_api/common",
775 "$graphic_2d_root/utils/color_manager/export",790 "$graphic_2d_root/utils/color_manager/export",
776 "$graphic_2d_root/utils/socketpair/export",791 "$graphic_2d_root/utils/socketpair/export",
@@ -849,6 +864,7 @@ if (graphic_2d_feature_product == "phone" || graphic_2d_feature_product == "tabl
849 include_dirs = [864 include_dirs = [
850 "core",865 "core",
851 "main",866 "main",
867+ "main/render_process/transaction/zidl",
852 "$graphic_2d_root/interfaces/inner_api/common",868 "$graphic_2d_root/interfaces/inner_api/common",
853 "$graphic_2d_root/rosen/modules/composer/hdi_backend/include",869 "$graphic_2d_root/rosen/modules/composer/hdi_backend/include",
854 "$graphic_2d_root/rosen/modules/render_service/composer/composer_client/connection",870 "$graphic_2d_root/rosen/modules/render_service/composer/composer_client/connection",
@@ -28,7 +28,7 @@
28#include "pipeline/main_thread/rs_main_thread.h"28#include "pipeline/main_thread/rs_main_thread.h"
29#include "platform/common/rs_log.h"29#include "platform/common/rs_log.h"
30#include "rs_composer_to_render_connection.h"30#include "rs_composer_to_render_connection.h"
31-#include "rs_ipc_persistence_data.h"31+#include "rs_ipc_persistence_def.h"
32#include "rs_render_connect_parcel_info.h"32#include "rs_render_connect_parcel_info.h"
33#include "rs_render_pipeline_agent.h"33#include "rs_render_pipeline_agent.h"
34#include "transaction/rs_connect_to_render_process.h"34#include "transaction/rs_connect_to_render_process.h"
@@ -90,8 +90,7 @@ bool IsInvalidReplyInfo(const sptr<ReplyToRenderInfo>& result)
90 return !result ||90 return !result ||
91 !result->composeConnection_ ||91 !result->composeConnection_ ||
92 !result->rsScreenProperty_ ||92 !result->rsScreenProperty_ ||
93- !result->vsyncConn_ ||93+ !result->vsyncConn_;
94- !result->replayData_;
95}94}
96}95}
97 96 
@@ -152,10 +151,10 @@ bool RSRenderProcess::Init()
152 renderPipeline_->OnScreenConnected(151 renderPipeline_->OnScreenConnected(
153 rsScreenProperty, renderToComposerConnection, composerToRenderConnection, nullptr);152 rsScreenProperty, renderToComposerConnection, composerToRenderConnection, nullptr);
154 153 
155- // replay global ipc154+ // apply global ipc persistence reply data
156- RS_LOGI("%{public}s: Replay Global Ipc", __func__);155+ RS_LOGI("%{public}s: Apply Global Ipc Persistence Data", __func__);
157 auto renderPipelineAgent = sptr<RSRenderPipelineAgent>::MakeSptr(renderPipeline_);156 auto renderPipelineAgent = sptr<RSRenderPipelineAgent>::MakeSptr(renderPipeline_);
158- ApplyIpcPersistenceData(renderPipelineAgent, *replyToRenderInfo->replayData_);157+ ApplyIpcPersistenceData(renderPipelineAgent, replyToRenderInfo->persistenceData_);
159 158 
160 auto renderProcessAgent = sptr<RSRenderProcessAgent>::MakeSptr(*this);159 auto renderProcessAgent = sptr<RSRenderProcessAgent>::MakeSptr(*this);
161 // called from service160 // called from service
@@ -201,14 +200,14 @@ sptr<RSIRenderToServiceConnection> RSRenderProcess::ConnectToRenderService()
201}200}
202 201 
203void RSRenderProcess::ApplyIpcPersistenceData(const sptr<RSRenderPipelineAgent>& renderPipelineAgent,202void RSRenderProcess::ApplyIpcPersistenceData(const sptr<RSRenderPipelineAgent>& renderPipelineAgent,
204- const IpcPersistenceTypeToDataMap& replayData)203+ const IpcPersistenceMap& replayData)
205{204{
206- for (const auto& [type, dataVec] : replayData) {205+ for (const auto& [typeId, transfer] : replayData) {
207- for (const auto& data : dataVec) {206+ if (!transfer) {
208- if (!data) {207+ continue;
209- continue;208+ }
210- }209+ if (!transfer->Apply(renderPipelineAgent)) {
211- data->Apply(renderPipelineAgent);210+ RS_LOGE("%{public}s: Apply failed for typeId %{public}u", __func__, static_cast<uint32_t>(typeId));
212 }211 }
213 }212 }
214}213}
@@ -45,7 +45,7 @@ private:
45 sptr<RSIRenderToServiceConnection> ConnectToRenderService();45 sptr<RSIRenderToServiceConnection> ConnectToRenderService();
46 46 
47 void ApplyIpcPersistenceData(const sptr<RSRenderPipelineAgent>& renderPipelineAgent,47 void ApplyIpcPersistenceData(const sptr<RSRenderPipelineAgent>& renderPipelineAgent,
48- const IpcPersistenceTypeToDataMap& replayData);48+ const IpcPersistenceMap& replayData);
49#ifdef RES_SCHED_ENABLE49#ifdef RES_SCHED_ENABLE
50 void SubScribeSystemAbility();50 void SubScribeSystemAbility();
51#endif51#endif
@@ -1,295 +0,0 @@
1-/*
2- * Copyright (c) 2026 Huawei Device Co., Ltd.
3- * Licensed under the Apache License, Version 2.0 (the "License");
4- * you may not use this file except in compliance with the License.
5- * You may obtain a copy of the License at
6- *
7- * http://www.apache.org/licenses/LICENSE-2.0
8- *
9- * Unless required by applicable law or agreed to in writing, software
10- * distributed under the License is distributed on an "AS IS" BASIS,
11- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12- * See the License for the specific language governing permissions and
13- * limitations under the License.
14- */
15- 
16-#include "rs_ipc_persistence_data.h"
17- 
18-#include <cstdint>
19- 
20-#include "platform/common/rs_log.h"
21-#include "rs_render_pipeline_agent.h"
22-#include "transaction/rs_marshalling_helper.h"
23- 
24-#undef LOG_TAG
25-#define LOG_TAG "RSIpcPersistenceData"
26- 
27-namespace OHOS {
28-namespace Rosen {
29-namespace {
30-constexpr uint32_t MAX_PID_SIZE_NUMBER = 100000;
31-constexpr uint32_t MAX_WATERMARK_GRID_COUNT = 255;
32-} // namespace
33- 
34-// SetWaterMark
35-bool SetWatermarkPersistenceData::Marshalling(Parcel& parcel) const
36-{
37- if (rowCount_ > MAX_WATERMARK_GRID_COUNT || colCount_ > MAX_WATERMARK_GRID_COUNT) {
38- RS_LOGE("SetWatermarkPersistenceData::Marshalling: rowCount or colCount out of range");
39- return false;
40- }
41- return RSMarshallingHelper::Marshalling(parcel, pid_) &&
42- RSMarshallingHelper::Marshalling(parcel, name_) &&
43- parcel.WriteParcelable(watermark_.get()) &&
44- RSMarshallingHelper::Marshalling(parcel, success_) &&
45- RSMarshallingHelper::Marshalling(parcel, rowCount_) &&
46- RSMarshallingHelper::Marshalling(parcel, colCount_);
47-}
48- 
49-SetWatermarkPersistenceData* SetWatermarkPersistenceData::Unmarshalling(Parcel& parcel)
50-{
51- auto result = std::make_unique<SetWatermarkPersistenceData>();
52- if (!RSMarshallingHelper::Unmarshalling(parcel, result->pid_)) {
53- RS_LOGE("SetWatermarkPersistenceData::Unmarshalling: failed to read pid");
54- return nullptr;
55- }
56- if (!RSMarshallingHelper::Unmarshalling(parcel, result->name_)) {
57- RS_LOGE("SetWatermarkPersistenceData::Unmarshalling: failed to read name");
58- return nullptr;
59- }
60- if (result->watermark_ = std::shared_ptr<Media::PixelMap>(parcel.ReadParcelable<Media::PixelMap>());
61- !result->watermark_) {
62- RS_LOGE("SetWatermarkPersistenceData::Unmarshalling: failed to read watermark");
63- return nullptr;
64- }
65- if (!RSMarshallingHelper::Unmarshalling(parcel, result->success_)) {
66- RS_LOGE("SetWatermarkPersistenceData::Unmarshalling: failed to read success");
67- return nullptr;
68- }
69- if (!RSMarshallingHelper::Unmarshalling(parcel, result->rowCount_)) {
70- RS_LOGE("SetWatermarkPersistenceData::Unmarshalling: failed to read rowCount");
71- return nullptr;
72- }
73- if (!RSMarshallingHelper::Unmarshalling(parcel, result->colCount_)) {
74- RS_LOGE("SetWatermarkPersistenceData::Unmarshalling: failed to read colCount");
75- return nullptr;
76- }
77- if (result->rowCount_ > MAX_WATERMARK_GRID_COUNT || result->colCount_ > MAX_WATERMARK_GRID_COUNT) {
78- RS_LOGE("SetWatermarkPersistenceData::Unmarshalling: rowCount or colCount out of range");
79- return nullptr;
80- }
81- return result.release();
82-}
83- 
84-void SetWatermarkPersistenceData::Apply(const sptr<RSRenderPipelineAgent>& renderPipelineAgent)
85-{
86- if (renderPipelineAgent) {
87- bool success = false;
88- renderPipelineAgent->SetWatermark(pid_, name_, watermark_, success, rowCount_, colCount_);
89- }
90-}
91- 
92-// ShowWaterMark
93-bool ShowWatermarkPersistenceData::Marshalling(Parcel& parcel) const
94-{
95- return parcel.WriteParcelable(watermarkImg_.get()) &&
96- RSMarshallingHelper::Marshalling(parcel, isShow_);
97-}
98- 
99-ShowWatermarkPersistenceData* ShowWatermarkPersistenceData::Unmarshalling(Parcel& parcel)
100-{
101- auto result = std::make_unique<ShowWatermarkPersistenceData>();
102- if (result->watermarkImg_ = std::shared_ptr<Media::PixelMap>(parcel.ReadParcelable<Media::PixelMap>());
103- !result->watermarkImg_) {
104- RS_LOGE("ShowWatermarkPersistenceData::Unmarshalling: failed to read watermarkImg");
105- return nullptr;
106- }
107- if (!RSMarshallingHelper::Unmarshalling(parcel, result->isShow_)) {
108- RS_LOGE("ShowWatermarkPersistenceData::Unmarshalling: failed to read isShow");
109- return nullptr;
110- }
111- return result.release();
112-}
113- 
114-void ShowWatermarkPersistenceData::Apply(const sptr<RSRenderPipelineAgent>& renderPipelineAgent)
115-{
116- if (renderPipelineAgent) {
117- renderPipelineAgent->ShowWatermark(watermarkImg_, isShow_);
118- }
119-}
120- 
121-// OnHwcEvent
122-bool OnHwcEventPersistenceData::Marshalling(Parcel& parcel) const
123-{
124- return RSMarshallingHelper::Marshalling(parcel, deviceId_) &&
125- RSMarshallingHelper::Marshalling(parcel, eventId_) &&
126- RSMarshallingHelper::Marshalling(parcel, eventData_);
127-}
128- 
129-OnHwcEventPersistenceData* OnHwcEventPersistenceData::Unmarshalling(Parcel& parcel)
130-{
131- auto result = std::make_unique<OnHwcEventPersistenceData>();
132- if (!RSMarshallingHelper::Unmarshalling(parcel, result->deviceId_)) {
133- RS_LOGE("OnHwcEventPersistenceData::Unmarshalling: failed to read deviceId");
134- return nullptr;
135- }
136- if (!RSMarshallingHelper::Unmarshalling(parcel, result->eventId_)) {
137- RS_LOGE("OnHwcEventPersistenceData::Unmarshalling: failed to read eventId");
138- return nullptr;
139- }
140- if (!RSMarshallingHelper::Unmarshalling(parcel, result->eventData_)) {
141- RS_LOGE("OnHwcEventPersistenceData::Unmarshalling: failed to read eventData");
142- return nullptr;
143- }
144- return result.release();
145-}
146- 
147-void OnHwcEventPersistenceData::Apply(const sptr<RSRenderPipelineAgent>& renderPipelineAgent)
148-{
149- if (renderPipelineAgent) {
150- renderPipelineAgent->NotifyHwcEventToRender(deviceId_, eventId_, eventData_);
151- }
152-}
153- 
154-// SetBehindWindowFilterEnabled
155-bool SetBehindWindowFilterEnabledPersistenceData::Marshalling(Parcel& parcel) const
156-{
157- return RSMarshallingHelper::Marshalling(parcel, enabled_);
158-}
159- 
160-SetBehindWindowFilterEnabledPersistenceData* SetBehindWindowFilterEnabledPersistenceData::Unmarshalling(Parcel& parcel)
161-{
162- auto result = std::make_unique<SetBehindWindowFilterEnabledPersistenceData>();
163- if (!RSMarshallingHelper::Unmarshalling(parcel, result->enabled_)) {
164- RS_LOGE("SetBehindWindowFilterEnabledPersistenceData::Unmarshalling: failed to read enabled");
165- return nullptr;
166- }
167- return result.release();
168-}
169- 
170-void SetBehindWindowFilterEnabledPersistenceData::Apply(const sptr<RSRenderPipelineAgent>& renderPipelineAgent)
171-{
172- if (renderPipelineAgent) {
173- renderPipelineAgent->SetBehindWindowFilterEnabled(enabled_);
174- }
175-}
176- 
177-// SetShowRefreshRateEnabled
178-bool SetShowRefreshRateEnabledPersistenceData::Marshalling(Parcel& parcel) const
179-{
180- return RSMarshallingHelper::Marshalling(parcel, enabled_) &&
181- RSMarshallingHelper::Marshalling(parcel, type_);
182-}
183- 
184-SetShowRefreshRateEnabledPersistenceData* SetShowRefreshRateEnabledPersistenceData::Unmarshalling(Parcel& parcel)
185-{
186- auto result = std::make_unique<SetShowRefreshRateEnabledPersistenceData>();
187- if (!RSMarshallingHelper::Unmarshalling(parcel, result->enabled_)) {
188- RS_LOGE("SetShowRefreshRateEnabledPersistenceData::Unmarshalling: failed to read enabled");
189- return nullptr;
190- }
191- if (!RSMarshallingHelper::Unmarshalling(parcel, result->type_)) {
192- RS_LOGE("SetShowRefreshRateEnabledPersistenceData::Unmarshalling: failed to read type");
193- return nullptr;
194- }
195- return result.release();
196-}
197- 
198-void SetShowRefreshRateEnabledPersistenceData::Apply(const sptr<RSRenderPipelineAgent>& renderPipelineAgent)
199-{
200- if (renderPipelineAgent) {
201- renderPipelineAgent->SetShowRefreshRateEnabled(enabled_, type_);
202- }
203-}
204- 
205-// SelfDrawingNodeRectChangeCallback
206-bool SelfDrawingNodeRectChangeCallbackPersistenceData::Marshalling(Parcel& parcel) const
207-{
208- MessageParcel* message = static_cast<MessageParcel*>(&parcel);
209- if (!message->WriteInt32(pid_)) {
210- return false;
211- }
212- 
213- size_t pidsSize = constraint_.pids.size();
214- if (pidsSize > UINT32_MAX) {
215- RS_LOGE("%{public}s: pids.size() exceeds UINT32_MAX", __func__);
216- return false;
217- }
218- uint32_t size = static_cast<uint32_t>(pidsSize);
219- if (!message->WriteUint32(size)) {
220- return false;
221- }
222- for (int32_t pid : constraint_.pids) {
223- if (!message->WriteInt32(pid)) {
224- return false;
225- }
226- }
227- 
228- if (!message->WriteInt32(constraint_.range.lowLimit.width) ||
229- !message->WriteInt32(constraint_.range.lowLimit.height) ||
230- !message->WriteInt32(constraint_.range.highLimit.width) ||
231- !message->WriteInt32(constraint_.range.highLimit.height)) {
232- return false;
233- }
234- if (!message->WriteRemoteObject(callback_->AsObject())) {
235- return false;
236- }
237- return true;
238-}
239- 
240-SelfDrawingNodeRectChangeCallbackPersistenceData* SelfDrawingNodeRectChangeCallbackPersistenceData::Unmarshalling(
241- Parcel& parcel)
242-{
243- auto result = std::make_unique<SelfDrawingNodeRectChangeCallbackPersistenceData>();
244- MessageParcel* message = static_cast<MessageParcel*>(&parcel);
245- if (!message->ReadInt32(result->pid_)) {
246- RS_LOGE("SelfDrawingNodeRectChangeCallbackPersistenceData::Unmarshalling: failed to read pid");
247- return nullptr;
248- }
249- uint32_t size;
250- if (!message->ReadUint32(size)) {
251- RS_LOGE("SelfDrawingNodeRectChangeCallbackPersistenceData::Unmarshalling: failed to read pids size");
252- return nullptr;
253- }
254- if (size > MAX_PID_SIZE_NUMBER) {
255- RS_LOGE(
256- "SelfDrawingNodeRectChangeCallbackPersistenceData::Unmarshalling: pids size exceeds MAX_PID_SIZE_NUMBER");
257- return nullptr;
258- }
259- for (uint32_t i = 0; i < size; ++i) {
260- pid_t pid;
261- if (!message->ReadInt32(pid)) {
262- RS_LOGE("SelfDrawingNodeRectChangeCallbackPersistenceData::Unmarshalling: failed to read pid in pids");
263- return nullptr;
264- }
265- result->constraint_.pids.insert(pid);
266- }
267- if (!message->ReadInt32(result->constraint_.range.lowLimit.width) ||
268- !message->ReadInt32(result->constraint_.range.lowLimit.height) ||
269- !message->ReadInt32(result->constraint_.range.highLimit.width) ||
270- !message->ReadInt32(result->constraint_.range.highLimit.height)) {
271- RS_LOGE("SelfDrawingNodeRectChangeCallbackPersistenceData::Unmarshalling: failed to read range");
272- return nullptr;
273- }
274- 
275- auto remoteObject = message->ReadRemoteObject();
276- if (remoteObject == nullptr) {
277- RS_LOGE("SelfDrawingNodeRectChangeCallbackPersistenceData::Unmarshalling: failed to read remoteObject");
278- return nullptr;
279- }
280- result->callback_ = iface_cast<RSISelfDrawingNodeRectChangeCallback>(remoteObject);
281- if (result->callback_ == nullptr) {
282- RS_LOGE("SelfDrawingNodeRectChangeCallbackPersistenceData::Unmarshalling: failed to cast callback");
283- return nullptr;
284- }
285- return result.release();
286-}
287- 
288-void SelfDrawingNodeRectChangeCallbackPersistenceData::Apply(const sptr<RSRenderPipelineAgent>& renderPipelineAgent)
289-{
290- if (renderPipelineAgent) {
291- renderPipelineAgent->RegisterSelfDrawingNodeRectChangeCallback(pid_, constraint_, callback_);
292- }
293-}
294-} // namespace Rosen
295-} // namespace OHOS
@@ -1,156 +0,0 @@
1-/*
2- * Copyright (c) 2026 Huawei Device Co., Ltd.
3- * Licensed under the Apache License, Version 2.0 (the "License");
4- * you may not use this file except in compliance with the License.
5- * You may obtain a copy of the License at
6- *
7- * http://www.apache.org/licenses/LICENSE-2.0
8- *
9- * Unless required by applicable law or agreed to in writing, software
10- * distributed under the License is distributed on an "AS IS" BASIS,
11- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12- * See the License for the specific language governing permissions and
13- * limitations under the License.
14- */
15- 
16-#ifndef RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_IPC_PERSISTENCE_RS_IPC_PERSISTENCE_DATA_H
17-#define RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_IPC_PERSISTENCE_RS_IPC_PERSISTENCE_DATA_H
18- 
19-#include "common/rs_self_draw_rect_change_callback_constraint.h"
20-#include "ipc_callbacks/rs_iself_drawing_node_rect_change_callback.h"
21-#include "rs_ipc_persistence_def.h"
22- 
23-namespace OHOS {
24-namespace Media {
25-class PixelMap;
26-} // namespace Media
27- 
28-namespace Rosen {
29-class SetWatermarkPersistenceData : public RSIpcPersistenceDataBase {
30-public:
31- SetWatermarkPersistenceData() = default;
32- SetWatermarkPersistenceData(pid_t pid, const std::string& name, std::shared_ptr<Media::PixelMap> watermark,
33- bool success, uint32_t rowCount = 0, uint32_t colCount = 0)
34- : pid_(pid), name_(name), watermark_(watermark), success_(success), rowCount_(rowCount), colCount_(colCount)
35- {}
36- ~SetWatermarkPersistenceData() noexcept override = default;
37- 
38- RSIpcPersistenceType GetType() const override { return RSIpcPersistenceType::SET_WATERMARK; }
39- pid_t GetCallingPid() const override { return pid_; }
40- 
41- bool Marshalling(Parcel& parcel) const override;
42- [[nodiscard]] static SetWatermarkPersistenceData* Unmarshalling(Parcel& parcel);
43- 
44- void Apply(const sptr<RSRenderPipelineAgent>& renderPipelineAgent) override;
45- 
46-private:
47- pid_t pid_;
48- std::string name_;
49- std::shared_ptr<Media::PixelMap> watermark_;
50- bool success_;
51- uint32_t rowCount_;
52- uint32_t colCount_;
53-};
54- 
55-class ShowWatermarkPersistenceData : public RSIpcPersistenceDataBase {
56-public:
57- ShowWatermarkPersistenceData() = default;
58- ShowWatermarkPersistenceData(const std::shared_ptr<Media::PixelMap>& watermarkImg, bool isShow)
59- : watermarkImg_(watermarkImg), isShow_(isShow) {}
60- ~ShowWatermarkPersistenceData() noexcept override = default;
61- 
62- RSIpcPersistenceType GetType() const override { return RSIpcPersistenceType::SHOW_WATERMARK; }
63- 
64- bool Marshalling(Parcel& parcel) const override;
65- [[nodiscard]] static ShowWatermarkPersistenceData* Unmarshalling(Parcel& parcel);
66- 
67- void Apply(const sptr<RSRenderPipelineAgent>& renderPipelineAgent) override;
68- 
69-private:
70- std::shared_ptr<Media::PixelMap> watermarkImg_;
71- bool isShow_;
72-};
73- 
74-class OnHwcEventPersistenceData : public RSIpcPersistenceDataBase {
75-public:
76- OnHwcEventPersistenceData() = default;
77- OnHwcEventPersistenceData(uint32_t deviceId, uint32_t eventId, const std::vector<int32_t>& eventData)
78- : deviceId_(deviceId), eventId_(eventId), eventData_(eventData) {}
79- ~OnHwcEventPersistenceData() noexcept override = default;
80- 
81- RSIpcPersistenceType GetType() const override { return RSIpcPersistenceType::ON_HWC_EVENT; }
82- 
83- bool Marshalling(Parcel& parcel) const override;
84- [[nodiscard]] static OnHwcEventPersistenceData* Unmarshalling(Parcel& parcel);
85- 
86- void Apply(const sptr<RSRenderPipelineAgent>& renderPipelineAgent) override;
87- 
88-private:
89- uint32_t deviceId_;
90- uint32_t eventId_;
91- std::vector<int32_t> eventData_;
92-};
93- 
94-class SetBehindWindowFilterEnabledPersistenceData : public RSIpcPersistenceDataBase {
95-public:
96- SetBehindWindowFilterEnabledPersistenceData() = default;
97- explicit SetBehindWindowFilterEnabledPersistenceData(bool enabled) : enabled_(enabled) {}
98- ~SetBehindWindowFilterEnabledPersistenceData() noexcept override = default;
99- 
100- RSIpcPersistenceType GetType() const override { return RSIpcPersistenceType::SET_BEHIND_WINDOW_FILTER_ENABLED; }
101- 
102- bool Marshalling(Parcel& parcel) const override;
103- [[nodiscard]] static SetBehindWindowFilterEnabledPersistenceData* Unmarshalling(Parcel& parcel);
104- 
105- void Apply(const sptr<RSRenderPipelineAgent>& renderPipelineAgent) override;
106- 
107-private:
108- bool enabled_;
109-};
110- 
111-class SetShowRefreshRateEnabledPersistenceData : public RSIpcPersistenceDataBase {
112-public:
113- SetShowRefreshRateEnabledPersistenceData() = default;
114- SetShowRefreshRateEnabledPersistenceData(bool enabled, int32_t type) : enabled_(enabled), type_(type) {}
115- ~SetShowRefreshRateEnabledPersistenceData() noexcept override = default;
116- 
117- RSIpcPersistenceType GetType() const override { return RSIpcPersistenceType::SET_SHOW_REFRESH_RATE_ENABLED; }
118- 
119- bool Marshalling(Parcel& parcel) const override;
120- [[nodiscard]] static SetShowRefreshRateEnabledPersistenceData* Unmarshalling(Parcel& parcel);
121- 
122- void Apply(const sptr<RSRenderPipelineAgent>& renderPipelineAgent) override;
123- 
124-private:
125- bool enabled_;
126- int32_t type_;
127-};
128- 
129-class SelfDrawingNodeRectChangeCallbackPersistenceData : public RSIpcPersistenceDataBase {
130-public:
131- SelfDrawingNodeRectChangeCallbackPersistenceData() = default;
132- SelfDrawingNodeRectChangeCallbackPersistenceData(
133- pid_t pid, const RectConstraint& constraint, sptr<RSISelfDrawingNodeRectChangeCallback> callback)
134- : pid_(pid), constraint_(constraint), callback_(callback) {}
135- ~SelfDrawingNodeRectChangeCallbackPersistenceData() noexcept override = default;
136- 
137- RSIpcPersistenceType GetType() const override
138- {
139- return RSIpcPersistenceType::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK;
140- }
141- pid_t GetCallingPid() const override { return pid_; }
142- 
143- bool Marshalling(Parcel& parcel) const override;
144- [[nodiscard]] static SelfDrawingNodeRectChangeCallbackPersistenceData* Unmarshalling(Parcel& parcel);
145- 
146- void Apply(const sptr<RSRenderPipelineAgent>& renderPipelineAgent) override;
147- 
148-private:
149- pid_t pid_;
150- RectConstraint constraint_;
151- sptr<RSISelfDrawingNodeRectChangeCallback> callback_;
152-};
153-} // namespace Rosen
154-} // namespace OHOS
155- 
156-#endif // RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_IPC_PERSISTENCE_RS_IPC_PERSISTENCE_DATA_H
@@ -16,40 +16,177 @@
16#ifndef RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_IPC_PERSISTENCE_RS_IPC_PERSISTENCE_DEF_H16#ifndef RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_IPC_PERSISTENCE_RS_IPC_PERSISTENCE_DEF_H
17#define RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_IPC_PERSISTENCE_RS_IPC_PERSISTENCE_DEF_H17#define RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_IPC_PERSISTENCE_RS_IPC_PERSISTENCE_DEF_H
18 18 
19+#include <cstdint>
19#include <memory>20#include <memory>
21+#include <mutex>
22+#include <sys/types.h>
23+#include <unordered_map>
20 24 
21#include <parcel.h>25#include <parcel.h>
26+#include "render_process/transaction/zidl/rs_iservice_to_render_connection_ipc_interface_code.h"
22 27 
23namespace OHOS {28namespace OHOS {
24namespace Rosen {29namespace Rosen {
25-enum class RSIpcPersistenceType : uint32_t {30+ 
26- SET_WATERMARK = 0,31+enum class FanoutPolicy : uint32_t {
27- SHOW_WATERMARK,32+ ANY_SUCCESS = 0, // success if any render process accepted the transfer
28- ON_HWC_EVENT,33+ FAIL_FAST = 1, // return the first failure immediately without sending to the remaining processes
29- SET_BEHIND_WINDOW_FILTER_ENABLED,
30- SET_SHOW_REFRESH_RATE_ENABLED,
31- REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK,
32- DEFAULT = 0xFFFFFFFF,
33};34};
34 35 
35-// Indicates the default PID of the IPC that does not need the calling PID.36+namespace Detail {
36-constexpr pid_t IPC_PERSISTENCE_DEFAULT_PID = -1;37+constexpr uint32_t MAX_PERSIST_MAP_SIZE = 100;
38+constexpr int32_t REPLY_RESULT_PENDING = -1;
39+} // namespace Detail
37 40 
38class RSRenderPipelineAgent;41class RSRenderPipelineAgent;
42+class RSIpcTransferBase;
39 43 
40-class RSIpcPersistenceDataBase : public Parcelable {44+using IpcPersistenceMap =
45+ std::unordered_map<RSIServiceToRenderConnectionInterfaceCode, std::shared_ptr<RSIpcTransferBase>>;
46+ 
47+class RSIpcTransferBase {
41public:48public:
42- RSIpcPersistenceDataBase() = default;49+ virtual ~RSIpcTransferBase() = default;
43- ~RSIpcPersistenceDataBase() noexcept override = default;
44 50 
45- virtual RSIpcPersistenceType GetType() const = 0;51+ virtual RSIServiceToRenderConnectionInterfaceCode GetTypeId() const = 0;
46- virtual pid_t GetCallingPid() const { return IPC_PERSISTENCE_DEFAULT_PID; }52+ virtual RSIServiceToRenderConnectionInterfaceCode GetPersistLockTypeId() const { return GetTypeId(); }
53+ virtual bool IsPersistent() const = 0; // true: persist and replay on render process restart
54+ virtual bool IsSync() const = 0; // true: sync IPC, reply marshalled back to proxy
55+ virtual FanoutPolicy GetFanoutPolicy() const = 0; // fanout aggregation rule across render processes
56+ virtual int32_t GetReplyResult() const { return Detail::REPLY_RESULT_PENDING; }
47 57 
48- virtual void Apply(const sptr<RSRenderPipelineAgent>& renderPipelineAgent) = 0;58+ virtual void Persist(IpcPersistenceMap& map, std::mutex& mutex) = 0;
59+ virtual void ClearPid(pid_t pid) = 0;
60+ 
61+ virtual bool Apply(const sptr<RSRenderPipelineAgent>& agent) = 0;
62+ 
63+ virtual bool ProxyMarshalling(Parcel& parcel) const = 0;
64+ virtual bool StubMarshalling(Parcel& parcel) const = 0;
65+ virtual bool ProxyUnmarshalling(Parcel& parcel) = 0;
66+ 
67+ virtual std::shared_ptr<RSIpcTransferBase> CopyTransfer() const = 0;
68+ 
69+ RSIpcTransferBase(const RSIpcTransferBase&) = delete;
70+ RSIpcTransferBase& operator=(const RSIpcTransferBase&) = delete;
71+ RSIpcTransferBase(RSIpcTransferBase&&) = delete;
72+ RSIpcTransferBase& operator=(RSIpcTransferBase&&) = delete;
73+ 
74+protected:
75+ RSIpcTransferBase() = default;
76+ 
77+ mutable std::mutex mutex_;
78+};
79+ 
80+template<typename Derived>
81+class RSIpcPersistenceDataBase {
82+public:
83+ virtual ~RSIpcPersistenceDataBase() = default;
84+ 
85+ virtual bool Marshalling(Parcel& parcel) const = 0;
86+ 
87+ [[nodiscard]] static std::shared_ptr<Derived> Unmarshalling(Parcel& parcel, int32_t& errCode)
88+ {
89+ return Derived::Unmarshalling(parcel, errCode);
90+ }
91+ 
92+ RSIpcPersistenceDataBase(const RSIpcPersistenceDataBase&) = delete;
93+ RSIpcPersistenceDataBase& operator=(const RSIpcPersistenceDataBase&) = delete;
94+ RSIpcPersistenceDataBase(RSIpcPersistenceDataBase&&) = delete;
95+ RSIpcPersistenceDataBase& operator=(RSIpcPersistenceDataBase&&) = delete;
96+ 
97+protected:
98+ RSIpcPersistenceDataBase() = default;
99+};
100+ 
101+template<typename Derived>
102+class RSIpcPersistenceReplyBase {
103+public:
104+ virtual ~RSIpcPersistenceReplyBase() = default;
105+ 
106+ virtual bool Marshalling(Parcel& parcel) const = 0;
107+ virtual bool Unmarshalling(Parcel& parcel) = 0;
108+ 
109+ RSIpcPersistenceReplyBase(const RSIpcPersistenceReplyBase&) = delete;
110+ RSIpcPersistenceReplyBase& operator=(const RSIpcPersistenceReplyBase&) = delete;
111+ RSIpcPersistenceReplyBase(RSIpcPersistenceReplyBase&&) = delete;
112+ RSIpcPersistenceReplyBase& operator=(RSIpcPersistenceReplyBase&&) = delete;
113+ 
114+protected:
115+ RSIpcPersistenceReplyBase() = default;
116+};
117+ 
118+class RSIpcEmptyReply final : public RSIpcPersistenceReplyBase<RSIpcEmptyReply> {
119+public:
120+ bool Marshalling(Parcel& parcel) const override
121+ {
122+ (void)parcel;
123+ return true;
124+ }
125+ bool Unmarshalling(Parcel& parcel) override
126+ {
127+ (void)parcel;
128+ return true;
129+ }
130+};
131+ 
132+template<RSIServiceToRenderConnectionInterfaceCode TypeId, typename TransferClass>
133+class RSIpcPersistentTransferRegister;
134+ 
135+template<typename TransferClass>
136+struct TransferRegistrationChecker {
137+ static constexpr bool Check = TransferClass::registered_;
138+ static const RSIpcPersistentTransferRegister<TransferClass::TypeId, TransferClass> registrar;
139+};
140+ 
141+template<typename Derived, typename InputData, typename ReplyData>
142+class RSIpcTransferCRTP : public RSIpcTransferBase {
143+public:
144+ RSIpcTransferCRTP()
145+ {
146+ static_assert(TransferRegistrationChecker<Derived>::Check,
147+ "Transfer must declare static bool registered_ (required by RSIpcPersistentTransferRegister)");
148+ [[maybe_unused]] auto* reg = &TransferRegistrationChecker<Derived>::registrar;
149+ }
150+ 
151+ bool StubMarshalling(Parcel& parcel) const override
152+ {
153+ std::lock_guard<std::mutex> lock(mutex_);
154+ if (!replyData_) {
155+ return false;
156+ }
157+ return replyData_->Marshalling(parcel);
158+ }
159+ 
160+ bool ProxyUnmarshalling(Parcel& parcel) override
161+ {
162+ std::lock_guard<std::mutex> lock(mutex_);
163+ if (!replyData_) {
164+ replyData_ = std::make_shared<ReplyData>();
165+ }
166+ return replyData_->Unmarshalling(parcel);
167+ }
168+ 
169+ [[nodiscard]] static std::shared_ptr<Derived> StubUnmarshalling(
170+ Parcel& parcel, uint32_t maxEntries, int32_t& errCode)
171+ {
172+ (void)maxEntries;
173+ auto input = RSIpcPersistenceDataBase<InputData>::Unmarshalling(parcel, errCode);
174+ if (!input) {
175+ return nullptr;
176+ }
177+ return std::make_shared<Derived>(input);
178+ }
179+ 
180+protected:
181+ void SetReplyData(std::shared_ptr<ReplyData> data)
182+ {
183+ std::lock_guard<std::mutex> lock(mutex_);
184+ replyData_ = std::move(data);
185+ }
186+ 
187+ std::shared_ptr<ReplyData> replyData_;
49};188};
50 189 
51-using IpcPersistenceTypeToDataMap =
52- std::unordered_map<RSIpcPersistenceType, std::vector<std::shared_ptr<RSIpcPersistenceDataBase>>>;
53} // namespace Rosen190} // namespace Rosen
54} // namespace OHOS191} // namespace OHOS
55 192 
@@ -16,183 +16,170 @@
16#include "rs_ipc_persistence_manager.h"16#include "rs_ipc_persistence_manager.h"
17 17 
18#include "platform/common/rs_log.h"18#include "platform/common/rs_log.h"
19-#include "rs_ipc_persistence_data.h"
20 19 
21#undef LOG_TAG20#undef LOG_TAG
22#define LOG_TAG "RSIpcPersistenceManager"21#define LOG_TAG "RSIpcPersistenceManager"
23 22 
24namespace OHOS {23namespace OHOS {
25namespace Rosen {24namespace Rosen {
26-namespace {
27-constexpr uint32_t MAX_MAP_SIZE = 100;
28-constexpr uint32_t MAX_VECTOR_SIZE = 200;
29-} // namespace
30 25 
31-IpcPersistenceTypeToDataMap RSIpcPersistenceManager::GetReplayData() const26+RSIpcPersistenceManager::FactoryRegistry& RSIpcPersistenceManager::GetFactoryRegistry()
32{27{
33- std::lock_guard<std::mutex> lock(mutex_);28+ static FactoryRegistry* reg = new FactoryRegistry();
34- return replayData_;29+ return *reg;
35}30}
36 31 
37-void RSIpcPersistenceManager::RegisterWithCallingPid(std::shared_ptr<RSIpcPersistenceDataBase> data)32+void RSIpcPersistenceManager::RegisterFactory(RSIServiceToRenderConnectionInterfaceCode typeId, TransferFactory factory)
38{33{
39- if (!data || data->GetCallingPid() == IPC_PERSISTENCE_DEFAULT_PID) {34+ auto& reg = GetFactoryRegistry();
40- return;35+ std::lock_guard<std::mutex> lock(reg.mutex);
36+ bool isNewTypeId = reg.map.find(typeId) == reg.map.end();
37+ reg.map[typeId] = factory;
38+ if (reg.typeMutexes.find(typeId) == reg.typeMutexes.end()) {
39+ reg.typeMutexes.emplace(typeId, std::make_shared<std::mutex>());
41 }40 }
42- std::lock_guard<std::mutex> lock(mutex_);41+ if (isNewTypeId) {
43- UnregisterByTypeAndCallingPidLocked(data->GetType(), data->GetCallingPid());42+ auto typeIds = std::make_shared<std::vector<RSIServiceToRenderConnectionInterfaceCode>>(*reg.typeIds);
44- replayData_[data->GetType()].emplace_back(data);43+ typeIds->push_back(typeId);
45-}44+ reg.typeIds = std::move(typeIds);
46- 
47-void RSIpcPersistenceManager::RegisterWithoutCallingPid(std::shared_ptr<RSIpcPersistenceDataBase> data)
48-{
49- if (!data || data->GetCallingPid() != IPC_PERSISTENCE_DEFAULT_PID) {
50- return;
51 }45 }
52- std::lock_guard<std::mutex> lock(mutex_);
53- UnregisterWithoutCallingPidByTypeLocked(data->GetType());
54- replayData_[data->GetType()].emplace_back(data);
55}46}
56 47 
57-void RSIpcPersistenceManager::UnregisterByType(RSIpcPersistenceType type)48+std::shared_ptr<const std::vector<RSIServiceToRenderConnectionInterfaceCode>>
49+RSIpcPersistenceManager::GetRegisteredTypeIds()
58{50{
59- std::lock_guard<std::mutex> lock(mutex_);51+ auto& reg = GetFactoryRegistry();
60- replayData_.erase(type);52+ std::lock_guard<std::mutex> lock(reg.mutex);
53+ return reg.typeIds;
61}54}
62 55 
63-void RSIpcPersistenceManager::UnregisterByCallingPid(pid_t pid)56+std::shared_ptr<std::mutex> RSIpcPersistenceManager::GetTypeMutex(
57+ RSIServiceToRenderConnectionInterfaceCode typeId)
64{58{
65- std::lock_guard<std::mutex> lock(mutex_);59+ auto& reg = GetFactoryRegistry();
66- for (auto mapIter = replayData_.begin(); mapIter != replayData_.end();) {60+ std::lock_guard<std::mutex> lock(reg.mutex);
67- auto& dataVec = mapIter->second;61+ auto it = reg.typeMutexes.find(typeId);
68- dataVec.erase(std::remove_if(62+ if (it == reg.typeMutexes.end()) {
69- dataVec.begin(), dataVec.end(), [pid](const auto& data) { return data->GetCallingPid() == pid; }));63+ it = reg.typeMutexes.emplace(typeId, std::make_shared<std::mutex>()).first;
70- if (dataVec.empty()) {64+ }
71- mapIter = replayData_.erase(mapIter);65+ return it->second;
72- } else {66+}
73- mapIter++;67+ 
68+std::shared_ptr<RSIpcTransferBase> RSIpcPersistenceManager::CreateTransferByTypeId(
69+ RSIServiceToRenderConnectionInterfaceCode typeId, Parcel& parcel, int32_t& errCode, uint32_t maxEntries)
70+{
71+ TransferFactory factory = nullptr;
72+ {
73+ auto& reg = GetFactoryRegistry();
74+ std::lock_guard<std::mutex> lock(reg.mutex);
75+ auto it = reg.map.find(typeId);
76+ if (it == reg.map.end()) {
77+ RS_LOGE("%{public}s: typeId %{public}u not registered", __func__, static_cast<uint32_t>(typeId));
78+ errCode = ERR_INVALID_DATA;
79+ return nullptr;
74 }80 }
81+ factory = it->second;
75 }82 }
83+ return factory(parcel, maxEntries, errCode);
76}84}
77 85 
78-void RSIpcPersistenceManager::UnregisterWithoutCallingPidByTypeLocked(RSIpcPersistenceType type)86+IpcPersistenceMap RSIpcPersistenceManager::GetPersistenceMap() const
79-{
80- auto mapIter = replayData_.find(type);
81- if (mapIter == replayData_.end()) {
82- return;
83- }
84- auto& dataVec = mapIter->second;
85- dataVec.erase(std::remove_if(dataVec.begin(), dataVec.end(),
86- [](const auto& data) { return data->GetCallingPid() == IPC_PERSISTENCE_DEFAULT_PID; }));
87- if (dataVec.empty()) {
88- replayData_.erase(mapIter);
89- }
90-}
91- 
92-void RSIpcPersistenceManager::UnregisterWithoutCallingPidByType(RSIpcPersistenceType type)
93{87{
94 std::lock_guard<std::mutex> lock(mutex_);88 std::lock_guard<std::mutex> lock(mutex_);
95- UnregisterWithoutCallingPidByTypeLocked(type);89+ return persistedData_;
96}90}
97 91 
98-void RSIpcPersistenceManager::UnregisterByTypeAndCallingPidLocked(RSIpcPersistenceType type, pid_t pid)92+bool RSIpcPersistenceManager::Marshalling(Parcel& parcel, const IpcPersistenceMap& map)
99{93{
100- auto mapIter = replayData_.find(type);94+ if (map.size() > Detail::MAX_PERSIST_MAP_SIZE) {
101- if (mapIter == replayData_.end()) {95+ RS_LOGE("%{public}s: map size %{public}zu exceeds max %{public}u",
102- return;96+ __func__, map.size(), Detail::MAX_PERSIST_MAP_SIZE);
103- }
104- auto& dataVec = mapIter->second;
105- dataVec.erase(std::remove_if(
106- dataVec.begin(), dataVec.end(), [pid](const auto& data) { return data->GetCallingPid() == pid; }));
107- if (dataVec.empty()) {
108- replayData_.erase(mapIter);
109- }
110-}
111- 
112-void RSIpcPersistenceManager::UnregisterByTypeAndCallingPid(RSIpcPersistenceType type, pid_t pid)
113-{
114- std::lock_guard<std::mutex> lock(mutex_);
115- UnregisterByTypeAndCallingPidLocked(type, pid);
116-}
117- 
118-bool RSIpcPersistenceManager::Marshalling(Parcel& parcel, const IpcPersistenceTypeToDataMap& typeToDataMap)
119-{
120- if (!parcel.WriteUint32(typeToDataMap.size())) {
121 return false;97 return false;
122 }98 }
123- for (const auto& [type, dataVec] : typeToDataMap) {99+ if (!parcel.WriteUint32(static_cast<uint32_t>(map.size()))) {
124- if (!parcel.WriteUint32(static_cast<uint32_t>(type))) {100+ RS_LOGE("%{public}s: WriteUint32 size failed", __func__);
101+ return false;
102+ }
103+ for (const auto& [typeId, transfer] : map) {
104+ if (!parcel.WriteUint32(static_cast<uint32_t>(typeId))) {
105+ RS_LOGE("%{public}s: WriteUint32 typeId failed", __func__);
125 return false;106 return false;
126 }107 }
127- if (!parcel.WriteUint32(dataVec.size())) {108+ if (!transfer) {
109+ RS_LOGE("%{public}s: transfer is nullptr", __func__);
128 return false;110 return false;
129 }111 }
130- for (const auto& data : dataVec) {112+ if (!transfer->ProxyMarshalling(parcel)) {
131- if (!data->Marshalling(parcel)) {113+ RS_LOGE("%{public}s: Transfer ProxyMarshalling failed", __func__);
132- return false;114+ return false;
133- }
134 }115 }
135 }116 }
136 return true;117 return true;
137}118}
138 119 
139-std::optional<IpcPersistenceTypeToDataMap> RSIpcPersistenceManager::Unmarshalling(Parcel& parcel)120+std::optional<IpcPersistenceMap> RSIpcPersistenceManager::Unmarshalling(Parcel& parcel)
140{121{
141- uint32_t mapSize;122+ uint32_t typeCount = 0;
142- if (!parcel.ReadUint32(mapSize) || mapSize > MAX_MAP_SIZE) {123+ if (!parcel.ReadUint32(typeCount) || typeCount > Detail::MAX_PERSIST_MAP_SIZE) {
143- RS_LOGE("Unmarshalling: dataVecSize %{public}u exceeds max %{public}u", mapSize, MAX_MAP_SIZE);124+ RS_LOGE("%{public}s: typeCount %{public}u exceeds max %{public}u",
125+ __func__, typeCount, Detail::MAX_PERSIST_MAP_SIZE);
144 return std::nullopt;126 return std::nullopt;
145 }127 }
146- IpcPersistenceTypeToDataMap result;128+ 
147- for (uint32_t i = 0; i < mapSize; i++) {129+ IpcPersistenceMap dataMap;
148- uint32_t type;130+ for (uint32_t i = 0; i < typeCount; ++i) {
149- if (!parcel.ReadUint32(type)) {131+ uint32_t typeIdVal;
132+ if (!parcel.ReadUint32(typeIdVal)) {
133+ RS_LOGE("%{public}s: ReadUint32 typeId failed", __func__);
150 return std::nullopt;134 return std::nullopt;
151 }135 }
152- auto ipcPersistenceType = static_cast<RSIpcPersistenceType>(type);136+ auto typeId = static_cast<RSIServiceToRenderConnectionInterfaceCode>(typeIdVal);
153- uint32_t dataVecSize;137+ if (dataMap.find(typeId) != dataMap.end()) {
154- if (!parcel.ReadUint32(dataVecSize) || dataVecSize > MAX_VECTOR_SIZE) {138+ RS_LOGE("%{public}s: duplicate typeId %{public}u in replay data", __func__, typeIdVal);
155- RS_LOGE("Unmarshalling: dataVecSize %{public}u exceeds max %{public}u", dataVecSize, MAX_VECTOR_SIZE);
156 return std::nullopt;139 return std::nullopt;
157 }140 }
158- for (uint32_t j = 0; j < dataVecSize; j++) {141+ int32_t deserErr = ERR_NULL_OBJECT;
159- std::shared_ptr<RSIpcPersistenceDataBase> data;142+ auto transfer = RSIpcPersistenceManager::CreateTransferByTypeId(typeId, parcel, deserErr);
160- switch (ipcPersistenceType) {143+ if (!transfer) {
161- case RSIpcPersistenceType::SET_WATERMARK:144+ RS_LOGE("%{public}s: CreateTransferByTypeId failed for typeId %{public}u, err=%{public}d",
162- data = std::shared_ptr<SetWatermarkPersistenceData>(145+ __func__, typeIdVal, deserErr);
163- SetWatermarkPersistenceData::Unmarshalling(parcel));146+ return std::nullopt;
164- break;147+ }
165- case RSIpcPersistenceType::SHOW_WATERMARK:148+ dataMap[typeId] = std::move(transfer);
166- data = std::shared_ptr<ShowWatermarkPersistenceData>(149+ }
167- ShowWatermarkPersistenceData::Unmarshalling(parcel));150+ return dataMap;
168- break;151+}
169- case RSIpcPersistenceType::ON_HWC_EVENT:152+ 
170- data = std::shared_ptr<OnHwcEventPersistenceData>(OnHwcEventPersistenceData::Unmarshalling(parcel));153+void RSIpcPersistenceManager::PersistTransfer(const std::shared_ptr<RSIpcTransferBase>& transfer)
171- break;154+{
172- case RSIpcPersistenceType::SET_BEHIND_WINDOW_FILTER_ENABLED:155+ if (!transfer || !transfer->IsPersistent()) {
173- data = std::shared_ptr<SetBehindWindowFilterEnabledPersistenceData>(156+ return;
174- SetBehindWindowFilterEnabledPersistenceData::Unmarshalling(parcel));157+ }
175- break;158+ auto typeMutex = GetTypeMutex(transfer->GetPersistLockTypeId());
176- case RSIpcPersistenceType::SET_SHOW_REFRESH_RATE_ENABLED:159+ std::lock_guard<std::mutex> typeLock(*typeMutex);
177- data = std::shared_ptr<SetShowRefreshRateEnabledPersistenceData>(160+ transfer->Persist(persistedData_, mutex_);
178- SetShowRefreshRateEnabledPersistenceData::Unmarshalling(parcel));161+}
179- break;162+ 
180- case RSIpcPersistenceType::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK:163+void RSIpcPersistenceManager::ClearPid(pid_t pid)
181- data = std::shared_ptr<SelfDrawingNodeRectChangeCallbackPersistenceData>(164+{
182- SelfDrawingNodeRectChangeCallbackPersistenceData::Unmarshalling(parcel));165+ auto typeIds = GetRegisteredTypeIds();
183- break;166+ for (const auto& typeId : *typeIds) {
184- default:167+ auto typeMutex = GetTypeMutex(typeId);
185- break;168+ std::lock_guard<std::mutex> typeLock(*typeMutex);
186- }169+ std::shared_ptr<RSIpcTransferBase> target;
187- if (data) {170+ {
188- result[ipcPersistenceType].emplace_back(data);171+ std::lock_guard<std::mutex> lock(mutex_);
189- } else {172+ auto it = persistedData_.find(typeId);
190- RS_LOGE("Unmarshalling: failed to unmarshall data for type %{public}u", type);173+ if (it == persistedData_.end()) {
191- return std::nullopt;174+ continue;
192 }175 }
176+ target = it->second;
177+ }
178+ if (target) {
179+ target->ClearPid(pid);
193 }180 }
194 }181 }
195- return result;
196}182}
183+ 
197} // namespace Rosen184} // namespace Rosen
198} // namespace OHOS185} // namespace OHOS
@@ -16,44 +16,78 @@
16#ifndef RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_IPC_PERSISTENCE_RS_IPC_PERSISTENCE_MANAGER_H16#ifndef RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_IPC_PERSISTENCE_RS_IPC_PERSISTENCE_MANAGER_H
17#define RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_IPC_PERSISTENCE_RS_IPC_PERSISTENCE_MANAGER_H17#define RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_IPC_PERSISTENCE_RS_IPC_PERSISTENCE_MANAGER_H
18 18 
19+#include <cstdint>
20+#include <limits>
19#include <mutex>21#include <mutex>
22+#include <optional>
23+#include <unordered_map>
24+#include <vector>
25+ 
26+#include <parcel.h>
27+#include "ipc_types.h"
20 28 
21#include "rs_ipc_persistence_def.h"29#include "rs_ipc_persistence_def.h"
22 30 
23namespace OHOS {31namespace OHOS {
24namespace Rosen {32namespace Rosen {
33+ 
25class RSIpcPersistenceManager {34class RSIpcPersistenceManager {
26public:35public:
36+ using TransferFactory = std::shared_ptr<RSIpcTransferBase>(*)(Parcel&, uint32_t, int32_t&);
37+ 
27 RSIpcPersistenceManager() = default;38 RSIpcPersistenceManager() = default;
28 ~RSIpcPersistenceManager() noexcept = default;39 ~RSIpcPersistenceManager() noexcept = default;
29 40 
30- IpcPersistenceTypeToDataMap GetReplayData() const;41+ RSIpcPersistenceManager(const RSIpcPersistenceManager&) = delete;
42+ RSIpcPersistenceManager& operator=(const RSIpcPersistenceManager&) = delete;
43+ RSIpcPersistenceManager(RSIpcPersistenceManager&&) = delete;
44+ RSIpcPersistenceManager& operator=(RSIpcPersistenceManager&&) = delete;
31 45 
32- // used to register a IPC with calling PID46+ static void RegisterFactory(RSIServiceToRenderConnectionInterfaceCode typeId, TransferFactory factory);
33- void RegisterWithCallingPid(std::shared_ptr<RSIpcPersistenceDataBase> data);47+ static std::shared_ptr<const std::vector<RSIServiceToRenderConnectionInterfaceCode>> GetRegisteredTypeIds();
34- // used to register a IPC without calling PID48+ static std::shared_ptr<std::mutex> GetTypeMutex(RSIServiceToRenderConnectionInterfaceCode typeId);
35- void RegisterWithoutCallingPid(std::shared_ptr<RSIpcPersistenceDataBase> data);49+ static std::shared_ptr<RSIpcTransferBase> CreateTransferByTypeId(
50+ RSIServiceToRenderConnectionInterfaceCode typeId, Parcel& parcel,
51+ int32_t& errCode, uint32_t maxEntries = std::numeric_limits<uint32_t>::max());
52+ void PersistTransfer(const std::shared_ptr<RSIpcTransferBase>& transfer);
53+ void ClearPid(pid_t pid);
36 54 
37- // unregister all IPCs of a specific type55+ IpcPersistenceMap GetPersistenceMap() const;
38- void UnregisterByType(RSIpcPersistenceType type);56+ static bool Marshalling(Parcel& parcel, const IpcPersistenceMap& map);
39- // unregister all IPCs with calling PID57+ [[nodiscard]] static std::optional<IpcPersistenceMap> Unmarshalling(Parcel& parcel);
40- void UnregisterByCallingPid(pid_t pid);
41- 
42- // unregister IPC with calling PID of a specific type
43- void UnregisterByTypeAndCallingPid(RSIpcPersistenceType type, pid_t pid);
44- // unregister IPC without calling PID of a specific type
45- void UnregisterWithoutCallingPidByType(RSIpcPersistenceType type);
46- 
47- static bool Marshalling(Parcel& parcel, const IpcPersistenceTypeToDataMap& typeToDataMap);
48- static std::optional<IpcPersistenceTypeToDataMap> Unmarshalling(Parcel& parcel);
49 58 
50private:59private:
51- void UnregisterByTypeAndCallingPidLocked(RSIpcPersistenceType type, pid_t pid);60+ using FactoryMap = std::unordered_map<RSIServiceToRenderConnectionInterfaceCode, TransferFactory>;
52- void UnregisterWithoutCallingPidByTypeLocked(RSIpcPersistenceType type);61+ using TypeMutexMap = std::unordered_map<RSIServiceToRenderConnectionInterfaceCode, std::shared_ptr<std::mutex>>;
62+ struct FactoryRegistry {
63+ std::mutex mutex;
64+ FactoryMap map;
65+ TypeMutexMap typeMutexes;
66+ std::shared_ptr<const std::vector<RSIServiceToRenderConnectionInterfaceCode>> typeIds =
67+ std::make_shared<std::vector<RSIServiceToRenderConnectionInterfaceCode>>();
68+ };
69+ static FactoryRegistry& GetFactoryRegistry();
53 70 
54 mutable std::mutex mutex_;71 mutable std::mutex mutex_;
55- IpcPersistenceTypeToDataMap replayData_;72+ IpcPersistenceMap persistedData_;
56};73};
74+ 
75+template<RSIServiceToRenderConnectionInterfaceCode TypeId, typename TransferClass>
76+class RSIpcPersistentTransferRegister {
77+public:
78+ RSIpcPersistentTransferRegister()
79+ {
80+ RSIpcPersistenceManager::RegisterFactory(
81+ TypeId,
82+ [](Parcel& parcel, uint32_t maxEntries, int32_t& errCode) -> std::shared_ptr<RSIpcTransferBase> {
83+ return TransferClass::StubUnmarshalling(parcel, maxEntries, errCode);
84+ });
85+ }
86+};
87+ 
88+template<typename TransferClass>
89+const RSIpcPersistentTransferRegister<TransferClass::TypeId, TransferClass>
90+ TransferRegistrationChecker<TransferClass>::registrar;
57} // namespace Rosen91} // namespace Rosen
58} // namespace OHOS92} // namespace OHOS
59 93 
@@ -139,12 +139,6 @@ void RSServiceToRenderConnection::ReportGameStateData(GameStateData info)
139 FrameReport::GetInstance().SetGameScene(info.pid, info.state);139 FrameReport::GetInstance().SetGameScene(info.pid, info.state);
140}140}
141 141 
142-ErrCode RSServiceToRenderConnection::SetBehindWindowFilterEnabled(bool enabled)
143-{
144- renderPipelineAgent_->SetBehindWindowFilterEnabled(enabled);
145- return ERR_OK;
146-}
147- 
148ErrCode RSServiceToRenderConnection::GetBehindWindowFilterEnabled(bool& enabled)142ErrCode RSServiceToRenderConnection::GetBehindWindowFilterEnabled(bool& enabled)
149{143{
150 enabled = renderPipelineAgent_->GetBehindWindowFilterEnabled();144 enabled = renderPipelineAgent_->GetBehindWindowFilterEnabled();
@@ -189,12 +183,6 @@ void RSServiceToRenderConnection::HgmForceUpdateTask(bool flag, const std::strin
189 renderPipelineAgent_->HgmForceUpdateTask(flag, fromWhom);183 renderPipelineAgent_->HgmForceUpdateTask(flag, fromWhom);
190}184}
191 185 
192-void RSServiceToRenderConnection::HandleHwcEvent(uint32_t deviceId, uint32_t eventId,
193- const std::vector<int32_t>& eventData)
194-{
195- renderPipelineAgent_->NotifyHwcEventToRender(deviceId, eventId, eventData);
196-}
197- 
198ErrCode RSServiceToRenderConnection::RepaintEverything()186ErrCode RSServiceToRenderConnection::RepaintEverything()
199{187{
200 ErrCode errCode = renderPipelineAgent_->RepaintEverything();188 ErrCode errCode = renderPipelineAgent_->RepaintEverything();
@@ -296,23 +284,12 @@ ErrCode RSServiceToRenderConnection::GetPixelMapByProcessId(std::vector<PixelMap
296 return renderPipelineAgent_->GetPixelMapByProcessId(pixelMapInfoVector, pid, repCode);284 return renderPipelineAgent_->GetPixelMapByProcessId(pixelMapInfoVector, pid, repCode);
297}285}
298 286 
299-ErrCode RSServiceToRenderConnection::SetWatermark(pid_t callingPid, const std::string& name,
300- std::shared_ptr<Media::PixelMap> watermark, bool& success, uint32_t rowCount, uint32_t colCount)
301-{
302- return renderPipelineAgent_->SetWatermark(callingPid, name, watermark, success, rowCount, colCount);
303-}
304- 
305ErrCode RSServiceToRenderConnection::SetUifirstScale(float scaleFactor)287ErrCode RSServiceToRenderConnection::SetUifirstScale(float scaleFactor)
306{288{
307 RS_LOGD("RSServiceToRenderConnection::SetUifirstScale scaleFactor:%{public}f", scaleFactor);289 RS_LOGD("RSServiceToRenderConnection::SetUifirstScale scaleFactor:%{public}f", scaleFactor);
308 return renderPipelineAgent_->SetUifirstScale(scaleFactor);290 return renderPipelineAgent_->SetUifirstScale(scaleFactor);
309}291}
310 292 
311-void RSServiceToRenderConnection::ShowWatermark(const std::shared_ptr<Media::PixelMap> &watermarkImg, bool isShow)
312-{
313- renderPipelineAgent_->ShowWatermark(watermarkImg, isShow);
314-}
315- 
316ErrCode RSServiceToRenderConnection::SetColorFollow(const std::string &nodeIdStr, bool isColorFollow)293ErrCode RSServiceToRenderConnection::SetColorFollow(const std::string &nodeIdStr, bool isColorFollow)
317{294{
318 return renderPipelineAgent_->SetColorFollow(nodeIdStr, isColorFollow);295 return renderPipelineAgent_->SetColorFollow(nodeIdStr, isColorFollow);
@@ -324,27 +301,11 @@ ErrCode RSServiceToRenderConnection::GetSurfaceRootNodeId(NodeId& windowNodeId)
324 return ERR_OK;301 return ERR_OK;
325}302}
326 303 
327-int32_t RSServiceToRenderConnection::RegisterSelfDrawingNodeRectChangeCallback(
328- pid_t remotePid, const RectConstraint& constraint, sptr<RSISelfDrawingNodeRectChangeCallback> callback)
329-{
330- return renderPipelineAgent_->RegisterSelfDrawingNodeRectChangeCallback(remotePid, constraint, callback);
331-}
332- 
333-int32_t RSServiceToRenderConnection::UnRegisterSelfDrawingNodeRectChangeCallback(pid_t remotePid)
334-{
335- return renderPipelineAgent_->UnRegisterSelfDrawingNodeRectChangeCallback(remotePid);
336-}
337- 
338uint32_t RSServiceToRenderConnection::GetRealtimeRefreshRate(ScreenId screenId)304uint32_t RSServiceToRenderConnection::GetRealtimeRefreshRate(ScreenId screenId)
339{305{
340 return renderPipelineAgent_->GetRealtimeRefreshRate(screenId);306 return renderPipelineAgent_->GetRealtimeRefreshRate(screenId);
341}307}
342 308 
343-void RSServiceToRenderConnection::SetShowRefreshRateEnabled(bool enabled, int32_t type)
344-{
345- renderPipelineAgent_->SetShowRefreshRateEnabled(enabled, type);
346-}
347- 
348ErrCode RSServiceToRenderConnection::GetShowRefreshRateEnabled(bool& enable)309ErrCode RSServiceToRenderConnection::GetShowRefreshRateEnabled(bool& enable)
349{310{
350 return renderPipelineAgent_->GetShowRefreshRateEnabled(enable);311 return renderPipelineAgent_->GetShowRefreshRateEnabled(enable);
@@ -399,5 +360,13 @@ void RSServiceToRenderConnection::SetCacheEnabledForRotation(bool enabled)
399{360{
400 renderPipelineAgent_->SetCacheEnabledForRotation(enabled);361 renderPipelineAgent_->SetCacheEnabledForRotation(enabled);
401}362}
363+ 
364+int32_t RSServiceToRenderConnection::SendTransfer(const std::shared_ptr<RSIpcTransferBase>& transfer)
365+{
366+ if (renderPipelineAgent_ == nullptr || !transfer) {
367+ return StatusCode::RS_CONNECTION_ERROR;
368+ }
369+ return transfer->Apply(renderPipelineAgent_) ? StatusCode::SUCCESS : StatusCode::RS_CONNECTION_ERROR;
370+}
402} // namespace Rosen371} // namespace Rosen
403} // namespace OHOS372} // namespace OHOS
@@ -19,6 +19,7 @@
19#include "rs_render_process_agent.h"19#include "rs_render_process_agent.h"
20#include "core/rs_render_pipeline_agent.h"20#include "core/rs_render_pipeline_agent.h"
21#include "zidl/rs_service_to_render_connection_stub.h"21#include "zidl/rs_service_to_render_connection_stub.h"
22+#include "ipc_persistence/rs_ipc_persistence_def.h"
22 23 
23namespace OHOS {24namespace OHOS {
24namespace Rosen {25namespace Rosen {
@@ -44,7 +45,6 @@ public:
44 45 
45 // Screen Manager46 // Screen Manager
46 int32_t NotifyScreenRefresh(ScreenId screenId) override;47 int32_t NotifyScreenRefresh(ScreenId screenId) override;
47- void HandleHwcEvent(uint32_t deviceId, uint32_t eventId, const std::vector<int32_t>& eventData) override;
48 void OnScreenBacklightChanged(const RsScreenBrightnessData& brightnessData) override;48 void OnScreenBacklightChanged(const RsScreenBrightnessData& brightnessData) override;
49 void OnGlobalBlacklistChanged(const std::unordered_set<NodeId>& globalBlackList) override;49 void OnGlobalBlacklistChanged(const std::unordered_set<NodeId>& globalBlackList) override;
50 50 
@@ -74,12 +74,6 @@ public:
74 ErrCode GetPixelMapByProcessId(std::vector<PixelMapInfo>& pixelMapInfoVector, pid_t pid, int32_t& repCode) override;74 ErrCode GetPixelMapByProcessId(std::vector<PixelMapInfo>& pixelMapInfoVector, pid_t pid, int32_t& repCode) override;
75 void SetCurtainScreenUsingStatus(bool isCurtainScreenOn) override;75 void SetCurtainScreenUsingStatus(bool isCurtainScreenOn) override;
76 76 
77- // Watermark
78- ErrCode SetWatermark(
79- pid_t callingPid, const std::string& name, std::shared_ptr<Media::PixelMap> watermark, bool& success,
80- uint32_t rowCount = 0, uint32_t colCount = 0) override;
81- void ShowWatermark(const std::shared_ptr<Media::PixelMap>& watermarkImg, bool isShow) override;
82- 
83 // uifirstcale77 // uifirstcale
84 ErrCode SetUifirstScale(float scaleFactor) override;78 ErrCode SetUifirstScale(float scaleFactor) override;
85 79 
@@ -96,7 +90,6 @@ public:
96 void NotifyWindowModeTypeEvent(uint8_t windowModeType) override;90 void NotifyWindowModeTypeEvent(uint8_t windowModeType) override;
97 void HgmForceUpdateTask(bool flag, const std::string& fromWhom) override;91 void HgmForceUpdateTask(bool flag, const std::string& fromWhom) override;
98 uint32_t GetRealtimeRefreshRate(ScreenId screenId) override;92 uint32_t GetRealtimeRefreshRate(ScreenId screenId) override;
99- void SetShowRefreshRateEnabled(bool enabled, int32_t type) override;
100 ErrCode GetShowRefreshRateEnabled(bool& enable) override;93 ErrCode GetShowRefreshRateEnabled(bool& enable) override;
101 94 
102 // Overlay95 // Overlay
@@ -107,9 +100,6 @@ public:
107 ErrCode SendVideoRateInfo(const std::unordered_map<std::string, std::string>& videoRateInfo) override;100 ErrCode SendVideoRateInfo(const std::unordered_map<std::string, std::string>& videoRateInfo) override;
108#endif101#endif
109 // Energy Consumption102 // Energy Consumption
110- int32_t RegisterSelfDrawingNodeRectChangeCallback(pid_t remotePid, const RectConstraint& constraint,
111- sptr<RSISelfDrawingNodeRectChangeCallback> callback) override;
112- int32_t UnRegisterSelfDrawingNodeRectChangeCallback(pid_t remotePid) override;
113 std::vector<ActiveDirtyRegionInfo> GetActiveDirtyRegionInfo() override;103 std::vector<ActiveDirtyRegionInfo> GetActiveDirtyRegionInfo() override;
114 GlobalDirtyRegionInfo GetGlobalDirtyRegionInfo() override;104 GlobalDirtyRegionInfo GetGlobalDirtyRegionInfo() override;
115 LayerComposeInfo GetLayerComposeInfo() override;105 LayerComposeInfo GetLayerComposeInfo() override;
@@ -121,7 +111,6 @@ public:
121 void ReportGameStateData(GameStateData info) override;111 void ReportGameStateData(GameStateData info) override;
122 112 
123 // Behind Window Filter113 // Behind Window Filter
124- ErrCode SetBehindWindowFilterEnabled(bool enabled) override;
125 ErrCode GetBehindWindowFilterEnabled(bool& enabled) override;114 ErrCode GetBehindWindowFilterEnabled(bool& enabled) override;
126 115 
127 // Aps116 // Aps
@@ -146,6 +135,8 @@ public:
146 void SetCacheEnabledForRotation(bool enabled) override;135 void SetCacheEnabledForRotation(bool enabled) override;
147 void SetVmaCacheStatus(bool flag) override;136 void SetVmaCacheStatus(bool flag) override;
148 137 
138+ int32_t SendTransfer(const std::shared_ptr<RSIpcTransferBase>& transfer) override;
139+ 
149private:140private:
150 const sptr<RSRenderProcessAgent> renderProcessAgent_;141 const sptr<RSRenderProcessAgent> renderProcessAgent_;
151 const sptr<RSRenderPipelineAgent> renderPipelineAgent_;142 const sptr<RSRenderPipelineAgent> renderPipelineAgent_;
@@ -154,4 +145,4 @@ private:
154} // namespace Rosen145} // namespace Rosen
155} // namespace OHOS146} // namespace OHOS
156 147 
157-#endif // RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_RS_SERVICE_TO_RENDER_CONNECTION_H148+#endif // RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_RS_SERVICE_TO_RENDER_CONNECTION_H
@@ -20,18 +20,17 @@
20 20 
21#include "irs_render_to_composer_connection.h"21#include "irs_render_to_composer_connection.h"
22#include "ipc_callbacks/brightness_info_change_callback.h"22#include "ipc_callbacks/brightness_info_change_callback.h"
23-#include "ipc_callbacks/rs_iself_drawing_node_rect_change_callback.h"
24#include "info_collection/rs_hardware_compose_disabled_reason_collection.h"23#include "info_collection/rs_hardware_compose_disabled_reason_collection.h"
25#include "info_collection/rs_gpu_dirty_region_collection.h"24#include "info_collection/rs_gpu_dirty_region_collection.h"
26#include "transaction/rs_render_service_client_info.h"25#include "transaction/rs_render_service_client_info.h"
27#include "info_collection/rs_layer_compose_collection.h"26#include "info_collection/rs_layer_compose_collection.h"
28#include "screen_manager/rs_screen_property.h"27#include "screen_manager/rs_screen_property.h"
29#include "ipc_callbacks/rs_iuiextension_callback.h"28#include "ipc_callbacks/rs_iuiextension_callback.h"
30-#include "common/rs_self_draw_rect_change_callback_constraint.h"
31#include "ipc_callbacks/dfx/rs_dump_callback.h"29#include "ipc_callbacks/dfx/rs_dump_callback.h"
32 30 
33namespace OHOS {31namespace OHOS {
34namespace Rosen {32namespace Rosen {
33+class RSIpcTransferBase;
35 34 
36class RSIServiceToRenderConnection : public IRemoteBroker {35class RSIServiceToRenderConnection : public IRemoteBroker {
37public:36public:
@@ -50,7 +49,6 @@ public:
50 49 
51 // Screen Manager50 // Screen Manager
52 virtual int32_t NotifyScreenRefresh(ScreenId id) = 0;51 virtual int32_t NotifyScreenRefresh(ScreenId id) = 0;
53- virtual void HandleHwcEvent(uint32_t deviceId, uint32_t eventId, const std::vector<int32_t>& eventData) = 0;
54 virtual void OnScreenBacklightChanged(const RsScreenBrightnessData& brightnessData) = 0;52 virtual void OnScreenBacklightChanged(const RsScreenBrightnessData& brightnessData) = 0;
55 virtual void OnGlobalBlacklistChanged(const std::unordered_set<NodeId>& globalBlackList) = 0;53 virtual void OnGlobalBlacklistChanged(const std::unordered_set<NodeId>& globalBlackList) = 0;
56 54 
@@ -81,12 +79,6 @@ public:
81 std::vector<PixelMapInfo>& pixelMapInfoVector, pid_t pid, int32_t& repCode) = 0;79 std::vector<PixelMapInfo>& pixelMapInfoVector, pid_t pid, int32_t& repCode) = 0;
82 virtual void SetCurtainScreenUsingStatus(bool isCurtainScreenOn) = 0;80 virtual void SetCurtainScreenUsingStatus(bool isCurtainScreenOn) = 0;
83 81 
84- // Watermark
85- virtual ErrCode SetWatermark(
86- pid_t callingPid, const std::string& name, std::shared_ptr<Media::PixelMap> watermark, bool& success,
87- uint32_t rowCount = 0, uint32_t colCount = 0) = 0;
88- virtual void ShowWatermark(const std::shared_ptr<Media::PixelMap>& watermarkImg, bool isShow) = 0;
89- 
90 // uifirstscale82 // uifirstscale
91 virtual ErrCode SetUifirstScale(float scaleFactor) = 0;83 virtual ErrCode SetUifirstScale(float scaleFactor) = 0;
92 84 
@@ -103,7 +95,6 @@ public:
103 virtual void NotifyWindowModeTypeEvent(uint8_t windowModeType) = 0;95 virtual void NotifyWindowModeTypeEvent(uint8_t windowModeType) = 0;
104 virtual void HgmForceUpdateTask(bool flag, const std::string& fromWhom) = 0;96 virtual void HgmForceUpdateTask(bool flag, const std::string& fromWhom) = 0;
105 virtual uint32_t GetRealtimeRefreshRate(ScreenId screenId) = 0;97 virtual uint32_t GetRealtimeRefreshRate(ScreenId screenId) = 0;
106- virtual void SetShowRefreshRateEnabled(bool enabled, int32_t type) = 0;
107 virtual ErrCode GetShowRefreshRateEnabled(bool& enable) = 0;98 virtual ErrCode GetShowRefreshRateEnabled(bool& enable) = 0;
108 99 
109 // Overlay100 // Overlay
@@ -114,9 +105,6 @@ public:
114 virtual ErrCode SendVideoRateInfo(const std::unordered_map<std::string, std::string>& videoRateInfo) = 0;105 virtual ErrCode SendVideoRateInfo(const std::unordered_map<std::string, std::string>& videoRateInfo) = 0;
115#endif106#endif
116 // Energy Consumption107 // Energy Consumption
117- virtual int32_t RegisterSelfDrawingNodeRectChangeCallback(
118- pid_t remotePid, const RectConstraint& constraint, sptr<RSISelfDrawingNodeRectChangeCallback> callback) = 0;
119- virtual int32_t UnRegisterSelfDrawingNodeRectChangeCallback(pid_t remotePid) = 0;
120 virtual std::vector<ActiveDirtyRegionInfo> GetActiveDirtyRegionInfo() = 0;108 virtual std::vector<ActiveDirtyRegionInfo> GetActiveDirtyRegionInfo() = 0;
121 virtual GlobalDirtyRegionInfo GetGlobalDirtyRegionInfo() = 0;109 virtual GlobalDirtyRegionInfo GetGlobalDirtyRegionInfo() = 0;
122 virtual LayerComposeInfo GetLayerComposeInfo() = 0;110 virtual LayerComposeInfo GetLayerComposeInfo() = 0;
@@ -128,7 +116,6 @@ public:
128 virtual void ReportGameStateData(GameStateData info) = 0;116 virtual void ReportGameStateData(GameStateData info) = 0;
129 117 
130 // Behind Window Filter118 // Behind Window Filter
131- virtual ErrCode SetBehindWindowFilterEnabled(bool enabled) = 0;
132 virtual ErrCode GetBehindWindowFilterEnabled(bool& enabled) = 0;119 virtual ErrCode GetBehindWindowFilterEnabled(bool& enabled) = 0;
133 120 
134 // Aps121 // Aps
@@ -155,6 +142,8 @@ public:
155 virtual void SetCacheEnabledForRotation(bool enabled) = 0;142 virtual void SetCacheEnabledForRotation(bool enabled) = 0;
156 virtual ErrCode SetRogScreenResolution(ScreenId screenId, uint32_t width, uint32_t height,143 virtual ErrCode SetRogScreenResolution(ScreenId screenId, uint32_t width, uint32_t height,
157 ScreenSamplingMode samplingMode) = 0;144 ScreenSamplingMode samplingMode) = 0;
145+ 
146+ virtual int32_t SendTransfer(const std::shared_ptr<RSIpcTransferBase>& transfer) = 0;
158};147};
159 148 
160} // namespace Rosen149} // namespace Rosen
@@ -78,24 +78,25 @@ enum class RSIServiceToRenderConnectionInterfaceCode : CodeUnderlyingType {
78 SET_BRIGHTNESS_INFO_CHANGE_CALLBACK = 0x00E007,78 SET_BRIGHTNESS_INFO_CHANGE_CALLBACK = 0x00E007,
79 SET_UI_MODE_3D = 0x00E008,79 SET_UI_MODE_3D = 0x00E008,
80 SET_FORCE_REFRESH = 0x00F000,80 SET_FORCE_REFRESH = 0x00F000,
81- CREATE_PIXEL_MAP_FROM_SURFACE = 0X00F001,81+ CREATE_PIXEL_MAP_FROM_SURFACE = 0x00F001,
82- SET_LAYER_TOP = 0X00F002,82+ SET_LAYER_TOP = 0x00F002,
83- REGISTER_UIEXTENSION_CALLBACK = 0X00F003,83+ REGISTER_UIEXTENSION_CALLBACK = 0x00F003,
84- SET_VMA_CACHE_STATUS = 0X00F005,84+ SET_VMA_CACHE_STATUS = 0x00F005,
85- GET_PID_GPU_MEMORY_IN_MB = 0X00F006,85+ GET_PID_GPU_MEMORY_IN_MB = 0x00F006,
86- SET_COLOR_FOLLOW = 0X00F007,86+ SET_COLOR_FOLLOW = 0x00F007,
87 SET_CURTAIN_SCREEN_USING_STATUS = 0x00F008,87 SET_CURTAIN_SCREEN_USING_STATUS = 0x00F008,
88- CLEAN_RESOURCE = 0X00F010,88+ CLEAN_RESOURCE = 0x00F010,
89 SET_BACKLIGHT_LEVEL = 0x00F011,89 SET_BACKLIGHT_LEVEL = 0x00F011,
90 ON_GLOBAL_BLACKLIST_CHANGED = 0x00F012,90 ON_GLOBAL_BLACKLIST_CHANGED = 0x00F012,
91 SET_CACHE_ENABLED_FOR_ROTATION = 0x00F013,91 SET_CACHE_ENABLED_FOR_ROTATION = 0x00F013,
92- SET_HDR_FORCE_HWC_ENABLED = 0X00F014,92+ SET_HDR_FORCE_HWC_ENABLED = 0x00F014,
93- SET_APS_CONFIG_PARAMS = 0X00F016,93+ SET_APS_CONFIG_PARAMS = 0x00F016,
94- NOTIFY_WINDOW_MODE_TYPE_EVENT = 0X00F017,94+ NOTIFY_WINDOW_MODE_TYPE_EVENT = 0x00F017,
95- AUTHORIZE_UIEXTENSION_PID = 0X00F018,95+ AUTHORIZE_UIEXTENSION_PID = 0x00F018,
96+ SEND_RENDER_PROCESS_DATA = 0x00F100,
96};97};
97 98 
98} // namespace Rosen99} // namespace Rosen
99} // namespace OHOS100} // namespace OHOS
100 101 
101-#endif // RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_ZIDL_RS_ISERVICE_TO_RENDER_CONNECTION_IPC_INTERFACE_CODE_H102+#endif // RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_ZIDL_RS_ISERVICE_TO_RENDER_CONNECTION_IPC_INTERFACE_CODE_H
@@ -22,6 +22,7 @@
22#include <vector>22#include <vector>
23#include "buffer_utils.h"23#include "buffer_utils.h"
24#include "rs_trace.h"24#include "rs_trace.h"
25+#include "rs_ipc_persistence_def.h"
25#include "feature/capture/rs_ui_capture.h"26#include "feature/capture/rs_ui_capture.h"
26#include "platform/common/rs_log.h"27#include "platform/common/rs_log.h"
27#include "platform/common/rs_system_properties.h"28#include "platform/common/rs_system_properties.h"
@@ -38,7 +39,7 @@ namespace {
38constexpr uint32_t MAX_VIDEO_INFO_SIZE = 32; // video rate info max map size39constexpr uint32_t MAX_VIDEO_INFO_SIZE = 32; // video rate info max map size
39#endif40#endif
40static constexpr uint32_t MAX_APS_PARAMS_SIZE = 128;41static constexpr uint32_t MAX_APS_PARAMS_SIZE = 128;
41-}42+} // namespace
42RSServiceToRenderConnectionProxy::RSServiceToRenderConnectionProxy(const sptr<IRemoteObject>& impl)43RSServiceToRenderConnectionProxy::RSServiceToRenderConnectionProxy(const sptr<IRemoteObject>& impl)
43 : IRemoteProxy<RSIServiceToRenderConnection>(impl) {}44 : IRemoteProxy<RSIServiceToRenderConnection>(impl) {}
44 45 
@@ -903,36 +904,6 @@ ErrCode RSServiceToRenderConnectionProxy::GetPixelMapByProcessId(
903 return ERR_OK;904 return ERR_OK;
904}905}
905 906 
906-void RSServiceToRenderConnectionProxy::ShowWatermark(const std::shared_ptr<Media::PixelMap>& watermarkImg, bool isShow)
907-{
908- if (watermarkImg == nullptr) {
909- ROSEN_LOGE("%{public}s: watermarkImg is nullptr.", __func__);
910- return;
911- }
912- MessageParcel data;
913- MessageParcel reply;
914- MessageOption option;
915- option.SetFlags(MessageOption::TF_ASYNC);
916- if (!data.WriteInterfaceToken(RSIServiceToRenderConnection::GetDescriptor())) {
917- ROSEN_LOGE("%{public}s: WriteInterfaceToken GetDescriptor err.", __func__);
918- return;
919- }
920- if (!data.WriteParcelable(watermarkImg.get())) {
921- ROSEN_LOGE("%{public}s: WriteParcelable watermarkImg.get() err.", __func__);
922- return;
923- }
924- if (!data.WriteBool(isShow)) {
925- ROSEN_LOGE("%{public}s: WriteBool isShow err.", __func__);
926- return;
927- }
928- uint32_t code = static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::SHOW_WATERMARK);
929- int32_t err = SendRequest(code, data, reply, option);
930- if (err != NO_ERROR) {
931- ROSEN_LOGE("%{public}s: Send Request err.", __func__);
932- return;
933- }
934-}
935- 
936ErrCode RSServiceToRenderConnectionProxy::GetSurfaceRootNodeId(NodeId& windowNodeId)907ErrCode RSServiceToRenderConnectionProxy::GetSurfaceRootNodeId(NodeId& windowNodeId)
937{908{
938 MessageParcel data;909 MessageParcel data;
@@ -982,49 +953,6 @@ void RSServiceToRenderConnectionProxy::SetVmaCacheStatus(bool flag)
982 }953 }
983}954}
984 955 
985-ErrCode RSServiceToRenderConnectionProxy::SetWatermark(pid_t callingPid, const std::string& name,
986- std::shared_ptr<Media::PixelMap> watermark, bool& success, uint32_t rowCount, uint32_t colCount)
987-{
988- MessageParcel data;
989- MessageParcel reply;
990- MessageOption option;
991- option.SetFlags(MessageOption::TF_ASYNC);
992- if (!data.WriteInterfaceToken(RSIServiceToRenderConnection::GetDescriptor())) {
993- ROSEN_LOGE("%{public}s: WriteInterfaceToken GetDescriptor err.", __func__);
994- success = false;
995- return ERR_INVALID_VALUE;
996- }
997- if (!data.WriteInt32(callingPid)) {
998- ROSEN_LOGE("%{public}s: WriteUint64 pid err.", __func__);
999- success = false;
1000- return ERR_INVALID_VALUE;
1001- }
1002- if (!data.WriteString(name)) {
1003- ROSEN_LOGE("%{public}s: WriteString name err.", __func__);
1004- success = false;
1005- return ERR_INVALID_VALUE;
1006- }
1007- if (!data.WriteParcelable(watermark.get())) {
1008- ROSEN_LOGE("%{public}s: WriteParcelable watermark.get() err.", __func__);
1009- success = false;
1010- return ERR_INVALID_VALUE;
1011- }
1012- if (!data.WriteUint32(rowCount) || !data.WriteUint32(colCount)) {
1013- ROSEN_LOGE("%{public}s: WriteUint32 rowCount/colCount err.", __func__);
1014- success = false;
1015- return ERR_INVALID_VALUE;
1016- }
1017- uint32_t code = static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::SET_WATERMARK);
1018- int32_t err = SendRequest(code, data, reply, option);
1019- if (err != NO_ERROR) {
1020- ROSEN_LOGE("%{public}s: Send Request err.", __func__);
1021- success = false;
1022- return ERR_INVALID_VALUE;
1023- }
1024- success = true;
1025- return ERR_OK;
1026-}
1027- 
1028ErrCode RSServiceToRenderConnectionProxy::SetUifirstScale(float scaleFactor)956ErrCode RSServiceToRenderConnectionProxy::SetUifirstScale(float scaleFactor)
1029{957{
1030 MessageParcel data;958 MessageParcel data;
@@ -1232,30 +1160,6 @@ void RSServiceToRenderConnectionProxy::ReportGameStateData(GameStateData info)
1232 ROSEN_LOGI("RSServiceToRenderConnectionProxy sendrequest ret : %{public}d", ret);1160 ROSEN_LOGI("RSServiceToRenderConnectionProxy sendrequest ret : %{public}d", ret);
1233}1161}
1234 1162 
1235-ErrCode RSServiceToRenderConnectionProxy::SetBehindWindowFilterEnabled(bool enabled)
1236-{
1237- MessageParcel data;
1238- MessageParcel reply;
1239- MessageOption option;
1240- option.SetFlags(MessageOption::TF_SYNC);
1241- if (!data.WriteInterfaceToken(RSIServiceToRenderConnection::GetDescriptor())) {
1242- ROSEN_LOGE("RSServiceToRenderConnectionProxy::SetBehindWindowFilterEnabled WriteInterfaceToken failed.");
1243- return ERR_INVALID_VALUE;
1244- }
1245- if (!data.WriteBool(enabled)) {
1246- ROSEN_LOGE("RSServiceToRenderConnectionProxy::SetBehindWindowFilterEnabled WriteBool err.");
1247- return ERR_INVALID_VALUE;
1248- }
1249- uint32_t code = static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::SET_BEHIND_WINDOW_FILTER_ENABLED);
1250- int32_t err = SendRequest(code, data, reply, option);
1251- if (err != NO_ERROR) {
1252- ROSEN_LOGE("RSServiceToRenderConnectionProxy::SetBehindWindowFilterEnabled sendrequest error : "
1253- " %{public}d", err);
1254- return ERR_INVALID_VALUE;
1255- }
1256- return ERR_OK;
1257-}
1258- 
1259ErrCode RSServiceToRenderConnectionProxy::GetBehindWindowFilterEnabled(bool& enabled)1163ErrCode RSServiceToRenderConnectionProxy::GetBehindWindowFilterEnabled(bool& enabled)
1260{1164{
1261 MessageParcel data;1165 MessageParcel data;
@@ -1466,37 +1370,6 @@ void RSServiceToRenderConnectionProxy::HgmForceUpdateTask(bool flag, const std::
1466 }1370 }
1467}1371}
1468 1372 
1469-void RSServiceToRenderConnectionProxy::HandleHwcEvent(uint32_t deviceId, uint32_t eventId,
1470- const std::vector<int32_t>& eventData)
1471-{
1472- MessageParcel data;
1473- MessageParcel reply;
1474- MessageOption option;
1475- option.SetFlags(MessageOption::TF_ASYNC);
1476- if (!data.WriteInterfaceToken(RSIServiceToRenderConnection::GetDescriptor())) {
1477- RS_LOGE("%{public}s: WriteInterfaceToken failed.", __func__);
1478- return;
1479- }
1480- if (!data.WriteUint32(deviceId)) {
1481- RS_LOGE("%{public}s: WriteUint32 err.", __func__);
1482- return;
1483- }
1484- if (!data.WriteUint32(eventId)) {
1485- RS_LOGE("%{public}s: WriteUint32 err.", __func__);
1486- return;
1487- }
1488- if (!data.WriteInt32Vector(eventData)) {
1489- RS_LOGE("%{public}s: WriteInt32Vector err.", __func__);
1490- return;
1491- }
1492- uint32_t code = static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::HANDLE_HWC_EVENT);
1493- int32_t err = SendRequest(code, data, reply, option);
1494- if (err != NO_ERROR) {
1495- RS_LOGE("%{public}s: SendRequest failed, err is %{public}d.", __func__, err);
1496- return;
1497- }
1498-}
1499- 
1500int32_t RSServiceToRenderConnectionProxy::GetPidGpuMemoryInMB(pid_t pid, float& gpuMemInMB)1373int32_t RSServiceToRenderConnectionProxy::GetPidGpuMemoryInMB(pid_t pid, float& gpuMemInMB)
1501{1374{
1502 MessageParcel data;1375 MessageParcel data;
@@ -1610,96 +1483,6 @@ ErrCode RSServiceToRenderConnectionProxy::SetColorFollow(const std::string& node
1610 return ERR_OK;1483 return ERR_OK;
1611}1484}
1612 1485 
1613-int32_t RSServiceToRenderConnectionProxy::RegisterSelfDrawingNodeRectChangeCallback(
1614- pid_t remotePid, const RectConstraint& constraint, sptr<RSISelfDrawingNodeRectChangeCallback> callback)
1615-{
1616- if (!callback) {
1617- ROSEN_LOGE("%{public}s callback is nullptr", __func__);
1618- return ERR_INVALID_VALUE;
1619- }
1620- MessageParcel data;
1621- MessageParcel reply;
1622- MessageOption option;
1623- option.SetFlags(MessageOption::TF_SYNC);
1624- if (!data.WriteInterfaceToken(RSIServiceToRenderConnection::GetDescriptor())) {
1625- ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: WriteInterfaceToken GetDescriptor err.");
1626- return WRITE_PARCEL_ERR;
1627- }
1628- if (!data.WriteInt32(remotePid)) {
1629- ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: Write remotePid err.");
1630- return WRITE_PARCEL_ERR;
1631- }
1632- 
1633- size_t pidsSize = constraint.pids.size();
1634- if (pidsSize > UINT32_MAX) {
1635- ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: pids.size() exceeds UINT32_MAX.");
1636- return WRITE_PARCEL_ERR;
1637- }
1638- uint32_t size = static_cast<uint32_t>(pidsSize);
1639- if (!data.WriteUint32(size)) {
1640- ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: Write size err.");
1641- return WRITE_PARCEL_ERR;
1642- }
1643- for (int32_t pid : constraint.pids) {
1644- if (!data.WriteInt32(pid)) {
1645- ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: Write pid err.");
1646- return WRITE_PARCEL_ERR;
1647- }
1648- }
1649- 
1650- if (!data.WriteInt32(constraint.range.lowLimit.width) || !data.WriteInt32(constraint.range.lowLimit.height) ||
1651- !data.WriteInt32(constraint.range.highLimit.width) || !data.WriteInt32(constraint.range.highLimit.height)) {
1652- ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: Write rectRange err.");
1653- return WRITE_PARCEL_ERR;
1654- }
1655- if (!data.WriteRemoteObject(callback->AsObject())) {
1656- ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: WriteRemoteObject callback->AsObject() err.");
1657- return WRITE_PARCEL_ERR;
1658- }
1659- uint32_t code = static_cast<uint32_t>(
1660- RSIServiceToRenderConnectionInterfaceCode::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK);
1661- int32_t err = SendRequest(code, data, reply, option);
1662- if (err != NO_ERROR) {
1663- ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: Send request err.");
1664- return RS_CONNECTION_ERROR;
1665- }
1666- int32_t result = 0;
1667- if (!reply.ReadInt32(result)) {
1668- ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: ReadInt32 fail.");
1669- return RS_CONNECTION_ERROR;
1670- }
1671- return result;
1672-}
1673- 
1674-int32_t RSServiceToRenderConnectionProxy::UnRegisterSelfDrawingNodeRectChangeCallback(pid_t remotePid)
1675-{
1676- MessageParcel data;
1677- MessageParcel reply;
1678- MessageOption option;
1679- option.SetFlags(MessageOption::TF_SYNC);
1680- if (!data.WriteInterfaceToken(RSIServiceToRenderConnection::GetDescriptor())) {
1681- ROSEN_LOGE("UnRegisterSelfDrawingNodeRectChangeCallback: WriteInterfaceToken GetDescriptor err.");
1682- return WRITE_PARCEL_ERR;
1683- }
1684- if (!data.WriteInt32(remotePid)) {
1685- ROSEN_LOGE("UnRegisterSelfDrawingNodeRectChangeCallback: Write remotePid err.");
1686- return WRITE_PARCEL_ERR;
1687- }
1688- uint32_t code = static_cast<uint32_t>(
1689- RSIServiceToRenderConnectionInterfaceCode::UNREGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK);
1690- int32_t err = SendRequest(code, data, reply, option);
1691- if (err != NO_ERROR) {
1692- ROSEN_LOGE("UnRegisterSelfDrawingNodeRectChangeCallback: Send request err.");
1693- return RS_CONNECTION_ERROR;
1694- }
1695- int32_t result{0};
1696- if (!reply.ReadInt32(result)) {
1697- ROSEN_LOGE("RSServiceToRenderConnectionProxy::UnRegisterSelfDrawingNodeRectChangeCallback Read result failed");
1698- return READ_PARCEL_ERR;
1699- }
1700- return result;
1701-}
1702- 
1703uint32_t RSServiceToRenderConnectionProxy::GetRealtimeRefreshRate(ScreenId id)1486uint32_t RSServiceToRenderConnectionProxy::GetRealtimeRefreshRate(ScreenId id)
1704{1487{
1705 MessageParcel data;1488 MessageParcel data;
@@ -1728,28 +1511,6 @@ uint32_t RSServiceToRenderConnectionProxy::GetRealtimeRefreshRate(ScreenId id)
1728 return rate;1511 return rate;
1729}1512}
1730 1513 
1731-void RSServiceToRenderConnectionProxy::SetShowRefreshRateEnabled(bool enabled, int32_t type)
1732-{
1733- MessageParcel data;
1734- MessageParcel reply;
1735- MessageOption option;
1736- option.SetFlags(MessageOption::TF_SYNC);
1737- if (!data.WriteInterfaceToken(RSIServiceToRenderConnection::GetDescriptor())) {
1738- ROSEN_LOGE("SetShowRefreshRateEnabled: WriteInterfaceToken GetDescriptor err.");
1739- return;
1740- }
1741- if (!data.WriteBool(enabled) || !data.WriteInt32(type)) {
1742- ROSEN_LOGE("SetShowRefreshRateEnabled: WriteBool[enable] OR WriteInt32[type] err.");
1743- return;
1744- }
1745- uint32_t code = static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::SET_SHOW_REFRESH_RATE_ENABLED);
1746- int32_t err = SendRequest(code, data, reply, option);
1747- if (err != NO_ERROR) {
1748- ROSEN_LOGE("SetShowRefreshRateEnabled: sendrequest error : %{public}d", err);
1749- return;
1750- }
1751-}
1752- 
1753ErrCode RSServiceToRenderConnectionProxy::GetShowRefreshRateEnabled(bool& enable)1514ErrCode RSServiceToRenderConnectionProxy::GetShowRefreshRateEnabled(bool& enable)
1754{1515{
1755 MessageParcel data;1516 MessageParcel data;
@@ -2071,5 +1832,45 @@ void RSServiceToRenderConnectionProxy::SetCacheEnabledForRotation(bool enabled)
2071 RS_LOGE("%{public}s: SendRequest failed, err is %{public}d", __func__, err);1832 RS_LOGE("%{public}s: SendRequest failed, err is %{public}d", __func__, err);
2072 }1833 }
2073}1834}
1835+ 
1836+int32_t RSServiceToRenderConnectionProxy::SendTransfer(const std::shared_ptr<RSIpcTransferBase>& transfer)
1837+{
1838+ if (!transfer) {
1839+ RS_LOGE("%{public}s: transfer is nullptr", __func__);
1840+ return StatusCode::RS_CONNECTION_ERROR;
1841+ }
1842+ 
1843+ MessageParcel data;
1844+ MessageParcel reply;
1845+ MessageOption option;
1846+ option.SetFlags(transfer->IsSync() ? MessageOption::TF_SYNC : MessageOption::TF_ASYNC);
1847+ 
1848+ if (!data.WriteInterfaceToken(RSIServiceToRenderConnection::GetDescriptor())) {
1849+ RS_LOGE("%{public}s: WriteInterfaceToken failed", __func__);
1850+ return StatusCode::WRITE_PARCEL_ERR;
1851+ }
1852+ if (!data.WriteUint32(static_cast<uint32_t>(transfer->GetTypeId()))) {
1853+ RS_LOGE("%{public}s: WriteTypeId failed", __func__);
1854+ return StatusCode::WRITE_PARCEL_ERR;
1855+ }
1856+ if (!transfer->ProxyMarshalling(data)) {
1857+ RS_LOGE("%{public}s: Transfer ProxyMarshalling failed", __func__);
1858+ return StatusCode::WRITE_PARCEL_ERR;
1859+ }
1860+ uint32_t code = static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::SEND_RENDER_PROCESS_DATA);
1861+ int32_t err = SendRequest(code, data, reply, option);
1862+ if (err != ERR_OK) {
1863+ RS_LOGE("%{public}s: SendRequest failed, err is %{public}d", __func__, err);
1864+ return StatusCode::RS_CONNECTION_ERROR;
1865+ }
1866+ if (transfer->IsSync()) {
1867+ if (!transfer->ProxyUnmarshalling(reply)) {
1868+ RS_LOGE("%{public}s: ReplyUnmarshalling failed", __func__);
1869+ return StatusCode::READ_PARCEL_ERR;
1870+ }
1871+ }
1872+ return StatusCode::SUCCESS;
1873+}
1874+ 
2074} // namespace Rosen1875} // namespace Rosen
2075} // namespace OHOS1876} // namespace OHOS
@@ -41,7 +41,6 @@ public:
41 41 
42 // Screen Manager42 // Screen Manager
43 int32_t NotifyScreenRefresh(ScreenId screenId) override;43 int32_t NotifyScreenRefresh(ScreenId screenId) override;
44- void HandleHwcEvent(uint32_t deviceId, uint32_t eventId, const std::vector<int32_t>& eventData) override;
45 void OnScreenBacklightChanged(const RsScreenBrightnessData& brightnessData) override;44 void OnScreenBacklightChanged(const RsScreenBrightnessData& brightnessData) override;
46 void OnGlobalBlacklistChanged(const std::unordered_set<NodeId>& globalBlackList) override;45 void OnGlobalBlacklistChanged(const std::unordered_set<NodeId>& globalBlackList) override;
47 46 
@@ -71,12 +70,6 @@ public:
71 ErrCode GetPixelMapByProcessId(std::vector<PixelMapInfo>& pixelMapInfoVector, pid_t pid, int32_t& repCode) override;70 ErrCode GetPixelMapByProcessId(std::vector<PixelMapInfo>& pixelMapInfoVector, pid_t pid, int32_t& repCode) override;
72 void SetCurtainScreenUsingStatus(bool isCurtainScreenOn) override;71 void SetCurtainScreenUsingStatus(bool isCurtainScreenOn) override;
73 72 
74- // Watermark
75- ErrCode SetWatermark(
76- pid_t callingPid, const std::string& name, std::shared_ptr<Media::PixelMap> watermark, bool& success,
77- uint32_t rowCount = 0, uint32_t colCount = 0) override;
78- void ShowWatermark(const std::shared_ptr<Media::PixelMap>& watermarkImg, bool isShow) override;
79- 
80 // uifristscale73 // uifristscale
81 ErrCode SetUifirstScale(float scaleFactor) override;74 ErrCode SetUifirstScale(float scaleFactor) override;
82 75 
@@ -93,7 +86,6 @@ public:
93 void NotifyWindowModeTypeEvent(uint8_t windowModeType) override;86 void NotifyWindowModeTypeEvent(uint8_t windowModeType) override;
94 void HgmForceUpdateTask(bool flag, const std::string& fromWhom) override;87 void HgmForceUpdateTask(bool flag, const std::string& fromWhom) override;
95 uint32_t GetRealtimeRefreshRate(ScreenId screenId) override;88 uint32_t GetRealtimeRefreshRate(ScreenId screenId) override;
96- void SetShowRefreshRateEnabled(bool enabled, int32_t type) override;
97 ErrCode GetShowRefreshRateEnabled(bool& enable) override;89 ErrCode GetShowRefreshRateEnabled(bool& enable) override;
98 90 
99 // Overlay91 // Overlay
@@ -104,9 +96,6 @@ public:
104 ErrCode SendVideoRateInfo(const std::unordered_map<std::string, std::string>& videoRateInfo) override;96 ErrCode SendVideoRateInfo(const std::unordered_map<std::string, std::string>& videoRateInfo) override;
105#endif97#endif
106 // Energy Consumption98 // Energy Consumption
107- int32_t RegisterSelfDrawingNodeRectChangeCallback(pid_t remotePid, const RectConstraint& constraint,
108- sptr<RSISelfDrawingNodeRectChangeCallback> callback) override;
109- int32_t UnRegisterSelfDrawingNodeRectChangeCallback(pid_t remotePid) override;
110 std::vector<ActiveDirtyRegionInfo> GetActiveDirtyRegionInfo() override;99 std::vector<ActiveDirtyRegionInfo> GetActiveDirtyRegionInfo() override;
111 GlobalDirtyRegionInfo GetGlobalDirtyRegionInfo() override;100 GlobalDirtyRegionInfo GetGlobalDirtyRegionInfo() override;
112 LayerComposeInfo GetLayerComposeInfo() override;101 LayerComposeInfo GetLayerComposeInfo() override;
@@ -118,7 +107,6 @@ public:
118 void ReportGameStateData(GameStateData info) override;107 void ReportGameStateData(GameStateData info) override;
119 108 
120 // Behind Window Filter109 // Behind Window Filter
121- ErrCode SetBehindWindowFilterEnabled(bool enabled) override;
122 ErrCode GetBehindWindowFilterEnabled(bool& enabled) override;110 ErrCode GetBehindWindowFilterEnabled(bool& enabled) override;
123 111 
124 // Aps112 // Aps
@@ -143,6 +131,8 @@ public:
143 void SetCacheEnabledForRotation(bool enabled) override;131 void SetCacheEnabledForRotation(bool enabled) override;
144 void SetVmaCacheStatus(bool flag) override;132 void SetVmaCacheStatus(bool flag) override;
145 133 
134+ int32_t SendTransfer(const std::shared_ptr<RSIpcTransferBase>& transfer) override;
135+ 
146private:136private:
147 static inline BrokerDelegator<RSServiceToRenderConnectionProxy> delegator_;137 static inline BrokerDelegator<RSServiceToRenderConnectionProxy> delegator_;
148 int32_t SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);138 int32_t SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
@@ -152,4 +142,4 @@ private:
152} // namespace Rosen142} // namespace Rosen
153} // namespace OHOS143} // namespace OHOS
154 144 
155-#endif // RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_ZIDL_RS_SERVICE_TO_RENDER_CONNECTION_PROXY_H145+#endif // RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_ZIDL_RS_SERVICE_TO_RENDER_CONNECTION_PROXY_H
@@ -16,14 +16,15 @@
16#include "rs_service_to_render_connection_stub.h"16#include "rs_service_to_render_connection_stub.h"
17 17 
18#include "buffer_utils.h"18#include "buffer_utils.h"
19-#include "rs_iservice_to_render_connection_ipc_interface_code.h"
20-#include "ipc_security/rs_ipc_interface_code_access_verifier_base.h"
21#include "rs_profiler.h"19#include "rs_profiler.h"
22#include "common/rs_xcollie.h"20#include "common/rs_xcollie.h"
23-#include "platform/common/rs_log.h"
24-#include "transaction/rs_marshalling_helper.h"
25#include "gfx/dump/rs_dump_manager.h"21#include "gfx/dump/rs_dump_manager.h"
26-#include "rs_profiler.h"22+#include "ipc_security/rs_ipc_interface_code_access_verifier_base.h"
23+#include "platform/common/rs_log.h"
24+#include "platform/common/rs_system_properties.h"
25+#include "rs_ipc_persistence_manager.h"
26+#include "rs_iservice_to_render_connection_ipc_interface_code.h"
27+#include "transaction/rs_marshalling_helper.h"
27 28 
28#undef LOG_TAG29#undef LOG_TAG
29#define LOG_TAG "RSServiceToRenderConnectionStub"30#define LOG_TAG "RSServiceToRenderConnectionStub"
@@ -31,15 +32,14 @@
31namespace OHOS {32namespace OHOS {
32namespace Rosen {33namespace Rosen {
33namespace {34namespace {
34-constexpr uint32_t MAX_PID_SIZE_NUMBER = 100000;
35constexpr uint32_t MAX_LIST_SIZE = 50;35constexpr uint32_t MAX_LIST_SIZE = 50;
36#ifdef RS_ENABLE_TV_PQ_METADATA36#ifdef RS_ENABLE_TV_PQ_METADATA
37constexpr uint32_t MAX_VIDEO_INFO_SIZE = 32; // video rate info max map size37constexpr uint32_t MAX_VIDEO_INFO_SIZE = 32; // video rate info max map size
38#endif38#endif
39constexpr uint32_t MAX_APS_PARAMS_SIZE = 128;39constexpr uint32_t MAX_APS_PARAMS_SIZE = 128;
40constexpr size_t PIDLIST_SIZE_MAX = 128;40constexpr size_t PIDLIST_SIZE_MAX = 128;
41-constexpr size_t HWC_EVENT_DATA_SIZE_MAX = 100;
42constexpr uint32_t ACVIDEO_VECTOR_MAX_LENGTH = 8;41constexpr uint32_t ACVIDEO_VECTOR_MAX_LENGTH = 8;
42+constexpr uint32_t LIVE_MAX_ENTRIES = 1;
43} // namespace43} // namespace
44 44 
45static void TypefaceXcollieCallback(void* arg)45static void TypefaceXcollieCallback(void* arg)
@@ -407,60 +407,6 @@ int RSServiceToRenderConnectionStub::OnRemoteRequest(
407 SetVmaCacheStatus(flag);407 SetVmaCacheStatus(flag);
408 break;408 break;
409 }409 }
410- case static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::SET_WATERMARK): {
411- if (!RSSystemProperties::GetSurfaceNodeWatermarkEnabled()) {
412- RS_LOGI("RSServiceToRenderStub::SET_WATERMARK Current disenable water mark");
413- break;
414- }
415- pid_t callingPid;
416- if (!data.ReadInt32(callingPid)) {
417- ret = ERR_INVALID_VALUE;
418- break;
419- }
420- std::string name;
421- if (!data.ReadString(name)) {
422- ret = ERR_INVALID_DATA;
423- break;
424- }
425- auto watermark = std::shared_ptr<Media::PixelMap>(data.ReadParcelable<Media::PixelMap>());
426- if (watermark == nullptr) {
427- ret = ERR_NULL_OBJECT;
428- RS_LOGE("RSServiceToRenderStub::SET_WATERMARK:std::shared_ptr<Media::PixelMap> watermark == nullptr");
429- break;
430- }
431- uint32_t rowCount = 0;
432- uint32_t colCount = 0;
433- if (!data.ReadUint32(rowCount)) {
434- ret = ERR_INVALID_DATA;
435- break;
436- }
437- if (!data.ReadUint32(colCount)) {
438- ret = ERR_INVALID_DATA;
439- break;
440- }
441- bool success;
442- if (SetWatermark(callingPid, name, watermark, success, rowCount, colCount) != ERR_OK || !success) {
443- RS_LOGE("RSServiceToRenderStub::SetWatermark failed");
444- }
445- break;
446- }
447- case static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::SHOW_WATERMARK): {
448- std::shared_ptr<Media::PixelMap> watermarkImg =
449- std::shared_ptr<Media::PixelMap>(data.ReadParcelable<Media::PixelMap>());
450- bool isShow{false};
451- if (!data.ReadBool(isShow)) {
452- RS_LOGE("RSServiceToRenderStub::SHOW_WATERMARK Read isShow failed!");
453- ret = ERR_INVALID_DATA;
454- break;
455- }
456- if (!watermarkImg) {
457- RS_LOGE("RSServiceToRenderStub::SHOW_WATERMARK watermarkImg is nullptr");
458- ret = ERR_INVALID_DATA;
459- break;
460- }
461- ShowWatermark(watermarkImg, isShow);
462- break;
463- }
464 case static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::SET_UIFIRST_SCALE): {410 case static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::SET_UIFIRST_SCALE): {
465 float scaleFactor { 1.0f };411 float scaleFactor { 1.0f };
466 if (!data.ReadFloat(scaleFactor)) {412 if (!data.ReadFloat(scaleFactor)) {
@@ -622,20 +568,6 @@ int RSServiceToRenderConnectionStub::OnRemoteRequest(
622 ReportGameStateData(info);568 ReportGameStateData(info);
623 break;569 break;
624 }570 }
625- case static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::SET_BEHIND_WINDOW_FILTER_ENABLED): {
626- bool enabled {false};
627- if (!data.ReadBool(enabled)) {
628- RS_LOGE("RSServiceToRenderStub::SET_BEHIND_WINDOW_FILTER_ENABLED Read enabled failed");
629- ret = ERR_INVALID_DATA;
630- break;
631- }
632- auto err = SetBehindWindowFilterEnabled(enabled);
633- if (err != ERR_OK) {
634- RS_LOGE("RSServiceToRenderStub::SET_BEHIND_WINDOW_FILTER_ENABLED Write status failed");
635- ret = ERR_INVALID_REPLY;
636- }
637- break;
638- }
639 case static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::GET_BEHIND_WINDOW_FILTER_ENABLED): {571 case static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::GET_BEHIND_WINDOW_FILTER_ENABLED): {
640 bool enabled;572 bool enabled;
641 if (GetBehindWindowFilterEnabled(enabled) != ERR_OK || !reply.WriteBool(enabled)) {573 if (GetBehindWindowFilterEnabled(enabled) != ERR_OK || !reply.WriteBool(enabled)) {
@@ -934,83 +866,6 @@ int RSServiceToRenderConnectionStub::OnRemoteRequest(
934 SetColorFollow(nodeIdStr, isColorFollow);866 SetColorFollow(nodeIdStr, isColorFollow);
935 break;867 break;
936 }868 }
937- case static_cast<uint32_t>(
938- RSIServiceToRenderConnectionInterfaceCode::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK): {
939- pid_t remotePid;
940- if (!data.ReadInt32(remotePid)) {
941- ROSEN_LOGE("RSIServiceToRenderConnectionStub::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK Read "
942- "remotePid failed");
943- ret = ERR_INVALID_REPLY;
944- break;
945- }
946- uint32_t size;
947- if (!data.ReadUint32(size)) {
948- ROSEN_LOGE("RSIServiceToRenderConnectionStub::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK Read "
949- "size failed");
950- ret = ERR_INVALID_REPLY;
951- break;
952- }
953- RectConstraint constraint;
954- if (size > MAX_PID_SIZE_NUMBER) {
955- ROSEN_LOGE("RSIServiceToRenderConnectionStub::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK "
956- "size number is too large.");
957- break;
958- }
959- bool shouldBreak = false;
960- for (uint32_t i = 0; i < size; ++i) {
961- pid_t pid;
962- if (!data.ReadInt32(pid)) {
963- ROSEN_LOGE("RSIServiceToRenderConnectionStub::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK Read "
964- "pid failed");
965- ret = ERR_INVALID_REPLY;
966- shouldBreak = true;
967- break;
968- }
969- constraint.pids.insert(pid);
970- }
971- if (shouldBreak) {
972- break;
973- }
974- if (!data.ReadInt32(constraint.range.lowLimit.width) || !data.ReadInt32(constraint.range.lowLimit.height) ||
975- !data.ReadInt32(constraint.range.highLimit.width) ||
976- !data.ReadInt32(constraint.range.highLimit.height)) {
977- ROSEN_LOGE("RSIServiceToRenderConnectionStub::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK Read "
978- "rectRange failed");
979- ret = ERR_INVALID_REPLY;
980- break;
981- }
982- auto remoteObject = data.ReadRemoteObject();
983- if (remoteObject == nullptr) {
984- ret = ERR_NULL_OBJECT;
985- break;
986- }
987- sptr<RSISelfDrawingNodeRectChangeCallback> callback =
988- iface_cast<RSISelfDrawingNodeRectChangeCallback>(remoteObject);
989- if (callback == nullptr) {
990- ret = ERR_NULL_OBJECT;
991- break;
992- }
993- int32_t status = RegisterSelfDrawingNodeRectChangeCallback(remotePid, constraint, callback);
994- if (!reply.WriteInt32(status)) {
995- ret = ERR_INVALID_REPLY;
996- }
997- break;
998- }
999- case static_cast<uint32_t>(
1000- RSIServiceToRenderConnectionInterfaceCode::UNREGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK): {
1001- pid_t remotePid;
1002- if (!data.ReadInt32(remotePid)) {
1003- ROSEN_LOGE("RSIServiceToRenderConnectionStub::UNREGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK Read "
1004- "remotePid failed");
1005- ret = ERR_INVALID_REPLY;
1006- break;
1007- }
1008- int32_t status = UnRegisterSelfDrawingNodeRectChangeCallback(remotePid);
1009- if (!reply.WriteInt32(status)) {
1010- ret = ERR_INVALID_REPLY;
1011- }
1012- break;
1013- }
1014 case static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::GET_REALTIME_REFRESH_RATE): {869 case static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::GET_REALTIME_REFRESH_RATE): {
1015 ScreenId id{INVALID_SCREEN_ID};870 ScreenId id{INVALID_SCREEN_ID};
1016 if (!data.ReadUint64(id)) {871 if (!data.ReadUint64(id)) {
@@ -1025,17 +880,6 @@ int RSServiceToRenderConnectionStub::OnRemoteRequest(
1025 }880 }
1026 break;881 break;
1027 }882 }
1028- case static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::SET_SHOW_REFRESH_RATE_ENABLED): {
1029- bool enabled{false};
1030- int32_t type{0};
1031- if (!data.ReadBool(enabled) || !data.ReadInt32(type)) {
1032- RS_LOGE("RSServiceToRenderStub::SET_SHOW_REFRESH_RATE_ENABLED Read parcel failed!");
1033- ret = ERR_INVALID_DATA;
1034- break;
1035- }
1036- SetShowRefreshRateEnabled(enabled, type);
1037- break;
1038- }
1039 case static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::GET_SHOW_REFRESH_RATE_ENABLED): {883 case static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::GET_SHOW_REFRESH_RATE_ENABLED): {
1040 bool enable = false;884 bool enable = false;
1041 if (GetShowRefreshRateEnabled(enable) != ERR_OK || !reply.WriteBool(enable)) {885 if (GetShowRefreshRateEnabled(enable) != ERR_OK || !reply.WriteBool(enable)) {
@@ -1044,34 +888,6 @@ int RSServiceToRenderConnectionStub::OnRemoteRequest(
1044 }888 }
1045 break;889 break;
1046 }890 }
1047- case static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::HANDLE_HWC_EVENT): {
1048- uint32_t deviceId{0};
1049- if (!data.ReadUint32(deviceId)) {
1050- RS_LOGE("HandleHwcEvent: read deviceId err.");
1051- ret = ERR_INVALID_DATA;
1052- break;
1053- }
1054- uint32_t eventId{0};
1055- if (!data.ReadUint32(eventId)) {
1056- RS_LOGE("HandleHwcEvent: read eventId err.");
1057- ret = ERR_INVALID_DATA;
1058- break;
1059- }
1060- std::vector<int32_t> eventData;
1061- if (!data.ReadInt32Vector(&eventData)) {
1062- RS_LOGE("HandleHwcEvent: read eventData err.");
1063- ret = ERR_INVALID_DATA;
1064- break;
1065- }
1066- if (eventData.size() > HWC_EVENT_DATA_SIZE_MAX) {
1067- RS_LOGE("HandleHwcEvent: eventData size %{public}zu exceeds max %{public}zu.",
1068- eventData.size(), HWC_EVENT_DATA_SIZE_MAX);
1069- ret = ERR_INVALID_DATA;
1070- break;
1071- }
1072- HandleHwcEvent(deviceId, eventId, eventData);
1073- break;
1074- }
1075 case static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::GET_ACTIVE_DIRTY_REGION_INFO): {891 case static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::GET_ACTIVE_DIRTY_REGION_INFO): {
1076 const auto& activeDirtyRegionInfos = GetActiveDirtyRegionInfo();892 const auto& activeDirtyRegionInfos = GetActiveDirtyRegionInfo();
1077 if (!reply.WriteInt32(activeDirtyRegionInfos.size())) {893 if (!reply.WriteInt32(activeDirtyRegionInfos.size())) {
@@ -1252,6 +1068,49 @@ int RSServiceToRenderConnectionStub::OnRemoteRequest(
1252 SetApsConfigParams(event, params);1068 SetApsConfigParams(event, params);
1253 break;1069 break;
1254 }1070 }
1071+ case static_cast<uint32_t>(RSIServiceToRenderConnectionInterfaceCode::SEND_RENDER_PROCESS_DATA): {
1072+ uint32_t typeIdVal;
1073+ if (!data.ReadUint32(typeIdVal)) {
1074+ RS_LOGE("%{public}s: Read typeId failed", __func__);
1075+ ret = ERR_INVALID_DATA;
1076+ break;
1077+ }
1078+ // Same gate as the old SET_WATERMARK case: reject before any parcel parsing when the
1079+ // feature is off. Live path only; the replay path must keep deserializing, otherwise a
1080+ // persisted watermark plus a disabled property would fail the whole snapshot and break
1081+ // render process restart. Apply() re-checks the property to guard the replay path.
1082+ if (static_cast<RSIServiceToRenderConnectionInterfaceCode>(typeIdVal) ==
1083+ RSIServiceToRenderConnectionInterfaceCode::SET_WATERMARK &&
1084+ !RSSystemProperties::GetSurfaceNodeWatermarkEnabled()) {
1085+ RS_LOGI("%{public}s: watermark disabled by system property, typeId=%{public}u",
1086+ __func__, typeIdVal);
1087+ break;
1088+ }
1089+ int32_t deserErr = ERR_NULL_OBJECT;
1090+ auto transfer = RSIpcPersistenceManager::CreateTransferByTypeId(
1091+ static_cast<RSIServiceToRenderConnectionInterfaceCode>(typeIdVal), data, deserErr, LIVE_MAX_ENTRIES);
1092+ if (!transfer) {
1093+ RS_LOGE("%{public}s: CreateTransferByTypeId failed for %{public}u, err=%{public}d",
1094+ __func__, typeIdVal, deserErr);
1095+ ret = deserErr;
1096+ break;
1097+ }
1098+ int32_t sendRet = SendTransfer(transfer);
1099+ if (sendRet != StatusCode::SUCCESS) {
1100+ RS_LOGE("%{public}s: SendTransfer failed for %{public}u, err=%{public}d",
1101+ __func__, typeIdVal, sendRet);
1102+ ret = sendRet;
1103+ break;
1104+ }
1105+ if (transfer->IsSync()) {
1106+ if (!transfer->StubMarshalling(reply)) {
1107+ RS_LOGE("%{public}s: ReplyMarshalling failed for %{public}u", __func__, typeIdVal);
1108+ ret = ERR_INVALID_REPLY;
1109+ break;
1110+ }
1111+ }
1112+ break;
1113+ }
1255 default:1114 default:
1256 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);1115 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
1257 }1116 }
@@ -1307,4 +1166,4 @@ bool RSServiceToRenderConnectionStub::ReadAppInfo(AppInfo& info, MessageParcel&
1307 return true;1166 return true;
1308}1167}
1309} // namespace Rosen1168} // namespace Rosen
1310-} // namespace OHOS1169+} // namespace OHOS
@@ -0,0 +1,130 @@
1+/*
2+ * Copyright (c) 2026 Huawei Device Co., Ltd.
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+ 
16+#include "rs_on_hwc_event_transfer.h"
17+ 
18+#include "core/rs_render_pipeline_agent.h"
19+#include "ipc_persistence/rs_ipc_persistence_manager.h"
20+ 
21+#include "platform/common/rs_log.h"
22+ 
23+#undef LOG_TAG
24+#define LOG_TAG "OnHwcEventTransfer"
25+ 
26+namespace OHOS {
27+namespace Rosen {
28+ 
29+namespace {
30+constexpr size_t HWC_EVENT_DATA_SIZE_MAX = 100;
31+}
32+ 
33+bool OnHwcEventInput::Marshalling(Parcel& parcel) const
34+{
35+ if (!parcel.WriteUint32(deviceId_)) {
36+ RS_LOGE("%{public}s: WriteUint32 deviceId failed", __func__);
37+ return false;
38+ }
39+ if (!parcel.WriteUint32(eventId_)) {
40+ RS_LOGE("%{public}s: WriteUint32 eventId failed", __func__);
41+ return false;
42+ }
43+ if (!parcel.WriteInt32Vector(eventData_)) {
44+ RS_LOGE("%{public}s: WriteInt32Vector eventData failed", __func__);
45+ return false;
46+ }
47+ return true;
48+}
49+ 
50+std::shared_ptr<OnHwcEventInput> OnHwcEventInput::Unmarshalling(Parcel& parcel, int32_t& errCode)
51+{
52+ uint32_t deviceId;
53+ if (!parcel.ReadUint32(deviceId)) {
54+ RS_LOGE("%{public}s: ReadUint32 deviceId failed", __func__);
55+ errCode = ERR_INVALID_DATA;
56+ return nullptr;
57+ }
58+ uint32_t eventId;
59+ if (!parcel.ReadUint32(eventId)) {
60+ RS_LOGE("%{public}s: ReadUint32 eventId failed", __func__);
61+ errCode = ERR_INVALID_DATA;
62+ return nullptr;
63+ }
64+ std::vector<int32_t> eventData;
65+ if (!parcel.ReadInt32Vector(&eventData)) {
66+ RS_LOGE("%{public}s: ReadInt32Vector eventData failed", __func__);
67+ errCode = ERR_INVALID_DATA;
68+ return nullptr;
69+ }
70+ if (eventData.size() > HWC_EVENT_DATA_SIZE_MAX) {
71+ RS_LOGE("%{public}s: eventData size[%{public}zu] exceeds max[%{public}zu]",
72+ __func__, eventData.size(), HWC_EVENT_DATA_SIZE_MAX);
73+ errCode = ERR_INVALID_DATA;
74+ return nullptr;
75+ }
76+ return std::make_shared<OnHwcEventInput>(deviceId, eventId, eventData);
77+}
78+ 
79+void OnHwcEventTransfer::Persist(IpcPersistenceMap& map, std::mutex& mutex)
80+{
81+ auto typeId = GetTypeId();
82+ std::shared_ptr<OnHwcEventTransfer> target;
83+ {
84+ std::lock_guard<std::mutex> lock(mutex);
85+ auto it = map.find(typeId);
86+ if (it == map.end()) {
87+ if (map.size() >= Detail::MAX_PERSIST_MAP_SIZE) {
88+ RS_LOGE("%{public}s: persist map full, size=%{public}zu", __func__, map.size());
89+ return;
90+ }
91+ map[typeId] = std::make_shared<OnHwcEventTransfer>(inputData_);
92+ return;
93+ }
94+ target = std::static_pointer_cast<OnHwcEventTransfer>(it->second);
95+ }
96+ if (!target) {
97+ RS_LOGE("%{public}s: existing transfer is nullptr", __func__);
98+ return;
99+ }
100+ std::lock_guard<std::mutex> targetLock(target->mutex_);
101+ target->inputData_ = inputData_;
102+}
103+ 
104+bool OnHwcEventTransfer::ProxyMarshalling(Parcel& parcel) const
105+{
106+ std::lock_guard<std::mutex> lock(mutex_);
107+ if (!inputData_) {
108+ return false;
109+ }
110+ return inputData_->Marshalling(parcel);
111+}
112+ 
113+bool OnHwcEventTransfer::Apply(const sptr<RSRenderPipelineAgent>& agent)
114+{
115+ if (!agent || !inputData_) {
116+ RS_LOGE("%{public}s: agent or input is nullptr", __func__);
117+ return false;
118+ }
119+ agent->NotifyHwcEventToRender(
120+ inputData_->GetDeviceId(), inputData_->GetEventId(), inputData_->GetEventData());
121+ return true;
122+}
123+ 
124+// Explicit ODR-use: guarantee factory registration at static init time, independent of
125+// whether any OnHwcEventTransfer is constructed before CreateTransferByTypeId.
126+[[maybe_unused]] const auto* g_onHwcEventRegistrar =
127+ &TransferRegistrationChecker<OnHwcEventTransfer>::registrar;
128+ 
129+} // namespace Rosen
130+} // namespace OHOS
@@ -0,0 +1,91 @@
1+/*
2+ * Copyright (c) 2026 Huawei Device Co., Ltd.
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+ 
16+#ifndef RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_ZIDL_TRANSFERS_RS_ON_HWC_EVENT_TRANSFER_H
17+#define RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_ZIDL_TRANSFERS_RS_ON_HWC_EVENT_TRANSFER_H
18+ 
19+#include <cstdint>
20+#include <memory>
21+#include <vector>
22+ 
23+#include <parcel.h>
24+ 
25+#include "rs_ipc_persistence_def.h"
26+#include "rs_ipc_persistence_manager.h"
27+ 
28+namespace OHOS {
29+namespace Rosen {
30+ 
31+class OnHwcEventInput : public RSIpcPersistenceDataBase<OnHwcEventInput> {
32+public:
33+ OnHwcEventInput(uint32_t deviceId, uint32_t eventId, const std::vector<int32_t>& eventData)
34+ : deviceId_(deviceId), eventId_(eventId), eventData_(eventData) {}
35+ 
36+ uint32_t GetDeviceId() const { return deviceId_; }
37+ uint32_t GetEventId() const { return eventId_; }
38+ const std::vector<int32_t>& GetEventData() const { return eventData_; }
39+ 
40+ bool Marshalling(Parcel& parcel) const override;
41+ [[nodiscard]] static std::shared_ptr<OnHwcEventInput> Unmarshalling(Parcel& parcel, int32_t& errCode);
42+ 
43+ OnHwcEventInput(const OnHwcEventInput&) = delete;
44+ OnHwcEventInput& operator=(const OnHwcEventInput&) = delete;
45+ OnHwcEventInput(OnHwcEventInput&&) = delete;
46+ OnHwcEventInput& operator=(OnHwcEventInput&&) = delete;
47+ 
48+private:
49+ uint32_t deviceId_;
50+ uint32_t eventId_;
51+ std::vector<int32_t> eventData_;
52+};
53+ 
54+class OnHwcEventTransfer final
55+ : public RSIpcTransferCRTP<OnHwcEventTransfer, OnHwcEventInput, RSIpcEmptyReply> {
56+public:
57+ explicit OnHwcEventTransfer(const std::shared_ptr<OnHwcEventInput>& input) : inputData_(input) {}
58+ 
59+ static constexpr RSIServiceToRenderConnectionInterfaceCode TypeId =
60+ RSIServiceToRenderConnectionInterfaceCode::HANDLE_HWC_EVENT;
61+ RSIServiceToRenderConnectionInterfaceCode GetTypeId() const override { return TypeId; }
62+ bool IsPersistent() const override { return true; }
63+ bool IsSync() const override { return false; }
64+ FanoutPolicy GetFanoutPolicy() const override { return FanoutPolicy::ANY_SUCCESS; }
65+ 
66+ bool Apply(const sptr<RSRenderPipelineAgent>& agent) override;
67+ bool ProxyMarshalling(Parcel& parcel) const override;
68+ std::shared_ptr<RSIpcTransferBase> CopyTransfer() const override
69+ {
70+ return std::make_shared<OnHwcEventTransfer>(inputData_);
71+ }
72+ void ClearPid(pid_t) override {}
73+ 
74+ OnHwcEventTransfer(const OnHwcEventTransfer&) = delete;
75+ OnHwcEventTransfer& operator=(const OnHwcEventTransfer&) = delete;
76+ OnHwcEventTransfer(OnHwcEventTransfer&&) = delete;
77+ OnHwcEventTransfer& operator=(OnHwcEventTransfer&&) = delete;
78+ 
79+protected:
80+ void Persist(IpcPersistenceMap& map, std::mutex& mutex) override;
81+ 
82+private:
83+ static constexpr bool registered_ = true;
84+ friend struct TransferRegistrationChecker<OnHwcEventTransfer>;
85+ std::shared_ptr<OnHwcEventInput> inputData_;
86+};
87+ 
88+} // namespace Rosen
89+} // namespace OHOS
90+ 
91+#endif // RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_ZIDL_TRANSFERS_RS_ON_HWC_EVENT_TRANSFER_H
@@ -0,0 +1,330 @@
1+/*
2+ * Copyright (c) 2026 Huawei Device Co., Ltd.
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+ 
16+#include "rs_self_drawing_node_rect_change_callback_transfer.h"
17+ 
18+#include <algorithm>
19+#include <cstdint>
20+ 
21+#include "core/rs_render_pipeline_agent.h"
22+#include "ipc_persistence/rs_ipc_persistence_manager.h"
23+#include "message_parcel.h"
24+ 
25+#include "common/rs_self_draw_rect_change_callback_constraint.h"
26+#include "platform/common/rs_log.h"
27+ 
28+#undef LOG_TAG
29+#define LOG_TAG "SelfDrawingNodeRectChangeCallbackTransfer"
30+ 
31+namespace OHOS {
32+namespace Rosen {
33+ 
34+namespace {
35+constexpr uint32_t MAX_PID_SIZE_NUMBER = 100000;
36+constexpr size_t MAX_CALLBACK_INPUTS = 100;
37+}
38+ 
39+bool SelfDrawingNodeRectChangeCallbackInput::Marshalling(Parcel& parcel) const
40+{
41+ if (!callback_) {
42+ RS_LOGE("%{public}s: callback is nullptr", __func__);
43+ return false;
44+ }
45+ if (!parcel.WriteInt32(pid_)) {
46+ RS_LOGE("%{public}s: WriteInt32 pid failed", __func__);
47+ return false;
48+ }
49+ const auto& pids = constraint_.pids;
50+ uint32_t pidsSize = static_cast<uint32_t>(pids.size());
51+ if (pidsSize > MAX_PID_SIZE_NUMBER) {
52+ RS_LOGE("%{public}s: pids size %{public}u exceeds max", __func__, pidsSize);
53+ return false;
54+ }
55+ if (!parcel.WriteUint32(pidsSize)) {
56+ RS_LOGE("%{public}s: WriteUint32 pids size failed", __func__);
57+ return false;
58+ }
59+ for (int32_t p : pids) {
60+ if (!parcel.WriteInt32(p)) {
61+ RS_LOGE("%{public}s: WriteInt32 pid in constraint failed", __func__);
62+ return false;
63+ }
64+ }
65+ if (!parcel.WriteInt32(constraint_.range.lowLimit.width) ||
66+ !parcel.WriteInt32(constraint_.range.lowLimit.height) ||
67+ !parcel.WriteInt32(constraint_.range.highLimit.width) ||
68+ !parcel.WriteInt32(constraint_.range.highLimit.height)) {
69+ RS_LOGE("%{public}s: Write rectRange failed", __func__);
70+ return false;
71+ }
72+ if (!static_cast<MessageParcel*>(&parcel)->WriteRemoteObject(callback_->AsObject())) {
73+ RS_LOGE("%{public}s: WriteRemoteObject callback failed", __func__);
74+ return false;
75+ }
76+ return true;
77+}
78+ 
79+std::shared_ptr<SelfDrawingNodeRectChangeCallbackInput> SelfDrawingNodeRectChangeCallbackInput::Unmarshalling(
80+ Parcel& parcel, int32_t& errCode)
81+{
82+ pid_t pid;
83+ if (!parcel.ReadInt32(pid)) {
84+ RS_LOGE("%{public}s: ReadInt32 pid failed", __func__);
85+ errCode = ERR_INVALID_DATA;
86+ return nullptr;
87+ }
88+ uint32_t pidsSize;
89+ if (!parcel.ReadUint32(pidsSize) || pidsSize > MAX_PID_SIZE_NUMBER) {
90+ RS_LOGE("%{public}s: pids size exceeds max", __func__);
91+ errCode = ERR_INVALID_DATA;
92+ return nullptr;
93+ }
94+ RectConstraint constraint;
95+ for (uint32_t i = 0; i < pidsSize; ++i) {
96+ pid_t pidValue;
97+ if (!parcel.ReadInt32(pidValue)) {
98+ RS_LOGE("%{public}s: ReadInt32 pid[%{public}u] failed", __func__, i);
99+ errCode = ERR_INVALID_DATA;
100+ return nullptr;
101+ }
102+ constraint.pids.insert(pidValue);
103+ }
104+ if (!parcel.ReadInt32(constraint.range.lowLimit.width) ||
105+ !parcel.ReadInt32(constraint.range.lowLimit.height) ||
106+ !parcel.ReadInt32(constraint.range.highLimit.width) ||
107+ !parcel.ReadInt32(constraint.range.highLimit.height)) {
108+ RS_LOGE("%{public}s: Read rectRange failed", __func__);
109+ errCode = ERR_INVALID_DATA;
110+ return nullptr;
111+ }
112+ auto remoteObject = static_cast<MessageParcel*>(&parcel)->ReadRemoteObject();
113+ if (remoteObject == nullptr) {
114+ RS_LOGE("%{public}s: ReadRemoteObject failed", __func__);
115+ errCode = ERR_NULL_OBJECT;
116+ return nullptr;
117+ }
118+ auto callback = iface_cast<RSISelfDrawingNodeRectChangeCallback>(remoteObject);
119+ if (callback == nullptr) {
120+ RS_LOGE("%{public}s: iface_cast failed", __func__);
121+ errCode = ERR_NULL_OBJECT;
122+ return nullptr;
123+ }
124+ return std::make_shared<SelfDrawingNodeRectChangeCallbackInput>(pid, constraint, callback);
125+}
126+ 
127+bool SelfDrawingNodeRectChangeCallbackReply::Marshalling(Parcel& parcel) const
128+{
129+ if (!parcel.WriteInt32(result_)) {
130+ RS_LOGE("%{public}s: WriteInt32 result failed", __func__);
131+ return false;
132+ }
133+ return true;
134+}
135+ 
136+bool SelfDrawingNodeRectChangeCallbackReply::Unmarshalling(Parcel& parcel)
137+{
138+ if (!parcel.ReadInt32(result_)) {
139+ RS_LOGE("%{public}s: ReadInt32 result failed", __func__);
140+ return false;
141+ }
142+ return true;
143+}
144+ 
145+void SelfDrawingNodeRectChangeCallbackTransfer::Persist(IpcPersistenceMap& map, std::mutex& mutex)
146+{
147+ auto typeId = GetTypeId();
148+ std::shared_ptr<SelfDrawingNodeRectChangeCallbackTransfer> target;
149+ {
150+ std::lock_guard<std::mutex> lock(mutex);
151+ auto it = map.find(typeId);
152+ if (it == map.end()) {
153+ if (map.size() >= Detail::MAX_PERSIST_MAP_SIZE) {
154+ RS_LOGE("%{public}s: persist map full, size=%{public}zu", __func__, map.size());
155+ return;
156+ }
157+ map[typeId] = std::make_shared<SelfDrawingNodeRectChangeCallbackTransfer>(inputs_);
158+ return;
159+ }
160+ target = std::static_pointer_cast<SelfDrawingNodeRectChangeCallbackTransfer>(it->second);
161+ }
162+ if (!target) {
163+ RS_LOGE("%{public}s: existing transfer is nullptr", __func__);
164+ return;
165+ }
166+ std::lock_guard<std::mutex> targetLock(target->mutex_);
167+ for (const auto& [pid, input] : inputs_) {
168+ if (target->inputs_.size() >= MAX_CALLBACK_INPUTS) {
169+ RS_LOGE("%{public}s: inputs_ map full, size=%{public}zu", __func__, target->inputs_.size());
170+ break;
171+ }
172+ target->inputs_[pid] = input;
173+ }
174+}
175+ 
176+void SelfDrawingNodeRectChangeCallbackTransfer::ClearPid(pid_t pid)
177+{
178+ std::lock_guard<std::mutex> lock(mutex_);
179+ inputs_.erase(pid);
180+}
181+ 
182+bool SelfDrawingNodeRectChangeCallbackTransfer::Apply(const sptr<RSRenderPipelineAgent>& agent)
183+{
184+ if (!agent) {
185+ RS_LOGE("%{public}s: agent is nullptr", __func__);
186+ return false;
187+ }
188+ int32_t result = ERR_OK;
189+ for (const auto& [pid, input] : inputs_) {
190+ if (!input || !input->GetCallback()) {
191+ RS_LOGE("%{public}s: input or callback is nullptr for pid %{public}d", __func__, pid);
192+ continue;
193+ }
194+ int32_t ret = agent->RegisterSelfDrawingNodeRectChangeCallback(
195+ pid, input->GetConstraint(), input->GetCallback());
196+ if (ret != ERR_OK && result == ERR_OK) {
197+ result = ret;
198+ }
199+ }
200+ SetReplyData(std::make_shared<SelfDrawingNodeRectChangeCallbackReply>(result));
201+ return true;
202+}
203+ 
204+bool SelfDrawingNodeRectChangeCallbackTransfer::ProxyMarshalling(Parcel& parcel) const
205+{
206+ std::lock_guard<std::mutex> lock(mutex_);
207+ if (!parcel.WriteUint32(static_cast<uint32_t>(inputs_.size()))) {
208+ RS_LOGE("%{public}s: WriteUint32 count failed", __func__);
209+ return false;
210+ }
211+ for (const auto& [pid, input] : inputs_) {
212+ if (!input || !input->Marshalling(parcel)) {
213+ RS_LOGE("%{public}s: Input Marshalling failed for pid %{public}d", __func__, pid);
214+ return false;
215+ }
216+ }
217+ return true;
218+}
219+ 
220+std::shared_ptr<SelfDrawingNodeRectChangeCallbackTransfer>
221+SelfDrawingNodeRectChangeCallbackTransfer::StubUnmarshalling(Parcel& parcel, uint32_t maxEntries, int32_t& errCode)
222+{
223+ const uint32_t cap = std::min(maxEntries, static_cast<uint32_t>(MAX_CALLBACK_INPUTS));
224+ uint32_t size = 0;
225+ if (!parcel.ReadUint32(size) || size > cap) {
226+ RS_LOGE("%{public}s: count %{public}u exceeds max %{public}u", __func__, size, cap);
227+ errCode = ERR_INVALID_DATA;
228+ return nullptr;
229+ }
230+ std::map<pid_t, std::shared_ptr<SelfDrawingNodeRectChangeCallbackInput>> inputs;
231+ for (uint32_t i = 0; i < size; ++i) {
232+ auto input = SelfDrawingNodeRectChangeCallbackInput::Unmarshalling(parcel, errCode);
233+ if (!input) {
234+ return nullptr;
235+ }
236+ inputs[input->GetPid()] = input;
237+ }
238+ return std::make_shared<SelfDrawingNodeRectChangeCallbackTransfer>(std::move(inputs));
239+}
240+ 
241+bool UnRegisterSelfDrawingNodeRectChangeCallbackInput::Marshalling(Parcel& parcel) const
242+{
243+ if (!parcel.WriteInt32(pid_)) {
244+ RS_LOGE("%{public}s: WriteInt32 pid failed", __func__);
245+ return false;
246+ }
247+ return true;
248+}
249+ 
250+std::shared_ptr<UnRegisterSelfDrawingNodeRectChangeCallbackInput>
251+UnRegisterSelfDrawingNodeRectChangeCallbackInput::Unmarshalling(Parcel& parcel, int32_t& errCode)
252+{
253+ pid_t pid;
254+ if (!parcel.ReadInt32(pid)) {
255+ RS_LOGE("%{public}s: ReadInt32 pid failed", __func__);
256+ errCode = ERR_INVALID_DATA;
257+ return nullptr;
258+ }
259+ return std::make_shared<UnRegisterSelfDrawingNodeRectChangeCallbackInput>(pid);
260+}
261+ 
262+bool UnRegisterSelfDrawingNodeRectChangeCallbackReply::Marshalling(Parcel& parcel) const
263+{
264+ if (!parcel.WriteInt32(result_)) {
265+ RS_LOGE("%{public}s: WriteInt32 result failed", __func__);
266+ return false;
267+ }
268+ return true;
269+}
270+ 
271+bool UnRegisterSelfDrawingNodeRectChangeCallbackReply::Unmarshalling(Parcel& parcel)
272+{
273+ if (!parcel.ReadInt32(result_)) {
274+ RS_LOGE("%{public}s: ReadInt32 result failed", __func__);
275+ return false;
276+ }
277+ return true;
278+}
279+ 
280+void UnRegisterSelfDrawingNodeRectChangeCallbackTransfer::Persist(IpcPersistenceMap& map, std::mutex& mutex)
281+{
282+ constexpr auto registerTypeId =
283+ RSIServiceToRenderConnectionInterfaceCode::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK;
284+ if (!inputData_) {
285+ RS_LOGE("%{public}s: inputData_ is nullptr", __func__);
286+ return;
287+ }
288+ std::shared_ptr<RSIpcTransferBase> target;
289+ {
290+ std::lock_guard<std::mutex> lock(mutex);
291+ auto it = map.find(registerTypeId);
292+ if (it == map.end()) {
293+ return;
294+ }
295+ target = it->second;
296+ }
297+ if (target) {
298+ target->ClearPid(inputData_->GetPid());
299+ }
300+}
301+ 
302+bool UnRegisterSelfDrawingNodeRectChangeCallbackTransfer::ProxyMarshalling(Parcel& parcel) const
303+{
304+ std::lock_guard<std::mutex> lock(mutex_);
305+ if (!inputData_) {
306+ return false;
307+ }
308+ return inputData_->Marshalling(parcel);
309+}
310+ 
311+bool UnRegisterSelfDrawingNodeRectChangeCallbackTransfer::Apply(const sptr<RSRenderPipelineAgent>& agent)
312+{
313+ if (!agent || !inputData_) {
314+ RS_LOGE("%{public}s: agent or input is nullptr", __func__);
315+ return false;
316+ }
317+ auto result = agent->UnRegisterSelfDrawingNodeRectChangeCallback(inputData_->GetPid());
318+ SetReplyData(std::make_shared<UnRegisterSelfDrawingNodeRectChangeCallbackReply>(result));
319+ return true;
320+}
321+ 
322+// Explicit ODR-use: guarantee factory registration at static init time, independent of
323+// whether any SelfDrawing Transfer is constructed before CreateTransferByTypeId.
324+[[maybe_unused]] const auto* g_selfDrawingRegisterRegistrar =
325+ &TransferRegistrationChecker<SelfDrawingNodeRectChangeCallbackTransfer>::registrar;
326+[[maybe_unused]] const auto* g_selfDrawingUnRegisterRegistrar =
327+ &TransferRegistrationChecker<UnRegisterSelfDrawingNodeRectChangeCallbackTransfer>::registrar;
328+ 
329+} // namespace Rosen
330+} // namespace OHOS
@@ -0,0 +1,224 @@
1+/*
2+ * Copyright (c) 2026 Huawei Device Co., Ltd.
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+ 
16+#ifndef RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_ZIDL_TRANSFERS_RS_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK_TRANSFER_H
17+#define RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_ZIDL_TRANSFERS_RS_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK_TRANSFER_H
18+ 
19+#include <cstdint>
20+#include <map>
21+#include <memory>
22+#include <sys/types.h>
23+ 
24+#include <parcel.h>
25+ 
26+#include "rs_ipc_persistence_def.h"
27+#include "rs_ipc_persistence_manager.h"
28+#include "ipc_callbacks/rs_iself_drawing_node_rect_change_callback.h"
29+#include "common/rs_self_draw_rect_change_callback_constraint.h"
30+ 
31+namespace OHOS {
32+namespace Rosen {
33+ 
34+class SelfDrawingNodeRectChangeCallbackInput
35+ : public RSIpcPersistenceDataBase<SelfDrawingNodeRectChangeCallbackInput> {
36+public:
37+ SelfDrawingNodeRectChangeCallbackInput(pid_t pid, const RectConstraint& constraint,
38+ sptr<RSISelfDrawingNodeRectChangeCallback> callback)
39+ : pid_(pid), constraint_(constraint), callback_(callback) {}
40+ 
41+ pid_t GetPid() const { return pid_; }
42+ const RectConstraint& GetConstraint() const { return constraint_; }
43+ const sptr<RSISelfDrawingNodeRectChangeCallback>& GetCallback() const { return callback_; }
44+ 
45+ bool Marshalling(Parcel& parcel) const override;
46+ [[nodiscard]] static std::shared_ptr<SelfDrawingNodeRectChangeCallbackInput> Unmarshalling(
47+ Parcel& parcel, int32_t& errCode);
48+ 
49+ SelfDrawingNodeRectChangeCallbackInput(const SelfDrawingNodeRectChangeCallbackInput&) = delete;
50+ SelfDrawingNodeRectChangeCallbackInput& operator=(const SelfDrawingNodeRectChangeCallbackInput&) = delete;
51+ SelfDrawingNodeRectChangeCallbackInput(SelfDrawingNodeRectChangeCallbackInput&&) = delete;
52+ SelfDrawingNodeRectChangeCallbackInput& operator=(SelfDrawingNodeRectChangeCallbackInput&&) = delete;
53+ 
54+private:
55+ pid_t pid_;
56+ RectConstraint constraint_;
57+ sptr<RSISelfDrawingNodeRectChangeCallback> callback_;
58+};
59+ 
60+class SelfDrawingNodeRectChangeCallbackReply
61+ : public RSIpcPersistenceReplyBase<SelfDrawingNodeRectChangeCallbackReply> {
62+public:
63+ explicit SelfDrawingNodeRectChangeCallbackReply(int32_t result = Detail::REPLY_RESULT_PENDING)
64+ : result_(result) {}
65+ 
66+ int32_t GetResult() const { return result_; }
67+ 
68+ bool Marshalling(Parcel& parcel) const override;
69+ bool Unmarshalling(Parcel& parcel) override;
70+ 
71+ SelfDrawingNodeRectChangeCallbackReply(const SelfDrawingNodeRectChangeCallbackReply&) = delete;
72+ SelfDrawingNodeRectChangeCallbackReply& operator=(const SelfDrawingNodeRectChangeCallbackReply&) = delete;
73+ SelfDrawingNodeRectChangeCallbackReply(SelfDrawingNodeRectChangeCallbackReply&&) = delete;
74+ SelfDrawingNodeRectChangeCallbackReply& operator=(SelfDrawingNodeRectChangeCallbackReply&&) = delete;
75+ 
76+private:
77+ int32_t result_ = Detail::REPLY_RESULT_PENDING;
78+};
79+ 
80+class SelfDrawingNodeRectChangeCallbackTransfer final
81+ : public RSIpcTransferCRTP<SelfDrawingNodeRectChangeCallbackTransfer,
82+ SelfDrawingNodeRectChangeCallbackInput,
83+ SelfDrawingNodeRectChangeCallbackReply> {
84+public:
85+ explicit SelfDrawingNodeRectChangeCallbackTransfer(
86+ std::map<pid_t, std::shared_ptr<SelfDrawingNodeRectChangeCallbackInput>> inputs)
87+ : inputs_(std::move(inputs)) {}
88+ 
89+ static constexpr RSIServiceToRenderConnectionInterfaceCode TypeId =
90+ RSIServiceToRenderConnectionInterfaceCode::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK;
91+ RSIServiceToRenderConnectionInterfaceCode GetTypeId() const override { return TypeId; }
92+ bool IsPersistent() const override { return true; }
93+ bool IsSync() const override { return true; }
94+ FanoutPolicy GetFanoutPolicy() const override { return FanoutPolicy::FAIL_FAST; }
95+ int32_t GetReplyResult() const override
96+ {
97+ std::lock_guard<std::mutex> lock(mutex_);
98+ return replyData_ ? replyData_->GetResult() : Detail::REPLY_RESULT_PENDING;
99+ }
100+ 
101+ bool Apply(const sptr<RSRenderPipelineAgent>& agent) override;
102+ 
103+ bool ProxyMarshalling(Parcel& parcel) const override;
104+ [[nodiscard]] static std::shared_ptr<SelfDrawingNodeRectChangeCallbackTransfer> StubUnmarshalling(
105+ Parcel& parcel, uint32_t maxEntries, int32_t& errCode);
106+ std::shared_ptr<RSIpcTransferBase> CopyTransfer() const override
107+ {
108+ return std::make_shared<SelfDrawingNodeRectChangeCallbackTransfer>(inputs_);
109+ }
110+ void ClearPid(pid_t pid) override;
111+ 
112+ SelfDrawingNodeRectChangeCallbackTransfer(const SelfDrawingNodeRectChangeCallbackTransfer&) = delete;
113+ SelfDrawingNodeRectChangeCallbackTransfer& operator=(const SelfDrawingNodeRectChangeCallbackTransfer&) = delete;
114+ SelfDrawingNodeRectChangeCallbackTransfer(SelfDrawingNodeRectChangeCallbackTransfer&&) = delete;
115+ SelfDrawingNodeRectChangeCallbackTransfer& operator=(SelfDrawingNodeRectChangeCallbackTransfer&&) = delete;
116+ 
117+protected:
118+ void Persist(IpcPersistenceMap& map, std::mutex& mutex) override;
119+ 
120+private:
121+ static constexpr bool registered_ = true;
122+ friend struct TransferRegistrationChecker<SelfDrawingNodeRectChangeCallbackTransfer>;
123+ std::map<pid_t, std::shared_ptr<SelfDrawingNodeRectChangeCallbackInput>> inputs_;
124+};
125+ 
126+class UnRegisterSelfDrawingNodeRectChangeCallbackInput
127+ : public RSIpcPersistenceDataBase<UnRegisterSelfDrawingNodeRectChangeCallbackInput> {
128+public:
129+ explicit UnRegisterSelfDrawingNodeRectChangeCallbackInput(pid_t pid) : pid_(pid) {}
130+ 
131+ pid_t GetPid() const { return pid_; }
132+ 
133+ bool Marshalling(Parcel& parcel) const override;
134+ [[nodiscard]] static std::shared_ptr<UnRegisterSelfDrawingNodeRectChangeCallbackInput> Unmarshalling(
135+ Parcel& parcel, int32_t& errCode);
136+ 
137+ UnRegisterSelfDrawingNodeRectChangeCallbackInput(const UnRegisterSelfDrawingNodeRectChangeCallbackInput&) = delete;
138+ UnRegisterSelfDrawingNodeRectChangeCallbackInput& operator=(
139+ const UnRegisterSelfDrawingNodeRectChangeCallbackInput&) = delete;
140+ UnRegisterSelfDrawingNodeRectChangeCallbackInput(UnRegisterSelfDrawingNodeRectChangeCallbackInput&&) = delete;
141+ UnRegisterSelfDrawingNodeRectChangeCallbackInput& operator=(
142+ UnRegisterSelfDrawingNodeRectChangeCallbackInput&&) = delete;
143+ 
144+private:
145+ pid_t pid_;
146+};
147+ 
148+class UnRegisterSelfDrawingNodeRectChangeCallbackReply
149+ : public RSIpcPersistenceReplyBase<UnRegisterSelfDrawingNodeRectChangeCallbackReply> {
150+public:
151+ explicit UnRegisterSelfDrawingNodeRectChangeCallbackReply(int32_t result = Detail::REPLY_RESULT_PENDING)
152+ : result_(result) {}
153+ 
154+ int32_t GetResult() const { return result_; }
155+ 
156+ bool Marshalling(Parcel& parcel) const override;
157+ bool Unmarshalling(Parcel& parcel) override;
158+ 
159+ UnRegisterSelfDrawingNodeRectChangeCallbackReply(const UnRegisterSelfDrawingNodeRectChangeCallbackReply&) = delete;
160+ UnRegisterSelfDrawingNodeRectChangeCallbackReply& operator=(
161+ const UnRegisterSelfDrawingNodeRectChangeCallbackReply&) = delete;
162+ UnRegisterSelfDrawingNodeRectChangeCallbackReply(UnRegisterSelfDrawingNodeRectChangeCallbackReply&&) = delete;
163+ UnRegisterSelfDrawingNodeRectChangeCallbackReply& operator=(
164+ UnRegisterSelfDrawingNodeRectChangeCallbackReply&&) = delete;
165+ 
166+private:
167+ int32_t result_ = Detail::REPLY_RESULT_PENDING;
168+};
169+ 
170+class UnRegisterSelfDrawingNodeRectChangeCallbackTransfer final
171+ : public RSIpcTransferCRTP<UnRegisterSelfDrawingNodeRectChangeCallbackTransfer,
172+ UnRegisterSelfDrawingNodeRectChangeCallbackInput,
173+ UnRegisterSelfDrawingNodeRectChangeCallbackReply> {
174+public:
175+ explicit UnRegisterSelfDrawingNodeRectChangeCallbackTransfer(
176+ const std::shared_ptr<UnRegisterSelfDrawingNodeRectChangeCallbackInput>& input)
177+ : inputData_(input) {}
178+ 
179+ static constexpr RSIServiceToRenderConnectionInterfaceCode TypeId =
180+ RSIServiceToRenderConnectionInterfaceCode::UNREGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK;
181+ RSIServiceToRenderConnectionInterfaceCode GetTypeId() const override { return TypeId; }
182+ RSIServiceToRenderConnectionInterfaceCode GetPersistLockTypeId() const override
183+ {
184+ return RSIServiceToRenderConnectionInterfaceCode::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK;
185+ }
186+ bool IsPersistent() const override { return true; }
187+ bool IsSync() const override { return true; }
188+ FanoutPolicy GetFanoutPolicy() const override { return FanoutPolicy::FAIL_FAST; }
189+ int32_t GetReplyResult() const override
190+ {
191+ std::lock_guard<std::mutex> lock(mutex_);
192+ return replyData_ ? replyData_->GetResult() : Detail::REPLY_RESULT_PENDING;
193+ }
194+ 
195+ bool Apply(const sptr<RSRenderPipelineAgent>& agent) override;
196+ bool ProxyMarshalling(Parcel& parcel) const override;
197+ std::shared_ptr<RSIpcTransferBase> CopyTransfer() const override
198+ {
199+ return std::make_shared<UnRegisterSelfDrawingNodeRectChangeCallbackTransfer>(inputData_);
200+ }
201+ void ClearPid(pid_t) override {}
202+ 
203+ UnRegisterSelfDrawingNodeRectChangeCallbackTransfer(
204+ const UnRegisterSelfDrawingNodeRectChangeCallbackTransfer&) = delete;
205+ UnRegisterSelfDrawingNodeRectChangeCallbackTransfer& operator=(
206+ const UnRegisterSelfDrawingNodeRectChangeCallbackTransfer&) = delete;
207+ UnRegisterSelfDrawingNodeRectChangeCallbackTransfer(
208+ UnRegisterSelfDrawingNodeRectChangeCallbackTransfer&&) = delete;
209+ UnRegisterSelfDrawingNodeRectChangeCallbackTransfer& operator=(
210+ UnRegisterSelfDrawingNodeRectChangeCallbackTransfer&&) = delete;
211+ 
212+protected:
213+ void Persist(IpcPersistenceMap& map, std::mutex& mutex) override;
214+ 
215+private:
216+ static constexpr bool registered_ = true;
217+ friend struct TransferRegistrationChecker<UnRegisterSelfDrawingNodeRectChangeCallbackTransfer>;
218+ std::shared_ptr<UnRegisterSelfDrawingNodeRectChangeCallbackInput> inputData_;
219+};
220+ 
221+} // namespace Rosen
222+} // namespace OHOS
223+ 
224+#endif // RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_ZIDL_TRANSFERS_RS_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK_TRANSFER_H
@@ -0,0 +1,101 @@
1+/*
2+ * Copyright (c) 2026 Huawei Device Co., Ltd.
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+ 
16+#include "rs_set_behind_window_filter_enabled_transfer.h"
17+ 
18+#include "core/rs_render_pipeline_agent.h"
19+#include "ipc_persistence/rs_ipc_persistence_manager.h"
20+ 
21+#include "platform/common/rs_log.h"
22+ 
23+#undef LOG_TAG
24+#define LOG_TAG "SetBehindWindowFilterEnabledTransfer"
25+ 
26+namespace OHOS {
27+namespace Rosen {
28+ 
29+bool SetBehindWindowFilterEnabledInput::Marshalling(Parcel& parcel) const
30+{
31+ if (!parcel.WriteBool(enabled_)) {
32+ RS_LOGE("%{public}s: WriteBool enabled failed", __func__);
33+ return false;
34+ }
35+ return true;
36+}
37+ 
38+std::shared_ptr<SetBehindWindowFilterEnabledInput> SetBehindWindowFilterEnabledInput::Unmarshalling(
39+ Parcel& parcel, int32_t& errCode)
40+{
41+ bool enabled;
42+ if (!parcel.ReadBool(enabled)) {
43+ RS_LOGE("%{public}s: ReadBool enabled failed", __func__);
44+ errCode = ERR_INVALID_DATA;
45+ return nullptr;
46+ }
47+ return std::make_shared<SetBehindWindowFilterEnabledInput>(enabled);
48+}
49+ 
50+void SetBehindWindowFilterEnabledTransfer::Persist(IpcPersistenceMap& map, std::mutex& mutex)
51+{
52+ auto typeId = GetTypeId();
53+ std::shared_ptr<SetBehindWindowFilterEnabledTransfer> target;
54+ {
55+ std::lock_guard<std::mutex> lock(mutex);
56+ auto it = map.find(typeId);
57+ if (it == map.end()) {
58+ if (map.size() >= Detail::MAX_PERSIST_MAP_SIZE) {
59+ RS_LOGE("%{public}s: persist map full, size=%{public}zu", __func__, map.size());
60+ return;
61+ }
62+ map[typeId] = std::make_shared<SetBehindWindowFilterEnabledTransfer>(inputData_);
63+ return;
64+ }
65+ target = std::static_pointer_cast<SetBehindWindowFilterEnabledTransfer>(it->second);
66+ }
67+ if (!target) {
68+ RS_LOGE("%{public}s: existing transfer is nullptr", __func__);
69+ return;
70+ }
71+ std::lock_guard<std::mutex> targetLock(target->mutex_);
72+ target->inputData_ = inputData_;
73+}
74+ 
75+bool SetBehindWindowFilterEnabledTransfer::ProxyMarshalling(Parcel& parcel) const
76+{
77+ std::lock_guard<std::mutex> lock(mutex_);
78+ if (!inputData_) {
79+ return false;
80+ }
81+ return inputData_->Marshalling(parcel);
82+}
83+ 
84+bool SetBehindWindowFilterEnabledTransfer::Apply(const sptr<RSRenderPipelineAgent>& agent)
85+{
86+ if (!agent || !inputData_) {
87+ RS_LOGE("%{public}s: agent or input is nullptr", __func__);
88+ return false;
89+ }
90+ agent->SetBehindWindowFilterEnabled(inputData_->GetEnabled());
91+ SetReplyData(std::make_shared<RSIpcEmptyReply>());
92+ return true;
93+}
94+ 
95+// Explicit ODR-use: guarantee factory registration at static init time, independent of
96+// whether any SetBehindWindowFilterEnabledTransfer is constructed before CreateTransferByTypeId.
97+[[maybe_unused]] const auto* g_setBehindWindowFilterRegistrar =
98+ &TransferRegistrationChecker<SetBehindWindowFilterEnabledTransfer>::registrar;
99+ 
100+} // namespace Rosen
101+} // namespace OHOS
@@ -0,0 +1,90 @@
1+/*
2+ * Copyright (c) 2026 Huawei Device Co., Ltd.
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+ 
16+#ifndef RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_ZIDL_TRANSFERS_RS_SET_BEHIND_WINDOW_FILTER_ENABLED_TRANSFER_H
17+#define RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_ZIDL_TRANSFERS_RS_SET_BEHIND_WINDOW_FILTER_ENABLED_TRANSFER_H
18+ 
19+#include <cstdint>
20+#include <memory>
21+ 
22+#include <parcel.h>
23+ 
24+#include "rs_ipc_persistence_def.h"
25+#include "rs_ipc_persistence_manager.h"
26+ 
27+namespace OHOS {
28+namespace Rosen {
29+ 
30+class SetBehindWindowFilterEnabledInput : public RSIpcPersistenceDataBase<SetBehindWindowFilterEnabledInput> {
31+public:
32+ explicit SetBehindWindowFilterEnabledInput(bool enabled) : enabled_(enabled) {}
33+ 
34+ bool GetEnabled() const { return enabled_; }
35+ 
36+ bool Marshalling(Parcel& parcel) const override;
37+ [[nodiscard]] static std::shared_ptr<SetBehindWindowFilterEnabledInput> Unmarshalling(
38+ Parcel& parcel, int32_t& errCode);
39+ 
40+ SetBehindWindowFilterEnabledInput(const SetBehindWindowFilterEnabledInput&) = delete;
41+ SetBehindWindowFilterEnabledInput& operator=(const SetBehindWindowFilterEnabledInput&) = delete;
42+ SetBehindWindowFilterEnabledInput(SetBehindWindowFilterEnabledInput&&) = delete;
43+ SetBehindWindowFilterEnabledInput& operator=(SetBehindWindowFilterEnabledInput&&) = delete;
44+ 
45+private:
46+ bool enabled_;
47+};
48+ 
49+class SetBehindWindowFilterEnabledTransfer final
50+ : public RSIpcTransferCRTP<SetBehindWindowFilterEnabledTransfer,
51+ SetBehindWindowFilterEnabledInput,
52+ RSIpcEmptyReply> {
53+public:
54+ explicit SetBehindWindowFilterEnabledTransfer(
55+ const std::shared_ptr<SetBehindWindowFilterEnabledInput>& input)
56+ : inputData_(input) {}
57+ 
58+ static constexpr RSIServiceToRenderConnectionInterfaceCode TypeId =
59+ RSIServiceToRenderConnectionInterfaceCode::SET_BEHIND_WINDOW_FILTER_ENABLED;
60+ RSIServiceToRenderConnectionInterfaceCode GetTypeId() const override { return TypeId; }
61+ bool IsPersistent() const override { return true; }
62+ bool IsSync() const override { return true; }
63+ FanoutPolicy GetFanoutPolicy() const override { return FanoutPolicy::ANY_SUCCESS; }
64+ 
65+ bool Apply(const sptr<RSRenderPipelineAgent>& agent) override;
66+ bool ProxyMarshalling(Parcel& parcel) const override;
67+ std::shared_ptr<RSIpcTransferBase> CopyTransfer() const override
68+ {
69+ return std::make_shared<SetBehindWindowFilterEnabledTransfer>(inputData_);
70+ }
71+ void ClearPid(pid_t) override {}
72+ 
73+ SetBehindWindowFilterEnabledTransfer(const SetBehindWindowFilterEnabledTransfer&) = delete;
74+ SetBehindWindowFilterEnabledTransfer& operator=(const SetBehindWindowFilterEnabledTransfer&) = delete;
75+ SetBehindWindowFilterEnabledTransfer(SetBehindWindowFilterEnabledTransfer&&) = delete;
76+ SetBehindWindowFilterEnabledTransfer& operator=(SetBehindWindowFilterEnabledTransfer&&) = delete;
77+ 
78+protected:
79+ void Persist(IpcPersistenceMap& map, std::mutex& mutex) override;
80+ 
81+private:
82+ static constexpr bool registered_ = true;
83+ friend struct TransferRegistrationChecker<SetBehindWindowFilterEnabledTransfer>;
84+ std::shared_ptr<SetBehindWindowFilterEnabledInput> inputData_;
85+};
86+ 
87+} // namespace Rosen
88+} // namespace OHOS
89+ 
90+#endif // RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_ZIDL_TRANSFERS_RS_SET_BEHIND_WINDOW_FILTER_ENABLED_TRANSFER_H
@@ -0,0 +1,111 @@
1+/*
2+ * Copyright (c) 2026 Huawei Device Co., Ltd.
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+ 
16+#include "rs_set_show_refresh_rate_enabled_transfer.h"
17+ 
18+#include "core/rs_render_pipeline_agent.h"
19+#include "ipc_persistence/rs_ipc_persistence_manager.h"
20+ 
21+#include "platform/common/rs_log.h"
22+ 
23+#undef LOG_TAG
24+#define LOG_TAG "SetShowRefreshRateEnabledTransfer"
25+ 
26+namespace OHOS {
27+namespace Rosen {
28+ 
29+bool SetShowRefreshRateEnabledInput::Marshalling(Parcel& parcel) const
30+{
31+ if (!parcel.WriteBool(enabled_)) {
32+ RS_LOGE("%{public}s: WriteBool enabled failed", __func__);
33+ return false;
34+ }
35+ if (!parcel.WriteInt32(type_)) {
36+ RS_LOGE("%{public}s: WriteInt32 type failed", __func__);
37+ return false;
38+ }
39+ return true;
40+}
41+ 
42+std::shared_ptr<SetShowRefreshRateEnabledInput> SetShowRefreshRateEnabledInput::Unmarshalling(
43+ Parcel& parcel, int32_t& errCode)
44+{
45+ bool enabled;
46+ if (!parcel.ReadBool(enabled)) {
47+ RS_LOGE("%{public}s: ReadBool enabled failed", __func__);
48+ errCode = ERR_INVALID_DATA;
49+ return nullptr;
50+ }
51+ int32_t type;
52+ if (!parcel.ReadInt32(type)) {
53+ RS_LOGE("%{public}s: ReadInt32 type failed", __func__);
54+ errCode = ERR_INVALID_DATA;
55+ return nullptr;
56+ }
57+ return std::make_shared<SetShowRefreshRateEnabledInput>(enabled, type);
58+}
59+ 
60+void SetShowRefreshRateEnabledTransfer::Persist(IpcPersistenceMap& map, std::mutex& mutex)
61+{
62+ auto typeId = GetTypeId();
63+ std::shared_ptr<SetShowRefreshRateEnabledTransfer> target;
64+ {
65+ std::lock_guard<std::mutex> lock(mutex);
66+ auto it = map.find(typeId);
67+ if (it == map.end()) {
68+ if (map.size() >= Detail::MAX_PERSIST_MAP_SIZE) {
69+ RS_LOGE("%{public}s: persist map full, size=%{public}zu", __func__, map.size());
70+ return;
71+ }
72+ map[typeId] = std::make_shared<SetShowRefreshRateEnabledTransfer>(inputData_);
73+ return;
74+ }
75+ target = std::static_pointer_cast<SetShowRefreshRateEnabledTransfer>(it->second);
76+ }
77+ if (!target) {
78+ RS_LOGE("%{public}s: existing transfer is nullptr", __func__);
79+ return;
80+ }
81+ std::lock_guard<std::mutex> targetLock(target->mutex_);
82+ target->inputData_ = inputData_;
83+}
84+ 
85+bool SetShowRefreshRateEnabledTransfer::ProxyMarshalling(Parcel& parcel) const
86+{
87+ std::lock_guard<std::mutex> lock(mutex_);
88+ if (!inputData_) {
89+ return false;
90+ }
91+ return inputData_->Marshalling(parcel);
92+}
93+ 
94+bool SetShowRefreshRateEnabledTransfer::Apply(const sptr<RSRenderPipelineAgent>& agent)
95+{
96+ if (!agent || !inputData_) {
97+ RS_LOGE("%{public}s: agent or input is nullptr", __func__);
98+ return false;
99+ }
100+ agent->SetShowRefreshRateEnabled(inputData_->GetEnabled(), inputData_->GetType());
101+ SetReplyData(std::make_shared<RSIpcEmptyReply>());
102+ return true;
103+}
104+ 
105+// Explicit ODR-use: guarantee factory registration at static init time, independent of
106+// whether any SetShowRefreshRateEnabledTransfer is constructed before CreateTransferByTypeId.
107+[[maybe_unused]] const auto* g_setShowRefreshRateRegistrar =
108+ &TransferRegistrationChecker<SetShowRefreshRateEnabledTransfer>::registrar;
109+ 
110+} // namespace Rosen
111+} // namespace OHOS
@@ -0,0 +1,92 @@
1+/*
2+ * Copyright (c) 2026 Huawei Device Co., Ltd.
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+ 
16+#ifndef RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_ZIDL_TRANSFERS_RS_SET_SHOW_REFRESH_RATE_ENABLED_TRANSFER_H
17+#define RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_ZIDL_TRANSFERS_RS_SET_SHOW_REFRESH_RATE_ENABLED_TRANSFER_H
18+ 
19+#include <cstdint>
20+#include <memory>
21+ 
22+#include <parcel.h>
23+ 
24+#include "rs_ipc_persistence_def.h"
25+#include "rs_ipc_persistence_manager.h"
26+ 
27+namespace OHOS {
28+namespace Rosen {
29+ 
30+class SetShowRefreshRateEnabledInput : public RSIpcPersistenceDataBase<SetShowRefreshRateEnabledInput> {
31+public:
32+ SetShowRefreshRateEnabledInput(bool enabled, int32_t type) : enabled_(enabled), type_(type) {}
33+ 
34+ bool GetEnabled() const { return enabled_; }
35+ int32_t GetType() const { return type_; }
36+ 
37+ bool Marshalling(Parcel& parcel) const override;
38+ [[nodiscard]] static std::shared_ptr<SetShowRefreshRateEnabledInput> Unmarshalling(
39+ Parcel& parcel, int32_t& errCode);
40+ 
41+ SetShowRefreshRateEnabledInput(const SetShowRefreshRateEnabledInput&) = delete;
42+ SetShowRefreshRateEnabledInput& operator=(const SetShowRefreshRateEnabledInput&) = delete;
43+ SetShowRefreshRateEnabledInput(SetShowRefreshRateEnabledInput&&) = delete;
44+ SetShowRefreshRateEnabledInput& operator=(SetShowRefreshRateEnabledInput&&) = delete;
45+ 
46+private:
47+ bool enabled_;
48+ int32_t type_;
49+};
50+ 
51+class SetShowRefreshRateEnabledTransfer final
52+ : public RSIpcTransferCRTP<SetShowRefreshRateEnabledTransfer,
53+ SetShowRefreshRateEnabledInput,
54+ RSIpcEmptyReply> {
55+public:
56+ explicit SetShowRefreshRateEnabledTransfer(
57+ const std::shared_ptr<SetShowRefreshRateEnabledInput>& input)
58+ : inputData_(input) {}
59+ 
60+ static constexpr RSIServiceToRenderConnectionInterfaceCode TypeId =
61+ RSIServiceToRenderConnectionInterfaceCode::SET_SHOW_REFRESH_RATE_ENABLED;
62+ RSIServiceToRenderConnectionInterfaceCode GetTypeId() const override { return TypeId; }
63+ bool IsPersistent() const override { return true; }
64+ bool IsSync() const override { return true; }
65+ FanoutPolicy GetFanoutPolicy() const override { return FanoutPolicy::ANY_SUCCESS; }
66+ 
67+ bool Apply(const sptr<RSRenderPipelineAgent>& agent) override;
68+ bool ProxyMarshalling(Parcel& parcel) const override;
69+ std::shared_ptr<RSIpcTransferBase> CopyTransfer() const override
70+ {
71+ return std::make_shared<SetShowRefreshRateEnabledTransfer>(inputData_);
72+ }
73+ void ClearPid(pid_t) override {}
74+ 
75+ SetShowRefreshRateEnabledTransfer(const SetShowRefreshRateEnabledTransfer&) = delete;
76+ SetShowRefreshRateEnabledTransfer& operator=(const SetShowRefreshRateEnabledTransfer&) = delete;
77+ SetShowRefreshRateEnabledTransfer(SetShowRefreshRateEnabledTransfer&&) = delete;
78+ SetShowRefreshRateEnabledTransfer& operator=(SetShowRefreshRateEnabledTransfer&&) = delete;
79+ 
80+protected:
81+ void Persist(IpcPersistenceMap& map, std::mutex& mutex) override;
82+ 
83+private:
84+ static constexpr bool registered_ = true;
85+ friend struct TransferRegistrationChecker<SetShowRefreshRateEnabledTransfer>;
86+ std::shared_ptr<SetShowRefreshRateEnabledInput> inputData_;
87+};
88+ 
89+} // namespace Rosen
90+} // namespace OHOS
91+ 
92+#endif // RENDER_SERVICE_MAIN_RENDER_PROCESS_TRANSACTION_ZIDL_TRANSFERS_RS_SET_SHOW_REFRESH_RATE_ENABLED_TRANSFER_H