vcl/inc/skia/gdiimpl.hxx | 1 + vcl/skia/gdiimpl.cxx | 12 ++++++++++++ 2 files changed, 13 insertions(+)
New commits: commit acb47f7aaaec14baccc0f3233670044e72342d29 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Sat Sep 5 10:59:25 2020 +0200 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Mon Sep 7 15:21:41 2020 +0200 do not queue up too many Skia image drawing operations (tdf#136369) The document tries to draw a larger number of tiny bitmaps, which results in Skia trying to allocate many tiny GPU images, which slows it down (something quadratic there?) and it may eventually run out of memory. So force a flush if there are too many such operations unflushed. This is somewhat similar to what was done in the past by ad3580df085b3a3d66eb73cae997ea5ca178ccc1 . Change-Id: Ib0309ea9c7ac6c80d69ceed2922e885a2aa7f2d8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102166 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx index 32beae036d5f..9405bc39ade2 100644 --- a/vcl/inc/skia/gdiimpl.hxx +++ b/vcl/inc/skia/gdiimpl.hxx @@ -325,6 +325,7 @@ protected: double transparency; }; LastPolyPolygonInfo mLastPolyPolygonInfo; + int mPendingOperationsToFlush; }; #endif diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index cb0f9b47ecf8..17fcbf092335 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -255,6 +255,7 @@ SkiaSalGraphicsImpl::SkiaSalGraphicsImpl(SalGraphics& rParent, SalGeometryProvid , mFillColor(SALCOLOR_NONE) , mXorMode(false) , mFlush(new SkiaFlushIdle(this)) + , mPendingOperationsToFlush(0) { } @@ -389,6 +390,15 @@ void SkiaSalGraphicsImpl::preDraw() void SkiaSalGraphicsImpl::postDraw() { scheduleFlush(); + // Skia (at least when using Vulkan) queues drawing commands and executes them only later. + // But tdf#136369 leads to creating and queueing many tiny bitmaps, which makes + // Skia slow, and may make it even run out of memory. So force a flush if such + // a problematic operation has been performed too many times without a flush. + if (mPendingOperationsToFlush > 1000) + { + mSurface->flushAndSubmit(); + mPendingOperationsToFlush = 0; + } SkiaZone::leave(); // matched in preDraw() } @@ -454,6 +464,7 @@ void SkiaSalGraphicsImpl::flushDrawing() if (mXorMode) applyXor(); mSurface->flushAndSubmit(); + mPendingOperationsToFlush = 0; } bool SkiaSalGraphicsImpl::setClipRegion(const vcl::Region& region) @@ -1550,6 +1561,7 @@ void SkiaSalGraphicsImpl::drawImage(const SalTwoRect& rPosAry, const sk_sp<SkIma "drawimage(" << this << "): " << rPosAry << ":" << SkBlendMode_Name(eBlendMode)); getDrawCanvas()->drawImageRect(aImage, aSourceRect, aDestinationRect, &aPaint); addXorRegion(aDestinationRect); + ++mPendingOperationsToFlush; // tdf#136369 postDraw(); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits