[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / public-api / model-components / material.cpp
1 /*
2  * Copyright (c) 2023 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/model-components/material.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23 #include <dali/public-api/rendering/sampler.h>
24
25 // INTERNAL INCLUDES
26 #include <dali-scene3d/internal/model-components/material-impl.h>
27
28 namespace Dali
29 {
30 namespace Scene3D
31 {
32 Material Material::New()
33 {
34   Internal::MaterialPtr internal = Internal::Material::New();
35
36   return Material(internal.Get());
37 }
38
39 Material::Material()
40 {
41 }
42
43 Material::Material(const Material& mateiral) = default;
44
45 Material::Material(Material&& rhs) noexcept = default;
46
47 Material::~Material()
48 {
49 }
50
51 Material& Material::operator=(const Material& handle) = default;
52
53 Material& Material::operator=(Material&& rhs) noexcept = default;
54
55 Material Material::DownCast(BaseHandle handle)
56 {
57   return Material(dynamic_cast<Dali::Scene3D::Internal::Material*>(handle.GetObjectPtr()));
58 }
59
60 Material::Material(Dali::Scene3D::Internal::Material* internal)
61 : BaseHandle(internal)
62 {
63 }
64
65 // Public Method
66
67 void Material::SetProperty(Dali::Property::Index index, Dali::Property::Value propertyValue)
68 {
69   GetImplementation(*this).SetProperty(index, propertyValue);
70 }
71
72 Dali::Property::Value Material::GetProperty(Dali::Property::Index index) const
73 {
74   return GetImplementation(*this).GetProperty(index);
75 }
76
77 void Material::SetTexture(Scene3D::Material::TextureType index, Dali::Texture texture)
78 {
79   GetImplementation(*this).SetTexture(index, texture);
80 }
81
82 Dali::Texture Material::GetTexture(Scene3D::Material::TextureType index)
83 {
84   return GetImplementation(*this).GetTexture(index);
85 }
86
87 void Material::SetSampler(Scene3D::Material::TextureType index, Dali::Sampler sampler)
88 {
89   GetImplementation(*this).SetSampler(index, sampler);
90 }
91
92 Dali::Sampler Material::GetSampler(Scene3D::Material::TextureType index)
93 {
94   return GetImplementation(*this).GetSampler(index);
95 }
96
97 } // namespace Scene3D
98
99 } // namespace Dali