1 /* 2 * Copyright (c) 2021 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_WINDOW_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_WINDOW_H 18 19 #include <memory> 20 21 #include "base/utils/macros.h" 22 #include "base/utils/noncopyable.h" 23 #include "core/common/ace_page.h" 24 #include "core/common/platform_window.h" 25 26 namespace OHOS::Ace { 27 28 class ACE_EXPORT Window { 29 public: 30 explicit Window(std::unique_ptr<PlatformWindow> platformWindow); 31 virtual ~Window() = default; 32 33 virtual void RequestFrame(); 34 Destroy()35 virtual void Destroy() 36 { 37 platformWindow_->Destroy(); 38 platformWindow_.reset(); 39 } 40 41 virtual void SetRootRenderNode(const RefPtr<RenderNode>& root); 42 43 void OnVsync(uint64_t nanoTimestamp, uint32_t frameCount); 44 SetVsyncCallback(AceVsyncCallback && callback)45 virtual void SetVsyncCallback(AceVsyncCallback&& callback) 46 { 47 callbacks_.push_back(std::move(callback)); 48 } 49 OnShow()50 void OnShow() 51 { 52 onShow_ = true; 53 } 54 OnHide()55 void OnHide() 56 { 57 onShow_ = false; 58 } 59 IsHide()60 bool IsHide() const 61 { 62 return !onShow_; 63 } 64 65 private: 66 std::unique_ptr<PlatformWindow> platformWindow_; 67 std::list<AceVsyncCallback> callbacks_; 68 bool isRequestVsync_ = false; 69 bool onShow_ = true; 70 71 ACE_DISALLOW_COPY_AND_MOVE(Window); 72 }; 73 74 } // namespace OHOS::Ace 75 76 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_WINDOW_H 77