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