1 #ifndef DALI_TOOLKIT_PARTICLE_SYSTEM_INTERNAL_PARTICLE_RENDERER_H
2 #define DALI_TOOLKIT_PARTICLE_SYSTEM_INTERNAL_PARTICLE_RENDERER_H
4 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
22 #include <dali-toolkit/public-api/particle-system/particle-emitter.h>
23 #include <dali-toolkit/public-api/particle-system/particle-renderer.h>
24 #include <dali-toolkit/public-api/particle-system/particle.h>
26 #include <dali/public-api/actors/actor.h>
27 #include <dali/public-api/object/base-object.h>
28 #include <dali/public-api/rendering/renderer.h>
29 #include <dali/public-api/rendering/vertex-buffer.h>
30 #include <dali/public-api/signals/render-callback.h>
32 namespace Dali::Graphics
36 } // namespace Dali::Graphics
38 namespace Dali::Toolkit::ParticleSystem
40 class ParticleEmitter;
43 namespace Dali::Toolkit::ParticleSystem::Internal
45 class ParticleEmitter;
46 class ParticleRenderer;
49 class ParticleRenderer : public Dali::BaseObject
59 void SetTexture(const Dali::Texture& texture);
61 void SetBlendingMode(BlendingMode blendingMode);
63 BlendingMode GetBlendingMode() const;
69 void SetEmitter(ParticleSystem::Internal::ParticleEmitter* emitter);
71 void UpdateParticlesTask(Internal::ParticleList& list,
72 uint32_t particleStartIndex,
73 uint32_t particleCount,
76 [[nodiscard]] Renderer GetRenderer() const;
78 uint32_t OnStreamBufferUpdate(void* data, size_t size);
80 bool mUsingStreamDivisor{true}; ///< If attribute divisor is supported, it's going to be used
82 Internal::ParticleEmitter* mEmitter{nullptr}; ///< Emitter implementation that uses the renderer
84 Dali::Texture mTexture;
85 Dali::TextureSet mTextureSet;
86 Dali::Renderer mRenderer;
88 Dali::Geometry mGeometry;
89 Dali::VertexBuffer mVertexBuffer;
90 Dali::VertexBuffer mStreamBuffer;
91 BlendingMode mBlendingMode{BlendingMode::DEFAULT};
93 std::unique_ptr<Dali::VertexBufferUpdateCallback> mStreamBufferUpdateCallback;
95 bool mInitialized{false};
97 } // namespace Dali::Toolkit::ParticleSystem::Internal
100 inline Toolkit::ParticleSystem::Internal::ParticleRenderer& GetImplementation(Toolkit::ParticleSystem::ParticleRenderer& source)
102 DALI_ASSERT_ALWAYS(source && "ParticleRenderer handle is empty");
104 BaseObject& handle = source.GetBaseObject();
106 return static_cast<Toolkit::ParticleSystem::Internal::ParticleRenderer&>(handle);
109 inline const Toolkit::ParticleSystem::Internal::ParticleRenderer& GetImplementation(const Toolkit::ParticleSystem::ParticleRenderer& source)
111 DALI_ASSERT_ALWAYS(source && "ParticleRenderer handle is empty");
113 const BaseObject& handle = source.GetBaseObject();
115 return static_cast<const Toolkit::ParticleSystem::Internal::ParticleRenderer&>(handle);
120 #endif // DALI_TOOLKIT_PARTICLE_SYSTEM_INTERNAL_PARTICLE_RENDERER_H