summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vcl/inc/skia/gdiimpl.hxx4
-rw-r--r--vcl/skia/gdiimpl.cxx34
-rw-r--r--vcl/skia/win/gdiimpl.cxx1
-rw-r--r--vcl/skia/x11/gdiimpl.cxx2
4 files changed, 26 insertions, 15 deletions
diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx
index 6b60f63ae405..3ad6f3ea0869 100644
--- a/vcl/inc/skia/gdiimpl.hxx
+++ b/vcl/inc/skia/gdiimpl.hxx
@@ -239,7 +239,7 @@ protected:
void checkSurface();
void destroySurface();
// Reimplemented for X11.
- virtual bool avoidRecreateByResize() const { return false; }
+ virtual bool avoidRecreateByResize() const;
void createWindowSurface(bool forceRaster = false);
virtual void createWindowContext(bool forceRaster = false) = 0;
void createOffscreenSurface();
@@ -249,7 +249,7 @@ protected:
void setProvider(SalGeometryProvider* provider) { mProvider = provider; }
- bool isOffscreen() const { return mProvider == nullptr || mProvider->IsOffScreen(); }
+ bool isOffscreen() const;
bool isGPU() const { return mIsGPU; }
void invert(basegfx::B2DPolygon const& rPoly, SalInvert eFlags);
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 773bdd2be1bf..4e6383d91473 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -335,14 +335,24 @@ void SkiaSalGraphicsImpl::createWindowSurface(bool forceRaster)
#endif
}
+bool SkiaSalGraphicsImpl::isOffscreen() const
+{
+ if (mProvider == nullptr || mProvider->IsOffScreen())
+ return true;
+ // HACK: Sometimes (tdf#131939, tdf#138022, tdf#140288) VCL passes us a zero-sized window,
+ // and zero size is invalid for Skia, so force offscreen surface, where we handle this.
+ if (GetWidth() <= 0 || GetHeight() <= 0)
+ return true;
+ return false;
+}
+
void SkiaSalGraphicsImpl::createOffscreenSurface()
{
SkiaZone zone;
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).
+ // HACK: See isOffscreen().
int width = std::max(1, GetWidth());
int height = std::max(1, GetHeight());
switch (SkiaHelper::renderMethodToUse())
@@ -461,17 +471,7 @@ void SkiaSalGraphicsImpl::checkSurface()
}
else if (GetWidth() != mSurface->width() || GetHeight() != mSurface->height())
{
- if (avoidRecreateByResize())
- return;
-
- if (!GetWidth() || !GetHeight())
- {
- SAL_WARN("vcl.skia", "recreate(" << this << "): can't create empty surface "
- << Size(GetWidth(), GetHeight())
- << " => keeping old one!");
- return;
- }
-
+ if (!avoidRecreateByResize())
{
Size oldSize(mSurface->width(), mSurface->height());
// Recreating a surface means that the old SkSurface contents will be lost.
@@ -504,6 +504,14 @@ void SkiaSalGraphicsImpl::checkSurface()
}
}
+bool SkiaSalGraphicsImpl::avoidRecreateByResize() const
+{
+ // Keep the old surface if VCL sends us a broken size (see isOffscreen()).
+ if (GetWidth() == 0 || GetHeight() == 0)
+ return true;
+ return false;
+}
+
void SkiaSalGraphicsImpl::flushDrawing()
{
if (!mSurface)
diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx
index b7e661896fa4..e2ea31de8aaa 100644
--- a/vcl/skia/win/gdiimpl.cxx
+++ b/vcl/skia/win/gdiimpl.cxx
@@ -38,6 +38,7 @@ void WinSkiaSalGraphicsImpl::createWindowContext(bool forceRaster)
{
SkiaZone zone;
sk_app::DisplayParams displayParams;
+ assert(GetWidth() > 0 && GetHeight() > 0);
displayParams.fSurfaceProps = *SkiaHelper::surfaceProps();
switch (forceRaster ? SkiaHelper::RenderRaster : SkiaHelper::renderMethodToUse())
{
diff --git a/vcl/skia/x11/gdiimpl.cxx b/vcl/skia/x11/gdiimpl.cxx
index 29fb15d27140..2ef186ad78d0 100644
--- a/vcl/skia/x11/gdiimpl.cxx
+++ b/vcl/skia/x11/gdiimpl.cxx
@@ -108,6 +108,8 @@ X11SkiaSalGraphicsImpl::createWindowContext(Display* display, Drawable drawable,
bool X11SkiaSalGraphicsImpl::avoidRecreateByResize() const
{
+ if (SkiaSalGraphicsImpl::avoidRecreateByResize())
+ return true;
if (!mSurface || isOffscreen())
return false;
// Skia's WindowContext uses actual dimensions of the X window, which due to X11 being