[webkit-changes] [WebKit/WebKit] c71e10: [UnifiedPDF] PDF flickers/flashes while zooming

Simon Fraser noreply at github.com
Wed Mar 20 16:55:06 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c71e10996782481c1c4e50483cade26d81e001f6
      https://github.com/WebKit/WebKit/commit/c71e10996782481c1c4e50483cade26d81e001f6
  Author: Simon Fraser <simon.fraser at apple.com>
  Date:   2024-03-20 (Wed, 20 Mar 2024)

  Changed paths:
    M Source/WebCore/platform/graphics/GraphicsLayerClient.h
    M Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/AsyncPDFRenderer.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/AsyncPDFRenderer.mm
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm
    M Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.mm

  Log Message:
  -----------
  [UnifiedPDF] PDF flickers/flashes while zooming
https://bugs.webkit.org/show_bug.cgi?id=271292
rdar://122884598

Reviewed by Tim Horton.

Change the way we paint the low-resolution page backgrounds so that they reliably appear behind
the PDF tiles when zooming.

Previously, the page previews were only painted in `AsyncPDFRenderer::paintTilesForPage()` if
we'd painted no cached tiles. However, there was no guarantee that the entire rect was covered
in cached tile paints, and "leakage" of repaint rects between tiles (because of GraphicsLayerCA-level
integral rounding) often resulting in painting some strips of tiles around the edges, but not
filling the entire area; this area would remain white (from the white fill painted earlier), hence
flashing.

Conceptually the page preview needs to appear behind cached tiles, and it's hard to answer the
question "have I filled the given rect with tiles" given floating point drawing coordinates.
We also want to avoid always painting the page previews behind the tiles, for performance.

So instead, display the page previews in the "page background" layers which we already have
and currently just provide a white fill. We need draw the page previews only once; we can just
scale the page background layers as necessary. To avoid repaints on page scale changes, we need
to implement a new GraphicsLayerClient callback that allows us to keep the layer contentsScale
fixed.

The page background layers, and their associated cache buffers are always sized using `layoutBoundsForPageAtIndex()`,
and the buffer scale, and the layer contents scale are determined via `scaleForPagePreviews()`.

The white fill behind the full-resolution PDF content is now painted into the cached buffers.

* Source/WebCore/platform/graphics/GraphicsLayerClient.h:
(WebCore::GraphicsLayerClient::customContentsScale const):
* Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::updateContentsScale):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/AsyncPDFRenderer.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/AsyncPDFRenderer.mm:
(WebKit::AsyncPDFRenderer::paintPagePreviewOnWorkQueue):
(WebKit::AsyncPDFRenderer::coverageRectDidChange):
(WebKit::AsyncPDFRenderer::paintPDFIntoBuffer):
(WebKit::AsyncPDFRenderer::paintTilesForPage):
(WebKit::AsyncPDFRenderer::paintPagePreview):
(WebKit::AsyncPDFRenderer::updateTilesForPaintingRect):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::updatePageBackgroundLayers):
(WebKit::UnifiedPDFPlugin::paintBackgroundLayerForPage):
(WebKit::UnifiedPDFPlugin::scaleForPagePreviews const):
(WebKit::UnifiedPDFPlugin::didGeneratePreviewForPage):
(WebKit::UnifiedPDFPlugin::backgroundLayerForPage const):
(WebKit::UnifiedPDFPlugin::pageIndexForPageBackgroundLayer const):
(WebKit::UnifiedPDFPlugin::customContentsScale const):
(WebKit::UnifiedPDFPlugin::tiledBackingUsageChanged):
(WebKit::UnifiedPDFPlugin::didChangeIsInWindow):
(WebKit::UnifiedPDFPlugin::paint):
(WebKit::UnifiedPDFPlugin::paintContents):
(WebKit::UnifiedPDFPlugin::paintPDFContent):
* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.mm:
(WebKit::PlatformCALayerRemote::create):

,

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



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list