From c3b044abc2906bbb56a0f359f89ee7c1eb400c93 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Wed, 15 Apr 2020 12:33:17 +0200 Subject: keep old contents of resized windows with Skia (tdf#131952) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It seems this is necessary in rare cases. Change-Id: Id7557a069bc0adf61b34068f00761e16b961fbc5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92258 Tested-by: Jenkins Reviewed-by: Luboš Luňák --- vcl/skia/gdiimpl.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'vcl') diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index 6f7c2b70b1df..e20d63018747 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -432,7 +432,22 @@ void SkiaSalGraphicsImpl::checkSurface() if (!avoidRecreateByResize()) { Size oldSize(mSurface->width(), mSurface->height()); + // Recreating a surface means that the old SkSurface contents will be lost. + // But if a window has been resized the windowing system may send repaint events + // only for changed parts and VCL would not repaint the whole area, assuming + // that some parts have not changed (this is what seems to cause tdf#131952). + // So carry over the old contents for windows, even though generally everything + // will be usually repainted anyway. + sk_sp snapshot; + if (!isOffscreen()) + snapshot = mSurface->makeImageSnapshot(); recreateSurface(); + if (snapshot) + { + SkPaint paint; + paint.setBlendMode(SkBlendMode::kSrc); // copy as is + mSurface->getCanvas()->drawImage(snapshot, 0, 0, &paint); + } SAL_INFO("vcl.skia.trace", "recreate(" << this << "): old " << oldSize << " new " << Size(mSurface->width(), mSurface->height()) << " requested " -- cgit