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 CORE__RENDER__NODE_DATA__RENDER_DATA_STORE_MORPH_H
17 #define CORE__RENDER__NODE_DATA__RENDER_DATA_STORE_MORPH_H
18 
19 #include <cstdint>
20 
21 #include <3d/render/intf_render_data_store_morph.h>
22 #include <base/containers/array_view.h>
23 #include <base/containers/string.h>
24 #include <base/containers/string_view.h>
25 #include <base/containers/vector.h>
26 #include <base/util/uid.h>
27 
28 RENDER_BEGIN_NAMESPACE()
29 class IRenderContext;
30 RENDER_END_NAMESPACE()
31 
CORE3D_BEGIN_NAMESPACE()32 CORE3D_BEGIN_NAMESPACE()
33 /**
34 RenderDataStoreMorph implementation.
35 */
36 class RenderDataStoreMorph final : public IRenderDataStoreMorph {
37 public:
38     explicit RenderDataStoreMorph(const BASE_NS::string_view name);
39     ~RenderDataStoreMorph() override = default;
40 
41     void Init(const IRenderDataStoreMorph::ReserveSize& reserveSize);
42 
43     void CommitFrameData() override {};
44     void PreRender() override {};
45     // Reset and start indexing from the beginning. i.e. frame boundary reset.
46     void PostRender() override;
47     void PreRenderBackend() override {};
48     void PostRenderBackend() override {};
49     void Clear() override;
50     uint32_t GetFlags() const override
51     {
52         return 0;
53     };
54 
55     // Add submeshes safely.
56     void AddSubmesh(const RenderDataMorph::Submesh& submesh) override;
57 
58     BASE_NS::array_view<const RenderDataMorph::Submesh> GetSubmeshes() const override;
59 
60     // for plugin / factory interface
61     static constexpr char const* const TYPE_NAME = "RenderDataStoreMorph";
62     static IRenderDataStore* Create(RENDER_NS::IRenderContext& renderContext, char const* name);
63     static void Destroy(IRenderDataStore* instance);
64 
65     BASE_NS::string_view GetTypeName() const override
66     {
67         return TYPE_NAME;
68     }
69 
70     BASE_NS::string_view GetName() const override
71     {
72         return name_;
73     }
74 
75     const BASE_NS::Uid& GetUid() const override
76     {
77         return UID;
78     }
79 
80 private:
81     const BASE_NS::string name_;
82 
83     BASE_NS::vector<RenderDataMorph::Submesh> submeshes_;
84 };
85 CORE3D_END_NAMESPACE()
86 
87 #endif // CORE__RENDER__NODE_DATA__RENDER_DATA_STORE_MORPH_H
88