1 /* 2 * Copyright (c) 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 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 #include "common/rs_macros.h" 24 #include "modifier/rs_modifier_type.h" 25 #include "modifier/rs_render_modifier.h" 26 27 namespace OHOS { 28 namespace Rosen { 29 class RSB_EXPORT RSSingleFrameComposer { 30 public: 31 RSSingleFrameComposer() = default; 32 ~RSSingleFrameComposer() = default; 33 34 bool SingleFrameModifierAddToList(RSModifierType type, std::list<std::shared_ptr<RSRenderModifier>>& modifierList); 35 bool SingleFrameIsNeedSkip(bool needSkip, const std::shared_ptr<RSRenderModifier>& modifier); 36 void SingleFrameAddModifier(const std::shared_ptr<RSRenderModifier>& modifier); 37 static void SetSingleFrameFlag(const std::thread::id ipcThreadId); 38 static bool IsShouldSingleFrameComposer(); 39 static void AddOrRemoveAppPidToMap(bool isNodeSingleFrameComposer, pid_t pid); 40 static bool IsShouldProcessByIpcThread(pid_t pid); 41 42 private: 43 bool FindSingleFrameModifier(const std::list<std::shared_ptr<RSRenderModifier>>& modifierList); 44 void EraseSingleFrameModifier(std::list<std::shared_ptr<RSRenderModifier>>& modifierList); 45 void SingleFrameModifierAdd(std::list<std::shared_ptr<RSRenderModifier>>& singleFrameModifierList, 46 std::list<std::shared_ptr<RSRenderModifier>>& modifierList); 47 48 std::map<RSModifierType, std::list<std::shared_ptr<RSRenderModifier>>> singleFrameDrawCmdModifiers_; 49 mutable std::mutex singleFrameDrawMutex_; 50 static std::map<std::thread::id, uint64_t> ipcThreadIdMap_; 51 static std::mutex ipcThreadIdMapMutex_; 52 static std::map<pid_t, uint64_t> appPidMap_; 53 static std::mutex appPidMapMutex_; 54 }; 55 } 56 } 57 58 #endif