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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_PLATFORM_WINDOW_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_PLATFORM_WINDOW_H
18 
19 #include <functional>
20 #include <memory>
21 
22 #include "base/memory/ace_type.h"
23 #include "base/utils/macros.h"
24 #include "base/utils/noncopyable.h"
25 
26 namespace OHOS::Ace {
27 
28 using AceVsyncCallback = std::function<void(uint64_t, uint32_t)>;
29 class AceView;
30 class RenderNode;
31 
32 class ACE_EXPORT PlatformWindow {
33 public:
34     PlatformWindow() = default;
35     virtual ~PlatformWindow() = default;
36 
37     static std::unique_ptr<PlatformWindow> Create(AceView* aceView);
38 
Destroy()39     virtual void Destroy() {}
40 
41     // Request next vsync.
42     virtual void RequestFrame() = 0;
43 
44     // Register Vsync callback.
45     virtual void RegisterVsyncCallback(AceVsyncCallback&& callback) = 0;
46 
47     // Attach root render node to container
48     virtual void SetRootRenderNode(const RefPtr<RenderNode>& root) = 0;
49 
SetUiDvsyncSwitch(bool dvsyncSwitch)50     virtual void SetUiDvsyncSwitch(bool dvsyncSwitch) {}
51 
52 private:
53     ACE_DISALLOW_COPY_AND_MOVE(PlatformWindow);
54 };
55 
56 } // namespace OHOS::Ace
57 
58 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_PLATFORM_WINDOW_H
59