Bug 180008 - Use more Uint8ClampedArray& and constness in filter and image buffer code
Summary: Use more Uint8ClampedArray& and constness in filter and image buffer code
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-24 14:26 PST by Simon Fraser (smfr)
Modified: 2017-11-26 15:14 PST (History)
11 users (show)

See Also:


Attachments
Patch (99.50 KB, patch)
2017-11-24 14:27 PST, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews103 for mac-elcapitan (2.12 MB, application/zip)
2017-11-24 15:25 PST, EWS Watchlist
no flags Details
Archive of layout-test-results from ews104 for mac-elcapitan-wk2 (2.53 MB, application/zip)
2017-11-24 15:36 PST, EWS Watchlist
no flags Details
Archive of layout-test-results from ews123 for ios-simulator-wk2 (2.11 MB, application/zip)
2017-11-24 15:51 PST, EWS Watchlist
no flags Details
Archive of layout-test-results from ews112 for mac-elcapitan (3.33 MB, application/zip)
2017-11-24 16:03 PST, EWS Watchlist
no flags Details
Patch (104.00 KB, patch)
2017-11-24 22:25 PST, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff
Patch (104.00 KB, patch)
2017-11-24 23:10 PST, Simon Fraser (smfr)
darin: review+
Details | Formatted Diff | Diff
Patch (103.57 KB, patch)
2017-11-26 08:46 PST, Simon Fraser (smfr)
no flags 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-24 14:26:01 PST
Use more Uint8ClampedArray& and constness in filter and image buffer code
Comment 1 Simon Fraser (smfr) 2017-11-24 14:27:19 PST
Created attachment 327557 [details]
Patch
Comment 2 EWS Watchlist 2017-11-24 14:29:44 PST
Attachment 327557 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp:400:  Declaration has space between type name and * in m_bias * 255  [whitespace/declaration] [3]
Total errors found: 1 in 32 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 EWS Watchlist 2017-11-24 15:25:51 PST
Comment on attachment 327557 [details]
Patch

Attachment 327557 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/5352446

New failing tests:
css3/filters/filter-on-overflow-hidden.html
Comment 4 EWS Watchlist 2017-11-24 15:25:52 PST
Created attachment 327558 [details]
Archive of layout-test-results from ews103 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews103  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 5 EWS Watchlist 2017-11-24 15:36:54 PST
Comment on attachment 327557 [details]
Patch

Attachment 327557 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/5352458

New failing tests:
css3/filters/filter-on-overflow-hidden.html
Comment 6 EWS Watchlist 2017-11-24 15:36:55 PST
Created attachment 327559 [details]
Archive of layout-test-results from ews104 for mac-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews104  Port: mac-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 7 EWS Watchlist 2017-11-24 15:51:42 PST
Comment on attachment 327557 [details]
Patch

Attachment 327557 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/5352475

New failing tests:
css3/filters/filter-on-overflow-hidden.html
Comment 8 EWS Watchlist 2017-11-24 15:51:44 PST
Created attachment 327560 [details]
Archive of layout-test-results from ews123 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews123  Port: ios-simulator-wk2  Platform: Mac OS X 10.12.6
Comment 9 EWS Watchlist 2017-11-24 16:03:47 PST
Comment on attachment 327557 [details]
Patch

Attachment 327557 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/5352513

New failing tests:
css3/filters/effect-reference-hw.html
css3/filters/effect-reference-ordering-hw.html
css3/filters/filter-on-overflow-hidden.html
css3/filters/effect-reference.html
svg/filters/feGaussianBlur.svg
svg/filters/feGaussianBlur-zero-deviation.svg
css3/filters/effect-reference-ordering.html
Comment 10 EWS Watchlist 2017-11-24 16:03:48 PST
Created attachment 327561 [details]
Archive of layout-test-results from ews112 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews112  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 11 Simon Fraser (smfr) 2017-11-24 22:25:13 PST
Created attachment 327571 [details]
Patch
Comment 12 EWS Watchlist 2017-11-24 22:28:19 PST
Attachment 327571 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp:400:  Declaration has space between type name and * in m_bias * 255  [whitespace/declaration] [3]
Total errors found: 1 in 36 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 13 Simon Fraser (smfr) 2017-11-24 23:10:55 PST
Created attachment 327572 [details]
Patch
Comment 14 EWS Watchlist 2017-11-24 23:12:14 PST
Attachment 327572 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp:400:  Declaration has space between type name and * in m_bias * 255  [whitespace/declaration] [3]
Total errors found: 1 in 36 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 15 Darin Adler 2017-11-25 11:15:55 PST
Comment on attachment 327572 [details]
Patch

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

I probably would have used auto in  quite a few places instead of writing out types

> Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp:485
> +            RetainPtr<CGContextRef> sourceContext = adoptCF(CGBitmapContextCreate(reinterpret_cast<void*>(const_cast<uint8_t*>(srcRows)), width.unsafeGet(), height.unsafeGet(), 8, srcBytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast));

The reinterpret_cast should not be needed here: the const_cast alone should be sufficient, because we can pass a uint8_t* as a void* without a cast.

> Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp:494
> +            srcRows = const_cast<const uint8_t*>(destRows);

A const_cast should not be needed to add const, only to remove it. We should be able to assign to a variable of type const uint8_t* with uint8_t* without a cast.

> Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp:542
> +        src.data = reinterpret_cast<void*>(const_cast<uint8_t*>(srcRows));

The reinterpret_cast should not be needed here: the const_cast alone should be sufficient, because we can pass assign to a void* with a uint8_t* without a cast.

> Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp:571
> +            srcRows = const_cast<const uint8_t*>(destRows);

A const_cast should not be needed to add const, only to remove it. We should be able to assign to a variable of type const uint8_t* with uint8_t* without a cast.

> Source/WebCore/platform/graphics/cpu/arm/filters/FECompositeArithmeticNEON.h:47
> +    const uint32_t* sourcePixel = reinterpret_cast<uint32_t*>(source);

I believe this won’t compile unless we change the type inside reinterpret_cast to "const uint32_t*", not just the type of the local.
Comment 16 Simon Fraser (smfr) 2017-11-26 08:46:01 PST
Created attachment 327585 [details]
Patch
Comment 17 EWS Watchlist 2017-11-26 08:47:33 PST
Attachment 327585 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp:400:  Declaration has space between type name and * in m_bias * 255  [whitespace/declaration] [3]
Total errors found: 1 in 36 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 18 WebKit Commit Bot 2017-11-26 12:03:06 PST
Comment on attachment 327585 [details]
Patch

Clearing flags on attachment: 327585

Committed r225147: <https://trac.webkit.org/changeset/225147>
Comment 19 Radar WebKit Bug Importer 2017-11-26 15:14:29 PST
<rdar://problem/35690466>