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

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Tue Nov 17 10:34:09 UTC 2020


 vcl/inc/skia/gdiimpl.hxx |    1 -
 vcl/skia/gdiimpl.cxx     |   23 +++++++++++++++--------
 2 files changed, 15 insertions(+), 9 deletions(-)

New commits:
commit 42e30c24615402c49351f80cc8a47d61d47267c6
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Mon Nov 16 22:43:51 2020 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 17 11:33:32 2020 +0100

    tdf#138022 Skia don't recreate empty surfaces
    
    Skia can't create empty surfaces, so the recreation will hit the
    std::abort() in SkiaSalGraphicsImpl::createWindowSurface. Origin
    of the backtrace is some queued Resize event, which will hit
    this a few times via SkiaSalGraphicsImpl::checkSurface.
    
    This feels a bit like tdf#130831, where VCL tried to track damange
    for an empty Qt image...
    
    Change-Id: I75e22c987ba633e7a403541db8d580df33c68964
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105963
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx
index 8e14df458a23..6b60f63ae405 100644
--- a/vcl/inc/skia/gdiimpl.hxx
+++ b/vcl/inc/skia/gdiimpl.hxx
@@ -237,7 +237,6 @@ protected:
     // Call to ensure that mSurface is valid. If mSurface is going to be modified,
     // use preDraw() instead of this.
     void checkSurface();
-    void recreateSurface();
     void destroySurface();
     // Reimplemented for X11.
     virtual bool avoidRecreateByResize() const { return false; }
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index e339171d9d80..d89ec093a964 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -277,12 +277,6 @@ SkiaSalGraphicsImpl::~SkiaSalGraphicsImpl()
 
 void SkiaSalGraphicsImpl::Init() {}
 
-void SkiaSalGraphicsImpl::recreateSurface()
-{
-    destroySurface();
-    createSurface();
-}
-
 void SkiaSalGraphicsImpl::createSurface()
 {
     SkiaZone zone;
@@ -453,7 +447,17 @@ void SkiaSalGraphicsImpl::checkSurface()
     }
     else if (GetWidth() != mSurface->width() || GetHeight() != mSurface->height())
     {
-        if (!avoidRecreateByResize())
+        if (avoidRecreateByResize())
+            return;
+
+        if (!GetWidth() || !GetHeight())
+        {
+            SAL_WARN("vcl.skia", "recreate(" << this << "): can't create empty surface "
+                                             << Size(GetWidth(), GetHeight())
+                                             << " => keeping old one!");
+            return;
+        }
+
         {
             Size oldSize(mSurface->width(), mSurface->height());
             // Recreating a surface means that the old SkSurface contents will be lost.
@@ -468,7 +472,10 @@ void SkiaSalGraphicsImpl::checkSurface()
                 flushDrawing();
                 snapshot = SkiaHelper::makeCheckedImageSnapshot(mSurface);
             }
-            recreateSurface();
+
+            destroySurface();
+            createSurface();
+
             if (snapshot)
             {
                 SkPaint paint;


More information about the Libreoffice-commits mailing list