Merge "Fixed vector and list includes to use wrappers" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / particle-system / particle-renderer-impl.h
1 #ifndef DALI_TOOLKIT_PARTICLE_SYSTEM_INTERNAL_PARTICLE_RENDERER_H
2 #define DALI_TOOLKIT_PARTICLE_SYSTEM_INTERNAL_PARTICLE_RENDERER_H
3 /*
4  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
5  *
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  */
19
20 #include <memory>
21
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>
25
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>
31
32 namespace Dali::Graphics
33 {
34 class Controller;
35 class Shader;
36 } // namespace Dali::Graphics
37
38 namespace Dali::Toolkit::ParticleSystem
39 {
40 class ParticleEmitter;
41 }
42
43 namespace Dali::Toolkit::ParticleSystem::Internal
44 {
45 class ParticleEmitter;
46 class ParticleRenderer;
47 class ParticleList;
48
49 class ParticleRenderer : public Dali::BaseObject
50 {
51 public:
52   ParticleRenderer();
53
54   /**
55    * Create shader
56    */
57   void CreateShader();
58
59   void SetTexture(const Dali::Texture& texture);
60
61   void SetBlendingMode(BlendingMode blendingMode);
62
63   bool Initialize();
64
65   void SetEmitter(ParticleSystem::Internal::ParticleEmitter* emitter);
66
67   void UpdateParticlesTask(Internal::ParticleList& list,
68                            uint32_t                particleStartIndex,
69                            uint32_t                particleCount,
70                            uint8_t*                dst);
71
72   [[nodiscard]] Renderer GetRenderer() const;
73
74   uint32_t OnStreamBufferUpdate(void* data, size_t size);
75
76   bool mUsingStreamDivisor{true}; ///< If attribute divisor is supported, it's going to be used
77
78   Internal::ParticleEmitter* mEmitter{nullptr}; ///< Emitter implementation that uses the renderer
79
80   Dali::Texture      mTexture;
81   Dali::TextureSet   mTextureSet;
82   Dali::Renderer     mRenderer;
83   Dali::Shader       mShader;
84   Dali::Geometry     mGeometry;
85   Dali::VertexBuffer mVertexBuffer;
86   Dali::VertexBuffer mStreamBuffer;
87   BlendingMode       mBlendingMode{BlendingMode::DEFAULT};
88
89   std::unique_ptr<Dali::VertexBufferUpdateCallback> mStreamBufferUpdateCallback;
90
91   bool mInitialized{false};
92 };
93 } // namespace Dali::Toolkit::ParticleSystem::Internal
94 namespace Dali
95 {
96 inline Toolkit::ParticleSystem::Internal::ParticleRenderer& GetImplementation(Toolkit::ParticleSystem::ParticleRenderer& source)
97 {
98   DALI_ASSERT_ALWAYS(source && "ParticleRenderer handle is empty");
99
100   BaseObject& handle = source.GetBaseObject();
101
102   return static_cast<Toolkit::ParticleSystem::Internal::ParticleRenderer&>(handle);
103 }
104
105 inline const Toolkit::ParticleSystem::Internal::ParticleRenderer& GetImplementation(const Toolkit::ParticleSystem::ParticleRenderer& source)
106 {
107   DALI_ASSERT_ALWAYS(source && "ParticleRenderer handle is empty");
108
109   const BaseObject& handle = source.GetBaseObject();
110
111   return static_cast<const Toolkit::ParticleSystem::Internal::ParticleRenderer&>(handle);
112 }
113
114 } // namespace Dali
115
116 #endif // DALI_TOOLKIT_PARTICLE_SYSTEM_INTERNAL_PARTICLE_RENDERER_H