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 DumpHelpInfo(std::string& dumpString) const; 48 void DumpRSEvenParam(std::string& dumpString) const; 49 void DumpRenderServiceTree(std::string& dumpString) const; 50 void DumpSurfaceNode(std::string& dumpString, NodeId id) const; 51 void DumpMem(std::unordered_set<std::u16string>& argSets, std::string& dumpString) const; 52 void FPSDUMPProcess(std::unordered_set<std::u16string>& argSets, std::string& dumpString, 53 const std::u16string& arg) const; 54 void FPSDUMPClearProcess(std::unordered_set<std::u16string>& argSets, 55 std::string& dumpString, const std::u16string& arg) const; 56 57 sptr<RSIRenderServiceConnection> CreateConnection(const sptr<RSIConnectionToken>& token) override; 58 void RemoveConnection(sptr<IRemoteObject> token); 59 60 RSMainThread* mainThread_ = nullptr; 61 sptr<RSScreenManager> screenManager_; 62 63 friend class RSRenderServiceConnection; 64 mutable std::mutex mutex_; 65 std::map<sptr<IRemoteObject>, sptr<RSIRenderServiceConnection>> connections_; 66 67 sptr<VSyncController> rsVSyncController_; 68 sptr<VSyncController> appVSyncController_; 69 70 sptr<VSyncDistributor> rsVSyncDistributor_; 71 sptr<VSyncDistributor> appVSyncDistributor_; 72 }; 73 } // Rosen 74 } // OHOS 75 76 #endif // RENDER_SERVICE_PIPELINE_RS_RENDER_SERVICE_H 77