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