[Libreoffice-commits] core.git: vcl/inc vcl/win

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Fri May 22 11:26:37 UTC 2020


 vcl/inc/skia/salbmp.hxx |    1 +
 vcl/win/gdi/salgdi2.cxx |   19 +++++++++++++++----
 2 files changed, 16 insertions(+), 4 deletions(-)

New commits:
commit aff8471dbffdd6d26e63533d7ffa8ddea6b2396b
Author:     Luboš Luňák <l.lunak at centrum.cz>
AuthorDate: Thu May 21 15:02:37 2020 +0000
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Fri May 22 13:25:56 2020 +0200

    convert properly SkiaSalBitmap to WinSalBitmap (tdf#133152)
    
    The code didn't account for topdown bitmaps.
    
    Change-Id: Ia326834cfd6d2d022579fdde24828f7e0a8d8b3e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94643
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/vcl/inc/skia/salbmp.hxx b/vcl/inc/skia/salbmp.hxx
index 7eb2a8eb72a6..0761217d4eb9 100644
--- a/vcl/inc/skia/salbmp.hxx
+++ b/vcl/inc/skia/salbmp.hxx
@@ -60,6 +60,7 @@ public:
     virtual bool InterpretAs8Bit() override;
     virtual bool ConvertToGreyscale() override;
 
+    const BitmapPalette& Palette() const { return mPalette; }
     // Returns the contents as SkImage (possibly GPU-backed).
     const sk_sp<SkImage>& GetSkImage() const;
 
diff --git a/vcl/win/gdi/salgdi2.cxx b/vcl/win/gdi/salgdi2.cxx
index 6ccf3140c169..fdac864d0f32 100644
--- a/vcl/win/gdi/salgdi2.cxx
+++ b/vcl/win/gdi/salgdi2.cxx
@@ -43,6 +43,7 @@
 #include <config_features.h>
 #if HAVE_FEATURE_SKIA
 #include <skia/win/gdiimpl.hxx>
+#include <skia/salbmp.hxx>
 #endif
 
 
@@ -113,6 +114,10 @@ void convertToWinSalBitmap(SalBitmap& rSalBitmap, WinSalBitmap& rWinSalBitmap)
     {
         aBitmapPalette = pGLSalBitmap->GetBitmapPalette();
     }
+#if HAVE_FEATURE_SKIA
+    if(SkiaSalBitmap* pSkiaSalBitmap = dynamic_cast<SkiaSalBitmap*>(&rSalBitmap))
+        aBitmapPalette = pSkiaSalBitmap->Palette();
+#endif
 
     BitmapBuffer* pRead = rSalBitmap.AcquireBuffer(BitmapAccessMode::Read);
 
@@ -121,13 +126,19 @@ void convertToWinSalBitmap(SalBitmap& rSalBitmap, WinSalBitmap& rWinSalBitmap)
 
     sal_uInt8* pSource(pRead->mpBits);
     sal_uInt8* pDestination(pWrite->mpBits);
+    long readRowChange = pRead->mnScanlineSize;
+    if(pRead->mnFormat & ScanlineFormat::TopDown)
+    {
+        pSource += pRead->mnScanlineSize * (pRead->mnHeight - 1);
+        readRowChange = -readRowChange;
+    }
 
     std::unique_ptr<ColorScanlineConverter> pConverter;
 
-    if (pRead->mnFormat == ScanlineFormat::N24BitTcRgb)
+    if (RemoveScanline(pRead->mnFormat) == ScanlineFormat::N24BitTcRgb)
         pConverter.reset(new ColorScanlineConverter(ScanlineFormat::N24BitTcRgb,
                                                     3, pRead->mnScanlineSize));
-    else if (pRead->mnFormat == ScanlineFormat::N32BitTcRgba)
+    else if (RemoveScanline(pRead->mnFormat) == ScanlineFormat::N32BitTcRgba)
         pConverter.reset(new ColorScanlineConverter(ScanlineFormat::N32BitTcRgba,
                                                     4, pRead->mnScanlineSize));
     if (pConverter)
@@ -135,7 +146,7 @@ void convertToWinSalBitmap(SalBitmap& rSalBitmap, WinSalBitmap& rWinSalBitmap)
         for (long y = 0; y < pRead->mnHeight; y++)
         {
             pConverter->convertScanline(pSource, pDestination);
-            pSource += pRead->mnScanlineSize;
+            pSource += readRowChange;
             pDestination += pWrite->mnScanlineSize;
         }
     }
@@ -144,7 +155,7 @@ void convertToWinSalBitmap(SalBitmap& rSalBitmap, WinSalBitmap& rWinSalBitmap)
         for (long y = 0; y < pRead->mnHeight; y++)
         {
             memcpy(pDestination, pSource, pRead->mnScanlineSize);
-            pSource += pRead->mnScanlineSize;
+            pSource += readRowChange;
             pDestination += pWrite->mnScanlineSize;
         }
     }


More information about the Libreoffice-commits mailing list