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_RENDER_IRENDER_NODE_PARSER_UTIL_H
17 #define API_RENDER_IRENDER_NODE_PARSER_UTIL_H
18
19 #include <base/containers/string_view.h>
20 #include <base/util/uid.h>
21 #include <core/json/json.h>
22 #include <core/plugin/intf_interface.h>
23 #include <render/namespace.h>
24 #include <render/render_data_structures.h>
25
RENDER_BEGIN_NAMESPACE()26 RENDER_BEGIN_NAMESPACE()
27
28 /** @ingroup group_render_irendernodeparserutil */
29 /**
30 * Provides parsering utilities for render node graph node jsons.
31 */
32 class IRenderNodeParserUtil : public CORE_NS::IInterface {
33 public:
34 static constexpr auto UID = BASE_NS::Uid("cfba834a-63ea-4973-a3b5-337522cc51d2");
35
36 /** Get uint64_t value from json. Returns max value if not found.
37 * @param jsonValue Json value.
38 * @param name Name of the value.
39 */
40 virtual uint64_t GetUintValue(const CORE_NS::json::value& jsonValue, const BASE_NS::string_view name) const = 0;
41
42 /** Get int64_t value from json. Returns max value if not found.
43 * @param jsonValue Json value.
44 */
45 virtual int64_t GetIntValue(const CORE_NS::json::value& jsonValue, const BASE_NS::string_view name) const = 0;
46
47 /** Get uint32_t value from json. Returns max value if not found.
48 * @param jsonValue Json value.
49 */
50 virtual float GetFloatValue(const CORE_NS::json::value& jsonValue, const BASE_NS::string_view name) const = 0;
51
52 /** Get string value from json.
53 * @param jsonValue Json value.
54 */
55 virtual BASE_NS::string GetStringValue(
56 const CORE_NS::json::value& jsonValue, const BASE_NS::string_view name) const = 0;
57
58 /** Get input render pass from json.
59 * @param jsonValue Json value.
60 * @param name Name of the render pass in json. In core libraries "renderPass" is usually used.
61 */
62 virtual RenderNodeGraphInputs::InputRenderPass GetInputRenderPass(
63 const CORE_NS::json::value& jsonValue, const BASE_NS::string_view name) const = 0;
64
65 /** Get input render pass from json.
66 * @param jsonValue Json value.
67 * @param name Name of the resources pass in json. In core libraries "resources" is usually used.
68 */
69 virtual RenderNodeGraphInputs::InputResources GetInputResources(
70 const CORE_NS::json::value& jsonValue, const BASE_NS::string_view name) const = 0;
71
72 /** Get render data store from json.
73 * @param jsonValue Json value.
74 * @param name Name of the data store block json. In core libraries "renderDataStore" is usually used.
75 */
76 virtual RenderNodeGraphInputs::RenderDataStore GetRenderDataStore(
77 const CORE_NS::json::value& jsonValue, const BASE_NS::string_view name) const = 0;
78
79 /** Get GpuImageDescs from json.
80 * @param jsonValue Json value.
81 * @param name Name of the image desc block json. In core libraries "gpuImageDescs" is usually used.
82 */
83 virtual BASE_NS::vector<RenderNodeGraphInputs::RenderNodeGraphGpuImageDesc> GetGpuImageDescs(
84 const CORE_NS::json::value& jsonValue, const BASE_NS::string_view name) const = 0;
85
86 /** Get GpuBufferDescs from json.
87 * @param jsonValue Json value.
88 * @param name Name of the buffer desc block json. In core libraries "gpuBuffersDescs" is usually used.
89 */
90 virtual BASE_NS::vector<RenderNodeGraphInputs::RenderNodeGraphGpuBufferDesc> GetGpuBufferDescs(
91 const CORE_NS::json::value& jsonValue, const BASE_NS::string_view name) const = 0;
92
93 /** Get RenderSlotSortType from json.
94 * @param jsonValue Json value.
95 * @param name Name of the sort type block json. In core libraries "renderSlotSortType" is usually used.
96 */
97 virtual RenderSlotSortType GetRenderSlotSortType(
98 const CORE_NS::json::value& jsonValue, const BASE_NS::string_view name) const = 0;
99
100 /** Get RenderSlotCullType from json.
101 * @param jsonValue Json value.
102 * @param name Name of the cull type block json. In core libraries "renderSlotCullType" is usually used.
103 */
104 virtual RenderSlotCullType GetRenderSlotCullType(
105 const CORE_NS::json::value& jsonValue, const BASE_NS::string_view name) const = 0;
106
107 protected:
108 IRenderNodeParserUtil() = default;
109 virtual ~IRenderNodeParserUtil() = default;
110
111 IRenderNodeParserUtil(const IRenderNodeParserUtil&) = delete;
112 IRenderNodeParserUtil& operator=(const IRenderNodeParserUtil&) = delete;
113 IRenderNodeParserUtil(IRenderNodeParserUtil&&) = delete;
114 IRenderNodeParserUtil& operator=(IRenderNodeParserUtil&&) = delete;
115 };
116 RENDER_END_NAMESPACE()
117
118 #endif // API_RENDER_IRENDER_NODE_PARSER_UTIL_H
119