Bug 179952 - FEComponentTransfer cleanup and optimization
Summary: FEComponentTransfer cleanup and optimization
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: Simon Fraser (smfr)
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-11-22 11:06 PST by Simon Fraser (smfr)
Modified: 2017-11-22 22:49 PST (History)
6 users (show)

See Also:


Attachments
Patch (11.98 KB, patch)
2017-11-22 11:11 PST, Simon Fraser (smfr)
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Fraser (smfr) 2017-11-22 11:06:18 PST
FEComponentTransfer cleanup and optimization
Comment 1 Simon Fraser (smfr) 2017-11-22 11:11:04 PST
Created attachment 327462 [details]
Patch
Comment 2 EWS Watchlist 2017-11-22 11:13:43 PST
Attachment 327462 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp:173:  One space before end of line comments  [whitespace/comments] [5]
ERROR: Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp:174:  One space before end of line comments  [whitespace/comments] [5]
ERROR: Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp:175:  One space before end of line comments  [whitespace/comments] [5]
ERROR: Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp:176:  One space before end of line comments  [whitespace/comments] [5]
ERROR: Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp:177:  One space before end of line comments  [whitespace/comments] [5]
ERROR: Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp:178:  One space before end of line comments  [whitespace/comments] [5]
ERROR: Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp:181:  Please replace ASSERT_WITH_SECURITY_IMPLICATION() with RELEASE_ASSERT_WITH_SECURITY_IMPLICATION().  [security/assertion] [5]
ERROR: Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp:182:  Please replace ASSERT_WITH_SECURITY_IMPLICATION() with RELEASE_ASSERT_WITH_SECURITY_IMPLICATION().  [security/assertion] [5]
ERROR: Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp:183:  Please replace ASSERT_WITH_SECURITY_IMPLICATION() with RELEASE_ASSERT_WITH_SECURITY_IMPLICATION().  [security/assertion] [5]
ERROR: Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp:184:  Please replace ASSERT_WITH_SECURITY_IMPLICATION() with RELEASE_ASSERT_WITH_SECURITY_IMPLICATION().  [security/assertion] [5]
Total errors found: 10 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Darin Adler 2017-11-22 11:23:56 PST
Comment on attachment 327462 [details]
Patch

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

Not a huge fan of all the abbreviations here. I would say m_redFunction instead m_redFunc, and redTable instead of rTable, etc.

> Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp:73
> +void FEComponentTransfer::computeIdentityTable(FEComponentTransfer::LookupTable, const ComponentTransferFunction&)

Can just call it LookupTable because this is inside the declaration of a FEComponentTransfer member function.

> Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp:150
> +        unsigned char c = data[pixelOffset];
> +        data[pixelOffset] = rTable[c];

auto or uint8_t or do it in single lines without local variables so we don’t need all the comments:

    data[pixelOffset] = rTable[data[pixelOffset]];
    data[pixelOffset + 1] = gTable[data[pixelOffset + 1]];
    data[pixelOffset + 2] = bTable[data[pixelOffset + 2]];
    data[pixelOffset + 3] = aTable[data[pixelOffset + 3]];

> Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp:171
> +    typedef void (*TransferType)(LookupTable, const ComponentTransferFunction&);

We are using "using" these days:

    using TransferType = void (*)(LookupTable, const ComponentTransferFunction&);

> Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp:186
> +    (*callEffect[m_redFunc.type])(rValues, m_redFunc);

I don’t think the (*x) is needed. Should just be able to call:

    callEffect[m_redFunc.type](rValues, m_redFunc);

> Source/WebCore/platform/graphics/filters/FEComponentTransfer.h:76
> +    typedef uint8_t LookupTable[lookupTableSize];

Better to use using. But even better to use std::array so the strangeness of C arrays doesn’t affect us so much. Then when you want to modify the table you have to pass LookupTable& instead. And you can call size() instead of having a separate constant.

    using LookupTable = std::array<uint8_t, 256>;

> Source/WebCore/platform/graphics/filters/FEComponentTransfer.h:78
> +    static void computeIdentityTable(FEComponentTransfer::LookupTable, const ComponentTransferFunction&);

Same here, no need to write FEComponentTransfer:: prefix.
Comment 4 Simon Fraser (smfr) 2017-11-22 22:48:25 PST
https://trac.webkit.org/changeset/225107/webkit
Comment 5 Radar WebKit Bug Importer 2017-11-22 22:49:23 PST
<rdar://problem/35672813>