• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 RENDER_DATA_STORE_RENDER_POST_PROCESSES_H
17 #define RENDER_DATA_STORE_RENDER_POST_PROCESSES_H
18 
19 #include <atomic>
20 #include <cstdint>
21 #include <mutex>
22 
23 #include <base/containers/string.h>
24 #include <base/containers/string_view.h>
25 #include <base/containers/unordered_map.h>
26 #include <base/math/vector.h>
27 #include <base/util/uid.h>
28 #include <render/datastore/intf_render_data_store_render_post_processes.h>
29 #include <render/namespace.h>
30 
31 RENDER_BEGIN_NAMESPACE()
32 class IRenderContext;
33 
34 /**
35  * RenderDataStoreRenderPostProcesses implementation.
36  */
37 class RenderDataStoreRenderPostProcesses final : public IRenderDataStoreRenderPostProcesses {
38 public:
39     RenderDataStoreRenderPostProcesses(const IRenderContext& renderContex, BASE_NS::string_view name);
40     ~RenderDataStoreRenderPostProcesses() override;
41 
42     void AddData(BASE_NS::string_view name, BASE_NS::array_view<const PostProcessData> data) override;
43     PostProcessPipeline GetData(BASE_NS::string_view name) const override;
44 
PreRender()45     void PreRender() override {};
46     void PostRender() override;
PreRenderBackend()47     void PreRenderBackend() override {};
PostRenderBackend()48     void PostRenderBackend() override {};
49     void Clear() override;
GetFlags()50     uint32_t GetFlags() const override
51     {
52         return 0;
53     };
54 
GetTypeName()55     BASE_NS::string_view GetTypeName() const override
56     {
57         return TYPE_NAME;
58     }
59 
GetName()60     BASE_NS::string_view GetName() const override
61     {
62         return name_;
63     }
64 
GetUid()65     const BASE_NS::Uid& GetUid() const override
66     {
67         return UID;
68     }
69 
70     void Ref() override;
71     void Unref() override;
72     int32_t GetRefCount() override;
73 
74     // for plugin / factory interface
75     static constexpr const char* const TYPE_NAME = "RenderDataStoreRenderPostProcesses";
76 
77     static BASE_NS::refcnt_ptr<IRenderDataStore> Create(IRenderContext& renderContext, const char* name);
78 
79 private:
80     const BASE_NS::string name_;
81 
82     BASE_NS::vector<PostProcessPipeline> pipelines_;
83     BASE_NS::unordered_map<BASE_NS::string, uint32_t> nameToPipeline_;
84 
85     mutable std::mutex mutex_;
86 
87     std::atomic_int32_t refcnt_ { 0 };
88 };
89 RENDER_END_NAMESPACE()
90 
91 #endif // RENDER_DATA_STORE_RENDER_POST_PROCESSES_H
92