Bug 226916 - [CG] Create a sub-image when drawing an image only if the destination image will be enlarged, rotated or sheared
Summary: [CG] Create a sub-image when drawing an image only if the destination image w...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Images (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Said Abou-Hallawa
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-06-11 01:39 PDT by Said Abou-Hallawa
Modified: 2021-07-02 15:07 PDT (History)
7 users (show)

See Also:


Attachments
Patch (7.00 KB, patch)
2021-06-11 01:44 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (15.02 KB, patch)
2021-06-13 02:08 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (15.11 KB, patch)
2021-06-13 19:56 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (16.59 KB, patch)
2021-06-13 23:45 PDT, Said Abou-Hallawa
simon.fraser: review+
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch for landing (16.17 KB, patch)
2021-06-14 19:30 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Said Abou-Hallawa 2021-06-11 01:39:18 PDT
Creating a sub-image using CGImageCreateWithImageInRect() is expensive. But the cost of its creation will be worthy, if it is referenced multiple times. So we should postpone creating and caching the sub-image until it is referenced twice.
Comment 1 Said Abou-Hallawa 2021-06-11 01:39:58 PDT
<rdar://71712144>
Comment 2 Said Abou-Hallawa 2021-06-11 01:44:05 PDT
Created attachment 431184 [details]
Patch
Comment 3 Said Abou-Hallawa 2021-06-13 02:08:15 PDT
Created attachment 431271 [details]
Patch
Comment 4 Said Abou-Hallawa 2021-06-13 19:56:12 PDT
Created attachment 431298 [details]
Patch
Comment 5 Said Abou-Hallawa 2021-06-13 23:45:20 PDT
Created attachment 431303 [details]
Patch
Comment 6 Said Abou-Hallawa 2021-06-13 23:49:50 PDT
This patch fixes the following:
1. The perf problem in the emoji dropdown of twitter.com editor because no sub-images are created to display the emoji images.
2. The perf problem in the http://www.antutu.com/html5/collision.html because sub-images are created to display the rotated balls.
3. The display of the canvas in the layout test: fast/canvas/drawImage-with-negative-source-destination.html which has been broken for sometime.
Comment 7 Simon Fraser (smfr) 2021-06-14 14:39:32 PDT
Comment on attachment 431303 [details]
Patch

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

> Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp:230
> +static inline bool shouldUseSubimage(CGInterpolationQuality interpolationQuality, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform& transform)

This could be a lambda function.

> Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp:241
> +static inline RetainPtr<CGImageRef> getSubimage(CGImageRef image, const FloatSize& imageSize, const FloatRect& subimageRect, const ImagePaintingOptions& options)

This could be a lambda function.

> Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp:259
> +static inline FloatSize imageLogicalSize(CGImageRef image, const ImagePaintingOptions& options)

This could be a lambda function.
Comment 8 Said Abou-Hallawa 2021-06-14 19:30:06 PDT
Created attachment 431396 [details]
Patch for landing
Comment 9 EWS 2021-06-15 00:40:51 PDT
Committed r278863 (238807@main): <https://commits.webkit.org/238807@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 431396 [details].