• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 OHOS_RENDER_3D_SCENE_ADAPTER_H
17 #define OHOS_RENDER_3D_SCENE_ADAPTER_H
18 
19 #include "intf_scene_adapter.h"
20 #include <meta/interface/intf_object.h>
21 
22 #include <base/containers/array_view.h>
23 
24 #include <core/intf_engine.h>
25 #include <core/ecs/intf_system_graph_loader.h>
26 #include <core/engine_info.h>
27 #include <core/implementation_uids.h>
28 #include <core/io/intf_file_manager.h>
29 #include <core/namespace.h>
30 #include <core/os/intf_platform.h>
31 #include <core/plugin/intf_plugin_register.h>
32 #include <core/property/intf_property_handle.h>
33 
34 #include <meta/interface/intf_meta_object_lib.h>
35 #include <meta/interface/intf_task_queue_registry.h>
36 #include <meta/interface/intf_task_queue.h>
37 #include <meta/interface/intf_object.h>
38 #include <meta/interface/intf_object_registry.h>
39 #include <meta/interface/intf_task_queue.h>
40 #include <meta/base/shared_ptr.h>
41 #include <meta/base/interface_macros.h>
42 #include <meta/api/make_callback.h>
43 #include <meta/ext/object.h>
44 
45 #include <scene_plugin/namespace.h>
46 #include <scene_plugin/interface/intf_scene.h>
47 #include <scene_plugin/interface/intf_ecs_scene.h>
48 #include <scene_plugin/interface/intf_mesh.h>
49 #include <scene_plugin/interface/intf_material.h>
50 #include <scene_plugin/api/scene_uid.h>
51 
52 #include <render/implementation_uids.h>
53 #include <render/gles/intf_device_gles.h>
54 #include <render/intf_renderer.h>
55 #include <render/intf_render_context.h>
56 
57 #include <ohos/platform_data.h>
58 
59 namespace OHOS::Render3D {
60 
61 class TextureLayer;
62 
63 class SceneAdapter : public ISceneAdapter {
64 public:
65     SceneAdapter();
66     bool LoadPluginsAndInit() override;
67     std::shared_ptr<TextureLayer> CreateTextureLayer() override;
68     void OnWindowChange(const WindowChangeInfo& windowChangeInfo) override;
69     void RenderFrame(bool needsSyncPaint = false) override;
Deinit()70     void Deinit() override {};
71     void SetNeedsRepaint(bool needsRepaint);
72     bool NeedsRepaint() override;
73     virtual void SetSceneObj(META_NS::IObject::Ptr pt);
74 
75     ~SceneAdapter() override;
76 
77 private:
78     bool LoadEngineLib();
79     bool LoadPlugins(const CORE_NS::PlatformCreateInfo& platformCreateInfo);
80     bool InitEngine(CORE_NS::PlatformCreateInfo platformCreateInfo);
81     void AttachSwapchain(META_NS::IObject::Ptr camera, RENDER_NS::RenderHandleReference swapchain);
82     void RenderFunction();
83     void InitRenderThread();
84     void DeinitRenderThread();
85 
86     META_NS::IObject::Ptr sceneWidgetObj_;
87     RENDER_NS::RenderHandleReference swapchainHandle_;
88 
89     std::shared_ptr<TextureLayer> textureLayer_;
90     HapInfo hapInfo_;
91     SCENE_NS::IBitmap::Ptr bitmap_;
92     uint32_t key_;
93     META_NS::ITaskQueue::Token renderTask {};
94     bool needsRepaint_ = true;
95     META_NS::ITaskQueueTask::Ptr singleFrameAsync;
96     META_NS::ITaskQueueWaitableTask::Ptr singleFrameSync;
97 };
98 } // namespace OHOS::Render3D
99 #endif // OHOS_RENDER_3D_SCENE_ADAPTER_H
100