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 
16 #ifndef RS_LAYER_COMPOSE_COLLECTION_H
17 #define RS_LAYER_COMPOSE_COLLECTION_H
18 
19 #include <mutex>
20 
21 #include "common/rs_common_def.h"
22 
23 namespace OHOS {
24 namespace Rosen {
25 
26 struct LayerComposeInfo {
27     int32_t uniformRenderFrameNumber = 0;
28     int32_t offlineComposeFrameNumber = 0;
29     int32_t redrawFrameNumber = 0;
LayerComposeInfoLayerComposeInfo30     LayerComposeInfo()
31         : uniformRenderFrameNumber(), offlineComposeFrameNumber(), redrawFrameNumber() {}
LayerComposeInfoLayerComposeInfo32     LayerComposeInfo(int32_t uniformRenderFrameNumber_, int32_t offlineComposeFrameNumber_,
33         int32_t redrawFrameNumber_)
34         : uniformRenderFrameNumber(uniformRenderFrameNumber_), offlineComposeFrameNumber(offlineComposeFrameNumber_),
35           redrawFrameNumber(redrawFrameNumber_) {}
36 };
37 
38 class RSB_EXPORT LayerComposeCollection {
39 public:
40     static LayerComposeCollection& GetInstance();
41 
42     void UpdateUniformOrOfflineComposeFrameNumberForDFX(size_t layerSize);
43     void UpdateRedrawFrameNumberForDFX();
44     LayerComposeInfo GetLayerComposeInfo() const;
45     void ResetLayerComposeInfo();
46 
47 private:
48     LayerComposeCollection();
49     ~LayerComposeCollection() noexcept;
50     LayerComposeCollection(const LayerComposeCollection&) = delete;
51     LayerComposeCollection(const LayerComposeCollection&&) = delete;
52     LayerComposeCollection& operator=(const LayerComposeCollection&) = delete;
53     LayerComposeCollection& operator=(const LayerComposeCollection&&) = delete;
54 
55     LayerComposeInfo layerComposeInfo_;
56     mutable std::mutex layerMtx_;
57 };
58 } // namespace Rosen
59 } // namespace OHOS
60 
61 #endif // RS_LAYER_COMPOSE_COLLECTION_H