1 /* 2 * Copyright (c) 2023-2025 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 RS_SINGLE_FRAME_COMPOSER_H 17 #define RS_SINGLE_FRAME_COMPOSER_H 18 19 #include <list> 20 #include <map> 21 #include <mutex> 22 #include <thread> 23 24 #include "common/rs_macros.h" 25 #include "modifier_ng/rs_render_modifier_ng.h" 26 27 namespace OHOS { 28 namespace Rosen { 29 class RSB_EXPORT RSSingleFrameComposer { 30 public: 31 RSSingleFrameComposer() = default; 32 ~RSSingleFrameComposer() = default; 33 34 bool SingleFrameModifierAddToListNG( 35 ModifierNG::RSModifierType type, std::vector<std::shared_ptr<ModifierNG::RSRenderModifier>>& modifierList); 36 bool SingleFrameIsNeedSkipNG(bool needSkip, const std::shared_ptr<ModifierNG::RSRenderModifier>& modifier); 37 void SingleFrameAddModifierNG(const std::shared_ptr<ModifierNG::RSRenderModifier>& modifier); 38 39 static void SetSingleFrameFlag(const std::thread::id ipcThreadId); 40 static bool IsShouldSingleFrameComposer(); 41 static void AddOrRemoveAppPidToMap(bool isNodeSingleFrameComposer, pid_t pid); 42 static bool IsShouldProcessByIpcThread(pid_t pid); 43 44 private: 45 bool FindSingleFrameModifierNG(const std::vector<std::shared_ptr<ModifierNG::RSRenderModifier>>& modifierList); 46 void EraseSingleFrameModifierNG(std::vector<std::shared_ptr<ModifierNG::RSRenderModifier>>& modifierList); 47 void SingleFrameModifierAddNG(std::vector<std::shared_ptr<ModifierNG::RSRenderModifier>>& singleFrameModifierList, 48 std::vector<std::shared_ptr<ModifierNG::RSRenderModifier>>& modifierList); 49 50 std::map<ModifierNG::RSModifierType, std::vector<std::shared_ptr<ModifierNG::RSRenderModifier>>> 51 singleFrameDrawCmdModifiersNG_; 52 mutable std::mutex singleFrameDrawMutex_; 53 static std::map<std::thread::id, uint64_t> ipcThreadIdMap_; 54 static std::mutex ipcThreadIdMapMutex_; 55 static std::map<pid_t, uint64_t> appPidMap_; 56 static std::mutex appPidMapMutex_; 57 }; 58 } // namespace Rosen 59 } // namespace OHOS 60 #endif