[Libreoffice-commits] core.git: Branch 'feature/skia' - 168 commits - bin/update_pch compilerplugins/clang compilerplugins/Makefile-clang.mk config_host/config_features.h.in config_host/config_skia.h.in config_host.mk.in configure.ac cui/inc cui/source cui/uiconfig download.lst drawinglayer/source external/mdds external/Module_external.mk external/skia helpcontent2 include/o3tl include/sal include/svl include/svtools include/vcl Makefile.fetch officecfg/registry package/source readlicense_oo/license RepositoryExternal.mk sal/osl schema/libreoffice sc/inc sc/qa sc/source sd/source sd/uiconfig solenv/clang-format solenv/CompilerTest_compilerplugins_clang.mk solenv/gbuild solenv/sanitizers starmath/source svl/source svtools/source svtools/uiconfig sw/inc sw/qa sw/source vcl/backendtest vcl/inc vcl/Library_vcl.mk vcl/Library_vclplug_gen.mk vcl/Library_vclplug_win.mk vcl/opengl vcl/qa vcl/README.vars vcl/skia vcl/source vcl/unx vcl/win vcl/workben writerfilter/source xmloff/source

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Tue Nov 26 09:04:43 UTC 2019


Rebased ref, commits from common ancestor:
commit cb824de147adb317cd06ec00e783ad8b3071f956
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Nov 22 12:58:50 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:34 2019 +0100

    fix SkiaSalGraphicsImpl::drawPolyLine()
    
    Code pretty much copy&pasted from the vcl/quartz version. Fixes
    e.g. Writer marks showing paper corners.
    
    Change-Id: I3c9d2ed00efe409abd0a730a6f7dc0ea2a31c90a

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index b109b698914b..3996965e9760 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -620,16 +620,13 @@ bool SkiaSalGraphicsImpl::drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectTo
     return true;
 }
 
-// TODO implement rObjectToDevice - need to take the matrix into account
 bool SkiaSalGraphicsImpl::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice,
                                        const basegfx::B2DPolygon& rPolyLine, double fTransparency,
                                        const basegfx::B2DVector& rLineWidths,
                                        basegfx::B2DLineJoin eLineJoin,
                                        css::drawing::LineCap eLineCap, double fMiterMinimumAngle,
-                                       bool /*bPixelSnapHairline*/)
+                                       bool bPixelSnapHairline)
 {
-    //(void)bPixelSnapHairline; // TODO
-
     if (rPolyLine.count() == 0 || fTransparency < 0.0 || fTransparency >= 1.0
         || mLineColor == SALCOLOR_NONE)
         return true;
@@ -637,27 +634,16 @@ bool SkiaSalGraphicsImpl::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDev
     preDraw();
     SAL_INFO("vcl.skia", "drawpolyline(" << this << "): " << rPolyLine << ":" << mLineColor);
 
-    basegfx::B2DVector aLineWidths(rLineWidths);
-    const bool bObjectToDeviceIsIdentity(rObjectToDevice.isIdentity());
-    const basegfx::B2DVector aDeviceLineWidths(
-        bObjectToDeviceIsIdentity ? rLineWidths : rObjectToDevice * rLineWidths);
-    const bool bCorrectLineWidth(!bObjectToDeviceIsIdentity && aDeviceLineWidths.getX() < 1.0
-                                 && aLineWidths.getX() >= 1.0);
-
-    // on-demand inverse of ObjectToDevice transformation
-    basegfx::B2DHomMatrix aObjectToDeviceInv;
+    // need to check/handle LineWidth when ObjectToDevice transformation is used
+    const basegfx::B2DVector aDeviceLineWidths(rObjectToDevice * rLineWidths);
+    const bool bCorrectLineWidth(aDeviceLineWidths.getX() < 1.0 && rLineWidths.getX() >= 1.0);
+    const basegfx::B2DVector aLineWidths(bCorrectLineWidth ? rLineWidths : aDeviceLineWidths);
 
-    if (bCorrectLineWidth)
-    {
-        if (aObjectToDeviceInv.isIdentity())
-        {
-            aObjectToDeviceInv = rObjectToDevice;
-            aObjectToDeviceInv.invert();
-        }
-
-        // calculate-back logical LineWidth for a hairline
-        aLineWidths = aObjectToDeviceInv * basegfx::B2DVector(1.0, 1.0);
-    }
+    // Transform to DeviceCoordinates, get DeviceLineWidth, execute PixelSnapHairline
+    basegfx::B2DPolygon aPolyLine(rPolyLine);
+    aPolyLine.transform(rObjectToDevice);
+    if (bPixelSnapHairline)
+        aPolyLine = basegfx::utils::snapPointsOfHorizontalOrVerticalEdges(aPolyLine);
 
     // Setup Line Join
     SkPaint::Join eSkLineJoin = SkPaint::kMiter_Join;
@@ -704,7 +690,7 @@ bool SkiaSalGraphicsImpl::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDev
     aPaint.setAntiAlias(mParent.getAntiAliasB2DDraw());
 
     SkPath aPath;
-    addPolygonToPath(rPolyLine, aPath);
+    addPolygonToPath(aPolyLine, aPath);
     aPath.setFillType(SkPath::kEvenOdd_FillType);
     // Apply the same adjustment as toSkX()/toSkY() do. Do it here even in the non-GPU
     // case as it seems to produce better results.
commit 6ed7af6192500680feeafa465102737bebdf0659
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Nov 22 15:12:57 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:34 2019 +0100

    don't fall back to raster if Skia is first asked for offscreen surface
    
    This is rare, but it may happen. Since now the code shared just one
    GrContext properly, this is not really a problem anymore (and the extra
    WindowContext creation shouldn't be hopefully noticeable either).
    
    Change-Id: I50887b7512e778b70870690a3f672b27cc7f2d21

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index dfa7eb7a7320..b109b698914b 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -245,26 +245,22 @@ void SkiaSalGraphicsImpl::createOffscreenSurface()
         {
             mOffscreenGrContext = sk_app::VulkanWindowContext::getSharedGrContext();
             GrContext* grContext = mOffscreenGrContext.getGrContext();
-            // We may not get a GrContext if called before any onscreen window is created,
-            // but that happens very early, so this should be rare and insignificant.
-            // Unittests are an exception, they usually do not create any windows,
-            // so in that case do create GrContext that has no window associated.
+            // We may not get a GrContext if called before any onscreen window is created.
             if (!grContext)
             {
-                static bool isUnitTest = (getenv("LO_TESTNAME") != nullptr);
-                if (isUnitTest)
-                {
-                    // Create temporary WindowContext with no window. That will fail,
-                    // but it will initialize the shared GrContext.
-                    createWindowContext();
-                    // Keep a reference.
-                    sk_app::VulkanWindowContext::SharedGrContext context
-                        = sk_app::VulkanWindowContext::getSharedGrContext();
-                    // Destroy the temporary WindowContext.
-                    destroySurface();
-                    mOffscreenGrContext = context;
-                    grContext = mOffscreenGrContext.getGrContext();
-                }
+                SAL_INFO("vcl.skia",
+                         "creating Vulkan offscreen GPU surface before any window exists");
+                // Create temporary WindowContext with no window. That will fail,
+                // but it will initialize the shared GrContext.
+                createWindowContext();
+                // Keep a reference.
+                sk_app::VulkanWindowContext::SharedGrContext context
+                    = sk_app::VulkanWindowContext::getSharedGrContext();
+                // Destroy the temporary WindowContext.
+                destroySurface();
+                // Keep a reference until the surface is destroyed.
+                mOffscreenGrContext = context;
+                grContext = mOffscreenGrContext.getGrContext();
             }
             if (grContext)
             {
commit 2b181f0ac82922fc5fe8aebcdb9560fc9c492203
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Nov 22 12:36:31 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:34 2019 +0100

    do not require Vulkan devel package for Skia
    
    I don't see why this should use libvulkan.so, using libvulkan.so.1
    should do as well, and quite possibly any future libvulkan.so.2
    could be binary-incompatible anyway.
    
    Change-Id: I46be40da7fbfdcb59c947e6d088820e580cf4c44

diff --git a/external/skia/UnpackedTarball_skia.mk b/external/skia/UnpackedTarball_skia.mk
index aabb1149a3ae..1d2da19c2b5b 100644
--- a/external/skia/UnpackedTarball_skia.mk
+++ b/external/skia/UnpackedTarball_skia.mk
@@ -20,6 +20,7 @@ skia_patches := \
     fix-shader-locale.patch.1 \
     no-trace-resources-on-exit.patch.1 \
     fix-alpha-difference-copy.patch.1 \
+    libvulkan-name.patch.1 \
     share-grcontext.patch.1
 
 $(eval $(call gb_UnpackedTarball_set_patchlevel,skia,1))
diff --git a/external/skia/libvulkan-name.patch.1 b/external/skia/libvulkan-name.patch.1
new file mode 100644
index 000000000000..265d8daa11df
--- /dev/null
+++ b/external/skia/libvulkan-name.patch.1
@@ -0,0 +1,13 @@
+diff --git a/tools/gpu/vk/VkTestUtils.cpp b/tools/gpu/vk/VkTestUtils.cpp
+index 5b7e8c29ae..1580136b5c 100644
+--- a/tools/gpu/vk/VkTestUtils.cpp
++++ b/tools/gpu/vk/VkTestUtils.cpp
+@@ -13,7 +13,7 @@
+     #if defined _WIN32
+         #define SK_GPU_TOOLS_VK_LIBRARY_NAME "vulkan-1.dll"
+     #else
+-        #define SK_GPU_TOOLS_VK_LIBRARY_NAME "libvulkan.so"
++        #define SK_GPU_TOOLS_VK_LIBRARY_NAME "libvulkan.so.1"
+     #endif
+ #endif
+ 
commit 7a88b9e30850b33f037b744b19b378efbc202054
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Nov 22 12:30:16 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:33 2019 +0100

    use the native Skia color Type when using Vulkan
    
    Change-Id: Ie46d7d89b9aa149f48617ccdbe3a8c492759880f

diff --git a/vcl/skia/x11/gdiimpl.cxx b/vcl/skia/x11/gdiimpl.cxx
index 3f706399f136..04e2586e7f7a 100644
--- a/vcl/skia/x11/gdiimpl.cxx
+++ b/vcl/skia/x11/gdiimpl.cxx
@@ -41,12 +41,7 @@ void X11SkiaSalGraphicsImpl::Init()
 void X11SkiaSalGraphicsImpl::createWindowContext()
 {
     sk_app::DisplayParams displayParams;
-    // Use a macro to hide an unreachable code warning.
-    // TODO The Skia Xlib code actually requires the non-native color type to work properly.
-#define GET_FORMAT                                                                                 \
-    kN32_SkColorType == kBGRA_8888_SkColorType ? kRGBA_8888_SkColorType : kBGRA_8888_SkColorType
-    displayParams.fColorType = GET_FORMAT;
-#undef GET_FORMAT
+    displayParams.fColorType = kN32_SkColorType;
     sk_app::window_context_factory::XlibWindowInfo winInfo;
     winInfo.fDisplay = mX11Parent.GetXDisplay();
     winInfo.fWindow = mX11Parent.GetDrawable();
@@ -68,6 +63,10 @@ void X11SkiaSalGraphicsImpl::createWindowContext()
     switch (SkiaHelper::renderMethodToUse())
     {
         case SkiaHelper::RenderRaster:
+            // TODO The Skia Xlib code actually requires the non-native color type to work properly.
+            displayParams.fColorType
+                = (displayParams.fColorType == kBGRA_8888_SkColorType ? kRGBA_8888_SkColorType
+                                                                      : kBGRA_8888_SkColorType);
             mWindowContext
                 = sk_app::window_context_factory::MakeRasterForXlib(winInfo, displayParams);
             mIsGPU = false;
commit 58579b1ce06bc1ea16f0dc8866614f66b32f39a9
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Thu Nov 21 12:17:13 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:33 2019 +0100

    revert BackendCapabilities::mbSupportsBitmap32 for Skia
    
    It appears that there are still some paths that do not expect
    bitmaps to be truly 32bit, so better revert to the old safe (and
    poor, complicated and inefficient) way of pretty much ignoring
    the alpha channel in SkiaSalBitmap, and let BitmapEx handle
    it by using an extra alpha bitmap.
    
    Change-Id: I4318c05f4ceafc5de48e19eeae5efe2abed2ec69

diff --git a/vcl/inc/unx/salinst.h b/vcl/inc/unx/salinst.h
index a84c659917cd..1b4b6c1af6f8 100644
--- a/vcl/inc/unx/salinst.h
+++ b/vcl/inc/unx/salinst.h
@@ -81,8 +81,6 @@ public:
 
     virtual void                AfterAppInit() override;
 
-    std::shared_ptr<vcl::BackendCapabilities> GetBackendCapabilities() override;
-
     // dtrans implementation
     virtual css::uno::Reference< css::uno::XInterface >
         CreateClipboard( const css::uno::Sequence< css::uno::Any >& i_rArguments ) override;
diff --git a/vcl/inc/win/salinst.h b/vcl/inc/win/salinst.h
index c06e51c84050..bcd3540ad8a9 100644
--- a/vcl/inc/win/salinst.h
+++ b/vcl/inc/win/salinst.h
@@ -73,7 +73,6 @@ public:
     virtual void                AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) override;
 
     virtual OUString            getOSVersion() override;
-    virtual std::shared_ptr<vcl::BackendCapabilities> GetBackendCapabilities() override;
 
     static int WorkaroundExceptionHandlingInUSER32Lib(int nExcept, LPEXCEPTION_POINTERS pExceptionInfo);
 };
diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 9910693d6336..fb0c3608028d 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -80,8 +80,16 @@ bool SkiaSalBitmap::Create(const Size& rSize, sal_uInt16 nBitCount, const Bitmap
     }
     if (colorType != kUnknown_SkColorType)
     {
+        // TODO
+        // As long as vcl::BackendCapabilities::mbSupportsBitmap32 is not set, we must use
+        // unpremultiplied alpha. This is because without mbSupportsBitmap32 set VCL uses
+        // an extra bitmap for the alpha channel and then merges the channels together
+        // into colors. kPremul_SkAlphaType would provide better performance, but
+        // without mbSupportsBitmap32 BitmapReadAccess::ImplSetAccessPointers() would use
+        // functions that merely read RGB without A, so the premultiplied values would
+        // not be converted back to unpremultiplied values.
         if (!mBitmap.tryAllocPixels(
-                SkImageInfo::Make(rSize.Width(), rSize.Height(), colorType, kPremul_SkAlphaType)))
+                SkImageInfo::Make(rSize.Width(), rSize.Height(), colorType, kUnpremul_SkAlphaType)))
         {
             return false;
         }
diff --git a/vcl/unx/generic/app/salinst.cxx b/vcl/unx/generic/app/salinst.cxx
index 3ec713ca0e72..3c39a1addbd9 100644
--- a/vcl/unx/generic/app/salinst.cxx
+++ b/vcl/unx/generic/app/salinst.cxx
@@ -220,14 +220,4 @@ std::unique_ptr<GenPspGraphics> X11SalInstance::CreatePrintGraphics()
     return std::make_unique<GenPspGraphics>();
 }
 
-std::shared_ptr<vcl::BackendCapabilities> X11SalInstance::GetBackendCapabilities()
-{
-    auto pBackendCapabilities = SalInstance::GetBackendCapabilities();
-#if HAVE_FEATURE_SKIA
-    if( SkiaHelper::isVCLSkiaEnabled())
-        pBackendCapabilities->mbSupportsBitmap32 = true;
-#endif
-    return pBackendCapabilities;
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 7c7bfc6e76e0..1915fb6f6b97 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -1067,14 +1067,4 @@ OUString WinSalInstance::getOSVersion()
     return aVer.makeStringAndClear();
 }
 
-std::shared_ptr<vcl::BackendCapabilities> WinSalInstance::GetBackendCapabilities()
-{
-    auto pBackendCapabilities = SalInstance::GetBackendCapabilities();
-#if HAVE_FEATURE_SKIA
-    if( SkiaHelper::isVCLSkiaEnabled())
-        pBackendCapabilities->mbSupportsBitmap32 = true;
-#endif
-    return pBackendCapabilities;
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 4b308ce61a71bc24f43dac6ab8da49e070c1bd89
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Thu Nov 21 12:09:17 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:33 2019 +0100

    patch Skia bug with copying data with different alpha type
    
    https://bugs.chromium.org/p/skia/issues/detail?id=9662
    
    Change-Id: Ic5208c2c817912cddbfae4b86e3b3647306262fb

diff --git a/external/skia/UnpackedTarball_skia.mk b/external/skia/UnpackedTarball_skia.mk
index 1fab368cc34b..aabb1149a3ae 100644
--- a/external/skia/UnpackedTarball_skia.mk
+++ b/external/skia/UnpackedTarball_skia.mk
@@ -19,6 +19,7 @@ skia_patches := \
     make-api-visible.patch.1 \
     fix-shader-locale.patch.1 \
     no-trace-resources-on-exit.patch.1 \
+    fix-alpha-difference-copy.patch.1 \
     share-grcontext.patch.1
 
 $(eval $(call gb_UnpackedTarball_set_patchlevel,skia,1))
diff --git a/external/skia/fix-alpha-difference-copy.patch.1 b/external/skia/fix-alpha-difference-copy.patch.1
new file mode 100644
index 000000000000..d9e992a770a7
--- /dev/null
+++ b/external/skia/fix-alpha-difference-copy.patch.1
@@ -0,0 +1,13 @@
+diff --git a/src/core/SkBlitter_Sprite.cpp b/src/core/SkBlitter_Sprite.cpp
+index 89b107b939..042d8e65aa 100644
+--- a/src/core/SkBlitter_Sprite.cpp
++++ b/src/core/SkBlitter_Sprite.cpp
+@@ -178,7 +178,7 @@ SkBlitter* SkBlitter::ChooseSprite(const SkPixmap& dst, const SkPaint& paint,
+     */
+     SkASSERT(allocator != nullptr);
+ 
+-    if (source.alphaType() == kUnpremul_SkAlphaType) {
++    if (source.alphaType() != dst.alphaType()) {
+         return nullptr;
+     }
+ 
commit 105e616d692ca7db8234052382931a3ec9f1c69c
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Wed Nov 20 15:37:11 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:33 2019 +0100

    handle properly true 32bit bitmaps in some places
    
    I.e. those created with vcl::BackendCapabilities::mbSupportsBitmap32 set.
    But there are quite possibly many more places that do not expect
    that the Bitmap itself would contain alpha.
    
    Change-Id: I83db37b3d346f42565f96b9bbf81c71b97b6bf8b

diff --git a/drawinglayer/source/texture/texture3d.cxx b/drawinglayer/source/texture/texture3d.cxx
index 3c5f7d5e29bf..8874d3425599 100644
--- a/drawinglayer/source/texture/texture3d.cxx
+++ b/drawinglayer/source/texture/texture3d.cxx
@@ -23,6 +23,7 @@
 
 #include <drawinglayer/texture/texture3d.hxx>
 #include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapTools.hxx>
 #include <drawinglayer/primitive3d/hatchtextureprimitive3d.hxx>
 #include <sal/log.hxx>
 
@@ -76,6 +77,8 @@ namespace drawinglayer
             mbIsAlpha(false),
             mbIsTransparent(maBitmapEx.IsTransparent())
         {
+            if(vcl::bitmap::convertBitmap32To24Plus8(maBitmapEx,maBitmapEx))
+                mbIsTransparent = maBitmapEx.IsTransparent();
             // #121194# Todo: use alpha channel, too (for 3d)
             maBitmap = maBitmapEx.GetBitmap();
 
diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx
index f37499dff0b8..b4d7c106b37c 100644
--- a/vcl/source/gdi/bitmapex.cxx
+++ b/vcl/source/gdi/bitmapex.cxx
@@ -689,6 +689,8 @@ sal_uInt8 BitmapEx::GetTransparency(sal_Int32 nX, sal_Int32 nY) const
     {
         if (nX >= 0 && nX < GetSizePixel().Width() && nY >= 0 && nY < GetSizePixel().Height())
         {
+            if (maBitmap.GetBitCount() == 32)
+                return GetPixelColor(nX, nY).GetTransparency();
             switch(meTransparent)
             {
                 case TransparentType::NONE:
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index 8ac555009541..8b8f029b1897 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -261,6 +261,7 @@ static void CreateNetWmAppIcon( sal_uInt16 nIcon, NetWmIconData& netwm_icon )
 
         if( aIcon.IsEmpty())
             continue;
+        vcl::bitmap::convertBitmap32To24Plus8(aIcon, aIcon);
         Bitmap icon = aIcon.GetBitmap();
         AlphaMask mask;
         switch( aIcon.GetTransparentType())
commit d49f78927fd0458fd338def3c9dddd5a2f7e3198
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Wed Nov 20 12:47:23 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:33 2019 +0100

    copy SkImage properly
    
    Change-Id: I61f082d8a8d8eead6c49bbf3da997462e7d9738e

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 1e5c554b49f2..9910693d6336 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -49,7 +49,9 @@ SkiaSalBitmap::SkiaSalBitmap(const SkImage& image)
     {
         SkCanvas canvas(mBitmap);
         // TODO makeNonTextureImage() ?
-        canvas.drawImage(&image, 0, 0);
+        SkPaint paint;
+        paint.setBlendMode(SkBlendMode::kSrc); // set as is, including alpha
+        canvas.drawImage(&image, 0, 0, &paint);
     }
 }
 
commit 935d9a038a34313e8c7fe225e11e035e4182c41a
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Wed Nov 20 12:10:21 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:33 2019 +0100

    fix mistyped operator
    
    Change-Id: I10ca633d31163c968b0010983132942a1823a3f6

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index de49400cd481..1e5c554b49f2 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -86,7 +86,7 @@ bool SkiaSalBitmap::Create(const Size& rSize, sal_uInt16 nBitCount, const Bitmap
 #ifdef DBG_UTIL
         // fill with random garbage
         sal_uInt8* buffer = static_cast<sal_uInt8*>(mBitmap.getPixels());
-        size_t size = mBitmap.rowBytes() & mBitmap.height();
+        size_t size = mBitmap.rowBytes() * mBitmap.height();
         for (size_t i = 0; i < size; i++)
             buffer[i] = (i & 0xFF);
 #endif
commit 57df3fa418586405c67f89f919da7a92b658f894
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Tue Nov 19 12:52:00 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:33 2019 +0100

    fix a VirtualDevice leak
    
    VclPtr is a smart ptr, but it does not own (and thus does not autodelete).
    
    Change-Id: I2d9b924852d01b118fb0bc2a583063da230ee065

diff --git a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx
index c377f4ee6526..ae753a40a39b 100644
--- a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx
+++ b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx
@@ -170,7 +170,7 @@ namespace
             if (maDeviceTemplates[pRetval]->isDisposed())
             {
                 maDeviceTemplates.erase(pRetval);
-                pRetval = nullptr;
+                pRetval.disposeAndClear();
             }
             else
             {
commit 35d3c14c497fb3d43ab61089571ba0286efc2974
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Tue Nov 12 17:28:14 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:33 2019 +0100

    fix Skia with --enable-pch=full
    
    Change-Id: I6bec47e373c042d1ffb3607bf5dca9dfe2509466

diff --git a/external/skia/fix-pch.patch b/external/skia/fix-pch.patch
index 1bd09f1bbc30..a991e80970e9 100644
--- a/external/skia/fix-pch.patch
+++ b/external/skia/fix-pch.patch
@@ -54,3 +54,31 @@
  #include <dwrite.h>
  #include <d2d1.h>
  
+--- skia/include/core/SkColor.h
++++ skia/include/core/SkColor.h
+@@ -396,6 +396,7 @@ using SkColor4f = SkRGBA4f<kUnpremul_SkAlphaType>;
+ 
+ template <> SK_API SkColor4f SkColor4f::FromColor(SkColor);
+ template <> SK_API SkColor   SkColor4f::toSkColor() const;
++template <> uint32_t SkColor4f::toBytes_RGBA() const;
+ 
+ namespace SkColors {
+ constexpr SkColor4f kTransparent = {0, 0, 0, 0};
+--- skia/include/private/SkColorData.h
++++ skia/include/private/SkColorData.h
+@@ -441,4 +441,6 @@ constexpr SkPMColor4f SK_PMColor4fILLEGAL = { SK_FloatNegativeInfinity,
+                                                   SK_FloatNegativeInfinity,
+                                                   SK_FloatNegativeInfinity };
+ 
++template <> uint32_t SkPMColor4f::toBytes_RGBA() const;
++
+ #endif
+--- skia/src/gpu/text/GrTextBlobCache.h
++++ skia/src/gpu/text/GrTextBlobCache.h
+@@ -188,4 +188,6 @@ private:
+     SkMessageBus<PurgeBlobMessage>::Inbox fPurgeBlobInbox;
+ };
+ 
++template<> SkMessageBus<GrTextBlobCache::PurgeBlobMessage>* SkMessageBus<GrTextBlobCache::PurgeBlobMessage>::Get();
++
+ #endif
commit 6ed504a73c9c7c18af3d502e81863ea50c5e0331
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Tue Nov 19 18:08:07 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:33 2019 +0100

    build Skia only on selected platforms
    
    Feel free to adjust your platform as necessary.
    
    Change-Id: I3003a643c39b6afeb3102f97280f20534b9c7f77

diff --git a/configure.ac b/configure.ac
index 20cde192061e..04f8330a9ac8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -590,6 +590,7 @@ case "$host_os" in
 solaris*)
     build_gstreamer_1_0=yes
     test_freetype=yes
+    build_skia=yes
     _os=SunOS
 
     dnl ===========================================================
@@ -616,6 +617,7 @@ linux-gnu*|k*bsd*-gnu*)
     build_gstreamer_1_0=yes
     test_kf5=yes
     test_gtk3_kde5=yes
+    build_skia=yes
     test_gdb_index=yes
     test_split_debug=yes
     if test "$enable_fuzzers" != yes; then
@@ -654,6 +656,7 @@ cygwin*|interix*)
     test_xrender=no
     test_freetype=no
     test_fontconfig=no
+    build_skia=yes
     _os=WINNT
 
     DLLPOST=".dll"
@@ -708,6 +711,7 @@ freebsd*)
     test_kf5=yes
     test_gtk3_kde5=yes
     test_freetype=yes
+    build_skia=yes
     AC_MSG_CHECKING([the FreeBSD operating system release])
     if test -n "$with_os_version"; then
         OSVERSION="$with_os_version"
@@ -735,6 +739,7 @@ freebsd*)
     test_kf5=yes
     test_gtk3_kde5=yes
     test_freetype=yes
+    build_skia=yes
     PTHREAD_LIBS="-pthread -lpthread"
     _os=NetBSD
     ;;
@@ -758,6 +763,7 @@ dragonfly*)
     test_kf5=yes
     test_gtk3_kde5=yes
     test_freetype=yes
+    build_skia=yes
     PTHREAD_LIBS="-pthread"
     _os=DragonFly
     ;;
@@ -10882,7 +10888,7 @@ AC_SUBST(POPPLER_LIBS)
 # Skia?
 AC_MSG_CHECKING([whether to build Skia])
 ENABLE_SKIA=
-if test "$enable_skia" != "no"; then
+if test "$enable_skia" != "no" -a "$build_skia" = "yes"; then
     AC_MSG_RESULT([yes])
     ENABLE_SKIA=TRUE
     AC_DEFINE(HAVE_FEATURE_SKIA)
commit c3fd3899cc59975967866789c87e6b8ba54260a5
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Tue Nov 19 14:54:22 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:32 2019 +0100

    avoid some compiler warnings in Skia VCL code
    
    Mostly warnings from the 'casttovoid' Clang plugin, which is rather
    annoying here.
    
    Change-Id: I3d69697143f690211cdd26d1b9a4c0efe9397197

diff --git a/vcl/backendtest/outputdevice/common.cxx b/vcl/backendtest/outputdevice/common.cxx
index 34e37e771f1f..a7e857ffd1fd 100644
--- a/vcl/backendtest/outputdevice/common.cxx
+++ b/vcl/backendtest/outputdevice/common.cxx
@@ -262,7 +262,7 @@ TestResult OutputDeviceTestCommon::checkAALines(Bitmap& rBitmap)
     return checkHorizontalVerticalDiagonalLines(rBitmap, constLineColor, 30); // 30 color values threshold delta
 }
 
-void checkResult(TestResult eResult, TestResult & eTotal)
+static void checkResult(TestResult eResult, TestResult & eTotal)
 {
     if (eTotal == TestResult::Failed)
         return;
diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx
index 0036b2d89f7a..517bad0db5c8 100644
--- a/vcl/inc/skia/gdiimpl.hxx
+++ b/vcl/inc/skia/gdiimpl.hxx
@@ -251,7 +251,8 @@ protected:
     friend inline std::basic_ostream<charT, traits>&
     operator<<(std::basic_ostream<charT, traits>& stream, const SkiaSalGraphicsImpl* graphics)
     { // O - offscreen, G - GPU-based, R - raster
-        return stream << (void*)graphics << " " << Size(graphics->GetWidth(), graphics->GetHeight())
+        return stream << static_cast<const void*>(graphics) << " "
+                      << Size(graphics->GetWidth(), graphics->GetHeight())
                       << (graphics->isOffscreen() ? "O" : "") << (graphics->isGPU() ? "G" : "R");
     }
 
diff --git a/vcl/inc/skia/salbmp.hxx b/vcl/inc/skia/salbmp.hxx
index c5922685c5b7..ed0f374162d6 100644
--- a/vcl/inc/skia/salbmp.hxx
+++ b/vcl/inc/skia/salbmp.hxx
@@ -83,8 +83,8 @@ private:
     operator<<(std::basic_ostream<charT, traits>& stream, const SkiaSalBitmap* bitmap)
     { // TODO GPU-based, once it's done
         // B - has SkBitmap, A - has alpha SkBitmap, D - has data buffer
-        return stream << (void*)bitmap << " " << bitmap->GetSize() << "/" << bitmap->mBitCount
-                      << (!bitmap->mBitmap.drawsNothing() ? "B" : "")
+        return stream << static_cast<const void*>(bitmap) << " " << bitmap->GetSize() << "/"
+                      << bitmap->mBitCount << (!bitmap->mBitmap.drawsNothing() ? "B" : "")
                       << (!bitmap->mAlphaBitmap.drawsNothing() ? "A" : "")
                       << (bitmap->mBuffer.get() ? "D" : "");
     }
diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index 810e8f9b0b11..040f189be74f 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -103,8 +103,9 @@ static bool initRenderMethodToUse()
 SkiaHelper::RenderMethod SkiaHelper::renderMethodToUse()
 {
     static bool methodToUseInited = initRenderMethodToUse();
-    (void)methodToUseInited; // Used just to ensure thread-safe one-time init.
-    return methodToUse;
+    if (methodToUseInited) // Used just to ensure thread-safe one-time init.
+        return methodToUse;
+    abort();
 }
 
 void SkiaHelper::disableRenderMethod(RenderMethod method)
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 271f1a61321c..dfa7eb7a7320 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -439,10 +439,9 @@ void SkiaSalGraphicsImpl::SetFillColor() { mFillColor = SALCOLOR_NONE; }
 
 void SkiaSalGraphicsImpl::SetFillColor(Color nColor) { mFillColor = nColor; }
 
-void SkiaSalGraphicsImpl::SetXORMode(bool bSet, bool bInvertOnly)
+void SkiaSalGraphicsImpl::SetXORMode(bool, bool)
 {
-    (void)bSet;
-    (void)bInvertOnly;
+    // TODO
 }
 
 void SkiaSalGraphicsImpl::SetROPLineColor(SalROPColor nROPColor)
@@ -631,9 +630,9 @@ bool SkiaSalGraphicsImpl::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDev
                                        const basegfx::B2DVector& rLineWidths,
                                        basegfx::B2DLineJoin eLineJoin,
                                        css::drawing::LineCap eLineCap, double fMiterMinimumAngle,
-                                       bool bPixelSnapHairline)
+                                       bool /*bPixelSnapHairline*/)
 {
-    (void)bPixelSnapHairline;
+    //(void)bPixelSnapHairline; // TODO
 
     if (rPolyLine.count() == 0 || fTransparency < 0.0 || fTransparency >= 1.0
         || mLineColor == SALCOLOR_NONE)
@@ -720,32 +719,22 @@ bool SkiaSalGraphicsImpl::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDev
     return true;
 }
 
-bool SkiaSalGraphicsImpl::drawPolyLineBezier(sal_uInt32 nPoints, const SalPoint* pPtAry,
-                                             const PolyFlags* pFlgAry)
+bool SkiaSalGraphicsImpl::drawPolyLineBezier(sal_uInt32, const SalPoint*, const PolyFlags*)
 {
-    (void)nPoints;
-    (void)pPtAry;
-    (void)pFlgAry;
+    // TODO?
     return false;
 }
 
-bool SkiaSalGraphicsImpl::drawPolygonBezier(sal_uInt32 nPoints, const SalPoint* pPtAry,
-                                            const PolyFlags* pFlgAry)
+bool SkiaSalGraphicsImpl::drawPolygonBezier(sal_uInt32, const SalPoint*, const PolyFlags*)
 {
-    (void)nPoints;
-    (void)pPtAry;
-    (void)pFlgAry;
+    // TODO?
     return false;
 }
 
-bool SkiaSalGraphicsImpl::drawPolyPolygonBezier(sal_uInt32 nPoly, const sal_uInt32* pPoints,
-                                                const SalPoint* const* pPtAry,
-                                                const PolyFlags* const* pFlgAry)
+bool SkiaSalGraphicsImpl::drawPolyPolygonBezier(sal_uInt32, const sal_uInt32*,
+                                                const SalPoint* const*, const PolyFlags* const*)
 {
-    (void)nPoly;
-    (void)pPoints;
-    (void)pPtAry;
-    (void)pFlgAry;
+    // TODO?
     return false;
 }
 
@@ -1005,15 +994,9 @@ void SkiaSalGraphicsImpl::invert(sal_uInt32 nPoints, const SalPoint* pPointArray
     invert(aPolygon, eFlags);
 }
 
-bool SkiaSalGraphicsImpl::drawEPS(long nX, long nY, long nWidth, long nHeight, void* pPtr,
-                                  sal_uInt32 nSize)
+bool SkiaSalGraphicsImpl::drawEPS(long, long, long, long, void*, sal_uInt32)
 {
-    (void)nX;
-    (void)nY;
-    (void)nWidth;
-    (void)nHeight;
-    (void)pPtr;
-    (void)nSize;
+    // TODO?
     return false;
 }
 
@@ -1122,11 +1105,9 @@ bool SkiaSalGraphicsImpl::drawAlphaRect(long nX, long nY, long nWidth, long nHei
     return true;
 }
 
-bool SkiaSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolygon,
-                                       const Gradient& rGradient)
+bool SkiaSalGraphicsImpl::drawGradient(const tools::PolyPolygon&, const Gradient&)
 {
-    (void)rPolygon;
-    (void)rGradient;
+    // TODO?
     return false;
 }
 
diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index c1ff1f13e9e3..de49400cd481 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -164,15 +164,11 @@ bool SkiaSalBitmap::Create(const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount)
     // TODO copy data
     SAL_INFO("vcl.skia", "copy(" << this << "): (" << &src << ")");
     abort();
-    return true;
 }
 
-bool SkiaSalBitmap::Create(const css::uno::Reference<css::rendering::XBitmapCanvas>& rBitmapCanvas,
-                           Size& rSize, bool bMask)
+bool SkiaSalBitmap::Create(const css::uno::Reference<css::rendering::XBitmapCanvas>&, Size&, bool)
 {
-    (void)rBitmapCanvas;
-    (void)rSize;
-    (void)bMask;
+    // TODO?
     return false;
 }
 
@@ -187,9 +183,9 @@ Size SkiaSalBitmap::GetSize() const { return mSize; }
 
 sal_uInt16 SkiaSalBitmap::GetBitCount() const { return mBitCount; }
 
-BitmapBuffer* SkiaSalBitmap::AcquireBuffer(BitmapAccessMode nMode)
+BitmapBuffer* SkiaSalBitmap::AcquireBuffer(BitmapAccessMode /*nMode*/)
 {
-    (void)nMode; // TODO
+    //(void)nMode; // TODO
     if (mBitmap.drawsNothing() && !mBuffer)
         return nullptr;
     BitmapBuffer* buffer = new BitmapBuffer;
@@ -257,27 +253,23 @@ void SkiaSalBitmap::ReleaseBuffer(BitmapBuffer* pBuffer, BitmapAccessMode nMode)
     delete pBuffer;
 }
 
-bool SkiaSalBitmap::GetSystemData(BitmapSystemData& rData)
+bool SkiaSalBitmap::GetSystemData(BitmapSystemData&)
 {
-    (void)rData;
+    // TODO?
     return false;
 }
 
 bool SkiaSalBitmap::ScalingSupported() const { return false; }
 
-bool SkiaSalBitmap::Scale(const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag)
+bool SkiaSalBitmap::Scale(const double&, const double&, BmpScaleFlag)
 {
-    (void)rScaleX;
-    (void)rScaleY;
-    (void)nScaleFlag;
+    // TODO?
     return false;
 }
 
-bool SkiaSalBitmap::Replace(const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol)
+bool SkiaSalBitmap::Replace(const Color&, const Color&, sal_uInt8)
 {
-    (void)rSearchColor;
-    (void)rReplaceColor;
-    (void)nTol;
+    // TODO?
     return false;
 }
 
@@ -298,10 +290,10 @@ const SkBitmap& SkiaSalBitmap::GetSkBitmap() const
             // Convert 24bpp RGB/BGR to 32bpp RGBA/BGRA.
             std::unique_ptr<sal_uInt8[]> data(new sal_uInt8[mSize.Height() * mSize.Width() * 4]);
             sal_uInt8* dest = data.get();
-            for (int y = 0; y < mSize.Height(); ++y)
+            for (long y = 0; y < mSize.Height(); ++y)
             {
                 const sal_uInt8* src = mBuffer.get() + mScanlineSize * y;
-                for (int x = 0; x < mSize.Width(); ++x)
+                for (long x = 0; x < mSize.Width(); ++x)
                 {
                     *dest++ = *src++;
                     *dest++ = *src++;
diff --git a/vcl/source/bitmap/salbmp.cxx b/vcl/source/bitmap/salbmp.cxx
index 28a46ccc262b..c9aca589edba 100644
--- a/vcl/source/bitmap/salbmp.cxx
+++ b/vcl/source/bitmap/salbmp.cxx
@@ -148,7 +148,7 @@ std::unique_ptr< sal_uInt8[] > SalBitmap::convertDataBitCount( const sal_uInt8*
 {
     assert( bitCount == 1 || bitCount == 4 || bitCount == 8 );
     static const int bpp[] = { 1, 3, 3, 4, 4 };
-    std::unique_ptr< sal_uInt8[] > data( new sal_uInt8[width * height * bpp[ (int)type ]] );
+    std::unique_ptr< sal_uInt8[] > data( new sal_uInt8[width * height * bpp[ static_cast<int>(type) ]] );
     std::unique_ptr<ImplPixelFormat> pSrcFormat(ImplPixelFormat::GetFormat(bitCount, palette));
 
     const sal_uInt8* pSrcData = src;
commit 5c9f8e538136b3824f189a50e1ed72e18a9553b6
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Mon Nov 18 16:40:25 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:32 2019 +0100

    solve the Skia lerp() conflict differently
    
    New versions of libstdc++ provide lerp() in the global namespace,
    older ones don't, but it depends on the libstdc++ version and not
    the c++ version. Since the function is local, just "rename" it.
    
    Change-Id: I37896190c620350739fba9b8ce6544f945519244

diff --git a/external/skia/lerp.patch b/external/skia/lerp.patch
index c87a965e7caf..2062c21f2df0 100644
--- a/external/skia/lerp.patch
+++ b/external/skia/lerp.patch
@@ -1,14 +1,12 @@
---- skia/src/shaders/SkPerlinNoiseShader.cpp.sav	2019-07-29 14:37:30.429563360 +0200
-+++ skia/src/shaders/SkPerlinNoiseShader.cpp	2019-07-29 16:45:29.736231751 +0200
-@@ -573,9 +573,11 @@ static SkScalar fade(SkScalar t) {
+diff --git a/src/shaders/SkPerlinNoiseShader.cpp b/src/shaders/SkPerlinNoiseShader.cpp
+index 812dc1694f..60b8d617c6 100644
+--- a/src/shaders/SkPerlinNoiseShader.cpp
++++ b/src/shaders/SkPerlinNoiseShader.cpp
+@@ -573,6 +573,7 @@ static SkScalar fade(SkScalar t) {
      return t * t * t * (t * (t * 6 - 15) + 10);
  }
  
-+#if __cplusplus <= 201703L
++#define lerp skia_lerp
  static SkScalar lerp(SkScalar t, SkScalar a, SkScalar b) {
      return a + t * (b - a);
  }
-+#endif
- 
- static SkScalar grad(int hash, SkScalar x, SkScalar y, SkScalar z) {
-     int h = hash & 15;
commit 8f51026580e0d80d490a7ed82d4045d170ed69df
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Mon Nov 18 13:52:09 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:32 2019 +0100

    avoid unused parameter warning in non-debug build
    
    Change-Id: I3ea06a872d5348f7681602a6d68ff69990f2cd7e

diff --git a/vcl/qa/cppunit/BackendTest.cxx b/vcl/qa/cppunit/BackendTest.cxx
index 1090c33b73e0..0f253a797097 100644
--- a/vcl/qa/cppunit/BackendTest.cxx
+++ b/vcl/qa/cppunit/BackendTest.cxx
@@ -59,6 +59,7 @@ public:
     {
         // This ensures that all backends return a valid name.
         assert(!name.isEmpty());
+        (void)name;
         return false;
     }
 
commit 2bd73b140670e2c9dfb5849393158e7ff571eeec
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Mon Nov 18 12:24:59 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:32 2019 +0100

    make about dialog differentiate between Skia with Vulkan or raster
    
    Since they are technically still two different rendering implementations.
    
    Change-Id: I83c324b384b7acfcc84e729271d00b995327eec6

diff --git a/vcl/inc/strings.hrc b/vcl/inc/strings.hrc
index d8f73a587722..e378b54814bd 100644
--- a/vcl/inc/strings.hrc
+++ b/vcl/inc/strings.hrc
@@ -125,7 +125,8 @@
 #define SV_APP_OSVERSION                             NC_("SV_APP_OSVERSION", "OS: ")
 #define SV_APP_UIRENDER                              NC_("SV_APP_UIRENDER", "UI render: ")
 #define SV_APP_GL                                    NC_("SV_APP_GL", "GL")
-#define SV_APP_SKIA                                  NC_("SV_APP_SKIA", "Skia")
+#define SV_APP_SKIA_VULKAN                           NC_("SV_APP_SKIA_VULKAN", "Skia/Vulkan")
+#define SV_APP_SKIA_RASTER                           NC_("SV_APP_SKIA_RASTER", "Skia/Raster")
 #define SV_APP_DEFAULT                               NC_("SV_APP_DEFAULT", "default")
 
 #define SV_MSGBOX_INFO                               NC_("SV_MSGBOX_INFO", "Information")
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 4b97754bebbe..511e6dd5e598 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -1153,9 +1153,21 @@ OUString Application::GetHWOSConfInfo()
         aDetails.append( VclResId(SV_APP_GL) );
     else
 #endif
+#if HAVE_FEATURE_SKIA
     if ( SkiaHelper::isVCLSkiaEnabled() )
-        aDetails.append( VclResId(SV_APP_SKIA) );
+    {
+        switch(SkiaHelper::renderMethodToUse())
+        {
+            case SkiaHelper::RenderVulkan:
+                aDetails.append( VclResId(SV_APP_SKIA_VULKAN) );
+                break;
+            case SkiaHelper::RenderRaster:
+                aDetails.append( VclResId(SV_APP_SKIA_RASTER) );
+                break;
+        }
+    }
     else
+#endif
         aDetails.append( VclResId(SV_APP_DEFAULT) );
     aDetails.append( "; " );
 
commit f09de67fb9ddcf523d1c9f40896cd6f56a55199d
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Mon Nov 18 12:10:36 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:32 2019 +0100

    make sure Skia invert with TrackFrame doesn't paint outside
    
    According to Tomaž that's a requirement and that is what the test
    for it tests. This is easy to implement with additional clipping.
    
    Change-Id: Ia54489e20ce58ae0624183f2989036e6938cd44f

diff --git a/vcl/qa/cppunit/BackendTest.cxx b/vcl/qa/cppunit/BackendTest.cxx
index 6dfda5d02d35..1090c33b73e0 100644
--- a/vcl/qa/cppunit/BackendTest.cxx
+++ b/vcl/qa/cppunit/BackendTest.cxx
@@ -465,8 +465,7 @@ public:
 
     CPPUNIT_TEST(testDrawInvertWithRectangle);
     CPPUNIT_TEST(testDrawInvertN50WithRectangle);
-    // AFAIK this test (itself) is broken.
-    // CPPUNIT_TEST(testDrawInvertTrackFrameWithRectangle);
+    CPPUNIT_TEST(testDrawInvertTrackFrameWithRectangle);
 
     CPPUNIT_TEST(testDrawBezierWithPolylineB2D);
     CPPUNIT_TEST(testDrawBezierAAWithPolylineB2D);
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 948c85df72e4..271f1a61321c 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -920,6 +920,11 @@ void SkiaSalGraphicsImpl::invert(basegfx::B2DPolygon const& rPoly, SalInvert eFl
         SkPath aPath;
         addPolygonToPath(rPoly, aPath);
         aPath.setFillType(SkPath::kEvenOdd_FillType);
+        // TrackFrame is not supposed to paint outside of the polygon (usually rectangle),
+        // but wider stoke width usually results in that, so ensure the requirement
+        // by clipping.
+        SkAutoCanvasRestore autoRestore(mSurface->getCanvas(), true);
+        mSurface->getCanvas()->clipRect(aPath.getBounds(), SkClipOp::kIntersect, false);
         SkPaint aPaint;
         aPaint.setStrokeWidth(2);
         float intervals[] = { 4.0f, 4.0f };
commit 140acc170ab71441482a91b4dc7e05325ea09221
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Nov 15 17:22:38 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:32 2019 +0100

    disable Skia resource leak checking on exit
    
    This is normally enabled in Skia debug builds and it asserts if there
    is a problem, which there is with a number of our unittests that leak
    something (usually a VirtualDevice). Those are non-trivial to find
    and don't matter in practice (or if they do they should be fixed
    for all VCL backends), so just disable the Skia check.
    
    Change-Id: I0a0721d8a3f0f961e14513574f4b3cc88ec1e62c

diff --git a/external/skia/UnpackedTarball_skia.mk b/external/skia/UnpackedTarball_skia.mk
index c3988042a012..1fab368cc34b 100644
--- a/external/skia/UnpackedTarball_skia.mk
+++ b/external/skia/UnpackedTarball_skia.mk
@@ -18,6 +18,7 @@ skia_patches := \
     fix-ddi.patch \
     make-api-visible.patch.1 \
     fix-shader-locale.patch.1 \
+    no-trace-resources-on-exit.patch.1 \
     share-grcontext.patch.1
 
 $(eval $(call gb_UnpackedTarball_set_patchlevel,skia,1))
diff --git a/external/skia/no-trace-resources-on-exit.patch.1 b/external/skia/no-trace-resources-on-exit.patch.1
new file mode 100644
index 000000000000..7a8567938eba
--- /dev/null
+++ b/external/skia/no-trace-resources-on-exit.patch.1
@@ -0,0 +1,26 @@
+diff --git a/src/gpu/vk/GrVkCommandPool.h b/src/gpu/vk/GrVkCommandPool.h
+index fd44d62e94..f9e90f185f 100644
+--- a/src/gpu/vk/GrVkCommandPool.h
++++ b/src/gpu/vk/GrVkCommandPool.h
+@@ -41,7 +41,7 @@ public:
+     // returns true if close() has not been called
+     bool isOpen() const { return fOpen; }
+ 
+-#ifdef SK_DEBUG
++#ifdef SK_TRACE_VK_RESOURCES
+     void dumpInfo() const override {
+         SkDebugf("GrVkCommandPool: %p (%d refs)\n", fCommandPool, this->getRefCnt());
+     }
+diff --git a/src/gpu/vk/GrVkResource.h b/src/gpu/vk/GrVkResource.h
+index 7b9949ba1b..4e8fb48c7c 100644
+--- a/src/gpu/vk/GrVkResource.h
++++ b/src/gpu/vk/GrVkResource.h
+@@ -17,7 +17,7 @@ class GrVkGpu;
+ 
+ // uncomment to enable tracing of resource refs
+ #ifdef SK_DEBUG
+-#define SK_TRACE_VK_RESOURCES
++//#define SK_TRACE_VK_RESOURCES
+ #endif
+ 
+ /** \class GrVkResource
commit 3f6d5056b674976538f33a2b0e7e87503f554bf3
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Nov 15 17:20:44 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:32 2019 +0100

    fix memory leak
    
    Change-Id: I6148159737edd4fe225d1140606064cdb77ef615

diff --git a/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx
index e109cf6a76eb..39efe91e51c7 100644
--- a/include/vcl/pdfwriter.hxx
+++ b/include/vcl/pdfwriter.hxx
@@ -74,7 +74,7 @@ class VCL_DLLPUBLIC PDFOutputStream
 
 class VCL_DLLPUBLIC PDFWriter
 {
-    VclPtr<PDFWriterImpl> xImplementation;
+    ScopedVclPtr<PDFWriterImpl> xImplementation;
 
     PDFWriter(const PDFWriter&) = delete;
     PDFWriter& operator=(const PDFWriter&) = delete;
commit 80843a125e8dabd28fd49e545d6836a30a96e243
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Nov 15 14:42:05 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:32 2019 +0100

    make Skia GPU offscreen surfaces work with unittests
    
    Skia is now patched to be able to create also invalid
    sk_app::WindowContext that will just initialize the shared GrContext.
    And always use that GrContext, even for tests, because some tests
    first create a offscreen surfaces and only later create windows,
    which before this patch led to mixing GrContext instances.
    
    Change-Id: Ic79c0719f98f6ac48527c2ea2a9a9a69412adeff

diff --git a/external/skia/Library_skia.mk b/external/skia/Library_skia.mk
index 7d84762a621d..ed24d30fa93f 100644
--- a/external/skia/Library_skia.mk
+++ b/external/skia/Library_skia.mk
@@ -62,7 +62,6 @@ ifeq ($(OS),LINUX)
 $(eval $(call gb_Library_add_libs,skia,\
     -lm \
     -ldl \
-    -lGLU \
     -lGLX \
     -lGL \
     -lX11-xcb \
@@ -814,12 +813,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\
 ))
 
 $(eval $(call gb_Library_add_generated_exception_objects,skia,\
-    UnpackedTarball/skia/tools/gpu/GrContextFactory \
-    UnpackedTarball/skia/tools/gpu/TestContext \
-    UnpackedTarball/skia/tools/gpu/gl/GLTestContext \
-    UnpackedTarball/skia/tools/gpu/gl/command_buffer/GLTestContext_command_buffer \
-    UnpackedTarball/skia/tools/gpu/mock/MockTestContext \
-    UnpackedTarball/skia/tools/gpu/vk/VkTestContext \
     UnpackedTarball/skia/tools/gpu/vk/VkTestUtils \
     UnpackedTarball/skia/tools/sk_app/GLWindowContext \
     UnpackedTarball/skia/tools/sk_app/VulkanWindowContext \
@@ -848,7 +841,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\
 ))
 
 $(eval $(call gb_Library_add_generated_exception_objects,skia,\
-    UnpackedTarball/skia/tools/gpu/gl/win/CreatePlatformGLTestContext_win \
     UnpackedTarball/skia/tools/sk_app/win/GLWindowContext_win \
     UnpackedTarball/skia/tools/sk_app/win/RasterWindowContext_win \
     UnpackedTarball/skia/tools/sk_app/win/VulkanWindowContext_win \
@@ -871,7 +863,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\
 ))
 
 $(eval $(call gb_Library_add_generated_exception_objects,skia,\
-    UnpackedTarball/skia/tools/gpu/gl/glx/CreatePlatformGLTestContext_glx \
     UnpackedTarball/skia/tools/sk_app/unix/GLWindowContext_unix \
     UnpackedTarball/skia/tools/sk_app/unix/RasterWindowContext_unix \
     UnpackedTarball/skia/tools/sk_app/unix/VulkanWindowContext_unix \
diff --git a/external/skia/make-api-visible.patch.1 b/external/skia/make-api-visible.patch.1
index 3c2ff873eabb..2bf3a0f3d73a 100644
--- a/external/skia/make-api-visible.patch.1
+++ b/external/skia/make-api-visible.patch.1
@@ -1,29 +1,3 @@
-diff --git a/tools/gpu/GrContextFactory.h b/tools/gpu/GrContextFactory.h
-index d1b7fd5fa0..1b0bc249d2 100644
---- a/tools/gpu/GrContextFactory.h
-+++ b/tools/gpu/GrContextFactory.h
-@@ -26,7 +26,7 @@ class ContextInfo;
-  * factory is destroyed (though the caller can always grab a ref on the returned
-  * Gr and GL contexts to make them outlive the factory).
-  */
--class GrContextFactory : SkNoncopyable {
-+class SK_API GrContextFactory : SkNoncopyable {
- public:
-     // The availability of context types is subject to platform and build configuration
-     // restrictions.
-diff --git a/tools/gpu/gl/GLTestContext.cpp b/tools/gpu/gl/GLTestContext.cpp
-index d4aa605188..5d246f9737 100644
---- a/tools/gpu/gl/GLTestContext.cpp
-+++ b/tools/gpu/gl/GLTestContext.cpp
-@@ -298,7 +298,7 @@ void GLTestContext::teardown() {
- void GLTestContext::testAbandon() {
-     INHERITED::testAbandon();
-     if (fGL) {
--        fGL->abandon();
-+//        fGL->abandon();
-     }
- }
- 
 diff --git a/tools/sk_app/unix/WindowContextFactory_unix.h b/tools/sk_app/unix/WindowContextFactory_unix.h
 index 47310970d5..e02e6eb5b7 100644
 --- a/tools/sk_app/unix/WindowContextFactory_unix.h
diff --git a/external/skia/share-grcontext.patch.1 b/external/skia/share-grcontext.patch.1
index 357c3a885880..ed81e772aa20 100644
--- a/external/skia/share-grcontext.patch.1
+++ b/external/skia/share-grcontext.patch.1
@@ -1,13 +1,168 @@
-diff --git a/tools/sk_app/VulkanWindowContext.cpp b/tools/sk_app/VulkanWindowContext.cpp
-index 793c88c158..21164cac67 100644
---- a/tools/sk_app/VulkanWindowContext.cpp
-+++ b/tools/sk_app/VulkanWindowContext.cpp
-@@ -1,4 +1,3 @@
+--- ./tools/sk_app/VulkanWindowContext.h.sav	2019-11-14 16:46:31.218722399 +0100
++++ ./tools/sk_app/VulkanWindowContext.h	2019-11-15 11:58:46.656455921 +0100
+@@ -23,14 +23,30 @@ class GrRenderTarget;
+ 
+ namespace sk_app {
+ 
+-class VulkanWindowContext : public WindowContext {
++class SK_API VulkanWindowContext : public WindowContext {
++    struct Shared;
+ public:
+     ~VulkanWindowContext() override;
+ 
++    class SharedGrContext {
++    public:
++        SharedGrContext() {}
++        GrContext* getGrContext() { return shared ? shared->fContext.get() : nullptr; }
++        ~SharedGrContext() { shared.reset(); checkDestroyShared(); }
++        bool operator!() const { return !shared; }
++        void reset() { shared.reset(); }
++    private:
++        friend class VulkanWindowContext;
++        SharedGrContext(sk_sp<Shared>& sh ) : shared( sh ) {}
++        sk_sp<Shared> shared;
++    };
++
++    static SharedGrContext getSharedGrContext() { return SharedGrContext( fGlobalShared ); }
++
+     sk_sp<SkSurface> getBackbufferSurface() override;
+     void swapBuffers() override;
+ 
+-    bool isValid() override { return fDevice != VK_NULL_HANDLE; }
++    bool isValid() override { return fSurface != VK_NULL_HANDLE; }
+ 
+     void resize(int w, int h) override {
+         this->createSwapchain(w, h, fDisplayParams);
+@@ -53,6 +69,7 @@ public:
+ private:
+     void initializeContext();
+     void destroyContext();
++    static void checkDestroyShared();
+ 
+     struct BackbufferInfo {
+         uint32_t        fImageIndex;          // image this is associated with
+@@ -64,11 +81,6 @@ private:
+     void createBuffers(VkFormat format, SkColorType colorType);
+     void destroyBuffers();
+ 
+-    VkInstance fInstance = VK_NULL_HANDLE;
+-    VkPhysicalDevice fPhysicalDevice = VK_NULL_HANDLE;
+-    VkDevice fDevice = VK_NULL_HANDLE;
+-    VkDebugReportCallbackEXT fDebugCallback = VK_NULL_HANDLE;
 -
- /*
-  * Copyright 2015 Google Inc.
-  *
-@@ -24,8 +23,10 @@
+     // Create functions
+     CreateVkSurfaceFn fCreateVkSurfaceFn;
+     CanPresentFn      fCanPresentFn;
+@@ -90,20 +102,41 @@ private:
+     PFN_vkAcquireNextImageKHR fAcquireNextImageKHR = nullptr;
+     PFN_vkQueuePresentKHR fQueuePresentKHR = nullptr;
+ 
+-    PFN_vkDestroyInstance fDestroyInstance = nullptr;
+     PFN_vkDeviceWaitIdle fDeviceWaitIdle = nullptr;
+-    PFN_vkDestroyDebugReportCallbackEXT fDestroyDebugReportCallbackEXT = nullptr;
+     PFN_vkQueueWaitIdle fQueueWaitIdle = nullptr;
+-    PFN_vkDestroyDevice fDestroyDevice = nullptr;
+     PFN_vkGetDeviceQueue fGetDeviceQueue = nullptr;
+ 
++    // We need to use just one GrContext, so share all the relevant data.
++    struct Shared : public SkRefCnt
++    {
++    PFN_vkDestroyInstance fDestroyInstance = nullptr;
++    PFN_vkDestroyDevice fDestroyDevice = nullptr;
++    PFN_vkDestroyDebugReportCallbackEXT fDestroyDebugReportCallbackEXT = nullptr;
++
++    VkInstance fInstance = VK_NULL_HANDLE;
++    VkPhysicalDevice fPhysicalDevice = VK_NULL_HANDLE;
++    VkDevice fDevice = VK_NULL_HANDLE;
++    VkDebugReportCallbackEXT fDebugCallback = VK_NULL_HANDLE;
++
+     sk_sp<const GrVkInterface> fInterface;
+ 
+-    VkSurfaceKHR      fSurface;
+-    VkSwapchainKHR    fSwapchain;
++    // Original code had this as a function-local variable, but that seems wrong.
++    // It should exist as long as the context exists.
++    VkPhysicalDeviceFeatures2 features;
++
+     uint32_t          fGraphicsQueueIndex;
+     VkQueue           fGraphicsQueue;
+     uint32_t          fPresentQueueIndex;
++
++    sk_sp<GrContext> fContext;
++    };
++
++    sk_sp<Shared> fShared;
++
++    static sk_sp<Shared> fGlobalShared;
++
++    VkSurfaceKHR      fSurface;
++    VkSwapchainKHR    fSwapchain;
+     VkQueue           fPresentQueue;
+ 
+     uint32_t               fImageCount;
+--- ./tools/sk_app/unix/VulkanWindowContext_unix.cpp.sav	2019-10-21 12:03:51.753745188 +0200
++++ ./tools/sk_app/unix/VulkanWindowContext_unix.cpp	2019-11-15 12:08:01.605967642 +0100
+@@ -30,7 +30,7 @@ std::unique_ptr<WindowContext> MakeVulka
+         return nullptr;
+     }
+ 
+-    auto createVkSurface = [&info, instProc](VkInstance instance) -> VkSurfaceKHR {
++    VulkanWindowContext::CreateVkSurfaceFn createVkSurface = [&info, instProc](VkInstance instance) -> VkSurfaceKHR {
+         static PFN_vkCreateXcbSurfaceKHR createXcbSurfaceKHR = nullptr;
+         if (!createXcbSurfaceKHR) {
+             createXcbSurfaceKHR =
+@@ -54,6 +54,9 @@ std::unique_ptr<WindowContext> MakeVulka
+ 
+         return surface;
+     };
++    // Allow creating just the shared context, without an associated window.
++    if(info.fWindow == None)
++        createVkSurface = nullptr;
+ 
+     auto canPresent = [&info, instProc](VkInstance instance, VkPhysicalDevice physDev,
+                               uint32_t queueFamilyIndex) {
+@@ -76,7 +79,7 @@ std::unique_ptr<WindowContext> MakeVulka
+     };
+     std::unique_ptr<WindowContext> ctx(
+             new VulkanWindowContext(displayParams, createVkSurface, canPresent, instProc, devProc));
+-    if (!ctx->isValid()) {
++    if (!ctx->isValid() && createVkSurface != nullptr) {
+         return nullptr;
+     }
+     return ctx;
+--- ./tools/sk_app/win/VulkanWindowContext_win.cpp.sav	2019-10-21 12:03:51.753745188 +0200
++++ ./tools/sk_app/win/VulkanWindowContext_win.cpp	2019-11-15 12:08:21.466022257 +0100
+@@ -30,7 +30,7 @@ std::unique_ptr<WindowContext> MakeVulka
+         return nullptr;
+     }
+ 
+-    auto createVkSurface = [hwnd, instProc] (VkInstance instance) -> VkSurfaceKHR {
++    VulkanWindowContext::CreateVkSurfaceFn createVkSurface = [hwnd, instProc] (VkInstance instance) -> VkSurfaceKHR {
+         static PFN_vkCreateWin32SurfaceKHR createWin32SurfaceKHR = nullptr;
+         if (!createWin32SurfaceKHR) {
+             createWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)
+@@ -54,6 +54,9 @@ std::unique_ptr<WindowContext> MakeVulka
+ 
+         return surface;
+     };
++    // Allow creating just the shared context, without an associated window.
++    if(hwnd == nullptr)
++        createVkSurface = nullptr;
+ 
+     auto canPresent = [instProc] (VkInstance instance, VkPhysicalDevice physDev,
+                                   uint32_t queueFamilyIndex) {
+@@ -71,7 +74,7 @@ std::unique_ptr<WindowContext> MakeVulka
+ 
+     std::unique_ptr<WindowContext> ctx(
+             new VulkanWindowContext(params, createVkSurface, canPresent, instProc, devProc));
+-    if (!ctx->isValid()) {
++    if (!ctx->isValid() && createVkSurface != nullptr) {
+         return nullptr;
+     }
+     return ctx;
+--- ./tools/sk_app/VulkanWindowContext.cpp.sav	2019-11-14 16:46:31.218722399 +0100
++++ ./tools/sk_app/VulkanWindowContext.cpp	2019-11-15 11:58:46.656455921 +0100
+@@ -24,8 +24,10 @@
  #undef CreateSemaphore
  #endif
  
@@ -20,7 +175,7 @@ index 793c88c158..21164cac67 100644
  
  namespace sk_app {
  
-@@ -49,6 +50,14 @@ VulkanWindowContext::VulkanWindowContext(const DisplayParams& params,
+@@ -49,6 +51,14 @@ VulkanWindowContext::VulkanWindowContext
  }
  
  void VulkanWindowContext::initializeContext() {
@@ -35,7 +190,7 @@ index 793c88c158..21164cac67 100644
      // any config code here (particularly for msaa)?
  
      PFN_vkGetInstanceProcAddr getInstanceProc = fGetInstanceProcAddr;
-@@ -62,24 +71,25 @@ void VulkanWindowContext::initializeContext() {
+@@ -62,24 +72,25 @@ void VulkanWindowContext::initializeCont
      };
      GrVkBackendContext backendContext;
      GrVkExtensions extensions;
@@ -71,7 +226,7 @@ index 793c88c158..21164cac67 100644
  
      PFN_vkGetPhysicalDeviceProperties localGetPhysicalDeviceProperties =
              reinterpret_cast<PFN_vkGetPhysicalDeviceProperties>(
-@@ -87,21 +97,31 @@ void VulkanWindowContext::initializeContext() {
+@@ -87,21 +98,31 @@ void VulkanWindowContext::initializeCont
                                              backendContext.fInstance,
                                              VK_NULL_HANDLE));
      if (!localGetPhysicalDeviceProperties) {
@@ -108,7 +263,7 @@ index 793c88c158..21164cac67 100644
      GET_PROC(DestroySurfaceKHR);
      GET_PROC(GetPhysicalDeviceSurfaceSupportKHR);
      GET_PROC(GetPhysicalDeviceSurfaceCapabilitiesKHR);
-@@ -109,7 +129,6 @@ void VulkanWindowContext::initializeContext() {
+@@ -109,7 +130,6 @@ void VulkanWindowContext::initializeCont
      GET_PROC(GetPhysicalDeviceSurfacePresentModesKHR);
      GET_DEV_PROC(DeviceWaitIdle);
      GET_DEV_PROC(QueueWaitIdle);
@@ -116,12 +271,15 @@ index 793c88c158..21164cac67 100644
      GET_DEV_PROC(CreateSwapchainKHR);
      GET_DEV_PROC(DestroySwapchainKHR);
      GET_DEV_PROC(GetSwapchainImagesKHR);
-@@ -117,46 +136,40 @@ void VulkanWindowContext::initializeContext() {
+@@ -117,46 +137,44 @@ void VulkanWindowContext::initializeCont
      GET_DEV_PROC(QueuePresentKHR);
      GET_DEV_PROC(GetDeviceQueue);
  
 -    fContext = GrContext::MakeVulkan(backendContext, fDisplayParams.fGrContextOptions);
--
++    // No actual window, used just to create the shared GrContext.
++    if(fCreateVkSurfaceFn == nullptr)
++        return;
+ 
 -    fSurface = fCreateVkSurfaceFn(fInstance);
 +    fSurface = fCreateVkSurfaceFn(fShared->fInstance);
      if (VK_NULL_HANDLE == fSurface) {
@@ -130,6 +288,9 @@ index 793c88c158..21164cac67 100644
          return;
      }
  
++    // create presentQueue
++    fGetDeviceQueue(fShared->fDevice, fShared->fPresentQueueIndex, 0, &fPresentQueue);
++
      VkBool32 supported;
 -    VkResult res = fGetPhysicalDeviceSurfaceSupportKHR(fPhysicalDevice, fPresentQueueIndex,
 +    VkResult res = fGetPhysicalDeviceSurfaceSupportKHR(fShared->fPhysicalDevice, fShared->fPresentQueueIndex,
@@ -145,11 +306,10 @@ index 793c88c158..21164cac67 100644
 -        sk_gpu_test::FreeVulkanFeaturesStructs(&features);
          return;
      }
- 
-     // create presentQueue
+-
+-    // create presentQueue
 -    fGetDeviceQueue(fDevice, fPresentQueueIndex, 0, &fPresentQueue);
 -    sk_gpu_test::FreeVulkanFeaturesStructs(&features);
-+    fGetDeviceQueue(fShared->fDevice, fShared->fPresentQueueIndex, 0, &fPresentQueue);
  }
  
  bool VulkanWindowContext::createSwapchain(int width, int height,
@@ -168,7 +328,7 @@ index 793c88c158..21164cac67 100644
                                                nullptr);
      if (VK_SUCCESS != res) {
          return false;
-@@ -164,14 +177,14 @@ bool VulkanWindowContext::createSwapchain(int width, int height,
+@@ -164,14 +182,14 @@ bool VulkanWindowContext::createSwapchai
  
      SkAutoMalloc surfaceFormatAlloc(surfaceFormatCount * sizeof(VkSurfaceFormatKHR));
      VkSurfaceFormatKHR* surfaceFormats = (VkSurfaceFormatKHR*)surfaceFormatAlloc.get();
@@ -185,7 +345,7 @@ index 793c88c158..21164cac67 100644
                                                     nullptr);
      if (VK_SUCCESS != res) {
          return false;
-@@ -179,7 +192,7 @@ bool VulkanWindowContext::createSwapchain(int width, int height,
+@@ -179,7 +197,7 @@ bool VulkanWindowContext::createSwapchai
  
      SkAutoMalloc presentModeAlloc(presentModeCount * sizeof(VkPresentModeKHR));
      VkPresentModeKHR* presentModes = (VkPresentModeKHR*)presentModeAlloc.get();
@@ -194,7 +354,7 @@ index 793c88c158..21164cac67 100644
                                                     presentModes);
      if (VK_SUCCESS != res) {
          return false;
-@@ -286,8 +299,8 @@ bool VulkanWindowContext::createSwapchain(int width, int height,
+@@ -286,8 +304,8 @@ bool VulkanWindowContext::createSwapchai
      swapchainCreateInfo.imageArrayLayers = 1;
      swapchainCreateInfo.imageUsage = usageFlags;
  
@@ -205,7 +365,7 @@ index 793c88c158..21164cac67 100644
          swapchainCreateInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT;
          swapchainCreateInfo.queueFamilyIndexCount = 2;
          swapchainCreateInfo.pQueueFamilyIndices = queueFamilies;
-@@ -303,18 +316,18 @@ bool VulkanWindowContext::createSwapchain(int width, int height,
+@@ -303,18 +321,18 @@ bool VulkanWindowContext::createSwapchai
      swapchainCreateInfo.clipped = true;
      swapchainCreateInfo.oldSwapchain = fSwapchain;
  
@@ -227,7 +387,7 @@ index 793c88c158..21164cac67 100644
      }
  
      this->createBuffers(swapchainCreateInfo.imageFormat, colorType);
-@@ -323,10 +336,10 @@ bool VulkanWindowContext::createSwapchain(int width, int height,
+@@ -323,10 +341,10 @@ bool VulkanWindowContext::createSwapchai
  }
  
  void VulkanWindowContext::createBuffers(VkFormat format, SkColorType colorType) {
@@ -240,7 +400,7 @@ index 793c88c158..21164cac67 100644
  
      // set up initial image layouts and create surfaces
      fImageLayouts = new VkImageLayout[fImageCount];
-@@ -341,7 +354,7 @@ void VulkanWindowContext::createBuffers(VkFormat format, SkColorType colorType)
+@@ -341,7 +359,7 @@ void VulkanWindowContext::createBuffers(
          info.fImageTiling = VK_IMAGE_TILING_OPTIMAL;
          info.fFormat = format;
          info.fLevelCount = 1;
@@ -249,7 +409,7 @@ index 793c88c158..21164cac67 100644
  
          if (fSampleCount == 1) {
              GrBackendRenderTarget backendRT(fWidth, fHeight, fSampleCount, info);
-@@ -372,8 +385,8 @@ void VulkanWindowContext::createBuffers(VkFormat format, SkColorType colorType)
+@@ -372,8 +390,8 @@ void VulkanWindowContext::createBuffers(
      fBackbuffers = new BackbufferInfo[fImageCount + 1];
      for (uint32_t i = 0; i < fImageCount + 1; ++i) {
          fBackbuffers[i].fImageIndex = -1;
@@ -260,7 +420,7 @@ index 793c88c158..21164cac67 100644
                                              nullptr, &fBackbuffers[i].fRenderSemaphore));
      }
      fCurrentBackbufferIndex = fImageCount;
-@@ -384,8 +397,8 @@ void VulkanWindowContext::destroyBuffers() {
+@@ -384,8 +402,8 @@ void VulkanWindowContext::destroyBuffers
      if (fBackbuffers) {
          for (uint32_t i = 0; i < fImageCount + 1; ++i) {
              fBackbuffers[i].fImageIndex = -1;
@@ -271,7 +431,7 @@ index 793c88c158..21164cac67 100644
                                          fBackbuffers[i].fRenderSemaphore,
                                          nullptr));
          }
-@@ -410,41 +423,55 @@ VulkanWindowContext::~VulkanWindowContext() {
+@@ -410,41 +428,55 @@ VulkanWindowContext::~VulkanWindowContex
  void VulkanWindowContext::destroyContext() {
      if (this->isValid()) {
          fQueueWaitIdle(fPresentQueue);
@@ -340,7 +500,7 @@ index 793c88c158..21164cac67 100644
  }
  
  VulkanWindowContext::BackbufferInfo* VulkanWindowContext::getAvailableBackbuffer() {
-@@ -470,34 +497,34 @@ sk_sp<SkSurface> VulkanWindowContext::getBackbufferSurface() {
+@@ -470,34 +502,34 @@ sk_sp<SkSurface> VulkanWindowContext::ge
      semaphoreInfo.pNext = nullptr;
      semaphoreInfo.flags = 0;
      VkSemaphore semaphore;
@@ -381,119 +541,10 @@ index 793c88c158..21164cac67 100644
              return nullptr;
          }
      }
-@@ -541,4 +568,6 @@ void VulkanWindowContext::swapBuffers() {
+@@ -541,4 +573,6 @@ void VulkanWindowContext::swapBuffers()
      fQueuePresentKHR(fPresentQueue, &presentInfo);
  }
  
 +SK_API sk_sp<VulkanWindowContext::Shared> VulkanWindowContext::fGlobalShared;
 +
  }   //namespace sk_app
-diff --git a/tools/sk_app/VulkanWindowContext.h b/tools/sk_app/VulkanWindowContext.h
-index 2db9e79ae6..7950dc159b 100644
---- a/tools/sk_app/VulkanWindowContext.h
-+++ b/tools/sk_app/VulkanWindowContext.h
-@@ -1,4 +1,3 @@
--
- /*
-  * Copyright 2016 Google Inc.
-  *
-@@ -23,14 +22,30 @@ class GrRenderTarget;
- 
- namespace sk_app {
- 
--class VulkanWindowContext : public WindowContext {
-+class SK_API VulkanWindowContext : public WindowContext {
-+    struct Shared;
- public:
-     ~VulkanWindowContext() override;
- 
-+    class SharedGrContext {
-+    public:
-+        SharedGrContext() {}
-+        GrContext* getGrContext() { return shared ? shared->fContext.get() : nullptr; }
-+        ~SharedGrContext() { shared.reset(); checkDestroyShared(); }
-+        bool operator!() const { return !shared; }
-+        void reset() { shared.reset(); }
-+    private:
-+        friend class VulkanWindowContext;
-+        SharedGrContext(sk_sp<Shared>& sh ) : shared( sh ) {}
-+        sk_sp<Shared> shared;
-+    };
-+
-+    static SharedGrContext getSharedGrContext() { return SharedGrContext( fGlobalShared ); }
-+
-     sk_sp<SkSurface> getBackbufferSurface() override;
-     void swapBuffers() override;
- 
--    bool isValid() override { return fDevice != VK_NULL_HANDLE; }
-+    bool isValid() override { return fShared && fShared->fDevice != VK_NULL_HANDLE; }
- 
-     void resize(int w, int h) override {
-         this->createSwapchain(w, h, fDisplayParams);
-@@ -53,6 +68,7 @@ public:
- private:
-     void initializeContext();
-     void destroyContext();
-+    static void checkDestroyShared();
- 
-     struct BackbufferInfo {
-         uint32_t        fImageIndex;          // image this is associated with
-@@ -64,11 +80,6 @@ private:
-     void createBuffers(VkFormat format, SkColorType colorType);
-     void destroyBuffers();
- 
--    VkInstance fInstance = VK_NULL_HANDLE;
--    VkPhysicalDevice fPhysicalDevice = VK_NULL_HANDLE;
--    VkDevice fDevice = VK_NULL_HANDLE;
--    VkDebugReportCallbackEXT fDebugCallback = VK_NULL_HANDLE;
--
-     // Create functions
-     CreateVkSurfaceFn fCreateVkSurfaceFn;
-     CanPresentFn      fCanPresentFn;
-@@ -90,20 +101,41 @@ private:
-     PFN_vkAcquireNextImageKHR fAcquireNextImageKHR = nullptr;
-     PFN_vkQueuePresentKHR fQueuePresentKHR = nullptr;
- 
--    PFN_vkDestroyInstance fDestroyInstance = nullptr;
-     PFN_vkDeviceWaitIdle fDeviceWaitIdle = nullptr;
--    PFN_vkDestroyDebugReportCallbackEXT fDestroyDebugReportCallbackEXT = nullptr;
-     PFN_vkQueueWaitIdle fQueueWaitIdle = nullptr;
--    PFN_vkDestroyDevice fDestroyDevice = nullptr;
-     PFN_vkGetDeviceQueue fGetDeviceQueue = nullptr;
- 
-+    // We need to use just one GrContext, so share all the relevant data.
-+    struct Shared : public SkRefCnt
-+    {
-+    PFN_vkDestroyInstance fDestroyInstance = nullptr;
-+    PFN_vkDestroyDevice fDestroyDevice = nullptr;
-+    PFN_vkDestroyDebugReportCallbackEXT fDestroyDebugReportCallbackEXT = nullptr;
-+
-+    VkInstance fInstance = VK_NULL_HANDLE;
-+    VkPhysicalDevice fPhysicalDevice = VK_NULL_HANDLE;
-+    VkDevice fDevice = VK_NULL_HANDLE;
-+    VkDebugReportCallbackEXT fDebugCallback = VK_NULL_HANDLE;
-+
-     sk_sp<const GrVkInterface> fInterface;
- 
--    VkSurfaceKHR      fSurface;
--    VkSwapchainKHR    fSwapchain;
-+    // Original code had this as a function-local variable, but that seems wrong.
-+    // It should exist as long as the context exists.
-+    VkPhysicalDeviceFeatures2 features;
-+
-     uint32_t          fGraphicsQueueIndex;
-     VkQueue           fGraphicsQueue;
-     uint32_t          fPresentQueueIndex;
-+
-+    sk_sp<GrContext> fContext;
-+    };
-+
-+    sk_sp<Shared> fShared;
-+
-+    static sk_sp<Shared> fGlobalShared;
-+
-+    VkSurfaceKHR      fSurface;
-+    VkSwapchainKHR    fSwapchain;
-     VkQueue           fPresentQueue;
- 
-     uint32_t               fImageCount;
diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx
index 7c41e98a91b5..0036b2d89f7a 100644
--- a/vcl/inc/skia/gdiimpl.hxx
+++ b/vcl/inc/skia/gdiimpl.hxx
@@ -211,6 +211,8 @@ protected:
     void destroySurface();
     // Reimplemented for X11.
     virtual bool avoidRecreateByResize() const { return false; }
+    void createWindowSurface();
+    virtual void createWindowContext() = 0;
     void createOffscreenSurface();
 
     void privateDrawAlphaRect(long nX, long nY, long nWidth, long nHeight, double nTransparency,
@@ -256,11 +258,12 @@ protected:
     SalGraphics& mParent;
     /// Pointer to the SalFrame or SalVirtualDevice
     SalGeometryProvider* mProvider;
+    std::unique_ptr<sk_app::WindowContext> mWindowContext;
+    sk_app::VulkanWindowContext::SharedGrContext mOffscreenGrContext;
     // The Skia surface that is target of all the rendering.
     sk_sp<SkSurface> mSurface;
     bool mIsGPU; // whether the surface is GPU-backed
     // Keep reference to shared GrContext.
-    sk_app::VulkanWindowContext::SharedGrContext mOffscreenGrContext;
     vcl::Region mClipRegion;
     Color mLineColor;
     Color mFillColor;
diff --git a/vcl/inc/skia/win/gdiimpl.hxx b/vcl/inc/skia/win/gdiimpl.hxx
index 321f35f24366..75531ae9a164 100644
--- a/vcl/inc/skia/win/gdiimpl.hxx
+++ b/vcl/inc/skia/win/gdiimpl.hxx
@@ -21,10 +21,6 @@
 #include <svdata.hxx>
 
 class ControlCacheKey;
-namespace sk_app
-{
-class WindowContext;
-}
 
 class SkiaCompatibleDC : public CompatibleDC
 {
@@ -79,11 +75,8 @@ public:
                                   const SalTwoRect& rPosAry) override;
 
 protected:
-    virtual void createSurface() override;
+    virtual void createWindowContext() override;
     virtual void performFlush() override;
-
-private:
-    std::unique_ptr<sk_app::WindowContext> mWindowContext;
 };
 
 typedef std::pair<ControlCacheKey, SkBitmap> SkiaControlCachePair;
diff --git a/vcl/inc/skia/x11/gdiimpl.hxx b/vcl/inc/skia/x11/gdiimpl.hxx
index 1dc5064e6667..4d88740b8ba9 100644
--- a/vcl/inc/skia/x11/gdiimpl.hxx
+++ b/vcl/inc/skia/x11/gdiimpl.hxx
@@ -16,11 +16,6 @@
 #include <unx/x11/x11gdiimpl.h>
 #include <skia/gdiimpl.hxx>
 
-namespace sk_app
-{
-class WindowContext;
-}
-
 class VCL_PLUGIN_PUBLIC X11SkiaSalGraphicsImpl : public SkiaSalGraphicsImpl, public X11GraphicsImpl
 {
 private:
@@ -35,12 +30,9 @@ public:
     virtual void freeResources() override;
 
 protected:
-    virtual void createSurface() override;
+    virtual void createWindowContext() override;
     virtual void performFlush() override;
     virtual bool avoidRecreateByResize() const override;
-
-private:
-    std::unique_ptr<sk_app::WindowContext> mWindowContext;
 };
 
 #endif // INCLUDED_VCL_INC_SKIA_X11_GDIIMPL_HXX
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index caed9fb33431..948c85df72e4 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -31,7 +31,6 @@
 #include <SkRegion.h>
 #include <SkDashPathEffect.h>
 #include <GrBackendSurface.h>
-#include <GrContextFactory.h>
 
 #include <basegfx/polygon/b2dpolygontools.hxx>
 
@@ -182,6 +181,7 @@ SkiaSalGraphicsImpl::SkiaSalGraphicsImpl(SalGraphics& rParent, SalGeometryProvid
 SkiaSalGraphicsImpl::~SkiaSalGraphicsImpl()
 {
     assert(!mSurface);
+    assert(!mWindowContext);
     assert(!mOffscreenGrContext);
 }
 
@@ -191,6 +191,17 @@ void SkiaSalGraphicsImpl::recreateSurface()
 {
     destroySurface();
     createSurface();
+}
+
+void SkiaSalGraphicsImpl::createSurface()
+{
+    if (isOffscreen())
+        createOffscreenSurface();
+    else
+        createWindowSurface();
+#ifdef DBG_UTIL
+    prefillSurface();
+#endif
     mSurface->getCanvas()->save(); // see SetClipRegion()
     mClipRegion = vcl::Region(tools::Rectangle(0, 0, GetWidth(), GetHeight()));
 
@@ -199,20 +210,35 @@ void SkiaSalGraphicsImpl::recreateSurface()
     mFlush->SetPriority(TaskPriority::POST_PAINT);
 }
 
-void SkiaSalGraphicsImpl::createSurface()
+void SkiaSalGraphicsImpl::createWindowSurface()
 {
-    // Create raster surface. Subclasses will create GPU-backed surfaces as appropriate.
-    mSurface = SkSurface::MakeRasterN32Premul(GetWidth(), GetHeight());
-    mIsGPU = false;
-#ifdef DBG_UTIL
-    prefillSurface();
-#endif
+    assert(!isOffscreen());
+    assert(!mSurface);
+    assert(!mWindowContext);
+    createWindowContext();
+    if (mWindowContext)
+        mSurface = mWindowContext->getBackbufferSurface();
+    if (!mSurface)
+    {
+        switch (SkiaHelper::renderMethodToUse())
+        {
+            case SkiaHelper::RenderVulkan:
+                SAL_WARN("vcl.skia", "cannot create Vulkan GPU window surface, disabling Vulkan");
+                // fall back to raster
+                SkiaHelper::disableRenderMethod(SkiaHelper::RenderVulkan);
+                destroySurface(); // destroys also WindowContext
+                return createWindowSurface(); // try again
+            case SkiaHelper::RenderRaster:
+                abort(); // this should not really happen
+        }
+    }
 }
 
 void SkiaSalGraphicsImpl::createOffscreenSurface()
 {
     assert(isOffscreen());
-    destroySurface();
+    assert(!mSurface);
+    assert(!mWindowContext);
     switch (SkiaHelper::renderMethodToUse())
     {
         case SkiaHelper::RenderVulkan:
@@ -228,11 +254,16 @@ void SkiaSalGraphicsImpl::createOffscreenSurface()
                 static bool isUnitTest = (getenv("LO_TESTNAME") != nullptr);
                 if (isUnitTest)
                 {
-                    static vcl::DeleteOnDeinit<sk_gpu_test::GrContextFactory> factory(
-                        new sk_gpu_test::GrContextFactory);
-                    // The factory owns the context.
-                    grContext
-                        = factory.get()->get(sk_gpu_test::GrContextFactory::kVulkan_ContextType);
+                    // Create temporary WindowContext with no window. That will fail,
+                    // but it will initialize the shared GrContext.
+                    createWindowContext();
+                    // Keep a reference.
+                    sk_app::VulkanWindowContext::SharedGrContext context
+                        = sk_app::VulkanWindowContext::getSharedGrContext();
+                    // Destroy the temporary WindowContext.
+                    destroySurface();
+                    mOffscreenGrContext = context;
+                    grContext = mOffscreenGrContext.getGrContext();
                 }
             }
             if (grContext)
@@ -241,7 +272,7 @@ void SkiaSalGraphicsImpl::createOffscreenSurface()
                     grContext, SkBudgeted::kNo,
                     SkImageInfo::MakeN32Premul(GetWidth(), GetHeight()));
                 mIsGPU = true;
-                assert(mSurface.get());
+                assert(mSurface);
 #ifdef DBG_UTIL
                 prefillSurface();
 #endif
@@ -254,7 +285,10 @@ void SkiaSalGraphicsImpl::createOffscreenSurface()
         default:
             break;
     }
-    return SkiaSalGraphicsImpl::createSurface(); // create a raster one
+    // Create raster surface. Subclasses will create GPU-backed surfaces as appropriate.
+    mSurface = SkSurface::MakeRasterN32Premul(GetWidth(), GetHeight());
+    assert(mSurface);
+    mIsGPU = false;
 }
 
 void SkiaSalGraphicsImpl::destroySurface()
@@ -266,6 +300,7 @@ void SkiaSalGraphicsImpl::destroySurface()
         // if this fails, something forgot to use SkAutoCanvasRestore
         assert(mSurface->getCanvas()->getTotalMatrix().isIdentity());
     }
+    // TODO Is this still needed?
     // If we use e.g. Vulkan, we must destroy the surface before the context,
     // otherwise destroying the surface will reference the context. This is
     // handled by calling destroySurface() before destroying the context.
@@ -276,6 +311,7 @@ void SkiaSalGraphicsImpl::destroySurface()
     if (mSurface)
         mSurface->flush();
     mSurface.reset();
+    mWindowContext.reset();
     mIsGPU = false;
     mOffscreenGrContext.reset();
 }
diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx
index cba8bed29355..dd63f4d6121e 100644
--- a/vcl/skia/win/gdiimpl.cxx
+++ b/vcl/skia/win/gdiimpl.cxx
@@ -43,43 +43,26 @@ void WinSkiaSalGraphicsImpl::Init()
     SkiaSalGraphicsImpl::Init();
 }
 
-void WinSkiaSalGraphicsImpl::createSurface()
+void WinSkiaSalGraphicsImpl::createWindowContext()
 {
-    if (isOffscreen())
-        return createOffscreenSurface();
-    destroySurface();
     // When created, Init() gets called with size (0,0), which is invalid size
     // for Skia. Creating the actual surface is delayed, so the size should be always
     // valid here, but better check.
-    assert(GetWidth() != 0 && GetHeight() != 0);
+    assert((GetWidth() != 0 && GetHeight() != 0) || isOffscreen());
     sk_app::DisplayParams displayParams;
     switch (SkiaHelper::renderMethodToUse())
     {
         case SkiaHelper::RenderRaster:
             mWindowContext = sk_app::window_context_factory::MakeRasterForWin(mWinParent.gethWnd(),
                                                                               displayParams);
-            assert(SkToBool(mWindowContext));
-            mSurface = mWindowContext->getBackbufferSurface();
-            assert(mSurface.get());
             mIsGPU = false;
             break;
         case SkiaHelper::RenderVulkan:
             mWindowContext = sk_app::window_context_factory::MakeVulkanForWin(mWinParent.gethWnd(),
                                                                               displayParams);
-            if (mWindowContext)
-                mSurface = mWindowContext->getBackbufferSurface();
-            if (!mSurface)
-            {
-                SAL_WARN("vcl.skia", "cannot create Vulkan GPU surface, disabling Vulkan");
-                SkiaHelper::disableRenderMethod(SkiaHelper::RenderVulkan);
-                return createSurface(); // try again
-            }
             mIsGPU = true;
             break;
     }
-#ifdef DBG_UTIL
-    prefillSurface();
-#endif
 }
 
 void WinSkiaSalGraphicsImpl::DeInit()
diff --git a/vcl/skia/x11/gdiimpl.cxx b/vcl/skia/x11/gdiimpl.cxx
index e679fa8dbb2d..3f706399f136 100644
--- a/vcl/skia/x11/gdiimpl.cxx
+++ b/vcl/skia/x11/gdiimpl.cxx
@@ -38,11 +38,8 @@ void X11SkiaSalGraphicsImpl::Init()
     SkiaSalGraphicsImpl::Init();
 }
 
-void X11SkiaSalGraphicsImpl::createSurface()
+void X11SkiaSalGraphicsImpl::createWindowContext()
 {
-    if (isOffscreen())
-        return createOffscreenSurface();
-    destroySurface();
     sk_app::DisplayParams displayParams;
     // Use a macro to hide an unreachable code warning.
     // TODO The Skia Xlib code actually requires the non-native color type to work properly.
@@ -53,7 +50,10 @@ void X11SkiaSalGraphicsImpl::createSurface()
     sk_app::window_context_factory::XlibWindowInfo winInfo;
     winInfo.fDisplay = mX11Parent.GetXDisplay();
     winInfo.fWindow = mX11Parent.GetDrawable();
-    assert(winInfo.fDisplay && winInfo.fWindow != None);
+    assert(winInfo.fDisplay);
+    // Allow window being None if offscreen, this is used to temporarily create GrContext
+    // for an offscreen surface.
+    assert(winInfo.fWindow != None || isOffscreen());
     winInfo.fFBConfig = nullptr; // not used
     winInfo.fVisualInfo = const_cast<SalVisual*>(&mX11Parent.GetVisual());
 #ifdef DBG_UTIL
@@ -70,28 +70,14 @@ void X11SkiaSalGraphicsImpl::createSurface()
         case SkiaHelper::RenderRaster:
             mWindowContext
                 = sk_app::window_context_factory::MakeRasterForXlib(winInfo, displayParams);
-            assert(SkToBool(mWindowContext));
-            mSurface = mWindowContext->getBackbufferSurface();
-            assert(mSurface.get());
             mIsGPU = false;
             break;
         case SkiaHelper::RenderVulkan:
             mWindowContext
                 = sk_app::window_context_factory::MakeVulkanForXlib(winInfo, displayParams);
-            if (mWindowContext)
-                mSurface = mWindowContext->getBackbufferSurface();
-            if (!mSurface)
-            {
-                SAL_WARN("vcl.skia", "cannot create Vulkan GPU surface, disabling Vulkan");
-                SkiaHelper::disableRenderMethod(SkiaHelper::RenderVulkan);
-                return createSurface(); // try again
-            }
             mIsGPU = true;
             break;
     }
-#ifdef DBG_UTIL
-    prefillSurface();
-#endif
 }
 
 bool X11SkiaSalGraphicsImpl::avoidRecreateByResize() const
commit 9ec39a8f3507d24d88366cf51e163b88365ff3ed
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Wed Nov 13 17:24:42 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:32 2019 +0100

    add invert() tests to visualbackendtest
    
    They already exist and are used by the unittest. And the TrackFrame
    test actually appears to expect incorrect results (or otherwise pretty
    much all backends implement the operation incorrectly).
    
    Change-Id: I26867a2d1b0f01b5e836131932b422cb8823fb5b

diff --git a/vcl/backendtest/VisualBackendTest.cxx b/vcl/backendtest/VisualBackendTest.cxx
index 4110082a6985..cab225918087 100644
--- a/vcl/backendtest/VisualBackendTest.cxx
+++ b/vcl/backendtest/VisualBackendTest.cxx
@@ -90,7 +90,7 @@ class VisualBackendTestWindow : public WorkWindow
 private:
     Timer maUpdateTimer;
     std::vector<std::chrono::high_resolution_clock::time_point> mTimePoints;
-    static constexpr unsigned char gnNumberOfTests = 7;
+    static constexpr unsigned char gnNumberOfTests = 8;
     unsigned char mnTest;
     bool mbAnimate;
     ScopedVclPtr<VirtualDevice> mpVDev;
@@ -391,6 +391,43 @@ public:
         }
     }
 
+    static void testInvert(vcl::RenderContext& rRenderContext, int nWidth, int nHeight)
+    {
+        tools::Rectangle aRectangle;
+        size_t index = 0;
+
+        std::vector<tools::Rectangle> aRegions = setupRegions(2, 2, nWidth, nHeight);
+
+        aRectangle = aRegions[index++];
+        {
+            vcl::test::OutputDeviceTestRect aOutDevTest;
+            Bitmap aBitmap = aOutDevTest.setupInvert_NONE();
+            assertAndSetBackground(vcl::test::OutputDeviceTestRect::checkInvertRectangle(aBitmap), aRectangle, rRenderContext);
+            drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
+        }
+        aRectangle = aRegions[index++];
+        {
+            vcl::test::OutputDeviceTestRect aOutDevTest;
+            Bitmap aBitmap = aOutDevTest.setupInvert_N50();
+            assertAndSetBackground(vcl::test::OutputDeviceTestRect::checkInvertN50Rectangle(aBitmap), aRectangle, rRenderContext);
+            drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
+        }
+        aRectangle = aRegions[index++];
+        {
+            vcl::test::OutputDeviceTestRect aOutDevTest;
+            Bitmap aBitmap = aOutDevTest.setupInvert_TrackFrame();
+            assertAndSetBackground(vcl::test::OutputDeviceTestRect::checkInvertTrackFrameRectangle(aBitmap), aRectangle, rRenderContext);
+            drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
+        }
+        aRectangle = aRegions[index++];
+        {
+            vcl::test::OutputDeviceTestAnotherOutDev aOutDevTest;
+            Bitmap aBitmap = aOutDevTest.setupXOR();
+            assertAndSetBackground(vcl::test::OutputDeviceTestAnotherOutDev::checkXOR(aBitmap), aRectangle, rRenderContext);
+            drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
+        }
+    }
+
     virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/) override
     {
         if (mnTest % gnNumberOfTests == gnNumberOfTests - 1)
@@ -487,7 +524,11 @@ public:
         }
         else if (mnTest % gnNumberOfTests == 5)
         {
-            std::vector<tools::Rectangle> aRegions = setupRegions(3, 2, nWidth, nHeight);
+            testInvert(rRenderContext, nWidth, nHeight);
+        }
+        else if (mnTest % gnNumberOfTests == 6)
+        {
+            std::vector<tools::Rectangle> aRegions = setupRegions(3, 1, nWidth, nHeight);
 
             aRectangle = aRegions[index++];
             {
@@ -498,13 +539,6 @@ public:
             }
             aRectangle = aRegions[index++];
             {
-                vcl::test::OutputDeviceTestAnotherOutDev aOutDevTest;
-                Bitmap aBitmap = aOutDevTest.setupXOR();
-                assertAndSetBackground(vcl::test::OutputDeviceTestAnotherOutDev::checkXOR(aBitmap), aRectangle, rRenderContext);
-                drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
-            }
-            aRectangle = aRegions[index++];
-            {
                 vcl::test::OutputDeviceTestGradient aOutDevTest;
                 Bitmap aBitmap = aOutDevTest.setupLinearGradient();
                 drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
diff --git a/vcl/qa/cppunit/BackendTest.cxx b/vcl/qa/cppunit/BackendTest.cxx
index 01a81c0f17f3..6dfda5d02d35 100644
--- a/vcl/qa/cppunit/BackendTest.cxx
+++ b/vcl/qa/cppunit/BackendTest.cxx
@@ -465,7 +465,8 @@ public:
 
     CPPUNIT_TEST(testDrawInvertWithRectangle);
     CPPUNIT_TEST(testDrawInvertN50WithRectangle);
-    //    CPPUNIT_TEST(testDrawInvertTrackFrameWithRectangle); TODO SKIA
+    // AFAIK this test (itself) is broken.
+    // CPPUNIT_TEST(testDrawInvertTrackFrameWithRectangle);
 
     CPPUNIT_TEST(testDrawBezierWithPolylineB2D);
     CPPUNIT_TEST(testDrawBezierAAWithPolylineB2D);
commit d67ae4b6b9b22c6ea988015b51666af88f576a8a
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Thu Nov 14 11:26:58 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:32 2019 +0100

    do not use Xlib for accessing something that is not an X window
    
    Change-Id: I8986064e581fdb9876068ae3b9736b9716554fb6

diff --git a/vcl/skia/x11/gdiimpl.cxx b/vcl/skia/x11/gdiimpl.cxx
index 7eb02a51169e..e679fa8dbb2d 100644
--- a/vcl/skia/x11/gdiimpl.cxx
+++ b/vcl/skia/x11/gdiimpl.cxx
@@ -96,7 +96,7 @@ void X11SkiaSalGraphicsImpl::createSurface()
 
 bool X11SkiaSalGraphicsImpl::avoidRecreateByResize() const
 {
-    if (!mSurface)
+    if (!mSurface || isOffscreen())
         return false;
     // Skia's WindowContext uses actual dimensions of the X window, which due to X11 being
     // asynchronous may be temporarily different from what VCL thinks are the dimensions.
commit 4c7e9bfd08ef78110c1bfd897afdd7b2b5b2c682
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Wed Nov 13 13:58:58 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:31 2019 +0100

    remove no-longer-needed Skia workaround for GPU offscreen drawing
    
    Change-Id: I044a9a31af71c4c624f08a0813bc59472f4c728a

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index cb2beb2667a0..caed9fb33431 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -739,11 +739,6 @@ void SkiaSalGraphicsImpl::copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcG
         assert(dynamic_cast<SkiaSalGraphicsImpl*>(pSrcGraphics->GetImpl()));
         src = static_cast<SkiaSalGraphicsImpl*>(pSrcGraphics->GetImpl());
         src->checkSurface();
-        // TODO Without this flush() Skia asserts if both src and destination are
-        // GPU-backed SkSurface that come from different GrContext (e.g. when
-        // src comes from SkiaVulkanGrContext and target is a window). I don't
-        // know if it's a Skia bug or our GrContext usage is incorrect.
-        src->mSurface->flush();
     }
     else
         src = this;
commit f2fb76bea6609f4f4b9a4ac29b615d85a90e832f
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Wed Nov 13 13:27:57 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:31 2019 +0100

    make Skia VCL backend fall back to raster if vulkan doesn't work
    
    Change-Id: Ic446f6f85e5ebc2e50cb51a3ed1e732b8976a193

diff --git a/external/skia/share-grcontext.patch.1 b/external/skia/share-grcontext.patch.1
index 0492bd948240..357c3a885880 100644
--- a/external/skia/share-grcontext.patch.1
+++ b/external/skia/share-grcontext.patch.1
@@ -426,7 +426,7 @@ index 2db9e79ae6..7950dc159b 100644
      void swapBuffers() override;
  
 -    bool isValid() override { return fDevice != VK_NULL_HANDLE; }
-+    bool isValid() override { return fShared->fDevice != VK_NULL_HANDLE; }
++    bool isValid() override { return fShared && fShared->fDevice != VK_NULL_HANDLE; }
  
      void resize(int w, int h) override {
          this->createSwapchain(w, h, fDisplayParams);
diff --git a/include/vcl/skia/SkiaHelper.hxx b/include/vcl/skia/SkiaHelper.hxx
index 77e9fab5797a..d27cffd650f3 100644
--- a/include/vcl/skia/SkiaHelper.hxx
+++ b/include/vcl/skia/SkiaHelper.hxx
@@ -12,6 +12,8 @@
 
 #include <vcl/dllapi.h>
 
+#include <config_features.h>
+
 // All member functions static and VCL_DLLPUBLIC. Basically a glorified namespace.
 struct VCL_DLLPUBLIC SkiaHelper
 {
@@ -19,6 +21,17 @@ struct VCL_DLLPUBLIC SkiaHelper
 
 public:
     static bool isVCLSkiaEnabled();
+
+#if HAVE_FEATURE_SKIA
+    // Which Skia backend to use.
+    enum RenderMethod
+    {
+        RenderRaster,
+        RenderVulkan
+    };
+    static RenderMethod renderMethodToUse();
+    static void disableRenderMethod(RenderMethod method);
+#endif
 };
 
 #endif
diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx
index 195b5d877eed..7c41e98a91b5 100644
--- a/vcl/inc/skia/gdiimpl.hxx
+++ b/vcl/inc/skia/gdiimpl.hxx
@@ -241,14 +241,6 @@ protected:
     SkScalar toSkX(long x) const { return mIsGPU ? x + 0.5 : x; }
     SkScalar toSkY(long y) const { return mIsGPU ? y + 0.5 : y; }
 
-    // Which Skia backend to use.
-    enum RenderMethod
-    {
-        RenderRaster,
-        RenderVulkan
-    };
-    static RenderMethod renderMethodToUse();
-
 #ifdef DBG_UTIL
     void prefillSurface();
 #endif
diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index bc643bd546b1..810e8f9b0b11 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -13,8 +13,6 @@
 #include <desktop/crashreport.hxx>
 #include <officecfg/Office/Common.hxx>
 
-#include <config_features.h>
-
 #if !HAVE_FEATURE_SKIA
 bool SkiaHelper::isVCLSkiaEnabled() { return false; }
 
@@ -86,6 +84,37 @@ bool SkiaHelper::isVCLSkiaEnabled()
     return bRet;
 }
 
+static SkiaHelper::RenderMethod methodToUse = SkiaHelper::RenderRaster;
+
+static bool initRenderMethodToUse()
+{
+    if (const char* env = getenv("SAL_SKIA"))
+    {
+        if (strcmp(env, "raster") == 0)
+        {
+            methodToUse = SkiaHelper::RenderRaster;
+            return true;
+        }
+    }
+    methodToUse = SkiaHelper::RenderVulkan;
+    return true;
+}
+
+SkiaHelper::RenderMethod SkiaHelper::renderMethodToUse()
+{
+    static bool methodToUseInited = initRenderMethodToUse();
+    (void)methodToUseInited; // Used just to ensure thread-safe one-time init.
+    return methodToUse;
+}
+
+void SkiaHelper::disableRenderMethod(RenderMethod method)
+{
+    if (renderMethodToUse() != method)
+        return;
+    // Choose a fallback, right now always raster.
+    methodToUse = RenderRaster;
+}
+
 #endif // HAVE_FEATURE_SKIA
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index ac47d254cc03..cb2beb2667a0 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -24,6 +24,7 @@
 #include <vcl/idle.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/lazydelete.hxx>
+#include <vcl/skia/SkiaHelper.hxx>
 
 #include <SkCanvas.h>
 #include <SkPath.h>
@@ -168,20 +169,6 @@ public:
     }
 };
 
-SkiaSalGraphicsImpl::RenderMethod SkiaSalGraphicsImpl::renderMethodToUse()
-{
-    static RenderMethod method = [] {
-        if (const char* env = getenv("SAL_SKIA"))
-        {
-            if (strcmp(env, "raster") == 0)
-                return RenderRaster;
-        }
-        return RenderVulkan;
-    }();
-
-    return method;
-}
-
 SkiaSalGraphicsImpl::SkiaSalGraphicsImpl(SalGraphics& rParent, SalGeometryProvider* pProvider)
     : mParent(rParent)
     , mProvider(pProvider)
@@ -226,9 +213,9 @@ void SkiaSalGraphicsImpl::createOffscreenSurface()
 {
     assert(isOffscreen());
     destroySurface();
-    switch (renderMethodToUse())
+    switch (SkiaHelper::renderMethodToUse())
     {
-        case RenderVulkan:
+        case SkiaHelper::RenderVulkan:
         {
             mOffscreenGrContext = sk_app::VulkanWindowContext::getSharedGrContext();
             GrContext* grContext = mOffscreenGrContext.getGrContext();
@@ -260,7 +247,8 @@ void SkiaSalGraphicsImpl::createOffscreenSurface()
 #endif
                 return;
             }
-            SAL_WARN("vcl.skia", "cannot create Vulkan GPU offscreen surface");
+            SAL_WARN("vcl.skia", "cannot create Vulkan offscreen GPU surface, disabling Vulkan");
+            SkiaHelper::disableRenderMethod(SkiaHelper::RenderVulkan);
             break;
         }
         default:
diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx
index 8f30c3486dac..cba8bed29355 100644
--- a/vcl/skia/win/gdiimpl.cxx
+++ b/vcl/skia/win/gdiimpl.cxx
@@ -9,12 +9,13 @@
 
 #include <skia/win/gdiimpl.hxx>
 
-#include <tools/sk_app/win/WindowContextFactory_win.h>
-#include <tools/sk_app/WindowContext.h>
 #include <win/saldata.hxx>
+#include <vcl/skia/SkiaHelper.hxx>
 
 #include <SkColorFilter.h>
 #include <SkPixelRef.h>
+#include <tools/sk_app/win/WindowContextFactory_win.h>
+#include <tools/sk_app/WindowContext.h>
 
 WinSkiaSalGraphicsImpl::WinSkiaSalGraphicsImpl(WinSalGraphics& rGraphics,
                                                SalGeometryProvider* mpProvider)
@@ -52,22 +53,30 @@ void WinSkiaSalGraphicsImpl::createSurface()
     // valid here, but better check.
     assert(GetWidth() != 0 && GetHeight() != 0);
     sk_app::DisplayParams displayParams;
-    switch (renderMethodToUse())
+    switch (SkiaHelper::renderMethodToUse())
     {
-        case RenderRaster:
+        case SkiaHelper::RenderRaster:
             mWindowContext = sk_app::window_context_factory::MakeRasterForWin(mWinParent.gethWnd(),
                                                                               displayParams);
+            assert(SkToBool(mWindowContext));
+            mSurface = mWindowContext->getBackbufferSurface();
+            assert(mSurface.get());
             mIsGPU = false;
             break;
-        case RenderVulkan:
+        case SkiaHelper::RenderVulkan:
             mWindowContext = sk_app::window_context_factory::MakeVulkanForWin(mWinParent.gethWnd(),
                                                                               displayParams);
+            if (mWindowContext)
+                mSurface = mWindowContext->getBackbufferSurface();
+            if (!mSurface)
+            {
+                SAL_WARN("vcl.skia", "cannot create Vulkan GPU surface, disabling Vulkan");
+                SkiaHelper::disableRenderMethod(SkiaHelper::RenderVulkan);
+                return createSurface(); // try again
+            }
             mIsGPU = true;
             break;
     }
-    assert(SkToBool(mWindowContext)); // TODO
-    mSurface = mWindowContext->getBackbufferSurface();
-    assert(mSurface.get());
 #ifdef DBG_UTIL
     prefillSurface();
 #endif
diff --git a/vcl/skia/x11/gdiimpl.cxx b/vcl/skia/x11/gdiimpl.cxx
index ef381c5e56d3..7eb02a51169e 100644
--- a/vcl/skia/x11/gdiimpl.cxx
+++ b/vcl/skia/x11/gdiimpl.cxx
@@ -21,6 +21,8 @@
 #include <tools/sk_app/unix/WindowContextFactory_unix.h>
 #include <tools/sk_app/WindowContext.h>
 
+#include <vcl/skia/SkiaHelper.hxx>
+
 X11SkiaSalGraphicsImpl::X11SkiaSalGraphicsImpl(X11SalGraphics& rParent)
     : SkiaSalGraphicsImpl(rParent, rParent.GetGeometryProvider())
     , mX11Parent(rParent)
@@ -63,22 +65,30 @@ void X11SkiaSalGraphicsImpl::createSurface()
 #endif
     winInfo.fWidth = GetWidth();
     winInfo.fHeight = GetHeight();
-    switch (renderMethodToUse())
+    switch (SkiaHelper::renderMethodToUse())
     {
-        case RenderRaster:
+        case SkiaHelper::RenderRaster:
             mWindowContext
                 = sk_app::window_context_factory::MakeRasterForXlib(winInfo, displayParams);
+            assert(SkToBool(mWindowContext));
+            mSurface = mWindowContext->getBackbufferSurface();
+            assert(mSurface.get());
             mIsGPU = false;
             break;
-        case RenderVulkan:
+        case SkiaHelper::RenderVulkan:
             mWindowContext
                 = sk_app::window_context_factory::MakeVulkanForXlib(winInfo, displayParams);
+            if (mWindowContext)
+                mSurface = mWindowContext->getBackbufferSurface();
+            if (!mSurface)
+            {
+                SAL_WARN("vcl.skia", "cannot create Vulkan GPU surface, disabling Vulkan");
+                SkiaHelper::disableRenderMethod(SkiaHelper::RenderVulkan);
+                return createSurface(); // try again
+            }
             mIsGPU = true;
             break;
     }
-    assert(SkToBool(mWindowContext)); // TODO
-    mSurface = mWindowContext->getBackbufferSurface();
-    assert(mSurface.get());
 #ifdef DBG_UTIL
     prefillSurface();
 #endif
commit 8a4c318781396e501f277fe2ac2a492d6e6b2807
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Tue Nov 12 16:10:50 2019 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 26 10:03:31 2019 +0100

    fix Skia offscreen GPU-backed drawing
    
    The previous approach of using multiple GrContext instances apparently
    does not work, it's not possible to do drawing operations that
    involve objects using two different GrContext's. So patch Skia to use
    just one GrContext for our needs. See vcl/skia/README for details.
    
    Change-Id: I2bd3d3c618bf7f8ff45b2f37cbd086d2289940aa

diff --git a/external/skia/README b/external/skia/README
index 767f12e91936..95be1561d4fb 100644
--- a/external/skia/README
+++ b/external/skia/README
@@ -17,3 +17,9 @@ tar cvJf skia-mXX-$id.tar.xz skia
 (where XX refers to the branch version)
 
 And review differences for BUILD.gn and relevant files in gn/ .
+
+
+GrContext sharing
+=================
+
+For details about the share-grcontext patch, see vcl/skia/README.
diff --git a/external/skia/UnpackedTarball_skia.mk b/external/skia/UnpackedTarball_skia.mk
index e9905f5abfa7..c3988042a012 100644
--- a/external/skia/UnpackedTarball_skia.mk
+++ b/external/skia/UnpackedTarball_skia.mk
@@ -12,7 +12,13 @@ $(eval $(call gb_UnpackedTarball_UnpackedTarball,skia))
 $(eval $(call gb_UnpackedTarball_set_tarball,skia,$(SKIA_TARBALL)))
 
 # TODO
-skia_patches := lerp.patch fix-pch.patch fix-ddi.patch make-api-visible.patch.1 fix-shader-locale.patch.1
+skia_patches := \
+    lerp.patch \
+    fix-pch.patch \
+    fix-ddi.patch \
+    make-api-visible.patch.1 \
+    fix-shader-locale.patch.1 \
+    share-grcontext.patch.1
 
 $(eval $(call gb_UnpackedTarball_set_patchlevel,skia,1))
 

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list