RESOLVED FIXED 188195
Use static const global variable for TransformationMatrix instead of NeverDestroyed
https://bugs.webkit.org/show_bug.cgi?id=188195
Summary Use static const global variable for TransformationMatrix instead of NeverDes...
Yusuke Suzuki
Reported 2018-07-31 08:40:55 PDT
Use static const global variable for TransformationMatrix instead of NeverDestroyed
Attachments
Patch (4.94 KB, patch)
2018-07-31 08:42 PDT, Yusuke Suzuki
no flags
Patch (5.01 KB, patch)
2018-07-31 08:47 PDT, Yusuke Suzuki
no flags
Patch (5.00 KB, patch)
2018-07-31 08:50 PDT, Yusuke Suzuki
darin: review+
Yusuke Suzuki
Comment 1 2018-07-31 08:42:50 PDT
Yusuke Suzuki
Comment 2 2018-07-31 08:47:05 PDT
Yusuke Suzuki
Comment 3 2018-07-31 08:50:51 PDT
Darin Adler
Comment 4 2018-07-31 09:11:23 PDT
Comment on attachment 346169 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=346169&action=review > Source/WebCore/platform/graphics/GraphicsLayer.cpp:295 > +static const TransformationMatrix identityTransform { }; The braces here are OK, but not needed. > Source/WebCore/platform/graphics/transforms/TransformationMatrix.h:119 > + TransformationMatrix(const TransformationMatrix& t) { *this = t; } I know this is just showing up in the patch because of changes the other other nearby functions, but why is this needed? Isn’t this what the compiler will generate if we don’t write a copy constructor explicitly? Same question about the assignment operator below. Or maybe we do need to define these explicitly but can use "= default".
Yusuke Suzuki
Comment 5 2018-07-31 09:30:51 PDT
Comment on attachment 346169 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=346169&action=review >> Source/WebCore/platform/graphics/GraphicsLayer.cpp:295 >> +static const TransformationMatrix identityTransform { }; > > The braces here are OK, but not needed. Personally, I would like to have this here since it makes explicit that this is a definition :). >> Source/WebCore/platform/graphics/transforms/TransformationMatrix.h:119 >> + TransformationMatrix(const TransformationMatrix& t) { *this = t; } > > I know this is just showing up in the patch because of changes the other other nearby functions, but why is this needed? Isn’t this what the compiler will generate if we don’t write a copy constructor explicitly? Same question about the assignment operator below. Or maybe we do need to define these explicitly but can use "= default". In this patch, I keep these things. TransformationMatrix::operator= is different from the default operator: it first checks `*this != other`, and memcpy if the above condition is true. I'm not sure this check before copying is important... I think it is rather costly. But in the meantime, I would like to keep this patch simple by not having operator=/copy constructor changes. I'll open a bug to remove operator=/copy constructor separately.
Yusuke Suzuki
Comment 6 2018-07-31 09:31:54 PDT
Radar WebKit Bug Importer
Comment 7 2018-07-31 09:32:48 PDT
Yusuke Suzuki
Comment 8 2018-07-31 09:47:53 PDT
Comment on attachment 346169 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=346169&action=review >>> Source/WebCore/platform/graphics/transforms/TransformationMatrix.h:119 >>> + TransformationMatrix(const TransformationMatrix& t) { *this = t; } >> >> I know this is just showing up in the patch because of changes the other other nearby functions, but why is this needed? Isn’t this what the compiler will generate if we don’t write a copy constructor explicitly? Same question about the assignment operator below. Or maybe we do need to define these explicitly but can use "= default". > > In this patch, I keep these things. TransformationMatrix::operator= is different from the default operator: it first checks `*this != other`, and memcpy if the above condition is true. > I'm not sure this check before copying is important... I think it is rather costly. But in the meantime, I would like to keep this patch simple by not having operator=/copy constructor changes. > I'll open a bug to remove operator=/copy constructor separately. Ah, no. setMatrix's `if (m && m != m_matrix)` is pointer check since m is a C array. default copy constructor just works as expected.
Simon Fraser (smfr)
Comment 9 2018-07-31 11:32:34 PDT
Comment on attachment 346169 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=346169&action=review >>> Source/WebCore/platform/graphics/GraphicsLayer.cpp:295 >>> +static const TransformationMatrix identityTransform { }; >> >> The braces here are OK, but not needed. > > Personally, I would like to have this here since it makes explicit that this is a definition :). Can TransformationMatrix.h just export a static const TransformationMatrix identityTransform?
Yusuke Suzuki
Comment 10 2018-07-31 12:38:22 PDT
Comment on attachment 346169 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=346169&action=review >>>> Source/WebCore/platform/graphics/GraphicsLayer.cpp:295 >>>> +static const TransformationMatrix identityTransform { }; >>> >>> The braces here are OK, but not needed. >> >> Personally, I would like to have this here since it makes explicit that this is a definition :). > > Can TransformationMatrix.h just export a static const TransformationMatrix identityTransform? That sounds nice. I'll try this.
Note You need to log in before you can comment on or make changes to this bug.