• 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PAINTS_ADAPTER_ROSEN_WINDOW_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PAINTS_ADAPTER_ROSEN_WINDOW_H
18 
19 #include "render_service_client/core/ui/rs_ui_director.h"
20 
21 #ifdef OHOS_PLATFORM
22 #include "vsync_receiver.h"
23 #include "wm/window.h"
24 #elif VIRTUAL_RS_WINDOW
25 // use real rs window later
26 #ifdef IOS_PLATFORM
27 #include "adapter/ios/entrance/virtual_rs_window.h"
28 #else
29 #include "adapter/android/entrance/java/jni/virtual_rs_window.h"
30 #endif
31 #else
32 #include "previewer/include/window.h"
33 #endif
34 
35 #include "base/thread/task_executor.h"
36 #include "base/utils/noncopyable.h"
37 #include "core/common/window.h"
38 
39 namespace OHOS::Ace::NG {
40 
41 class RosenWindow : public Window {
42 public:
43     RosenWindow(const OHOS::sptr<OHOS::Rosen::Window>& window, RefPtr<TaskExecutor> taskExecutor, int32_t id);
44     ~RosenWindow() override = default;
45 
46     void RequestFrame() override;
47 
48     void Init() override;
49 
50     void Destroy() override;
51 
SetRootRenderNode(const RefPtr<RenderNode> & root)52     void SetRootRenderNode(const RefPtr<RenderNode>& root) override {}
53 
54     void SetRootFrameNode(const RefPtr<NG::FrameNode>& root) override;
55 
GetRSUIDirector()56     std::shared_ptr<Rosen::RSUIDirector> GetRSUIDirector() const override
57     {
58         return rsUIDirector_;
59     }
60 
GetRSWindow()61     sptr<Rosen::Window> GetRSWindow() const
62     {
63         return rsWindow_;
64     }
65 
66     void RecordFrameTime(uint64_t timeStamp, const std::string& name) override;
67 
68     void FlushTasks() override;
69 
70     void SetTaskRunner(RefPtr<TaskExecutor> taskExecutor, int32_t id);
71 
FlushCustomAnimation(uint64_t timeStamp)72     bool FlushCustomAnimation(uint64_t timeStamp) override
73     {
74         return rsUIDirector_->RunningCustomAnimation(timeStamp);
75     }
76 
77     void OnShow() override;
78     void OnHide() override;
79 
80     void SetDrawTextAsBitmap(bool useBitmap) override;
81 
82     float GetRefreshRate() const override;
83 
84     void SetKeepScreenOn(bool keepScreenOn) override;
85 
86 private:
87     OHOS::sptr<OHOS::Rosen::Window> rsWindow_;
88     WeakPtr<TaskExecutor> taskExecutor_;
89     int32_t id_ = 0;
90     std::shared_ptr<OHOS::Rosen::RSUIDirector> rsUIDirector_;
91     std::shared_ptr<OHOS::Rosen::VsyncCallback> vsyncCallback_;
92 
93     ACE_DISALLOW_COPY_AND_MOVE(RosenWindow);
94 };
95 
96 } // namespace OHOS::Ace::NG
97 
98 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PAINTS_ADAPTER_ROSEN_WINDOW_H
99