• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "pipeline/rs_render_frame_rate_linker_map.h"
17 #include "common/rs_common_def.h"
18 #include "platform/common/rs_log.h"
19 
20 namespace OHOS {
21 namespace Rosen {
RSRenderFrameRateLinkerMap()22 RSRenderFrameRateLinkerMap::RSRenderFrameRateLinkerMap()
23 {
24 }
25 
RegisterFrameRateLinker(const std::shared_ptr<RSRenderFrameRateLinker> & linkerPtr)26 bool RSRenderFrameRateLinkerMap::RegisterFrameRateLinker(const std::shared_ptr<RSRenderFrameRateLinker>& linkerPtr)
27 {
28     FrameRateLinkerId id = linkerPtr->GetId();
29     if (frameRateLinkerMap_.count(id)) {
30         return false;
31     }
32     frameRateLinkerMap_.emplace(id, linkerPtr);
33     return true;
34 }
35 
UnregisterFrameRateLinker(FrameRateLinkerId id)36 void RSRenderFrameRateLinkerMap::UnregisterFrameRateLinker(FrameRateLinkerId id)
37 {
38     ROSEN_LOGI("RSRenderFrameRateLinkerMap::UnregisterFrameRateLinker id: %{public}" PRIu64, id);
39     frameRateLinkerMap_.erase(id);
40 }
41 
FilterFrameRateLinkerByPid(pid_t pid)42 void RSRenderFrameRateLinkerMap::FilterFrameRateLinkerByPid(pid_t pid)
43 {
44     ROSEN_LOGD("RSRenderFrameRateLinkerMap::FilterFrameRateLinkerByPid removing all linker belong to pid %{public}llu",
45         (unsigned long long)pid);
46     // remove all nodes belong to given pid (by matching higher 32 bits of node id)
47     EraseIf(frameRateLinkerMap_, [pid](const auto& pair) -> bool {
48         return ExtractPid(pair.first) == pid;
49     });
50 }
51 
GetFrameRateLinker(FrameRateLinkerId id)52 std::shared_ptr<RSRenderFrameRateLinker> RSRenderFrameRateLinkerMap::GetFrameRateLinker(FrameRateLinkerId id)
53 {
54     return frameRateLinkerMap_.count(id) ? frameRateLinkerMap_[id] : nullptr;
55 }
56 } // namespace Rosen
57 } // namespace OHOS
58