Log Message
Use static const global variable for TransformationMatrix instead of NeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=188195
Reviewed by Darin Adler. Since TransformationMatrix does not have a non-trivial destructor, we can put it as static const global variable if its constructor is constexpr. This patch makes some of constructors constexpr and makes identityTransform static const global variable instead of NeverDestroyed<> + static function. This removes unnecessary static function and lazy initialization. No behavior change. * platform/graphics/GraphicsLayer.cpp: (WebCore::GraphicsLayer::transform const): (WebCore::GraphicsLayer::childrenTransform const): (WebCore::identityTransform): Deleted. * platform/graphics/transforms/TransformationMatrix.h: (WebCore::TransformationMatrix::TransformationMatrix):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (234426 => 234427)
--- trunk/Source/WebCore/ChangeLog 2018-07-31 15:57:10 UTC (rev 234426)
+++ trunk/Source/WebCore/ChangeLog 2018-07-31 16:31:47 UTC (rev 234427)
@@ -1,3 +1,25 @@
+2018-07-31 Yusuke Suzuki <[email protected]>
+
+ Use static const global variable for TransformationMatrix instead of NeverDestroyed
+ https://bugs.webkit.org/show_bug.cgi?id=188195
+
+ Reviewed by Darin Adler.
+
+ Since TransformationMatrix does not have a non-trivial destructor, we can put it
+ as static const global variable if its constructor is constexpr. This patch makes
+ some of constructors constexpr and makes identityTransform static const global variable
+ instead of NeverDestroyed<> + static function. This removes unnecessary static function
+ and lazy initialization.
+
+ No behavior change.
+
+ * platform/graphics/GraphicsLayer.cpp:
+ (WebCore::GraphicsLayer::transform const):
+ (WebCore::GraphicsLayer::childrenTransform const):
+ (WebCore::identityTransform): Deleted.
+ * platform/graphics/transforms/TransformationMatrix.h:
+ (WebCore::TransformationMatrix::TransformationMatrix):
+
2018-07-31 Zalan Bujtas <[email protected]>
[LFC][Floating] Add basic left/right floating positioning.
Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp (234426 => 234427)
--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp 2018-07-31 15:57:10 UTC (rev 234426)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp 2018-07-31 16:31:47 UTC (rev 234427)
@@ -292,15 +292,11 @@
}
}
-static const TransformationMatrix& identityTransform()
-{
- static NeverDestroyed<TransformationMatrix> identityTransform;
- return identityTransform;
-}
+static const TransformationMatrix identityTransform { };
const TransformationMatrix& GraphicsLayer::transform() const
{
- return m_transform ? *m_transform : identityTransform();
+ return m_transform ? *m_transform : identityTransform;
}
void GraphicsLayer::setTransform(const TransformationMatrix& matrix)
@@ -313,7 +309,7 @@
const TransformationMatrix& GraphicsLayer::childrenTransform() const
{
- return m_childrenTransform ? *m_childrenTransform : identityTransform();
+ return m_childrenTransform ? *m_childrenTransform : identityTransform;
}
void GraphicsLayer::setChildrenTransform(const TransformationMatrix& matrix)
Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h (234426 => 234427)
--- trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h 2018-07-31 15:57:10 UTC (rev 234426)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h 2018-07-31 16:31:47 UTC (rev 234427)
@@ -82,18 +82,43 @@
typedef double Matrix4[4][4];
#endif
- TransformationMatrix() { makeIdentity(); }
- WEBCORE_EXPORT TransformationMatrix(const AffineTransform&);
- TransformationMatrix(const TransformationMatrix& t) { *this = t; }
- TransformationMatrix(double a, double b, double c, double d, double e, double f) { setMatrix(a, b, c, d, e, f); }
- TransformationMatrix(double m11, double m12, double m13, double m14,
- double m21, double m22, double m23, double m24,
- double m31, double m32, double m33, double m34,
- double m41, double m42, double m43, double m44)
+ constexpr TransformationMatrix()
+ : m_matrix {
+ { 1, 0, 0, 0 },
+ { 0, 1, 0, 0 },
+ { 0, 0, 1, 0 },
+ { 0, 0, 0, 1 },
+ }
{
- setMatrix(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44);
}
+ constexpr TransformationMatrix(double a, double b, double c, double d, double e, double f)
+ : m_matrix {
+ { a, b, 0, 0 },
+ { c, d, 0, 0 },
+ { 0, 0, 1, 0 },
+ { e, f, 0, 1 },
+ }
+ {
+ }
+
+ constexpr TransformationMatrix(
+ double m11, double m12, double m13, double m14,
+ double m21, double m22, double m23, double m24,
+ double m31, double m32, double m33, double m34,
+ double m41, double m42, double m43, double m44)
+ : m_matrix {
+ { m11, m12, m13, m14 },
+ { m21, m22, m23, m24 },
+ { m31, m32, m33, m34 },
+ { m41, m42, m43, m44 },
+ }
+ {
+ }
+
+ 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)
{
m_matrix[0][0] = a; m_matrix[0][1] = b; m_matrix[0][2] = 0; m_matrix[0][3] = 0;
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
