summaryrefslogtreecommitdiff
path: root/vcl/skia/gdiimpl.cxx
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-09-10 16:06:03 +0200
committerLuboš Luňák <l.lunak@collabora.com>2021-11-12 09:12:47 +0100
commit0bd7dcf09d1801b03367ecbfd388c5940081d483 (patch)
treeba3a90626b49e3f87674c42f42b5b669c3289d18 /vcl/skia/gdiimpl.cxx
parentd4f0281f3127255b792a9ec492ba4a14d5ee64c2 (diff)
reduce copy&paste
Change-Id: Ie37f96755f348316bb8d5129df925134943e7ace Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125055 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/skia/gdiimpl.cxx')
-rw-r--r--vcl/skia/gdiimpl.cxx70
1 files changed, 24 insertions, 46 deletions
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 73f6cc3dd479..434209ae1dcf 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1466,46 +1466,24 @@ void SkiaSalGraphicsImpl::invert(basegfx::B2DPolygon const& rPoly, SalInvert eFl
addPolygonToPath(rPoly, aPath);
aPath.setFillType(SkPathFillType::kEvenOdd);
addUpdateRegion(aPath.getBounds());
+ SkAutoCanvasRestore autoRestore(getDrawCanvas(), true);
+ SkPaint aPaint;
// TrackFrame just inverts a dashed path around the polygon
if (eFlags == SalInvert::TrackFrame)
{
// TrackFrame is not supposed to paint outside of the polygon (usually rectangle),
// but wider stroke width usually results in that, so ensure the requirement
// by clipping.
- SkAutoCanvasRestore autoRestore(getDrawCanvas(), true);
getDrawCanvas()->clipRect(aPath.getBounds(), SkClipOp::kIntersect, false);
- SkPaint aPaint;
aPaint.setStrokeWidth(2);
- float intervals[] = { 4.0f, 4.0f };
+ constexpr float intervals[] = { 4.0f, 4.0f };
aPaint.setStyle(SkPaint::kStroke_Style);
aPaint.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0));
aPaint.setColor(SkColorSetARGB(255, 255, 255, 255));
aPaint.setBlendMode(SkBlendMode::kDifference);
- if (!rasterHack)
- getDrawCanvas()->drawPath(aPath, aPaint);
- else
- {
- SkRect area;
- aPath.getBounds().roundOut(&area);
- SkRect size = SkRect::MakeWH(area.width(), area.height());
- sk_sp<SkSurface> surface
- = SkSurface::MakeRasterN32Premul(area.width(), area.height(), surfaceProps());
- SkPaint copy;
- copy.setBlendMode(SkBlendMode::kSrc);
- flushDrawing();
- surface->getCanvas()->drawImageRect(makeCheckedImageSnapshot(mSurface), area, size,
- SkSamplingOptions(), &copy,
- SkCanvas::kFast_SrcRectConstraint);
- aPath.offset(-area.x(), -area.y());
- surface->getCanvas()->drawPath(aPath, aPaint);
- getDrawCanvas()->drawImageRect(makeCheckedImageSnapshot(surface), size, area,
- SkSamplingOptions(), &copy,
- SkCanvas::kFast_SrcRectConstraint);
- }
}
else
{
- SkPaint aPaint;
aPaint.setColor(SkColorSetARGB(255, 255, 255, 255));
aPaint.setStyle(SkPaint::kFill_Style);
aPaint.setBlendMode(SkBlendMode::kDifference);
@@ -1532,27 +1510,27 @@ void SkiaSalGraphicsImpl::invert(basegfx::B2DPolygon const& rPoly, SalInvert eFl
aPaint.setShader(
aBitmap.makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat, SkSamplingOptions()));
}
- if (!rasterHack)
- getDrawCanvas()->drawPath(aPath, aPaint);
- else
- {
- SkRect area;
- aPath.getBounds().roundOut(&area);
- SkRect size = SkRect::MakeWH(area.width(), area.height());
- sk_sp<SkSurface> surface
- = SkSurface::MakeRasterN32Premul(area.width(), area.height(), surfaceProps());
- SkPaint copy;
- copy.setBlendMode(SkBlendMode::kSrc);
- flushDrawing();
- surface->getCanvas()->drawImageRect(makeCheckedImageSnapshot(mSurface), area, size,
- SkSamplingOptions(), &copy,
- SkCanvas::kFast_SrcRectConstraint);
- aPath.offset(-area.x(), -area.y());
- surface->getCanvas()->drawPath(aPath, aPaint);
- getDrawCanvas()->drawImageRect(makeCheckedImageSnapshot(surface), size, area,
- SkSamplingOptions(), &copy,
- SkCanvas::kFast_SrcRectConstraint);
- }
+ }
+ if (!rasterHack)
+ getDrawCanvas()->drawPath(aPath, aPaint);
+ else
+ {
+ SkRect area;
+ aPath.getBounds().roundOut(&area);
+ SkRect size = SkRect::MakeWH(area.width(), area.height());
+ sk_sp<SkSurface> surface
+ = SkSurface::MakeRasterN32Premul(area.width(), area.height(), surfaceProps());
+ SkPaint copy;
+ copy.setBlendMode(SkBlendMode::kSrc);
+ flushDrawing();
+ surface->getCanvas()->drawImageRect(makeCheckedImageSnapshot(mSurface), area, size,
+ SkSamplingOptions(), &copy,
+ SkCanvas::kFast_SrcRectConstraint);
+ aPath.offset(-area.x(), -area.y());
+ surface->getCanvas()->drawPath(aPath, aPaint);
+ getDrawCanvas()->drawImageRect(makeCheckedImageSnapshot(surface), size, area,
+ SkSamplingOptions(), &copy,
+ SkCanvas::kFast_SrcRectConstraint);
}
postDraw();
}