• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DEFAULT_CAMERA_H
17 #define CORE__RENDER__NODE_DATA__RENDER_DATA_STORE_DEFAULT_CAMERA_H
18 
19 #include <atomic>
20 #include <cstdint>
21 
22 #include <3d/render/intf_render_data_store_default_camera.h>
23 #include <3d/render/render_data_defines_3d.h>
24 #include <base/containers/array_view.h>
25 #include <base/containers/refcnt_ptr.h>
26 #include <base/containers/string.h>
27 #include <base/containers/string_view.h>
28 #include <base/containers/unordered_map.h>
29 #include <base/containers/vector.h>
30 #include <base/util/uid.h>
31 
32 RENDER_BEGIN_NAMESPACE()
33 class IRenderContext;
34 RENDER_END_NAMESPACE()
35 
CORE3D_BEGIN_NAMESPACE()36 CORE3D_BEGIN_NAMESPACE()
37 /**
38 RenderDataStoreDefaultCamera implementation.
39 */
40 class RenderDataStoreDefaultCamera final : public IRenderDataStoreDefaultCamera {
41 public:
42     explicit RenderDataStoreDefaultCamera(const BASE_NS::string_view name);
43     ~RenderDataStoreDefaultCamera() override = default;
44 
45     // IRenderDataStore
46     void PreRender() override {}
47     // clear in post render
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     // IRenderDataStoreDefaultCamera
77     void AddCamera(const RenderCamera& camera) override;
78     void AddEnvironment(const RenderCamera::Environment& environment) override;
79 
80     BASE_NS::array_view<const RenderCamera> GetCameras() const override;
81     RenderCamera GetCamera(const BASE_NS::string_view name) const override;
82     RenderCamera GetCamera(const uint64_t id) const override;
83     uint32_t GetCameraIndex(const BASE_NS::string_view name) const override;
84     uint32_t GetCameraIndex(const uint64_t id) const override;
85     uint32_t GetCameraCount() const override;
86 
87     BASE_NS::array_view<const RenderCamera::Environment> GetEnvironments() const override;
88     RenderCamera::Environment GetEnvironment(const uint64_t id) const override;
89     uint32_t GetEnvironmentCount() const override;
90     bool HasBlendEnvironments() const override;
91     uint32_t GetEnvironmentIndex(const uint64_t id) const override;
92 
93     // for plugin / factory interface
94     static constexpr const char* const TYPE_NAME = "RenderDataStoreDefaultCamera";
95     static BASE_NS::refcnt_ptr<IRenderDataStore> Create(RENDER_NS::IRenderContext& renderContext, char const* name);
96 
97 private:
98     const BASE_NS::string name_;
99 
100     BASE_NS::vector<RenderCamera> cameras_;
101     BASE_NS::vector<RenderCamera::Environment> environments_;
102     bool hasBlendEnvironments_ { false };
103 
104     std::atomic_int32_t refcnt_ { 0 };
105 };
106 CORE3D_END_NAMESPACE()
107 
108 #endif // CORE__RENDER__NODE_DATA__RENDER_DATA_STORE_DEFAULT_CAMERA_H
109