• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_BASE_MODIFIER_RS_ANIMATABLE_ARITHMETIC_H
17 #define RENDER_SERVICE_BASE_MODIFIER_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 
27 namespace OHOS {
28 namespace Rosen {
29 template<typename T>
30 class RSB_EXPORT RSArithmetic {
31 public:
32     RSArithmetic() = default;
33     virtual ~RSArithmetic() = default;
34 
35     virtual bool IsEqual(const T& value) const = 0;
36 
37     bool operator==(const T& value) const
38     {
39         return IsEqual(value);
40     }
41 
42     bool operator!=(const T& value) const
43     {
44         return !IsEqual(value);
45     }
46 };
47 
48 template<typename T>
49 class RSB_EXPORT RSAnimatableArithmetic : public RSArithmetic<T> {
50 public:
51     RSAnimatableArithmetic() = default;
52     virtual ~RSAnimatableArithmetic() = default;
53 
54     virtual T Add(const T& value) const = 0;
55     virtual T Minus(const T& value) const = 0;
56     virtual T Multiply(const float scale) const = 0;
57 
58     T operator+(const T& value) const
59     {
60         return Add(value);
61     }
62     T operator+=(const T& value) const
63     {
64         return Add(value);
65     }
66     T operator-(const T& value) const
67     {
68         return Minus(value);
69     }
70     T operator-=(const T& value) const
71     {
72         return Minus(value);
73     }
74     T operator*(const float scale) const
75     {
76         return Multiply(scale);
77     }
78     T operator*=(const float scale) const
79     {
80         return Multiply(scale);
81     }
82 };
83 } // namespace Rosen
84 } // namespace OHOS
85 
86 #endif // RENDER_SERVICE_BASE_MODIFIER_RS_ANIMATABLE_ARITHMETIC_H
87