[Libreoffice-commits] core.git: vcl/skia

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 15 08:49:55 UTC 2020


 vcl/skia/gdiimpl.cxx     |    8 ++++++--
 vcl/skia/win/gdiimpl.cxx |    4 ----
 2 files changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 7d7a3eba57338925d1e9604db2455b0a3484b1b3
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Tue Apr 14 15:21:26 2020 +0200
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Wed Apr 15 10:49:19 2020 +0200

    do not create empty Skia surface (tdf#131939)
    
    Apparently SalGraphics may be occassionally of size (0,0), such as
    in this case where clipboard cleanup happens on exit. Just create
    a tiny surface in that case.
    
    Change-Id: Ic68deec6804c7e2099fc079d69018da7b780c8cb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92192
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index b9d6d3575c85..6f7c2b70b1df 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -266,13 +266,17 @@ void SkiaSalGraphicsImpl::createOffscreenSurface()
     assert(isOffscreen());
     assert(!mSurface);
     assert(!mWindowContext);
+    // When created (especially on Windows), Init() gets called with size (0,0), which is invalid size
+    // for Skia. May happen also in rare cases such as shutting down (tdf#131939).
+    int width = std::max(1, GetWidth());
+    int height = std::max(1, GetHeight());
     switch (SkiaHelper::renderMethodToUse())
     {
         case SkiaHelper::RenderVulkan:
         {
             if (SkiaHelper::getSharedGrContext())
             {
-                mSurface = SkiaHelper::createSkSurface(GetWidth(), GetHeight());
+                mSurface = SkiaHelper::createSkSurface(width, height);
                 assert(mSurface);
                 assert(mSurface->getCanvas()->getGrContext()); // is GPU-backed
                 mIsGPU = true;
@@ -286,7 +290,7 @@ void SkiaSalGraphicsImpl::createOffscreenSurface()
             break;
     }
     // Create raster surface as a fallback.
-    mSurface = SkiaHelper::createSkSurface(GetWidth(), GetHeight());
+    mSurface = SkiaHelper::createSkSurface(width, height);
     assert(mSurface);
     assert(!mSurface->getCanvas()->getGrContext()); // is not GPU-backed
     mIsGPU = false;
diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx
index 70ac8496ef83..fd796794464e 100644
--- a/vcl/skia/win/gdiimpl.cxx
+++ b/vcl/skia/win/gdiimpl.cxx
@@ -38,10 +38,6 @@ WinSkiaSalGraphicsImpl::WinSkiaSalGraphicsImpl(WinSalGraphics& rGraphics,
 void WinSkiaSalGraphicsImpl::createWindowContext()
 {
     SkiaZone zone;
-    // 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) || isOffscreen());
     sk_app::DisplayParams displayParams;
     switch (SkiaHelper::renderMethodToUse())
     {


More information about the Libreoffice-commits mailing list