1 /* 2 * Copyright (C) 2023 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 <base/containers/string_view.h> 22 #include <core/namespace.h> 23 #include <core/plugin/intf_interface.h> 24 #include <render/resource_handle.h> 25 26 CORE_BEGIN_NAMESPACE() 27 class IEngine; 28 class IEcs; 29 CORE_END_NAMESPACE() 30 31 RENDER_BEGIN_NAMESPACE() 32 class IRenderContext; 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 GetName(const IGraphicsContext *)91inline constexpr BASE_NS::string_view GetName(const IGraphicsContext*) 92 { 93 return "IGraphicsContext3D"; 94 } 95 CORE3D_END_NAMESPACE() 96 97 #endif // API_3D_IGRAPHICS_CONTEXT_H 98