Merge "Clean up the code to build successfully on macOS" into devel/master
[platform/core/uifw/dali-core.git] / dali / public-api / rendering / texture-set.cpp
1 /*
2  * Copyright (c) 2020 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/public-api/rendering/texture-set.h> // Dali::TextureSet
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/event/rendering/sampler-impl.h>     // Dali::Internal::Sampler
23 #include <dali/internal/event/rendering/shader-impl.h>      // Dali::Internal::Shader
24 #include <dali/internal/event/rendering/texture-set-impl.h> // Dali::Internal::TextureSet
25
26 namespace Dali
27 {
28 TextureSet TextureSet::New()
29 {
30   Internal::TextureSetPtr textureSet = Internal::TextureSet::New();
31   return TextureSet(textureSet.Get());
32 }
33
34 TextureSet::TextureSet() = default;
35
36 TextureSet::~TextureSet() = default;
37
38 TextureSet::TextureSet(const TextureSet& handle) = default;
39
40 TextureSet TextureSet::DownCast(BaseHandle handle)
41 {
42   return TextureSet(dynamic_cast<Dali::Internal::TextureSet*>(handle.GetObjectPtr()));
43 }
44
45 TextureSet& TextureSet::operator=(const TextureSet& handle) = default;
46
47 TextureSet::TextureSet(TextureSet&& rhs) = default;
48
49 TextureSet& TextureSet::operator=(TextureSet&& rhs) = default;
50
51 void TextureSet::SetTexture(size_t index, Texture texture)
52 {
53   if(texture)
54   {
55     Internal::TexturePtr texturePtr(&GetImplementation(texture));
56     GetImplementation(*this).SetTexture(static_cast<uint32_t>(index), texturePtr); // only support 4,294,967,295 textures
57   }
58   else
59   {
60     GetImplementation(*this).SetTexture(static_cast<uint32_t>(index), nullptr); // only support 4,294,967,295 textures
61   }
62 }
63
64 Texture TextureSet::GetTexture(size_t index) const
65 {
66   Internal::Texture* texturePtr = GetImplementation(*this).GetTexture(static_cast<uint32_t>(index)); // only support 4,294,967,295 textures
67   return Dali::Texture(texturePtr);
68 }
69
70 void TextureSet::SetSampler(size_t index, Sampler sampler)
71 {
72   if(sampler)
73   {
74     Internal::SamplerPtr samplerPtr(&GetImplementation(sampler));
75     GetImplementation(*this).SetSampler(static_cast<uint32_t>(index), samplerPtr); // only support 4,294,967,295 samplers
76   }
77   else
78   {
79     GetImplementation(*this).SetSampler(static_cast<uint32_t>(index), nullptr); // only support 4,294,967,295 samplers
80   }
81 }
82
83 Sampler TextureSet::GetSampler(size_t index) const
84 {
85   Internal::Sampler* samplerPtr = GetImplementation(*this).GetSampler(static_cast<uint32_t>(index)); // only support 4,294,967,295 samplers
86   return Dali::Sampler(samplerPtr);
87 }
88
89 size_t TextureSet::GetTextureCount() const
90 {
91   return GetImplementation(*this).GetTextureCount();
92 }
93
94 TextureSet::TextureSet(Internal::TextureSet* pointer)
95 : BaseHandle(pointer)
96 {
97 }
98
99 } //namespace Dali