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& layerName) const; 67 void FPSDumpClearProcess(std::unordered_set<std::u16string>& argSets, 68 std::string& dumpString, const std::u16string& arg) const; 69 void ClearFps(std::string& dumpString, std::string& layerName) const; 70 71 sptr<RSIRenderServiceConnection> CreateConnection(const sptr<RSIConnectionToken>& token) override; 72 void RemoveConnection(sptr<IRemoteObject> token); 73 74 // RS dump init 75 void RSGfxDumpInit(); 76 void RegisterRSGfxFuncs(); 77 void RegisterRSTreeFuncs(); 78 void RegisterMemFuncs(); 79 void RegisterFpsFuncs(); 80 void RegisterGpuFuncs(); 81 void RegisterBufferFuncs(); 82 void InitDVSyncParams(DVSyncFeatureParam &dvsyncParam); 83 84 // RS Filter CCM init 85 void FilterCCMInit(); 86 87 RSMainThread* mainThread_ = nullptr; 88 sptr<RSScreenManager> screenManager_; 89 90 friend class RSRenderServiceConnection; 91 mutable std::mutex mutex_; 92 std::map<sptr<IRemoteObject>, sptr<RSIRenderServiceConnection>> connections_; 93 94 sptr<VSyncController> rsVSyncController_; 95 sptr<VSyncController> appVSyncController_; 96 97 sptr<VSyncDistributor> rsVSyncDistributor_; 98 sptr<VSyncDistributor> appVSyncDistributor_; 99 100 #ifdef RS_PROFILER_ENABLED 101 friend class RSProfiler; 102 #endif 103 }; 104 } // Rosen 105 } // OHOS 106 107 #endif // RENDER_SERVICE_PIPELINE_RS_RENDER_SERVICE_H 108