[Libreoffice-commits] core.git: vcl/source

Caolán McNamara caolanm at redhat.com
Tue May 19 08:00:16 PDT 2015


 vcl/source/outdev/bitmap.cxx |   59 ++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 53 insertions(+), 6 deletions(-)

New commits:
commit 0da6ba6d3ccf736ba10bb98ca9b955736a83c5a4
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue May 19 15:58:09 2015 +0100

    Resolves: tdf#91392 orig map for orig code paths, and new map for new path
    
    otherwise with SAL_DISABLE_NATIVE_ALPHA=1/SAL_USE_VCLPLUGIN=gtk3 the 8 bit
    page icons in the status bar lose their bottom rows
    
    Change-Id: Id9d9ba1a6fb74784a0a4c29bf3d13ebf8476c376

diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 71e6afc..b94b8f1 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -680,7 +680,7 @@ void OutputDevice::DrawDeviceAlphaBitmap( const Bitmap& rBmp, const AlphaMask& r
 namespace
 {
 
-struct ScaleContext
+struct LinearScaleContext
 {
     boost::scoped_array<long> mpMapX;
     boost::scoped_array<long> mpMapY;
@@ -688,7 +688,7 @@ struct ScaleContext
     boost::scoped_array<long> mpMapXOffset;
     boost::scoped_array<long> mpMapYOffset;
 
-    ScaleContext(Rectangle& aDstRect, Rectangle& aBitmapRect,
+    LinearScaleContext(Rectangle& aDstRect, Rectangle& aBitmapRect,
                  Size& aOutSize, long nOffX, long nOffY)
 
         : mpMapX(new long[aDstRect.GetWidth()])
@@ -852,6 +852,52 @@ public:
     }
 };
 
+struct TradScaleContext
+{
+    boost::scoped_array<long> mpMapX;
+    boost::scoped_array<long> mpMapY;
+
+    TradScaleContext(Rectangle& aDstRect, Rectangle& aBitmapRect,
+                 Size& aOutSize, long nOffX, long nOffY)
+
+        : mpMapX(new long[aDstRect.GetWidth()])
+        , mpMapY(new long[aDstRect.GetHeight()])
+    {
+        const long nSrcWidth = aBitmapRect.GetWidth();
+        const long nSrcHeight = aBitmapRect.GetHeight();
+
+        const bool bHMirr = aOutSize.Width() < 0;
+        const bool bVMirr = aOutSize.Height() < 0;
+
+        generateSimpleMap(
+            nSrcWidth, aDstRect.GetWidth(), aBitmapRect.Left(),
+            aOutSize.Width(), nOffX, bHMirr, mpMapX.get());
+
+        generateSimpleMap(
+            nSrcHeight, aDstRect.GetHeight(), aBitmapRect.Top(),
+            aOutSize.Height(), nOffY, bVMirr, mpMapY.get());
+    }
+
+private:
+
+    static void generateSimpleMap(long nSrcDimension, long nDstDimension, long nDstLocation,
+                                  long nOutDimention, long nOffset, bool bMirror, long* pMap)
+    {
+        long nMirrorOffset = 0;
+
+        if (bMirror)
+            nMirrorOffset = (nDstLocation << 1) + nSrcDimension - 1L;
+
+        for (long i = 0L; i < nDstDimension; ++i, ++nOffset)
+        {
+            pMap[i] = nDstLocation + nOffset * nSrcDimension / nOutDimention;
+            if (bMirror)
+                pMap[i] = nMirrorOffset - pMap[i];
+        }
+    }
+};
+
+
 } // end anonymous namespace
 
 void OutputDevice::DrawDeviceAlphaBitmapSlowPath(const Bitmap& rBitmap, const AlphaMask& rAlpha, Rectangle aDstRect, Rectangle aBmpRect, Size& aOutSize, Point& aOutPoint)
@@ -896,7 +942,7 @@ void OutputDevice::DrawDeviceAlphaBitmapSlowPath(const Bitmap& rBitmap, const Al
 
     const long nOffY = aDstRect.Top() - aOutPoint.Y();
 
-    ScaleContext aContext(aDstRect, aBmpRect, aOutSize, nOffX, nOffY);
+    TradScaleContext aTradContext(aDstRect, aBmpRect, aOutSize, nOffX, nOffY);
 
     Bitmap::ScopedReadAccess pBitmapReadAccess(const_cast<Bitmap&>(rBitmap));
     AlphaMask::ScopedReadAccess pAlphaReadAccess(const_cast<AlphaMask&>(rAlpha));
@@ -917,11 +963,12 @@ void OutputDevice::DrawDeviceAlphaBitmapSlowPath(const Bitmap& rBitmap, const Al
                             aDstRect,
                             nOffY, nDstHeight,
                             nOffX, nDstWidth,
-                            aContext.mpMapX.get(), aContext.mpMapY.get() );
+                            aTradContext.mpMapX.get(), aTradContext.mpMapY.get() );
         }
         else
         {
-            if( aContext.blendBitmap( Bitmap::ScopedWriteAccess(aBmp).get(), pBitmapReadAccess.get(), pAlphaReadAccess.get(),
+            LinearScaleContext aLinearContext(aDstRect, aBmpRect, aOutSize, nOffX, nOffY);
+            if (aLinearContext.blendBitmap( Bitmap::ScopedWriteAccess(aBmp).get(), pBitmapReadAccess.get(), pAlphaReadAccess.get(),
                     nDstWidth, nDstHeight))
             {
                 aNewBitmap = aBmp;
@@ -934,7 +981,7 @@ void OutputDevice::DrawDeviceAlphaBitmapSlowPath(const Bitmap& rBitmap, const Al
                             nOffX, nDstWidth,
                             aBmpRect, aOutSize,
                             bHMirr, bVMirr,
-                            aContext.mpMapX.get(), aContext.mpMapY.get() );
+                            aTradContext.mpMapX.get(), aTradContext.mpMapY.get() );
             }
         }
 


More information about the Libreoffice-commits mailing list