Title: [234433] trunk/Source/WebCore
- Revision
- 234433
- Author
- [email protected]
- Date
- 2018-07-31 11:37:18 -0700 (Tue, 31 Jul 2018)
Log Message
Clean up TransformationMatrix implementation
https://bugs.webkit.org/show_bug.cgi?id=188197
Reviewed by Simon Fraser.
We perform cleaning up of TransformationMatrix.
1. We drop user-defined operator= and copy constructor. Default ones works well for TransformationMatrix.
2. Remove unused setMatrix. We explicitly use memcpy in TransformationMatrix.cpp (only one place).
3. Use memcmp for implementing operator==.
In (2) and (3), we use `memcpy(&matrix[0][0], &tmp[0][0], sizeof(Matrix4))` instead of `memcpy(matrix, tmp, sizeof(Matrix4))`,
since they both are non nullptr and the former is easier to understand.
* platform/graphics/transforms/TransformationMatrix.cpp:
(WebCore::TransformationMatrix::multiply):
* platform/graphics/transforms/TransformationMatrix.h:
(WebCore::TransformationMatrix::setMatrix):
(WebCore::TransformationMatrix::operator== const):
(WebCore::TransformationMatrix::operator =): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (234432 => 234433)
--- trunk/Source/WebCore/ChangeLog 2018-07-31 18:23:36 UTC (rev 234432)
+++ trunk/Source/WebCore/ChangeLog 2018-07-31 18:37:18 UTC (rev 234433)
@@ -1,3 +1,26 @@
+2018-07-31 Yusuke Suzuki <[email protected]>
+
+ Clean up TransformationMatrix implementation
+ https://bugs.webkit.org/show_bug.cgi?id=188197
+
+ Reviewed by Simon Fraser.
+
+ We perform cleaning up of TransformationMatrix.
+
+ 1. We drop user-defined operator= and copy constructor. Default ones works well for TransformationMatrix.
+ 2. Remove unused setMatrix. We explicitly use memcpy in TransformationMatrix.cpp (only one place).
+ 3. Use memcmp for implementing operator==.
+
+ In (2) and (3), we use `memcpy(&matrix[0][0], &tmp[0][0], sizeof(Matrix4))` instead of `memcpy(matrix, tmp, sizeof(Matrix4))`,
+ since they both are non nullptr and the former is easier to understand.
+
+ * platform/graphics/transforms/TransformationMatrix.cpp:
+ (WebCore::TransformationMatrix::multiply):
+ * platform/graphics/transforms/TransformationMatrix.h:
+ (WebCore::TransformationMatrix::setMatrix):
+ (WebCore::TransformationMatrix::operator== const):
+ (WebCore::TransformationMatrix::operator =): Deleted.
+
2018-07-31 Timothy Hatcher <[email protected]>
Don't call RenderTheme::platformColorsDidChange() during printing.
Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp (234432 => 234433)
--- trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp 2018-07-31 18:23:36 UTC (rev 234432)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp 2018-07-31 18:37:18 UTC (rev 234433)
@@ -1416,7 +1416,7 @@
tmp[3][3] = (mat.m_matrix[3][0] * m_matrix[0][3] + mat.m_matrix[3][1] * m_matrix[1][3]
+ mat.m_matrix[3][2] * m_matrix[2][3] + mat.m_matrix[3][3] * m_matrix[3][3]);
- setMatrix(tmp);
+ memcpy(&m_matrix[0][0], &tmp[0][0], sizeof(Matrix4));
#endif
return *this;
}
Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h (234432 => 234433)
--- trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h 2018-07-31 18:23:36 UTC (rev 234432)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h 2018-07-31 18:37:18 UTC (rev 234433)
@@ -116,7 +116,6 @@
{
}
- TransformationMatrix(const TransformationMatrix& t) { *this = t; }
WEBCORE_EXPORT TransformationMatrix(const AffineTransform&);
void setMatrix(double a, double b, double c, double d, double e, double f)
@@ -137,12 +136,6 @@
m_matrix[2][0] = m31; m_matrix[2][1] = m32; m_matrix[2][2] = m33; m_matrix[2][3] = m34;
m_matrix[3][0] = m41; m_matrix[3][1] = m42; m_matrix[3][2] = m43; m_matrix[3][3] = m44;
}
-
- TransformationMatrix& operator =(const TransformationMatrix &t)
- {
- setMatrix(t.m_matrix);
- return *this;
- }
TransformationMatrix& makeIdentity()
{
@@ -342,22 +335,7 @@
bool operator==(const TransformationMatrix& m2) const
{
- return (m_matrix[0][0] == m2.m_matrix[0][0] &&
- m_matrix[0][1] == m2.m_matrix[0][1] &&
- m_matrix[0][2] == m2.m_matrix[0][2] &&
- m_matrix[0][3] == m2.m_matrix[0][3] &&
- m_matrix[1][0] == m2.m_matrix[1][0] &&
- m_matrix[1][1] == m2.m_matrix[1][1] &&
- m_matrix[1][2] == m2.m_matrix[1][2] &&
- m_matrix[1][3] == m2.m_matrix[1][3] &&
- m_matrix[2][0] == m2.m_matrix[2][0] &&
- m_matrix[2][1] == m2.m_matrix[2][1] &&
- m_matrix[2][2] == m2.m_matrix[2][2] &&
- m_matrix[2][3] == m2.m_matrix[2][3] &&
- m_matrix[3][0] == m2.m_matrix[3][0] &&
- m_matrix[3][1] == m2.m_matrix[3][1] &&
- m_matrix[3][2] == m2.m_matrix[3][2] &&
- m_matrix[3][3] == m2.m_matrix[3][3]);
+ return memcmp(&m_matrix[0][0], &m2.m_matrix[0][0], sizeof(Matrix4)) == 0;
}
bool operator!=(const TransformationMatrix& other) const { return !(*this == other); }
@@ -439,12 +417,6 @@
return FloatPoint3D(static_cast<float>(resultX), static_cast<float>(resultY), static_cast<float>(resultZ));
}
- void setMatrix(const Matrix4 m)
- {
- if (m && m != m_matrix)
- memcpy(m_matrix, m, sizeof(Matrix4));
- }
-
Matrix4 m_matrix;
};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes