1 /* 2 * Copyright (c) 2022-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_ANIMATABLE_ARITHMETIC_H 17 #define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATABLE_ARITHMETIC_H 18 19 #include <memory> 20 21 #include "common/rs_color.h" 22 #include "common/rs_macros.h" 23 #include "common/rs_matrix3.h" 24 #include "common/rs_vector2.h" 25 #include "common/rs_vector4.h" 26 #include "render/rs_filter.h" 27 28 namespace OHOS { 29 namespace Rosen { 30 template<typename T> 31 class RSB_EXPORT RSArithmetic { 32 public: 33 RSArithmetic() = default; 34 virtual ~RSArithmetic() = default; 35 36 virtual bool IsEqual(const T& value) const = 0; 37 38 bool operator==(const T& value) const 39 { 40 return IsEqual(value); 41 } 42 43 bool operator!=(const T& value) const 44 { 45 return !IsEqual(value); 46 } 47 }; 48 49 template<typename T> 50 class RSB_EXPORT RSAnimatableArithmetic : public RSArithmetic<T> { 51 public: 52 RSAnimatableArithmetic() = default; 53 virtual ~RSAnimatableArithmetic() = default; 54 55 virtual T Add(const T& value) const = 0; 56 virtual T Minus(const T& value) const = 0; 57 virtual T Multiply(const float scale) const = 0; 58 59 T operator+(const T& value) const 60 { 61 return Add(value); 62 } 63 T operator+=(const T& value) const 64 { 65 return Add(value); 66 } 67 T operator-(const T& value) const 68 { 69 return Minus(value); 70 } 71 T operator-=(const T& value) const 72 { 73 return Minus(value); 74 } 75 T operator*(const float scale) const 76 { 77 return Multiply(scale); 78 } 79 T operator*=(const float scale) const 80 { 81 return Multiply(scale); 82 } 83 }; 84 } // namespace Rosen 85 } // namespace OHOS 86 87 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATABLE_ARITHMETIC_H 88