Bug 215994 - Optimize the implementation of TransformationMatrix::rotate(double)
Summary: Optimize the implementation of TransformationMatrix::rotate(double)
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Wenson Hsieh
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-08-30 16:26 PDT by Wenson Hsieh
Modified: 2020-08-31 08:16 PDT (History)
4 users (show)

See Also:


Attachments
For EWS (4.33 KB, patch)
2020-08-30 16:37 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wenson Hsieh 2020-08-30 16:26:02 PDT
TransformationMatrix::rotate(angle) currently just calls TransformationMatrix::rotate3d(0, 0, 1, angle), which has a fast path for the case where we're rotating about the z-axis. However, we should be able to make this *slightly* faster by omitting the hypotenuse computation, several floating point comparisons, and several assignments.
Comment 1 Wenson Hsieh 2020-08-30 16:37:21 PDT
Created attachment 407580 [details]
For EWS
Comment 2 Tim Horton 2020-08-30 18:44:12 PDT
Comment on attachment 407580 [details]
For EWS

View in context: https://bugs.webkit.org/attachment.cgi?id=407580&action=review

> Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp:905
> +    multiply({ cosZ, sinZ, -sinZ, cosZ, 0, 0 });

I assume something extends this with the 1s in the diagonals to preserve the other columns?
Comment 3 Wenson Hsieh 2020-08-30 21:14:10 PDT
Comment on attachment 407580 [details]
For EWS

View in context: https://bugs.webkit.org/attachment.cgi?id=407580&action=review

>> Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp:905
>> +    multiply({ cosZ, sinZ, -sinZ, cosZ, 0, 0 });
> 
> I assume something extends this with the 1s in the diagonals to preserve the other columns?

Indeed — this uses the a, b, c, d, e, f constructor for TransformationMatrix, which ensures that the last two values along the diagonal are 1:

    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 },
        }
    {
    }
Comment 4 EWS 2020-08-31 08:15:04 PDT
Committed r266353: <https://trac.webkit.org/changeset/266353>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 407580 [details].
Comment 5 Radar WebKit Bug Importer 2020-08-31 08:16:19 PDT
<rdar://problem/68076663>