• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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_RS_TEST_ST_RS_INTERFACES_TEST_UTILS_H
17 #define FRAMEWORKS_RS_TEST_ST_RS_INTERFACES_TEST_UTILS_H
18 
19 #include <securec.h>
20 
21 #include "display.h"
22 #include "display_info.h"
23 #include "display_manager.h"
24 #include "display_property.h"
25 #include "dm_common.h"
26 #include "screen.h"
27 #include "screen_manager.h"
28 #include "ui/rs_display_node.h"
29 #include "ui/rs_root_node.h"
30 #include "ui/rs_surface_node.h"
31 #include "ui/rs_ui_director.h"
32 #include "unique_fd.h"
33 #include "window.h"
34 #include "window_manager_hilog.h"
35 #include "window_option.h"
36 #include "wm_common.h"
37 
38 namespace OHOS {
39 namespace Rosen {
40 class RSInterfacesTestUtils {
41 public:
42     ~RSInterfacesTestUtils();
43     bool CreateSurface();
44     void RootNodeInit(std::shared_ptr<RSUIDirector> rsUiDirector, int width, int height);
45     sptr<Window> CreateWindowByDisplayParam(DisplayId displayId, std::string name,
46         Rect rect);
47     class BufferListener : public IBufferConsumerListener {
48     public:
BufferListener(RSInterfacesTestUtils & rsInterfacesTestUtils)49         explicit BufferListener(RSInterfacesTestUtils &rsInterfacesTestUtils): utils_(rsInterfacesTestUtils)
50         {
51         }
52         ~BufferListener() noexcept override = default;
OnBufferAvailable()53         void OnBufferAvailable() override
54         {
55             utils_.OnVsync();
56         }
57 
58     private:
59         RSInterfacesTestUtils &utils_;
60     };
61     friend class BufferListener;
62 
63     void OnVsync();
64     uint32_t successCount_ = 0;
65     uint32_t failCount_ = 0;
66     uint32_t defaultWidth_ = 0;
67     uint32_t defaultHeight_ = 0;
68     sptr<IBufferConsumerListener> listener_ = nullptr;
69     sptr<IConsumerSurface> cSurface_ = nullptr; // consumer surface
70     sptr<Surface> pSurface_ = nullptr; // producer surface
71     sptr<SurfaceBuffer> prevBuffer_ = nullptr;
72     BufferHandle *bufferHandle_ = nullptr;
73     std::shared_ptr<RSNode> rootNode_ = nullptr;
74 
75 private:
76     std::mutex mutex_;
77 };
78 } // namespace ROSEN
79 } // namespace OHOS
80 #endif // FRAMEWORKS_RS_TEST_ST_RS_INTERFACES_TEST_UTILS_H
81