• 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 #ifndef ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_RENDER_SERVICE_CONNECTION_PROXY_H
17 #define ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_RENDER_SERVICE_CONNECTION_PROXY_H
18 
19 #include "command/rs_node_showing_command.h"
20 #include <iremote_proxy.h>
21 #include <memory>
22 #include <platform/ohos/rs_irender_service_connection.h>
23 #include <platform/ohos/rs_irender_service_connection_ipc_interface_code.h>
24 #include "sandbox_utils.h"
25 
26 namespace OHOS {
27 namespace Rosen {
28 class RSRenderServiceConnectionProxy : public IRemoteProxy<RSIRenderServiceConnection> {
29 public:
30     explicit RSRenderServiceConnectionProxy(const sptr<IRemoteObject>& impl);
31     virtual ~RSRenderServiceConnectionProxy() noexcept = default;
32 
33     void CommitTransaction(std::unique_ptr<RSTransactionData>& transactionData) override;
34     void ExecuteSynchronousTask(const std::shared_ptr<RSSyncTask>& task) override;
35 
36     MemoryGraphic GetMemoryGraphic(int pid) override;
37     std::vector<MemoryGraphic> GetMemoryGraphics() override;
38     bool GetTotalAppMemSize(float& cpuMemSize, float& gpuMemSize) override;
39 
40     bool GetUniRenderEnabled() override;
41 
42     bool CreateNode(const RSSurfaceRenderNodeConfig& config) override;
43     bool CreateNode(const RSDisplayNodeConfig& displayNodeConfig, NodeId nodeId) override;
44     sptr<Surface> CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config, bool unobscured = false) override;
45 
46     virtual sptr<IVSyncConnection> CreateVSyncConnection(const std::string& name,
47                                                          const sptr<VSyncIConnectionToken>& token,
48                                                          uint64_t id = 0,
49                                                          NodeId windowNodeId = 0,
50                                                          bool fromXcomponent = false) override;
51 
52     std::shared_ptr<Media::PixelMap> CreatePixelMapFromSurface(sptr<Surface> surface, const Rect &srcRect) override;
53 
54     int32_t SetFocusAppInfo(
55         int32_t pid, int32_t uid, const std::string &bundleName, const std::string &abilityName,
56         uint64_t focusNodeId) override;
57 
58     ScreenId GetDefaultScreenId() override;
59     ScreenId GetActiveScreenId() override;
60 
61     std::vector<ScreenId> GetAllScreenIds() override;
62 
63     // mirrorId: decide which screen id to mirror, INVALID_SCREEN_ID means do not mirror any screen.
64     ScreenId CreateVirtualScreen(
65         const std::string &name,
66         uint32_t width,
67         uint32_t height,
68         sptr<Surface> surface,
69         ScreenId mirrorId = 0,
70         int32_t flags = 0,
71         std::vector<NodeId> whiteList = {}) override;
72 
73     int32_t SetVirtualScreenSurface(ScreenId id, sptr<Surface> surface) override;
74 
75     int32_t SetVirtualScreenBlackList(ScreenId id, std::vector<NodeId>& blackListVector) override;
76 
77     int32_t AddVirtualScreenBlackList(ScreenId id, std::vector<NodeId>& blackListVector) override;
78 
79     int32_t RemoveVirtualScreenBlackList(ScreenId id, std::vector<NodeId>& blackListVector) override;
80 
81     int32_t SetVirtualScreenSecurityExemptionList(
82         ScreenId id, const std::vector<NodeId>& securityExemptionList) override;
83 
84     int32_t SetCastScreenEnableSkipWindow(ScreenId id, bool enable) override;
85 
86     void RemoveVirtualScreen(ScreenId id) override;
87 
88     int32_t SetScreenChangeCallback(sptr<RSIScreenChangeCallback> callback) override;
89 
90     void SetScreenActiveMode(ScreenId id, uint32_t modeId) override;
91 
92     void SetScreenRefreshRate(ScreenId id, int32_t sceneId, int32_t rate) override;
93 
94     void SetRefreshRateMode(int32_t refreshRateMode) override;
95 
96     void SyncFrameRateRange(FrameRateLinkerId id, const FrameRateRange& range,
97         int32_t animatorExpectedFrameRate) override;
98 
99     void UnregisterFrameRateLinker(FrameRateLinkerId id) override;
100 
101     uint32_t GetScreenCurrentRefreshRate(ScreenId id) override;
102 
103     int32_t GetCurrentRefreshRateMode() override;
104 
105     std::vector<int32_t> GetScreenSupportedRefreshRates(ScreenId id) override;
106 
107     bool GetShowRefreshRateEnabled() override;
108 
109     void SetShowRefreshRateEnabled(bool enable) override;
110 
111     std::string GetRefreshInfo(pid_t pid) override;
112 
113     int32_t SetPhysicalScreenResolution(ScreenId id, uint32_t width, uint32_t height) override;
114 
115     int32_t SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height) override;
116 
117     void MarkPowerOffNeedProcessOneFrame() override;
118 
119     void DisablePowerOffRenderControl(ScreenId id) override;
120 
121     void SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status) override;
122 
123     void RegisterApplicationAgent(uint32_t pid, sptr<IApplicationAgent> app) override;
124 
125     void TakeSurfaceCapture(NodeId id, sptr<RSISurfaceCaptureCallback> callback,
126         const RSSurfaceCaptureConfig& captureConfig,
127         const Drawing::Rect& specifiedAreaRect = Drawing::Rect(0.f, 0.f, 0.f, 0.f),
128         RSSurfaceCapturePermissions permissions = RSSurfaceCapturePermissions()) override;
129 
130     void SetWindowFreezeImmediately(NodeId id, bool isFreeze, sptr<RSISurfaceCaptureCallback> callback,
131         const RSSurfaceCaptureConfig& captureConfig) override;
132 
133     bool WriteSurfaceCaptureConfig(const RSSurfaceCaptureConfig& captureConfig, MessageParcel& data);
134 
135     bool WriteSurfaceCaptureAreaRect(const Drawing::Rect& specifiedAreaRect, MessageParcel& data);
136 
137     RSVirtualScreenResolution GetVirtualScreenResolution(ScreenId id) override;
138 
139     RSScreenModeInfo GetScreenActiveMode(ScreenId id) override;
140 
141     std::vector<RSScreenModeInfo> GetScreenSupportedModes(ScreenId id) override;
142 
143     RSScreenCapability GetScreenCapability(ScreenId id) override;
144 
145     ScreenPowerStatus GetScreenPowerStatus(ScreenId id) override;
146 
147     RSScreenData GetScreenData(ScreenId id) override;
148 
149     int32_t GetScreenBacklight(ScreenId id) override;
150 
151     void SetScreenBacklight(ScreenId id, uint32_t level) override;
152 
153     void RegisterBufferAvailableListener(
154         NodeId id, sptr<RSIBufferAvailableCallback> callback, bool isFromRenderThread) override;
155 
156     void RegisterBufferClearListener(
157         NodeId id, sptr<RSIBufferClearCallback> callback) override;
158 
159     int32_t GetScreenSupportedColorGamuts(ScreenId id, std::vector<ScreenColorGamut>& mode) override;
160 
161     int32_t GetScreenSupportedMetaDataKeys(ScreenId id, std::vector<ScreenHDRMetadataKey>& keys) override;
162 
163     int32_t GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode) override;
164 
165     int32_t SetScreenColorGamut(ScreenId id, int32_t modeIdx) override;
166 
167     int32_t SetScreenGamutMap(ScreenId id, ScreenGamutMap mode) override;
168 
169     int32_t SetScreenCorrection(ScreenId id, ScreenRotation screenRotation) override;
170 
171     bool SetVirtualMirrorScreenCanvasRotation(ScreenId id, bool canvasRotation) override;
172 
173     bool SetVirtualMirrorScreenScaleMode(ScreenId id, ScreenScaleMode scaleMode) override;
174 
175     bool SetGlobalDarkColorMode(bool isDark) override;
176 
177     int32_t GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode) override;
178 
179     int32_t GetScreenHDRCapability(ScreenId id, RSScreenHDRCapability& screenHdrCapability) override;
180 
181     int32_t GetPixelFormat(ScreenId id, GraphicPixelFormat& pixelFormat) override;
182 
183     int32_t SetPixelFormat(ScreenId id, GraphicPixelFormat pixelFormat) override;
184 
185     int32_t GetScreenSupportedHDRFormats(ScreenId id, std::vector<ScreenHDRFormat>& hdrFormats) override;
186 
187     int32_t GetScreenHDRFormat(ScreenId id, ScreenHDRFormat& hdrFormat) override;
188 
189     int32_t SetScreenHDRFormat(ScreenId id, int32_t modeIdx) override;
190 
191     int32_t GetScreenSupportedColorSpaces(ScreenId id, std::vector<GraphicCM_ColorSpaceType>& colorSpaces) override;
192 
193     int32_t GetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType& colorSpace) override;
194 
195     int32_t SetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType colorSpace) override;
196 
197     int32_t GetScreenType(ScreenId id, RSScreenType& screenType) override;
198 
199     bool GetBitmap(NodeId id, Drawing::Bitmap& bitmap) override;
200     bool GetPixelmap(NodeId id, std::shared_ptr<Media::PixelMap> pixelmap,
201         const Drawing::Rect* rect, std::shared_ptr<Drawing::DrawCmdList> drawCmdList) override;
202     bool RegisterTypeface(uint64_t globalUniqueId, std::shared_ptr<Drawing::Typeface>& typeface) override;
203     bool UnRegisterTypeface(uint64_t globalUniqueId) override;
204 
205     int32_t SetScreenSkipFrameInterval(ScreenId id, uint32_t skipFrameInterval) override;
206 
207     int32_t SetVirtualScreenRefreshRate(ScreenId id, uint32_t maxRefreshRate, uint32_t& actualRefreshRate) override;
208 
209     uint32_t SetScreenActiveRect(ScreenId id, const Rect& activeRect) override;
210 
211     int32_t RegisterOcclusionChangeCallback(sptr<RSIOcclusionChangeCallback> callback) override;
212 
213     int32_t RegisterSurfaceOcclusionChangeCallback(
214         NodeId id, sptr<RSISurfaceOcclusionChangeCallback> callback, std::vector<float>& partitionPoints) override;
215 
216     int32_t UnRegisterSurfaceOcclusionChangeCallback(NodeId id) override;
217 
218     int32_t RegisterHgmConfigChangeCallback(sptr<RSIHgmConfigChangeCallback> callback) override;
219 
220     int32_t RegisterHgmRefreshRateModeChangeCallback(sptr<RSIHgmConfigChangeCallback> callback) override;
221 
222     int32_t RegisterHgmRefreshRateUpdateCallback(sptr<RSIHgmConfigChangeCallback> callback) override;
223 
224     int32_t RegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid,
225         sptr<RSIFrameRateLinkerExpectedFpsUpdateCallback> callback) override;
226 
227     void SetAppWindowNum(uint32_t num) override;
228 
229     bool SetSystemAnimatedScenes(SystemAnimatedScenes systemAnimatedScenes) override;
230 
231     void ShowWatermark(const std::shared_ptr<Media::PixelMap> &watermarkImg, bool isShow) override;
232 
233     int32_t ResizeVirtualScreen(ScreenId id, uint32_t width, uint32_t height) override;
234 
235     void ReportJankStats() override;
236 
237     void NotifyLightFactorStatus(bool isSafe) override;
238 
239     void NotifyPackageEvent(uint32_t listSize, const std::vector<std::string>& packageList) override;
240 
241     void NotifyRefreshRateEvent(const EventInfo& eventInfo) override;
242 
243     void NotifyTouchEvent(int32_t touchStatus, int32_t touchCnt) override;
244 
245     void NotifyDynamicModeEvent(bool enableDynamicMode) override;
246 
247     void ReportEventResponse(DataBaseRs info) override;
248 
249     void ReportEventComplete(DataBaseRs info) override;
250 
251     void ReportEventJankFrame(DataBaseRs info) override;
252 
253     void ReportGameStateData(GameStateData info) override;
254 
255     void SetHardwareEnabled(NodeId id, bool isEnabled, SelfDrawingNodeType selfDrawingType,
256         bool dynamicHardwareEnable) override;
257 
258     uint32_t SetHidePrivacyContent(NodeId id, bool needHidePrivacyContent) override;
259 
260     void SetCacheEnabledForRotation(bool isEnabled) override;
261 
262     void SetOnRemoteDiedCallback(const OnRemoteDiedCallback& callback) override;
263 
264     void RunOnRemoteDiedCallback() override;
265 
266     std::vector<ActiveDirtyRegionInfo> GetActiveDirtyRegionInfo() override;
267 
268     GlobalDirtyRegionInfo GetGlobalDirtyRegionInfo() override;
269 
270     LayerComposeInfo GetLayerComposeInfo() override;
271 
272     HwcDisabledReasonInfos GetHwcDisabledReasonInfo() override;
273 
274     void SetVmaCacheStatus(bool flag) override;
275 
276     int32_t RegisterUIExtensionCallback(uint64_t userId, sptr<RSIUIExtensionCallback> callback,
277         bool unobscured = false) override;
278 
279 #ifdef TP_FEATURE_ENABLE
280     void SetTpFeatureConfig(int32_t feature, const char* config,
281         TpFeatureConfigType tpFeatureConfigType = TpFeatureConfigType::DEFAULT_TP_FEATURE) override;
282 #endif
283     void SetVirtualScreenUsingStatus(bool isVirtualScreenUsingStatus) override;
284     void SetCurtainScreenUsingStatus(bool isCurtainScreenOn) override;
285 
286     void DropFrameByPid(const std::vector<int32_t> pidList) override;
287 
288     void RegisterSurfaceBufferCallback(pid_t pid, uint64_t uid,
289         sptr<RSISurfaceBufferCallback> callback) override;
290 
291     void UnregisterSurfaceBufferCallback(pid_t pid, uint64_t uid) override;
292 
293     void NotifyScreenSwitched() override;
294 
295     void SetWindowContainer(NodeId nodeId, bool value) override;
296 private:
297     bool FillParcelWithTransactionData(
298         std::unique_ptr<RSTransactionData>& transactionData, std::shared_ptr<MessageParcel>& data);
299 
300     void ReportDataBaseRs(MessageParcel& data, MessageParcel& reply, MessageOption& option, DataBaseRs info);
301 
302     void ReportGameStateDataRs(MessageParcel& data, MessageParcel& reply, MessageOption& option, GameStateData info);
303 
304     bool SetAncoForceDoDirect(bool direct) override;
305 
306     void SetLayerTop(const std::string &nodeIdStr, bool isTop) override;
307 
308     static inline BrokerDelegator<RSRenderServiceConnectionProxy> delegator_;
309 
310     pid_t pid_ = GetRealPid();
311     uint32_t transactionDataIndex_ = 0;
312     OnRemoteDiedCallback OnRemoteDiedCallback_;
313 };
314 } // namespace Rosen
315 } // namespace OHOS
316 
317 #endif // ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_RENDER_SERVICE_CONNECTION_PROXY_H
318