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 #include "info_collection/rs_layer_compose_collection.h"
17 
18 namespace OHOS {
19 namespace Rosen {
GetInstance()20 LayerComposeCollection& LayerComposeCollection::GetInstance()
21 {
22     static LayerComposeCollection instance;
23     return instance;
24 }
25 
LayerComposeCollection()26 LayerComposeCollection::LayerComposeCollection()
27 {
28 }
29 
~LayerComposeCollection()30 LayerComposeCollection::~LayerComposeCollection() noexcept
31 {
32 }
33 
UpdateUniformOrOfflineComposeFrameNumberForDFX(size_t layerSize)34 void LayerComposeCollection::UpdateUniformOrOfflineComposeFrameNumberForDFX(size_t layerSize)
35 {
36     std::lock_guard<std::mutex> lock(layerMtx_);
37     if (layerSize == 1) {
38         ++layerComposeInfo_.uniformRenderFrameNumber;
39         return;
40     }
41     ++layerComposeInfo_.offlineComposeFrameNumber;
42 }
43 
UpdateRedrawFrameNumberForDFX()44 void LayerComposeCollection::UpdateRedrawFrameNumberForDFX()
45 {
46     std::lock_guard<std::mutex> lock(layerMtx_);
47     --layerComposeInfo_.offlineComposeFrameNumber;
48     ++layerComposeInfo_.redrawFrameNumber;
49 }
50 
GetLayerComposeInfo() const51 LayerComposeInfo LayerComposeCollection::GetLayerComposeInfo() const
52 {
53     std::lock_guard<std::mutex> lock(layerMtx_);
54     return layerComposeInfo_;
55 }
56 
ResetLayerComposeInfo()57 void LayerComposeCollection::ResetLayerComposeInfo()
58 {
59     std::lock_guard<std::mutex> lock(layerMtx_);
60     layerComposeInfo_ = LayerComposeInfo {};
61 }
62 } // namespace Rosen
63 } // namespace OHOS