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_FUZZ_SCENE 17 #define OHOS_FUZZ_SCENE 18 19 20 #include <base/containers/array_view.h> 21 22 #include <core/intf_engine.h> 23 #include <core/ecs/intf_system_graph_loader.h> 24 #include <core/engine_info.h> 25 #include <core/implementation_uids.h> 26 #include <core/io/intf_file_manager.h> 27 #include <core/namespace.h> 28 #include <core/os/intf_platform.h> 29 #include <core/plugin/intf_plugin_register.h> 30 #include <core/property/intf_property_handle.h> 31 #include <3d/implementation_uids.h> 32 #include <3d/intf_graphics_context.h> 33 34 #include <render/implementation_uids.h> 35 #include <render/gles/intf_device_gles.h> 36 #include <render/intf_renderer.h> 37 #include <render/intf_render_context.h> 38 39 #include <meta/base/shared_ptr.h> 40 #include <memory> 41 #include "scene_adapter/intf_scene_adapter.h" 42 43 namespace OHOS::FUZZ { 44 45 struct EngineInstance { 46 void *libHandle_ = nullptr; 47 BASE_NS::shared_ptr<RENDER_NS::IRenderContext> renderContext_; 48 BASE_NS::shared_ptr<CORE_NS::IEngine> engine_; 49 BASE_NS::shared_ptr<CORE3D_NS::IGraphicsContext> graphicsContext_; 50 bool libsLoaded_ = false; 51 }; 52 53 class ISceneInit : public Render3D::ISceneAdapter { 54 public: 55 virtual bool LoadPluginsAndInit() = 0; 56 virtual std::shared_ptr<Render3D::TextureLayer> CreateTextureLayer() = 0; 57 virtual void OnWindowChange(const Render3D::WindowChangeInfo& windowChangeInfo) = 0; 58 virtual void RenderFrame(bool needsSyncPaint = false) = 0; 59 virtual EngineInstance& GetEngineInstance() = 0; 60 virtual void Deinit() = 0; 61 virtual bool NeedsRepaint() = 0; 62 virtual ~ISceneInit() = default; 63 }; 64 65 std::shared_ptr<ISceneInit> CreateFuzzScene(); 66 } 67 68 #endif // OHOS_FUZZ_SCENE