1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd.. All rights reserved. 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 SYMBOL_ENGINE_TEXT_ANIMATION_CONFIG_H 17 #define SYMBOL_ENGINE_TEXT_ANIMATION_CONFIG_H 18 19 #include <iostream> 20 #include <string> 21 #include <vector> 22 #include <utility> 23 24 #include "drawing.h" 25 #include "rosen_text/symbol_animation_config.h" 26 27 namespace OHOS::Rosen::SPText { 28 class TextAnimationConfig { 29 public: 30 ~TextAnimationConfig() = default; 31 32 TextAnimationConfig() = default; 33 34 void SetUniqueId(uint64_t uniqueId); 35 36 void SetEffectConfig(const std::vector<std::vector<Drawing::DrawingPiecewiseParameter>>& parameters); 37 38 void SetColor(const RSColor& color); 39 40 bool DrawTextEffect(RSCanvas* canvas, const std::vector<TextEngine::TextEffectElement>& effectElements); 41 42 void SetAnimationStart(bool animationStart); 43 44 void SetEffectStrategy(RSEffectStrategy effectStrategy); 45 46 void SetAnimation( 47 const std::function<bool(const std::shared_ptr<OHOS::Rosen::TextEngine::SymbolAnimationConfig>&)>& 48 animationFunc); 49 50 void AnimationUnchange(bool isUnchange); 51 52 void ClearAllTextAnimation(); 53 54 private: 55 std::function<bool(const std::shared_ptr<OHOS::Rosen::TextEngine::SymbolAnimationConfig>&)> 56 animationFunc_ = nullptr; 57 58 uint64_t uniqueId_ = 0; 59 RSColor color_; 60 bool animationStart_ = false; 61 std::vector<std::vector<Drawing::DrawingPiecewiseParameter>> parameters_; 62 RSEffectStrategy effectStrategy_ = RSEffectStrategy::NONE; 63 bool currentAnimationHasPlayed_ = false; 64 65 void ClearTextAnimation(uint64_t uniqueId); 66 67 bool TextAnimationRun(const std::vector<TextEngine::TextEffectElement>& effectElements); 68 69 void OnDrawTextEffect(RSCanvas* canvas, const std::vector<TextEngine::TextEffectElement>& effectElements); 70 }; 71 } 72 #endif