From d8dc16d7300c99a8f4e949a66c854473a33ffab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E9=92=B0=E8=83=9C?= Date: Sat, 11 Jan 2025 14:20:29 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=96=B0=E5=A2=9ESingleHandTransform?= =?UTF-8?q?=E7=B1=BB=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 白钰胜 --- interfaces/innerkits/wm/wm_common.h | 59 +++++++++++++++++++++++++++++ previewer/include/wm_common.h | 59 +++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index c685e0029e..ebc83c66fb 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -699,6 +699,65 @@ private: } }; +/** + * @class SingleHandTransform + * + * @brief parameter of transform in single hand mode. + */ +class SingleHandTransform { +public: + SingleHandTransform() : posX_(0), posY_(0), scaleX_(1.0f), scaleY_(1.0f) {} + ~SingleHandTransform() {} + + bool operator==(const SingleHandTransform& right) const + { + return NearZero(posX_ - right.posX_) && + NearZero(posY_ - right.posY_) && + NearZero(scaleX_ - right.scaleX_) && + NearZero(scaleY_ - right.scaleY_); + } + + bool operator!=(const SingleHandTransform& right) const + { + return !(*this == right); + } + + int32_t posX_; + int32_t posY_; + float scaleX_; + float scaleY_; + + static const SingleHandTransform& Identity() + { + static SingleHandTransform I; + return I; + } + + bool Marshalling(Parcel& parcel) const + { + return parcel.WriteInt32(posX_) && parcel.WriteInt32(posY_) && + parcel.WriteFloat(scaleX_) && parcel.WriteFloat(scaleY_); + } + + void Unmarshalling(Parcel& parcel) + { + posX_ = parcel.ReadInt32(); + posY_ = parcel.ReadInt32(); + scaleX_ = parcel.ReadFloat(); + scaleY_ = parcel.ReadFloat(); + } + +private: + static inline bool NearZero(float val) + { + return val < 0.001f && val > -0.001f; + } + static inline bool NearZero(int32_t val) + { + return val == 0; + } +}; + /** * @struct SystemBarProperty * diff --git a/previewer/include/wm_common.h b/previewer/include/wm_common.h index 42a6f43a59..2b7dc53733 100644 --- a/previewer/include/wm_common.h +++ b/previewer/include/wm_common.h @@ -498,6 +498,65 @@ private: } }; +/** + * @class SingleHandTransform + * + * @brief parameter of transform in single hand mode. + */ +class SingleHandTransform { +public: + SingleHandTransform() : posX_(0), posY_(0), scaleX_(1.0f), scaleY_(1.0f) {} + ~SingleHandTransform() {} + + bool operator==(const SingleHandTransform& right) const + { + return NearZero(posX_ - right.posX_) && + NearZero(posY_ - right.posY_) && + NearZero(scaleX_ - right.scaleX_) && + NearZero(scaleY_ - right.scaleY_); + } + + bool operator!=(const SingleHandTransform& right) const + { + return !(*this == right); + } + + int32_t posX_; + int32_t posY_; + float scaleX_; + float scaleY_; + + static const SingleHandTransform& Identity() + { + static SingleHandTransform I; + return I; + } + + bool Marshalling(Parcel& parcel) const + { + return parcel.WriteInt32(posX_) && parcel.WriteInt32(posY_) && + parcel.WriteFloat(scaleX_) && parcel.WriteFloat(scaleY_); + } + + void Unmarshalling(Parcel& parcel) + { + posX_ = parcel.ReadInt32(); + posY_ = parcel.ReadInt32(); + scaleX_ = parcel.ReadFloat(); + scaleY_ = parcel.ReadFloat(); + } + +private: + static inline bool NearZero(float val) + { + return val < 0.001f && val > -0.001f; + } + static inline bool NearZero(int32_t val) + { + return val == 0; + } +}; + /** * @struct RectAnimationConfig * -- Gitee From 0ca3e1f49f1e698e136132f6d9dd15b6beac0e6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E9=92=B0=E8=83=9C?= Date: Sat, 11 Jan 2025 16:08:56 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E7=9B=B8=E7=AD=89=E7=9A=84=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 白钰胜 --- interfaces/innerkits/wm/wm_common.h | 17 +++++++++-------- previewer/include/wm_common.h | 17 +++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index ebc83c66fb..4e7c0fba02 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -711,10 +711,10 @@ public: bool operator==(const SingleHandTransform& right) const { - return NearZero(posX_ - right.posX_) && - NearZero(posY_ - right.posY_) && - NearZero(scaleX_ - right.scaleX_) && - NearZero(scaleY_ - right.scaleY_); + return NearEqual(posX_, right.posX_) && + NearEqual(posY_, right.posY_) && + NearEqual(scaleX_, right.scaleX_) && + NearEqual(scaleY_, right.scaleY_); } bool operator!=(const SingleHandTransform& right) const @@ -748,13 +748,14 @@ public: } private: - static inline bool NearZero(float val) + static inline bool NearEqual(float left, float right) { - return val < 0.001f && val > -0.001f; + return abs(left - right) < 0.001f; } - static inline bool NearZero(int32_t val) + + static inline bool NearEqual(int32_t left, int32_t right) { - return val == 0; + return left == right; } }; diff --git a/previewer/include/wm_common.h b/previewer/include/wm_common.h index 2b7dc53733..36c56527b9 100644 --- a/previewer/include/wm_common.h +++ b/previewer/include/wm_common.h @@ -510,10 +510,10 @@ public: bool operator==(const SingleHandTransform& right) const { - return NearZero(posX_ - right.posX_) && - NearZero(posY_ - right.posY_) && - NearZero(scaleX_ - right.scaleX_) && - NearZero(scaleY_ - right.scaleY_); + return NearEqual(posX_, right.posX_) && + NearEqual(posY_, right.posY_) && + NearEqual(scaleX_, right.scaleX_) && + NearEqual(scaleY_, right.scaleY_); } bool operator!=(const SingleHandTransform& right) const @@ -547,13 +547,14 @@ public: } private: - static inline bool NearZero(float val) + static inline bool NearEqual(float left, float right) { - return val < 0.001f && val > -0.001f; + return abs(left - right) < 0.001f; } - static inline bool NearZero(int32_t val) + + static inline bool NearEqual(int32_t left, int32_t right) { - return val == 0; + return left == right; } }; -- Gitee From cbd1596efeb9fe13ea8a8e6dca30ac7b93f1265e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E9=92=B0=E8=83=9C?= Date: Sat, 11 Jan 2025 18:02:21 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E5=B0=86class=E4=BF=AE=E6=94=B9=E6=88=90st?= =?UTF-8?q?ruct?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 白钰胜 --- interfaces/innerkits/wm/wm_common.h | 36 ++++++++++++++--------------- previewer/include/wm_common.h | 36 ++++++++++++++--------------- 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index 4e7c0fba02..83c1e60f87 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -700,21 +700,19 @@ private: }; /** - * @class SingleHandTransform + * @struct SingleHandTransform * * @brief parameter of transform in single hand mode. */ -class SingleHandTransform { -public: - SingleHandTransform() : posX_(0), posY_(0), scaleX_(1.0f), scaleY_(1.0f) {} - ~SingleHandTransform() {} +struct SingleHandTransform { + SingleHandTransform() : posX(0), posY(0), scaleX(1.0f), scaleY(1.0f) {} bool operator==(const SingleHandTransform& right) const { - return NearEqual(posX_, right.posX_) && - NearEqual(posY_, right.posY_) && - NearEqual(scaleX_, right.scaleX_) && - NearEqual(scaleY_, right.scaleY_); + return NearEqual(posX, right.posX) && + NearEqual(posY, right.posY) && + NearEqual(scaleX, right.scaleX) && + NearEqual(scaleY, right.scaleY); } bool operator!=(const SingleHandTransform& right) const @@ -722,10 +720,10 @@ public: return !(*this == right); } - int32_t posX_; - int32_t posY_; - float scaleX_; - float scaleY_; + int32_t posX; + int32_t posY; + float scaleX; + float scaleY; static const SingleHandTransform& Identity() { @@ -735,16 +733,16 @@ public: bool Marshalling(Parcel& parcel) const { - return parcel.WriteInt32(posX_) && parcel.WriteInt32(posY_) && - parcel.WriteFloat(scaleX_) && parcel.WriteFloat(scaleY_); + return parcel.WriteInt32(posX) && parcel.WriteInt32(posY) && + parcel.WriteFloat(scaleX) && parcel.WriteFloat(scaleY); } void Unmarshalling(Parcel& parcel) { - posX_ = parcel.ReadInt32(); - posY_ = parcel.ReadInt32(); - scaleX_ = parcel.ReadFloat(); - scaleY_ = parcel.ReadFloat(); + posX = parcel.ReadInt32(); + posY = parcel.ReadInt32(); + scaleX = parcel.ReadFloat(); + scaleY = parcel.ReadFloat(); } private: diff --git a/previewer/include/wm_common.h b/previewer/include/wm_common.h index 36c56527b9..8a7b373c30 100644 --- a/previewer/include/wm_common.h +++ b/previewer/include/wm_common.h @@ -499,21 +499,19 @@ private: }; /** - * @class SingleHandTransform + * @struct SingleHandTransform * * @brief parameter of transform in single hand mode. */ -class SingleHandTransform { -public: - SingleHandTransform() : posX_(0), posY_(0), scaleX_(1.0f), scaleY_(1.0f) {} - ~SingleHandTransform() {} +struct SingleHandTransform { + SingleHandTransform() : posX(0), posY(0), scaleX(1.0f), scaleY(1.0f) {} bool operator==(const SingleHandTransform& right) const { - return NearEqual(posX_, right.posX_) && - NearEqual(posY_, right.posY_) && - NearEqual(scaleX_, right.scaleX_) && - NearEqual(scaleY_, right.scaleY_); + return NearEqual(posX, right.posX) && + NearEqual(posY, right.posY) && + NearEqual(scaleX, right.scaleX) && + NearEqual(scaleY, right.scaleY); } bool operator!=(const SingleHandTransform& right) const @@ -521,10 +519,10 @@ public: return !(*this == right); } - int32_t posX_; - int32_t posY_; - float scaleX_; - float scaleY_; + int32_t posX; + int32_t posY; + float scaleX; + float scaleY; static const SingleHandTransform& Identity() { @@ -534,16 +532,16 @@ public: bool Marshalling(Parcel& parcel) const { - return parcel.WriteInt32(posX_) && parcel.WriteInt32(posY_) && - parcel.WriteFloat(scaleX_) && parcel.WriteFloat(scaleY_); + return parcel.WriteInt32(posX) && parcel.WriteInt32(posY) && + parcel.WriteFloat(scaleX) && parcel.WriteFloat(scaleY); } void Unmarshalling(Parcel& parcel) { - posX_ = parcel.ReadInt32(); - posY_ = parcel.ReadInt32(); - scaleX_ = parcel.ReadFloat(); - scaleY_ = parcel.ReadFloat(); + posX = parcel.ReadInt32(); + posY = parcel.ReadInt32(); + scaleX = parcel.ReadFloat(); + scaleY = parcel.ReadFloat(); } private: -- Gitee From a401c7ad55e18eedf5e600cab058b815ee1a93d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E9=92=B0=E8=83=9C?= Date: Mon, 13 Jan 2025 11:58:20 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E5=B0=86NearEqual=E6=8A=BD=E5=88=B0?= =?UTF-8?q?=E5=85=AC=E5=85=B1=E9=83=A8=E5=88=86MathHelper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 白钰胜 --- interfaces/innerkits/wm/wm_common.h | 29 ++++++++--------------------- previewer/include/wm_common.h | 29 ++++++++--------------------- utils/include/wm_math.h | 10 ++++++++++ 3 files changed, 26 insertions(+), 42 deletions(-) diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index 83c1e60f87..a9b3d05531 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -705,14 +705,12 @@ private: * @brief parameter of transform in single hand mode. */ struct SingleHandTransform { - SingleHandTransform() : posX(0), posY(0), scaleX(1.0f), scaleY(1.0f) {} - bool operator==(const SingleHandTransform& right) const { - return NearEqual(posX, right.posX) && - NearEqual(posY, right.posY) && - NearEqual(scaleX, right.scaleX) && - NearEqual(scaleY, right.scaleY); + return MathHelper::NearEqual(posX, right.posX) && + MathHelper::NearEqual(posY, right.posY) && + MathHelper::NearEqual(scaleX, right.scaleX) && + MathHelper::NearEqual(scaleY, right.scaleY); } bool operator!=(const SingleHandTransform& right) const @@ -720,10 +718,10 @@ struct SingleHandTransform { return !(*this == right); } - int32_t posX; - int32_t posY; - float scaleX; - float scaleY; + int32_t posX = 0; + int32_t posY = 0; + float scaleX = 0; + float scaleY = 0; static const SingleHandTransform& Identity() { @@ -744,17 +742,6 @@ struct SingleHandTransform { scaleX = parcel.ReadFloat(); scaleY = parcel.ReadFloat(); } - -private: - static inline bool NearEqual(float left, float right) - { - return abs(left - right) < 0.001f; - } - - static inline bool NearEqual(int32_t left, int32_t right) - { - return left == right; - } }; /** diff --git a/previewer/include/wm_common.h b/previewer/include/wm_common.h index 8a7b373c30..ab8b436de5 100644 --- a/previewer/include/wm_common.h +++ b/previewer/include/wm_common.h @@ -504,14 +504,12 @@ private: * @brief parameter of transform in single hand mode. */ struct SingleHandTransform { - SingleHandTransform() : posX(0), posY(0), scaleX(1.0f), scaleY(1.0f) {} - bool operator==(const SingleHandTransform& right) const { - return NearEqual(posX, right.posX) && - NearEqual(posY, right.posY) && - NearEqual(scaleX, right.scaleX) && - NearEqual(scaleY, right.scaleY); + return MathHelper::NearEqual(posX, right.posX) && + MathHelper::NearEqual(posY, right.posY) && + MathHelper::NearEqual(scaleX, right.scaleX) && + MathHelper::NearEqual(scaleY, right.scaleY); } bool operator!=(const SingleHandTransform& right) const @@ -519,10 +517,10 @@ struct SingleHandTransform { return !(*this == right); } - int32_t posX; - int32_t posY; - float scaleX; - float scaleY; + int32_t posX = 0; + int32_t posY = 0; + float scaleX = 0; + float scaleY = 0; static const SingleHandTransform& Identity() { @@ -543,17 +541,6 @@ struct SingleHandTransform { scaleX = parcel.ReadFloat(); scaleY = parcel.ReadFloat(); } - -private: - static inline bool NearEqual(float left, float right) - { - return abs(left - right) < 0.001f; - } - - static inline bool NearEqual(int32_t left, int32_t right) - { - return left == right; - } }; /** diff --git a/utils/include/wm_math.h b/utils/include/wm_math.h index 0fbe679872..40ab03fe6b 100644 --- a/utils/include/wm_math.h +++ b/utils/include/wm_math.h @@ -32,6 +32,16 @@ inline bool NearZero(float val) return val < POS_ZERO && val > NAG_ZERO; } +inline bool NearEqual(float left, float right) +{ + return abs(left - right) < POS_ZERO; +} + +inline bool NearEqual(int32_t left, int32_t right) +{ + return left == right; +} + inline float ToRadians(float degrees) { return degrees * PI / 180.0f; -- Gitee From bbc90225fa971150b45b485d96eefd884b6cd43d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E9=92=B0=E8=83=9C?= Date: Mon, 13 Jan 2025 12:08:55 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E7=BC=A9=E5=87=8Finline=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E8=A1=8C=E6=95=B0=EF=BC=8C=E5=8E=BB=E6=8E=89int=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=9A=84NearEqual?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 白钰胜 --- interfaces/innerkits/wm/wm_common.h | 6 ++---- previewer/include/wm_common.h | 6 ++---- utils/include/wm_math.h | 10 +--------- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index a9b3d05531..d94f2ea544 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -707,10 +707,8 @@ private: struct SingleHandTransform { bool operator==(const SingleHandTransform& right) const { - return MathHelper::NearEqual(posX, right.posX) && - MathHelper::NearEqual(posY, right.posY) && - MathHelper::NearEqual(scaleX, right.scaleX) && - MathHelper::NearEqual(scaleY, right.scaleY); + return posX == right.posX && MathHelper::NearEqual(scaleX, right.scaleX) && + posY == right.posY && MathHelper::NearEqual(scaleY, right.scaleY); } bool operator!=(const SingleHandTransform& right) const diff --git a/previewer/include/wm_common.h b/previewer/include/wm_common.h index ab8b436de5..7f7c750a02 100644 --- a/previewer/include/wm_common.h +++ b/previewer/include/wm_common.h @@ -506,10 +506,8 @@ private: struct SingleHandTransform { bool operator==(const SingleHandTransform& right) const { - return MathHelper::NearEqual(posX, right.posX) && - MathHelper::NearEqual(posY, right.posY) && - MathHelper::NearEqual(scaleX, right.scaleX) && - MathHelper::NearEqual(scaleY, right.scaleY); + return posX == right.posX && MathHelper::NearEqual(scaleX, right.scaleX) && + posY == right.posY && MathHelper::NearEqual(scaleY, right.scaleY); } bool operator!=(const SingleHandTransform& right) const diff --git a/utils/include/wm_math.h b/utils/include/wm_math.h index 40ab03fe6b..c00ca60def 100644 --- a/utils/include/wm_math.h +++ b/utils/include/wm_math.h @@ -32,15 +32,7 @@ inline bool NearZero(float val) return val < POS_ZERO && val > NAG_ZERO; } -inline bool NearEqual(float left, float right) -{ - return abs(left - right) < POS_ZERO; -} - -inline bool NearEqual(int32_t left, int32_t right) -{ - return left == right; -} +inline bool NearEqual(float left, float right) { return abs(left - right) < POS_ZERO; } inline float ToRadians(float degrees) { -- Gitee From 8fdfffed474265d6c4a5215dc5fde7167a11432d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E9=92=B0=E8=83=9C?= Date: Mon, 13 Jan 2025 14:20:27 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E5=BC=95=E5=85=A5=E5=A4=B4=E6=96=87?= =?UTF-8?q?=E4=BB=B6wm=5Fmath.h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 白钰胜 --- interfaces/innerkits/wm/wm_common.h | 1 + previewer/include/wm_common.h | 1 + 2 files changed, 2 insertions(+) diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index d94f2ea544..69460d4cab 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -27,6 +27,7 @@ #include "../dm/dm_common.h" #include "securec.h" +#include "wm_math.h" namespace OHOS { namespace Rosen { diff --git a/previewer/include/wm_common.h b/previewer/include/wm_common.h index 7f7c750a02..cd3d9fd2de 100644 --- a/previewer/include/wm_common.h +++ b/previewer/include/wm_common.h @@ -25,6 +25,7 @@ #include #include "dm_common.h" #include "securec.h" +#include "wm_math.h" namespace OHOS { namespace Rosen { -- Gitee From 1de9bc4d52e0130aff7657ab374e023c4caddcd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E9=92=B0=E8=83=9C?= Date: Mon, 13 Jan 2025 14:25:59 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E5=88=A0=E6=8E=89=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E7=9A=84Identity=EF=BC=8C=E5=B9=B6=E5=B0=86=E6=88=90=E5=91=98?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E6=94=BE=E5=88=B0=E7=BB=93=E6=9E=84=E4=BD=93?= =?UTF-8?q?=E6=9C=80=E5=BC=80=E5=A7=8B=E7=9A=84=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 白钰胜 --- interfaces/innerkits/wm/wm_common.h | 16 +++++----------- previewer/include/wm_common.h | 16 +++++----------- utils/include/wm_math.h | 2 +- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index 69460d4cab..c3549d1fc1 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -706,6 +706,11 @@ private: * @brief parameter of transform in single hand mode. */ struct SingleHandTransform { + int32_t posX = 0; + int32_t posY = 0; + float scaleX = 0; + float scaleY = 0; + bool operator==(const SingleHandTransform& right) const { return posX == right.posX && MathHelper::NearEqual(scaleX, right.scaleX) && @@ -717,17 +722,6 @@ struct SingleHandTransform { return !(*this == right); } - int32_t posX = 0; - int32_t posY = 0; - float scaleX = 0; - float scaleY = 0; - - static const SingleHandTransform& Identity() - { - static SingleHandTransform I; - return I; - } - bool Marshalling(Parcel& parcel) const { return parcel.WriteInt32(posX) && parcel.WriteInt32(posY) && diff --git a/previewer/include/wm_common.h b/previewer/include/wm_common.h index cd3d9fd2de..e02c48eb86 100644 --- a/previewer/include/wm_common.h +++ b/previewer/include/wm_common.h @@ -505,6 +505,11 @@ private: * @brief parameter of transform in single hand mode. */ struct SingleHandTransform { + int32_t posX = 0; + int32_t posY = 0; + float scaleX = 0; + float scaleY = 0; + bool operator==(const SingleHandTransform& right) const { return posX == right.posX && MathHelper::NearEqual(scaleX, right.scaleX) && @@ -516,17 +521,6 @@ struct SingleHandTransform { return !(*this == right); } - int32_t posX = 0; - int32_t posY = 0; - float scaleX = 0; - float scaleY = 0; - - static const SingleHandTransform& Identity() - { - static SingleHandTransform I; - return I; - } - bool Marshalling(Parcel& parcel) const { return parcel.WriteInt32(posX) && parcel.WriteInt32(posY) && diff --git a/utils/include/wm_math.h b/utils/include/wm_math.h index c00ca60def..3226aac208 100644 --- a/utils/include/wm_math.h +++ b/utils/include/wm_math.h @@ -32,7 +32,7 @@ inline bool NearZero(float val) return val < POS_ZERO && val > NAG_ZERO; } -inline bool NearEqual(float left, float right) { return abs(left - right) < POS_ZERO; } +inline bool NearEqual(float left, float right) { return std::abs(left - right) < POS_ZERO; } inline float ToRadians(float degrees) { -- Gitee From 1326e9ac0c71a45bcb0cd5a16535933a0917c9cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E9=92=B0=E8=83=9C?= Date: Mon, 13 Jan 2025 17:32:53 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=BC=96=E8=AF=91=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 白钰胜 --- previewer/include/wm_common.h | 38 ----------------------------------- 1 file changed, 38 deletions(-) diff --git a/previewer/include/wm_common.h b/previewer/include/wm_common.h index e02c48eb86..42a6f43a59 100644 --- a/previewer/include/wm_common.h +++ b/previewer/include/wm_common.h @@ -25,7 +25,6 @@ #include #include "dm_common.h" #include "securec.h" -#include "wm_math.h" namespace OHOS { namespace Rosen { @@ -499,43 +498,6 @@ private: } }; -/** - * @struct SingleHandTransform - * - * @brief parameter of transform in single hand mode. - */ -struct SingleHandTransform { - int32_t posX = 0; - int32_t posY = 0; - float scaleX = 0; - float scaleY = 0; - - bool operator==(const SingleHandTransform& right) const - { - return posX == right.posX && MathHelper::NearEqual(scaleX, right.scaleX) && - posY == right.posY && MathHelper::NearEqual(scaleY, right.scaleY); - } - - bool operator!=(const SingleHandTransform& right) const - { - return !(*this == right); - } - - bool Marshalling(Parcel& parcel) const - { - return parcel.WriteInt32(posX) && parcel.WriteInt32(posY) && - parcel.WriteFloat(scaleX) && parcel.WriteFloat(scaleY); - } - - void Unmarshalling(Parcel& parcel) - { - posX = parcel.ReadInt32(); - posY = parcel.ReadInt32(); - scaleX = parcel.ReadFloat(); - scaleY = parcel.ReadFloat(); - } -}; - /** * @struct RectAnimationConfig * -- Gitee