1 /*
2  * Copyright (c) 2022-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 RENDER_SERVICE_BASE_COMMON_RS_PROPERTY_TRACE_H
17 #define RENDER_SERVICE_BASE_COMMON_RS_PROPERTY_TRACE_H
18 
19 #include <set>
20 #include <unordered_map>
21 #include <sys/stat.h>
22 
23 #include "common/rs_common_def.h"
24 #include "common/rs_macros.h"
25 #include "common/rs_obj_abs_geometry.h"
26 #include "modifier/rs_modifier_type.h"
27 #include "property/rs_properties.h"
28 
29 namespace OHOS {
30 namespace Rosen {
31 class RSB_EXPORT RSPropertyTrace {
32 public:
GetInstance()33     static RSPropertyTrace &GetInstance()
34     {
35         return instance_;
36     };
37 
38     void PropertiesDisplayByTrace(const NodeId& id, const std::shared_ptr<RSObjAbsGeometry>& boundsGeometry);
39     void TracePropertiesByNodeName(const NodeId& id, const std::string& nodeName, const RSProperties& properties);
40     void RefreshNodeTraceInfo();
41 private:
42     RSPropertyTrace() = default;
43     ~RSPropertyTrace() = default;
44 
45     void InitNodeAndPropertyInfo();
46 
47     void ClearNodeAndPropertyInfo();
48 
49     bool IsNeedPropertyTrace(const NodeId& id);
50     bool IsNeedPropertyTrace(const std::string& nodeName);
51 
52     void DealConfigInputInfo(const std::string& info);
53     bool DealNodeNameConfig(const std::string& info);
54 
55     bool IsNeedRefreshConfig();
56 
57     void AddTraceFlag(const std::string& str);
58 
59     bool needWriteAllNode_ {false};
60     bool needTraceAllNode_ {false};
61     static RSPropertyTrace instance_;
62     std::set<NodeId> nodeIdSet_;
63     std::set<std::string> nodeNameSet_;
64     std::string propertyFileLastModifyTime;
65 };
66 
67 } // namespace Rosen
68 } // namespace OHOS
69 
70 #endif // RENDER_SERVICE_BASE_COMMON_RS_PROPERTY_TRACE_H
71