canvas/source/vcl/backbuffer.cxx         |   12 ++----------
 canvas/source/vcl/bitmapbackbuffer.cxx   |   13 ++-----------
 canvas/source/vcl/impltools.cxx          |   18 ++++++++++++++++++
 canvas/source/vcl/impltools.hxx          |    1 +
 canvas/source/vcl/spritedevicehelper.cxx |   12 ++----------
 vcl/skia/gdiimpl.cxx                     |   18 +++++++++++++-----
 6 files changed, 38 insertions(+), 36 deletions(-)

New commits:
commit 5c3687e4c7697fdcb1451e9a1fc3a2d5b9a23a82
Author:     Luboš Luňák <[email protected]>
AuthorDate: Fri Oct 16 16:16:04 2020 +0200
Commit:     Luboš Luňák <[email protected]>
CommitDate: Tue Oct 20 19:21:33 2020 +0200

    fix skia matrix rounding imprecision
    
    Change-Id: I9908eb5981317799c978e13c244e3e1ec2867016
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104438
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <[email protected]>

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index e25f78f0be8b..067348d364ed 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -43,6 +43,7 @@
 #include <basegfx/polygon/b2dpolypolygontools.hxx>
 #include <basegfx/polygon/b2dpolypolygoncutter.hxx>
 #include <o3tl/sorted_vector.hxx>
+#include <rtl/math.hxx>
 
 namespace
 {
@@ -1676,11 +1677,18 @@ void SkiaSalGraphicsImpl::drawShader(const SalTwoRect& 
rPosAry, const sk_sp<SkSh
                       * 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));
+#ifndef NDEBUG
+    // Handle floating point imprecisions, round p1 to 2 decimal places.
+    auto compareRounded = [](const SkPoint& p1, const SkPoint& p2) {
+        return rtl::math::round(p1.x(), 2) == p2.x() && 
rtl::math::round(p1.y(), 2) == p2.y();
+    };
+#endif
+    assert(compareRounded(matrix.mapXY(rPosAry.mnSrcX, rPosAry.mnSrcY),
+                          SkPoint::Make(rPosAry.mnDestX, rPosAry.mnDestY)));
+    assert(compareRounded(
+        matrix.mapXY(rPosAry.mnSrcX + rPosAry.mnSrcWidth, rPosAry.mnSrcY + 
rPosAry.mnSrcHeight),
+        SkPoint::Make(rPosAry.mnDestX + rPosAry.mnDestWidth,
+                      rPosAry.mnDestY + rPosAry.mnDestHeight)));
     canvas->concat(matrix);
     SkRect sourceRect
         = SkRect::MakeXYWH(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, 
rPosAry.mnSrcHeight);
commit b8a609e798a83a40e5ceb5873d6a95dfd93bfb83
Author:     Luboš Luňák <[email protected]>
AuthorDate: Fri Oct 16 15:00:00 2020 +0200
Commit:     Luboš Luňák <[email protected]>
CommitDate: Tue Oct 20 19:21:06 2020 +0200

    do not disable AA in vclcanvas if Skia is used
    
    Perhaps AA may not look good with GDI or Xlib VCL, but with Skia
    it is fine (and if it's not, I'll fix it).
    Also avoid the repeated copy&paste.
    
    Change-Id: I7aa60ae1e1c8a2ab4fa93d08ab0dfeb23c9c2cb7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104437
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <[email protected]>

diff --git a/canvas/source/vcl/backbuffer.cxx b/canvas/source/vcl/backbuffer.cxx
index 0ddf0344ea73..c2779cdf0489 100644
--- a/canvas/source/vcl/backbuffer.cxx
+++ b/canvas/source/vcl/backbuffer.cxx
@@ -22,6 +22,7 @@
 #include <vcl/svapp.hxx>
 
 #include "backbuffer.hxx"
+#include "impltools.hxx"
 
 
 namespace vclcanvas
@@ -34,16 +35,7 @@ namespace vclcanvas
         if( bMonochromeBuffer )
             return;
 
-        // #i95645#
-#if defined( MACOSX )
-        // use AA on VCLCanvas for Mac
-        maVDev->SetAntialiasing( AntialiasingFlags::Enable | 
maVDev->GetAntialiasing() );
-#else
-        // switch off AA for WIN32 and UNIX, the VCLCanvas does not look good 
with it and
-        // is not required to do AA. It would need to be adapted to use it 
correctly
-        // (especially gradient painting). This will need extra work.
-        maVDev->SetAntialiasing( maVDev->GetAntialiasing() & 
~AntialiasingFlags::Enable);
-#endif
+        tools::SetDefaultDeviceAntiAliasing( maVDev );
     }
 
     BackBuffer::~BackBuffer()
diff --git a/canvas/source/vcl/bitmapbackbuffer.cxx 
b/canvas/source/vcl/bitmapbackbuffer.cxx
index 4ac6d1a7b95e..337e0bae7c2e 100644
--- a/canvas/source/vcl/bitmapbackbuffer.cxx
+++ b/canvas/source/vcl/bitmapbackbuffer.cxx
@@ -24,7 +24,7 @@
 #include <vcl/svapp.hxx>
 
 #include "bitmapbackbuffer.hxx"
-
+#include "impltools.hxx"
 
 namespace vclcanvas
 {
@@ -120,16 +120,7 @@ namespace vclcanvas
 
         mpVDev->SetOutputSizePixel( maBitmap->GetSizePixel() );
 
-        // #i95645#
-#if defined( MACOSX )
-        // use AA on VCLCanvas for Mac
-        mpVDev->SetAntialiasing( AntialiasingFlags::Enable | 
mpVDev->GetAntialiasing() );
-#else
-        // switch off AA for WIN32 and UNIX, the VCLCanvas does not look good 
with it and
-        // is not required to do AA. It would need to be adapted to use it 
correctly
-        // (especially gradient painting). This will need extra work.
-        mpVDev->SetAntialiasing(mpVDev->GetAntialiasing() & 
~AntialiasingFlags::Enable);
-#endif
+        tools::SetDefaultDeviceAntiAliasing( mpVDev );
     }
 
     void BitmapBackBuffer::updateVDev() const
diff --git a/canvas/source/vcl/impltools.cxx b/canvas/source/vcl/impltools.cxx
index 754a34ce0806..a76fefcb40c7 100644
--- a/canvas/source/vcl/impltools.cxx
+++ b/canvas/source/vcl/impltools.cxx
@@ -33,6 +33,7 @@
 #include <vcl/canvastools.hxx>
 #include <vcl/BitmapTools.hxx>
 #include <vcl/metric.hxx>
+#include <vcl/skia/SkiaHelper.hxx>
 
 #include <canvas/canvastools.hxx>
 
@@ -216,6 +217,23 @@ namespace vclcanvas::tools
 
             return vcl::bitmap::CanvasTransformBitmap(rBitmap, rTransform, 
aDestRect, aLocalTransform);
         }
+
+        void SetDefaultDeviceAntiAliasing( OutputDevice* pDevice )
+        {
+#if defined( MACOSX )
+            // use AA on VCLCanvas for Mac
+            pDevice->SetAntialiasing( AntialiasingFlags::Enable | 
pDevice->GetAntialiasing() );
+#else
+            // switch off AA for WIN32 and UNIX, the VCLCanvas does not look 
good with it and
+            // is not required to do AA. It would need to be adapted to use it 
correctly
+            // (especially gradient painting). This will need extra work.
+            if( SkiaHelper::isVCLSkiaEnabled()) // But Skia handles AA fine.
+                pDevice->SetAntialiasing( AntialiasingFlags::Enable | 
pDevice->GetAntialiasing() );
+            else
+                pDevice->SetAntialiasing(pDevice->GetAntialiasing() & 
~AntialiasingFlags::Enable);
+#endif
+        }
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/vcl/impltools.hxx b/canvas/source/vcl/impltools.hxx
index 8ac5a7e62d42..f8a9db075227 100644
--- a/canvas/source/vcl/impltools.hxx
+++ b/canvas/source/vcl/impltools.hxx
@@ -171,6 +171,7 @@ namespace vclcanvas
         ::BitmapEx transformBitmap( const BitmapEx&                            
         rBitmap,
                                     const ::basegfx::B2DHomMatrix&             
         rTransform );
 
+        void SetDefaultDeviceAntiAliasing( OutputDevice* pDevice );
     }
 }
 
diff --git a/canvas/source/vcl/spritedevicehelper.cxx 
b/canvas/source/vcl/spritedevicehelper.cxx
index f123b31e4cfb..150e3fcb42af 100644
--- a/canvas/source/vcl/spritedevicehelper.cxx
+++ b/canvas/source/vcl/spritedevicehelper.cxx
@@ -25,6 +25,7 @@
 #include <tools/stream.hxx>
 
 #include "spritedevicehelper.hxx"
+#include "impltools.hxx"
 
 using namespace ::com::sun::star;
 
@@ -44,16 +45,7 @@ namespace vclcanvas
         mpBackBuffer = std::make_shared<BackBuffer>( rOutDev );
         mpBackBuffer->setSize( rOutDev.GetOutputSizePixel() );
 
-        // #i95645#
-#if defined( MACOSX )
-        // use AA on VCLCanvas for Mac
-        mpBackBuffer->getOutDev().SetAntialiasing( AntialiasingFlags::Enable | 
mpBackBuffer->getOutDev().GetAntialiasing() );
-#else
-        // switch off AA for WIN32 and UNIX, the VCLCanvas does not look good 
with it and
-        // is not required to do AA. It would need to be adapted to use it 
correctly
-        // (especially gradient painting). This will need extra work.
-        
mpBackBuffer->getOutDev().SetAntialiasing(mpBackBuffer->getOutDev().GetAntialiasing()
 & ~AntialiasingFlags::Enable);
-#endif
+        tools::SetDefaultDeviceAntiAliasing( &mpBackBuffer->getOutDev());
     }
 
     bool SpriteDeviceHelper::showBuffer( bool, bool )
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to