work around copy-to-self SkSurface::draw() being buggy (tdf#132051)
This may become the actual fix or may be removed later depending
on the outcome of
https://groups.google.com/d/msgid/skia-discuss/202004151937.05051.l.lunak%40collabora.com .
Change-Id: I709f3e7bffbe86ddb2f6d75724bf30e4b0f0116e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92587
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 1937115..6926823 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -897,6 +897,16 @@
// Using SkSurface::draw() should be more efficient than SkSurface::makeImageSnapshot(),
// because it may detect copying to itself and avoid some needless copies.
// It cannot do a subrectangle though, so clip.
if (canvas == surface->getCanvas())
{
// TODO: Currently copy-to-self is buggy with SkSurface::draw().
SkPaint paint;
paint.setBlendMode(SkBlendMode::kSrc); // copy as is, including alpha
canvas->drawImageRect(surface->makeImageSnapshot(),
SkIRect::MakeXYWH(nSrcX, nSrcY, nSrcWidth, nSrcHeight),
SkRect::MakeXYWH(nDestX, nDestY, nSrcWidth, nSrcHeight), &paint);
return;
}
canvas->save();
canvas->clipRect(SkRect::MakeXYWH(nDestX, nDestY, nSrcWidth, nSrcHeight));
SkPaint paint;