summaryrefslogtreecommitdiff
path: root/vcl/skia
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-04-14 15:21:26 +0200
committerLuboš Luňák <l.lunak@collabora.com>2020-04-15 10:49:19 +0200
commit7d7a3eba57338925d1e9604db2455b0a3484b1b3 (patch)
tree55d0574c9586ed5f0764f76a334109d00233f134 /vcl/skia
parent598a65a3c1632c24f2aac38c5a2c9f6a55618cd6 (diff)
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>
Diffstat (limited to 'vcl/skia')
-rw-r--r--vcl/skia/gdiimpl.cxx8
-rw-r--r--vcl/skia/win/gdiimpl.cxx4
2 files changed, 6 insertions, 6 deletions
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())
{