Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 72c98dc7d00b14e390e83ba0b7723d69c6357bf8
      
https://github.com/WebKit/WebKit/commit/72c98dc7d00b14e390e83ba0b7723d69c6357bf8
  Author: Simon Fraser <[email protected]>
  Date:   2024-02-15 (Thu, 15 Feb 2024)

  Changed paths:
    M Source/WebCore/platform/graphics/ImageBuffer.h
    M Source/WebKit/SourcesCocoa.txt
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/AsyncPDFRenderer.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/AsyncPDFRenderer.mm
    A Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFPageCoverage.h
    A Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFPageCoverage.mm
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm

  Log Message:
  -----------
  [UnifiedPDF] Paint PDF content off the main thread
https://bugs.webkit.org/show_bug.cgi?id=269505
rdar://119632313

Reviewed by Tim Horton.

Enable AsyncPDFRenderer which paints PDF tiles off the main thread. The one 
line at
`asyncRenderer()->setupWithLayer(*m_contentsLayer)` creates the 
AsyncPDFRenderer, and the
rest of the code is conditional on it being non-null.

There are various sources of complexity in managing the cache of tiles, and 
painting them
correctly. First, the TiledBackingClient callbacks are all in terms of tile 
coordinates,
which are independent of the page scale factor that we push onto 
m_contentsLayer (since
TiledBacking has a behavior of mapping back to screen space to create the 
tiles, so they are
always 512x512 in screen space). This complexity is handled by
`convertTileRectToPaintingCoords()` and `tileToPaintingTransform()`. When 
comparing clips
etc we have to take care to map into the right coordinate systems.

Second, we have to not paint tiles that were generated earlier when the scale 
was different,
so AsyncPDFRenderer uses a `ObjectIdentifier<PDFConfiguration>` to track 
configurations, and
throws away tiles if the configuration changed while they were painting; this 
is necessary
to avoid lots of issues when resizing.

Painting the cached tiles themselves is done inside the per-page painting loop; 
this is
necessary to clip out pages for which `shouldDisplayPage()` is false, in 
non-continuous
scrolling modes. This is not ideal, because we have (per-tile * per-page * 
per-cached tile)
runtime performance, which will need optimizing.

* Source/WebCore/platform/graphics/ImageBuffer.h:
* Source/WebKit/SourcesCocoa.txt:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/AsyncPDFRenderer.h:
(WebKit::AsyncPDFRenderer::paintingWorkQueue const): Deleted.
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/AsyncPDFRenderer.mm:
(WebKit::AsyncPDFRenderer::AsyncPDFRenderer):
(WebKit::AsyncPDFRenderer::~AsyncPDFRenderer):
(WebKit::AsyncPDFRenderer::teardown):
(WebKit::AsyncPDFRenderer::setShowDebugBorders):
(WebKit::AsyncPDFRenderer::willRepaintTile):
(WebKit::AsyncPDFRenderer::willRemoveTile):
(WebKit::AsyncPDFRenderer::willRepaintAllTiles):
(WebKit::AsyncPDFRenderer::layoutConfigurationChanged):
(WebKit::AsyncPDFRenderer::clearRequestsAndCachedTiles):
(WebKit::AsyncPDFRenderer::tileToPaintingTransform):
(WebKit::AsyncPDFRenderer::convertTileRectToPaintingCoords):
(WebKit::AsyncPDFRenderer::enqueuePaintWithClip):
(WebKit::AsyncPDFRenderer::paintTileOnWorkQueue):
(WebKit::AsyncPDFRenderer::paintPDFIntoBuffer):
(WebKit::AsyncPDFRenderer::transferBufferToMainThread):
(WebKit::AsyncPDFRenderer::paintTilesForPaintingRect):
(WebKit::operator<<):
(WebKit::AsyncPDFRenderer::clearCachedTiles): Deleted.
(WebKit::AsyncPDFRenderer::paintTileForClip): Deleted.
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFPageCoverage.h: Added.
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFPageCoverage.mm: Added.
(WebKit::operator<<):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::teardown):
(WebKit::UnifiedPDFPlugin::asyncRenderer):
(WebKit::UnifiedPDFPlugin::asyncRendererIfExists const):
(WebKit::UnifiedPDFPlugin::ensureLayers):
(WebKit::UnifiedPDFPlugin::updateLayerHierarchy):
(WebKit::UnifiedPDFPlugin::shouldShowDebugIndicators const):
(WebKit::UnifiedPDFPlugin::didChangeSettings):
(WebKit::UnifiedPDFPlugin::pageCoverageForRect const):
(WebKit::UnifiedPDFPlugin::paintPDFContent):
(WebKit::UnifiedPDFPlugin::setPageScaleFactor):

Canonical link: https://commits.webkit.org/274802@main


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to