Bug 188195 - Use static const global variable for TransformationMatrix instead of NeverDestroyed
Summary: Use static const global variable for TransformationMatrix instead of NeverDes...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-07-31 08:40 PDT by Yusuke Suzuki
Modified: 2018-07-31 12:38 PDT (History)
6 users (show)

See Also:


Attachments
Patch (4.94 KB, patch)
2018-07-31 08:42 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (5.01 KB, patch)
2018-07-31 08:47 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (5.00 KB, patch)
2018-07-31 08:50 PDT, Yusuke Suzuki
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2018-07-31 08:40:55 PDT
Use static const global variable for TransformationMatrix instead of NeverDestroyed
Comment 1 Yusuke Suzuki 2018-07-31 08:42:50 PDT
Created attachment 346167 [details]
Patch
Comment 2 Yusuke Suzuki 2018-07-31 08:47:05 PDT
Created attachment 346168 [details]
Patch
Comment 3 Yusuke Suzuki 2018-07-31 08:50:51 PDT
Created attachment 346169 [details]
Patch
Comment 4 Darin Adler 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".
Comment 5 Yusuke Suzuki 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.
Comment 6 Yusuke Suzuki 2018-07-31 09:31:54 PDT
Committed r234427: <https://trac.webkit.org/changeset/234427>
Comment 7 Radar WebKit Bug Importer 2018-07-31 09:32:48 PDT
<rdar://problem/42774823>
Comment 8 Yusuke Suzuki 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.
Comment 9 Simon Fraser (smfr) 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?
Comment 10 Yusuke Suzuki 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.