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@collabora.com>
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index b9d6d35..6f7c2b7 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -266,13 +266,17 @@
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 @@
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 70ac849..fd79679 100644
--- a/vcl/skia/win/gdiimpl.cxx
+++ b/vcl/skia/win/gdiimpl.cxx
@@ -38,10 +38,6 @@
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())
{