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_CLIENT_H 17 #define ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_RENDER_SERVICE_CLIENT_H 18 19 #include <functional> 20 #include <map> 21 #include <memory> 22 #include <mutex> 23 #include <shared_mutex> 24 #include <refbase.h> 25 #include <surface_type.h> 26 #ifndef ROSEN_CROSS_PLATFORM 27 #include <surface.h> 28 #include <utility> 29 #endif 30 31 #include "common/rs_self_draw_rect_change_callback_constraint.h" 32 #include "ipc_callbacks/buffer_available_callback.h" 33 #include "ipc_callbacks/iapplication_agent.h" 34 #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR 35 #include "ipc_callbacks/pointer_render/pointer_luminance_change_callback.h" 36 #endif 37 #include "ipc_callbacks/rs_surface_buffer_callback.h" 38 #include "ipc_callbacks/screen_change_callback.h" 39 #include "ipc_callbacks/screen_switching_notify_callback.h" 40 #include "ipc_callbacks/surface_capture_callback.h" 41 #include "ipc_callbacks/rs_transaction_data_callback.h" 42 #include "memory/rs_memory_graphic.h" 43 #include "platform/drawing/rs_surface.h" 44 #include "rs_hrp_service.h" 45 #include "rs_irender_client.h" 46 #include "variable_frame_rate/rs_variable_frame_rate.h" 47 #include "screen_manager/rs_screen_capability.h" 48 #include "screen_manager/rs_screen_data.h" 49 #include "screen_manager/rs_screen_hdr_capability.h" 50 #include "screen_manager/rs_screen_mode_info.h" 51 #include "screen_manager/screen_types.h" 52 #include "screen_manager/rs_virtual_screen_resolution.h" 53 #include "vsync_receiver.h" 54 #include "ipc_callbacks/rs_iocclusion_change_callback.h" 55 #include "rs_hgm_config_data.h" 56 #include "rs_occlusion_data.h" 57 #include "rs_self_drawing_node_rect_data.h" 58 #include "rs_uiextension_data.h" 59 #include "info_collection/rs_gpu_dirty_region_collection.h" 60 #include "info_collection/rs_hardware_compose_disabled_reason_collection.h" 61 #include "info_collection/rs_layer_compose_collection.h" 62 #include "utils/scalar.h" 63 64 namespace OHOS { 65 namespace Rosen { 66 // normal callback functor for client users. 67 using ScreenChangeCallback = std::function<void(ScreenId, ScreenEvent, ScreenChangeReason)>; 68 using ScreenSwitchingNotifyCallback = std::function<void(bool)>; 69 #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR 70 using PointerLuminanceChangeCallback = std::function<void(int32_t)>; 71 #endif 72 using BufferAvailableCallback = std::function<void()>; 73 using BufferClearCallback = std::function<void()>; 74 using OcclusionChangeCallback = std::function<void(std::shared_ptr<RSOcclusionData>)>; 75 using SurfaceOcclusionChangeCallback = std::function<void(float)>; 76 using HgmConfigChangeCallback = std::function<void(std::shared_ptr<RSHgmConfigData>)>; 77 using OnRemoteDiedCallback = std::function<void()>; 78 using HgmRefreshRateModeChangeCallback = std::function<void(int32_t)>; 79 using HgmRefreshRateUpdateCallback = std::function<void(int32_t)>; 80 using FrameRateLinkerExpectedFpsUpdateCallback = std::function<void(int32_t, const std::string&, int32_t)>; 81 using UIExtensionCallback = std::function<void(std::shared_ptr<RSUIExtensionData>, uint64_t)>; 82 using SelfDrawingNodeRectChangeCallback = std::function<void(std::shared_ptr<RSSelfDrawingNodeRectData>)>; 83 using FirstFrameCommitCallback = std::function<void(uint64_t, int64_t)>; 84 struct DataBaseRs { 85 int32_t appPid = -1; 86 int32_t eventType = -1; 87 int32_t versionCode = -1; 88 int64_t uniqueId = 0; 89 int64_t inputTime = 0; 90 int64_t beginVsyncTime = 0; 91 int64_t endVsyncTime = 0; 92 bool isDisplayAnimator = false; 93 std::string sceneId; 94 std::string versionName; 95 std::string bundleName; 96 std::string processName; 97 std::string abilityName; 98 std::string pageUrl; 99 std::string sourceType; 100 std::string note; 101 }; 102 103 struct AppInfo { 104 int64_t startTime = 0; 105 int64_t endTime = 0; 106 int32_t pid = 0; 107 std::string versionName; 108 int32_t versionCode = -1; 109 std::string bundleName; 110 std::string processName; 111 }; 112 struct GameStateData { 113 int32_t pid = -1; 114 int32_t uid = 0; 115 int32_t state = 0; 116 int32_t renderTid = -1; 117 std::string bundleName; 118 }; 119 120 class SurfaceCaptureCallback { 121 public: SurfaceCaptureCallback()122 SurfaceCaptureCallback() {} ~SurfaceCaptureCallback()123 virtual ~SurfaceCaptureCallback() {} 124 virtual void OnSurfaceCapture(std::shared_ptr<Media::PixelMap> pixelmap) = 0; 125 virtual void OnSurfaceCaptureHDR(std::shared_ptr<Media::PixelMap> pixelmap, 126 std::shared_ptr<Media::PixelMap> pixelmapHDR) = 0; 127 }; 128 129 class SurfaceBufferCallback { 130 public: 131 SurfaceBufferCallback() = default; 132 virtual ~SurfaceBufferCallback() noexcept = default; 133 virtual void OnFinish(const FinishCallbackRet& ret) = 0; 134 virtual void OnAfterAcquireBuffer(const AfterAcquireBufferRet& ret) = 0; 135 }; 136 137 class RSB_EXPORT RSRenderServiceClient : public RSIRenderClient { 138 public: 139 RSRenderServiceClient() = default; 140 virtual ~RSRenderServiceClient() = default; 141 142 RSRenderServiceClient(const RSRenderServiceClient&) = delete; 143 void operator=(const RSRenderServiceClient&) = delete; 144 145 void CommitTransaction(std::unique_ptr<RSTransactionData>& transactionData) override; 146 void ExecuteSynchronousTask(const std::shared_ptr<RSSyncTask>& task) override; 147 148 bool GetUniRenderEnabled(); 149 150 bool CreateNode(const RSSurfaceRenderNodeConfig& config); 151 bool CreateNode(const RSDisplayNodeConfig& displayNodeConfig, NodeId nodeId); 152 std::shared_ptr<RSSurface> CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config, bool unobscured = false); 153 std::shared_ptr<VSyncReceiver> CreateVSyncReceiver( 154 const std::string& name, 155 const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper = nullptr, 156 uint64_t id = 0, 157 NodeId windowNodeId = 0, 158 bool fromXcomponent = false); 159 160 int32_t GetPixelMapByProcessId(std::vector<PixelMapInfo>& pixelMapInfoVector, pid_t pid); 161 162 std::shared_ptr<Media::PixelMap> CreatePixelMapFromSurfaceId(uint64_t surfaceid, const Rect &srcRect); 163 164 bool TakeSurfaceCapture(NodeId id, std::shared_ptr<SurfaceCaptureCallback> callback, 165 const RSSurfaceCaptureConfig& captureConfig, 166 const RSSurfaceCaptureBlurParam& blurParam = {}, 167 const Drawing::Rect& specifiedAreaRect = Drawing::Rect(0.f, 0.f, 0.f, 0.f)); 168 169 std::vector<std::pair<NodeId, std::shared_ptr<Media::PixelMap>>> TakeSurfaceCaptureSoloNode( 170 NodeId id, const RSSurfaceCaptureConfig& captureConfig); 171 172 bool TakeSelfSurfaceCapture(NodeId id, std::shared_ptr<SurfaceCaptureCallback> callback, 173 const RSSurfaceCaptureConfig& captureConfig); 174 175 bool SetWindowFreezeImmediately(NodeId id, bool isFreeze, std::shared_ptr<SurfaceCaptureCallback> callback, 176 const RSSurfaceCaptureConfig& captureConfig, const RSSurfaceCaptureBlurParam& blurParam = {}); 177 178 bool TaskSurfaceCaptureWithAllWindows(NodeId id, 179 std::shared_ptr<SurfaceCaptureCallback> callback, const RSSurfaceCaptureConfig& captureConfig, 180 bool checkDrmAndSurfaceLock); 181 182 bool FreezeScreen(NodeId id, bool isFreeze); 183 184 bool TakeUICaptureInRange( 185 NodeId id, std::shared_ptr<SurfaceCaptureCallback> callback, const RSSurfaceCaptureConfig& captureConfig); 186 187 bool SetHwcNodeBounds(int64_t rsNodeId, float positionX, float positionY, 188 float positionZ, float positionW); 189 190 int32_t SetFocusAppInfo(const FocusAppInfo& info); 191 192 ScreenId GetDefaultScreenId(); 193 ScreenId GetActiveScreenId(); 194 195 std::vector<ScreenId> GetAllScreenIds(); 196 197 #ifndef ROSEN_CROSS_PLATFORM 198 std::shared_ptr<RSSurface> CreateRSSurface(const sptr<Surface> &surface); 199 ScreenId CreateVirtualScreen(const std::string& name, uint32_t width, uint32_t height, sptr<Surface> surface, 200 ScreenId mirrorId, int32_t flags, std::vector<NodeId> whiteList = {}); 201 202 int32_t SetVirtualScreenSurface(ScreenId id, sptr<Surface> surface); 203 204 int32_t SetVirtualScreenBlackList(ScreenId id, std::vector<NodeId>& blackListVector); 205 206 int32_t SetVirtualScreenTypeBlackList(ScreenId id, std::vector<NodeType>& typeBlackListVector); 207 208 int32_t AddVirtualScreenBlackList(ScreenId id, std::vector<NodeId>& blackListVector); 209 210 int32_t RemoveVirtualScreenBlackList(ScreenId id, std::vector<NodeId>& blackListVector); 211 #endif 212 213 int32_t SetVirtualScreenSecurityExemptionList(ScreenId id, const std::vector<NodeId>& securityExemptionList); 214 215 int32_t SetScreenSecurityMask(ScreenId id, std::shared_ptr<Media::PixelMap> securityMask); 216 217 int32_t SetMirrorScreenVisibleRect(ScreenId id, const Rect& mainScreenRect, bool supportRotation = false); 218 219 int32_t SetCastScreenEnableSkipWindow(ScreenId id, bool enable); 220 221 bool SetWatermark(const std::string& name, std::shared_ptr<Media::PixelMap> watermark); 222 223 void RemoveVirtualScreen(ScreenId id); 224 225 #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR 226 int32_t SetPointerColorInversionConfig(float darkBuffer, float brightBuffer, int64_t interval, int32_t rangeSize); 227 228 int32_t SetPointerColorInversionEnabled(bool enable); 229 230 int32_t RegisterPointerLuminanceChangeCallback(const PointerLuminanceChangeCallback &callback); 231 232 int32_t UnRegisterPointerLuminanceChangeCallback(); 233 #endif 234 235 int32_t SetScreenChangeCallback(const ScreenChangeCallback& callback); 236 237 int32_t SetScreenSwitchingNotifyCallback(const ScreenSwitchingNotifyCallback& callback); 238 239 #ifndef ROSEN_ARKUI_X 240 void SetScreenActiveMode(ScreenId id, uint32_t modeId); 241 #endif // !ROSEN_ARKUI_X 242 void SetScreenRefreshRate(ScreenId id, int32_t sceneId, int32_t rate); 243 244 void SetRefreshRateMode(int32_t refreshRateMode); 245 246 void SyncFrameRateRange(FrameRateLinkerId id, const FrameRateRange& range, 247 int32_t animatorExpectedFrameRate); 248 249 void UnregisterFrameRateLinker(FrameRateLinkerId id); 250 251 uint32_t GetScreenCurrentRefreshRate(ScreenId id); 252 253 int32_t GetCurrentRefreshRateMode(); 254 255 std::vector<int32_t> GetScreenSupportedRefreshRates(ScreenId id); 256 257 bool GetShowRefreshRateEnabled(); 258 259 void SetShowRefreshRateEnabled(bool enabled, int32_t type); 260 261 uint32_t GetRealtimeRefreshRate(ScreenId screenId); 262 263 std::string GetRefreshInfo(pid_t pid); 264 std::string GetRefreshInfoToSP(NodeId id); 265 266 #ifndef ROSEN_ARKUI_X 267 int32_t SetPhysicalScreenResolution(ScreenId id, uint32_t width, uint32_t height); 268 269 int32_t SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height); 270 271 RSVirtualScreenResolution GetVirtualScreenResolution(ScreenId id); 272 273 void MarkPowerOffNeedProcessOneFrame(); 274 275 void RepaintEverything(); 276 277 void DisablePowerOffRenderControl(ScreenId id); 278 279 void SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status); 280 281 RSScreenModeInfo GetScreenActiveMode(ScreenId id); 282 283 std::vector<RSScreenModeInfo> GetScreenSupportedModes(ScreenId id); 284 285 RSScreenCapability GetScreenCapability(ScreenId id); 286 287 ScreenPowerStatus GetScreenPowerStatus(ScreenId id); 288 289 RSScreenData GetScreenData(ScreenId id); 290 291 MemoryGraphic GetMemoryGraphic(int pid); 292 293 std::vector<MemoryGraphic> GetMemoryGraphics(); 294 #endif // !ROSEN_ARKUI_X 295 bool GetTotalAppMemSize(float& cpuMemSize, float& gpuMemSize); 296 297 int32_t GetScreenBacklight(ScreenId id); 298 299 void SetScreenBacklight(ScreenId id, uint32_t level); 300 301 bool RegisterBufferAvailableListener( 302 NodeId id, const BufferAvailableCallback &callback, bool isFromRenderThread = false); 303 304 bool RegisterBufferClearListener( 305 NodeId id, const BufferClearCallback &callback); 306 307 bool UnregisterBufferAvailableListener(NodeId id); 308 309 int32_t GetScreenSupportedColorGamuts(ScreenId id, std::vector<ScreenColorGamut>& mode); 310 311 int32_t GetScreenSupportedMetaDataKeys(ScreenId id, std::vector<ScreenHDRMetadataKey>& keys); 312 313 int32_t GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode); 314 315 int32_t SetScreenColorGamut(ScreenId id, int32_t modeIdx); 316 317 int32_t SetScreenGamutMap(ScreenId id, ScreenGamutMap mode); 318 319 int32_t SetScreenCorrection(ScreenId id, ScreenRotation screenRotation); 320 321 bool SetVirtualMirrorScreenCanvasRotation(ScreenId id, bool canvasRotation); 322 323 int32_t SetVirtualScreenAutoRotation(ScreenId id, bool isAutoRotation); 324 325 bool SetVirtualMirrorScreenScaleMode(ScreenId id, ScreenScaleMode scaleMode); 326 327 bool SetGlobalDarkColorMode(bool isDark); 328 329 int32_t GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode); 330 331 int32_t GetScreenHDRCapability(ScreenId id, RSScreenHDRCapability& screenHdrCapability); 332 333 int32_t GetPixelFormat(ScreenId id, GraphicPixelFormat& pixelFormat); 334 335 int32_t SetPixelFormat(ScreenId id, GraphicPixelFormat pixelFormat); 336 337 int32_t GetScreenSupportedHDRFormats(ScreenId id, std::vector<ScreenHDRFormat>& hdrFormats); 338 339 int32_t GetScreenHDRFormat(ScreenId id, ScreenHDRFormat& hdrFormat); 340 341 int32_t GetScreenHDRStatus(ScreenId id, HdrStatus& hdrStatus); 342 343 int32_t SetScreenHDRFormat(ScreenId id, int32_t modeIdx); 344 345 int32_t GetScreenSupportedColorSpaces(ScreenId id, std::vector<GraphicCM_ColorSpaceType>& colorSpaces); 346 347 int32_t GetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType& colorSpace); 348 349 int32_t SetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType colorSpace); 350 351 int32_t GetScreenType(ScreenId id, RSScreenType& screenType); 352 353 bool GetBitmap(NodeId id, Drawing::Bitmap& bitmap); 354 bool GetPixelmap(NodeId id, std::shared_ptr<Media::PixelMap> pixelmap, 355 const Drawing::Rect* rect, std::shared_ptr<Drawing::DrawCmdList> drawCmdList); 356 bool RegisterTypeface(std::shared_ptr<Drawing::Typeface>& typeface); 357 bool UnRegisterTypeface(std::shared_ptr<Drawing::Typeface>& typeface); 358 359 int32_t GetDisplayIdentificationData(ScreenId id, uint8_t& outPort, std::vector<uint8_t>& edidData); 360 361 int32_t SetScreenSkipFrameInterval(ScreenId id, uint32_t skipFrameInterval); 362 363 int32_t SetVirtualScreenRefreshRate(ScreenId id, uint32_t maxRefreshRate, uint32_t& actualRefreshRate); 364 365 uint32_t SetScreenActiveRect(ScreenId id, const Rect& activeRect); 366 367 void SetScreenOffset(ScreenId id, int32_t offsetX, int32_t offsetY); 368 369 void SetScreenFrameGravity(ScreenId id, int32_t gravity); 370 371 int32_t RegisterOcclusionChangeCallback(const OcclusionChangeCallback& callback); 372 373 int32_t RegisterSurfaceOcclusionChangeCallback( 374 NodeId id, const SurfaceOcclusionChangeCallback& callback, std::vector<float>& partitionPoints); 375 376 int32_t UnRegisterSurfaceOcclusionChangeCallback(NodeId id); 377 378 int32_t RegisterHgmConfigChangeCallback(const HgmConfigChangeCallback& callback); 379 380 int32_t RegisterHgmRefreshRateModeChangeCallback(const HgmRefreshRateModeChangeCallback& callback); 381 382 int32_t RegisterHgmRefreshRateUpdateCallback(const HgmRefreshRateUpdateCallback& callback); 383 384 int32_t RegisterFirstFrameCommitCallback(const FirstFrameCommitCallback& callback); 385 386 int32_t RegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid, 387 const FrameRateLinkerExpectedFpsUpdateCallback& callback); 388 389 void SetAppWindowNum(uint32_t num); 390 391 bool SetSystemAnimatedScenes(SystemAnimatedScenes systemAnimatedScenes, bool isRegularAnimation = false); 392 393 void ShowWatermark(const std::shared_ptr<Media::PixelMap> &watermarkImg, bool isShow); 394 395 int32_t ResizeVirtualScreen(ScreenId id, uint32_t width, uint32_t height); 396 397 void ReportJankStats(); 398 399 void NotifyLightFactorStatus(int32_t lightFactorStatus); 400 401 void NotifyPackageEvent(uint32_t listSize, const std::vector<std::string>& packageList); 402 403 void NotifyAppStrategyConfigChangeEvent(const std::string& pkgName, uint32_t listSize, 404 const std::vector<std::pair<std::string, std::string>>& newConfig); 405 406 void NotifyRefreshRateEvent(const EventInfo& eventInfo); 407 408 void SetWindowExpectedRefreshRate(const std::unordered_map<uint64_t, EventInfo>& eventInfos); 409 410 void SetWindowExpectedRefreshRate(const std::unordered_map<std::string, EventInfo>& eventInfos); 411 412 bool NotifySoftVsyncRateDiscountEvent(uint32_t pid, const std::string &name, uint32_t rateDiscount); 413 414 void NotifyTouchEvent(int32_t touchStatus, int32_t touchCnt); 415 416 void NotifyDynamicModeEvent(bool enableDynamicMode); 417 418 void NotifyHgmConfigEvent(const std::string &eventName, bool state); 419 420 void NotifyXComponentExpectedFrameRate(const std::string& id, int32_t expectedFrameRate); 421 422 void ReportEventResponse(DataBaseRs info); 423 424 void ReportEventComplete(DataBaseRs info); 425 426 void ReportEventJankFrame(DataBaseRs info); 427 428 void ReportRsSceneJankStart(AppInfo info); 429 430 void ReportRsSceneJankEnd(AppInfo info); 431 432 void ReportGameStateData(GameStateData info); 433 434 void SetHardwareEnabled(NodeId id, bool isEnabled, SelfDrawingNodeType selfDrawingType, bool dynamicHardwareEnable); 435 436 uint32_t SetHidePrivacyContent(NodeId id, bool needHidePrivacyContent); 437 438 void SetCacheEnabledForRotation(bool isEnabled); 439 440 void SetOnRemoteDiedCallback(const OnRemoteDiedCallback& callback); 441 442 std::vector<ActiveDirtyRegionInfo> GetActiveDirtyRegionInfo(); 443 444 GlobalDirtyRegionInfo GetGlobalDirtyRegionInfo(); 445 446 LayerComposeInfo GetLayerComposeInfo(); 447 448 HwcDisabledReasonInfos GetHwcDisabledReasonInfo(); 449 450 int64_t GetHdrOnDuration(); 451 452 void SetVmaCacheStatus(bool flag); 453 454 int32_t RegisterUIExtensionCallback(uint64_t userId, const UIExtensionCallback& callback, bool unobscured = false); 455 456 bool SetAncoForceDoDirect(bool direct); 457 458 void SetLayerTopForHWC(NodeId nodeId, bool isTop, uint32_t zOrder); 459 460 void SetLayerTop(const std::string &nodeIdStr, bool isTop); 461 462 void SetForceRefresh(const std::string &nodeIdStr, bool isForceRefresh); 463 464 void SetColorFollow(const std::string &nodeIdStr, bool isColorFollow); 465 466 #ifdef RS_ENABLE_OVERLAY_DISPLAY 467 int32_t SetOverlayDisplayMode(int32_t mode); 468 #endif 469 470 #ifdef TP_FEATURE_ENABLE 471 void SetTpFeatureConfig(int32_t feature, const char* config, 472 TpFeatureConfigType tpFeatureConfigType = TpFeatureConfigType::DEFAULT_TP_FEATURE); 473 #endif 474 void SetVirtualScreenUsingStatus(bool isVirtualScreenUsingStatus); 475 void SetCurtainScreenUsingStatus(bool isCurtainScreenOn); 476 477 void DropFrameByPid(const std::vector<int32_t> pidList); 478 479 bool SetVirtualScreenStatus(ScreenId id, VirtualScreenStatus screenStatus); 480 481 void SetFreeMultiWindowStatus(bool enable); 482 483 bool RegisterSurfaceBufferCallback(pid_t pid, uint64_t uid, 484 std::shared_ptr<SurfaceBufferCallback> callback); 485 486 bool UnregisterSurfaceBufferCallback(pid_t pid, uint64_t uid); 487 488 void NotifyScreenSwitched(); 489 490 void ForceRefreshOneFrameWithNextVSync(); 491 492 void SetWindowContainer(NodeId nodeId, bool value); 493 494 int32_t RegisterSelfDrawingNodeRectChangeCallback( 495 const RectConstraint& constraint, const SelfDrawingNodeRectChangeCallback& callback); 496 497 int32_t UnRegisterSelfDrawingNodeRectChangeCallback(); 498 499 void NotifyPageName(const std::string &packageName, const std::string &pageName, bool isEnter); 500 501 bool GetHighContrastTextState(); 502 503 bool RegisterTransactionDataCallback(uint64_t token, uint64_t timeStamp, std::function<void()> callback); 504 505 bool SetBehindWindowFilterEnabled(bool enabled); 506 507 bool GetBehindWindowFilterEnabled(bool& enabled); 508 509 int32_t GetPidGpuMemoryInMB(pid_t pid, float &gpuMemInMB); 510 511 RetCodeHrpService ProfilerServiceOpenFile(const HrpServiceDirInfo& dirInfo, 512 const std::string& fileName, int32_t flags, int& outFd); 513 RetCodeHrpService ProfilerServicePopulateFiles(const HrpServiceDirInfo& dirInfo, 514 uint32_t firstFileIndex, std::vector<HrpServiceFileInfo>& outFiles); 515 bool ProfilerIsSecureScreen(); 516 517 void ClearUifirstCache(NodeId id); 518 private: 519 void TriggerSurfaceCaptureCallback(NodeId id, const RSSurfaceCaptureConfig& captureConfig, 520 std::shared_ptr<Media::PixelMap> pixelmap, std::shared_ptr<Media::PixelMap> pixelmapHDR = nullptr); 521 void TriggerOnFinish(const FinishCallbackRet& ret) const; 522 void TriggerOnAfterAcquireBuffer(const AfterAcquireBufferRet& ret) const; 523 void TriggerTransactionDataCallbackAndErase(uint64_t token, uint64_t timeStamp); 524 struct RectHash { operatorRectHash525 std::size_t operator()(const Drawing::Rect& rect) const { 526 std::size_t h1 = std::hash<Drawing::scalar>()(rect.left_); 527 std::size_t h2 = std::hash<Drawing::scalar>()(rect.top_); 528 std::size_t h3 = std::hash<Drawing::scalar>()(rect.right_); 529 std::size_t h4 = std::hash<Drawing::scalar>()(rect.bottom_); 530 return h1 ^ (h2 << 1) ^ (h3 << 2) ^ (h4 << 3); 531 } 532 }; 533 534 // Hash for solo node capture 535 struct UICaptureParamHash { operatorUICaptureParamHash536 std::size_t operator()(const RSUICaptureInRangeParam& param) const { 537 std::size_t h1 = std::hash<NodeId>()(param.endNodeId); 538 std::size_t h2 = std::hash<bool>()(param.useBeginNodeSize); 539 return h1 ^ (h2 << 1); 540 } 541 }; 542 543 struct PairHash { operatorPairHash544 std::size_t operator()(const std::pair<NodeId, RSSurfaceCaptureConfig>& p) const { 545 std::size_t h1 = std::hash<NodeId>()(p.first); 546 std::size_t h2 = RectHash()(p.second.mainScreenRect); 547 std::size_t h3 = UICaptureParamHash()(p.second.uiCaptureInRangeParam); 548 std::size_t h4 = RectHash()(p.second.specifiedAreaRect); 549 return h1 ^ (h2 << 1) ^ (h3 << 2) ^ (h4 << 3); 550 } 551 }; 552 553 std::mutex mutex_; 554 std::mutex surfaceCaptureCbDirectorMutex_; 555 std::map<NodeId, sptr<RSIBufferAvailableCallback>> bufferAvailableCbRTMap_; 556 std::mutex mapMutex_; 557 std::map<NodeId, sptr<RSIBufferAvailableCallback>> bufferAvailableCbUIMap_; 558 sptr<RSIScreenChangeCallback> screenChangeCb_ = nullptr; 559 sptr<RSIScreenSwitchingNotifyCallback> screenSwitchingNotifyCb_ = nullptr; 560 sptr<RSISurfaceCaptureCallback> surfaceCaptureCbDirector_ = nullptr; 561 std::unordered_map<std::pair<NodeId, RSSurfaceCaptureConfig>, 562 std::vector<std::shared_ptr<SurfaceCaptureCallback>>, PairHash> surfaceCaptureCbMap_; 563 564 sptr<RSISurfaceBufferCallback> surfaceBufferCbDirector_; 565 std::map<uint64_t, std::shared_ptr<SurfaceBufferCallback>> surfaceBufferCallbacks_; 566 mutable std::shared_mutex surfaceBufferCallbackMutex_; 567 568 sptr<RSITransactionDataCallback> transactionDataCbDirector_; 569 std::map<std::pair<uint64_t, uint64_t>, std::function<void()>> transactionDataCallbacks_; 570 std::mutex transactionDataCallbackMutex_; 571 572 friend class SurfaceCaptureCallbackDirector; 573 friend class SurfaceBufferCallbackDirector; 574 friend class TransactionDataCallbackDirector; 575 }; 576 } // namespace Rosen 577 } // namespace OHOS 578 579 #endif // ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_RENDER_SERVICE_CLIENT_H 580