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.
<rdar://71712144>
Created attachment 431184 [details] Patch
Created attachment 431271 [details] Patch
Created attachment 431298 [details] Patch
Created attachment 431303 [details] Patch
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 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.
Created attachment 431396 [details] Patch for landing
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].