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