Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UnifiedPDF] Get initial painting working #18359

Conversation

smfr
Copy link
Contributor

@smfr smfr commented Sep 28, 2023

8b9d4c4

[UnifiedPDF] Get initial painting working
https://bugs.webkit.org/show_bug.cgi?id=262311
rdar://116185973

Reviewed by Tim Horton.

Start getting PDF drawing working for Unified PDF. Currently this just draws the first
page via `CGPDFDocumentCreateWithProvider()` and `CGPDFDocumentGetPage()`.

Move two bits of code into PDFPluginBase; first, have it handle `geometryDidChange()` so
we can store the size. Second, because UnifiedPDFPlugin isn't layer-backed, we need to
plumb through a `paint()` function from `PluginView`.

* Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::geometryDidChange):
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h:
(WebKit::PDFPluginBase::paint):
(WebKit::PDFPluginBase::size const):
(WebKit::PDFPluginBase::geometryDidChange): Deleted.
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm:
(WebKit::PDFPluginBase::geometryDidChange):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::createPDFDocument):
(WebKit::UnifiedPDFPlugin::installPDFDocument):
(WebKit::UnifiedPDFPlugin::paint):
(WebKit::UnifiedPDFPlugin::geometryDidChange):
* Source/WebKit/WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::paint):

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

6dbd5dc

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug   πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ›  gtk
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  tv-sim
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch
βœ… πŸ›  watch-sim

@smfr smfr requested a review from cdumez as a code owner September 28, 2023 16:04
@smfr smfr self-assigned this Sep 28, 2023
@smfr smfr added the PDF For bugs in WebKit's built-in PDF support. label Sep 28, 2023
@@ -148,6 +148,11 @@
m_view->frame()->document()->loader()->addArchiveResource(resource.releaseNonNull());
}

void PDFPluginBase::geometryDidChange(const IntSize& pluginSize, const AffineTransform& pluginToRootViewTransform)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the compiler going to complain here about unused parameter?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thankfully WebKit doesn't enable that silly warning


void UnifiedPDFPlugin::paint(GraphicsContext& context, const WebCore::IntRect& rect)
{
ALWAYS_LOG_WITH_STREAM(stream << "UnifiedPDFPlugin::paint " << rect);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this log be here?


if (!m_view)
return;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there something missing here?


auto imageBuffer = ImageBuffer::create(m_size, RenderingPurpose::Unspecified, 1.0, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this code going to deal with large PDF files? The maximum size of an ImageBuffer is 4096 x 4096 pixels. Beyond that ImageBuffer is going to scale the context. So the PDF will be pixelated.

@smfr smfr added the merge-queue Applied to send a pull request to merge-queue label Sep 28, 2023
https://bugs.webkit.org/show_bug.cgi?id=262311
rdar://116185973

Reviewed by Tim Horton.

Start getting PDF drawing working for Unified PDF. Currently this just draws the first
page via `CGPDFDocumentCreateWithProvider()` and `CGPDFDocumentGetPage()`.

Move two bits of code into PDFPluginBase; first, have it handle `geometryDidChange()` so
we can store the size. Second, because UnifiedPDFPlugin isn't layer-backed, we need to
plumb through a `paint()` function from `PluginView`.

* Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::geometryDidChange):
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h:
(WebKit::PDFPluginBase::paint):
(WebKit::PDFPluginBase::size const):
(WebKit::PDFPluginBase::geometryDidChange): Deleted.
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm:
(WebKit::PDFPluginBase::geometryDidChange):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::createPDFDocument):
(WebKit::UnifiedPDFPlugin::installPDFDocument):
(WebKit::UnifiedPDFPlugin::paint):
(WebKit::UnifiedPDFPlugin::geometryDidChange):
* Source/WebKit/WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::paint):

Canonical link: https://commits.webkit.org/268610@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/UnifiedPDF-Get-initial-painting-working branch from 6dbd5dc to 8b9d4c4 Compare September 28, 2023 21:09
@webkit-commit-queue
Copy link
Collaborator

Committed 268610@main (8b9d4c4): https://commits.webkit.org/268610@main

Reviewed commits have been landed. Closing PR #18359 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 8b9d4c4 into WebKit:main Sep 28, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Sep 28, 2023
@smfr smfr deleted the eng/UnifiedPDF-Get-initial-painting-working branch October 1, 2023 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PDF For bugs in WebKit's built-in PDF support.
Projects
None yet
6 participants