1 /*
2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <cstdint>
17 #include <functional>
18
19 #include "rs_interfaces.h"
20 #include "rs_trace.h"
21
22 #include "platform/common/rs_system_properties.h"
23 #include "pipeline/rs_render_node.h"
24 #include "pipeline/rs_surface_buffer_callback_manager.h"
25 #include "offscreen_render/rs_offscreen_render_thread.h"
26 #include "feature/hyper_graphic_manager/rs_frame_rate_policy.h"
27 #include "feature/ui_capture/rs_divided_ui_capture.h"
28 #include "ui/rs_proxy_node.h"
29 #include "platform/common/rs_log.h"
30 #include "render/rs_typeface_cache.h"
31
32 namespace OHOS {
33 namespace Rosen {
34 #ifdef ROSEN_OHOS
35 namespace {
36 constexpr uint32_t WATERMARK_PIXELMAP_SIZE_LIMIT = 500 * 1024;
37 constexpr uint32_t WATERMARK_NAME_LENGTH_LIMIT = 128;
38 constexpr int32_t SECURITYMASK_IMAGE_WIDTH_LIMIT = 4096;
39 constexpr int32_t SECURITYMASK_IMAGE_HEIGHT_LIMIT = 4096;
40 }
41 #endif
GetInstance()42 RSInterfaces &RSInterfaces::GetInstance()
43 {
44 static RSInterfaces instance;
45 return instance;
46 }
47
RSInterfaces()48 RSInterfaces::RSInterfaces() : renderServiceClient_(std::make_unique<RSRenderServiceClient>())
49 {
50 }
51
~RSInterfaces()52 RSInterfaces::~RSInterfaces() noexcept
53 {
54 }
55
SetFocusAppInfo(FocusAppInfo & info)56 int32_t RSInterfaces::SetFocusAppInfo(FocusAppInfo& info)
57 {
58 int32_t pid = info.pid;
59 int32_t uid = info.uid;
60 const std::string bundleName = info.bundleName;
61 const std::string abilityName = info.abilityName;
62 uint64_t focusNodeId = info.focusNodeId;
63 return renderServiceClient_->SetFocusAppInfo(pid, uid, bundleName, abilityName, focusNodeId);
64 }
65
GetDefaultScreenId()66 ScreenId RSInterfaces::GetDefaultScreenId()
67 {
68 return renderServiceClient_->GetDefaultScreenId();
69 }
70
GetActiveScreenId()71 ScreenId RSInterfaces::GetActiveScreenId()
72 {
73 return renderServiceClient_->GetActiveScreenId();
74 }
75
GetAllScreenIds()76 std::vector<ScreenId> RSInterfaces::GetAllScreenIds()
77 {
78 return renderServiceClient_->GetAllScreenIds();
79 }
80
81 #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)82 ScreenId RSInterfaces::CreateVirtualScreen(
83 const std::string &name,
84 uint32_t width,
85 uint32_t height,
86 sptr<Surface> surface,
87 ScreenId mirrorId,
88 int flags,
89 std::vector<NodeId> whiteList)
90 {
91 return renderServiceClient_->CreateVirtualScreen(name, width, height, surface, mirrorId, flags, whiteList);
92 }
93
SetVirtualScreenBlackList(ScreenId id,std::vector<NodeId> & blackListVector)94 int32_t RSInterfaces::SetVirtualScreenBlackList(ScreenId id, std::vector<NodeId>& blackListVector)
95 {
96 return renderServiceClient_->SetVirtualScreenBlackList(id, blackListVector);
97 }
98
AddVirtualScreenBlackList(ScreenId id,std::vector<NodeId> & blackListVector)99 int32_t RSInterfaces::AddVirtualScreenBlackList(ScreenId id, std::vector<NodeId>& blackListVector)
100 {
101 return renderServiceClient_->AddVirtualScreenBlackList(id, blackListVector);
102 }
103
RemoveVirtualScreenBlackList(ScreenId id,std::vector<NodeId> & blackListVector)104 int32_t RSInterfaces::RemoveVirtualScreenBlackList(ScreenId id, std::vector<NodeId>& blackListVector)
105 {
106 return renderServiceClient_->RemoveVirtualScreenBlackList(id, blackListVector);
107 }
108
SetVirtualScreenSecurityExemptionList(ScreenId id,const std::vector<NodeId> & securityExemptionList)109 int32_t RSInterfaces::SetVirtualScreenSecurityExemptionList(
110 ScreenId id,
111 const std::vector<NodeId>& securityExemptionList)
112 {
113 return renderServiceClient_->SetVirtualScreenSecurityExemptionList(id, securityExemptionList);
114 }
115
SetScreenSecurityMask(ScreenId id,std::shared_ptr<Media::PixelMap> securityMask)116 int32_t RSInterfaces::SetScreenSecurityMask(ScreenId id, std::shared_ptr<Media::PixelMap> securityMask)
117 {
118 Media::ImageInfo imageInfo;
119 if (securityMask) {
120 securityMask->GetImageInfo(imageInfo);
121 }
122 if (securityMask && (imageInfo.size.width > SECURITYMASK_IMAGE_WIDTH_LIMIT ||
123 imageInfo.size.height > SECURITYMASK_IMAGE_HEIGHT_LIMIT)) {
124 ROSEN_LOGE("SetScreenSecurityMask failed, securityMask width: %{public}d, height: %{public}d is error",
125 imageInfo.size.width, imageInfo.size.height);
126 return RS_CONNECTION_ERROR;
127 }
128 return renderServiceClient_->SetScreenSecurityMask(id, std::move(securityMask));
129 }
130
SetMirrorScreenVisibleRect(ScreenId id,const Rect & mainScreenRect,bool supportRotation)131 int32_t RSInterfaces::SetMirrorScreenVisibleRect(ScreenId id, const Rect& mainScreenRect, bool supportRotation)
132 {
133 return renderServiceClient_->SetMirrorScreenVisibleRect(id, mainScreenRect, supportRotation);
134 }
135
SetCastScreenEnableSkipWindow(ScreenId id,bool enable)136 int32_t RSInterfaces::SetCastScreenEnableSkipWindow(ScreenId id, bool enable)
137 {
138 return renderServiceClient_->SetCastScreenEnableSkipWindow(id, enable);
139 }
140
SetVirtualScreenSurface(ScreenId id,sptr<Surface> surface)141 int32_t RSInterfaces::SetVirtualScreenSurface(ScreenId id, sptr<Surface> surface)
142 {
143 return renderServiceClient_->SetVirtualScreenSurface(id, surface);
144 }
145 #endif
146
RemoveVirtualScreen(ScreenId id)147 void RSInterfaces::RemoveVirtualScreen(ScreenId id)
148 {
149 renderServiceClient_->RemoveVirtualScreen(id);
150 }
151
SetWatermark(const std::string & name,std::shared_ptr<Media::PixelMap> watermark)152 bool RSInterfaces::SetWatermark(const std::string& name, std::shared_ptr<Media::PixelMap> watermark)
153 {
154 #ifdef ROSEN_OHOS
155 if (renderServiceClient_ == nullptr) {
156 return false;
157 }
158 if (name.length() > WATERMARK_NAME_LENGTH_LIMIT || name.empty()) {
159 ROSEN_LOGE("SetWatermark failed, name[%{public}s] is error.", name.c_str());
160 return false;
161 }
162 if (watermark && (watermark->IsAstc() || watermark->GetCapacity() > WATERMARK_PIXELMAP_SIZE_LIMIT)) {
163 ROSEN_LOGE("SetWatermark failed, watermark[%{public}d, %{public}d] is error",
164 watermark->IsAstc(), watermark->GetCapacity());
165 return false;
166 }
167 return renderServiceClient_->SetWatermark(name, watermark);
168 #else
169 return false;
170 #endif
171 }
172
173 #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR
SetPointerColorInversionConfig(float darkBuffer,float brightBuffer,int64_t interval,int32_t rangeSize)174 int32_t RSInterfaces::SetPointerColorInversionConfig(float darkBuffer, float brightBuffer,
175 int64_t interval, int32_t rangeSize)
176 {
177 if (renderServiceClient_ == nullptr) {
178 return StatusCode::RENDER_SERVICE_NULL;
179 }
180 return renderServiceClient_->SetPointerColorInversionConfig(darkBuffer, brightBuffer, interval, rangeSize);
181 }
182
SetPointerColorInversionEnabled(bool enable)183 int32_t RSInterfaces::SetPointerColorInversionEnabled(bool enable)
184 {
185 if (renderServiceClient_ == nullptr) {
186 return StatusCode::RENDER_SERVICE_NULL;
187 }
188 return renderServiceClient_->SetPointerColorInversionEnabled(enable);
189 }
190
RegisterPointerLuminanceChangeCallback(const PointerLuminanceChangeCallback & callback)191 int32_t RSInterfaces::RegisterPointerLuminanceChangeCallback(const PointerLuminanceChangeCallback &callback)
192 {
193 if (renderServiceClient_ == nullptr) {
194 return StatusCode::RENDER_SERVICE_NULL;
195 }
196 return renderServiceClient_->RegisterPointerLuminanceChangeCallback(callback);
197 }
198
UnRegisterPointerLuminanceChangeCallback()199 int32_t RSInterfaces::UnRegisterPointerLuminanceChangeCallback()
200 {
201 if (renderServiceClient_ == nullptr) {
202 return StatusCode::RENDER_SERVICE_NULL;
203 }
204 return renderServiceClient_->UnRegisterPointerLuminanceChangeCallback();
205 }
206 #endif
207
SetScreenChangeCallback(const ScreenChangeCallback & callback)208 int32_t RSInterfaces::SetScreenChangeCallback(const ScreenChangeCallback &callback)
209 {
210 return renderServiceClient_->SetScreenChangeCallback(callback);
211 }
212
GetPixelMapByProcessId(std::vector<PixelMapInfo> & pixelMapInfoVector,pid_t pid)213 int32_t RSInterfaces::GetPixelMapByProcessId(std::vector<PixelMapInfo>& pixelMapInfoVector, pid_t pid)
214 {
215 return renderServiceClient_->GetPixelMapByProcessId(pixelMapInfoVector, pid);
216 }
217
TakeSurfaceCapture(std::shared_ptr<RSSurfaceNode> node,std::shared_ptr<SurfaceCaptureCallback> callback,RSSurfaceCaptureConfig captureConfig)218 bool RSInterfaces::TakeSurfaceCapture(std::shared_ptr<RSSurfaceNode> node,
219 std::shared_ptr<SurfaceCaptureCallback> callback, RSSurfaceCaptureConfig captureConfig)
220 {
221 if (!node) {
222 ROSEN_LOGE("%{public}s node is nullptr", __func__);
223 return false;
224 }
225 return renderServiceClient_->TakeSurfaceCapture(node->GetId(), callback, captureConfig);
226 }
227
TakeSurfaceCaptureWithBlur(std::shared_ptr<RSSurfaceNode> node,std::shared_ptr<SurfaceCaptureCallback> callback,RSSurfaceCaptureConfig captureConfig,float blurRadius)228 bool RSInterfaces::TakeSurfaceCaptureWithBlur(std::shared_ptr<RSSurfaceNode> node,
229 std::shared_ptr<SurfaceCaptureCallback> callback, RSSurfaceCaptureConfig captureConfig, float blurRadius)
230 {
231 if (blurRadius < 1) {
232 ROSEN_LOGW("%{public}s no blur effect", __func__);
233 return TakeSurfaceCapture(node, callback, captureConfig);
234 }
235 if (!node) {
236 ROSEN_LOGE("%{public}s node is nullptr", __func__);
237 return false;
238 }
239 RSSurfaceCaptureBlurParam blurParam;
240 blurParam.isNeedBlur = true;
241 blurParam.blurRadius = blurRadius;
242 return renderServiceClient_->TakeSurfaceCapture(node->GetId(), callback, captureConfig, blurParam);
243 }
244
TakeSelfSurfaceCapture(std::shared_ptr<RSSurfaceNode> node,std::shared_ptr<SurfaceCaptureCallback> callback,RSSurfaceCaptureConfig captureConfig)245 bool RSInterfaces::TakeSelfSurfaceCapture(std::shared_ptr<RSSurfaceNode> node,
246 std::shared_ptr<SurfaceCaptureCallback> callback, RSSurfaceCaptureConfig captureConfig)
247 {
248 if (!node) {
249 ROSEN_LOGE("%{public}s node is nullptr", __func__);
250 return false;
251 }
252 return renderServiceClient_->TakeSelfSurfaceCapture(node->GetId(), callback, captureConfig);
253 }
254
SetWindowFreezeImmediately(std::shared_ptr<RSSurfaceNode> node,bool isFreeze,std::shared_ptr<SurfaceCaptureCallback> callback,RSSurfaceCaptureConfig captureConfig,float blurRadius)255 bool RSInterfaces::SetWindowFreezeImmediately(std::shared_ptr<RSSurfaceNode> node, bool isFreeze,
256 std::shared_ptr<SurfaceCaptureCallback> callback, RSSurfaceCaptureConfig captureConfig, float blurRadius)
257 {
258 if (!node) {
259 ROSEN_LOGE("%{public}s node is nullptr", __func__);
260 return false;
261 }
262 RSSurfaceCaptureBlurParam blurParam;
263 if (ROSEN_GE(blurRadius, 1.f)) {
264 blurParam.isNeedBlur = true;
265 blurParam.blurRadius = blurRadius;
266 }
267 return renderServiceClient_->SetWindowFreezeImmediately(
268 node->GetId(), isFreeze, callback, captureConfig, blurParam);
269 }
270
SetHwcNodeBounds(int64_t rsNodeId,float positionX,float positionY,float positionZ,float positionW)271 bool RSInterfaces::SetHwcNodeBounds(int64_t rsNodeId, float positionX, float positionY,
272 float positionZ, float positionW)
273 {
274 return renderServiceClient_->SetHwcNodeBounds(rsNodeId, positionX, positionY, positionZ, positionW);
275 }
276
TakeSurfaceCapture(std::shared_ptr<RSDisplayNode> node,std::shared_ptr<SurfaceCaptureCallback> callback,RSSurfaceCaptureConfig captureConfig)277 bool RSInterfaces::TakeSurfaceCapture(std::shared_ptr<RSDisplayNode> node,
278 std::shared_ptr<SurfaceCaptureCallback> callback, RSSurfaceCaptureConfig captureConfig)
279 {
280 if (!node) {
281 ROSEN_LOGE("%{public}s node is nullptr", __func__);
282 return false;
283 }
284 return renderServiceClient_->TakeSurfaceCapture(node->GetId(), callback, captureConfig);
285 }
286
TakeSurfaceCapture(NodeId id,std::shared_ptr<SurfaceCaptureCallback> callback,RSSurfaceCaptureConfig captureConfig)287 bool RSInterfaces::TakeSurfaceCapture(NodeId id,
288 std::shared_ptr<SurfaceCaptureCallback> callback, RSSurfaceCaptureConfig captureConfig)
289 {
290 return renderServiceClient_->TakeSurfaceCapture(id, callback, captureConfig);
291 }
292
293 #ifndef ROSEN_ARKUI_X
SetScreenActiveMode(ScreenId id,uint32_t modeId)294 void RSInterfaces::SetScreenActiveMode(ScreenId id, uint32_t modeId)
295 {
296 renderServiceClient_->SetScreenActiveMode(id, modeId);
297 }
298 #endif // !ROSEN_ARKUI_X
SetScreenRefreshRate(ScreenId id,int32_t sceneId,int32_t rate)299 void RSInterfaces::SetScreenRefreshRate(ScreenId id, int32_t sceneId, int32_t rate)
300 {
301 renderServiceClient_->SetScreenRefreshRate(id, sceneId, rate);
302 }
303
SetRefreshRateMode(int32_t refreshRateMode)304 void RSInterfaces::SetRefreshRateMode(int32_t refreshRateMode)
305 {
306 renderServiceClient_->SetRefreshRateMode(refreshRateMode);
307 }
308
SyncFrameRateRange(FrameRateLinkerId id,const FrameRateRange & range,int32_t animatorExpectedFrameRate)309 void RSInterfaces::SyncFrameRateRange(FrameRateLinkerId id, const FrameRateRange& range,
310 int32_t animatorExpectedFrameRate)
311 {
312 renderServiceClient_->SyncFrameRateRange(id, range, animatorExpectedFrameRate);
313 }
314
GetScreenCurrentRefreshRate(ScreenId id)315 uint32_t RSInterfaces::GetScreenCurrentRefreshRate(ScreenId id)
316 {
317 return renderServiceClient_->GetScreenCurrentRefreshRate(id);
318 }
319
GetCurrentRefreshRateMode()320 int32_t RSInterfaces::GetCurrentRefreshRateMode()
321 {
322 return renderServiceClient_->GetCurrentRefreshRateMode();
323 }
324
GetScreenSupportedRefreshRates(ScreenId id)325 std::vector<int32_t> RSInterfaces::GetScreenSupportedRefreshRates(ScreenId id)
326 {
327 return renderServiceClient_->GetScreenSupportedRefreshRates(id);
328 }
329
GetShowRefreshRateEnabled()330 bool RSInterfaces::GetShowRefreshRateEnabled()
331 {
332 return renderServiceClient_->GetShowRefreshRateEnabled();
333 }
334
SetShowRefreshRateEnabled(bool enabled,int32_t type)335 void RSInterfaces::SetShowRefreshRateEnabled(bool enabled, int32_t type)
336 {
337 return renderServiceClient_->SetShowRefreshRateEnabled(enabled, type);
338 }
339
GetRealtimeRefreshRate(ScreenId id)340 uint32_t RSInterfaces::GetRealtimeRefreshRate(ScreenId id)
341 {
342 RS_LOGD("GetRealtimeRefreshRate: screenId[%{public}" PRIu64"]", id);
343 return renderServiceClient_->GetRealtimeRefreshRate(id);
344 }
345
GetRefreshInfo(pid_t pid)346 std::string RSInterfaces::GetRefreshInfo(pid_t pid)
347 {
348 return renderServiceClient_->GetRefreshInfo(pid);
349 }
350
TakeSurfaceCaptureForUI(std::shared_ptr<RSNode> node,std::shared_ptr<SurfaceCaptureCallback> callback,float scaleX,float scaleY,bool isSync,const Drawing::Rect & specifiedAreaRect)351 bool RSInterfaces::TakeSurfaceCaptureForUI(std::shared_ptr<RSNode> node,
352 std::shared_ptr<SurfaceCaptureCallback> callback, float scaleX, float scaleY,
353 bool isSync, const Drawing::Rect& specifiedAreaRect)
354 {
355 if (!node) {
356 ROSEN_LOGW("RSInterfaces::TakeSurfaceCaptureForUI rsnode is nullpter return");
357 return false;
358 }
359 if (!((node->GetType() == RSUINodeType::ROOT_NODE) ||
360 (node->GetType() == RSUINodeType::CANVAS_NODE) ||
361 (node->GetType() == RSUINodeType::CANVAS_DRAWING_NODE) ||
362 (node->GetType() == RSUINodeType::SURFACE_NODE))) {
363 ROSEN_LOGE("RSInterfaces::TakeSurfaceCaptureForUI unsupported node type return");
364 return false;
365 }
366 RSSurfaceCaptureConfig captureConfig;
367 captureConfig.scaleX = scaleX;
368 captureConfig.scaleY = scaleY;
369 captureConfig.captureType = SurfaceCaptureType::UICAPTURE;
370 captureConfig.isSync = isSync;
371 if (RSSystemProperties::GetUniRenderEnabled()) {
372 if (isSync) {
373 node->SetTakeSurfaceForUIFlag();
374 }
375 return renderServiceClient_->TakeSurfaceCapture(node->GetId(), callback, captureConfig, {}, specifiedAreaRect);
376 } else {
377 return TakeSurfaceCaptureForUIWithoutUni(node->GetId(), callback, scaleX, scaleY);
378 }
379 }
380
RegisterTypeface(std::shared_ptr<Drawing::Typeface> & typeface)381 bool RSInterfaces::RegisterTypeface(std::shared_ptr<Drawing::Typeface>& typeface)
382 {
383 static std::function<std::shared_ptr<Drawing::Typeface> (uint64_t)> customTypefaceQueryfunc =
384 [](uint64_t globalUniqueId) -> std::shared_ptr<Drawing::Typeface> {
385 return RSTypefaceCache::Instance().GetDrawingTypefaceCache(globalUniqueId);
386 };
387
388 static std::once_flag onceFlag;
389 std::call_once(onceFlag, []() {
390 Drawing::DrawOpItem::SetTypefaceQueryCallBack(customTypefaceQueryfunc);
391 });
392
393 if (RSSystemProperties::GetUniRenderEnabled()) {
394 bool result = renderServiceClient_->RegisterTypeface(typeface);
395 if (result) {
396 RS_LOGI("RSInterfaces:Succeed in reg typeface, family name:%{public}s, uniqueid:%{public}u",
397 typeface->GetFamilyName().c_str(), typeface->GetUniqueID());
398 uint64_t globalUniqueId = RSTypefaceCache::GenGlobalUniqueId(typeface->GetUniqueID());
399 RSTypefaceCache::Instance().CacheDrawingTypeface(globalUniqueId, typeface);
400 } else {
401 RS_LOGE("RSInterfaces:Failed to reg typeface, family name:%{public}s, uniqueid:%{public}u",
402 typeface->GetFamilyName().c_str(), typeface->GetUniqueID());
403 }
404 return result;
405 }
406
407 RS_LOGI("RSInterfaces:Succeed in reg typeface, family name:%{public}s, uniqueid:%{public}u",
408 typeface->GetFamilyName().c_str(), typeface->GetUniqueID());
409 uint64_t globalUniqueId = RSTypefaceCache::GenGlobalUniqueId(typeface->GetUniqueID());
410 RSTypefaceCache::Instance().CacheDrawingTypeface(globalUniqueId, typeface);
411 return true;
412 }
413
UnRegisterTypeface(std::shared_ptr<Drawing::Typeface> & typeface)414 bool RSInterfaces::UnRegisterTypeface(std::shared_ptr<Drawing::Typeface>& typeface)
415 {
416 RS_LOGW("RSInterfaces:Unreg typeface: family name:%{public}s, uniqueid:%{public}u",
417 typeface->GetFamilyName().c_str(), typeface->GetUniqueID());
418 if (RSSystemProperties::GetUniRenderEnabled()) {
419 bool result = renderServiceClient_->UnRegisterTypeface(typeface);
420 if (result) {
421 uint64_t globalUniqueId = RSTypefaceCache::GenGlobalUniqueId(typeface->GetUniqueID());
422 RSTypefaceCache::Instance().RemoveDrawingTypefaceByGlobalUniqueId(globalUniqueId);
423 }
424 return result;
425 }
426
427 uint64_t globalUniqueId = RSTypefaceCache::GenGlobalUniqueId(typeface->GetUniqueID());
428 RSTypefaceCache::Instance().AddDelayDestroyQueue(globalUniqueId);
429 return true;
430 }
431
SetGlobalDarkColorMode(bool isDark)432 bool RSInterfaces::SetGlobalDarkColorMode(bool isDark)
433 {
434 return renderServiceClient_->SetGlobalDarkColorMode(isDark);
435 }
436
437 #ifndef ROSEN_ARKUI_X
SetPhysicalScreenResolution(ScreenId id,uint32_t width,uint32_t height)438 int32_t RSInterfaces::SetPhysicalScreenResolution(ScreenId id, uint32_t width, uint32_t height)
439 {
440 return renderServiceClient_->SetPhysicalScreenResolution(id, width, height);
441 }
442
SetVirtualScreenResolution(ScreenId id,uint32_t width,uint32_t height)443 int32_t RSInterfaces::SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height)
444 {
445 return renderServiceClient_->SetVirtualScreenResolution(id, width, height);
446 }
447 #endif // !ROSEN_ARKUI_X
448
SetVirtualMirrorScreenCanvasRotation(ScreenId id,bool canvasRotation)449 bool RSInterfaces::SetVirtualMirrorScreenCanvasRotation(ScreenId id, bool canvasRotation)
450 {
451 return renderServiceClient_->SetVirtualMirrorScreenCanvasRotation(id, canvasRotation);
452 }
453
SetVirtualMirrorScreenScaleMode(ScreenId id,ScreenScaleMode scaleMode)454 bool RSInterfaces::SetVirtualMirrorScreenScaleMode(ScreenId id, ScreenScaleMode scaleMode)
455 {
456 return renderServiceClient_->SetVirtualMirrorScreenScaleMode(id, scaleMode);
457 }
458 #ifndef ROSEN_ARKUI_X
GetVirtualScreenResolution(ScreenId id)459 RSVirtualScreenResolution RSInterfaces::GetVirtualScreenResolution(ScreenId id)
460 {
461 return renderServiceClient_->GetVirtualScreenResolution(id);
462 }
463
MarkPowerOffNeedProcessOneFrame()464 void RSInterfaces::MarkPowerOffNeedProcessOneFrame()
465 {
466 RS_LOGD("[UL_POWER]RSInterfaces::MarkPowerOffNeedProcessOneFrame.");
467 renderServiceClient_->MarkPowerOffNeedProcessOneFrame();
468 }
469
RepaintEverything()470 void RSInterfaces::RepaintEverything()
471 {
472 renderServiceClient_->RepaintEverything();
473 }
474
ForceRefreshOneFrameWithNextVSync()475 void RSInterfaces::ForceRefreshOneFrameWithNextVSync()
476 {
477 renderServiceClient_->ForceRefreshOneFrameWithNextVSync();
478 }
479
DisablePowerOffRenderControl(ScreenId id)480 void RSInterfaces::DisablePowerOffRenderControl(ScreenId id)
481 {
482 RS_LOGD("RSInterfaces::DisablePowerOffRenderControl.");
483 renderServiceClient_->DisablePowerOffRenderControl(id);
484 }
485
SetScreenPowerStatus(ScreenId id,ScreenPowerStatus status)486 void RSInterfaces::SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status)
487 {
488 RS_LOGI("[UL_POWER]RSInterfaces::SetScreenPowerStatus: ScreenId: %{public}" PRIu64
489 ", ScreenPowerStatus: %{public}u",
490 id, static_cast<uint32_t>(status));
491 renderServiceClient_->SetScreenPowerStatus(id, status);
492 }
493
494 #endif // !ROSEN_ARKUI_X
TakeSurfaceCaptureForUIWithoutUni(NodeId id,std::shared_ptr<SurfaceCaptureCallback> callback,float scaleX,float scaleY)495 bool RSInterfaces::TakeSurfaceCaptureForUIWithoutUni(NodeId id,
496 std::shared_ptr<SurfaceCaptureCallback> callback, float scaleX, float scaleY)
497 {
498 std::function<void()> offscreenRenderTask = [scaleX, scaleY, callback, id, this]() -> void {
499 ROSEN_LOGD(
500 "RSInterfaces::TakeSurfaceCaptureForUIWithoutUni callback->OnOffscreenRender nodeId:"
501 "[%{public}" PRIu64 "]", id);
502 ROSEN_TRACE_BEGIN(HITRACE_TAG_GRAPHIC_AGP, "RSRenderThread::TakeSurfaceCaptureForUIWithoutUni");
503 std::shared_ptr<RSDividedUICapture> rsDividedUICapture =
504 std::make_shared<RSDividedUICapture>(id, scaleX, scaleY);
505 std::shared_ptr<Media::PixelMap> pixelmap = rsDividedUICapture->TakeLocalCapture();
506 ROSEN_TRACE_END(HITRACE_TAG_GRAPHIC_AGP);
507 callback->OnSurfaceCapture(pixelmap);
508 };
509 RSOffscreenRenderThread::Instance().PostTask(offscreenRenderTask);
510 return true;
511 }
512
513 #ifndef ROSEN_ARKUI_X
GetScreenActiveMode(ScreenId id)514 RSScreenModeInfo RSInterfaces::GetScreenActiveMode(ScreenId id)
515 {
516 return renderServiceClient_->GetScreenActiveMode(id);
517 }
518
GetScreenSupportedModes(ScreenId id)519 std::vector<RSScreenModeInfo> RSInterfaces::GetScreenSupportedModes(ScreenId id)
520 {
521 return renderServiceClient_->GetScreenSupportedModes(id);
522 }
523
GetScreenCapability(ScreenId id)524 RSScreenCapability RSInterfaces::GetScreenCapability(ScreenId id)
525 {
526 return renderServiceClient_->GetScreenCapability(id);
527 }
528
GetScreenPowerStatus(ScreenId id)529 ScreenPowerStatus RSInterfaces::GetScreenPowerStatus(ScreenId id)
530 {
531 return renderServiceClient_->GetScreenPowerStatus(id);
532 }
533
GetScreenData(ScreenId id)534 RSScreenData RSInterfaces::GetScreenData(ScreenId id)
535 {
536 return renderServiceClient_->GetScreenData(id);
537 }
538 #endif // !ROSEN_ARKUI_X
GetScreenBacklight(ScreenId id)539 int32_t RSInterfaces::GetScreenBacklight(ScreenId id)
540 {
541 return renderServiceClient_->GetScreenBacklight(id);
542 }
543
SetScreenBacklight(ScreenId id,uint32_t level)544 void RSInterfaces::SetScreenBacklight(ScreenId id, uint32_t level)
545 {
546 RS_LOGD("RSInterfaces::SetScreenBacklight: ScreenId: %{public}" PRIu64 ", level: %{public}u", id, level);
547 renderServiceClient_->SetScreenBacklight(id, level);
548 }
549
GetScreenSupportedColorGamuts(ScreenId id,std::vector<ScreenColorGamut> & mode)550 int32_t RSInterfaces::GetScreenSupportedColorGamuts(ScreenId id, std::vector<ScreenColorGamut>& mode)
551 {
552 return renderServiceClient_->GetScreenSupportedColorGamuts(id, mode);
553 }
554
GetScreenSupportedMetaDataKeys(ScreenId id,std::vector<ScreenHDRMetadataKey> & keys)555 int32_t RSInterfaces::GetScreenSupportedMetaDataKeys(ScreenId id, std::vector<ScreenHDRMetadataKey>& keys)
556 {
557 return renderServiceClient_->GetScreenSupportedMetaDataKeys(id, keys);
558 }
559
GetScreenColorGamut(ScreenId id,ScreenColorGamut & mode)560 int32_t RSInterfaces::GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode)
561 {
562 return renderServiceClient_->GetScreenColorGamut(id, mode);
563 }
564
SetScreenColorGamut(ScreenId id,int32_t modeIdx)565 int32_t RSInterfaces::SetScreenColorGamut(ScreenId id, int32_t modeIdx)
566 {
567 return renderServiceClient_->SetScreenColorGamut(id, modeIdx);
568 }
569
SetScreenGamutMap(ScreenId id,ScreenGamutMap mode)570 int32_t RSInterfaces::SetScreenGamutMap(ScreenId id, ScreenGamutMap mode)
571 {
572 return renderServiceClient_->SetScreenGamutMap(id, mode);
573 }
574
SetScreenCorrection(ScreenId id,ScreenRotation screenRotation)575 int32_t RSInterfaces::SetScreenCorrection(ScreenId id, ScreenRotation screenRotation)
576 {
577 return renderServiceClient_->SetScreenCorrection(id, screenRotation);
578 }
579
GetScreenGamutMap(ScreenId id,ScreenGamutMap & mode)580 int32_t RSInterfaces::GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode)
581 {
582 return renderServiceClient_->GetScreenGamutMap(id, mode);
583 }
584
CreateVSyncReceiver(const std::string & name,const std::shared_ptr<OHOS::AppExecFwk::EventHandler> & looper)585 std::shared_ptr<VSyncReceiver> RSInterfaces::CreateVSyncReceiver(
586 const std::string& name,
587 const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper)
588 {
589 return renderServiceClient_->CreateVSyncReceiver(name, looper);
590 }
591
CreateVSyncReceiver(const std::string & name,uint64_t id,const std::shared_ptr<OHOS::AppExecFwk::EventHandler> & looper,NodeId windowNodeId,bool fromXcomponent)592 std::shared_ptr<VSyncReceiver> RSInterfaces::CreateVSyncReceiver(
593 const std::string& name,
594 uint64_t id,
595 const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper,
596 NodeId windowNodeId,
597 bool fromXcomponent)
598 {
599 return renderServiceClient_->CreateVSyncReceiver(name, looper, id, windowNodeId, fromXcomponent);
600 }
601
CreatePixelMapFromSurfaceId(uint64_t surfaceId,const Rect & srcRect)602 std::shared_ptr<Media::PixelMap> RSInterfaces::CreatePixelMapFromSurfaceId(uint64_t surfaceId, const Rect &srcRect)
603 {
604 return renderServiceClient_->CreatePixelMapFromSurfaceId(surfaceId, srcRect);
605 }
606
GetScreenHDRCapability(ScreenId id,RSScreenHDRCapability & screenHdrCapability)607 int32_t RSInterfaces::GetScreenHDRCapability(ScreenId id, RSScreenHDRCapability& screenHdrCapability)
608 {
609 return renderServiceClient_->GetScreenHDRCapability(id, screenHdrCapability);
610 }
611
GetPixelFormat(ScreenId id,GraphicPixelFormat & pixelFormat)612 int32_t RSInterfaces::GetPixelFormat(ScreenId id, GraphicPixelFormat& pixelFormat)
613 {
614 return renderServiceClient_->GetPixelFormat(id, pixelFormat);
615 }
616
SetPixelFormat(ScreenId id,GraphicPixelFormat pixelFormat)617 int32_t RSInterfaces::SetPixelFormat(ScreenId id, GraphicPixelFormat pixelFormat)
618 {
619 return renderServiceClient_->SetPixelFormat(id, pixelFormat);
620 }
621
GetScreenSupportedHDRFormats(ScreenId id,std::vector<ScreenHDRFormat> & hdrFormats)622 int32_t RSInterfaces::GetScreenSupportedHDRFormats(ScreenId id, std::vector<ScreenHDRFormat>& hdrFormats)
623 {
624 return renderServiceClient_->GetScreenSupportedHDRFormats(id, hdrFormats);
625 }
626
GetScreenHDRFormat(ScreenId id,ScreenHDRFormat & hdrFormat)627 int32_t RSInterfaces::GetScreenHDRFormat(ScreenId id, ScreenHDRFormat& hdrFormat)
628 {
629 return renderServiceClient_->GetScreenHDRFormat(id, hdrFormat);
630 }
631
SetScreenHDRFormat(ScreenId id,int32_t modeIdx)632 int32_t RSInterfaces::SetScreenHDRFormat(ScreenId id, int32_t modeIdx)
633 {
634 return renderServiceClient_->SetScreenHDRFormat(id, modeIdx);
635 }
636
GetScreenSupportedColorSpaces(ScreenId id,std::vector<GraphicCM_ColorSpaceType> & colorSpaces)637 int32_t RSInterfaces::GetScreenSupportedColorSpaces(ScreenId id, std::vector<GraphicCM_ColorSpaceType>& colorSpaces)
638 {
639 return renderServiceClient_->GetScreenSupportedColorSpaces(id, colorSpaces);
640 }
641
GetScreenColorSpace(ScreenId id,GraphicCM_ColorSpaceType & colorSpace)642 int32_t RSInterfaces::GetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType& colorSpace)
643 {
644 return renderServiceClient_->GetScreenColorSpace(id, colorSpace);
645 }
646
SetScreenColorSpace(ScreenId id,GraphicCM_ColorSpaceType colorSpace)647 int32_t RSInterfaces::SetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType colorSpace)
648 {
649 return renderServiceClient_->SetScreenColorSpace(id, colorSpace);
650 }
651
GetScreenType(ScreenId id,RSScreenType & screenType)652 int32_t RSInterfaces::GetScreenType(ScreenId id, RSScreenType& screenType)
653 {
654 return renderServiceClient_->GetScreenType(id, screenType);
655 }
656
GetDisplayIdentificationData(ScreenId id,uint8_t & outPort,std::vector<uint8_t> & edidData)657 int32_t RSInterfaces::GetDisplayIdentificationData(ScreenId id, uint8_t& outPort, std::vector<uint8_t>& edidData)
658 {
659 return renderServiceClient_->GetDisplayIdentificationData(id, outPort, edidData);
660 }
661
SetScreenSkipFrameInterval(ScreenId id,uint32_t skipFrameInterval)662 int32_t RSInterfaces::SetScreenSkipFrameInterval(ScreenId id, uint32_t skipFrameInterval)
663 {
664 return renderServiceClient_->SetScreenSkipFrameInterval(id, skipFrameInterval);
665 }
666
SetScreenActiveRect(ScreenId id,const Rect & activeRect)667 uint32_t RSInterfaces::SetScreenActiveRect(ScreenId id, const Rect& activeRect)
668 {
669 return renderServiceClient_->SetScreenActiveRect(id, activeRect);
670 }
671
SetVirtualScreenRefreshRate(ScreenId id,uint32_t maxRefreshRate,uint32_t & actualRefreshRate)672 int32_t RSInterfaces::SetVirtualScreenRefreshRate(ScreenId id, uint32_t maxRefreshRate, uint32_t& actualRefreshRate)
673 {
674 return renderServiceClient_->SetVirtualScreenRefreshRate(id, maxRefreshRate, actualRefreshRate);
675 }
676
SetSystemAnimatedScenes(SystemAnimatedScenes systemAnimatedScenes,bool isRegularAnimation)677 bool RSInterfaces::SetSystemAnimatedScenes(SystemAnimatedScenes systemAnimatedScenes, bool isRegularAnimation)
678 {
679 return renderServiceClient_->SetSystemAnimatedScenes(systemAnimatedScenes, isRegularAnimation);
680 }
681
RegisterOcclusionChangeCallback(const OcclusionChangeCallback & callback)682 int32_t RSInterfaces::RegisterOcclusionChangeCallback(const OcclusionChangeCallback& callback)
683 {
684 return renderServiceClient_->RegisterOcclusionChangeCallback(callback);
685 }
686
RegisterSurfaceOcclusionChangeCallback(NodeId id,const SurfaceOcclusionChangeCallback & callback,std::vector<float> & partitionPoints)687 int32_t RSInterfaces::RegisterSurfaceOcclusionChangeCallback(
688 NodeId id, const SurfaceOcclusionChangeCallback& callback, std::vector<float>& partitionPoints)
689 {
690 return renderServiceClient_->RegisterSurfaceOcclusionChangeCallback(id, callback, partitionPoints);
691 }
692
UnRegisterSurfaceOcclusionChangeCallback(NodeId id)693 int32_t RSInterfaces::UnRegisterSurfaceOcclusionChangeCallback(NodeId id)
694 {
695 return renderServiceClient_->UnRegisterSurfaceOcclusionChangeCallback(id);
696 }
697
RegisterHgmConfigChangeCallback(const HgmConfigChangeCallback & callback)698 int32_t RSInterfaces::RegisterHgmConfigChangeCallback(const HgmConfigChangeCallback& callback)
699 {
700 return renderServiceClient_->RegisterHgmConfigChangeCallback(callback);
701 }
702
RegisterHgmRefreshRateModeChangeCallback(const HgmRefreshRateModeChangeCallback & callback)703 int32_t RSInterfaces::RegisterHgmRefreshRateModeChangeCallback(const HgmRefreshRateModeChangeCallback& callback)
704 {
705 return renderServiceClient_->RegisterHgmRefreshRateModeChangeCallback(callback);
706 }
707
RegisterHgmRefreshRateUpdateCallback(const HgmRefreshRateUpdateCallback & callback)708 int32_t RSInterfaces::RegisterHgmRefreshRateUpdateCallback(const HgmRefreshRateUpdateCallback& callback)
709 {
710 return renderServiceClient_->RegisterHgmRefreshRateUpdateCallback(callback);
711 }
712
UnRegisterHgmRefreshRateUpdateCallback()713 int32_t RSInterfaces::UnRegisterHgmRefreshRateUpdateCallback()
714 {
715 return renderServiceClient_->RegisterHgmRefreshRateUpdateCallback(nullptr);
716 }
717
RegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid,const FrameRateLinkerExpectedFpsUpdateCallback & callback)718 int32_t RSInterfaces::RegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid,
719 const FrameRateLinkerExpectedFpsUpdateCallback& callback)
720 {
721 if (callback == nullptr) {
722 ROSEN_LOGE("RSInterfaces::RegisterFrameRateLinkerExpectedFpsUpdateCallback callback == nullptr.");
723 return INVALID_ARGUMENTS;
724 }
725 return renderServiceClient_->RegisterFrameRateLinkerExpectedFpsUpdateCallback(dstPid, callback);
726 }
727
UnRegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid)728 int32_t RSInterfaces::UnRegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid)
729 {
730 return renderServiceClient_->RegisterFrameRateLinkerExpectedFpsUpdateCallback(dstPid, nullptr);
731 }
732
SetAppWindowNum(uint32_t num)733 void RSInterfaces::SetAppWindowNum(uint32_t num)
734 {
735 renderServiceClient_->SetAppWindowNum(num);
736 }
737
ShowWatermark(const std::shared_ptr<Media::PixelMap> & watermarkImg,bool isShow)738 void RSInterfaces::ShowWatermark(const std::shared_ptr<Media::PixelMap> &watermarkImg, bool isShow)
739 {
740 renderServiceClient_->ShowWatermark(watermarkImg, isShow);
741 }
742
ResizeVirtualScreen(ScreenId id,uint32_t width,uint32_t height)743 int32_t RSInterfaces::ResizeVirtualScreen(ScreenId id, uint32_t width, uint32_t height)
744 {
745 return renderServiceClient_->ResizeVirtualScreen(id, width, height);
746 }
747
748 #ifndef ROSEN_ARKUI_X
GetMemoryGraphic(int pid)749 MemoryGraphic RSInterfaces::GetMemoryGraphic(int pid)
750 {
751 return renderServiceClient_->GetMemoryGraphic(pid);
752 }
753
GetMemoryGraphics()754 std::vector<MemoryGraphic> RSInterfaces::GetMemoryGraphics()
755 {
756 return renderServiceClient_->GetMemoryGraphics();
757 }
758 #endif // !ROSEN_ARKUI_X
GetTotalAppMemSize(float & cpuMemSize,float & gpuMemSize)759 bool RSInterfaces::GetTotalAppMemSize(float& cpuMemSize, float& gpuMemSize)
760 {
761 return renderServiceClient_->GetTotalAppMemSize(cpuMemSize, gpuMemSize);
762 }
763
ReportJankStats()764 void RSInterfaces::ReportJankStats()
765 {
766 renderServiceClient_->ReportJankStats();
767 }
768
ReportEventResponse(DataBaseRs info)769 void RSInterfaces::ReportEventResponse(DataBaseRs info)
770 {
771 renderServiceClient_->ReportEventResponse(info);
772 }
773
ReportEventComplete(DataBaseRs info)774 void RSInterfaces::ReportEventComplete(DataBaseRs info)
775 {
776 renderServiceClient_->ReportEventComplete(info);
777 }
778
ReportEventJankFrame(DataBaseRs info)779 void RSInterfaces::ReportEventJankFrame(DataBaseRs info)
780 {
781 renderServiceClient_->ReportEventJankFrame(info);
782 }
783
ReportGameStateData(GameStateData info)784 void RSInterfaces::ReportGameStateData(GameStateData info)
785 {
786 renderServiceClient_->ReportGameStateData(info);
787 }
788
ReportRsSceneJankStart(AppInfo info)789 void RSInterfaces::ReportRsSceneJankStart(AppInfo info)
790 {
791 renderServiceClient_->ReportRsSceneJankStart(info);
792 }
793
ReportRsSceneJankEnd(AppInfo info)794 void RSInterfaces::ReportRsSceneJankEnd(AppInfo info)
795 {
796 renderServiceClient_->ReportRsSceneJankEnd(info);
797 }
798
EnableCacheForRotation()799 void RSInterfaces::EnableCacheForRotation()
800 {
801 renderServiceClient_->SetCacheEnabledForRotation(true);
802 }
803
NotifyLightFactorStatus(int32_t lightFactorStatus)804 void RSInterfaces::NotifyLightFactorStatus(int32_t lightFactorStatus)
805 {
806 renderServiceClient_->NotifyLightFactorStatus(lightFactorStatus);
807 }
808
NotifyPackageEvent(uint32_t listSize,const std::vector<std::string> & packageList)809 void RSInterfaces::NotifyPackageEvent(uint32_t listSize, const std::vector<std::string>& packageList)
810 {
811 renderServiceClient_->NotifyPackageEvent(listSize, packageList);
812 }
813
NotifyAppStrategyConfigChangeEvent(const std::string & pkgName,uint32_t listSize,const std::vector<std::pair<std::string,std::string>> & newConfig)814 void RSInterfaces::NotifyAppStrategyConfigChangeEvent(const std::string& pkgName, uint32_t listSize,
815 const std::vector<std::pair<std::string, std::string>>& newConfig)
816 {
817 renderServiceClient_->NotifyAppStrategyConfigChangeEvent(pkgName, listSize, newConfig);
818 }
819
NotifyRefreshRateEvent(const EventInfo & eventInfo)820 void RSInterfaces::NotifyRefreshRateEvent(const EventInfo& eventInfo)
821 {
822 renderServiceClient_->NotifyRefreshRateEvent(eventInfo);
823 }
824
NotifyTouchEvent(int32_t touchStatus,int32_t touchCnt)825 void RSInterfaces::NotifyTouchEvent(int32_t touchStatus, int32_t touchCnt)
826 {
827 if (!RSFrameRatePolicy::GetInstance()->GetTouchOrPointerAction(touchStatus)) {
828 return;
829 }
830 renderServiceClient_->NotifyTouchEvent(touchStatus, touchCnt);
831 }
832
NotifyDynamicModeEvent(bool enableDynamicMode)833 void RSInterfaces::NotifyDynamicModeEvent(bool enableDynamicMode)
834 {
835 renderServiceClient_->NotifyDynamicModeEvent(enableDynamicMode);
836 }
837
NotifyHgmConfigEvent(const std::string & eventName,bool state)838 void RSInterfaces::NotifyHgmConfigEvent(const std::string &eventName, bool state)
839 {
840 renderServiceClient_->NotifyHgmConfigEvent(eventName, state);
841 }
842
DisableCacheForRotation()843 void RSInterfaces::DisableCacheForRotation()
844 {
845 renderServiceClient_->SetCacheEnabledForRotation(false);
846 }
847
SetOnRemoteDiedCallback(const OnRemoteDiedCallback & callback)848 void RSInterfaces::SetOnRemoteDiedCallback(const OnRemoteDiedCallback& callback)
849 {
850 renderServiceClient_->SetOnRemoteDiedCallback(callback);
851 }
852
GetActiveDirtyRegionInfo() const853 std::vector<ActiveDirtyRegionInfo> RSInterfaces::GetActiveDirtyRegionInfo() const
854 {
855 const auto& activeDirtyRegionInfo = renderServiceClient_->GetActiveDirtyRegionInfo();
856 return activeDirtyRegionInfo;
857 }
858
GetGlobalDirtyRegionInfo() const859 GlobalDirtyRegionInfo RSInterfaces::GetGlobalDirtyRegionInfo() const
860 {
861 const auto& globalDirtyRegionInfo = renderServiceClient_->GetGlobalDirtyRegionInfo();
862 return globalDirtyRegionInfo;
863 }
864
GetLayerComposeInfo() const865 LayerComposeInfo RSInterfaces::GetLayerComposeInfo() const
866 {
867 const auto& layerComposeInfo = renderServiceClient_->GetLayerComposeInfo();
868 return layerComposeInfo;
869 }
870
GetHwcDisabledReasonInfo() const871 HwcDisabledReasonInfos RSInterfaces::GetHwcDisabledReasonInfo() const
872 {
873 const auto& hwcDisabledReasonInfo = renderServiceClient_->GetHwcDisabledReasonInfo();
874 return hwcDisabledReasonInfo;
875 }
876
GetHdrOnDuration() const877 int64_t RSInterfaces::GetHdrOnDuration() const
878 {
879 return renderServiceClient_->GetHdrOnDuration();
880 }
881
SetVmaCacheStatus(bool flag)882 void RSInterfaces::SetVmaCacheStatus(bool flag)
883 {
884 renderServiceClient_->SetVmaCacheStatus(flag);
885 }
886
887 #ifdef TP_FEATURE_ENABLE
SetTpFeatureConfig(int32_t feature,const char * config,TpFeatureConfigType tpFeatureConfigType)888 void RSInterfaces::SetTpFeatureConfig(int32_t feature, const char* config, TpFeatureConfigType tpFeatureConfigType)
889 {
890 renderServiceClient_->SetTpFeatureConfig(feature, config, tpFeatureConfigType);
891 }
892 #endif
893
SetVirtualScreenUsingStatus(bool isVirtualScreenUsingStatus)894 void RSInterfaces::SetVirtualScreenUsingStatus(bool isVirtualScreenUsingStatus)
895 {
896 renderServiceClient_->SetVirtualScreenUsingStatus(isVirtualScreenUsingStatus);
897 }
898
SetCurtainScreenUsingStatus(bool isCurtainScreenOn)899 void RSInterfaces::SetCurtainScreenUsingStatus(bool isCurtainScreenOn)
900 {
901 renderServiceClient_->SetCurtainScreenUsingStatus(isCurtainScreenOn);
902 }
903
DropFrameByPid(const std::vector<int32_t> pidList)904 void RSInterfaces::DropFrameByPid(const std::vector<int32_t> pidList)
905 {
906 if (pidList.empty()) {
907 return;
908 }
909 RS_TRACE_NAME("DropFrameByPid");
910 renderServiceClient_->DropFrameByPid(pidList);
911 }
912
RegisterUIExtensionCallback(uint64_t userId,const UIExtensionCallback & callback,bool unobscured)913 int32_t RSInterfaces::RegisterUIExtensionCallback(uint64_t userId, const UIExtensionCallback& callback, bool unobscured)
914 {
915 return renderServiceClient_->RegisterUIExtensionCallback(userId, callback, unobscured);
916 }
917
SetAncoForceDoDirect(bool direct)918 bool RSInterfaces::SetAncoForceDoDirect(bool direct)
919 {
920 return renderServiceClient_->SetAncoForceDoDirect(direct);
921 }
922
SetVirtualScreenStatus(ScreenId id,VirtualScreenStatus screenStatus)923 bool RSInterfaces::SetVirtualScreenStatus(ScreenId id, VirtualScreenStatus screenStatus)
924 {
925 return renderServiceClient_->SetVirtualScreenStatus(id, screenStatus);
926 }
927
SetFreeMultiWindowStatus(bool enable)928 void RSInterfaces::SetFreeMultiWindowStatus(bool enable)
929 {
930 renderServiceClient_->SetFreeMultiWindowStatus(enable);
931 }
932
RegisterSurfaceBufferCallback(pid_t pid,uint64_t uid,std::shared_ptr<SurfaceBufferCallback> callback)933 bool RSInterfaces::RegisterSurfaceBufferCallback(pid_t pid, uint64_t uid,
934 std::shared_ptr<SurfaceBufferCallback> callback)
935 {
936 if (callback == nullptr) {
937 ROSEN_LOGE("RSInterfaces::RegisterSurfaceBufferCallback callback == nullptr.");
938 return false;
939 }
940 RSSurfaceBufferCallbackManager::Instance().RegisterSurfaceBufferCallback(pid, uid,
941 new (std::nothrow) RSDefaultSurfaceBufferCallback ({
942 .OnFinish = [callback](const FinishCallbackRet& ret) {
943 callback->OnFinish(ret);
944 },
945 .OnAfterAcquireBuffer = [callback](const AfterAcquireBufferRet& ret) {
946 callback->OnAfterAcquireBuffer(ret);
947 },
948 })
949 );
950 return renderServiceClient_->RegisterSurfaceBufferCallback(pid, uid, callback);
951 }
952
UnregisterSurfaceBufferCallback(pid_t pid,uint64_t uid)953 bool RSInterfaces::UnregisterSurfaceBufferCallback(pid_t pid, uint64_t uid)
954 {
955 RSSurfaceBufferCallbackManager::Instance().UnregisterSurfaceBufferCallback(pid, uid);
956 return renderServiceClient_->UnregisterSurfaceBufferCallback(pid, uid);
957 }
958
SetLayerTop(const std::string & nodeIdStr,bool isTop)959 void RSInterfaces::SetLayerTop(const std::string &nodeIdStr, bool isTop)
960 {
961 renderServiceClient_->SetLayerTop(nodeIdStr, isTop);
962 }
963
NotifyScreenSwitched()964 void RSInterfaces::NotifyScreenSwitched()
965 {
966 renderServiceClient_->NotifyScreenSwitched();
967 }
968
SetWindowContainer(NodeId nodeId,bool value)969 void RSInterfaces::SetWindowContainer(NodeId nodeId, bool value)
970 {
971 renderServiceClient_->SetWindowContainer(nodeId, value);
972 }
973
RegisterSelfDrawingNodeRectChangeCallback(const SelfDrawingNodeRectChangeCallback & callback)974 int32_t RSInterfaces::RegisterSelfDrawingNodeRectChangeCallback(const SelfDrawingNodeRectChangeCallback& callback)
975 {
976 RS_TRACE_NAME("RSInterfaces::RegisterSelfDrawingNodeRectChangeCallback");
977 return renderServiceClient_->RegisterSelfDrawingNodeRectChangeCallback(callback);
978 }
979
980 #ifdef RS_ENABLE_OVERLAY_DISPLAY
SetOverlayDisplayMode(int32_t mode)981 int32_t RSInterfaces::SetOverlayDisplayMode(int32_t mode)
982 {
983 ROSEN_LOGI("RSInterfaces::SetOverlayDisplayMode enter.");
984 return renderServiceClient_->SetOverlayDisplayMode(mode);
985 }
986 #endif
987
NotifyPageName(const std::string & packageName,const std::string & pageName,bool isEnter)988 void RSInterfaces::NotifyPageName(const std::string &packageName, const std::string &pageName, bool isEnter)
989 {
990 auto pageNameList = RSFrameRatePolicy::GetInstance()->GetPageNameList();
991 auto item = pageNameList.find(pageName);
992 if (item != pageNameList.end()) {
993 ROSEN_LOGI("RSInterfaces packageName = %{public}s pageName = %{public}s isEnter = %{public}d",
994 packageName.c_str(), pageName.c_str(), isEnter);
995 renderServiceClient_->NotifyPageName(packageName, pageName, isEnter);
996 }
997 }
998
TestLoadFileSubTreeToNode(NodeId nodeId,const std::string & filePath)999 void RSInterfaces::TestLoadFileSubTreeToNode(NodeId nodeId, const std::string &filePath)
1000 {
1001 renderServiceClient_->TestLoadFileSubTreeToNode(nodeId, filePath);
1002 }
1003 } // namespace Rosen
1004 } // namespace OHOS
1005