• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "rs_interfaces.h"
17 
18 namespace OHOS {
19 namespace Rosen {
GetInstance()20 RSInterfaces &RSInterfaces::GetInstance()
21 {
22     static RSInterfaces instance;
23     return instance;
24 }
25 
RSInterfaces()26 RSInterfaces::RSInterfaces() : renderServiceClient_(std::make_unique<RSRenderServiceClient>())
27 {
28 }
29 
~RSInterfaces()30 RSInterfaces::~RSInterfaces() noexcept
31 {
32 }
33 
SetFocusAppInfo(FocusAppInfo & info)34 int32_t RSInterfaces::SetFocusAppInfo(FocusAppInfo& info)
35 {
36     int32_t pid = info.pid;
37     int32_t uid = info.uid;
38     const std::string bundleName = info.bundleName;
39     const std::string abilityName = info.abilityName;
40     return renderServiceClient_->SetFocusAppInfo(pid, uid, bundleName, abilityName);
41 }
42 
GetDefaultScreenId()43 ScreenId RSInterfaces::GetDefaultScreenId()
44 {
45     return renderServiceClient_->GetDefaultScreenId();
46 }
47 
GetAllScreenIds()48 std::vector<ScreenId> RSInterfaces::GetAllScreenIds()
49 {
50     return renderServiceClient_->GetAllScreenIds();
51 }
52 
53 #if !defined(__gnu_linux__) && !defined(_WIN32) && !defined(__APPLE__)
CreateVirtualScreen(const std::string & name,uint32_t width,uint32_t height,sptr<Surface> surface,ScreenId mirrorId,int flags)54 ScreenId RSInterfaces::CreateVirtualScreen(
55     const std::string &name,
56     uint32_t width,
57     uint32_t height,
58     sptr<Surface> surface,
59     ScreenId mirrorId,
60     int flags)
61 {
62     return renderServiceClient_->CreateVirtualScreen(name, width, height, surface, mirrorId, flags);
63 }
64 
SetVirtualScreenSurface(ScreenId id,sptr<Surface> surface)65 int32_t RSInterfaces::SetVirtualScreenSurface(ScreenId id, sptr<Surface> surface)
66 {
67     return renderServiceClient_->SetVirtualScreenSurface(id, surface);
68 }
69 #endif
70 
RemoveVirtualScreen(ScreenId id)71 void RSInterfaces::RemoveVirtualScreen(ScreenId id)
72 {
73     renderServiceClient_->RemoveVirtualScreen(id);
74 }
75 
SetScreenChangeCallback(const ScreenChangeCallback & callback)76 int32_t RSInterfaces::SetScreenChangeCallback(const ScreenChangeCallback &callback)
77 {
78     return renderServiceClient_->SetScreenChangeCallback(callback);
79 }
80 
TakeSurfaceCapture(std::shared_ptr<RSSurfaceNode> node,std::shared_ptr<SurfaceCaptureCallback> callback,float scaleX,float scaleY)81 bool RSInterfaces::TakeSurfaceCapture(std::shared_ptr<RSSurfaceNode> node,
82     std::shared_ptr<SurfaceCaptureCallback> callback, float scaleX, float scaleY)
83 {
84     return renderServiceClient_->TakeSurfaceCapture(node->GetId(), callback, scaleX, scaleY);
85 }
86 
TakeSurfaceCapture(std::shared_ptr<RSDisplayNode> node,std::shared_ptr<SurfaceCaptureCallback> callback,float scaleX,float scaleY)87 bool RSInterfaces::TakeSurfaceCapture(std::shared_ptr<RSDisplayNode> node,
88     std::shared_ptr<SurfaceCaptureCallback> callback, float scaleX, float scaleY)
89 {
90     return renderServiceClient_->TakeSurfaceCapture(node->GetId(), callback, scaleX, scaleY);
91 }
92 
SetScreenActiveMode(ScreenId id,uint32_t modeId)93 void RSInterfaces::SetScreenActiveMode(ScreenId id, uint32_t modeId)
94 {
95     renderServiceClient_->SetScreenActiveMode(id, modeId);
96 }
97 
SetVirtualScreenResolution(ScreenId id,uint32_t width,uint32_t height)98 int32_t RSInterfaces::SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height)
99 {
100     return renderServiceClient_->SetVirtualScreenResolution(id, width, height);
101 }
102 
GetVirtualScreenResolution(ScreenId id)103 RSVirtualScreenResolution RSInterfaces::GetVirtualScreenResolution(ScreenId id)
104 {
105     return renderServiceClient_->GetVirtualScreenResolution(id);
106 }
107 
SetScreenPowerStatus(ScreenId id,ScreenPowerStatus status)108 void RSInterfaces::SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status)
109 {
110     renderServiceClient_->SetScreenPowerStatus(id, status);
111 }
112 
GetScreenActiveMode(ScreenId id)113 RSScreenModeInfo RSInterfaces::GetScreenActiveMode(ScreenId id)
114 {
115     return renderServiceClient_->GetScreenActiveMode(id);
116 }
117 
GetScreenSupportedModes(ScreenId id)118 std::vector<RSScreenModeInfo> RSInterfaces::GetScreenSupportedModes(ScreenId id)
119 {
120     return renderServiceClient_->GetScreenSupportedModes(id);
121 }
122 
GetScreenCapability(ScreenId id)123 RSScreenCapability RSInterfaces::GetScreenCapability(ScreenId id)
124 {
125     return renderServiceClient_->GetScreenCapability(id);
126 }
127 
GetScreenPowerStatus(ScreenId id)128 ScreenPowerStatus RSInterfaces::GetScreenPowerStatus(ScreenId id)
129 {
130     return renderServiceClient_->GetScreenPowerStatus(id);
131 }
132 
GetScreenData(ScreenId id)133 RSScreenData RSInterfaces::GetScreenData(ScreenId id)
134 {
135     return renderServiceClient_->GetScreenData(id);
136 }
137 
GetScreenBacklight(ScreenId id)138 int32_t RSInterfaces::GetScreenBacklight(ScreenId id)
139 {
140     return renderServiceClient_->GetScreenBacklight(id);
141 }
142 
SetScreenBacklight(ScreenId id,uint32_t level)143 void RSInterfaces::SetScreenBacklight(ScreenId id, uint32_t level)
144 {
145     renderServiceClient_->SetScreenBacklight(id, level);
146 }
147 
GetScreenSupportedColorGamuts(ScreenId id,std::vector<ScreenColorGamut> & mode)148 int32_t RSInterfaces::GetScreenSupportedColorGamuts(ScreenId id, std::vector<ScreenColorGamut>& mode)
149 {
150     return renderServiceClient_->GetScreenSupportedColorGamuts(id, mode);
151 }
152 
GetScreenSupportedMetaDataKeys(ScreenId id,std::vector<ScreenHDRMetadataKey> & keys)153 int32_t RSInterfaces::GetScreenSupportedMetaDataKeys(ScreenId id, std::vector<ScreenHDRMetadataKey>& keys)
154 {
155     return renderServiceClient_->GetScreenSupportedMetaDataKeys(id, keys);
156 }
157 
GetScreenColorGamut(ScreenId id,ScreenColorGamut & mode)158 int32_t RSInterfaces::GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode)
159 {
160     return renderServiceClient_->GetScreenColorGamut(id, mode);
161 }
162 
SetScreenColorGamut(ScreenId id,int32_t modeIdx)163 int32_t RSInterfaces::SetScreenColorGamut(ScreenId id, int32_t modeIdx)
164 {
165     return renderServiceClient_->SetScreenColorGamut(id, modeIdx);
166 }
167 
SetScreenGamutMap(ScreenId id,ScreenGamutMap mode)168 int32_t RSInterfaces::SetScreenGamutMap(ScreenId id, ScreenGamutMap mode)
169 {
170     return renderServiceClient_->SetScreenGamutMap(id, mode);
171 }
172 
GetScreenGamutMap(ScreenId id,ScreenGamutMap & mode)173 int32_t RSInterfaces::GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode)
174 {
175     return renderServiceClient_->GetScreenGamutMap(id, mode);
176 }
177 
CreateVSyncReceiver(const std::string & name,const std::shared_ptr<OHOS::AppExecFwk::EventHandler> & looper)178 std::shared_ptr<VSyncReceiver> RSInterfaces::CreateVSyncReceiver(
179     const std::string& name,
180     const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper)
181 {
182     return renderServiceClient_->CreateVSyncReceiver(name, looper);
183 }
184 
GetScreenHDRCapability(ScreenId id,RSScreenHDRCapability & screenHdrCapability)185 int32_t RSInterfaces::GetScreenHDRCapability(ScreenId id, RSScreenHDRCapability& screenHdrCapability)
186 {
187     return renderServiceClient_->GetScreenHDRCapability(id, screenHdrCapability);
188 }
189 
GetScreenType(ScreenId id,RSScreenType & screenType)190 int32_t RSInterfaces::GetScreenType(ScreenId id, RSScreenType& screenType)
191 {
192     return renderServiceClient_->GetScreenType(id, screenType);
193 }
194 
SetScreenSkipFrameInterval(ScreenId id,uint32_t skipFrameInterval)195 int32_t RSInterfaces::SetScreenSkipFrameInterval(ScreenId id, uint32_t skipFrameInterval)
196 {
197     return renderServiceClient_->SetScreenSkipFrameInterval(id, skipFrameInterval);
198 }
199 
RegisterOcclusionChangeCallback(const OcclusionChangeCallback & callback)200 int32_t RSInterfaces::RegisterOcclusionChangeCallback(const OcclusionChangeCallback& callback)
201 {
202     return renderServiceClient_->RegisterOcclusionChangeCallback(callback);
203 }
204 
UnRegisterOcclusionChangeCallback(const OcclusionChangeCallback & callback)205 int32_t RSInterfaces::UnRegisterOcclusionChangeCallback(const OcclusionChangeCallback& callback)
206 {
207     return renderServiceClient_->UnRegisterOcclusionChangeCallback(callback);
208 }
209 
SetRenderModeChangeCallback(const RenderModeChangeCallback & callback)210 int32_t RSInterfaces::SetRenderModeChangeCallback(const RenderModeChangeCallback& callback)
211 {
212     return renderServiceClient_->SetRenderModeChangeCallback(callback);
213 }
214 
UpdateRenderMode(bool isUniRender)215 void RSInterfaces::UpdateRenderMode(bool isUniRender)
216 {
217     renderServiceClient_->UpdateRenderMode(isUniRender);
218 }
219 
SetAppWindowNum(uint32_t num)220 void RSInterfaces::SetAppWindowNum(uint32_t num)
221 {
222     renderServiceClient_->SetAppWindowNum(num);
223 }
224 } // namespace Rosen
225 } // namespace OHOS
226