• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 "rs_render_service_connection.h"
17 
18 #include "pipeline/rs_render_node_map.h"
19 #include "pipeline/rs_render_service_listener.h"
20 #include "pipeline/rs_surface_capture_task.h"
21 #include "pipeline/rs_surface_render_node.h"
22 #include "pipeline/rs_uni_render_judgement.h"
23 #include "platform/common/rs_log.h"
24 #include "rs_main_thread.h"
25 #include "rs_trace.h"
26 
27 namespace OHOS {
28 namespace Rosen {
29 // we guarantee that when constructing this object,
30 // all these pointers are valid, so will not check them.
RSRenderServiceConnection(pid_t remotePid,wptr<RSRenderService> renderService,RSMainThread * mainThread,sptr<RSScreenManager> screenManager,sptr<IRemoteObject> token,sptr<VSyncDistributor> distributor)31 RSRenderServiceConnection::RSRenderServiceConnection(
32     pid_t remotePid,
33     wptr<RSRenderService> renderService,
34     RSMainThread* mainThread,
35     sptr<RSScreenManager> screenManager,
36     sptr<IRemoteObject> token,
37     sptr<VSyncDistributor> distributor)
38     : remotePid_(remotePid),
39       renderService_(renderService),
40       mainThread_(mainThread),
41       screenManager_(screenManager),
42       token_(token),
43       connDeathRecipient_(new RSConnectionDeathRecipient(this)),
44       ApplicationDeathRecipient_(new RSApplicationRenderThreadDeathRecipient(this)),
45       appVSyncDistributor_(distributor)
46 {
47     if (!token_->AddDeathRecipient(connDeathRecipient_)) {
48         RS_LOGW("RSRenderServiceConnection: Failed to set death recipient.");
49     }
50 }
51 
~RSRenderServiceConnection()52 RSRenderServiceConnection::~RSRenderServiceConnection() noexcept
53 {
54     CleanAll();
55 }
56 
CleanVirtualScreens()57 void RSRenderServiceConnection::CleanVirtualScreens() noexcept
58 {
59     std::lock_guard<std::mutex> lock(mutex_);
60 
61     for (const auto id : virtualScreenIds_) {
62         screenManager_->RemoveVirtualScreen(id);
63     }
64     virtualScreenIds_.clear();
65 
66     if (screenChangeCallback_ != nullptr) {
67         screenManager_->RemoveScreenChangeCallback(screenChangeCallback_);
68         screenChangeCallback_ = nullptr;
69     }
70 }
71 
CleanRenderNodes()72 void RSRenderServiceConnection::CleanRenderNodes() noexcept
73 {
74     auto& context = mainThread_->GetContext();
75     auto& nodeMap = context.GetMutableNodeMap();
76 
77     nodeMap.FilterNodeByPid(remotePid_);
78 }
79 
CleanAll(bool toDelete)80 void RSRenderServiceConnection::CleanAll(bool toDelete) noexcept
81 {
82     {
83         std::lock_guard<std::mutex> lock(mutex_);
84         if (cleanDone_) {
85             return;
86         }
87     }
88     RS_LOGD("RSRenderServiceConnection::CleanAll() start.");
89     mainThread_->ScheduleTask([this]() {
90         CleanVirtualScreens();
91         CleanRenderNodes();
92         mainThread_->ClearTransactionDataPidInfo(remotePid_);
93         mainThread_->UnRegisterOcclusionChangeCallback(remotePid_);
94     }).wait();
95 
96     for (auto& conn : vsyncConnections_) {
97         appVSyncDistributor_->RemoveConnection(conn);
98     }
99 
100     {
101         std::lock_guard<std::mutex> lock(mutex_);
102         vsyncConnections_.clear();
103         cleanDone_ = true;
104     }
105 
106     if (toDelete) {
107         auto renderService = renderService_.promote();
108         if (renderService == nullptr) {
109             RS_LOGW("RSRenderServiceConnection::CleanAll() RenderService is dead.");
110         } else {
111             renderService->RemoveConnection(GetToken());
112         }
113     }
114 
115     RS_LOGD("RSRenderServiceConnection::CleanAll() end.");
116 }
117 
RSConnectionDeathRecipient(wptr<RSRenderServiceConnection> conn)118 RSRenderServiceConnection::RSConnectionDeathRecipient::RSConnectionDeathRecipient(
119     wptr<RSRenderServiceConnection> conn) : conn_(conn)
120 {
121 }
122 
OnRemoteDied(const wptr<IRemoteObject> & token)123 void RSRenderServiceConnection::RSConnectionDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& token)
124 {
125     auto tokenSptr = token.promote();
126     if (tokenSptr == nullptr) {
127         RS_LOGW("RSConnectionDeathRecipient::OnRemoteDied: can't promote remote object.");
128         return;
129     }
130 
131     auto rsConn = conn_.promote();
132     if (rsConn == nullptr) {
133         RS_LOGW("RSConnectionDeathRecipient::OnRemoteDied: RSRenderServiceConnection was dead, do nothing.");
134         return;
135     }
136 
137     if (rsConn->GetToken() != tokenSptr) {
138         RS_LOGI("RSConnectionDeathRecipient::OnRemoteDied: token doesn't match, ignore it.");
139         return;
140     }
141 
142     RS_LOGI("RSConnectionDeathRecipient::OnRemoteDied: do the clean work.");
143     rsConn->CleanAll(true);
144 }
145 
RSApplicationRenderThreadDeathRecipient(wptr<RSRenderServiceConnection> conn)146 RSRenderServiceConnection::RSApplicationRenderThreadDeathRecipient::RSApplicationRenderThreadDeathRecipient(
147     wptr<RSRenderServiceConnection> conn) : conn_(conn)
148 {}
149 
OnRemoteDied(const wptr<IRemoteObject> & token)150 void RSRenderServiceConnection::RSApplicationRenderThreadDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& token)
151 {
152     auto tokenSptr = token.promote();
153     if (tokenSptr == nullptr) {
154         RS_LOGW("RSApplicationRenderThreadDeathRecipient::OnRemoteDied: can't promote remote object.");
155         return;
156     }
157 
158     auto rsConn = conn_.promote();
159     if (rsConn == nullptr) {
160         RS_LOGW("RSApplicationRenderThreadDeathRecipient::OnRemoteDied: RSRenderServiceConnection was dead, do nothing.");
161         return;
162     }
163 
164     RS_LOGI("RSApplicationRenderThreadDeathRecipient::OnRemoteDied: Unregister.");
165     auto app = iface_cast<IApplicationAgent>(tokenSptr);
166     rsConn->UnRegisterApplicationAgent(app);
167 }
168 
CommitTransaction(std::unique_ptr<RSTransactionData> & transactionData)169 void RSRenderServiceConnection::CommitTransaction(std::unique_ptr<RSTransactionData>& transactionData)
170 {
171     mainThread_->RecvRSTransactionData(transactionData);
172 }
173 
ExecuteSynchronousTask(const std::shared_ptr<RSSyncTask> & task)174 void RSRenderServiceConnection::ExecuteSynchronousTask(const std::shared_ptr<RSSyncTask>& task)
175 {
176     if (task == nullptr) {
177         return;
178     }
179 
180     auto& context = mainThread_->GetContext();
181     mainThread_->ScheduleTask([task, &context]() {
182         task->Process(context);
183     }).wait_for(std::chrono::nanoseconds(task->GetTimeout()));
184 }
185 
SetRenderModeChangeCallback(sptr<RSIRenderModeChangeCallback> callback)186 int32_t RSRenderServiceConnection::SetRenderModeChangeCallback(sptr<RSIRenderModeChangeCallback> callback)
187 {
188     if (!callback) {
189         RS_LOGD("RSRenderServiceConnection::SetRenderModeChangeCallback: callback is nullptr");
190         return INVALID_ARGUMENTS;
191     }
192     mainThread_->SetRenderModeChangeCallback(callback);
193     return SUCCESS;
194 }
195 
UpdateRenderMode(bool isUniRender)196 void RSRenderServiceConnection::UpdateRenderMode(bool isUniRender)
197 {
198     mainThread_->NotifyRenderModeChanged(isUniRender);
199 }
200 
GetUniRenderEnabled()201 bool RSRenderServiceConnection::GetUniRenderEnabled()
202 {
203     return RSUniRenderJudgement::IsUniRender();
204 }
205 
QueryIfRTNeedRender()206 bool RSRenderServiceConnection::QueryIfRTNeedRender()
207 {
208     return !mainThread_->QueryIfUseUniVisitor();
209 }
210 
CreateNode(const RSSurfaceRenderNodeConfig & config)211 bool RSRenderServiceConnection::CreateNode(const RSSurfaceRenderNodeConfig& config)
212 {
213     std::shared_ptr<RSSurfaceRenderNode> node =
214         std::make_shared<RSSurfaceRenderNode>(config, mainThread_->GetContext().weak_from_this());
215     if (node == nullptr) {
216         RS_LOGE("RSRenderService::CreateNode fail");
217         return false;
218     }
219     std::function<void()> registerNode = [node, this]() -> void {
220         this->mainThread_->GetContext().GetMutableNodeMap().RegisterRenderNode(node);
221     };
222     mainThread_->PostTask(registerNode);
223     return true;
224 }
225 
CreateNodeAndSurface(const RSSurfaceRenderNodeConfig & config)226 sptr<Surface> RSRenderServiceConnection::CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config)
227 {
228     std::shared_ptr<RSSurfaceRenderNode> node =
229         std::make_shared<RSSurfaceRenderNode>(config, mainThread_->GetContext().weak_from_this());
230     if (node == nullptr) {
231         RS_LOGE("RSRenderService::CreateNodeAndSurface CreateNode fail");
232         return nullptr;
233     }
234     sptr<Surface> surface = Surface::CreateSurfaceAsConsumer(config.name);
235     if (surface == nullptr) {
236         RS_LOGE("RSRenderService::CreateNodeAndSurface get consumer surface fail");
237         return nullptr;
238     }
239     const std::string& surfaceName = surface->GetName();
240     RS_LOGI("RsDebug RSRenderService::CreateNodeAndSurface node id:%" PRIu64 " name:%s surface id:%" PRIu64 " name:%s",
241         node->GetId(), node->GetName().c_str(), surface->GetUniqueId(), surfaceName.c_str());
242     node->SetConsumer(surface);
243     std::function<void()> registerNode = [node, this]() -> void {
244         this->mainThread_->GetContext().GetMutableNodeMap().RegisterRenderNode(node);
245     };
246     mainThread_->PostTask(registerNode);
247     std::weak_ptr<RSSurfaceRenderNode> surfaceRenderNode(node);
248     sptr<IBufferConsumerListener> listener = new RSRenderServiceListener(surfaceRenderNode);
249     SurfaceError ret = surface->RegisterConsumerListener(listener);
250     if (ret != SURFACE_ERROR_OK) {
251         RS_LOGE("RSRenderService::CreateNodeAndSurface Register Consumer Listener fail");
252         return nullptr;
253     }
254     return surface;
255 }
256 
257 
CreateVSyncConnection(const std::string & name)258 sptr<IVSyncConnection> RSRenderServiceConnection::CreateVSyncConnection(const std::string& name)
259 {
260     sptr<VSyncConnection> conn = new VSyncConnection(appVSyncDistributor_, name);
261     appVSyncDistributor_->AddConnection(conn);
262     {
263         std::lock_guard<std::mutex> lock(mutex_);
264         vsyncConnections_.push_back(conn);
265     }
266     return conn;
267 }
268 
SetFocusAppInfo(int32_t pid,int32_t uid,const std::string & bundleName,const std::string & abilityName)269 int32_t RSRenderServiceConnection::SetFocusAppInfo(
270     int32_t pid, int32_t uid, const std::string &bundleName, const std::string &abilityName)
271 {
272     mainThread_->SetFocusAppInfo(pid, uid, bundleName, abilityName);
273     return SUCCESS;
274 }
275 
GetDefaultScreenId()276 ScreenId RSRenderServiceConnection::GetDefaultScreenId()
277 {
278     std::lock_guard<std::mutex> lock(mutex_);
279     return screenManager_->GetDefaultScreenId();
280 }
281 
GetAllScreenIds()282 std::vector<ScreenId> RSRenderServiceConnection::GetAllScreenIds()
283 {
284     std::lock_guard<std::mutex> lock(mutex_);
285     return screenManager_->GetAllScreenIds();
286 }
287 
CreateVirtualScreen(const std::string & name,uint32_t width,uint32_t height,sptr<Surface> surface,ScreenId mirrorId,int32_t flags)288 ScreenId RSRenderServiceConnection::CreateVirtualScreen(
289     const std::string &name,
290     uint32_t width,
291     uint32_t height,
292     sptr<Surface> surface,
293     ScreenId mirrorId,
294     int32_t flags)
295 {
296     std::lock_guard<std::mutex> lock(mutex_);
297     auto newVirtualScreenId = screenManager_->CreateVirtualScreen(name, width, height, surface, mirrorId, flags);
298     virtualScreenIds_.insert(newVirtualScreenId);
299     return newVirtualScreenId;
300 }
301 
SetVirtualScreenSurface(ScreenId id,sptr<Surface> surface)302 int32_t RSRenderServiceConnection::SetVirtualScreenSurface(ScreenId id, sptr<Surface> surface)
303 {
304     std::lock_guard<std::mutex> lock(mutex_);
305     return screenManager_->SetVirtualScreenSurface(id, surface);
306 }
307 
RemoveVirtualScreen(ScreenId id)308 void RSRenderServiceConnection::RemoveVirtualScreen(ScreenId id)
309 {
310     std::lock_guard<std::mutex> lock(mutex_);
311     screenManager_->RemoveVirtualScreen(id);
312     virtualScreenIds_.erase(id);
313 }
314 
SetScreenChangeCallback(sptr<RSIScreenChangeCallback> callback)315 int32_t RSRenderServiceConnection::SetScreenChangeCallback(sptr<RSIScreenChangeCallback> callback)
316 {
317     std::unique_lock<std::mutex> lock(mutex_);
318     if (screenChangeCallback_ == callback) {
319         return INVALID_ARGUMENTS;
320     }
321 
322     if (screenChangeCallback_ != nullptr) {
323         // remove the old callback
324         screenManager_->RemoveScreenChangeCallback(screenChangeCallback_);
325     }
326 
327     // update
328     int32_t status = screenManager_->AddScreenChangeCallback(callback);
329     auto tmp = screenChangeCallback_;
330     screenChangeCallback_ = callback;
331     lock.unlock();
332     return status;
333 }
334 
SetScreenActiveMode(ScreenId id,uint32_t modeId)335 void RSRenderServiceConnection::SetScreenActiveMode(ScreenId id, uint32_t modeId)
336 {
337     mainThread_->ScheduleTask([=]() {
338         screenManager_->SetScreenActiveMode(id, modeId);
339     }).wait();
340 }
341 
SetVirtualScreenResolution(ScreenId id,uint32_t width,uint32_t height)342 int32_t RSRenderServiceConnection::SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height)
343 {
344     return mainThread_->ScheduleTask([=]() {
345         return screenManager_->SetVirtualScreenResolution(id, width, height);
346     }).get();
347 }
348 
SetScreenPowerStatus(ScreenId id,ScreenPowerStatus status)349 void RSRenderServiceConnection::SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status)
350 {
351     mainThread_->ScheduleTask([=]() {
352         screenManager_->SetScreenPowerStatus(id, status);
353     }).wait();
354 }
355 
TakeSurfaceCapture(NodeId id,sptr<RSISurfaceCaptureCallback> callback,float scaleX,float scaleY)356 void RSRenderServiceConnection::TakeSurfaceCapture(NodeId id, sptr<RSISurfaceCaptureCallback> callback,
357     float scaleX, float scaleY)
358 {
359     std::function<void()> captureTask = [scaleY, scaleX, callback, id]() -> void {
360         RS_LOGD("RSRenderService::TakeSurfaceCapture callback->OnSurfaceCapture nodeId:[%" PRIu64 "]", id);
361         ROSEN_TRACE_BEGIN(HITRACE_TAG_GRAPHIC_AGP, "RSRenderService::TakeSurfaceCapture");
362         RSSurfaceCaptureTask task(id, scaleX, scaleY);
363         std::unique_ptr<Media::PixelMap> pixelmap = task.Run();
364         callback->OnSurfaceCapture(id, pixelmap.get());
365         ROSEN_TRACE_END(HITRACE_TAG_GRAPHIC_AGP);
366     };
367     mainThread_->PostTask(captureTask);
368 }
369 
RegisterApplicationAgent(uint32_t pid,sptr<IApplicationAgent> app)370 void RSRenderServiceConnection::RegisterApplicationAgent(uint32_t pid, sptr<IApplicationAgent> app)
371 {
372     auto captureTask = [=]() -> void {
373         mainThread_->RegisterApplicationAgent(pid, app);
374     };
375     mainThread_->PostTask(captureTask);
376 
377     app->AsObject()->AddDeathRecipient(ApplicationDeathRecipient_);
378 }
379 
UnRegisterApplicationAgent(sptr<IApplicationAgent> app)380 void RSRenderServiceConnection::UnRegisterApplicationAgent(sptr<IApplicationAgent> app)
381 {
382     auto captureTask = [=]() -> void {
383         RSMainThread::Instance()->UnRegisterApplicationAgent(app);
384     };
385     RSMainThread::Instance()->ScheduleTask(captureTask).wait();
386 }
387 
GetVirtualScreenResolution(ScreenId id)388 RSVirtualScreenResolution RSRenderServiceConnection::GetVirtualScreenResolution(ScreenId id)
389 {
390     RSVirtualScreenResolution virtualScreenResolution;
391     screenManager_->GetVirtualScreenResolution(id, virtualScreenResolution);
392     return virtualScreenResolution;
393 }
394 
GetScreenActiveMode(ScreenId id)395 RSScreenModeInfo RSRenderServiceConnection::GetScreenActiveMode(ScreenId id)
396 {
397     RSScreenModeInfo screenModeInfo;
398     mainThread_->ScheduleTask([=, &screenModeInfo]() {
399         return screenManager_->GetScreenActiveMode(id, screenModeInfo);
400     }).wait();
401     return screenModeInfo;
402 }
403 
GetScreenSupportedModes(ScreenId id)404 std::vector<RSScreenModeInfo> RSRenderServiceConnection::GetScreenSupportedModes(ScreenId id)
405 {
406     return mainThread_->ScheduleTask([=]() {
407         return screenManager_->GetScreenSupportedModes(id);
408     }).get();
409 }
410 
GetScreenCapability(ScreenId id)411 RSScreenCapability RSRenderServiceConnection::GetScreenCapability(ScreenId id)
412 {
413     RSScreenCapability screenCapability;
414     return mainThread_->ScheduleTask([=]() {
415         return screenManager_->GetScreenCapability(id);
416     }).get();
417 }
418 
GetScreenPowerStatus(ScreenId id)419 ScreenPowerStatus RSRenderServiceConnection::GetScreenPowerStatus(ScreenId id)
420 {
421     return mainThread_->ScheduleTask([=]() {
422         return screenManager_->GetScreenPowerStatus(id);
423     }).get();
424 }
425 
GetScreenData(ScreenId id)426 RSScreenData RSRenderServiceConnection::GetScreenData(ScreenId id)
427 {
428     RSScreenData screenData;
429     return mainThread_->ScheduleTask([=]() {
430         return screenManager_->GetScreenData(id);
431     }).get();
432 }
433 
GetScreenBacklight(ScreenId id)434 int32_t RSRenderServiceConnection::GetScreenBacklight(ScreenId id)
435 {
436     return mainThread_->ScheduleTask([=]() {
437         return screenManager_->GetScreenBacklight(id);
438     }).get();
439 }
440 
SetScreenBacklight(ScreenId id,uint32_t level)441 void RSRenderServiceConnection::SetScreenBacklight(ScreenId id, uint32_t level)
442 {
443     mainThread_->ScheduleTask([=]() {
444         screenManager_->SetScreenBacklight(id, level);
445     }).wait();
446 }
447 
RegisterBufferAvailableListener(NodeId id,sptr<RSIBufferAvailableCallback> callback,bool isFromRenderThread)448 void RSRenderServiceConnection::RegisterBufferAvailableListener(
449     NodeId id, sptr<RSIBufferAvailableCallback> callback, bool isFromRenderThread)
450 {
451     auto registerBufferAvailableListener = [id, callback, isFromRenderThread, this]() -> bool {
452         if (auto node = this->mainThread_->GetContext().GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
453             node->RegisterBufferAvailableListener(callback, isFromRenderThread);
454             return true;
455         }
456         return false;
457     };
458     if (!registerBufferAvailableListener()) {
459         RS_LOGI("RegisterBufferAvailableListener: node not found, post task to retry");
460         mainThread_->PostTask(registerBufferAvailableListener);
461     }
462 }
463 
GetScreenSupportedColorGamuts(ScreenId id,std::vector<ScreenColorGamut> & mode)464 int32_t RSRenderServiceConnection::GetScreenSupportedColorGamuts(ScreenId id, std::vector<ScreenColorGamut>& mode)
465 {
466     return mainThread_->ScheduleTask([=, &mode]() {
467         return screenManager_->GetScreenSupportedColorGamuts(id, mode);
468     }).get();
469 }
470 
GetScreenSupportedMetaDataKeys(ScreenId id,std::vector<ScreenHDRMetadataKey> & keys)471 int32_t RSRenderServiceConnection::GetScreenSupportedMetaDataKeys(ScreenId id, std::vector<ScreenHDRMetadataKey>& keys)
472 {
473     return mainThread_->ScheduleTask([=, &keys]() {
474         return screenManager_->GetScreenSupportedMetaDataKeys(id, keys);
475     }).get();
476 }
477 
GetScreenColorGamut(ScreenId id,ScreenColorGamut & mode)478 int32_t RSRenderServiceConnection::GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode)
479 {
480     return mainThread_->ScheduleTask([=, &mode]() {
481         return screenManager_->GetScreenColorGamut(id, mode);
482     }).get();
483 }
484 
SetScreenColorGamut(ScreenId id,int32_t modeIdx)485 int32_t RSRenderServiceConnection::SetScreenColorGamut(ScreenId id, int32_t modeIdx)
486 {
487     return mainThread_->ScheduleTask([=]() {
488         return screenManager_->SetScreenColorGamut(id, modeIdx);
489     }).get();
490 }
491 
SetScreenGamutMap(ScreenId id,ScreenGamutMap mode)492 int32_t RSRenderServiceConnection::SetScreenGamutMap(ScreenId id, ScreenGamutMap mode)
493 {
494     return mainThread_->ScheduleTask([=]() {
495         return screenManager_->SetScreenGamutMap(id, mode);
496     }).get();
497 }
498 
GetScreenGamutMap(ScreenId id,ScreenGamutMap & mode)499 int32_t RSRenderServiceConnection::GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode)
500 {
501     return mainThread_->ScheduleTask([=, &mode]() {
502         return screenManager_->GetScreenGamutMap(id, mode);
503     }).get();
504 }
505 
GetScreenHDRCapability(ScreenId id,RSScreenHDRCapability & screenHdrCapability)506 int32_t RSRenderServiceConnection::GetScreenHDRCapability(ScreenId id, RSScreenHDRCapability& screenHdrCapability)
507 {
508     std::lock_guard<std::mutex> lock(mutex_);
509     return screenManager_->GetScreenHDRCapability(id, screenHdrCapability);
510 }
511 
GetScreenType(ScreenId id,RSScreenType & screenType)512 int32_t RSRenderServiceConnection::GetScreenType(ScreenId id, RSScreenType& screenType)
513 {
514     std::lock_guard<std::mutex> lock(mutex_);
515     return screenManager_->GetScreenType(id, screenType);
516 }
517 
SetScreenSkipFrameInterval(ScreenId id,uint32_t skipFrameInterval)518 int32_t RSRenderServiceConnection::SetScreenSkipFrameInterval(ScreenId id, uint32_t skipFrameInterval)
519 {
520     return mainThread_->ScheduleTask([=]() {
521         return screenManager_->SetScreenSkipFrameInterval(id, skipFrameInterval);
522     }).get();
523 }
524 
RegisterOcclusionChangeCallback(sptr<RSIOcclusionChangeCallback> callback)525 int32_t RSRenderServiceConnection::RegisterOcclusionChangeCallback(sptr<RSIOcclusionChangeCallback> callback)
526 {
527     std::lock_guard<std::mutex> lock(mutex_);
528     if (!callback) {
529         RS_LOGD("RSRenderServiceConnection::RegisterOcclusionChangeCallback: callback is nullptr");
530         return StatusCode::INVALID_ARGUMENTS;
531     }
532     mainThread_->RegisterOcclusionChangeCallback(remotePid_, callback);
533     return StatusCode::SUCCESS;
534 }
535 
SetAppWindowNum(uint32_t num)536 void RSRenderServiceConnection::SetAppWindowNum(uint32_t num)
537 {
538     auto task = [this, num]() -> void {
539         mainThread_->SetAppWindowNum(num);
540     };
541     mainThread_->PostTask(task);
542 }
543 } // namespace Rosen
544 } // namespace OHOS
545