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_ANIMATION_RS_ANIMATION_TRACE_UTILS_H 17 #define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_TRACE_UTILS_H 18 19 #include "animation/rs_animation_common.h" 20 #include "animation/rs_render_property_animation.h" 21 #include "common/rs_color.h" 22 #include "common/rs_common_def.h" 23 #include "modifier/rs_render_property.h" 24 25 26 namespace OHOS { 27 namespace Rosen { 28 class RSB_EXPORT RSAnimationTraceUtils { 29 public: GetInstance()30 static RSAnimationTraceUtils& GetInstance() 31 { 32 static RSAnimationTraceUtils instance; 33 return instance; 34 }; 35 void AddAnimationNameTrace(const std::string& str) const; 36 void AddAnimationFinishTrace( 37 const std::string info, const uint64_t nodeId, const uint64_t animationId, bool isAddLogInfo) const; 38 39 void AddAnimationCallFinishTrace(const uint64_t nodeId, const uint64_t animationId, 40 ModifierNG::RSPropertyType propertyType, bool isAddLogInfo) const; 41 42 void AddAnimationCreateTrace(const uint64_t nodeId, const std::string& nodeName, const uint64_t propertyId, 43 const uint64_t animationId, const ImplicitAnimationParamType animationType, 44 const ModifierNG::RSPropertyType propertyType, const std::shared_ptr<RSRenderPropertyBase>& startValue, 45 const std::shared_ptr<RSRenderPropertyBase>& endValue, const int animationDelay, const int animationDur, 46 const int repeat, const std::string& interfaceName, const int32_t frameNodeId, const std::string& frameNodeTag, 47 RSUINodeType nodeType) const; 48 49 void AddAnimationFrameTrace(const RSRenderNode* target, const uint64_t nodeId, const std::string& nodeName, 50 const uint64_t animationId, const uint64_t propertyId, const float fraction, 51 const std::shared_ptr<RSRenderPropertyBase>& value, const int64_t time, const int dur, const int repeat) const; 52 53 void AddSpringInitialVelocityTrace(const uint64_t propertyId, const uint64_t animationId, 54 const std::shared_ptr<RSRenderPropertyBase>& initialVelocity, 55 const std::shared_ptr<RSRenderPropertyBase>& value) const; 56 57 std::string ParseRenderPropertyValue(const std::shared_ptr<RSRenderPropertyBase>& value) const; 58 59 void AddAnimationCancelTrace(const uint64_t nodeId, const uint64_t propertyId) const; 60 void AddChangeAnimationValueTrace( 61 const uint64_t propertyId, const std::shared_ptr<RSRenderPropertyBase>& endValue) const; 62 63 private: 64 RSAnimationTraceUtils(); 65 ~RSAnimationTraceUtils() = default; 66 RSAnimationTraceUtils(const RSAnimationTraceUtils&) = delete; 67 RSAnimationTraceUtils& operator=(const RSAnimationTraceUtils&) = delete; 68 69 std::string ParseRenderPropertyValueInner(const std::shared_ptr<RSRenderPropertyBase>& value) const; 70 71 std::string GetColorString(const Color& value) const; 72 73 static void OnAnimationTraceEnabledChangedCallback(const char* key, const char* value, void* context); 74 std::string GetAnimationTypeString(ImplicitAnimationParamType type) const; 75 std::string GetNodeTypeString(RSUINodeType type) const; 76 77 static bool isDebugEnabled_; 78 }; 79 } // namespace Rosen 80 } // namespace OHOS 81 82 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_TRACE_UTILS_H