[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / public-api / light / light.cpp
1 /*
2  * Copyright (c) 2024 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali-scene3d/public-api/light/light.h>
20
21 // INTERNAL INCLUDES
22 #include <dali-scene3d/internal/light/light-impl.h>
23
24 namespace Dali
25 {
26 namespace Scene3D
27 {
28 Light::Light()
29 {
30 }
31
32 Light::Light(const Light& light) = default;
33
34 Light::Light(Light&& rhs) noexcept = default;
35
36 Light& Light::operator=(const Light& light) = default;
37
38 Light& Light::operator=(Light&& rhs) noexcept = default;
39
40 Light::~Light()
41 {
42 }
43
44 Light Light::New()
45 {
46   return Internal::Light::New();
47 }
48
49 Light Light::DownCast(BaseHandle handle)
50 {
51   Light result;
52
53   CustomActor custom = Dali::CustomActor::DownCast(handle);
54   if(custom)
55   {
56     CustomActorImpl& customImpl = custom.GetImplementation();
57
58     Internal::Light* impl = dynamic_cast<Internal::Light*>(&customImpl);
59
60     if(impl)
61     {
62       result = Light(customImpl.GetOwner());
63     }
64   }
65
66   return result;
67 }
68
69 void Light::Enable(bool enable)
70 {
71   Internal::GetImplementation(*this).Enable(enable);
72 }
73
74 bool Light::IsEnabled() const
75 {
76   return Internal::GetImplementation(*this).IsEnabled();
77 }
78
79 uint32_t Light::GetMaximumEnabledLightCount()
80 {
81   return Internal::Light::GetMaximumEnabledLightCount();
82 }
83
84 void Light::EnableShadow(bool enable)
85 {
86   Internal::GetImplementation(*this).EnableShadow(enable);
87 }
88
89 bool Light::IsShadowEnabled() const
90 {
91   return Internal::GetImplementation(*this).IsShadowEnabled();
92 }
93
94 void Light::EnableShadowSoftFiltering(bool useSoftFiltering)
95 {
96   Internal::GetImplementation(*this).EnableShadowSoftFiltering(useSoftFiltering);
97 }
98
99 bool Light::IsShadowSoftFilteringEnabled() const
100 {
101   return Internal::GetImplementation(*this).IsShadowSoftFilteringEnabled();
102 }
103
104 void Light::SetShadowIntensity(float shadowIntensity)
105 {
106   Internal::GetImplementation(*this).SetShadowIntensity(shadowIntensity);
107 }
108
109 float Light::GetShadowIntensity() const
110 {
111   return Internal::GetImplementation(*this).GetShadowIntensity();
112 }
113
114 void Light::SetShadowBias(float shadowBias)
115 {
116   Internal::GetImplementation(*this).SetShadowBias(shadowBias);
117 }
118
119 float Light::GetShadowBias() const
120 {
121   return Internal::GetImplementation(*this).GetShadowBias();
122 }
123
124 Light::Light(Internal::Light& implementation)
125 : Control(implementation)
126 {
127 }
128
129 Light::Light(Dali::Internal::CustomActor* internal)
130 : Control(internal)
131 {
132   // Can have a NULL pointer so we only need to check if the internal implementation is our class
133   // when there is a value.
134   if(internal)
135   {
136     DALI_ASSERT_DEBUG(dynamic_cast<Internal::Light*>(&CustomActor(internal).GetImplementation()));
137   }
138 }
139
140 } // namespace Scene3D
141
142 } // namespace Dali