[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / particle-system / particle-list.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 #include <dali-toolkit/internal/particle-system/particle-list-impl.h>
19 #include <dali-toolkit/public-api/particle-system/particle-list.h>
20
21 namespace Dali::Toolkit::ParticleSystem
22 {
23 template<>
24 ParticleStream::StreamDataType StreamDataTypeWrapper<Vector3>::GetType()
25 {
26   return ParticleStream::StreamDataType::FLOAT3;
27 }
28
29 template<>
30 ParticleStream::StreamDataType StreamDataTypeWrapper<Vector4>::GetType()
31 {
32   return ParticleStream::StreamDataType::FLOAT4;
33 }
34
35 template<>
36 ParticleStream::StreamDataType StreamDataTypeWrapper<Vector2>::GetType()
37 {
38   return ParticleStream::StreamDataType::FLOAT2;
39 }
40
41 template<>
42 ParticleStream::StreamDataType StreamDataTypeWrapper<float>::GetType()
43 {
44   return ParticleStream::StreamDataType::FLOAT;
45 }
46
47 ParticleList ParticleList::New(uint32_t capacity, const ParticleStreamTypeFlags& defaultStreams)
48 {
49   return {new ParticleSystem::Internal::ParticleList(capacity, defaultStreams)};
50 }
51
52 ParticleList ParticleList::DownCast(BaseHandle handle)
53 {
54   return {dynamic_cast<Internal::ParticleList*>(handle.GetObjectPtr())};
55 }
56
57 uint32_t ParticleList::AddStream(void* defaults, size_t dataTypeSize, ParticleStream::StreamDataType dataType, bool localStream)
58 {
59   return GetImplementation(*this).AddStream(dataTypeSize, defaults, dataType, "", localStream);
60 }
61
62 void* ParticleList::GetRawStream(uint32_t streamIndex)
63 {
64   return GetImplementation(*this).GetRawStream(streamIndex);
65 }
66
67 void* ParticleList::GetDefaultStream(ParticleStreamTypeFlagBit streamBit)
68 {
69   return GetImplementation(*this).GetDefaultStream(streamBit);
70 }
71
72 uint32_t ParticleList::GetActiveParticleCount()
73 {
74   return GetImplementation(*this).GetActiveParticleCount();
75 }
76
77 ParticleList::ParticleList(Dali::Toolkit::ParticleSystem::Internal::ParticleList* impl)
78 : Dali::BaseHandle(impl)
79 {
80 }
81
82 uint32_t ParticleList::GetCapacity() const
83 {
84   return GetImplementation(*this).GetParticleCount();
85 }
86
87 Particle ParticleList::NewParticle(float lifetime)
88 {
89   return GetImplementation(*this).NewParticle(lifetime);
90 }
91
92 uint32_t ParticleList::GetParticleDataSize(bool includeLocalStreams)
93 {
94   return GetImplementation(*this).GetStreamElementSize(includeLocalStreams);
95 }
96
97 int ParticleList::GetDefaultStreamIndex(ParticleStreamTypeFlagBit defaultStreamBit)
98 {
99   return GetImplementation(*this).GetDefaultStreamIndex(defaultStreamBit);
100 }
101
102 std::list<Particle>& ParticleList::GetActiveParticles()
103 {
104   return GetImplementation(*this).GetParticles();
105 }
106
107 ParticleList::ParticleList() = default;
108
109 } // namespace Dali::Toolkit::ParticleSystem