• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 <cstdint>
17 #include <functional>
18 
19 #include "rs_interfaces.h"
20 #include "rs_trace.h"
21 
22 #include "platform/common/rs_system_properties.h"
23 #include "pipeline/rs_render_node.h"
24 #include "pipeline/rs_surface_buffer_callback_manager.h"
25 #include "offscreen_render/rs_offscreen_render_thread.h"
26 #include "feature/hyper_graphic_manager/rs_frame_rate_policy.h"
27 #include "feature/ui_capture/rs_divided_ui_capture.h"
28 #include "ui/rs_proxy_node.h"
29 #include "platform/common/rs_log.h"
30 #include "render/rs_typeface_cache.h"
31 namespace OHOS {
32 namespace Rosen {
33 #ifdef ROSEN_OHOS
34 namespace {
35 constexpr uint32_t WATERMARK_PIXELMAP_SIZE_LIMIT = 500 * 1024;
36 constexpr uint32_t WATERMARK_NAME_LENGTH_LIMIT = 128;
37 constexpr int32_t SECURITYMASK_IMAGE_WIDTH_LIMIT = 4096;
38 constexpr int32_t SECURITYMASK_IMAGE_HEIGHT_LIMIT = 4096;
39 }
40 #endif
GetInstance()41 RSInterfaces &RSInterfaces::GetInstance()
42 {
43     static RSInterfaces instance;
44     return instance;
45 }
46 
RSInterfaces()47 RSInterfaces::RSInterfaces() : renderServiceClient_(std::make_unique<RSRenderServiceClient>())
48 {
49 }
50 
~RSInterfaces()51 RSInterfaces::~RSInterfaces() noexcept
52 {
53 }
54 
SetFocusAppInfo(const FocusAppInfo & info)55 int32_t RSInterfaces::SetFocusAppInfo(const FocusAppInfo& info)
56 {
57     return renderServiceClient_->SetFocusAppInfo(info);
58 }
59 
GetDefaultScreenId()60 ScreenId RSInterfaces::GetDefaultScreenId()
61 {
62     return renderServiceClient_->GetDefaultScreenId();
63 }
64 
GetActiveScreenId()65 ScreenId RSInterfaces::GetActiveScreenId()
66 {
67     return renderServiceClient_->GetActiveScreenId();
68 }
69 
GetAllScreenIds()70 std::vector<ScreenId> RSInterfaces::GetAllScreenIds()
71 {
72     return renderServiceClient_->GetAllScreenIds();
73 }
74 
75 #ifndef ROSEN_CROSS_PLATFORM
CreateVirtualScreen(const std::string & name,uint32_t width,uint32_t height,sptr<Surface> surface,ScreenId mirrorId,int flags,std::vector<NodeId> whiteList)76 ScreenId RSInterfaces::CreateVirtualScreen(
77     const std::string &name,
78     uint32_t width,
79     uint32_t height,
80     sptr<Surface> surface,
81     ScreenId mirrorId,
82     int flags,
83     std::vector<NodeId> whiteList)
84 {
85     return renderServiceClient_->CreateVirtualScreen(name, width, height, surface, mirrorId, flags, whiteList);
86 }
87 
SetVirtualScreenBlackList(ScreenId id,std::vector<NodeId> & blackListVector)88 int32_t RSInterfaces::SetVirtualScreenBlackList(ScreenId id, std::vector<NodeId>& blackListVector)
89 {
90     return renderServiceClient_->SetVirtualScreenBlackList(id, blackListVector);
91 }
92 
SetVirtualScreenTypeBlackList(ScreenId id,std::vector<NodeType> & typeBlackListVector)93 int32_t RSInterfaces::SetVirtualScreenTypeBlackList(ScreenId id, std::vector<NodeType>& typeBlackListVector)
94 {
95     return renderServiceClient_->SetVirtualScreenTypeBlackList(id, typeBlackListVector);
96 }
97 
AddVirtualScreenBlackList(ScreenId id,std::vector<NodeId> & blackListVector)98 int32_t RSInterfaces::AddVirtualScreenBlackList(ScreenId id, std::vector<NodeId>& blackListVector)
99 {
100     return renderServiceClient_->AddVirtualScreenBlackList(id, blackListVector);
101 }
102 
RemoveVirtualScreenBlackList(ScreenId id,std::vector<NodeId> & blackListVector)103 int32_t RSInterfaces::RemoveVirtualScreenBlackList(ScreenId id, std::vector<NodeId>& blackListVector)
104 {
105     return renderServiceClient_->RemoveVirtualScreenBlackList(id, blackListVector);
106 }
107 
SetVirtualScreenSecurityExemptionList(ScreenId id,const std::vector<NodeId> & securityExemptionList)108 int32_t RSInterfaces::SetVirtualScreenSecurityExemptionList(
109     ScreenId id,
110     const std::vector<NodeId>& securityExemptionList)
111 {
112     return renderServiceClient_->SetVirtualScreenSecurityExemptionList(id, securityExemptionList);
113 }
114 
SetScreenSecurityMask(ScreenId id,std::shared_ptr<Media::PixelMap> securityMask)115 int32_t RSInterfaces::SetScreenSecurityMask(ScreenId id, std::shared_ptr<Media::PixelMap> securityMask)
116 {
117     Media::ImageInfo imageInfo;
118     if (securityMask) {
119         securityMask->GetImageInfo(imageInfo);
120     }
121     if (securityMask && (imageInfo.size.width > SECURITYMASK_IMAGE_WIDTH_LIMIT ||
122         imageInfo.size.height > SECURITYMASK_IMAGE_HEIGHT_LIMIT)) {
123         ROSEN_LOGE("SetScreenSecurityMask failed, securityMask width: %{public}d, height: %{public}d is error",
124             imageInfo.size.width, imageInfo.size.height);
125         return RS_CONNECTION_ERROR;
126     }
127     return renderServiceClient_->SetScreenSecurityMask(id, std::move(securityMask));
128 }
129 
SetMirrorScreenVisibleRect(ScreenId id,const Rect & mainScreenRect,bool supportRotation)130 int32_t RSInterfaces::SetMirrorScreenVisibleRect(ScreenId id, const Rect& mainScreenRect, bool supportRotation)
131 {
132     return renderServiceClient_->SetMirrorScreenVisibleRect(id, mainScreenRect, supportRotation);
133 }
134 
SetCastScreenEnableSkipWindow(ScreenId id,bool enable)135 int32_t RSInterfaces::SetCastScreenEnableSkipWindow(ScreenId id, bool enable)
136 {
137     return renderServiceClient_->SetCastScreenEnableSkipWindow(id, enable);
138 }
139 
SetVirtualScreenSurface(ScreenId id,sptr<Surface> surface)140 int32_t RSInterfaces::SetVirtualScreenSurface(ScreenId id, sptr<Surface> surface)
141 {
142     return renderServiceClient_->SetVirtualScreenSurface(id, surface);
143 }
144 #endif
145 
RemoveVirtualScreen(ScreenId id)146 void RSInterfaces::RemoveVirtualScreen(ScreenId id)
147 {
148     renderServiceClient_->RemoveVirtualScreen(id);
149 }
150 
SetWatermark(const std::string & name,std::shared_ptr<Media::PixelMap> watermark)151 bool RSInterfaces::SetWatermark(const std::string& name, std::shared_ptr<Media::PixelMap> watermark)
152 {
153 #ifdef ROSEN_OHOS
154     if (renderServiceClient_ == nullptr) {
155         return false;
156     }
157     if (name.length() > WATERMARK_NAME_LENGTH_LIMIT || name.empty()) {
158         ROSEN_LOGE("SetWatermark failed, name[%{public}s] is error.", name.c_str());
159         return false;
160     }
161     if (watermark && (watermark->IsAstc() || watermark->GetCapacity() > WATERMARK_PIXELMAP_SIZE_LIMIT)) {
162         ROSEN_LOGE("SetWatermark failed, watermark[%{public}d, %{public}d] is error",
163             watermark->IsAstc(), watermark->GetCapacity());
164         return false;
165     }
166     return renderServiceClient_->SetWatermark(name, watermark);
167 #else
168     return false;
169 #endif
170 }
171 
172 #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR
SetPointerColorInversionConfig(float darkBuffer,float brightBuffer,int64_t interval,int32_t rangeSize)173 int32_t RSInterfaces::SetPointerColorInversionConfig(float darkBuffer, float brightBuffer,
174     int64_t interval, int32_t rangeSize)
175 {
176     if (renderServiceClient_ == nullptr) {
177         return StatusCode::RENDER_SERVICE_NULL;
178     }
179     return renderServiceClient_->SetPointerColorInversionConfig(darkBuffer, brightBuffer, interval, rangeSize);
180 }
181 
SetPointerColorInversionEnabled(bool enable)182 int32_t RSInterfaces::SetPointerColorInversionEnabled(bool enable)
183 {
184     if (renderServiceClient_ == nullptr) {
185         return StatusCode::RENDER_SERVICE_NULL;
186     }
187     return renderServiceClient_->SetPointerColorInversionEnabled(enable);
188 }
189 
RegisterPointerLuminanceChangeCallback(const PointerLuminanceChangeCallback & callback)190 int32_t RSInterfaces::RegisterPointerLuminanceChangeCallback(const PointerLuminanceChangeCallback &callback)
191 {
192     if (renderServiceClient_ == nullptr) {
193         return StatusCode::RENDER_SERVICE_NULL;
194     }
195     return renderServiceClient_->RegisterPointerLuminanceChangeCallback(callback);
196 }
197 
UnRegisterPointerLuminanceChangeCallback()198 int32_t RSInterfaces::UnRegisterPointerLuminanceChangeCallback()
199 {
200     if (renderServiceClient_ == nullptr) {
201         return StatusCode::RENDER_SERVICE_NULL;
202     }
203     return renderServiceClient_->UnRegisterPointerLuminanceChangeCallback();
204 }
205 #endif
206 
SetScreenChangeCallback(const ScreenChangeCallback & callback)207 int32_t RSInterfaces::SetScreenChangeCallback(const ScreenChangeCallback &callback)
208 {
209     ROSEN_LOGI("RSInterfaces::%{public}s", __func__);
210     return renderServiceClient_->SetScreenChangeCallback(callback);
211 }
212 
SetScreenSwitchingNotifyCallback(const ScreenSwitchingNotifyCallback & callback)213 int32_t RSInterfaces::SetScreenSwitchingNotifyCallback(const ScreenSwitchingNotifyCallback &callback)
214 {
215     ROSEN_LOGI("RSInterfaces::%{public}s", __func__);
216     return renderServiceClient_->SetScreenSwitchingNotifyCallback(callback);
217 }
218 
GetPixelMapByProcessId(std::vector<PixelMapInfo> & pixelMapInfoVector,pid_t pid)219 int32_t RSInterfaces::GetPixelMapByProcessId(std::vector<PixelMapInfo>& pixelMapInfoVector, pid_t pid)
220 {
221     return renderServiceClient_->GetPixelMapByProcessId(pixelMapInfoVector, pid);
222 }
223 
TakeSurfaceCapture(std::shared_ptr<RSSurfaceNode> node,std::shared_ptr<SurfaceCaptureCallback> callback,RSSurfaceCaptureConfig captureConfig)224 bool RSInterfaces::TakeSurfaceCapture(std::shared_ptr<RSSurfaceNode> node,
225     std::shared_ptr<SurfaceCaptureCallback> callback, RSSurfaceCaptureConfig captureConfig)
226 {
227     if (!node) {
228         ROSEN_LOGE("%{public}s node is nullptr", __func__);
229         return false;
230     }
231     return renderServiceClient_->TakeSurfaceCapture(node->GetId(), callback, captureConfig);
232 }
233 
TakeSurfaceCaptureWithBlur(std::shared_ptr<RSSurfaceNode> node,std::shared_ptr<SurfaceCaptureCallback> callback,RSSurfaceCaptureConfig captureConfig,float blurRadius)234 bool RSInterfaces::TakeSurfaceCaptureWithBlur(std::shared_ptr<RSSurfaceNode> node,
235     std::shared_ptr<SurfaceCaptureCallback> callback, RSSurfaceCaptureConfig captureConfig, float blurRadius)
236 {
237     if (blurRadius < 1) {
238         ROSEN_LOGW("%{public}s no blur effect", __func__);
239         return TakeSurfaceCapture(node, callback, captureConfig);
240     }
241     if (!node) {
242         ROSEN_LOGE("%{public}s node is nullptr", __func__);
243         return false;
244     }
245     RSSurfaceCaptureBlurParam blurParam;
246     blurParam.isNeedBlur = true;
247     blurParam.blurRadius = blurRadius;
248     return renderServiceClient_->TakeSurfaceCapture(node->GetId(), callback, captureConfig, blurParam);
249 }
250 
TakeSelfSurfaceCapture(std::shared_ptr<RSSurfaceNode> node,std::shared_ptr<SurfaceCaptureCallback> callback,RSSurfaceCaptureConfig captureConfig)251 bool RSInterfaces::TakeSelfSurfaceCapture(std::shared_ptr<RSSurfaceNode> node,
252     std::shared_ptr<SurfaceCaptureCallback> callback, RSSurfaceCaptureConfig captureConfig)
253 {
254     if (!node) {
255         ROSEN_LOGE("%{public}s node is nullptr", __func__);
256         return false;
257     }
258     return renderServiceClient_->TakeSelfSurfaceCapture(node->GetId(), callback, captureConfig);
259 }
260 
SetWindowFreezeImmediately(std::shared_ptr<RSSurfaceNode> node,bool isFreeze,std::shared_ptr<SurfaceCaptureCallback> callback,RSSurfaceCaptureConfig captureConfig,float blurRadius)261 bool RSInterfaces::SetWindowFreezeImmediately(std::shared_ptr<RSSurfaceNode> node, bool isFreeze,
262     std::shared_ptr<SurfaceCaptureCallback> callback, RSSurfaceCaptureConfig captureConfig, float blurRadius)
263 {
264     if (!node) {
265         ROSEN_LOGE("%{public}s node is nullptr", __func__);
266         return false;
267     }
268     RSSurfaceCaptureBlurParam blurParam;
269     if (ROSEN_GE(blurRadius, 1.f)) {
270         blurParam.isNeedBlur = true;
271         blurParam.blurRadius = blurRadius;
272     }
273     return renderServiceClient_->SetWindowFreezeImmediately(
274         node->GetId(), isFreeze, callback, captureConfig, blurParam);
275 }
276 
TaskSurfaceCaptureWithAllWindows(std::shared_ptr<RSDisplayNode> node,std::shared_ptr<SurfaceCaptureCallback> callback,RSSurfaceCaptureConfig captureConfig,bool checkDrmAndSurfaceLock)277 bool RSInterfaces::TaskSurfaceCaptureWithAllWindows(std::shared_ptr<RSDisplayNode> node,
278     std::shared_ptr<SurfaceCaptureCallback> callback, RSSurfaceCaptureConfig captureConfig,
279     bool checkDrmAndSurfaceLock)
280 {
281     if (!node) {
282         ROSEN_LOGE("%{public}s node is nullptr", __func__);
283         return false;
284     }
285     return renderServiceClient_->TaskSurfaceCaptureWithAllWindows(
286         node->GetId(), callback, captureConfig, checkDrmAndSurfaceLock);
287 }
288 
FreezeScreen(std::shared_ptr<RSDisplayNode> node,bool isFreeze)289 bool RSInterfaces::FreezeScreen(std::shared_ptr<RSDisplayNode> node, bool isFreeze)
290 {
291     if (!node) {
292         ROSEN_LOGE("%{public}s node is nullptr", __func__);
293         return false;
294     }
295     return renderServiceClient_->FreezeScreen(node->GetId(), isFreeze);
296 }
297 
SetHwcNodeBounds(int64_t rsNodeId,float positionX,float positionY,float positionZ,float positionW)298 bool RSInterfaces::SetHwcNodeBounds(int64_t rsNodeId, float positionX, float positionY,
299     float positionZ, float positionW)
300 {
301     return renderServiceClient_->SetHwcNodeBounds(rsNodeId, positionX, positionY, positionZ, positionW);
302 }
303 
TakeSurfaceCapture(std::shared_ptr<RSDisplayNode> node,std::shared_ptr<SurfaceCaptureCallback> callback,RSSurfaceCaptureConfig captureConfig)304 bool RSInterfaces::TakeSurfaceCapture(std::shared_ptr<RSDisplayNode> node,
305     std::shared_ptr<SurfaceCaptureCallback> callback, RSSurfaceCaptureConfig captureConfig)
306 {
307     if (!node) {
308         ROSEN_LOGE("%{public}s node is nullptr", __func__);
309         return false;
310     }
311     return renderServiceClient_->TakeSurfaceCapture(node->GetId(), callback, captureConfig);
312 }
313 
TakeSurfaceCapture(NodeId id,std::shared_ptr<SurfaceCaptureCallback> callback,RSSurfaceCaptureConfig captureConfig)314 bool RSInterfaces::TakeSurfaceCapture(NodeId id,
315     std::shared_ptr<SurfaceCaptureCallback> callback, RSSurfaceCaptureConfig captureConfig)
316 {
317     return renderServiceClient_->TakeSurfaceCapture(id, callback, captureConfig);
318 }
319 
320 #ifndef ROSEN_ARKUI_X
SetScreenActiveMode(ScreenId id,uint32_t modeId)321 void RSInterfaces::SetScreenActiveMode(ScreenId id, uint32_t modeId)
322 {
323     renderServiceClient_->SetScreenActiveMode(id, modeId);
324 }
325 #endif // !ROSEN_ARKUI_X
SetScreenRefreshRate(ScreenId id,int32_t sceneId,int32_t rate)326 void RSInterfaces::SetScreenRefreshRate(ScreenId id, int32_t sceneId, int32_t rate)
327 {
328     renderServiceClient_->SetScreenRefreshRate(id, sceneId, rate);
329 }
330 
SetRefreshRateMode(int32_t refreshRateMode)331 void RSInterfaces::SetRefreshRateMode(int32_t refreshRateMode)
332 {
333     renderServiceClient_->SetRefreshRateMode(refreshRateMode);
334 }
335 
SyncFrameRateRange(FrameRateLinkerId id,const FrameRateRange & range,int32_t animatorExpectedFrameRate)336 void RSInterfaces::SyncFrameRateRange(FrameRateLinkerId id, const FrameRateRange& range,
337     int32_t animatorExpectedFrameRate)
338 {
339     renderServiceClient_->SyncFrameRateRange(id, range, animatorExpectedFrameRate);
340 }
341 
GetScreenCurrentRefreshRate(ScreenId id)342 uint32_t RSInterfaces::GetScreenCurrentRefreshRate(ScreenId id)
343 {
344     return renderServiceClient_->GetScreenCurrentRefreshRate(id);
345 }
346 
GetCurrentRefreshRateMode()347 int32_t RSInterfaces::GetCurrentRefreshRateMode()
348 {
349     return renderServiceClient_->GetCurrentRefreshRateMode();
350 }
351 
GetScreenSupportedRefreshRates(ScreenId id)352 std::vector<int32_t> RSInterfaces::GetScreenSupportedRefreshRates(ScreenId id)
353 {
354     return renderServiceClient_->GetScreenSupportedRefreshRates(id);
355 }
356 
GetShowRefreshRateEnabled()357 bool RSInterfaces::GetShowRefreshRateEnabled()
358 {
359     return renderServiceClient_->GetShowRefreshRateEnabled();
360 }
361 
SetShowRefreshRateEnabled(bool enabled,int32_t type)362 void RSInterfaces::SetShowRefreshRateEnabled(bool enabled, int32_t type)
363 {
364     return renderServiceClient_->SetShowRefreshRateEnabled(enabled, type);
365 }
366 
GetRealtimeRefreshRate(ScreenId id)367 uint32_t RSInterfaces::GetRealtimeRefreshRate(ScreenId id)
368 {
369     RS_LOGD("RSInterfaces::GetRealtimeRefreshRate: id[%{public}" PRIu64"]", id);
370     return renderServiceClient_->GetRealtimeRefreshRate(id);
371 }
372 
GetRefreshInfo(pid_t pid)373 std::string RSInterfaces::GetRefreshInfo(pid_t pid)
374 {
375     return renderServiceClient_->GetRefreshInfo(pid);
376 }
377 
GetRefreshInfoToSP(NodeId id)378 std::string RSInterfaces::GetRefreshInfoToSP(NodeId id)
379 {
380     return renderServiceClient_->GetRefreshInfoToSP(id);
381 }
382 
TakeSurfaceCaptureForUI(std::shared_ptr<RSNode> node,std::shared_ptr<SurfaceCaptureCallback> callback,float scaleX,float scaleY,bool isSync,const Drawing::Rect & specifiedAreaRect)383 bool RSInterfaces::TakeSurfaceCaptureForUI(std::shared_ptr<RSNode> node,
384     std::shared_ptr<SurfaceCaptureCallback> callback, float scaleX, float scaleY,
385     bool isSync, const Drawing::Rect& specifiedAreaRect)
386 {
387     if (!node) {
388         ROSEN_LOGW("RSInterfaces::TakeSurfaceCaptureForUI rsnode is nullpter return");
389         return false;
390     }
391     // textureExportNode process cmds in renderThread of application, isSync is unnecessary.
392     if (node->IsTextureExportNode()) {
393         ROSEN_LOGD("RSInterfaces::TakeSurfaceCaptureForUI rsNode [%{public}" PRIu64
394             "] is textureExportNode, set isSync false", node->GetId());
395         isSync = false;
396     }
397     if (!((node->GetType() == RSUINodeType::ROOT_NODE) ||
398           (node->GetType() == RSUINodeType::CANVAS_NODE) ||
399           (node->GetType() == RSUINodeType::CANVAS_DRAWING_NODE) ||
400           (node->GetType() == RSUINodeType::SURFACE_NODE))) {
401         ROSEN_LOGE("RSInterfaces::TakeSurfaceCaptureForUI unsupported node type return");
402         return false;
403     }
404     RSSurfaceCaptureConfig captureConfig;
405     captureConfig.scaleX = scaleX;
406     captureConfig.scaleY = scaleY;
407     captureConfig.captureType = SurfaceCaptureType::UICAPTURE;
408     captureConfig.isSync = isSync;
409     captureConfig.specifiedAreaRect = specifiedAreaRect;
410     if (RSSystemProperties::GetUniRenderEnabled()) {
411         if (isSync) {
412             node->SetTakeSurfaceForUIFlag();
413         }
414         return renderServiceClient_->TakeSurfaceCapture(node->GetId(), callback, captureConfig, {}, specifiedAreaRect);
415     } else {
416         return TakeSurfaceCaptureForUIWithoutUni(node->GetId(), callback, scaleX, scaleY);
417     }
418 }
419 
420 std::vector<std::pair<NodeId, std::shared_ptr<Media::PixelMap>>>
TakeSurfaceCaptureSoloNodeList(std::shared_ptr<RSNode> node)421     RSInterfaces::TakeSurfaceCaptureSoloNodeList(std::shared_ptr<RSNode> node)
422 {
423     std::vector<std::pair<NodeId, std::shared_ptr<Media::PixelMap>>> pixelMapIdPairVector;
424     if (!node) {
425         ROSEN_LOGW("RSInterfaces::TakeSurfaceCaptureSoloNodeList rsnode is nullpter return");
426         return pixelMapIdPairVector;
427     }
428     if (!((node->GetType() == RSUINodeType::ROOT_NODE) ||
429           (node->GetType() == RSUINodeType::CANVAS_NODE) ||
430           (node->GetType() == RSUINodeType::CANVAS_DRAWING_NODE) ||
431           (node->GetType() == RSUINodeType::SURFACE_NODE))) {
432         ROSEN_LOGE("RSInterfaces::TakeSurfaceCaptureSoloNodeList unsupported node type return");
433         return pixelMapIdPairVector;
434     }
435     RSSurfaceCaptureConfig captureConfig;
436     captureConfig.isSoloNodeUiCapture = true;
437     if (RSSystemProperties::GetUniRenderEnabled()) {
438         pixelMapIdPairVector = renderServiceClient_->TakeSurfaceCaptureSoloNode(node->GetId(), captureConfig);
439         return pixelMapIdPairVector;
440     } else {
441         ROSEN_LOGE("RSInterfaces::TakeSurfaceCaptureSoloNodeList UniRender is not enabled return");
442         return pixelMapIdPairVector;
443     }
444 }
445 
TakeUICaptureInRange(std::shared_ptr<RSNode> beginNode,std::shared_ptr<RSNode> endNode,bool useBeginNodeSize,std::shared_ptr<SurfaceCaptureCallback> callback,float scaleX,float scaleY,bool isSync)446 bool RSInterfaces::TakeUICaptureInRange(std::shared_ptr<RSNode> beginNode, std::shared_ptr<RSNode> endNode,
447     bool useBeginNodeSize, std::shared_ptr<SurfaceCaptureCallback> callback, float scaleX, float scaleY, bool isSync)
448 {
449     if (!beginNode) {
450         ROSEN_LOGW("RSInterfaces::TakeUICaptureInRange beginNode is nullpter return");
451         return false;
452     }
453     if (!endNode) {
454         return TakeSurfaceCaptureForUI(beginNode, callback, scaleX, scaleY, isSync);
455     }
456     // textureExportNode process cmds in renderThread of application, isSync is unnecessary.
457     if (beginNode->IsTextureExportNode()) {
458         ROSEN_LOGD("RSInterfaces::TakeUICaptureInRange beginNode [%{public}" PRIu64
459             "] is textureExportNode, set isSync false", beginNode->GetId());
460         isSync = false;
461     }
462     if (!((beginNode->GetType() == RSUINodeType::ROOT_NODE) ||
463           (beginNode->GetType() == RSUINodeType::CANVAS_NODE) ||
464           (beginNode->GetType() == RSUINodeType::CANVAS_DRAWING_NODE) ||
465           (beginNode->GetType() == RSUINodeType::SURFACE_NODE))) {
466         ROSEN_LOGE("RSInterfaces::TakeUICaptureInRange unsupported node type return");
467         return false;
468     }
469     RSSurfaceCaptureConfig captureConfig;
470     captureConfig.scaleX = scaleX;
471     captureConfig.scaleY = scaleY;
472     captureConfig.captureType = SurfaceCaptureType::UICAPTURE;
473     captureConfig.isSync = isSync;
474     captureConfig.uiCaptureInRangeParam.endNodeId = endNode->GetId();
475     captureConfig.uiCaptureInRangeParam.useBeginNodeSize = useBeginNodeSize;
476     if (RSSystemProperties::GetUniRenderEnabled()) {
477         if (isSync) {
478             beginNode->SetTakeSurfaceForUIFlag();
479         }
480         return renderServiceClient_->TakeUICaptureInRange(beginNode->GetId(), callback, captureConfig);
481     } else {
482         return TakeSurfaceCaptureForUIWithoutUni(beginNode->GetId(), callback, scaleX, scaleY);
483     }
484 }
485 
RegisterTypeface(std::shared_ptr<Drawing::Typeface> & typeface)486 bool RSInterfaces::RegisterTypeface(std::shared_ptr<Drawing::Typeface>& typeface)
487 {
488     static std::function<std::shared_ptr<Drawing::Typeface> (uint64_t)> customTypefaceQueryfunc =
489         [](uint64_t globalUniqueId) -> std::shared_ptr<Drawing::Typeface> {
490         return RSTypefaceCache::Instance().GetDrawingTypefaceCache(globalUniqueId);
491     };
492 
493     static std::once_flag onceFlag;
494     std::call_once(onceFlag, []() {
495         Drawing::DrawOpItem::SetTypefaceQueryCallBack(customTypefaceQueryfunc);
496     });
497 
498     if (RSSystemProperties::GetUniRenderEnabled()) {
499         bool result = renderServiceClient_->RegisterTypeface(typeface);
500         if (result) {
501             RS_LOGI("RSInterfaces:Succeed in reg typeface, family name:%{public}s, uniqueid:%{public}u",
502                 typeface->GetFamilyName().c_str(), typeface->GetUniqueID());
503             uint64_t globalUniqueId = RSTypefaceCache::GenGlobalUniqueId(typeface->GetUniqueID());
504             RSTypefaceCache::Instance().CacheDrawingTypeface(globalUniqueId, typeface);
505         } else {
506             RS_LOGE("RSInterfaces:Failed to reg typeface, family name:%{public}s, uniqueid:%{public}u",
507                 typeface->GetFamilyName().c_str(), typeface->GetUniqueID());
508         }
509         return result;
510     }
511 
512     RS_LOGI("RSInterfaces:Succeed in reg typeface, family name:%{public}s, uniqueid:%{public}u",
513         typeface->GetFamilyName().c_str(), typeface->GetUniqueID());
514     uint64_t globalUniqueId = RSTypefaceCache::GenGlobalUniqueId(typeface->GetUniqueID());
515     RSTypefaceCache::Instance().CacheDrawingTypeface(globalUniqueId, typeface);
516     return true;
517 }
518 
UnRegisterTypeface(std::shared_ptr<Drawing::Typeface> & typeface)519 bool RSInterfaces::UnRegisterTypeface(std::shared_ptr<Drawing::Typeface>& typeface)
520 {
521     RS_LOGW("RSInterfaces:Unreg typeface: family name:%{public}s, uniqueid:%{public}u",
522         typeface->GetFamilyName().c_str(), typeface->GetUniqueID());
523     if (RSSystemProperties::GetUniRenderEnabled()) {
524         bool result = renderServiceClient_->UnRegisterTypeface(typeface);
525         if (result) {
526             uint64_t globalUniqueId = RSTypefaceCache::GenGlobalUniqueId(typeface->GetUniqueID());
527             RSTypefaceCache::Instance().RemoveDrawingTypefaceByGlobalUniqueId(globalUniqueId);
528         }
529         return result;
530     }
531 
532     uint64_t globalUniqueId = RSTypefaceCache::GenGlobalUniqueId(typeface->GetUniqueID());
533     RSTypefaceCache::Instance().AddDelayDestroyQueue(globalUniqueId);
534     return true;
535 }
536 
SetGlobalDarkColorMode(bool isDark)537 bool RSInterfaces::SetGlobalDarkColorMode(bool isDark)
538 {
539     return renderServiceClient_->SetGlobalDarkColorMode(isDark);
540 }
541 
542 #ifndef ROSEN_ARKUI_X
SetPhysicalScreenResolution(ScreenId id,uint32_t width,uint32_t height)543 int32_t RSInterfaces::SetPhysicalScreenResolution(ScreenId id, uint32_t width, uint32_t height)
544 {
545     RS_LOGI("RSInterfaces:%{public}s, screenId:%{public}" PRIu64 ", width:%{public}u, height:%{public}u", __func__, id,
546             width, height);
547     return renderServiceClient_->SetPhysicalScreenResolution(id, width, height);
548 }
549 
SetVirtualScreenResolution(ScreenId id,uint32_t width,uint32_t height)550 int32_t RSInterfaces::SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height)
551 {
552     return renderServiceClient_->SetVirtualScreenResolution(id, width, height);
553 }
554 #endif // !ROSEN_ARKUI_X
555 
SetVirtualMirrorScreenCanvasRotation(ScreenId id,bool canvasRotation)556 bool RSInterfaces::SetVirtualMirrorScreenCanvasRotation(ScreenId id, bool canvasRotation)
557 {
558     return renderServiceClient_->SetVirtualMirrorScreenCanvasRotation(id, canvasRotation);
559 }
560 
SetVirtualScreenAutoRotation(ScreenId id,bool isAutoRotation)561 int32_t RSInterfaces::SetVirtualScreenAutoRotation(ScreenId id, bool isAutoRotation)
562 {
563     return renderServiceClient_->SetVirtualScreenAutoRotation(id, isAutoRotation);
564 }
565 
SetVirtualMirrorScreenScaleMode(ScreenId id,ScreenScaleMode scaleMode)566 bool RSInterfaces::SetVirtualMirrorScreenScaleMode(ScreenId id, ScreenScaleMode scaleMode)
567 {
568     return renderServiceClient_->SetVirtualMirrorScreenScaleMode(id, scaleMode);
569 }
570 #ifndef ROSEN_ARKUI_X
GetVirtualScreenResolution(ScreenId id)571 RSVirtualScreenResolution RSInterfaces::GetVirtualScreenResolution(ScreenId id)
572 {
573     return renderServiceClient_->GetVirtualScreenResolution(id);
574 }
575 
MarkPowerOffNeedProcessOneFrame()576 void RSInterfaces::MarkPowerOffNeedProcessOneFrame()
577 {
578     RS_LOGD("[UL_POWER]RSInterfaces::MarkPowerOffNeedProcessOneFrame.");
579     renderServiceClient_->MarkPowerOffNeedProcessOneFrame();
580 }
581 
RepaintEverything()582 void RSInterfaces::RepaintEverything()
583 {
584     renderServiceClient_->RepaintEverything();
585 }
586 
ForceRefreshOneFrameWithNextVSync()587 void RSInterfaces::ForceRefreshOneFrameWithNextVSync()
588 {
589     renderServiceClient_->ForceRefreshOneFrameWithNextVSync();
590 }
591 
DisablePowerOffRenderControl(ScreenId id)592 void RSInterfaces::DisablePowerOffRenderControl(ScreenId id)
593 {
594     RS_LOGD("RSInterfaces::DisablePowerOffRenderControl.");
595     renderServiceClient_->DisablePowerOffRenderControl(id);
596 }
597 
SetScreenPowerStatus(ScreenId id,ScreenPowerStatus status)598 void RSInterfaces::SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status)
599 {
600     RS_LOGI("[UL_POWER]RSInterfaces::SetScreenPowerStatus: ScreenId: %{public}" PRIu64
601             ", ScreenPowerStatus: %{public}u",
602         id, static_cast<uint32_t>(status));
603     renderServiceClient_->SetScreenPowerStatus(id, status);
604 }
605 
606 #endif // !ROSEN_ARKUI_X
TakeSurfaceCaptureForUIWithoutUni(NodeId id,std::shared_ptr<SurfaceCaptureCallback> callback,float scaleX,float scaleY)607 bool RSInterfaces::TakeSurfaceCaptureForUIWithoutUni(NodeId id,
608     std::shared_ptr<SurfaceCaptureCallback> callback, float scaleX, float scaleY)
609 {
610     std::function<void()> offscreenRenderTask = [scaleX, scaleY, callback, id, this]() -> void {
611         ROSEN_LOGD(
612             "RSInterfaces::TakeSurfaceCaptureForUIWithoutUni callback->OnOffscreenRender nodeId:"
613             "[%{public}" PRIu64 "]", id);
614         ROSEN_TRACE_BEGIN(HITRACE_TAG_GRAPHIC_AGP, "RSRenderThread::TakeSurfaceCaptureForUIWithoutUni");
615         std::shared_ptr<RSDividedUICapture> rsDividedUICapture =
616             std::make_shared<RSDividedUICapture>(id, scaleX, scaleY);
617         std::shared_ptr<Media::PixelMap> pixelmap = rsDividedUICapture->TakeLocalCapture();
618         ROSEN_TRACE_END(HITRACE_TAG_GRAPHIC_AGP);
619         callback->OnSurfaceCapture(pixelmap);
620     };
621     RSOffscreenRenderThread::Instance().PostTask(offscreenRenderTask);
622     return true;
623 }
624 
625 #ifndef ROSEN_ARKUI_X
GetScreenActiveMode(ScreenId id)626 RSScreenModeInfo RSInterfaces::GetScreenActiveMode(ScreenId id)
627 {
628     return renderServiceClient_->GetScreenActiveMode(id);
629 }
630 
GetScreenSupportedModes(ScreenId id)631 std::vector<RSScreenModeInfo> RSInterfaces::GetScreenSupportedModes(ScreenId id)
632 {
633     return renderServiceClient_->GetScreenSupportedModes(id);
634 }
635 
GetScreenCapability(ScreenId id)636 RSScreenCapability RSInterfaces::GetScreenCapability(ScreenId id)
637 {
638     return renderServiceClient_->GetScreenCapability(id);
639 }
640 
GetScreenPowerStatus(ScreenId id)641 ScreenPowerStatus RSInterfaces::GetScreenPowerStatus(ScreenId id)
642 {
643     return renderServiceClient_->GetScreenPowerStatus(id);
644 }
645 
GetScreenData(ScreenId id)646 RSScreenData RSInterfaces::GetScreenData(ScreenId id)
647 {
648     return renderServiceClient_->GetScreenData(id);
649 }
650 #endif // !ROSEN_ARKUI_X
GetScreenBacklight(ScreenId id)651 int32_t RSInterfaces::GetScreenBacklight(ScreenId id)
652 {
653     return renderServiceClient_->GetScreenBacklight(id);
654 }
655 
SetScreenBacklight(ScreenId id,uint32_t level)656 void RSInterfaces::SetScreenBacklight(ScreenId id, uint32_t level)
657 {
658     RS_LOGD("RSInterfaces::SetScreenBacklight: ScreenId: %{public}" PRIu64 ", level: %{public}u", id, level);
659     renderServiceClient_->SetScreenBacklight(id, level);
660 }
661 
GetScreenSupportedColorGamuts(ScreenId id,std::vector<ScreenColorGamut> & mode)662 int32_t RSInterfaces::GetScreenSupportedColorGamuts(ScreenId id, std::vector<ScreenColorGamut>& mode)
663 {
664     return renderServiceClient_->GetScreenSupportedColorGamuts(id, mode);
665 }
666 
GetScreenSupportedMetaDataKeys(ScreenId id,std::vector<ScreenHDRMetadataKey> & keys)667 int32_t RSInterfaces::GetScreenSupportedMetaDataKeys(ScreenId id, std::vector<ScreenHDRMetadataKey>& keys)
668 {
669     return renderServiceClient_->GetScreenSupportedMetaDataKeys(id, keys);
670 }
671 
GetScreenColorGamut(ScreenId id,ScreenColorGamut & mode)672 int32_t RSInterfaces::GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode)
673 {
674     return renderServiceClient_->GetScreenColorGamut(id, mode);
675 }
676 
SetScreenColorGamut(ScreenId id,int32_t modeIdx)677 int32_t RSInterfaces::SetScreenColorGamut(ScreenId id, int32_t modeIdx)
678 {
679     return renderServiceClient_->SetScreenColorGamut(id, modeIdx);
680 }
681 
SetScreenGamutMap(ScreenId id,ScreenGamutMap mode)682 int32_t RSInterfaces::SetScreenGamutMap(ScreenId id, ScreenGamutMap mode)
683 {
684     return renderServiceClient_->SetScreenGamutMap(id, mode);
685 }
686 
SetScreenCorrection(ScreenId id,ScreenRotation screenRotation)687 int32_t RSInterfaces::SetScreenCorrection(ScreenId id, ScreenRotation screenRotation)
688 {
689     return renderServiceClient_->SetScreenCorrection(id, screenRotation);
690 }
691 
GetScreenGamutMap(ScreenId id,ScreenGamutMap & mode)692 int32_t RSInterfaces::GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode)
693 {
694     return renderServiceClient_->GetScreenGamutMap(id, mode);
695 }
696 
CreateVSyncReceiver(const std::string & name,const std::shared_ptr<OHOS::AppExecFwk::EventHandler> & looper)697 std::shared_ptr<VSyncReceiver> RSInterfaces::CreateVSyncReceiver(
698     const std::string& name,
699     const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper)
700 {
701     return renderServiceClient_->CreateVSyncReceiver(name, looper);
702 }
703 
CreateVSyncReceiver(const std::string & name,uint64_t id,const std::shared_ptr<OHOS::AppExecFwk::EventHandler> & looper,NodeId windowNodeId,bool fromXcomponent)704 std::shared_ptr<VSyncReceiver> RSInterfaces::CreateVSyncReceiver(
705     const std::string& name,
706     uint64_t id,
707     const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper,
708     NodeId windowNodeId,
709     bool fromXcomponent)
710 {
711     return renderServiceClient_->CreateVSyncReceiver(name, looper, id, windowNodeId, fromXcomponent);
712 }
713 
CreatePixelMapFromSurfaceId(uint64_t surfaceId,const Rect & srcRect)714 std::shared_ptr<Media::PixelMap> RSInterfaces::CreatePixelMapFromSurfaceId(uint64_t surfaceId, const Rect &srcRect)
715 {
716     return renderServiceClient_->CreatePixelMapFromSurfaceId(surfaceId, srcRect);
717 }
718 
GetScreenHDRCapability(ScreenId id,RSScreenHDRCapability & screenHdrCapability)719 int32_t RSInterfaces::GetScreenHDRCapability(ScreenId id, RSScreenHDRCapability& screenHdrCapability)
720 {
721     return renderServiceClient_->GetScreenHDRCapability(id, screenHdrCapability);
722 }
723 
GetPixelFormat(ScreenId id,GraphicPixelFormat & pixelFormat)724 int32_t RSInterfaces::GetPixelFormat(ScreenId id, GraphicPixelFormat& pixelFormat)
725 {
726     return renderServiceClient_->GetPixelFormat(id, pixelFormat);
727 }
728 
SetPixelFormat(ScreenId id,GraphicPixelFormat pixelFormat)729 int32_t RSInterfaces::SetPixelFormat(ScreenId id, GraphicPixelFormat pixelFormat)
730 {
731     return renderServiceClient_->SetPixelFormat(id, pixelFormat);
732 }
733 
GetScreenSupportedHDRFormats(ScreenId id,std::vector<ScreenHDRFormat> & hdrFormats)734 int32_t RSInterfaces::GetScreenSupportedHDRFormats(ScreenId id, std::vector<ScreenHDRFormat>& hdrFormats)
735 {
736     return renderServiceClient_->GetScreenSupportedHDRFormats(id, hdrFormats);
737 }
738 
GetScreenHDRFormat(ScreenId id,ScreenHDRFormat & hdrFormat)739 int32_t RSInterfaces::GetScreenHDRFormat(ScreenId id, ScreenHDRFormat& hdrFormat)
740 {
741     return renderServiceClient_->GetScreenHDRFormat(id, hdrFormat);
742 }
743 
GetScreenHDRStatus(ScreenId id,HdrStatus & hdrStatus)744 int32_t RSInterfaces::GetScreenHDRStatus(ScreenId id, HdrStatus& hdrStatus)
745 {
746     return renderServiceClient_->GetScreenHDRStatus(id, hdrStatus);
747 }
748 
SetScreenHDRFormat(ScreenId id,int32_t modeIdx)749 int32_t RSInterfaces::SetScreenHDRFormat(ScreenId id, int32_t modeIdx)
750 {
751     return renderServiceClient_->SetScreenHDRFormat(id, modeIdx);
752 }
753 
GetScreenSupportedColorSpaces(ScreenId id,std::vector<GraphicCM_ColorSpaceType> & colorSpaces)754 int32_t RSInterfaces::GetScreenSupportedColorSpaces(ScreenId id, std::vector<GraphicCM_ColorSpaceType>& colorSpaces)
755 {
756     return renderServiceClient_->GetScreenSupportedColorSpaces(id, colorSpaces);
757 }
758 
GetScreenColorSpace(ScreenId id,GraphicCM_ColorSpaceType & colorSpace)759 int32_t RSInterfaces::GetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType& colorSpace)
760 {
761     return renderServiceClient_->GetScreenColorSpace(id, colorSpace);
762 }
763 
SetScreenColorSpace(ScreenId id,GraphicCM_ColorSpaceType colorSpace)764 int32_t RSInterfaces::SetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType colorSpace)
765 {
766     return renderServiceClient_->SetScreenColorSpace(id, colorSpace);
767 }
768 
GetScreenType(ScreenId id,RSScreenType & screenType)769 int32_t RSInterfaces::GetScreenType(ScreenId id, RSScreenType& screenType)
770 {
771     return renderServiceClient_->GetScreenType(id, screenType);
772 }
773 
GetDisplayIdentificationData(ScreenId id,uint8_t & outPort,std::vector<uint8_t> & edidData)774 int32_t RSInterfaces::GetDisplayIdentificationData(ScreenId id, uint8_t& outPort, std::vector<uint8_t>& edidData)
775 {
776     return renderServiceClient_->GetDisplayIdentificationData(id, outPort, edidData);
777 }
778 
SetScreenSkipFrameInterval(ScreenId id,uint32_t skipFrameInterval)779 int32_t RSInterfaces::SetScreenSkipFrameInterval(ScreenId id, uint32_t skipFrameInterval)
780 {
781     return renderServiceClient_->SetScreenSkipFrameInterval(id, skipFrameInterval);
782 }
783 
SetScreenActiveRect(ScreenId id,const Rect & activeRect)784 uint32_t RSInterfaces::SetScreenActiveRect(ScreenId id, const Rect& activeRect)
785 {
786     return renderServiceClient_->SetScreenActiveRect(id, activeRect);
787 }
788 
SetScreenOffset(ScreenId id,int32_t offSetX,int32_t offSetY)789 void RSInterfaces::SetScreenOffset(ScreenId id, int32_t offSetX, int32_t offSetY)
790 {
791     return renderServiceClient_->SetScreenOffset(id, offSetX, offSetY);
792 }
793 
SetScreenFrameGravity(ScreenId id,int32_t gravity)794 void RSInterfaces::SetScreenFrameGravity(ScreenId id, int32_t gravity)
795 {
796     return renderServiceClient_->SetScreenFrameGravity(id, gravity);
797 }
798 
SetVirtualScreenRefreshRate(ScreenId id,uint32_t maxRefreshRate,uint32_t & actualRefreshRate)799 int32_t RSInterfaces::SetVirtualScreenRefreshRate(ScreenId id, uint32_t maxRefreshRate, uint32_t& actualRefreshRate)
800 {
801     return renderServiceClient_->SetVirtualScreenRefreshRate(id, maxRefreshRate, actualRefreshRate);
802 }
803 
SetSystemAnimatedScenes(SystemAnimatedScenes systemAnimatedScenes,bool isRegularAnimation)804 bool RSInterfaces::SetSystemAnimatedScenes(SystemAnimatedScenes systemAnimatedScenes, bool isRegularAnimation)
805 {
806     return renderServiceClient_->SetSystemAnimatedScenes(systemAnimatedScenes, isRegularAnimation);
807 }
808 
RegisterOcclusionChangeCallback(const OcclusionChangeCallback & callback)809 int32_t RSInterfaces::RegisterOcclusionChangeCallback(const OcclusionChangeCallback& callback)
810 {
811     return renderServiceClient_->RegisterOcclusionChangeCallback(callback);
812 }
813 
RegisterSurfaceOcclusionChangeCallback(NodeId id,const SurfaceOcclusionChangeCallback & callback,std::vector<float> & partitionPoints)814 int32_t RSInterfaces::RegisterSurfaceOcclusionChangeCallback(
815     NodeId id, const SurfaceOcclusionChangeCallback& callback, std::vector<float>& partitionPoints)
816 {
817     return renderServiceClient_->RegisterSurfaceOcclusionChangeCallback(id, callback, partitionPoints);
818 }
819 
UnRegisterSurfaceOcclusionChangeCallback(NodeId id)820 int32_t RSInterfaces::UnRegisterSurfaceOcclusionChangeCallback(NodeId id)
821 {
822     return renderServiceClient_->UnRegisterSurfaceOcclusionChangeCallback(id);
823 }
824 
RegisterHgmConfigChangeCallback(const HgmConfigChangeCallback & callback)825 int32_t RSInterfaces::RegisterHgmConfigChangeCallback(const HgmConfigChangeCallback& callback)
826 {
827     return renderServiceClient_->RegisterHgmConfigChangeCallback(callback);
828 }
829 
RegisterHgmRefreshRateModeChangeCallback(const HgmRefreshRateModeChangeCallback & callback)830 int32_t RSInterfaces::RegisterHgmRefreshRateModeChangeCallback(const HgmRefreshRateModeChangeCallback& callback)
831 {
832     return renderServiceClient_->RegisterHgmRefreshRateModeChangeCallback(callback);
833 }
834 
RegisterHgmRefreshRateUpdateCallback(const HgmRefreshRateUpdateCallback & callback)835 int32_t RSInterfaces::RegisterHgmRefreshRateUpdateCallback(const HgmRefreshRateUpdateCallback& callback)
836 {
837     return renderServiceClient_->RegisterHgmRefreshRateUpdateCallback(callback);
838 }
839 
UnRegisterHgmRefreshRateUpdateCallback()840 int32_t RSInterfaces::UnRegisterHgmRefreshRateUpdateCallback()
841 {
842     return renderServiceClient_->RegisterHgmRefreshRateUpdateCallback(nullptr);
843 }
844 
RegisterFirstFrameCommitCallback(const FirstFrameCommitCallback & callback)845 int32_t RSInterfaces::RegisterFirstFrameCommitCallback(const FirstFrameCommitCallback& callback)
846 {
847     return renderServiceClient_->RegisterFirstFrameCommitCallback(callback);
848 }
849 
UnRegisterFirstFrameCommitCallback()850 int32_t RSInterfaces::UnRegisterFirstFrameCommitCallback()
851 {
852     return renderServiceClient_->RegisterFirstFrameCommitCallback(nullptr);
853 }
854 
RegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid,const FrameRateLinkerExpectedFpsUpdateCallback & callback)855 int32_t RSInterfaces::RegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid,
856     const FrameRateLinkerExpectedFpsUpdateCallback& callback)
857 {
858     if (callback == nullptr) {
859         ROSEN_LOGE("RSInterfaces::RegisterFrameRateLinkerExpectedFpsUpdateCallback callback == nullptr.");
860         return INVALID_ARGUMENTS;
861     }
862     return renderServiceClient_->RegisterFrameRateLinkerExpectedFpsUpdateCallback(dstPid, callback);
863 }
864 
UnRegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid)865 int32_t RSInterfaces::UnRegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid)
866 {
867     return renderServiceClient_->RegisterFrameRateLinkerExpectedFpsUpdateCallback(dstPid, nullptr);
868 }
869 
SetAppWindowNum(uint32_t num)870 void RSInterfaces::SetAppWindowNum(uint32_t num)
871 {
872     renderServiceClient_->SetAppWindowNum(num);
873 }
874 
875 /**
876  * @brief Display safe Watermark
877  * @param watermarkImg, The image width and height are less than twice the screen size
878  * @param isShow, flag indicating whether to display the watermark identifier(true) or hide it(false)
879  */
ShowWatermark(const std::shared_ptr<Media::PixelMap> & watermarkImg,bool isShow)880 void RSInterfaces::ShowWatermark(const std::shared_ptr<Media::PixelMap> &watermarkImg, bool isShow)
881 {
882     if (watermarkImg == nullptr) {
883         ROSEN_LOGE("RSInterfaces::ShowWatermark watermarkImg is nullptr");
884     }
885     renderServiceClient_->ShowWatermark(watermarkImg, isShow);
886 }
887 
ResizeVirtualScreen(ScreenId id,uint32_t width,uint32_t height)888 int32_t RSInterfaces::ResizeVirtualScreen(ScreenId id, uint32_t width, uint32_t height)
889 {
890     return renderServiceClient_->ResizeVirtualScreen(id, width, height);
891 }
892 
893 #ifndef ROSEN_ARKUI_X
GetMemoryGraphic(int pid)894 MemoryGraphic RSInterfaces::GetMemoryGraphic(int pid)
895 {
896     return renderServiceClient_->GetMemoryGraphic(pid);
897 }
898 
GetMemoryGraphics()899 std::vector<MemoryGraphic> RSInterfaces::GetMemoryGraphics()
900 {
901     return renderServiceClient_->GetMemoryGraphics();
902 }
903 #endif // !ROSEN_ARKUI_X
GetTotalAppMemSize(float & cpuMemSize,float & gpuMemSize)904 bool RSInterfaces::GetTotalAppMemSize(float& cpuMemSize, float& gpuMemSize)
905 {
906     return renderServiceClient_->GetTotalAppMemSize(cpuMemSize, gpuMemSize);
907 }
908 
ReportJankStats()909 void RSInterfaces::ReportJankStats()
910 {
911     renderServiceClient_->ReportJankStats();
912 }
913 
ReportEventResponse(DataBaseRs info)914 void RSInterfaces::ReportEventResponse(DataBaseRs info)
915 {
916     renderServiceClient_->ReportEventResponse(info);
917 }
918 
ReportEventComplete(DataBaseRs info)919 void RSInterfaces::ReportEventComplete(DataBaseRs info)
920 {
921     renderServiceClient_->ReportEventComplete(info);
922 }
923 
ReportEventJankFrame(DataBaseRs info)924 void RSInterfaces::ReportEventJankFrame(DataBaseRs info)
925 {
926     renderServiceClient_->ReportEventJankFrame(info);
927 }
928 
ReportGameStateData(GameStateData info)929 void RSInterfaces::ReportGameStateData(GameStateData info)
930 {
931     renderServiceClient_->ReportGameStateData(info);
932 }
933 
ReportRsSceneJankStart(AppInfo info)934 void RSInterfaces::ReportRsSceneJankStart(AppInfo info)
935 {
936     renderServiceClient_->ReportRsSceneJankStart(info);
937 }
938 
ReportRsSceneJankEnd(AppInfo info)939 void RSInterfaces::ReportRsSceneJankEnd(AppInfo info)
940 {
941     renderServiceClient_->ReportRsSceneJankEnd(info);
942 }
943 
EnableCacheForRotation()944 void RSInterfaces::EnableCacheForRotation()
945 {
946     renderServiceClient_->SetCacheEnabledForRotation(true);
947 }
948 
NotifyLightFactorStatus(int32_t lightFactorStatus)949 void RSInterfaces::NotifyLightFactorStatus(int32_t lightFactorStatus)
950 {
951     renderServiceClient_->NotifyLightFactorStatus(lightFactorStatus);
952 }
953 
NotifyPackageEvent(uint32_t listSize,const std::vector<std::string> & packageList)954 void RSInterfaces::NotifyPackageEvent(uint32_t listSize, const std::vector<std::string>& packageList)
955 {
956     renderServiceClient_->NotifyPackageEvent(listSize, packageList);
957 }
958 
NotifyAppStrategyConfigChangeEvent(const std::string & pkgName,uint32_t listSize,const std::vector<std::pair<std::string,std::string>> & newConfig)959 void RSInterfaces::NotifyAppStrategyConfigChangeEvent(const std::string& pkgName, uint32_t listSize,
960     const std::vector<std::pair<std::string, std::string>>& newConfig)
961 {
962     renderServiceClient_->NotifyAppStrategyConfigChangeEvent(pkgName, listSize, newConfig);
963 }
964 
NotifyRefreshRateEvent(const EventInfo & eventInfo)965 void RSInterfaces::NotifyRefreshRateEvent(const EventInfo& eventInfo)
966 {
967     renderServiceClient_->NotifyRefreshRateEvent(eventInfo);
968 }
969 
SetWindowExpectedRefreshRate(const std::unordered_map<uint64_t,EventInfo> & eventInfos)970 void RSInterfaces::SetWindowExpectedRefreshRate(const std::unordered_map<uint64_t, EventInfo>& eventInfos)
971 {
972     renderServiceClient_->SetWindowExpectedRefreshRate(eventInfos);
973 }
974 
SetWindowExpectedRefreshRate(const std::unordered_map<std::string,EventInfo> & eventInfos)975 void RSInterfaces::SetWindowExpectedRefreshRate(const std::unordered_map<std::string, EventInfo>& eventInfos)
976 {
977     renderServiceClient_->SetWindowExpectedRefreshRate(eventInfos);
978 }
979 
NotifySoftVsyncRateDiscountEvent(uint32_t pid,const std::string & name,uint32_t rateDiscount)980 bool RSInterfaces::NotifySoftVsyncRateDiscountEvent(uint32_t pid, const std::string &name, uint32_t rateDiscount)
981 {
982     return renderServiceClient_->NotifySoftVsyncRateDiscountEvent(pid, name, rateDiscount);
983 }
984 
NotifyTouchEvent(int32_t touchStatus,int32_t touchCnt)985 void RSInterfaces::NotifyTouchEvent(int32_t touchStatus, int32_t touchCnt)
986 {
987     if (!RSFrameRatePolicy::GetInstance()->GetTouchOrPointerAction(touchStatus)) {
988         return;
989     }
990     renderServiceClient_->NotifyTouchEvent(touchStatus, touchCnt);
991 }
992 
NotifyDynamicModeEvent(bool enableDynamicMode)993 void RSInterfaces::NotifyDynamicModeEvent(bool enableDynamicMode)
994 {
995     renderServiceClient_->NotifyDynamicModeEvent(enableDynamicMode);
996 }
997 
NotifyHgmConfigEvent(const std::string & eventName,bool state)998 void RSInterfaces::NotifyHgmConfigEvent(const std::string &eventName, bool state)
999 {
1000     renderServiceClient_->NotifyHgmConfigEvent(eventName, state);
1001 }
1002 
NotifyXComponentExpectedFrameRate(const std::string & id,int32_t expectedFrameRate)1003 void RSInterfaces::NotifyXComponentExpectedFrameRate(const std::string& id, int32_t expectedFrameRate)
1004 {
1005     renderServiceClient_->NotifyXComponentExpectedFrameRate(id, expectedFrameRate);
1006 }
1007 
DisableCacheForRotation()1008 void RSInterfaces::DisableCacheForRotation()
1009 {
1010     renderServiceClient_->SetCacheEnabledForRotation(false);
1011 }
1012 
SetOnRemoteDiedCallback(const OnRemoteDiedCallback & callback)1013 void RSInterfaces::SetOnRemoteDiedCallback(const OnRemoteDiedCallback& callback)
1014 {
1015     renderServiceClient_->SetOnRemoteDiedCallback(callback);
1016 }
1017 
GetActiveDirtyRegionInfo() const1018 std::vector<ActiveDirtyRegionInfo> RSInterfaces::GetActiveDirtyRegionInfo() const
1019 {
1020     const auto& activeDirtyRegionInfo = renderServiceClient_->GetActiveDirtyRegionInfo();
1021     return activeDirtyRegionInfo;
1022 }
1023 
GetGlobalDirtyRegionInfo() const1024 GlobalDirtyRegionInfo RSInterfaces::GetGlobalDirtyRegionInfo() const
1025 {
1026     const auto& globalDirtyRegionInfo = renderServiceClient_->GetGlobalDirtyRegionInfo();
1027     return globalDirtyRegionInfo;
1028 }
1029 
GetLayerComposeInfo() const1030 LayerComposeInfo RSInterfaces::GetLayerComposeInfo() const
1031 {
1032     const auto& layerComposeInfo = renderServiceClient_->GetLayerComposeInfo();
1033     return layerComposeInfo;
1034 }
1035 
GetHwcDisabledReasonInfo() const1036 HwcDisabledReasonInfos RSInterfaces::GetHwcDisabledReasonInfo() const
1037 {
1038     const auto& hwcDisabledReasonInfo = renderServiceClient_->GetHwcDisabledReasonInfo();
1039     return hwcDisabledReasonInfo;
1040 }
1041 
GetHdrOnDuration() const1042 int64_t RSInterfaces::GetHdrOnDuration() const
1043 {
1044     return renderServiceClient_->GetHdrOnDuration();
1045 }
1046 
SetVmaCacheStatus(bool flag)1047 void RSInterfaces::SetVmaCacheStatus(bool flag)
1048 {
1049     renderServiceClient_->SetVmaCacheStatus(flag);
1050 }
1051 
1052 #ifdef TP_FEATURE_ENABLE
SetTpFeatureConfig(int32_t feature,const char * config,TpFeatureConfigType tpFeatureConfigType)1053 void RSInterfaces::SetTpFeatureConfig(int32_t feature, const char* config, TpFeatureConfigType tpFeatureConfigType)
1054 {
1055     renderServiceClient_->SetTpFeatureConfig(feature, config, tpFeatureConfigType);
1056 }
1057 #endif
1058 
SetVirtualScreenUsingStatus(bool isVirtualScreenUsingStatus)1059 void RSInterfaces::SetVirtualScreenUsingStatus(bool isVirtualScreenUsingStatus)
1060 {
1061     renderServiceClient_->SetVirtualScreenUsingStatus(isVirtualScreenUsingStatus);
1062 }
1063 
SetCurtainScreenUsingStatus(bool isCurtainScreenOn)1064 void RSInterfaces::SetCurtainScreenUsingStatus(bool isCurtainScreenOn)
1065 {
1066     renderServiceClient_->SetCurtainScreenUsingStatus(isCurtainScreenOn);
1067 }
1068 
DropFrameByPid(const std::vector<int32_t> pidList)1069 void RSInterfaces::DropFrameByPid(const std::vector<int32_t> pidList)
1070 {
1071     if (pidList.empty()) {
1072         return;
1073     }
1074     RS_TRACE_NAME("DropFrameByPid");
1075     renderServiceClient_->DropFrameByPid(pidList);
1076 }
1077 
RegisterUIExtensionCallback(uint64_t userId,const UIExtensionCallback & callback,bool unobscured)1078 int32_t RSInterfaces::RegisterUIExtensionCallback(uint64_t userId, const UIExtensionCallback& callback, bool unobscured)
1079 {
1080     return renderServiceClient_->RegisterUIExtensionCallback(userId, callback, unobscured);
1081 }
1082 
SetAncoForceDoDirect(bool direct)1083 bool RSInterfaces::SetAncoForceDoDirect(bool direct)
1084 {
1085     return renderServiceClient_->SetAncoForceDoDirect(direct);
1086 }
1087 
SetVirtualScreenStatus(ScreenId id,VirtualScreenStatus screenStatus)1088 bool RSInterfaces::SetVirtualScreenStatus(ScreenId id, VirtualScreenStatus screenStatus)
1089 {
1090     return renderServiceClient_->SetVirtualScreenStatus(id, screenStatus);
1091 }
1092 
SetFreeMultiWindowStatus(bool enable)1093 void RSInterfaces::SetFreeMultiWindowStatus(bool enable)
1094 {
1095     renderServiceClient_->SetFreeMultiWindowStatus(enable);
1096 }
1097 
RegisterTransactionDataCallback(uint64_t token,uint64_t timeStamp,std::function<void ()> callback)1098 bool RSInterfaces::RegisterTransactionDataCallback(uint64_t token, uint64_t timeStamp, std::function<void()> callback)
1099 {
1100     RS_LOGD("interface::RegisterTransactionDataCallback, timeStamp: %{public}"
1101         PRIu64 " token: %{public}" PRIu64, timeStamp, token);
1102     return renderServiceClient_->RegisterTransactionDataCallback(token, timeStamp, callback);
1103 }
1104 
RegisterSurfaceBufferCallback(pid_t pid,uint64_t uid,std::shared_ptr<SurfaceBufferCallback> callback)1105 bool RSInterfaces::RegisterSurfaceBufferCallback(pid_t pid, uint64_t uid,
1106     std::shared_ptr<SurfaceBufferCallback> callback)
1107 {
1108     if (callback == nullptr) {
1109         ROSEN_LOGE("RSInterfaces::RegisterSurfaceBufferCallback callback == nullptr.");
1110         return false;
1111     }
1112     RSSurfaceBufferCallbackManager::Instance().RegisterSurfaceBufferCallback(pid, uid,
1113         new (std::nothrow) RSDefaultSurfaceBufferCallback ({
1114             .OnFinish = [callback](const FinishCallbackRet& ret) {
1115                 callback->OnFinish(ret);
1116             },
1117             .OnAfterAcquireBuffer = [callback](const AfterAcquireBufferRet& ret) {
1118                 callback->OnAfterAcquireBuffer(ret);
1119             },
1120         })
1121     );
1122     return renderServiceClient_->RegisterSurfaceBufferCallback(pid, uid, callback);
1123 }
1124 
UnregisterSurfaceBufferCallback(pid_t pid,uint64_t uid)1125 bool RSInterfaces::UnregisterSurfaceBufferCallback(pid_t pid, uint64_t uid)
1126 {
1127     RSSurfaceBufferCallbackManager::Instance().UnregisterSurfaceBufferCallback(pid, uid);
1128     return renderServiceClient_->UnregisterSurfaceBufferCallback(pid, uid);
1129 }
1130 
SetLayerTopForHWC(NodeId nodeId,bool isTop,uint32_t zOrder)1131 void RSInterfaces::SetLayerTopForHWC(NodeId nodeId, bool isTop, uint32_t zOrder)
1132 {
1133     renderServiceClient_->SetLayerTopForHWC(nodeId, isTop, zOrder);
1134 }
1135 
SetLayerTop(const std::string & nodeIdStr,bool isTop)1136 void RSInterfaces::SetLayerTop(const std::string &nodeIdStr, bool isTop)
1137 {
1138     renderServiceClient_->SetLayerTop(nodeIdStr, isTop);
1139 }
1140 
SetForceRefresh(const std::string & nodeIdStr,bool isForceRefresh)1141 void RSInterfaces::SetForceRefresh(const std::string &nodeIdStr, bool isForceRefresh)
1142 {
1143     renderServiceClient_->SetForceRefresh(nodeIdStr, isForceRefresh);
1144 }
1145 
SetColorFollow(const std::string & nodeIdStr,bool isColorFollow)1146 void RSInterfaces::SetColorFollow(const std::string &nodeIdStr, bool isColorFollow)
1147 {
1148     renderServiceClient_->SetColorFollow(nodeIdStr, isColorFollow);
1149 }
1150 
NotifyScreenSwitched()1151 void RSInterfaces::NotifyScreenSwitched()
1152 {
1153     RS_TRACE_NAME("NotifyScreenSwitched");
1154     ROSEN_LOGI("RSInterfaces::%{public}s", __func__);
1155     renderServiceClient_->NotifyScreenSwitched();
1156 }
1157 
SetWindowContainer(NodeId nodeId,bool value)1158 void RSInterfaces::SetWindowContainer(NodeId nodeId, bool value)
1159 {
1160     renderServiceClient_->SetWindowContainer(nodeId, value);
1161 }
1162 
RegisterSelfDrawingNodeRectChangeCallback(const RectConstraint & constraint,const SelfDrawingNodeRectChangeCallback & callback)1163 int32_t RSInterfaces::RegisterSelfDrawingNodeRectChangeCallback(
1164     const RectConstraint& constraint, const SelfDrawingNodeRectChangeCallback& callback)
1165 {
1166     RS_LOGD("RSInterfaces::RegisterSelfDrawingNodeRectChangeCallback lowLimit_width: %{public}d lowLimit_height: "
1167             "%{public}d highLimit_width: %{public}d highLimit_height: %{public}d",
1168             constraint.range.lowLimit.width, constraint.range.lowLimit.height, constraint.range.highLimit.width,
1169             constraint.range.highLimit.height);
1170     return renderServiceClient_->RegisterSelfDrawingNodeRectChangeCallback(constraint, callback);
1171 }
1172 
UnRegisterSelfDrawingNodeRectChangeCallback()1173 int32_t RSInterfaces::UnRegisterSelfDrawingNodeRectChangeCallback()
1174 {
1175     return renderServiceClient_->UnRegisterSelfDrawingNodeRectChangeCallback();
1176 }
1177 
1178 #ifdef RS_ENABLE_OVERLAY_DISPLAY
SetOverlayDisplayMode(int32_t mode)1179 int32_t RSInterfaces::SetOverlayDisplayMode(int32_t mode)
1180 {
1181     ROSEN_LOGI("RSInterfaces::SetOverlayDisplayMode enter.");
1182     return renderServiceClient_->SetOverlayDisplayMode(mode);
1183 }
1184 #endif
1185 
NotifyPageName(const std::string & packageName,const std::string & pageName,bool isEnter)1186 void RSInterfaces::NotifyPageName(const std::string &packageName, const std::string &pageName, bool isEnter)
1187 {
1188     auto pageNameList = RSFrameRatePolicy::GetInstance()->GetPageNameList();
1189     auto item = pageNameList.find(pageName);
1190     if (item != pageNameList.end()) {
1191         ROSEN_LOGI("RSInterfaces packageName = %{public}s pageName = %{public}s isEnter = %{public}d",
1192             packageName.c_str(), pageName.c_str(), isEnter);
1193         renderServiceClient_->NotifyPageName(packageName, pageName, isEnter);
1194     }
1195 }
1196 
GetPidGpuMemoryInMB(pid_t pid,float & gpuMemInMB)1197 int32_t RSInterfaces::GetPidGpuMemoryInMB(pid_t pid, float &gpuMemInMB)
1198 {
1199     auto ret = renderServiceClient_->GetPidGpuMemoryInMB(pid, gpuMemInMB);
1200     ROSEN_LOGD("RSInterfaces::GetpidGpuMemoryInMB called!");
1201     return ret;
1202 }
1203 
GetHighContrastTextState()1204 bool RSInterfaces::GetHighContrastTextState()
1205 {
1206     return renderServiceClient_->GetHighContrastTextState();
1207 }
1208 
SetBehindWindowFilterEnabled(bool enabled)1209 bool RSInterfaces::SetBehindWindowFilterEnabled(bool enabled)
1210 {
1211     return renderServiceClient_->SetBehindWindowFilterEnabled(enabled);
1212 }
1213 
GetBehindWindowFilterEnabled(bool & enabled)1214 bool RSInterfaces::GetBehindWindowFilterEnabled(bool& enabled)
1215 {
1216     return renderServiceClient_->GetBehindWindowFilterEnabled(enabled);
1217 }
1218 
ClearUifirstCache(NodeId id)1219 void RSInterfaces::ClearUifirstCache(NodeId id)
1220 {
1221     renderServiceClient_->ClearUifirstCache(id);
1222 }
1223 } // namespace Rosen
1224 } // namespace OHOS
1225