Drawing a sub-rectangle of PDFDocumentImage can be expensive because the whole image has to be displayed. PDFDocumentImage tries to cache a viewport of the last source displayed rectangle. The viewport is a bigger rectangle which includes the source rectangle. The goal of caching the viewport is to reuse it as many times as possible and not to draw the image itself. The calculations and the transformation to create, draw and reuse the viewport is very complex and fragile. The solution is to clean up this code by introducing a new class called ImageViewport. This class will be responsible of creating a viewport ImageBuffer, drawing the source rectangle of the image to the viewport ImageBuffer and drawing this buffer to the destination GraphicsContext. The calculations can be simplified such that the resolution of the viewport ImageBuffer matches the effective resolution of the destination GraphicsContext.
rdar://97254192
Pull request: https://github.com/WebKit/WebKit/pull/4700
Committed 259928@main (8382d4d3c6e3): <https://commits.webkit.org/259928@main> Reviewed commits have been landed. Closing PR #4700 and removing active labels.