1 /* 2 * Copyright (c) 2024 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_RENDER_RS_PARTICLE_DRAWABLE_H 17 #define RENDER_SERVICE_CLIENT_CORE_RENDER_RS_PARTICLE_DRAWABLE_H 18 19 #include "animation/rs_render_particle.h" 20 #include "draw/canvas.h" 21 #include "image/image.h" 22 #include "render/rs_image.h" 23 namespace OHOS { 24 namespace Rosen { 25 class RSB_EXPORT RSParticlesDrawable { 26 public: 27 explicit RSParticlesDrawable(const std::vector<std::shared_ptr<RSRenderParticle>>& particles, 28 std::vector<std::shared_ptr<RSImage>>& imageVector, size_t imageCount); 29 RSParticlesDrawable() = default; 30 ~RSParticlesDrawable() = default; 31 void Draw(Drawing::Canvas& canvas, std::shared_ptr<RectF> bounds); 32 33 private: 34 std::shared_ptr<Drawing::Image> MakeCircleImage(int radius); 35 Drawing::RSXform MakeRSXform(Vector2f ofs, Vector2f position, float spin, float scale); 36 void CaculatePointAtlsArry( 37 const std::shared_ptr<RSRenderParticle>& particle, Vector2f position, float opacity, float scale); 38 void CaculateImageAtlsArry(Drawing::Canvas& canvas, const std::shared_ptr<RSRenderParticle>& particle, 39 Vector2f position, float opacity, float scale); 40 void DrawImageFill(Drawing::Canvas& canvas, const std::shared_ptr<RSRenderParticle>& particle, 41 Vector2f position, float opacity, float scale); 42 void DrawParticles(Drawing::Canvas& canvas); 43 void DrawCircle(Drawing::Canvas& canvas); 44 void DrawImages(Drawing::Canvas& canvas); 45 46 std::vector<std::shared_ptr<RSRenderParticle>> particles_; 47 std::shared_ptr<Drawing::Image> circleImage_; 48 std::vector<std::shared_ptr<RSImage>> imageVector_; 49 size_t imageCount_; 50 51 size_t pointCount_ = 0; 52 std::vector<Drawing::RSXform> pointRsxform_; 53 std::vector<Drawing::Rect> pointTex_; 54 std::vector<Drawing::ColorQuad> pointColors_; 55 56 std::vector<int> count_; // Counts the number of each image 57 std::vector<std::vector<Drawing::RSXform>> imageRsxform_; 58 std::vector<std::vector<Drawing::Rect>> imageTex_; 59 std::vector<std::vector<Drawing::ColorQuad>> imageColors_; 60 }; 61 62 } // namespace Rosen 63 } // namespace OHOS 64 #endif // RENDER_SERVICE_CLIENT_CORE_RENDER_RS_PARTICLE_DRAWABLE_H