vcl/inc/skia/utils.hxx  |    3 ---
 vcl/skia/SkiaHelper.cxx |   34 ----------------------------------
 vcl/skia/gdiimpl.cxx    |    7 ++++---
 3 files changed, 4 insertions(+), 40 deletions(-)

New commits:
commit 4a11c85baeb4998e12bc2ab45b0c23d7203bd5b0
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Thu Nov 25 22:38:55 2021 +0100
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Mon Nov 29 21:48:53 2021 +0100

    remove Skia kDifference workaround
    
    I thought it was a driver problem, but now I'm actually not sure,
    as I cannot reproduce it anymore and I don't know if it was a driver
    update or Skia update. Either way, this works now.
    
    Also switch to kExclusion, because the end result is the same,
    but this formula is simpler (to understand primarily, the performance
    is going to be probably the same).
    
    Change-Id: I6ced098ca4a3361cf98d3f9b32968c128eb9f299
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126050
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/vcl/inc/skia/utils.hxx b/vcl/inc/skia/utils.hxx
index 0583e9ceb624..ac8a185e711e 100644
--- a/vcl/inc/skia/utils.hxx
+++ b/vcl/inc/skia/utils.hxx
@@ -103,9 +103,6 @@ enum DirectImage
     No
 };
 
-// Do 'paint->setBlendMode(SkBlendMode::kDifference)' (workaround for buggy 
drivers).
-void setBlendModeDifference(SkPaint* paint);
-
 // Must be called in any VCL backend before any Skia functionality is used.
 // If not set, Skia will be disabled.
 VCL_DLLPUBLIC void
diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index 631e5b64fe52..d082b6799129 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -644,45 +644,11 @@ tools::Long maxImageCacheSize()
     return officecfg::Office::Common::Cache::Skia::ImageCacheSize::get();
 }
 
-static sk_sp<SkBlender> differenceBlender;
-
-void setBlendModeDifference(SkPaint* paint)
-{
-    // This should normally do 
'paint->setBlendMode(SkBlendMode::kDifference);'.
-    // But some drivers have a problem with this, namely currently AMD on 
Windows
-    // (e.g. 'Vulkan API version: 1.2.170, driver version: 2.0.179, vendor: 
0x1002 (AMD),
-    // device: 0x15dd, type: integrated, name: AMD Radeon(TM) Vega 8 Graphics')
-    // simply crashes when kDifference is used.
-    // Intel also had repaint problems with kDifference (tdf#130430), but it 
seems
-    // those do not(?) exist anymore.
-    // Interestingly, explicitly writing a shader that does exactly the same 
works fine,
-    // so do that.
-    if (!differenceBlender)
-    {
-        const char* const diff = R"(
-            vec4 main( vec4 src, vec4 dst )
-            {
-                return vec4(abs( src.r - dst.r ), abs( src.g - dst.g ), abs( 
src.b - dst.b ), dst.a );
-            }
-        )";
-        auto effect = SkRuntimeEffect::MakeForBlender(SkString(diff));
-        if (!effect.effect)
-        {
-            SAL_WARN("vcl.skia",
-                     "SKRuntimeEffect::MakeForBlender failed: " << 
effect.errorText.c_str());
-            abort();
-        }
-        differenceBlender = effect.effect->makeBlender(nullptr);
-    }
-    paint->setBlender(differenceBlender);
-}
-
 void cleanup()
 {
     sharedWindowContext.reset();
     imageCache.clear();
     imageCacheSize = 0;
-    differenceBlender.reset();
 }
 
 static SkSurfaceProps commonSurfaceProps;
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 3d7697c4dcfa..63d588aa913e 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1507,7 +1507,10 @@ void SkiaSalGraphicsImpl::invert(basegfx::B2DPolygon 
const& rPoly, SalInvert eFl
     addUpdateRegion(aPath.getBounds());
     SkAutoCanvasRestore autoRestore(getDrawCanvas(), true);
     SkPaint aPaint;
-    setBlendModeDifference(&aPaint);
+    // There's no blend mode for inverting as such, but kExclusion is 's + d - 
2*s*d',
+    // so with d = 1.0 (all channels) it becomes effectively '1 - s', i.e. 
inverted color.
+    aPaint.setBlendMode(SkBlendMode::kExclusion);
+    aPaint.setColor(SkColorSetARGB(255, 255, 255, 255));
     // TrackFrame just inverts a dashed path around the polygon
     if (eFlags == SalInvert::TrackFrame)
     {
@@ -1519,11 +1522,9 @@ void SkiaSalGraphicsImpl::invert(basegfx::B2DPolygon 
const& rPoly, SalInvert eFl
         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));
     }
     else
     {
-        aPaint.setColor(SkColorSetARGB(255, 255, 255, 255));
         aPaint.setStyle(SkPaint::kFill_Style);
 
         // N50 inverts in checker pattern

Reply via email to