[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - vcl/skia
LuboÅ¡ LuÅák (via logerrit)
logerrit at kemper.freedesktop.org
Sat Oct 3 13:46:32 UTC 2020
vcl/skia/gdiimpl.cxx | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
New commits:
commit 3b2a01c70a5d9496c95aebbcc1c69d5af0981e49
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Wed Sep 30 18:39:39 2020 +0200
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Sat Oct 3 15:46:00 2020 +0200
SkCanvas::drawPaint() -> drawRect(), where applicable, and fix matrix
It makes the code a bit simpler. Also fix the matrix used
in SkiaSalGraphicsImpl::drawShader(), plus add asserts to verify
it's correct.
Change-Id: Ia6692ad90e822e6e44028b280dc2faaac06959a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103743
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
(cherry picked from commit c1206e12eab237ffa7dde728da5bf1883a05ddb0)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103791
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index a4f0d5eb1a5d..fa2f386d6c35 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1626,17 +1626,21 @@ void SkiaSalGraphicsImpl::drawShader(const SalTwoRect& rPosAry, const sk_sp<SkSh
if (rPosAry.mnSrcWidth != rPosAry.mnDestWidth || rPosAry.mnSrcHeight != rPosAry.mnDestHeight)
paint.setFilterQuality(kHigh_SkFilterQuality);
SkCanvas* canvas = getDrawCanvas();
- // SkCanvas::drawShader() cannot do rectangles, so clip to destination and use a matrix
- // to map from source.
- SkMatrix matrix;
+ // Scaling needs to be done explicitly using a matrix.
SkAutoCanvasRestore autoRestore(canvas, true);
- canvas->clipRect(destinationRect);
- matrix.set(SkMatrix::kMScaleX, 1.0 * rPosAry.mnDestWidth / rPosAry.mnSrcWidth);
- matrix.set(SkMatrix::kMScaleY, 1.0 * rPosAry.mnDestHeight / rPosAry.mnSrcHeight);
- matrix.set(SkMatrix::kMTransX, rPosAry.mnDestX - rPosAry.mnSrcX);
- matrix.set(SkMatrix::kMTransY, rPosAry.mnDestY - rPosAry.mnSrcY);
+ SkMatrix matrix = SkMatrix::Translate(rPosAry.mnDestX, rPosAry.mnDestY)
+ * SkMatrix::Scale(1.0 * rPosAry.mnDestWidth / rPosAry.mnSrcWidth,
+ 1.0 * rPosAry.mnDestHeight / rPosAry.mnSrcHeight)
+ * SkMatrix::Translate(-rPosAry.mnSrcX, -rPosAry.mnSrcY);
+ assert(matrix.mapXY(rPosAry.mnSrcX, rPosAry.mnSrcY)
+ == SkPoint::Make(rPosAry.mnDestX, rPosAry.mnDestY));
+ assert(matrix.mapXY(rPosAry.mnSrcX + rPosAry.mnSrcWidth, rPosAry.mnSrcY + rPosAry.mnSrcHeight)
+ == SkPoint::Make(rPosAry.mnDestX + rPosAry.mnDestWidth,
+ rPosAry.mnDestY + rPosAry.mnDestHeight));
canvas->concat(matrix);
- canvas->drawPaint(paint);
+ SkRect sourceRect
+ = SkRect::MakeXYWH(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight);
+ canvas->drawRect(sourceRect, paint);
postDraw();
}
@@ -1705,12 +1709,10 @@ bool SkiaSalGraphicsImpl::drawTransformedBitmap(const basegfx::B2DPoint& rNull,
paint.setFilterQuality(kHigh_SkFilterQuality);
if (pSkiaAlphaBitmap)
{
- // SkCanvas::drawPaint() cannot do rectangles, so clip (is transformed by the matrix too).
- canvas->clipRect(SkRect::MakeWH(aSize.Width(), aSize.Height()));
paint.setShader(SkShaders::Blend(SkBlendMode::kDstOut, // VCL alpha is one-minus-alpha.
rSkiaBitmap.GetSkImage()->makeShader(),
pSkiaAlphaBitmap->GetAlphaSkImage()->makeShader()));
- canvas->drawPaint(paint);
+ canvas->drawRect(SkRect::MakeWH(aSize.Width(), aSize.Height()), paint);
}
else
{
More information about the Libreoffice-commits
mailing list