1 /* 2 * Copyright (c) 2021-2022 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 RENDER_SERVICE_PIPELINE_RS_RENDER_SERVICE_H 17 #define RENDER_SERVICE_PIPELINE_RS_RENDER_SERVICE_H 18 #include <map> 19 #include <unordered_set> 20 21 #include "screen_manager/rs_screen_manager.h" 22 #include "transaction/rs_render_service_stub.h" 23 #include "vsync_controller.h" 24 #include "vsync_distributor.h" 25 26 namespace OHOS { 27 namespace Rosen { 28 class RSMainThread; 29 class RSRenderServiceConnection; 30 31 class RSRenderService : public RSRenderServiceStub { 32 public: 33 RSRenderService(); 34 ~RSRenderService() noexcept; 35 36 RSRenderService(const RSRenderService&) = delete; 37 RSRenderService& operator=(const RSRenderService&) = delete; 38 39 bool Init(); 40 void Run(); 41 42 private: 43 int Dump(int fd, const std::vector<std::u16string>& args) override; 44 void DoDump(std::unordered_set<std::u16string>& argSets, std::string& dumpString) const; 45 void DumpNodesNotOnTheTree(std::string& dumpString) const; 46 void DumpAllNodesMemSize(std::string& dumpString) const; 47 void DumpGpuInfo(std::string& dumpString) const; 48 void DumpRSEvenParam(std::string& dumpString) const; 49 void DumpRenderServiceTree(std::string& dumpString, bool forceDumpSingleFrame = true) const; 50 void DumpRefreshRateCounts(std::string& dumpString) const; 51 void DumpClearRefreshRateCounts(std::string& dumpString) const; 52 void DumpJankStatsRs(std::string& dumpString) const; 53 #ifdef RS_ENABLE_VK 54 void DumpVkTextureLimit(std::string& dumpString) const; 55 #endif 56 void DumpSurfaceNode(std::string& dumpString, NodeId id) const; 57 58 void DumpExistPidMem(std::unordered_set<std::u16string>& argSets, std::string& dumpString) const; 59 60 void WindowHitchsDump(std::unordered_set<std::u16string>& argSets, std::string& dumpString, 61 const std::u16string& arg) const; 62 void DumpMem(std::unordered_set<std::u16string>& argSets, std::string& dumpString) const; 63 void DumpNode(std::unordered_set<std::u16string>& argSets, std::string& dumpString) const; 64 void FPSDUMPProcess(std::unordered_set<std::u16string>& argSets, std::string& dumpString, 65 const std::u16string& arg) const; 66 void DumpFps(std::string& dumpString, std::string& fpsArg) const; 67 void DumpSurfaceNodeFps(std::string& dumpString, std::string& fpsArg) const; 68 void FPSDUMPClearProcess(std::unordered_set<std::u16string>& argSets, 69 std::string& dumpString, const std::u16string& arg) const; 70 void ClearFps(std::string& dumpString, std::string& fpsArg) const; 71 void ClearSurfaceNodeFps(std::string& dumpString, std::string& fpsArg) const; 72 73 sptr<RSIRenderServiceConnection> CreateConnection(const sptr<RSIConnectionToken>& token) override; 74 void RemoveConnection(sptr<IRemoteObject> token); 75 76 // RS dump init 77 void RSGfxDumpInit(); 78 void RegisterRSGfxFuncs(); 79 void RegisterRSTreeFuncs(); 80 void RegisterMemFuncs(); 81 void RegisterFpsFuncs(); 82 void RegisterGpuFuncs(); 83 void InitDVSyncParams(DVSyncFeatureParam &dvsyncParam); 84 85 // RS Filter CCM init 86 void FilterCCMInit(); 87 88 RSMainThread* mainThread_ = nullptr; 89 sptr<RSScreenManager> screenManager_; 90 91 friend class RSRenderServiceConnection; 92 mutable std::mutex mutex_; 93 std::map<sptr<IRemoteObject>, sptr<RSIRenderServiceConnection>> connections_; 94 95 sptr<VSyncController> rsVSyncController_; 96 sptr<VSyncController> appVSyncController_; 97 98 sptr<VSyncDistributor> rsVSyncDistributor_; 99 sptr<VSyncDistributor> appVSyncDistributor_; 100 101 #ifdef RS_PROFILER_ENABLED 102 friend class RSProfiler; 103 #endif 104 }; 105 } // Rosen 106 } // OHOS 107 108 #endif // RENDER_SERVICE_PIPELINE_RS_RENDER_SERVICE_H 109