summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-04-20 17:35:30 +0200
committerLuboš Luňák <l.lunak@collabora.com>2020-04-21 10:02:48 +0200
commit6c559b122add7db32b06faa15854df58b30460f6 (patch)
tree6dc74cb544b57fa78d9a4e62a9e0a2665e158db9
parent9b7a2d33e9dcb5e4131e4901969d5853efdaf6e8 (diff)
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>
-rw-r--r--vcl/skia/gdiimpl.cxx10
1 files changed, 10 insertions, 0 deletions
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 1937115e1c23..6926823a5db0 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -897,6 +897,16 @@ static void copyArea(SkCanvas* canvas, sk_sp<SkSurface> surface, long nDestX, lo
// 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;