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 API_3D_IGRAPHICS_CONTEXT_H 17 #define API_3D_IGRAPHICS_CONTEXT_H 18 19 #include <3d/namespace.h> 20 #include <base/containers/array_view.h> 21 #include <core/namespace.h> 22 #include <core/plugin/intf_interface.h> 23 #include <render/namespace.h> 24 25 CORE_BEGIN_NAMESPACE() 26 class IEngine; 27 class IEcs; 28 CORE_END_NAMESPACE() 29 30 RENDER_BEGIN_NAMESPACE() 31 class IRenderContext; 32 class RenderHandleReference; 33 RENDER_END_NAMESPACE() 34 35 CORE3D_BEGIN_NAMESPACE() 36 class ISceneUtil; 37 class IRenderUtil; 38 class IMeshUtil; 39 class IGltf2; 40 41 /** 42 * IGraphicsContext. 43 * Graphics context interface for 3D rendering use cases. 44 */ 45 class IGraphicsContext : public CORE_NS::IInterface { 46 public: 47 static constexpr auto UID = BASE_NS::Uid { "c6eb95b1-8b32-40f7-8acd-7969792e574b" }; 48 49 using Ptr = BASE_NS::refcnt_ptr<IGraphicsContext>; 50 51 /** Initialize the context. 52 */ 53 virtual void Init() = 0; 54 55 /** Get rendering context. 56 * @return Reference to context. 57 */ 58 virtual RENDER_NS::IRenderContext& GetRenderContext() const = 0; 59 60 /** Get render node graphs from ECS instance. 61 * @return Array view of ECS instance render node graphs. 62 */ 63 virtual BASE_NS::array_view<const RENDER_NS::RenderHandleReference> GetRenderNodeGraphs( 64 const CORE_NS::IEcs& ecs) const = 0; 65 66 /** Get SceneUtil interface. Uses graphics context resource creator and engine internally. 67 * @return Reference to scene util interface. 68 */ 69 virtual ISceneUtil& GetSceneUtil() const = 0; 70 71 /** Get MeshUtil interface. Uses graphics context resource creator and engine internally. 72 * @return Reference to mesh util interface. 73 */ 74 virtual IMeshUtil& GetMeshUtil() const = 0; 75 76 /** Get Gltf2 interface. Uses graphics context resource creator and engine internally. 77 * @return Reference to gltf2 interface. 78 */ 79 virtual IGltf2& GetGltf() const = 0; 80 81 /** Get render util. 82 * @return Reference to render util. 83 */ 84 virtual IRenderUtil& GetRenderUtil() const = 0; 85 86 protected: 87 IGraphicsContext() = default; 88 virtual ~IGraphicsContext() = default; 89 }; 90 CORE3D_END_NAMESPACE() 91 92 #endif // API_3D_IGRAPHICS_CONTEXT_H 93