1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_RENDER_PARTICLE_SYSTEM_H 17 #define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_RENDER_PARTICLE_SYSTEM_H 18 19 #include "rs_render_particle_emitter.h" 20 21 namespace OHOS { 22 namespace Rosen { 23 class RSB_EXPORT RSRenderParticleSystem : RSRenderParticleEffector { 24 public: 25 explicit RSRenderParticleSystem(const std::vector<std::shared_ptr<ParticleRenderParams>>& particlesRenderParams); 26 virtual ~RSRenderParticleSystem() = default; 27 RSRenderParticleSystem() = default; 28 void CreateEmitter(); 29 void ClearEmitter(); 30 void Emit(int64_t deltaTime, std::vector<std::shared_ptr<RSRenderParticle>>& activeParticles, 31 std::vector<std::shared_ptr<RSImage>>& imageVector); 32 void UpdateParticle(int64_t deltaTime, std::vector<std::shared_ptr<RSRenderParticle>>& activeParticles); 33 bool IsFinish(const std::vector<std::shared_ptr<RSRenderParticle>>& activeParticles); 34 void UpdateEmitter(const std::vector<std::shared_ptr<ParticleRenderParams>>& particlesRenderParams); 35 void UpdateNoiseField(const std::shared_ptr<ParticleNoiseFields>& particleNoiseFields); GetParticleEmitter()36 const std::vector<std::shared_ptr<RSRenderParticleEmitter>>& GetParticleEmitter() const 37 { 38 return emitters_; 39 } GetParticleNoiseFields()40 const std::shared_ptr<ParticleNoiseFields>& GetParticleNoiseFields() const 41 { 42 return particleNoiseFields_; 43 } 44 45 private: 46 std::vector<std::shared_ptr<ParticleRenderParams>> particlesRenderParams_ = {}; 47 std::vector<std::shared_ptr<RSRenderParticleEmitter>> emitters_ = {}; 48 std::shared_ptr<ParticleNoiseFields> particleNoiseFields_; 49 std::vector<std::shared_ptr<RSImage>> imageVector_; 50 }; 51 } // namespace Rosen 52 } // namespace OHOS 53 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_RENDER_PARTICLE_SYSTEM_H 54