Bug 215015 - [CG] Avoid creating a sub-image when drawing a small scaled sub-rect from a native image
Summary: [CG] Avoid creating a sub-image when drawing a small scaled sub-rect from a n...
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: 2020-07-31 02:18 PDT by Said Abou-Hallawa
Modified: 2020-08-06 14:02 PDT (History)
2 users (show)

See Also:


Attachments
Patch (2.48 KB, patch)
2020-07-31 02:28 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (10.48 KB, patch)
2020-08-03 01:10 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (10.77 KB, patch)
2020-08-03 12:06 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (2.69 KB, patch)
2020-08-06 12:15 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 2020-07-31 02:18:55 PDT
The reason for creating the sub-image in GraphicsContext::drawNativeImage() is to have a better image interpolation for the scaled sub-rect. For small destRect, the interpolation on the original image is almost the same as the interpolation on the sub-image. So we should avoid creating the sub-image if destRect.area() is less than some minimum value. This will benefit the case of drawing many small rectangles from a large sprite image.
Comment 1 Said Abou-Hallawa 2020-07-31 02:19:47 PDT
<rdar://problem/63845893>
Comment 2 Said Abou-Hallawa 2020-07-31 02:28:38 PDT
Created attachment 405677 [details]
Patch
Comment 3 Simon Fraser (smfr) 2020-07-31 08:58:35 PDT
Does the subimage cache come into play here? Does turning it off change behavior?
Comment 4 Said Abou-Hallawa 2020-08-03 01:10:05 PDT
Created attachment 405817 [details]
Patch
Comment 5 Said Abou-Hallawa 2020-08-03 12:06:35 PDT
Created attachment 405853 [details]
Patch
Comment 6 Said Abou-Hallawa 2020-08-03 12:19:25 PDT
(In reply to Simon Fraser (smfr) from comment #3)
> Does the subimage cache come into play here? Does turning it off change
> behavior?

No not really. Subimage cache requires creating the sub images also. So the cost of caching these images is added when the sub-image is rendered for the first time.

For example, a page creates a picker element when it is first needed. When the picker element is popped up, its layer is rendered and the children elements are rendered for the first time. At this time the rendering might be slow if many sub-images are created. 

When the user selects an element from the picker or dismisses it, the picker element is hidden. If the user invokes an action which pops the picker up again, no rendering will be needed. All we need is showing the picker's layer. So caching and non caching the sub-images will not affect the rendering speed after the first time the sub-images are rendered.
Comment 7 Said Abou-Hallawa 2020-08-06 12:15:50 PDT
Created attachment 406099 [details]
Patch
Comment 8 EWS 2020-08-06 14:02:18 PDT
Committed r265346: <https://trac.webkit.org/changeset/265346>

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