• 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 
TakeSurfaceCapture(std::shared_ptr<RSDisplayNode> node,std::shared_ptr<SurfaceCaptureCallback> callback,RSSurfaceCaptureConfig captureConfig)138 bool RSInterfaces::TakeSurfaceCapture(std::shared_ptr<RSDisplayNode> node,
139     std::shared_ptr<SurfaceCaptureCallback> callback, RSSurfaceCaptureConfig captureConfig)
140 {
141     if (!node) {
142         ROSEN_LOGW("node is nullptr");
143         return false;
144     }
145     return renderServiceClient_->TakeSurfaceCapture(node->GetId(), callback, captureConfig);
146 }
147 
TakeSurfaceCapture(NodeId id,std::shared_ptr<SurfaceCaptureCallback> callback,RSSurfaceCaptureConfig captureConfig)148 bool RSInterfaces::TakeSurfaceCapture(NodeId id,
149     std::shared_ptr<SurfaceCaptureCallback> callback, RSSurfaceCaptureConfig captureConfig)
150 {
151     return renderServiceClient_->TakeSurfaceCapture(id, callback, captureConfig);
152 }
153 
154 #ifndef ROSEN_ARKUI_X
SetScreenActiveMode(ScreenId id,uint32_t modeId)155 void RSInterfaces::SetScreenActiveMode(ScreenId id, uint32_t modeId)
156 {
157     renderServiceClient_->SetScreenActiveMode(id, modeId);
158 }
159 #endif // !ROSEN_ARKUI_X
SetScreenRefreshRate(ScreenId id,int32_t sceneId,int32_t rate)160 void RSInterfaces::SetScreenRefreshRate(ScreenId id, int32_t sceneId, int32_t rate)
161 {
162     renderServiceClient_->SetScreenRefreshRate(id, sceneId, rate);
163 }
164 
SetRefreshRateMode(int32_t refreshRateMode)165 void RSInterfaces::SetRefreshRateMode(int32_t refreshRateMode)
166 {
167     renderServiceClient_->SetRefreshRateMode(refreshRateMode);
168 }
169 
SyncFrameRateRange(FrameRateLinkerId id,const FrameRateRange & range,int32_t animatorExpectedFrameRate)170 void RSInterfaces::SyncFrameRateRange(FrameRateLinkerId id, const FrameRateRange& range,
171     int32_t animatorExpectedFrameRate)
172 {
173     renderServiceClient_->SyncFrameRateRange(id, range, animatorExpectedFrameRate);
174 }
175 
GetScreenCurrentRefreshRate(ScreenId id)176 uint32_t RSInterfaces::GetScreenCurrentRefreshRate(ScreenId id)
177 {
178     return renderServiceClient_->GetScreenCurrentRefreshRate(id);
179 }
180 
GetCurrentRefreshRateMode()181 int32_t RSInterfaces::GetCurrentRefreshRateMode()
182 {
183     return renderServiceClient_->GetCurrentRefreshRateMode();
184 }
185 
GetScreenSupportedRefreshRates(ScreenId id)186 std::vector<int32_t> RSInterfaces::GetScreenSupportedRefreshRates(ScreenId id)
187 {
188     return renderServiceClient_->GetScreenSupportedRefreshRates(id);
189 }
190 
GetShowRefreshRateEnabled()191 bool RSInterfaces::GetShowRefreshRateEnabled()
192 {
193     return renderServiceClient_->GetShowRefreshRateEnabled();
194 }
195 
SetShowRefreshRateEnabled(bool enable)196 void RSInterfaces::SetShowRefreshRateEnabled(bool enable)
197 {
198     return renderServiceClient_->SetShowRefreshRateEnabled(enable);
199 }
200 
GetRefreshInfo(pid_t pid)201 std::string RSInterfaces::GetRefreshInfo(pid_t pid)
202 {
203     return renderServiceClient_->GetRefreshInfo(pid);
204 }
205 
TakeSurfaceCaptureForUI(std::shared_ptr<RSNode> node,std::shared_ptr<SurfaceCaptureCallback> callback,float scaleX,float scaleY,bool isSync)206 bool RSInterfaces::TakeSurfaceCaptureForUI(std::shared_ptr<RSNode> node,
207     std::shared_ptr<SurfaceCaptureCallback> callback, float scaleX, float scaleY, bool isSync)
208 {
209     if (!node) {
210         ROSEN_LOGW("RSInterfaces::TakeSurfaceCaptureForUI rsnode is nullpter return");
211         return false;
212     }
213     if (!((node->GetType() == RSUINodeType::ROOT_NODE) ||
214           (node->GetType() == RSUINodeType::CANVAS_NODE) ||
215           (node->GetType() == RSUINodeType::CANVAS_DRAWING_NODE) ||
216           (node->GetType() == RSUINodeType::SURFACE_NODE))) {
217         ROSEN_LOGE("RSInterfaces::TakeSurfaceCaptureForUI unsupported node type return");
218         return false;
219     }
220     RSSurfaceCaptureConfig captureConfig;
221     captureConfig.scaleX = scaleX;
222     captureConfig.scaleY = scaleY;
223     captureConfig.captureType = SurfaceCaptureType::UICAPTURE;
224     captureConfig.isSync = isSync;
225     if (RSSystemProperties::GetUniRenderEnabled()) {
226         if (isSync) {
227             node->SetTakeSurfaceForUIFlag();
228         }
229         return renderServiceClient_->TakeSurfaceCapture(node->GetId(), callback, captureConfig);
230     } else {
231         return TakeSurfaceCaptureForUIWithoutUni(node->GetId(), callback, scaleX, scaleY);
232     }
233 }
234 
RegisterTypeface(std::shared_ptr<Drawing::Typeface> & typeface)235 bool RSInterfaces::RegisterTypeface(std::shared_ptr<Drawing::Typeface>& typeface)
236 {
237     static std::function<std::shared_ptr<Drawing::Typeface> (uint64_t)> customTypefaceQueryfunc =
238             [](uint64_t globalUniqueId) -> std::shared_ptr<Drawing::Typeface> {
239         return RSTypefaceCache::Instance().GetDrawingTypefaceCache(globalUniqueId);
240     };
241 
242     static std::once_flag onceFlag;
243     std::call_once(onceFlag, []() {
244         Drawing::DrawOpItem::SetTypefaceQueryCallBack(customTypefaceQueryfunc);
245     });
246 
247     if (RSSystemProperties::GetUniRenderEnabled()) {
248         bool result = renderServiceClient_->RegisterTypeface(typeface);
249         if (result) {
250             RS_LOGD("RSInterfaces::RegisterTypeface: register typeface[%{public}u]",
251                     typeface->GetUniqueID());
252             uint64_t globalUniqueId = RSTypefaceCache::GenGlobalUniqueId(typeface->GetUniqueID());
253             RSTypefaceCache::Instance().CacheDrawingTypeface(globalUniqueId, typeface);
254         } else {
255             if (typeface != nullptr) {
256                 RS_LOGD("RSInterfaces:Failed to reg typeface, family name:%{public}s, uniqueid:%{public}u",
257                     typeface->GetFamilyName().c_str(), typeface->GetUniqueID());
258             }
259         }
260         return result;
261     }
262 
263     RS_LOGD("RSInterfaces::RegisterTypeface: register typeface[%{public}u]",
264         typeface->GetUniqueID());
265     uint64_t globalUniqueId = RSTypefaceCache::GenGlobalUniqueId(typeface->GetUniqueID());
266     RSTypefaceCache::Instance().CacheDrawingTypeface(globalUniqueId, typeface);
267     return true;
268 }
269 
UnRegisterTypeface(std::shared_ptr<Drawing::Typeface> & typeface)270 bool RSInterfaces::UnRegisterTypeface(std::shared_ptr<Drawing::Typeface>& typeface)
271 {
272     if (RSSystemProperties::GetUniRenderEnabled()) {
273         bool result = renderServiceClient_->UnRegisterTypeface(typeface);
274         if (result) {
275             uint64_t globalUniqueId = RSTypefaceCache::GenGlobalUniqueId(typeface->GetUniqueID());
276             RSTypefaceCache::Instance().RemoveDrawingTypefaceByGlobalUniqueId(globalUniqueId);
277         }
278         return result;
279     }
280 
281     RS_LOGD("RSInterfaces::UnRegisterTypeface: unregister typeface[%{public}u]",
282         typeface->GetUniqueID());
283     uint64_t globalUniqueId = RSTypefaceCache::GenGlobalUniqueId(typeface->GetUniqueID());
284     RSTypefaceCache::Instance().AddDelayDestroyQueue(globalUniqueId);
285     return true;
286 }
287 
SetGlobalDarkColorMode(bool isDark)288 bool RSInterfaces::SetGlobalDarkColorMode(bool isDark)
289 {
290     return renderServiceClient_->SetGlobalDarkColorMode(isDark);
291 }
292 
293 #ifndef ROSEN_ARKUI_X
SetVirtualScreenResolution(ScreenId id,uint32_t width,uint32_t height)294 int32_t RSInterfaces::SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height)
295 {
296     return renderServiceClient_->SetVirtualScreenResolution(id, width, height);
297 }
298 #endif // !ROSEN_ARKUI_X
SetVirtualMirrorScreenCanvasRotation(ScreenId id,bool canvasRotation)299 bool RSInterfaces::SetVirtualMirrorScreenCanvasRotation(ScreenId id, bool canvasRotation)
300 {
301     return renderServiceClient_->SetVirtualMirrorScreenCanvasRotation(id, canvasRotation);
302 }
303 
SetVirtualMirrorScreenScaleMode(ScreenId id,ScreenScaleMode scaleMode)304 bool RSInterfaces::SetVirtualMirrorScreenScaleMode(ScreenId id, ScreenScaleMode scaleMode)
305 {
306     return renderServiceClient_->SetVirtualMirrorScreenScaleMode(id, scaleMode);
307 }
308 
309 #ifndef ROSEN_ARKUI_X
GetVirtualScreenResolution(ScreenId id)310 RSVirtualScreenResolution RSInterfaces::GetVirtualScreenResolution(ScreenId id)
311 {
312     return renderServiceClient_->GetVirtualScreenResolution(id);
313 }
314 
MarkPowerOffNeedProcessOneFrame()315 void RSInterfaces::MarkPowerOffNeedProcessOneFrame()
316 {
317     RS_LOGD("[UL_POWER]RSInterfaces::MarkPowerOffNeedProcessOneFrame.");
318     renderServiceClient_->MarkPowerOffNeedProcessOneFrame();
319 }
320 
DisablePowerOffRenderControl(ScreenId id)321 void RSInterfaces::DisablePowerOffRenderControl(ScreenId id)
322 {
323     RS_LOGD("RSInterfaces::DisablePowerOffRenderControl.");
324     renderServiceClient_->DisablePowerOffRenderControl(id);
325 }
326 
SetScreenPowerStatus(ScreenId id,ScreenPowerStatus status)327 void RSInterfaces::SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status)
328 {
329     RS_LOGI("[UL_POWER]RSInterfaces::SetScreenPowerStatus: ScreenId: %{public}" PRIu64
330             ", ScreenPowerStatus: %{public}u",
331         id, static_cast<uint32_t>(status));
332     renderServiceClient_->SetScreenPowerStatus(id, status);
333 }
334 #endif // !ROSEN_ARKUI_X
TakeSurfaceCaptureForUIWithoutUni(NodeId id,std::shared_ptr<SurfaceCaptureCallback> callback,float scaleX,float scaleY)335 bool RSInterfaces::TakeSurfaceCaptureForUIWithoutUni(NodeId id,
336     std::shared_ptr<SurfaceCaptureCallback> callback, float scaleX, float scaleY)
337 {
338     std::function<void()> offscreenRenderTask = [scaleX, scaleY, callback, id, this]() -> void {
339         ROSEN_LOGD(
340             "RSInterfaces::TakeSurfaceCaptureForUIWithoutUni callback->OnOffscreenRender nodeId:"
341             "[%{public}" PRIu64 "]", id);
342         ROSEN_TRACE_BEGIN(HITRACE_TAG_GRAPHIC_AGP, "RSRenderThread::TakeSurfaceCaptureForUIWithoutUni");
343         std::shared_ptr<RSDividedUICapture> rsDividedUICapture =
344             std::make_shared<RSDividedUICapture>(id, scaleX, scaleY);
345         std::shared_ptr<Media::PixelMap> pixelmap = rsDividedUICapture->TakeLocalCapture();
346         ROSEN_TRACE_END(HITRACE_TAG_GRAPHIC_AGP);
347         callback->OnSurfaceCapture(pixelmap);
348     };
349     RSOffscreenRenderThread::Instance().PostTask(offscreenRenderTask);
350     return true;
351 }
352 
353 #ifndef ROSEN_ARKUI_X
GetScreenActiveMode(ScreenId id)354 RSScreenModeInfo RSInterfaces::GetScreenActiveMode(ScreenId id)
355 {
356     return renderServiceClient_->GetScreenActiveMode(id);
357 }
358 
GetScreenSupportedModes(ScreenId id)359 std::vector<RSScreenModeInfo> RSInterfaces::GetScreenSupportedModes(ScreenId id)
360 {
361     return renderServiceClient_->GetScreenSupportedModes(id);
362 }
363 
GetScreenCapability(ScreenId id)364 RSScreenCapability RSInterfaces::GetScreenCapability(ScreenId id)
365 {
366     return renderServiceClient_->GetScreenCapability(id);
367 }
368 
GetScreenPowerStatus(ScreenId id)369 ScreenPowerStatus RSInterfaces::GetScreenPowerStatus(ScreenId id)
370 {
371     return renderServiceClient_->GetScreenPowerStatus(id);
372 }
373 
GetScreenData(ScreenId id)374 RSScreenData RSInterfaces::GetScreenData(ScreenId id)
375 {
376     return renderServiceClient_->GetScreenData(id);
377 }
378 #endif // !ROSEN_ARKUI_X
GetScreenBacklight(ScreenId id)379 int32_t RSInterfaces::GetScreenBacklight(ScreenId id)
380 {
381     return renderServiceClient_->GetScreenBacklight(id);
382 }
383 
SetScreenBacklight(ScreenId id,uint32_t level)384 void RSInterfaces::SetScreenBacklight(ScreenId id, uint32_t level)
385 {
386     RS_LOGD("RSInterfaces::SetScreenBacklight: ScreenId: %{public}" PRIu64 ", level: %{public}u", id, level);
387     renderServiceClient_->SetScreenBacklight(id, level);
388 }
389 
GetScreenSupportedColorGamuts(ScreenId id,std::vector<ScreenColorGamut> & mode)390 int32_t RSInterfaces::GetScreenSupportedColorGamuts(ScreenId id, std::vector<ScreenColorGamut>& mode)
391 {
392     return renderServiceClient_->GetScreenSupportedColorGamuts(id, mode);
393 }
394 
GetScreenSupportedMetaDataKeys(ScreenId id,std::vector<ScreenHDRMetadataKey> & keys)395 int32_t RSInterfaces::GetScreenSupportedMetaDataKeys(ScreenId id, std::vector<ScreenHDRMetadataKey>& keys)
396 {
397     return renderServiceClient_->GetScreenSupportedMetaDataKeys(id, keys);
398 }
399 
GetScreenColorGamut(ScreenId id,ScreenColorGamut & mode)400 int32_t RSInterfaces::GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode)
401 {
402     return renderServiceClient_->GetScreenColorGamut(id, mode);
403 }
404 
SetScreenColorGamut(ScreenId id,int32_t modeIdx)405 int32_t RSInterfaces::SetScreenColorGamut(ScreenId id, int32_t modeIdx)
406 {
407     return renderServiceClient_->SetScreenColorGamut(id, modeIdx);
408 }
409 
SetScreenGamutMap(ScreenId id,ScreenGamutMap mode)410 int32_t RSInterfaces::SetScreenGamutMap(ScreenId id, ScreenGamutMap mode)
411 {
412     return renderServiceClient_->SetScreenGamutMap(id, mode);
413 }
414 
SetScreenCorrection(ScreenId id,ScreenRotation screenRotation)415 int32_t RSInterfaces::SetScreenCorrection(ScreenId id, ScreenRotation screenRotation)
416 {
417     return renderServiceClient_->SetScreenCorrection(id, screenRotation);
418 }
419 
GetScreenGamutMap(ScreenId id,ScreenGamutMap & mode)420 int32_t RSInterfaces::GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode)
421 {
422     return renderServiceClient_->GetScreenGamutMap(id, mode);
423 }
424 
CreateVSyncReceiver(const std::string & name,const std::shared_ptr<OHOS::AppExecFwk::EventHandler> & looper)425 std::shared_ptr<VSyncReceiver> RSInterfaces::CreateVSyncReceiver(
426     const std::string& name,
427     const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper)
428 {
429     return renderServiceClient_->CreateVSyncReceiver(name, looper);
430 }
431 
CreateVSyncReceiver(const std::string & name,uint64_t id,const std::shared_ptr<OHOS::AppExecFwk::EventHandler> & looper,NodeId windowNodeId)432 std::shared_ptr<VSyncReceiver> RSInterfaces::CreateVSyncReceiver(
433     const std::string& name,
434     uint64_t id,
435     const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper,
436     NodeId windowNodeId)
437 {
438     return renderServiceClient_->CreateVSyncReceiver(name, looper, id, windowNodeId);
439 }
440 
CreatePixelMapFromSurfaceId(uint64_t surfaceId,const Rect & srcRect)441 std::shared_ptr<Media::PixelMap> RSInterfaces::CreatePixelMapFromSurfaceId(uint64_t surfaceId, const Rect &srcRect)
442 {
443     return renderServiceClient_->CreatePixelMapFromSurfaceId(surfaceId, srcRect);
444 }
445 
GetScreenHDRCapability(ScreenId id,RSScreenHDRCapability & screenHdrCapability)446 int32_t RSInterfaces::GetScreenHDRCapability(ScreenId id, RSScreenHDRCapability& screenHdrCapability)
447 {
448     return renderServiceClient_->GetScreenHDRCapability(id, screenHdrCapability);
449 }
450 
GetPixelFormat(ScreenId id,GraphicPixelFormat & pixelFormat)451 int32_t RSInterfaces::GetPixelFormat(ScreenId id, GraphicPixelFormat& pixelFormat)
452 {
453     return renderServiceClient_->GetPixelFormat(id, pixelFormat);
454 }
455 
SetPixelFormat(ScreenId id,GraphicPixelFormat pixelFormat)456 int32_t RSInterfaces::SetPixelFormat(ScreenId id, GraphicPixelFormat pixelFormat)
457 {
458     return renderServiceClient_->SetPixelFormat(id, pixelFormat);
459 }
460 
GetScreenSupportedHDRFormats(ScreenId id,std::vector<ScreenHDRFormat> & hdrFormats)461 int32_t RSInterfaces::GetScreenSupportedHDRFormats(ScreenId id, std::vector<ScreenHDRFormat>& hdrFormats)
462 {
463     return renderServiceClient_->GetScreenSupportedHDRFormats(id, hdrFormats);
464 }
465 
GetScreenHDRFormat(ScreenId id,ScreenHDRFormat & hdrFormat)466 int32_t RSInterfaces::GetScreenHDRFormat(ScreenId id, ScreenHDRFormat& hdrFormat)
467 {
468     return renderServiceClient_->GetScreenHDRFormat(id, hdrFormat);
469 }
470 
SetScreenHDRFormat(ScreenId id,int32_t modeIdx)471 int32_t RSInterfaces::SetScreenHDRFormat(ScreenId id, int32_t modeIdx)
472 {
473     return renderServiceClient_->SetScreenHDRFormat(id, modeIdx);
474 }
475 
GetScreenSupportedColorSpaces(ScreenId id,std::vector<GraphicCM_ColorSpaceType> & colorSpaces)476 int32_t RSInterfaces::GetScreenSupportedColorSpaces(ScreenId id, std::vector<GraphicCM_ColorSpaceType>& colorSpaces)
477 {
478     return renderServiceClient_->GetScreenSupportedColorSpaces(id, colorSpaces);
479 }
480 
GetScreenColorSpace(ScreenId id,GraphicCM_ColorSpaceType & colorSpace)481 int32_t RSInterfaces::GetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType& colorSpace)
482 {
483     return renderServiceClient_->GetScreenColorSpace(id, colorSpace);
484 }
485 
SetScreenColorSpace(ScreenId id,GraphicCM_ColorSpaceType colorSpace)486 int32_t RSInterfaces::SetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType colorSpace)
487 {
488     return renderServiceClient_->SetScreenColorSpace(id, colorSpace);
489 }
490 
GetScreenType(ScreenId id,RSScreenType & screenType)491 int32_t RSInterfaces::GetScreenType(ScreenId id, RSScreenType& screenType)
492 {
493     return renderServiceClient_->GetScreenType(id, screenType);
494 }
495 
SetScreenSkipFrameInterval(ScreenId id,uint32_t skipFrameInterval)496 int32_t RSInterfaces::SetScreenSkipFrameInterval(ScreenId id, uint32_t skipFrameInterval)
497 {
498     return renderServiceClient_->SetScreenSkipFrameInterval(id, skipFrameInterval);
499 }
500 
SetSystemAnimatedScenes(SystemAnimatedScenes systemAnimatedScenes)501 bool RSInterfaces::SetSystemAnimatedScenes(SystemAnimatedScenes systemAnimatedScenes)
502 {
503     return renderServiceClient_->SetSystemAnimatedScenes(systemAnimatedScenes);
504 }
505 
RegisterOcclusionChangeCallback(const OcclusionChangeCallback & callback)506 int32_t RSInterfaces::RegisterOcclusionChangeCallback(const OcclusionChangeCallback& callback)
507 {
508     return renderServiceClient_->RegisterOcclusionChangeCallback(callback);
509 }
510 
RegisterSurfaceOcclusionChangeCallback(NodeId id,const SurfaceOcclusionChangeCallback & callback,std::vector<float> & partitionPoints)511 int32_t RSInterfaces::RegisterSurfaceOcclusionChangeCallback(
512     NodeId id, const SurfaceOcclusionChangeCallback& callback, std::vector<float>& partitionPoints)
513 {
514     return renderServiceClient_->RegisterSurfaceOcclusionChangeCallback(id, callback, partitionPoints);
515 }
516 
UnRegisterSurfaceOcclusionChangeCallback(NodeId id)517 int32_t RSInterfaces::UnRegisterSurfaceOcclusionChangeCallback(NodeId id)
518 {
519     return renderServiceClient_->UnRegisterSurfaceOcclusionChangeCallback(id);
520 }
521 
RegisterHgmConfigChangeCallback(const HgmConfigChangeCallback & callback)522 int32_t RSInterfaces::RegisterHgmConfigChangeCallback(const HgmConfigChangeCallback& callback)
523 {
524     return renderServiceClient_->RegisterHgmConfigChangeCallback(callback);
525 }
526 
RegisterHgmRefreshRateModeChangeCallback(const HgmRefreshRateModeChangeCallback & callback)527 int32_t RSInterfaces::RegisterHgmRefreshRateModeChangeCallback(const HgmRefreshRateModeChangeCallback& callback)
528 {
529     return renderServiceClient_->RegisterHgmRefreshRateModeChangeCallback(callback);
530 }
531 
RegisterHgmRefreshRateUpdateCallback(const HgmRefreshRateUpdateCallback & callback)532 int32_t RSInterfaces::RegisterHgmRefreshRateUpdateCallback(const HgmRefreshRateUpdateCallback& callback)
533 {
534     return renderServiceClient_->RegisterHgmRefreshRateUpdateCallback(callback);
535 }
536 
UnRegisterHgmRefreshRateUpdateCallback()537 int32_t RSInterfaces::UnRegisterHgmRefreshRateUpdateCallback()
538 {
539     return renderServiceClient_->RegisterHgmRefreshRateUpdateCallback(nullptr);
540 }
541 
SetAppWindowNum(uint32_t num)542 void RSInterfaces::SetAppWindowNum(uint32_t num)
543 {
544     renderServiceClient_->SetAppWindowNum(num);
545 }
546 
ShowWatermark(const std::shared_ptr<Media::PixelMap> & watermarkImg,bool isShow)547 void RSInterfaces::ShowWatermark(const std::shared_ptr<Media::PixelMap> &watermarkImg, bool isShow)
548 {
549     renderServiceClient_->ShowWatermark(watermarkImg, isShow);
550 }
551 
ResizeVirtualScreen(ScreenId id,uint32_t width,uint32_t height)552 int32_t RSInterfaces::ResizeVirtualScreen(ScreenId id, uint32_t width, uint32_t height)
553 {
554     return renderServiceClient_->ResizeVirtualScreen(id, width, height);
555 }
556 
557 #ifndef ROSEN_ARKUI_X
GetMemoryGraphic(int pid)558 MemoryGraphic RSInterfaces::GetMemoryGraphic(int pid)
559 {
560     return renderServiceClient_->GetMemoryGraphic(pid);
561 }
562 
GetMemoryGraphics()563 std::vector<MemoryGraphic> RSInterfaces::GetMemoryGraphics()
564 {
565     return renderServiceClient_->GetMemoryGraphics();
566 }
567 #endif // !ROSEN_ARKUI_X
GetTotalAppMemSize(float & cpuMemSize,float & gpuMemSize)568 bool RSInterfaces::GetTotalAppMemSize(float& cpuMemSize, float& gpuMemSize)
569 {
570     return renderServiceClient_->GetTotalAppMemSize(cpuMemSize, gpuMemSize);
571 }
572 
ReportJankStats()573 void RSInterfaces::ReportJankStats()
574 {
575     renderServiceClient_->ReportJankStats();
576 }
577 
ReportEventResponse(DataBaseRs info)578 void RSInterfaces::ReportEventResponse(DataBaseRs info)
579 {
580     renderServiceClient_->ReportEventResponse(info);
581 }
582 
ReportEventComplete(DataBaseRs info)583 void RSInterfaces::ReportEventComplete(DataBaseRs info)
584 {
585     renderServiceClient_->ReportEventComplete(info);
586 }
587 
ReportEventJankFrame(DataBaseRs info)588 void RSInterfaces::ReportEventJankFrame(DataBaseRs info)
589 {
590     renderServiceClient_->ReportEventJankFrame(info);
591 }
592 
ReportGameStateData(GameStateData info)593 void RSInterfaces::ReportGameStateData(GameStateData info)
594 {
595     renderServiceClient_->ReportGameStateData(info);
596 }
597 
EnableCacheForRotation()598 void RSInterfaces::EnableCacheForRotation()
599 {
600     renderServiceClient_->SetCacheEnabledForRotation(true);
601 }
602 
SetDefaultDeviceRotationOffset(uint32_t offset)603 void RSInterfaces::SetDefaultDeviceRotationOffset(uint32_t offset)
604 {
605     renderServiceClient_->SetDefaultDeviceRotationOffset(offset);
606 }
607 
NotifyLightFactorStatus(bool isSafe)608 void RSInterfaces::NotifyLightFactorStatus(bool isSafe)
609 {
610     renderServiceClient_->NotifyLightFactorStatus(isSafe);
611 }
612 
NotifyPackageEvent(uint32_t listSize,const std::vector<std::string> & packageList)613 void RSInterfaces::NotifyPackageEvent(uint32_t listSize, const std::vector<std::string>& packageList)
614 {
615     renderServiceClient_->NotifyPackageEvent(listSize, packageList);
616 }
617 
NotifyRefreshRateEvent(const EventInfo & eventInfo)618 void RSInterfaces::NotifyRefreshRateEvent(const EventInfo& eventInfo)
619 {
620     renderServiceClient_->NotifyRefreshRateEvent(eventInfo);
621 }
622 
NotifyTouchEvent(int32_t touchStatus,int32_t touchCnt)623 void RSInterfaces::NotifyTouchEvent(int32_t touchStatus, int32_t touchCnt)
624 {
625     renderServiceClient_->NotifyTouchEvent(touchStatus, touchCnt);
626 }
627 
NotifyDynamicModeEvent(bool enableDynamicMode)628 void RSInterfaces::NotifyDynamicModeEvent(bool enableDynamicMode)
629 {
630     renderServiceClient_->NotifyDynamicModeEvent(enableDynamicMode);
631 }
632 
DisableCacheForRotation()633 void RSInterfaces::DisableCacheForRotation()
634 {
635     renderServiceClient_->SetCacheEnabledForRotation(false);
636 }
637 
SetOnRemoteDiedCallback(const OnRemoteDiedCallback & callback)638 void RSInterfaces::SetOnRemoteDiedCallback(const OnRemoteDiedCallback& callback)
639 {
640     renderServiceClient_->SetOnRemoteDiedCallback(callback);
641 }
642 
GetActiveDirtyRegionInfo() const643 std::vector<ActiveDirtyRegionInfo> RSInterfaces::GetActiveDirtyRegionInfo() const
644 {
645     const auto& activeDirtyRegionInfo = renderServiceClient_->GetActiveDirtyRegionInfo();
646     return activeDirtyRegionInfo;
647 }
648 
GetGlobalDirtyRegionInfo() const649 GlobalDirtyRegionInfo RSInterfaces::GetGlobalDirtyRegionInfo() const
650 {
651     const auto& globalDirtyRegionInfo = renderServiceClient_->GetGlobalDirtyRegionInfo();
652     return globalDirtyRegionInfo;
653 }
654 
GetLayerComposeInfo() const655 LayerComposeInfo RSInterfaces::GetLayerComposeInfo() const
656 {
657     const auto& layerComposeInfo = renderServiceClient_->GetLayerComposeInfo();
658     return layerComposeInfo;
659 }
660 
GetHwcDisabledReasonInfo() const661 HwcDisabledReasonInfos RSInterfaces::GetHwcDisabledReasonInfo() const
662 {
663     const auto& hwcDisabledReasonInfo = renderServiceClient_->GetHwcDisabledReasonInfo();
664     return hwcDisabledReasonInfo;
665 }
666 
SetVmaCacheStatus(bool flag)667 void RSInterfaces::SetVmaCacheStatus(bool flag)
668 {
669     renderServiceClient_->SetVmaCacheStatus(flag);
670 }
671 
672 #ifdef TP_FEATURE_ENABLE
SetTpFeatureConfig(int32_t feature,const char * config)673 void RSInterfaces::SetTpFeatureConfig(int32_t feature, const char* config)
674 {
675     renderServiceClient_->SetTpFeatureConfig(feature, config);
676 }
677 #endif
678 
SetVirtualScreenUsingStatus(bool isVirtualScreenUsingStatus)679 void RSInterfaces::SetVirtualScreenUsingStatus(bool isVirtualScreenUsingStatus)
680 {
681     renderServiceClient_->SetVirtualScreenUsingStatus(isVirtualScreenUsingStatus);
682 }
683 
SetCurtainScreenUsingStatus(bool isCurtainScreenOn)684 void RSInterfaces::SetCurtainScreenUsingStatus(bool isCurtainScreenOn)
685 {
686     renderServiceClient_->SetCurtainScreenUsingStatus(isCurtainScreenOn);
687 }
688 
RegisterUIExtensionCallback(uint64_t userId,const UIExtensionCallback & callback)689 int32_t RSInterfaces::RegisterUIExtensionCallback(uint64_t userId, const UIExtensionCallback& callback)
690 {
691     return renderServiceClient_->RegisterUIExtensionCallback(userId, callback);
692 }
693 
SetAncoForceDoDirect(bool direct)694 bool RSInterfaces::SetAncoForceDoDirect(bool direct)
695 {
696     return renderServiceClient_->SetAncoForceDoDirect(direct);
697 }
698 
RegisterSurfaceBufferCallback(pid_t pid,uint64_t uid,std::shared_ptr<SurfaceBufferCallback> callback)699 bool RSInterfaces::RegisterSurfaceBufferCallback(pid_t pid, uint64_t uid,
700     std::shared_ptr<SurfaceBufferCallback> callback)
701 {
702     if (callback == nullptr) {
703         ROSEN_LOGE("RSInterfaces::RegisterSurfaceBufferCallback callback == nullptr.");
704         return false;
705     }
706     RSSurfaceBufferCallbackManager::Instance().RegisterSurfaceBufferCallback(pid, uid,
707         new (std::nothrow) RSDefaultSurfaceBufferCallback (
708             [callback](uint64_t uid, const std::vector<uint32_t>& bufferIds) {
709                 callback->OnFinish(uid, bufferIds);
710             }
711         )
712     );
713     return renderServiceClient_->RegisterSurfaceBufferCallback(pid, uid, callback);
714 }
715 
UnregisterSurfaceBufferCallback(pid_t pid,uint64_t uid)716 bool RSInterfaces::UnregisterSurfaceBufferCallback(pid_t pid, uint64_t uid)
717 {
718     RSSurfaceBufferCallbackManager::Instance().UnregisterSurfaceBufferCallback(pid, uid);
719     return renderServiceClient_->UnregisterSurfaceBufferCallback(pid, uid);
720 }
721 
SetLayerTop(const std::string & nodeIdStr,bool isTop)722 void RSInterfaces::SetLayerTop(const std::string &nodeIdStr, bool isTop)
723 {
724     renderServiceClient_->SetLayerTop(nodeIdStr, isTop);
725 }
726 } // namespace Rosen
727 } // namespace OHOS
728