lottie/vector: Remove the hack with mutable data member. 51/185351/1
authorsub.mohanty@samsung.com <smohantty@gmail.com>
Sat, 28 Jul 2018 08:29:58 +0000 (17:29 +0900)
committersub.mohanty@samsung.com <smohantty@gmail.com>
Sat, 28 Jul 2018 08:29:58 +0000 (17:29 +0900)
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
src/vector/vmatrix.h

index 412877d..688b273 100644 (file)
@@ -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<VMatrix *>(this)->dirty = MatrixType::None;
-    const_cast<VMatrix *>(this)->mType = newType;
-    return newType;
+    dirty = MatrixType::None;
+    return mType;
 }
 
 
index 4c3be7c..20e5e98 100644 (file)
@@ -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};