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_ANIMATION_H 17 #define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_RENDER_PARTICLE_ANIMATION_H 18 19 #include <memory> 20 21 #include "rs_particle_noise_field.h" 22 #include "rs_render_particle.h" 23 24 #include "animation/rs_render_particle_system.h" 25 #include "animation/rs_render_property_animation.h" 26 #include "common/rs_macros.h" 27 28 namespace OHOS { 29 namespace Rosen { 30 class RSB_EXPORT RSRenderParticleAnimation : public RSRenderPropertyAnimation { 31 public: 32 RSRenderParticleAnimation(AnimationId id, const PropertyId& propertyId, 33 const std::vector<std::shared_ptr<ParticleRenderParams>>& particlesRenderParams); 34 35 ~RSRenderParticleAnimation() override = default; 36 RSRenderParticleAnimation() = default; 37 38 void DumpAnimationType(std::string& out) const override; 39 40 bool Marshalling(Parcel& parcel) const override; 41 42 [[nodiscard]] static RSRenderParticleAnimation* Unmarshalling(Parcel& parcel); GetRenderParticle()43 const RSRenderParticleVector& GetRenderParticle() 44 { 45 return renderParticleVector_; 46 } 47 bool Animate(int64_t time) override; 48 void UpdateEmitter(const std::vector<std::shared_ptr<EmitterUpdater>>& emitterUpdater); 49 void UpdateNoiseField(const std::shared_ptr<ParticleNoiseFields>& particleNoiseFields); GetParticleSystem()50 const std::shared_ptr<RSRenderParticleSystem>& GetParticleSystem() 51 { 52 return particleSystem_; 53 } 54 55 protected: 56 void OnAttach() override; 57 void OnDetach() override; 58 59 private: 60 bool ParseParam(Parcel& parcel) override; 61 std::vector<std::shared_ptr<ParticleRenderParams>> particlesRenderParams_; 62 std::shared_ptr<RSRenderParticleSystem> particleSystem_; 63 RSRenderParticleVector renderParticleVector_; 64 std::shared_ptr<ParticleNoiseFields> particleNoiseFields_; 65 }; 66 } // namespace Rosen 67 } // namespace OHOS 68 69 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_RENDER_PARTICLE_ANIMATION_H 70