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
This commit is contained in:
sub.mohanty@samsung.com 2018-07-28 17:29:58 +09:00
parent e6bce26b6e
commit 61bb4fba3e
2 changed files with 10 additions and 12 deletions

View 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;
}

View 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};