• 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 CORE__RENDER__NODE_DATA__RENDER_DATA_STORE_DEFAULT_LIGHT_H
17 #define CORE__RENDER__NODE_DATA__RENDER_DATA_STORE_DEFAULT_LIGHT_H
18 
19 #include <atomic>
20 #include <cstdint>
21 
22 #include <3d/render/intf_render_data_store_default_light.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/vector.h>
27 #include <base/util/uid.h>
28 
29 RENDER_BEGIN_NAMESPACE()
30 class IRenderContext;
31 RENDER_END_NAMESPACE()
32 
CORE3D_BEGIN_NAMESPACE()33 CORE3D_BEGIN_NAMESPACE()
34 /**
35 RenderDataStoreDefaultLight implementation.
36 */
37 class RenderDataStoreDefaultLight final : public IRenderDataStoreDefaultLight {
38 public:
39     explicit RenderDataStoreDefaultLight(const BASE_NS::string_view name);
40     ~RenderDataStoreDefaultLight() override = default;
41 
42     // IRenderDataStore
43     void PreRender() override {}
44     // clear in post render
45     void PostRender() override;
46     void PreRenderBackend() override {}
47     void PostRenderBackend() override {}
48     void Clear() override;
49     uint32_t GetFlags() const override
50     {
51         return 0;
52     }
53 
54     BASE_NS::string_view GetTypeName() const override
55     {
56         return TYPE_NAME;
57     }
58 
59     BASE_NS::string_view GetName() const override
60     {
61         return name_;
62     }
63 
64     const BASE_NS::Uid& GetUid() const override
65     {
66         return UID;
67     }
68 
69     void Ref() override;
70     void Unref() override;
71     int32_t GetRefCount() override;
72 
73     // IRenderDataStoreDefaultLight
74     void SetShadowTypes(const ShadowTypes& shadowTypes, const uint32_t flags) override;
75     ShadowTypes GetShadowTypes() const override;
76 
77     void SetShadowQualityResolutions(const ShadowQualityResolutions& resolutions, const uint32_t flags) override;
78     BASE_NS::Math::UVec2 GetShadowQualityResolution() const override;
79 
80     void AddLight(const RenderLight& light) override;
81     BASE_NS::array_view<const RenderLight> GetLights() const override;
82     LightCounts GetLightCounts() const override;
83     LightingFlags GetLightingFlags() const override;
84 
85     // for plugin / factory interface
86     static constexpr const char* const TYPE_NAME = "RenderDataStoreDefaultLight";
87     static BASE_NS::refcnt_ptr<IRenderDataStore> Create(RENDER_NS::IRenderContext& renderContext, char const* name);
88 
89 private:
90     const BASE_NS::string name_;
91 
92     BASE_NS::vector<RenderLight> lights_;
93 
94     IRenderDataStoreDefaultLight::LightCounts lightCounts_;
95     IRenderDataStoreDefaultLight::ShadowTypes shadowTypes_;
96     IRenderDataStoreDefaultLight::ShadowQualityResolutions resolutions_;
97 
98     std::atomic_int32_t refcnt_ { 0 };
99 };
100 CORE3D_END_NAMESPACE()
101 
102 #endif // CORE__RENDER__NODE_DATA__RENDER_DATA_STORE_DEFAULT_LIGHT_H
103