• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 #include "rs_trace.h"
16 
17 #include "common/rs_special_layer_manager.h"
18 #include "platform/common/rs_log.h"
19 #include "set"
20 
21 namespace OHOS {
22 namespace Rosen {
Set(uint32_t type,bool set)23 bool RSSpecialLayerManager::Set(uint32_t type, bool set)
24 {
25     if (Find(type) == set) {
26         return false;
27     }
28     if (set) {
29         specialLayerType_ |= type;
30     } else {
31         specialLayerType_ &= ~type;
32     }
33     return true;
34 }
35 
Find(uint32_t type) const36 bool RSSpecialLayerManager::Find(uint32_t type) const
37 {
38     return specialLayerType_ & type;
39 }
40 
Get() const41 uint32_t RSSpecialLayerManager::Get() const
42 {
43     return specialLayerType_;
44 }
45 
AddIds(uint32_t type,NodeId id)46 void RSSpecialLayerManager::AddIds(uint32_t type, NodeId id)
47 {
48     uint32_t isType = type & IS_GENERAL_SPECIAL;
49     uint32_t currentType = SpecialLayerType::SECURITY;
50     while (isType != 0) {
51         auto IsSpecial = isType & 1;
52         if (IsSpecial) {
53             specialLayerIds_[currentType].insert(id);
54             specialLayerType_ |= (currentType << SPECIAL_TYPE_NUM);
55         }
56         isType >>= 1;
57         currentType <<= 1;
58     }
59 }
60 
RemoveIds(uint32_t type,NodeId id)61 void RSSpecialLayerManager::RemoveIds(uint32_t type, NodeId id)
62 {
63     uint32_t isType = type & IS_GENERAL_SPECIAL;
64     uint32_t currentType = SpecialLayerType::SECURITY;
65     while (isType != 0) {
66         auto IsSpecial = isType & 1;
67         if (IsSpecial) {
68             specialLayerIds_[currentType].erase(id);
69             if (specialLayerIds_[currentType].empty()) {
70                 specialLayerType_ &= ~(currentType << SPECIAL_TYPE_NUM);
71             }
72         }
73         isType >>= 1;
74         currentType <<= 1;
75     }
76 }
77 } // namespace Rosen
78 } // namespace OHOS