[webkit-changes] [WebKit/WebKit] 9046ee: [Skia][GTK] Implement printing support

Georges Basile Stavracas Neto noreply at github.com
Thu Mar 21 11:05:52 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9046ee541dbffdf24a9e923afc0920cc4c910cbb
      https://github.com/WebKit/WebKit/commit/9046ee541dbffdf24a9e923afc0920cc4c910cbb
  Author: Georges Basile Stavracas Neto <feaneron at igalia.com>
  Date:   2024-03-21 (Thu, 21 Mar 2024)

  Changed paths:
    M Source/ThirdParty/skia/CMakeLists.txt
    M Source/WebCore/platform/SharedBuffer.h
    M Source/WebCore/platform/skia/SharedBufferSkia.cpp
    M Source/WebKit/UIProcess/API/gtk/WebKitPrintOperation.cpp
    M Source/WebKit/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp
    M Source/WebKit/WebProcess/WebPage/gtk/WebPrintOperationGtk.h

  Log Message:
  -----------
  [Skia][GTK] Implement printing support
https://bugs.webkit.org/show_bug.cgi?id=271153

Reviewed by Carlos Garcia Campos.

Enable SkPDF in the build by adding the corresponding files, and their
dependencies, to the sources list in CMake.

Implement Skia code paths for WebPrintOperationGtk. Most of it is a
pretty direct conversion of cairo_t to SkCanvas APIs. The most notable
difference is that one SkPicture is created for each page sheet using
SkPictureRecorder, whereas Cairo operates on a single context for all
pages. When ending the print, take all SkPictures and add them in the
final document.

Limit WebKitPrintOperation to PDF files when printing using Skia, as
it's the only supported method for now. Modern printers support it, and
CUPS is able to implicitly convert between PDF and PostScript if that's
needed.

At last, change the Skia constructor of FragmentedSharedBuffer to receive
sk_sp<SkData>&& instead of a bare pointer (SkData*). This allows writing
the Skia variant of WebPrintOperationGtk::endPrint() in a more concise
way:

```
WebCore::FragmentedSharedBuffer::create(memoryBuffer.detachAsData())
```

instead of

```
sk_sp<SkData> data = memoryBuffer.detachAsData();
WebCore::FragmentedSharedBuffer::create(data.release());
```

* Source/ThirdParty/skia/CMakeLists.txt:
* Source/WebCore/platform/SharedBuffer.h:
* Source/WebCore/platform/skia/SharedBufferSkia.cpp:
(WebCore::FragmentedSharedBuffer::FragmentedSharedBuffer):
(WebCore::FragmentedSharedBuffer::create):
* Source/WebKit/UIProcess/API/gtk/WebKitPrintOperation.cpp:
(webkitPrintOperationRunDialog):
* Source/WebKit/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp:
(WebKit::WebPrintOperationGtk::startPrint):
(WebKit::WebPrintOperationGtk::startPage):
(WebKit::WebPrintOperationGtk::endPage):
(WebKit::WebPrintOperationGtk::endPrint):
(WebKit::WebPrintOperationGtk::rotatePageIfNeeded):
(WebKit::WebPrintOperationGtk::prepareContextToDraw):
(WebKit::WebPrintOperationGtk::renderPage):
(WebKit::WebPrintOperationGtk::printPagesDone):
(WebKit::WebPrintOperationGtk::print):
* Source/WebKit/WebProcess/WebPage/gtk/WebPrintOperationGtk.h:

Canonical link: https://commits.webkit.org/276477@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