• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 
GetDefaultScreenId()34 ScreenId RSInterfaces::GetDefaultScreenId()
35 {
36     return renderServiceClient_->GetDefaultScreenId();
37 }
38 
CreateVirtualScreen(const std::string & name,uint32_t width,uint32_t height,sptr<Surface> surface,ScreenId mirrorId,int flags)39 ScreenId RSInterfaces::CreateVirtualScreen(
40     const std::string &name,
41     uint32_t width,
42     uint32_t height,
43     sptr<Surface> surface,
44     ScreenId mirrorId,
45     int flags)
46 {
47     return renderServiceClient_->CreateVirtualScreen(name, width, height, surface, mirrorId, flags);
48 }
49 
SetVirtualScreenSurface(ScreenId id,sptr<Surface> surface)50 int32_t RSInterfaces::SetVirtualScreenSurface(ScreenId id, sptr<Surface> surface)
51 {
52     return renderServiceClient_->SetVirtualScreenSurface(id, surface);
53 }
54 
RemoveVirtualScreen(ScreenId id)55 void RSInterfaces::RemoveVirtualScreen(ScreenId id)
56 {
57     renderServiceClient_->RemoveVirtualScreen(id);
58 }
59 
SetScreenChangeCallback(const ScreenChangeCallback & callback)60 int32_t RSInterfaces::SetScreenChangeCallback(const ScreenChangeCallback &callback)
61 {
62     return renderServiceClient_->SetScreenChangeCallback(callback);
63 }
64 
TakeSurfaceCapture(std::shared_ptr<RSSurfaceNode> node,std::shared_ptr<SurfaceCaptureCallback> callback,float scaleX,float scaleY)65 bool RSInterfaces::TakeSurfaceCapture(std::shared_ptr<RSSurfaceNode> node,
66     std::shared_ptr<SurfaceCaptureCallback> callback, float scaleX, float scaleY)
67 {
68     return renderServiceClient_->TakeSurfaceCapture(node->GetId(), callback, scaleX, scaleY);
69 }
70 
TakeSurfaceCapture(std::shared_ptr<RSDisplayNode> node,std::shared_ptr<SurfaceCaptureCallback> callback,float scaleX,float scaleY)71 bool RSInterfaces::TakeSurfaceCapture(std::shared_ptr<RSDisplayNode> node,
72     std::shared_ptr<SurfaceCaptureCallback> callback, float scaleX, float scaleY)
73 {
74     return renderServiceClient_->TakeSurfaceCapture(node->GetId(), callback, scaleX, scaleY);
75 }
76 
SetScreenActiveMode(ScreenId id,uint32_t modeId)77 void RSInterfaces::SetScreenActiveMode(ScreenId id, uint32_t modeId)
78 {
79     renderServiceClient_->SetScreenActiveMode(id, modeId);
80 }
81 
SetScreenPowerStatus(ScreenId id,ScreenPowerStatus status)82 void RSInterfaces::SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status)
83 {
84     renderServiceClient_->SetScreenPowerStatus(id, status);
85 }
86 
GetScreenActiveMode(ScreenId id)87 RSScreenModeInfo RSInterfaces::GetScreenActiveMode(ScreenId id)
88 {
89     return renderServiceClient_->GetScreenActiveMode(id);
90 }
91 
GetScreenSupportedModes(ScreenId id)92 std::vector<RSScreenModeInfo> RSInterfaces::GetScreenSupportedModes(ScreenId id)
93 {
94     return renderServiceClient_->GetScreenSupportedModes(id);
95 }
96 
GetScreenCapability(ScreenId id)97 RSScreenCapability RSInterfaces::GetScreenCapability(ScreenId id)
98 {
99     return renderServiceClient_->GetScreenCapability(id);
100 }
101 
GetScreenPowerStatus(ScreenId id)102 ScreenPowerStatus RSInterfaces::GetScreenPowerStatus(ScreenId id)
103 {
104     return renderServiceClient_->GetScreenPowerStatus(id);
105 }
106 
GetScreenData(ScreenId id)107 RSScreenData RSInterfaces::GetScreenData(ScreenId id)
108 {
109     return renderServiceClient_->GetScreenData(id);
110 }
111 
GetScreenBacklight(ScreenId id)112 int32_t RSInterfaces::GetScreenBacklight(ScreenId id)
113 {
114     return renderServiceClient_->GetScreenBacklight(id);
115 }
116 
SetScreenBacklight(ScreenId id,uint32_t level)117 void RSInterfaces::SetScreenBacklight(ScreenId id, uint32_t level)
118 {
119     renderServiceClient_->SetScreenBacklight(id, level);
120 }
121 
GetScreenSupportedColorGamuts(ScreenId id,std::vector<ScreenColorGamut> & mode)122 int32_t RSInterfaces::GetScreenSupportedColorGamuts(ScreenId id, std::vector<ScreenColorGamut>& mode)
123 {
124     return renderServiceClient_->GetScreenSupportedColorGamuts(id, mode);
125 }
126 
GetScreenColorGamut(ScreenId id,ScreenColorGamut & mode)127 int32_t RSInterfaces::GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode)
128 {
129     return renderServiceClient_->GetScreenColorGamut(id, mode);
130 }
131 
SetScreenColorGamut(ScreenId id,int32_t modeIdx)132 int32_t RSInterfaces::SetScreenColorGamut(ScreenId id, int32_t modeIdx)
133 {
134     return renderServiceClient_->SetScreenColorGamut(id, modeIdx);
135 }
136 
SetScreenGamutMap(ScreenId id,ScreenGamutMap mode)137 int32_t RSInterfaces::SetScreenGamutMap(ScreenId id, ScreenGamutMap mode)
138 {
139     return renderServiceClient_->SetScreenGamutMap(id, mode);
140 }
141 
GetScreenGamutMap(ScreenId id,ScreenGamutMap & mode)142 int32_t RSInterfaces::GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode)
143 {
144     return renderServiceClient_->GetScreenGamutMap(id, mode);
145 }
146 
CreateVSyncReceiver(const std::string & name,const std::shared_ptr<OHOS::AppExecFwk::EventHandler> & looper)147 std::shared_ptr<VSyncReceiver> RSInterfaces::CreateVSyncReceiver(
148     const std::string& name,
149     const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper)
150 {
151     return renderServiceClient_->CreateVSyncReceiver(name, looper);
152 }
153 
RequestRotation(ScreenId id,ScreenRotation rotation)154 bool RSInterfaces::RequestRotation(ScreenId id, ScreenRotation rotation)
155 {
156     return renderServiceClient_->RequestRotation(id, rotation);
157 }
158 
GetRotation(ScreenId id)159 ScreenRotation RSInterfaces::GetRotation(ScreenId id)
160 {
161     return renderServiceClient_->GetRotation(id);
162 }
163 } // namespace Rosen
164 } // namespace OHOS
165