From 61bb4fba3e80a317bf8025176c9f4c8e232e2d5a Mon Sep 17 00:00:00 2001 From: "sub.mohanty@samsung.com" Date: Sat, 28 Jul 2018 17:29:58 +0900 Subject: [PATCH] lottie/vector: Remove the hack with mutable data member. NOTE: if you need to modify the object in a const member function make the data as mutable. Change-Id: I28b2cc18d75433475f75b048af878297747980db --- src/vector/vmatrix.cpp | 18 ++++++++---------- src/vector/vmatrix.h | 4 ++-- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/vector/vmatrix.cpp b/src/vector/vmatrix.cpp index 412877d..688b273 100644 --- a/src/vector/vmatrix.cpp +++ b/src/vector/vmatrix.cpp @@ -80,11 +80,10 @@ VMatrix::MatrixType VMatrix::type() const if(dirty == MatrixType::None || dirty < mType) return mType; - VMatrix::MatrixType newType; switch (dirty) { case MatrixType::Project: if (!vIsZero(m13) || !vIsZero(m23) || !vIsZero(m33 - 1)) { - newType = MatrixType::Project; + mType = MatrixType::Project; break; } case MatrixType::Shear: @@ -92,29 +91,28 @@ VMatrix::MatrixType VMatrix::type() const if (!vIsZero(m12) || !vIsZero(m21)) { const float dot = m11 * m12 + m21 * m22; if (vIsZero(dot)) - newType = MatrixType::Rotate; + mType = MatrixType::Rotate; else - newType = MatrixType::Shear; + mType = MatrixType::Shear; break; } case MatrixType::Scale: if (!vIsZero(m11 - 1) || !vIsZero(m22 - 1)) { - newType = MatrixType::Scale; + mType = MatrixType::Scale; break; } case MatrixType::Translate: if (!vIsZero(mtx) || !vIsZero(mty)) { - newType = MatrixType::Translate; + mType = MatrixType::Translate; break; } case MatrixType::None: - newType = MatrixType::None; + mType = MatrixType::None; break; } - const_cast(this)->dirty = MatrixType::None; - const_cast(this)->mType = newType; - return newType; + dirty = MatrixType::None; + return mType; } diff --git a/src/vector/vmatrix.h b/src/vector/vmatrix.h index 4c3be7c..20e5e98 100644 --- a/src/vector/vmatrix.h +++ b/src/vector/vmatrix.h @@ -59,8 +59,8 @@ public: friend std::ostream& operator<<(std::ostream& os, const VMatrix& o); private: friend struct VSpanData; - MatrixType mType{MatrixType::None}; - MatrixType dirty{MatrixType::None}; + mutable MatrixType mType{MatrixType::None}; + mutable MatrixType dirty{MatrixType::None}; float m11{1}, m12{0}, m13{0}; float m21{0}, m22{1}, m23{0}; float mtx{0}, mty{0}, m33{1}; -- 2.34.1