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