diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-11-11 20:51:55 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-11-12 18:49:39 +0100 |
commit | 110fa313628c55fef1d35830358aea7e27c1e3ee (patch) | |
tree | 6a7f817e299093d1c3db916897dcd3eaf968f191 /vcl/skia/gdiimpl.cxx | |
parent | 754697f0dcd63e1f0ce2edd70ab8b42b1b4d4484 (diff) |
get rid of Skia's 'rasterhack' for Invert()
It seems that manually writing a shader that does the same
as SkBlendMode::kDifference works fine even though the blend mode
crashes e.g. on Windows/AMD. So get rid of the memory<->GPU
conversions and use the shader as a workaround.
Change-Id: I971deeeb98f40e5ffa90f6a8dd7b0b21ec491c1a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125101
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.cxx | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index 9e2da70323de..fd86928c24c9 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -1412,16 +1412,6 @@ void SkiaSalGraphicsImpl::invert(basegfx::B2DPolygon const& rPoly, SalInvert eFl preDraw(); SAL_INFO("vcl.skia.trace", "invert(" << this << "): " << rPoly << ":" << int(eFlags)); assert(!mXorMode); - // Intel Vulkan drivers (up to current 0.401.3889) have a problem - // with SkBlendMode::kDifference(?) and surfaces wider than 1024 pixels, resulting - // in drawing errors. Work that around by fetching the relevant part of the surface - // and drawing using CPU. - bool rasterHack = (isGPU() && getVendor() == DriverBlocklist::VendorIntel && !mXorMode); - // BackendTest::testDrawInvertTrackFrameWithRectangle() also has a problem - // with SkBlendMode::kDifference on AMD, leading to crashes or even - // driver instability. Also work around by drawing using CPU. - if (isGPU() && getVendor() == DriverBlocklist::VendorAMD && !mXorMode) - rasterHack = true; SkPath aPath; aPath.incReserve(rPoly.count()); addPolygonToPath(rPoly, aPath); @@ -1429,6 +1419,7 @@ void SkiaSalGraphicsImpl::invert(basegfx::B2DPolygon const& rPoly, SalInvert eFl addUpdateRegion(aPath.getBounds()); SkAutoCanvasRestore autoRestore(getDrawCanvas(), true); SkPaint aPaint; + setBlendModeDifference(&aPaint); // TrackFrame just inverts a dashed path around the polygon if (eFlags == SalInvert::TrackFrame) { @@ -1441,13 +1432,11 @@ void SkiaSalGraphicsImpl::invert(basegfx::B2DPolygon const& rPoly, SalInvert eFl 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); } else { aPaint.setColor(SkColorSetARGB(255, 255, 255, 255)); aPaint.setStyle(SkPaint::kFill_Style); - aPaint.setBlendMode(SkBlendMode::kDifference); // N50 inverts in checker pattern if (eFlags == SalInvert::N50) @@ -1472,27 +1461,7 @@ void SkiaSalGraphicsImpl::invert(basegfx::B2DPolygon const& rPoly, SalInvert eFl 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(), ©, - SkCanvas::kFast_SrcRectConstraint); - aPath.offset(-area.x(), -area.y()); - surface->getCanvas()->drawPath(aPath, aPaint); - getDrawCanvas()->drawImageRect(makeCheckedImageSnapshot(surface), size, area, - SkSamplingOptions(), ©, - SkCanvas::kFast_SrcRectConstraint); - } + getDrawCanvas()->drawPath(aPath, aPaint); postDraw(); } |