• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 FRAMEWORKS_DM_TEST_ST_DISPLAY_TEST_UTILS_H
17 #define FRAMEWORKS_DM_TEST_ST_DISPLAY_TEST_UTILS_H
18 
19 #include <securec.h>
20 
21 #include "display_manager.h"
22 #include "screen_manager.h"
23 #include "display_property.h"
24 #include "display.h"
25 #include "screen.h"
26 #include "display_info.h"
27 #include "wm_common.h"
28 #include "dm_common.h"
29 #include "window_manager_hilog.h"
30 #include "unique_fd.h"
31 #include "ui/rs_surface_node.h"
32 #include "ui/rs_display_node.h"
33 
34 namespace OHOS {
35 namespace Rosen {
36 class DisplayTestUtils {
37 public:
38     ~DisplayTestUtils();
39     static bool SizeEqualToDisplay(const sptr<Display>& display, const Media::Size cur);
40     static bool SizeEqual(const Media::Size dst, const Media::Size cur);
41     void init();
42     bool CreateSurface();
43     void SetDefaultWH(const sptr<Display>& display);
44     class BufferListener : public IBufferConsumerListener {
45     public:
BufferListener(DisplayTestUtils & displayTestUtils)46         explicit BufferListener(DisplayTestUtils &displayTestUtils): utils_(displayTestUtils)
47         {
48         }
49         ~BufferListener() noexcept override = default;
OnBufferAvailable()50         void OnBufferAvailable() override
51         {
52             utils_.OnVsync();
53         }
54 
55     private:
56         DisplayTestUtils &utils_;
57     };
58     friend class BufferListener;
59 
60     void OnVsync();
61     uint32_t successCount_ = 0;
62     uint32_t failCount_ = 0;
63     uint32_t defaultWidth_ = 0;
64     uint32_t defaultHeight_ = 0;
65     sptr<IBufferConsumerListener> listener_ = nullptr;
66     sptr<Surface> csurface_ = nullptr; // cosumer surface
67     sptr<Surface> psurface_ = nullptr; // producer surface
68     sptr<SurfaceBuffer> prevBuffer_ = nullptr;
69     BufferHandle *bufferHandle_ = nullptr;
70 
71 private:
72     std::mutex mutex_;
73 };
74 } // namespace ROSEN
75 } // namespace OHOS
76 #endif // FRAMEWORKS_DM_TEST_ST_DISPLAY_TEST_UTILS_H
77