• 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_divided_ui_capture.h"
24 #include "pipeline/rs_surface_buffer_callback_manager.h"
25 #include "offscreen_render/rs_offscreen_render_thread.h"
26 #include "ui/rs_frame_rate_policy.h"
27 #include "ui/rs_proxy_node.h"
28 #include "platform/common/rs_log.h"
29 #include "render/rs_typeface_cache.h"
30 
31 namespace OHOS {
32 namespace Rosen {
GetInstance()33 RSInterfaces &RSInterfaces::GetInstance()
34 {
35     static RSInterfaces instance;
36     return instance;
37 }
38 
RSInterfaces()39 RSInterfaces::RSInterfaces() : renderServiceClient_(std::make_unique<RSRenderServiceClient>())
40 {
41 }
42 
~RSInterfaces()43 RSInterfaces::~RSInterfaces() noexcept
44 {
45 }
46 
SetFocusAppInfo(FocusAppInfo & info)47 int32_t RSInterfaces::SetFocusAppInfo(FocusAppInfo& info)
48 {
49     int32_t pid = info.pid;
50     int32_t uid = info.uid;
51     const std::string bundleName = info.bundleName;
52     const std::string abilityName = info.abilityName;
53     uint64_t focusNodeId = info.focusNodeId;
54     return renderServiceClient_->SetFocusAppInfo(pid, uid, bundleName, abilityName, focusNodeId);
55 }
56 
GetDefaultScreenId()57 ScreenId RSInterfaces::GetDefaultScreenId()
58 {
59     return renderServiceClient_->GetDefaultScreenId();
60 }
61 
GetActiveScreenId()62 ScreenId RSInterfaces::GetActiveScreenId()
63 {
64     return renderServiceClient_->GetActiveScreenId();
65 }
66 
GetAllScreenIds()67 std::vector<ScreenId> RSInterfaces::GetAllScreenIds()
68 {
69     return renderServiceClient_->GetAllScreenIds();
70 }
71 
72 #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)73 ScreenId RSInterfaces::CreateVirtualScreen(
74     const std::string &name,
75     uint32_t width,
76     uint32_t height,
77     sptr<Surface> surface,
78     ScreenId mirrorId,
79     int flags,
80     std::vector<NodeId> whiteList)
81 {
82     return renderServiceClient_->CreateVirtualScreen(name, width, height, surface, mirrorId, flags, whiteList);
83 }
84 
SetVirtualScreenBlackList(ScreenId id,std::vector<NodeId> & blackListVector)85 int32_t RSInterfaces::SetVirtualScreenBlackList(ScreenId id, std::vector<NodeId>& blackListVector)
86 {
87     return renderServiceClient_->SetVirtualScreenBlackList(id, blackListVector);
88 }
89 
AddVirtualScreenBlackList(ScreenId id,std::vector<NodeId> & blackListVector)90 int32_t RSInterfaces::AddVirtualScreenBlackList(ScreenId id, std::vector<NodeId>& blackListVector)
91 {
92     return renderServiceClient_->AddVirtualScreenBlackList(id, blackListVector);
93 }
94 
RemoveVirtualScreenBlackList(ScreenId id,std::vector<NodeId> & blackListVector)95 int32_t RSInterfaces::RemoveVirtualScreenBlackList(ScreenId id, std::vector<NodeId>& blackListVector)
96 {
97     return renderServiceClient_->RemoveVirtualScreenBlackList(id, blackListVector);
98 }
99 
SetVirtualScreenSecurityExemptionList(ScreenId id,const std::vector<NodeId> & securityExemptionList)100 int32_t RSInterfaces::SetVirtualScreenSecurityExemptionList(
101     ScreenId id,
102     const std::vector<NodeId>& securityExemptionList)
103 {
104     return renderServiceClient_->SetVirtualScreenSecurityExemptionList(id, securityExemptionList);
105 }
106 
SetCastScreenEnableSkipWindow(ScreenId id,bool enable)107 int32_t RSInterfaces::SetCastScreenEnableSkipWindow(ScreenId id, bool enable)
108 {
109     return renderServiceClient_->SetCastScreenEnableSkipWindow(id, enable);
110 }
111 
SetVirtualScreenSurface(ScreenId id,sptr<Surface> surface)112 int32_t RSInterfaces::SetVirtualScreenSurface(ScreenId id, sptr<Surface> surface)
113 {
114     return renderServiceClient_->SetVirtualScreenSurface(id, surface);
115 }
116 #endif
117 
RemoveVirtualScreen(ScreenId id)118 void RSInterfaces::RemoveVirtualScreen(ScreenId id)
119 {
120     renderServiceClient_->RemoveVirtualScreen(id);
121 }
122 
SetScreenChangeCallback(const ScreenChangeCallback & callback)123 int32_t RSInterfaces::SetScreenChangeCallback(const ScreenChangeCallback &callback)
124 {
125     return renderServiceClient_->SetScreenChangeCallback(callback);
126 }
127 
TakeSurfaceCapture(std::shared_ptr<RSSurfaceNode> node,std::shared_ptr<SurfaceCaptureCallback> callback,RSSurfaceCaptureConfig captureConfig)128 bool RSInterfaces::TakeSurfaceCapture(std::shared_ptr<RSSurfaceNode> node,
129     std::shared_ptr<SurfaceCaptureCallback> callback, RSSurfaceCaptureConfig captureConfig)
130 {
131     if (!node) {
132         ROSEN_LOGW("node is nullptr");
133         return false;
134     }
135     return renderServiceClient_->TakeSurfaceCapture(node->GetId(), callback, captureConfig);
136 }
137 
SetWindowFreezeImmediately(std::shared_ptr<RSSurfaceNode> node,bool isFreeze,std::shared_ptr<SurfaceCaptureCallback> callback,RSSurfaceCaptureConfig captureConfig)138 bool RSInterfaces::SetWindowFreezeImmediately(std::shared_ptr<RSSurfaceNode> node, bool isFreeze,
139     std::shared_ptr<SurfaceCaptureCallback> callback, RSSurfaceCaptureConfig captureConfig)
140 {
141     if (!node) {
142         ROSEN_LOGE("%{public}s node is nullptr", __func__);
143         return false;
144     }
145     return renderServiceClient_->SetWindowFreezeImmediately(node->GetId(), isFreeze, callback, captureConfig);
146 }
147 
TakeSurfaceCapture(std::shared_ptr<RSDisplayNode> node,std::shared_ptr<SurfaceCaptureCallback> callback,RSSurfaceCaptureConfig captureConfig)148 bool RSInterfaces::TakeSurfaceCapture(std::shared_ptr<RSDisplayNode> node,
149     std::shared_ptr<SurfaceCaptureCallback> callback, RSSurfaceCaptureConfig captureConfig)
150 {
151     if (!node) {
152         ROSEN_LOGW("node is nullptr");
153         return false;
154     }
155     return renderServiceClient_->TakeSurfaceCapture(node->GetId(), callback, captureConfig);
156 }
157 
TakeSurfaceCapture(NodeId id,std::shared_ptr<SurfaceCaptureCallback> callback,RSSurfaceCaptureConfig captureConfig)158 bool RSInterfaces::TakeSurfaceCapture(NodeId id,
159     std::shared_ptr<SurfaceCaptureCallback> callback, RSSurfaceCaptureConfig captureConfig)
160 {
161     return renderServiceClient_->TakeSurfaceCapture(id, callback, captureConfig);
162 }
163 
164 #ifndef ROSEN_ARKUI_X
SetScreenActiveMode(ScreenId id,uint32_t modeId)165 void RSInterfaces::SetScreenActiveMode(ScreenId id, uint32_t modeId)
166 {
167     renderServiceClient_->SetScreenActiveMode(id, modeId);
168 }
169 #endif // !ROSEN_ARKUI_X
SetScreenRefreshRate(ScreenId id,int32_t sceneId,int32_t rate)170 void RSInterfaces::SetScreenRefreshRate(ScreenId id, int32_t sceneId, int32_t rate)
171 {
172     renderServiceClient_->SetScreenRefreshRate(id, sceneId, rate);
173 }
174 
SetRefreshRateMode(int32_t refreshRateMode)175 void RSInterfaces::SetRefreshRateMode(int32_t refreshRateMode)
176 {
177     renderServiceClient_->SetRefreshRateMode(refreshRateMode);
178 }
179 
SyncFrameRateRange(FrameRateLinkerId id,const FrameRateRange & range,int32_t animatorExpectedFrameRate)180 void RSInterfaces::SyncFrameRateRange(FrameRateLinkerId id, const FrameRateRange& range,
181     int32_t animatorExpectedFrameRate)
182 {
183     renderServiceClient_->SyncFrameRateRange(id, range, animatorExpectedFrameRate);
184 }
185 
GetScreenCurrentRefreshRate(ScreenId id)186 uint32_t RSInterfaces::GetScreenCurrentRefreshRate(ScreenId id)
187 {
188     return renderServiceClient_->GetScreenCurrentRefreshRate(id);
189 }
190 
GetCurrentRefreshRateMode()191 int32_t RSInterfaces::GetCurrentRefreshRateMode()
192 {
193     return renderServiceClient_->GetCurrentRefreshRateMode();
194 }
195 
GetScreenSupportedRefreshRates(ScreenId id)196 std::vector<int32_t> RSInterfaces::GetScreenSupportedRefreshRates(ScreenId id)
197 {
198     return renderServiceClient_->GetScreenSupportedRefreshRates(id);
199 }
200 
GetShowRefreshRateEnabled()201 bool RSInterfaces::GetShowRefreshRateEnabled()
202 {
203     return renderServiceClient_->GetShowRefreshRateEnabled();
204 }
205 
SetShowRefreshRateEnabled(bool enable)206 void RSInterfaces::SetShowRefreshRateEnabled(bool enable)
207 {
208     return renderServiceClient_->SetShowRefreshRateEnabled(enable);
209 }
210 
GetRefreshInfo(pid_t pid)211 std::string RSInterfaces::GetRefreshInfo(pid_t pid)
212 {
213     return renderServiceClient_->GetRefreshInfo(pid);
214 }
215 
TakeSurfaceCaptureForUI(std::shared_ptr<RSNode> node,std::shared_ptr<SurfaceCaptureCallback> callback,float scaleX,float scaleY,bool isSync,const Drawing::Rect & specifiedAreaRect)216 bool RSInterfaces::TakeSurfaceCaptureForUI(std::shared_ptr<RSNode> node,
217     std::shared_ptr<SurfaceCaptureCallback> callback, float scaleX, float scaleY,
218     bool isSync, const Drawing::Rect& specifiedAreaRect)
219 {
220     if (!node) {
221         ROSEN_LOGW("RSInterfaces::TakeSurfaceCaptureForUI rsnode is nullpter return");
222         return false;
223     }
224     if (!((node->GetType() == RSUINodeType::ROOT_NODE) ||
225           (node->GetType() == RSUINodeType::CANVAS_NODE) ||
226           (node->GetType() == RSUINodeType::CANVAS_DRAWING_NODE) ||
227           (node->GetType() == RSUINodeType::SURFACE_NODE))) {
228         ROSEN_LOGE("RSInterfaces::TakeSurfaceCaptureForUI unsupported node type return");
229         return false;
230     }
231     RSSurfaceCaptureConfig captureConfig;
232     captureConfig.scaleX = scaleX;
233     captureConfig.scaleY = scaleY;
234     captureConfig.captureType = SurfaceCaptureType::UICAPTURE;
235     captureConfig.isSync = isSync;
236     if (RSSystemProperties::GetUniRenderEnabled()) {
237         if (isSync) {
238             node->SetTakeSurfaceForUIFlag();
239         }
240         return renderServiceClient_->TakeSurfaceCapture(node->GetId(), callback, captureConfig, specifiedAreaRect);
241     } else {
242         return TakeSurfaceCaptureForUIWithoutUni(node->GetId(), callback, scaleX, scaleY);
243     }
244 }
245 
RegisterTypeface(std::shared_ptr<Drawing::Typeface> & typeface)246 bool RSInterfaces::RegisterTypeface(std::shared_ptr<Drawing::Typeface>& typeface)
247 {
248     static std::function<std::shared_ptr<Drawing::Typeface> (uint64_t)> customTypefaceQueryfunc =
249             [](uint64_t globalUniqueId) -> std::shared_ptr<Drawing::Typeface> {
250         return RSTypefaceCache::Instance().GetDrawingTypefaceCache(globalUniqueId);
251     };
252 
253     static std::once_flag onceFlag;
254     std::call_once(onceFlag, []() {
255         Drawing::DrawOpItem::SetTypefaceQueryCallBack(customTypefaceQueryfunc);
256     });
257 
258     if (RSSystemProperties::GetUniRenderEnabled()) {
259         bool result = renderServiceClient_->RegisterTypeface(typeface);
260         if (result) {
261             RS_LOGD("RSInterfaces::RegisterTypeface: register typeface[%{public}u]",
262                     typeface->GetUniqueID());
263             uint64_t globalUniqueId = RSTypefaceCache::GenGlobalUniqueId(typeface->GetUniqueID());
264             RSTypefaceCache::Instance().CacheDrawingTypeface(globalUniqueId, typeface);
265         } else {
266             if (typeface != nullptr) {
267                 RS_LOGD("RSInterfaces:Failed to reg typeface, family name:%{public}s, uniqueid:%{public}u",
268                     typeface->GetFamilyName().c_str(), typeface->GetUniqueID());
269             }
270         }
271         return result;
272     }
273 
274     RS_LOGD("RSInterfaces::RegisterTypeface: register typeface[%{public}u]",
275         typeface->GetUniqueID());
276     uint64_t globalUniqueId = RSTypefaceCache::GenGlobalUniqueId(typeface->GetUniqueID());
277     RSTypefaceCache::Instance().CacheDrawingTypeface(globalUniqueId, typeface);
278     return true;
279 }
280 
UnRegisterTypeface(std::shared_ptr<Drawing::Typeface> & typeface)281 bool RSInterfaces::UnRegisterTypeface(std::shared_ptr<Drawing::Typeface>& typeface)
282 {
283     if (RSSystemProperties::GetUniRenderEnabled()) {
284         bool result = renderServiceClient_->UnRegisterTypeface(typeface);
285         if (result) {
286             uint64_t globalUniqueId = RSTypefaceCache::GenGlobalUniqueId(typeface->GetUniqueID());
287             RSTypefaceCache::Instance().RemoveDrawingTypefaceByGlobalUniqueId(globalUniqueId);
288         }
289         return result;
290     }
291 
292     RS_LOGD("RSInterfaces::UnRegisterTypeface: unregister typeface[%{public}u]",
293         typeface->GetUniqueID());
294     uint64_t globalUniqueId = RSTypefaceCache::GenGlobalUniqueId(typeface->GetUniqueID());
295     RSTypefaceCache::Instance().AddDelayDestroyQueue(globalUniqueId);
296     return true;
297 }
298 
SetGlobalDarkColorMode(bool isDark)299 bool RSInterfaces::SetGlobalDarkColorMode(bool isDark)
300 {
301     return renderServiceClient_->SetGlobalDarkColorMode(isDark);
302 }
303 
304 #ifndef ROSEN_ARKUI_X
SetPhysicalScreenResolution(ScreenId id,uint32_t width,uint32_t height)305 int32_t RSInterfaces::SetPhysicalScreenResolution(ScreenId id, uint32_t width, uint32_t height)
306 {
307     return renderServiceClient_->SetPhysicalScreenResolution(id, width, height);
308 }
309 
SetVirtualScreenResolution(ScreenId id,uint32_t width,uint32_t height)310 int32_t RSInterfaces::SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height)
311 {
312     return renderServiceClient_->SetVirtualScreenResolution(id, width, height);
313 }
314 #endif // !ROSEN_ARKUI_X
315 
SetVirtualMirrorScreenCanvasRotation(ScreenId id,bool canvasRotation)316 bool RSInterfaces::SetVirtualMirrorScreenCanvasRotation(ScreenId id, bool canvasRotation)
317 {
318     return renderServiceClient_->SetVirtualMirrorScreenCanvasRotation(id, canvasRotation);
319 }
320 
SetVirtualMirrorScreenScaleMode(ScreenId id,ScreenScaleMode scaleMode)321 bool RSInterfaces::SetVirtualMirrorScreenScaleMode(ScreenId id, ScreenScaleMode scaleMode)
322 {
323     return renderServiceClient_->SetVirtualMirrorScreenScaleMode(id, scaleMode);
324 }
325 
326 #ifndef ROSEN_ARKUI_X
GetVirtualScreenResolution(ScreenId id)327 RSVirtualScreenResolution RSInterfaces::GetVirtualScreenResolution(ScreenId id)
328 {
329     return renderServiceClient_->GetVirtualScreenResolution(id);
330 }
331 
MarkPowerOffNeedProcessOneFrame()332 void RSInterfaces::MarkPowerOffNeedProcessOneFrame()
333 {
334     RS_LOGD("[UL_POWER]RSInterfaces::MarkPowerOffNeedProcessOneFrame.");
335     renderServiceClient_->MarkPowerOffNeedProcessOneFrame();
336 }
337 
DisablePowerOffRenderControl(ScreenId id)338 void RSInterfaces::DisablePowerOffRenderControl(ScreenId id)
339 {
340     RS_LOGD("RSInterfaces::DisablePowerOffRenderControl.");
341     renderServiceClient_->DisablePowerOffRenderControl(id);
342 }
343 
SetScreenPowerStatus(ScreenId id,ScreenPowerStatus status)344 void RSInterfaces::SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status)
345 {
346     RS_LOGI("[UL_POWER]RSInterfaces::SetScreenPowerStatus: ScreenId: %{public}" PRIu64
347             ", ScreenPowerStatus: %{public}u",
348         id, static_cast<uint32_t>(status));
349     renderServiceClient_->SetScreenPowerStatus(id, status);
350 }
351 #endif // !ROSEN_ARKUI_X
TakeSurfaceCaptureForUIWithoutUni(NodeId id,std::shared_ptr<SurfaceCaptureCallback> callback,float scaleX,float scaleY)352 bool RSInterfaces::TakeSurfaceCaptureForUIWithoutUni(NodeId id,
353     std::shared_ptr<SurfaceCaptureCallback> callback, float scaleX, float scaleY)
354 {
355     std::function<void()> offscreenRenderTask = [scaleX, scaleY, callback, id, this]() -> void {
356         ROSEN_LOGD(
357             "RSInterfaces::TakeSurfaceCaptureForUIWithoutUni callback->OnOffscreenRender nodeId:"
358             "[%{public}" PRIu64 "]", id);
359         ROSEN_TRACE_BEGIN(HITRACE_TAG_GRAPHIC_AGP, "RSRenderThread::TakeSurfaceCaptureForUIWithoutUni");
360         std::shared_ptr<RSDividedUICapture> rsDividedUICapture =
361             std::make_shared<RSDividedUICapture>(id, scaleX, scaleY);
362         std::shared_ptr<Media::PixelMap> pixelmap = rsDividedUICapture->TakeLocalCapture();
363         ROSEN_TRACE_END(HITRACE_TAG_GRAPHIC_AGP);
364         callback->OnSurfaceCapture(pixelmap);
365     };
366     RSOffscreenRenderThread::Instance().PostTask(offscreenRenderTask);
367     return true;
368 }
369 
370 #ifndef ROSEN_ARKUI_X
GetScreenActiveMode(ScreenId id)371 RSScreenModeInfo RSInterfaces::GetScreenActiveMode(ScreenId id)
372 {
373     return renderServiceClient_->GetScreenActiveMode(id);
374 }
375 
GetScreenSupportedModes(ScreenId id)376 std::vector<RSScreenModeInfo> RSInterfaces::GetScreenSupportedModes(ScreenId id)
377 {
378     return renderServiceClient_->GetScreenSupportedModes(id);
379 }
380 
GetScreenCapability(ScreenId id)381 RSScreenCapability RSInterfaces::GetScreenCapability(ScreenId id)
382 {
383     return renderServiceClient_->GetScreenCapability(id);
384 }
385 
GetScreenPowerStatus(ScreenId id)386 ScreenPowerStatus RSInterfaces::GetScreenPowerStatus(ScreenId id)
387 {
388     return renderServiceClient_->GetScreenPowerStatus(id);
389 }
390 
GetScreenData(ScreenId id)391 RSScreenData RSInterfaces::GetScreenData(ScreenId id)
392 {
393     return renderServiceClient_->GetScreenData(id);
394 }
395 #endif // !ROSEN_ARKUI_X
GetScreenBacklight(ScreenId id)396 int32_t RSInterfaces::GetScreenBacklight(ScreenId id)
397 {
398     return renderServiceClient_->GetScreenBacklight(id);
399 }
400 
SetScreenBacklight(ScreenId id,uint32_t level)401 void RSInterfaces::SetScreenBacklight(ScreenId id, uint32_t level)
402 {
403     RS_LOGD("RSInterfaces::SetScreenBacklight: ScreenId: %{public}" PRIu64 ", level: %{public}u", id, level);
404     renderServiceClient_->SetScreenBacklight(id, level);
405 }
406 
GetScreenSupportedColorGamuts(ScreenId id,std::vector<ScreenColorGamut> & mode)407 int32_t RSInterfaces::GetScreenSupportedColorGamuts(ScreenId id, std::vector<ScreenColorGamut>& mode)
408 {
409     return renderServiceClient_->GetScreenSupportedColorGamuts(id, mode);
410 }
411 
GetScreenSupportedMetaDataKeys(ScreenId id,std::vector<ScreenHDRMetadataKey> & keys)412 int32_t RSInterfaces::GetScreenSupportedMetaDataKeys(ScreenId id, std::vector<ScreenHDRMetadataKey>& keys)
413 {
414     return renderServiceClient_->GetScreenSupportedMetaDataKeys(id, keys);
415 }
416 
GetScreenColorGamut(ScreenId id,ScreenColorGamut & mode)417 int32_t RSInterfaces::GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode)
418 {
419     return renderServiceClient_->GetScreenColorGamut(id, mode);
420 }
421 
SetScreenColorGamut(ScreenId id,int32_t modeIdx)422 int32_t RSInterfaces::SetScreenColorGamut(ScreenId id, int32_t modeIdx)
423 {
424     return renderServiceClient_->SetScreenColorGamut(id, modeIdx);
425 }
426 
SetScreenGamutMap(ScreenId id,ScreenGamutMap mode)427 int32_t RSInterfaces::SetScreenGamutMap(ScreenId id, ScreenGamutMap mode)
428 {
429     return renderServiceClient_->SetScreenGamutMap(id, mode);
430 }
431 
SetScreenCorrection(ScreenId id,ScreenRotation screenRotation)432 int32_t RSInterfaces::SetScreenCorrection(ScreenId id, ScreenRotation screenRotation)
433 {
434     return renderServiceClient_->SetScreenCorrection(id, screenRotation);
435 }
436 
GetScreenGamutMap(ScreenId id,ScreenGamutMap & mode)437 int32_t RSInterfaces::GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode)
438 {
439     return renderServiceClient_->GetScreenGamutMap(id, mode);
440 }
441 
CreateVSyncReceiver(const std::string & name,const std::shared_ptr<OHOS::AppExecFwk::EventHandler> & looper)442 std::shared_ptr<VSyncReceiver> RSInterfaces::CreateVSyncReceiver(
443     const std::string& name,
444     const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper)
445 {
446     return renderServiceClient_->CreateVSyncReceiver(name, looper);
447 }
448 
CreateVSyncReceiver(const std::string & name,uint64_t id,const std::shared_ptr<OHOS::AppExecFwk::EventHandler> & looper,NodeId windowNodeId,bool fromXcomponent)449 std::shared_ptr<VSyncReceiver> RSInterfaces::CreateVSyncReceiver(
450     const std::string& name,
451     uint64_t id,
452     const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper,
453     NodeId windowNodeId,
454     bool fromXcomponent)
455 {
456     return renderServiceClient_->CreateVSyncReceiver(name, looper, id, windowNodeId, fromXcomponent);
457 }
458 
CreatePixelMapFromSurfaceId(uint64_t surfaceId,const Rect & srcRect)459 std::shared_ptr<Media::PixelMap> RSInterfaces::CreatePixelMapFromSurfaceId(uint64_t surfaceId, const Rect &srcRect)
460 {
461     return renderServiceClient_->CreatePixelMapFromSurfaceId(surfaceId, srcRect);
462 }
463 
GetScreenHDRCapability(ScreenId id,RSScreenHDRCapability & screenHdrCapability)464 int32_t RSInterfaces::GetScreenHDRCapability(ScreenId id, RSScreenHDRCapability& screenHdrCapability)
465 {
466     return renderServiceClient_->GetScreenHDRCapability(id, screenHdrCapability);
467 }
468 
GetPixelFormat(ScreenId id,GraphicPixelFormat & pixelFormat)469 int32_t RSInterfaces::GetPixelFormat(ScreenId id, GraphicPixelFormat& pixelFormat)
470 {
471     return renderServiceClient_->GetPixelFormat(id, pixelFormat);
472 }
473 
SetPixelFormat(ScreenId id,GraphicPixelFormat pixelFormat)474 int32_t RSInterfaces::SetPixelFormat(ScreenId id, GraphicPixelFormat pixelFormat)
475 {
476     return renderServiceClient_->SetPixelFormat(id, pixelFormat);
477 }
478 
GetScreenSupportedHDRFormats(ScreenId id,std::vector<ScreenHDRFormat> & hdrFormats)479 int32_t RSInterfaces::GetScreenSupportedHDRFormats(ScreenId id, std::vector<ScreenHDRFormat>& hdrFormats)
480 {
481     return renderServiceClient_->GetScreenSupportedHDRFormats(id, hdrFormats);
482 }
483 
GetScreenHDRFormat(ScreenId id,ScreenHDRFormat & hdrFormat)484 int32_t RSInterfaces::GetScreenHDRFormat(ScreenId id, ScreenHDRFormat& hdrFormat)
485 {
486     return renderServiceClient_->GetScreenHDRFormat(id, hdrFormat);
487 }
488 
SetScreenHDRFormat(ScreenId id,int32_t modeIdx)489 int32_t RSInterfaces::SetScreenHDRFormat(ScreenId id, int32_t modeIdx)
490 {
491     return renderServiceClient_->SetScreenHDRFormat(id, modeIdx);
492 }
493 
GetScreenSupportedColorSpaces(ScreenId id,std::vector<GraphicCM_ColorSpaceType> & colorSpaces)494 int32_t RSInterfaces::GetScreenSupportedColorSpaces(ScreenId id, std::vector<GraphicCM_ColorSpaceType>& colorSpaces)
495 {
496     return renderServiceClient_->GetScreenSupportedColorSpaces(id, colorSpaces);
497 }
498 
GetScreenColorSpace(ScreenId id,GraphicCM_ColorSpaceType & colorSpace)499 int32_t RSInterfaces::GetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType& colorSpace)
500 {
501     return renderServiceClient_->GetScreenColorSpace(id, colorSpace);
502 }
503 
SetScreenColorSpace(ScreenId id,GraphicCM_ColorSpaceType colorSpace)504 int32_t RSInterfaces::SetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType colorSpace)
505 {
506     return renderServiceClient_->SetScreenColorSpace(id, colorSpace);
507 }
508 
GetScreenType(ScreenId id,RSScreenType & screenType)509 int32_t RSInterfaces::GetScreenType(ScreenId id, RSScreenType& screenType)
510 {
511     return renderServiceClient_->GetScreenType(id, screenType);
512 }
513 
SetScreenSkipFrameInterval(ScreenId id,uint32_t skipFrameInterval)514 int32_t RSInterfaces::SetScreenSkipFrameInterval(ScreenId id, uint32_t skipFrameInterval)
515 {
516     return renderServiceClient_->SetScreenSkipFrameInterval(id, skipFrameInterval);
517 }
518 
SetScreenActiveRect(ScreenId id,const Rect & activeRect)519 uint32_t RSInterfaces::SetScreenActiveRect(ScreenId id, const Rect& activeRect)
520 {
521     return renderServiceClient_->SetScreenActiveRect(id, activeRect);
522 }
523 
SetVirtualScreenRefreshRate(ScreenId id,uint32_t maxRefreshRate,uint32_t & actualRefreshRate)524 int32_t RSInterfaces::SetVirtualScreenRefreshRate(ScreenId id, uint32_t maxRefreshRate, uint32_t& actualRefreshRate)
525 {
526     return renderServiceClient_->SetVirtualScreenRefreshRate(id, maxRefreshRate, actualRefreshRate);
527 }
528 
SetSystemAnimatedScenes(SystemAnimatedScenes systemAnimatedScenes)529 bool RSInterfaces::SetSystemAnimatedScenes(SystemAnimatedScenes systemAnimatedScenes)
530 {
531     return renderServiceClient_->SetSystemAnimatedScenes(systemAnimatedScenes);
532 }
533 
RegisterOcclusionChangeCallback(const OcclusionChangeCallback & callback)534 int32_t RSInterfaces::RegisterOcclusionChangeCallback(const OcclusionChangeCallback& callback)
535 {
536     return renderServiceClient_->RegisterOcclusionChangeCallback(callback);
537 }
538 
RegisterSurfaceOcclusionChangeCallback(NodeId id,const SurfaceOcclusionChangeCallback & callback,std::vector<float> & partitionPoints)539 int32_t RSInterfaces::RegisterSurfaceOcclusionChangeCallback(
540     NodeId id, const SurfaceOcclusionChangeCallback& callback, std::vector<float>& partitionPoints)
541 {
542     return renderServiceClient_->RegisterSurfaceOcclusionChangeCallback(id, callback, partitionPoints);
543 }
544 
UnRegisterSurfaceOcclusionChangeCallback(NodeId id)545 int32_t RSInterfaces::UnRegisterSurfaceOcclusionChangeCallback(NodeId id)
546 {
547     return renderServiceClient_->UnRegisterSurfaceOcclusionChangeCallback(id);
548 }
549 
RegisterHgmConfigChangeCallback(const HgmConfigChangeCallback & callback)550 int32_t RSInterfaces::RegisterHgmConfigChangeCallback(const HgmConfigChangeCallback& callback)
551 {
552     return renderServiceClient_->RegisterHgmConfigChangeCallback(callback);
553 }
554 
RegisterHgmRefreshRateModeChangeCallback(const HgmRefreshRateModeChangeCallback & callback)555 int32_t RSInterfaces::RegisterHgmRefreshRateModeChangeCallback(const HgmRefreshRateModeChangeCallback& callback)
556 {
557     return renderServiceClient_->RegisterHgmRefreshRateModeChangeCallback(callback);
558 }
559 
RegisterHgmRefreshRateUpdateCallback(const HgmRefreshRateUpdateCallback & callback)560 int32_t RSInterfaces::RegisterHgmRefreshRateUpdateCallback(const HgmRefreshRateUpdateCallback& callback)
561 {
562     return renderServiceClient_->RegisterHgmRefreshRateUpdateCallback(callback);
563 }
564 
UnRegisterHgmRefreshRateUpdateCallback()565 int32_t RSInterfaces::UnRegisterHgmRefreshRateUpdateCallback()
566 {
567     return renderServiceClient_->RegisterHgmRefreshRateUpdateCallback(nullptr);
568 }
569 
RegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid,const FrameRateLinkerExpectedFpsUpdateCallback & callback)570 int32_t RSInterfaces::RegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid,
571     const FrameRateLinkerExpectedFpsUpdateCallback& callback)
572 {
573     if (callback == nullptr) {
574         ROSEN_LOGE("RSInterfaces::RegisterFrameRateLinkerExpectedFpsUpdateCallback callback == nullptr.");
575         return INVALID_ARGUMENTS;
576     }
577     return renderServiceClient_->RegisterFrameRateLinkerExpectedFpsUpdateCallback(dstPid, callback);
578 }
579 
UnRegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid)580 int32_t RSInterfaces::UnRegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid)
581 {
582     return renderServiceClient_->RegisterFrameRateLinkerExpectedFpsUpdateCallback(dstPid, nullptr);
583 }
584 
SetAppWindowNum(uint32_t num)585 void RSInterfaces::SetAppWindowNum(uint32_t num)
586 {
587     renderServiceClient_->SetAppWindowNum(num);
588 }
589 
ShowWatermark(const std::shared_ptr<Media::PixelMap> & watermarkImg,bool isShow)590 void RSInterfaces::ShowWatermark(const std::shared_ptr<Media::PixelMap> &watermarkImg, bool isShow)
591 {
592     renderServiceClient_->ShowWatermark(watermarkImg, isShow);
593 }
594 
ResizeVirtualScreen(ScreenId id,uint32_t width,uint32_t height)595 int32_t RSInterfaces::ResizeVirtualScreen(ScreenId id, uint32_t width, uint32_t height)
596 {
597     return renderServiceClient_->ResizeVirtualScreen(id, width, height);
598 }
599 
600 #ifndef ROSEN_ARKUI_X
GetMemoryGraphic(int pid)601 MemoryGraphic RSInterfaces::GetMemoryGraphic(int pid)
602 {
603     return renderServiceClient_->GetMemoryGraphic(pid);
604 }
605 
GetMemoryGraphics()606 std::vector<MemoryGraphic> RSInterfaces::GetMemoryGraphics()
607 {
608     return renderServiceClient_->GetMemoryGraphics();
609 }
610 #endif // !ROSEN_ARKUI_X
GetTotalAppMemSize(float & cpuMemSize,float & gpuMemSize)611 bool RSInterfaces::GetTotalAppMemSize(float& cpuMemSize, float& gpuMemSize)
612 {
613     return renderServiceClient_->GetTotalAppMemSize(cpuMemSize, gpuMemSize);
614 }
615 
ReportJankStats()616 void RSInterfaces::ReportJankStats()
617 {
618     renderServiceClient_->ReportJankStats();
619 }
620 
ReportEventResponse(DataBaseRs info)621 void RSInterfaces::ReportEventResponse(DataBaseRs info)
622 {
623     renderServiceClient_->ReportEventResponse(info);
624 }
625 
ReportEventComplete(DataBaseRs info)626 void RSInterfaces::ReportEventComplete(DataBaseRs info)
627 {
628     renderServiceClient_->ReportEventComplete(info);
629 }
630 
ReportEventJankFrame(DataBaseRs info)631 void RSInterfaces::ReportEventJankFrame(DataBaseRs info)
632 {
633     renderServiceClient_->ReportEventJankFrame(info);
634 }
635 
ReportGameStateData(GameStateData info)636 void RSInterfaces::ReportGameStateData(GameStateData info)
637 {
638     renderServiceClient_->ReportGameStateData(info);
639 }
640 
EnableCacheForRotation()641 void RSInterfaces::EnableCacheForRotation()
642 {
643     renderServiceClient_->SetCacheEnabledForRotation(true);
644 }
645 
NotifyLightFactorStatus(bool isSafe)646 void RSInterfaces::NotifyLightFactorStatus(bool isSafe)
647 {
648     renderServiceClient_->NotifyLightFactorStatus(isSafe);
649 }
650 
NotifyPackageEvent(uint32_t listSize,const std::vector<std::string> & packageList)651 void RSInterfaces::NotifyPackageEvent(uint32_t listSize, const std::vector<std::string>& packageList)
652 {
653     renderServiceClient_->NotifyPackageEvent(listSize, packageList);
654 }
655 
NotifyRefreshRateEvent(const EventInfo & eventInfo)656 void RSInterfaces::NotifyRefreshRateEvent(const EventInfo& eventInfo)
657 {
658     renderServiceClient_->NotifyRefreshRateEvent(eventInfo);
659 }
660 
NotifyTouchEvent(int32_t touchStatus,int32_t touchCnt)661 void RSInterfaces::NotifyTouchEvent(int32_t touchStatus, int32_t touchCnt)
662 {
663     renderServiceClient_->NotifyTouchEvent(touchStatus, touchCnt);
664 }
665 
NotifyDynamicModeEvent(bool enableDynamicMode)666 void RSInterfaces::NotifyDynamicModeEvent(bool enableDynamicMode)
667 {
668     renderServiceClient_->NotifyDynamicModeEvent(enableDynamicMode);
669 }
670 
DisableCacheForRotation()671 void RSInterfaces::DisableCacheForRotation()
672 {
673     renderServiceClient_->SetCacheEnabledForRotation(false);
674 }
675 
SetOnRemoteDiedCallback(const OnRemoteDiedCallback & callback)676 void RSInterfaces::SetOnRemoteDiedCallback(const OnRemoteDiedCallback& callback)
677 {
678     renderServiceClient_->SetOnRemoteDiedCallback(callback);
679 }
680 
GetActiveDirtyRegionInfo() const681 std::vector<ActiveDirtyRegionInfo> RSInterfaces::GetActiveDirtyRegionInfo() const
682 {
683     const auto& activeDirtyRegionInfo = renderServiceClient_->GetActiveDirtyRegionInfo();
684     return activeDirtyRegionInfo;
685 }
686 
GetGlobalDirtyRegionInfo() const687 GlobalDirtyRegionInfo RSInterfaces::GetGlobalDirtyRegionInfo() const
688 {
689     const auto& globalDirtyRegionInfo = renderServiceClient_->GetGlobalDirtyRegionInfo();
690     return globalDirtyRegionInfo;
691 }
692 
GetLayerComposeInfo() const693 LayerComposeInfo RSInterfaces::GetLayerComposeInfo() const
694 {
695     const auto& layerComposeInfo = renderServiceClient_->GetLayerComposeInfo();
696     return layerComposeInfo;
697 }
698 
GetHwcDisabledReasonInfo() const699 HwcDisabledReasonInfos RSInterfaces::GetHwcDisabledReasonInfo() const
700 {
701     const auto& hwcDisabledReasonInfo = renderServiceClient_->GetHwcDisabledReasonInfo();
702     return hwcDisabledReasonInfo;
703 }
704 
SetVmaCacheStatus(bool flag)705 void RSInterfaces::SetVmaCacheStatus(bool flag)
706 {
707     renderServiceClient_->SetVmaCacheStatus(flag);
708 }
709 
710 #ifdef TP_FEATURE_ENABLE
SetTpFeatureConfig(int32_t feature,const char * config,TpFeatureConfigType tpFeatureConfigType)711 void RSInterfaces::SetTpFeatureConfig(int32_t feature, const char* config, TpFeatureConfigType tpFeatureConfigType)
712 {
713     renderServiceClient_->SetTpFeatureConfig(feature, config, tpFeatureConfigType);
714 }
715 #endif
716 
SetVirtualScreenUsingStatus(bool isVirtualScreenUsingStatus)717 void RSInterfaces::SetVirtualScreenUsingStatus(bool isVirtualScreenUsingStatus)
718 {
719     renderServiceClient_->SetVirtualScreenUsingStatus(isVirtualScreenUsingStatus);
720 }
721 
SetCurtainScreenUsingStatus(bool isCurtainScreenOn)722 void RSInterfaces::SetCurtainScreenUsingStatus(bool isCurtainScreenOn)
723 {
724     renderServiceClient_->SetCurtainScreenUsingStatus(isCurtainScreenOn);
725 }
726 
DropFrameByPid(const std::vector<int32_t> pidList)727 void RSInterfaces::DropFrameByPid(const std::vector<int32_t> pidList)
728 {
729     if (pidList.empty()) {
730         return;
731     }
732     RS_TRACE_NAME("DropFrameByPid");
733     renderServiceClient_->DropFrameByPid(pidList);
734 }
735 
RegisterUIExtensionCallback(uint64_t userId,const UIExtensionCallback & callback,bool unobscured)736 int32_t RSInterfaces::RegisterUIExtensionCallback(uint64_t userId, const UIExtensionCallback& callback, bool unobscured)
737 {
738     return renderServiceClient_->RegisterUIExtensionCallback(userId, callback, unobscured);
739 }
740 
SetAncoForceDoDirect(bool direct)741 bool RSInterfaces::SetAncoForceDoDirect(bool direct)
742 {
743     return renderServiceClient_->SetAncoForceDoDirect(direct);
744 }
745 
RegisterSurfaceBufferCallback(pid_t pid,uint64_t uid,std::shared_ptr<SurfaceBufferCallback> callback)746 bool RSInterfaces::RegisterSurfaceBufferCallback(pid_t pid, uint64_t uid,
747     std::shared_ptr<SurfaceBufferCallback> callback)
748 {
749     if (callback == nullptr) {
750         ROSEN_LOGE("RSInterfaces::RegisterSurfaceBufferCallback callback == nullptr.");
751         return false;
752     }
753     RSSurfaceBufferCallbackManager::Instance().RegisterSurfaceBufferCallback(pid, uid,
754         new (std::nothrow) RSDefaultSurfaceBufferCallback ({
755             .OnFinish = [callback](const FinishCallbackRet& ret) {
756                 callback->OnFinish(ret);
757             },
758             .OnAfterAcquireBuffer = [callback](const AfterAcquireBufferRet& ret) {
759                 callback->OnAfterAcquireBuffer(ret);
760             },
761         })
762     );
763     return renderServiceClient_->RegisterSurfaceBufferCallback(pid, uid, callback);
764 }
765 
UnregisterSurfaceBufferCallback(pid_t pid,uint64_t uid)766 bool RSInterfaces::UnregisterSurfaceBufferCallback(pid_t pid, uint64_t uid)
767 {
768     RSSurfaceBufferCallbackManager::Instance().UnregisterSurfaceBufferCallback(pid, uid);
769     return renderServiceClient_->UnregisterSurfaceBufferCallback(pid, uid);
770 }
771 
SetLayerTop(const std::string & nodeIdStr,bool isTop)772 void RSInterfaces::SetLayerTop(const std::string &nodeIdStr, bool isTop)
773 {
774     renderServiceClient_->SetLayerTop(nodeIdStr, isTop);
775 }
776 
NotifyScreenSwitched()777 void RSInterfaces::NotifyScreenSwitched()
778 {
779     renderServiceClient_->NotifyScreenSwitched();
780 }
781 
SetWindowContainer(NodeId nodeId,bool value)782 void RSInterfaces::SetWindowContainer(NodeId nodeId, bool value)
783 {
784     renderServiceClient_->SetWindowContainer(nodeId, value);
785 }
786 } // namespace Rosen
787 } // namespace OHOS
788