summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-09-13 14:08:33 +0200
committerLuboš Luňák <l.lunak@collabora.com>2021-11-12 11:08:22 +0100
commitb11a510541f3758e1769f75b34cf27e70b846923 (patch)
tree06202679527118191158cb09585054389db99049 /vcl
parent5fe5ded723b2bea0c88ebc7647284dc0ade97ee3 (diff)
drop usage of SkSurface::draw()
It causes so many problems that it almost doesn't get used in practice anyway. Change-Id: Ie11042749d0cca998af45be1daee6f14bf9531f1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125056 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/skia/gdiimpl.cxx93
1 files changed, 27 insertions, 66 deletions
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 434209ae1dcf..642752a3bbdd 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1213,37 +1213,6 @@ bool SkiaSalGraphicsImpl::drawPolyPolygonBezier(sal_uInt32, const sal_uInt32*, c
return false;
}
-static void copyArea(SkCanvas* canvas, sk_sp<SkSurface> surface, tools::Long nDestX,
- tools::Long nDestY, tools::Long nSrcX, tools::Long nSrcY,
- tools::Long nSrcWidth, tools::Long nSrcHeight, bool srcIsRaster,
- bool destIsRaster)
-{
- // Using SkSurface::draw() should be more efficient than SkSurface::makeImageSnapshot(),
- // because it may detect copying to itself and avoid some needless copies.
- // But it has problems with drawing to itself
- // (https://groups.google.com/forum/#!topic/skia-discuss/6yiuw24jv0I) and also
- // raster surfaces do not avoid a copy of the source
- // (https://groups.google.com/forum/#!topic/skia-discuss/S3FMpCi82k0).
- // Finally, there's not much point if one of them is raster and the other is not (chrome/m86 even crashes).
- if (canvas == surface->getCanvas() || srcIsRaster || (srcIsRaster != destIsRaster))
- {
- SkPaint paint;
- paint.setBlendMode(SkBlendMode::kSrc); // copy as is, including alpha
- canvas->drawImageRect(makeCheckedImageSnapshot(surface),
- SkRect::MakeXYWH(nSrcX, nSrcY, nSrcWidth, nSrcHeight),
- SkRect::MakeXYWH(nDestX, nDestY, nSrcWidth, nSrcHeight),
- SkSamplingOptions(), &paint, SkCanvas::kFast_SrcRectConstraint);
- return;
- }
- // SkCanvas::draw() cannot do a subrectangle, so clip.
- canvas->save();
- canvas->clipRect(SkRect::MakeXYWH(nDestX, nDestY, nSrcWidth, nSrcHeight));
- SkPaint paint;
- paint.setBlendMode(SkBlendMode::kSrc); // copy as is, including alpha
- surface->draw(canvas, nDestX - nSrcX, nDestY - nSrcY, &paint);
- canvas->restore();
-}
-
void SkiaSalGraphicsImpl::copyArea(tools::Long nDestX, tools::Long nDestY, tools::Long nSrcX,
tools::Long nSrcY, tools::Long nSrcWidth, tools::Long nSrcHeight,
bool /*bWindowInvalidate*/)
@@ -1256,8 +1225,13 @@ void SkiaSalGraphicsImpl::copyArea(tools::Long nDestX, tools::Long nDestY, tools
<< SkIRect::MakeXYWH(nDestX, nDestY, nSrcWidth, nSrcHeight));
assert(!mXorMode);
addUpdateRegion(SkRect::MakeXYWH(nDestX, nDestY, nSrcWidth, nSrcHeight));
- ::copyArea(getDrawCanvas(), mSurface, nDestX, nDestY, nSrcX, nSrcY, nSrcWidth, nSrcHeight,
- !isGPU(), !isGPU());
+ // Using SkSurface::draw() should be more efficient, but it's too buggy.
+ SkPaint paint;
+ paint.setBlendMode(SkBlendMode::kSrc); // copy as is, including alpha
+ getDrawCanvas()->drawImageRect(makeCheckedImageSnapshot(mSurface),
+ SkRect::MakeXYWH(nSrcX, nSrcY, nSrcWidth, nSrcHeight),
+ SkRect::MakeXYWH(nDestX, nDestY, nSrcWidth, nSrcHeight),
+ SkSamplingOptions(), &paint, SkCanvas::kFast_SrcRectConstraint);
postDraw();
}
@@ -1280,39 +1254,26 @@ void SkiaSalGraphicsImpl::copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcG
assert(!mXorMode);
addUpdateRegion(SkRect::MakeXYWH(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth,
rPosAry.mnDestHeight));
- if (rPosAry.mnSrcWidth == rPosAry.mnDestWidth && rPosAry.mnSrcHeight == rPosAry.mnDestHeight)
- {
- auto srcDebug = [&]() -> std::string {
- if (src == this)
- return "(self)";
- else
- {
- std::ostringstream stream;
- stream << "(" << src << ")";
- return stream.str();
- }
- };
- SAL_INFO("vcl.skia.trace",
- "copybits(" << this << "): " << srcDebug() << " copy area: " << rPosAry);
- ::copyArea(getDrawCanvas(), src->mSurface, rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnSrcX,
- rPosAry.mnSrcY, rPosAry.mnDestWidth, rPosAry.mnDestHeight, !src->isGPU(),
- !isGPU());
- }
- else
- {
- SAL_INFO("vcl.skia.trace", "copybits(" << this << "): (" << src << "): " << rPosAry);
- // Do not use makeImageSnapshot(rect), as that one may make a needless data copy.
- sk_sp<SkImage> image = makeCheckedImageSnapshot(src->mSurface);
- SkPaint paint;
- paint.setBlendMode(SkBlendMode::kSrc); // copy as is, including alpha
- getDrawCanvas()->drawImageRect(image,
- SkRect::MakeXYWH(rPosAry.mnSrcX, rPosAry.mnSrcY,
- rPosAry.mnSrcWidth, rPosAry.mnSrcHeight),
- SkRect::MakeXYWH(rPosAry.mnDestX, rPosAry.mnDestY,
- rPosAry.mnDestWidth, rPosAry.mnDestHeight),
- makeSamplingOptions(rPosAry), &paint,
- SkCanvas::kFast_SrcRectConstraint);
- }
+ auto srcDebug = [&]() -> std::string {
+ if (src == this)
+ return "(self)";
+ else
+ {
+ std::ostringstream stream;
+ stream << "(" << src << ")";
+ return stream.str();
+ }
+ };
+ SAL_INFO("vcl.skia.trace", "copybits(" << this << "): " << srcDebug() << ": " << rPosAry);
+ SkPaint paint;
+ paint.setBlendMode(SkBlendMode::kSrc); // copy as is, including alpha
+ // Do not use makeImageSnapshot(rect), as that one may make a needless data copy.
+ getDrawCanvas()->drawImageRect(
+ makeCheckedImageSnapshot(src->mSurface),
+ SkRect::MakeXYWH(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight),
+ SkRect::MakeXYWH(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth,
+ rPosAry.mnDestHeight),
+ makeSamplingOptions(rPosAry), &paint, SkCanvas::kFast_SrcRectConstraint);
postDraw();
}