From d18731f71c60cbb6c02cabb042004b1aa9454de8 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Tue, 6 Oct 2020 22:14:36 +0200 Subject: track dirty areas for Skia drawing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updates to the screen in raster mode aren't _that_ slow, in fact it seems using SkRegion can make things slower because of manipulating the region, but with SkIRect this could sometimes help a bit. It also appears that StretchDIBits() that is used by the Windows raster code doesn't work correctly if only a subset of the y-axis range is specified, which reduces the usefulness. Change-Id: Ia93d2b60f2c62461e4c2c81210ab1d5d652a2cfb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104047 Tested-by: Jenkins Reviewed-by: Luboš Luňák --- vcl/inc/skia/gdiimpl.hxx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'vcl/inc/skia') diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx index 21aaf880ae8c..3cc577300128 100644 --- a/vcl/inc/skia/gdiimpl.hxx +++ b/vcl/inc/skia/gdiimpl.hxx @@ -264,12 +264,12 @@ protected: SkCanvas* getXorCanvas(); void applyXor(); // NOTE: This must be called before the operation does any drawing. - void addXorRegion(const SkRect& rect) + void addUpdateRegion(const SkRect& rect) { + // Make slightly larger, just in case (rounding, antialiasing,...). + SkIRect addedRect = rect.makeOutset(2, 2).round(); if (mXorMode) { - // Make slightly larger, just in case (rounding, antialiasing,...). - SkIRect addedRect = rect.makeOutset(2, 2).round(); // Two xor operations should cancel each other out. We batch xor operations, // but if they can overlap, apply xor now, since applyXor() does the operation // just once. @@ -277,6 +277,9 @@ protected: applyXor(); mXorRegion.op(addedRect, SkRegion::kUnion_Op); } + // Using SkIRect should be enough, SkRegion would be too slow with many operations + // and swapping to the screen is not _that_slow. + mDirtyRect.join(addedRect); } static void setCanvasClipRegion(SkCanvas* canvas, const vcl::Region& region); sk_sp mergeCacheBitmaps(const SkiaSalBitmap& bitmap, const SkiaSalBitmap* alphaBitmap, @@ -318,6 +321,7 @@ protected: // The Skia surface that is target of all the rendering. sk_sp mSurface; bool mIsGPU; // whether the surface is GPU-backed + SkIRect mDirtyRect; // the area that has been changed since the last performFlush() vcl::Region mClipRegion; Color mLineColor; Color mFillColor; -- cgit