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

Noel Grandin noel.grandin at collabora.co.uk
Tue Feb 20 11:54:47 UTC 2018


 drawinglayer/source/primitive2d/sceneprimitive2d.cxx |  101 ++++++++-----------
 1 file changed, 43 insertions(+), 58 deletions(-)

New commits:
commit b10c7022f1be6e4825269bd5872575b5b53744ef
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Feb 19 09:15:04 2018 +0200

    use RawBitmap in BPixelRasterToBitmapEx
    
    part of making BitmapWriteAccess an internal detail of vcl/
    
    Change-Id: I28b9e0e0b414489c564fb2f23c4de2390ad175c1
    Reviewed-on: https://gerrit.libreoffice.org/49964
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
index 150c13c58db7..5d3e972a6592 100644
--- a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
@@ -33,7 +33,7 @@
 #include <drawinglayer/processor3d/geometry2dextractor.hxx>
 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
 #include <basegfx/raster/bzpixelraster.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapTools.hxx>
 #include <comphelper/threadpool.hxx>
 
 using namespace com::sun::star;
@@ -49,83 +49,68 @@ namespace
         if(nWidth && nHeight)
         {
             const Size aDestSize(nWidth, nHeight);
-            sal_uInt8 nInitAlpha(255);
-            Bitmap aContent(aDestSize, 24);
-            AlphaMask aAlpha(aDestSize, &nInitAlpha);
-            Bitmap::ScopedWriteAccess pContent(aContent);
-            AlphaMask::ScopedWriteAccess pAlpha(aAlpha);
+            vcl::bitmap::RawBitmap aContent(aDestSize);
 
-            if (pContent && pAlpha)
+            if(mnAntiAlialize)
             {
-                if(mnAntiAlialize)
-                {
-                    const sal_uInt16 nDivisor(mnAntiAlialize * mnAntiAlialize);
+                const sal_uInt16 nDivisor(mnAntiAlialize * mnAntiAlialize);
 
-                    for(sal_uInt32 y(0); y < nHeight; y++)
+                for(sal_uInt32 y(0); y < nHeight; y++)
+                {
+                    for(sal_uInt32 x(0); x < nWidth; x++)
                     {
-                        Scanline pScanlineContent = pContent->GetScanline( y );
-                        Scanline pScanlineAlpha = pAlpha->GetScanline( y );
-                        for(sal_uInt32 x(0); x < nWidth; x++)
-                        {
-                            sal_uInt16 nRed(0);
-                            sal_uInt16 nGreen(0);
-                            sal_uInt16 nBlue(0);
-                            sal_uInt16 nOpacity(0);
-                            sal_uInt32 nIndex(rRaster.getIndexFromXY(x * mnAntiAlialize, y * mnAntiAlialize));
+                        sal_uInt16 nRed(0);
+                        sal_uInt16 nGreen(0);
+                        sal_uInt16 nBlue(0);
+                        sal_uInt16 nOpacity(0);
+                        sal_uInt32 nIndex(rRaster.getIndexFromXY(x * mnAntiAlialize, y * mnAntiAlialize));
 
-                            for(sal_uInt32 c(0); c < mnAntiAlialize; c++)
+                        for(sal_uInt32 c(0); c < mnAntiAlialize; c++)
+                        {
+                            for(sal_uInt32 d(0); d < mnAntiAlialize; d++)
                             {
-                                for(sal_uInt32 d(0); d < mnAntiAlialize; d++)
-                                {
-                                    const basegfx::BPixel& rPixel(rRaster.getBPixel(nIndex++));
-                                    nRed = nRed + rPixel.getRed();
-                                    nGreen = nGreen + rPixel.getGreen();
-                                    nBlue = nBlue + rPixel.getBlue();
-                                    nOpacity = nOpacity + rPixel.getOpacity();
-                                }
-
-                                nIndex += rRaster.getWidth() - mnAntiAlialize;
+                                const basegfx::BPixel& rPixel(rRaster.getBPixel(nIndex++));
+                                nRed = nRed + rPixel.getRed();
+                                nGreen = nGreen + rPixel.getGreen();
+                                nBlue = nBlue + rPixel.getBlue();
+                                nOpacity = nOpacity + rPixel.getOpacity();
                             }
 
-                            nOpacity = nOpacity / nDivisor;
+                            nIndex += rRaster.getWidth() - mnAntiAlialize;
+                        }
+
+                        nOpacity = nOpacity / nDivisor;
 
-                            if(nOpacity)
-                            {
-                                pContent->SetPixelOnData(pScanlineContent, x, BitmapColor(
-                                    static_cast<sal_uInt8>(nRed / nDivisor),
-                                    static_cast<sal_uInt8>(nGreen / nDivisor),
-                                    static_cast<sal_uInt8>(nBlue / nDivisor)));
-                                pAlpha->SetPixelOnData(pScanlineAlpha, x, BitmapColor(255 - static_cast<sal_uInt8>(nOpacity)));
-                            }
+                        if(nOpacity)
+                        {
+                            aContent.SetPixel(y, x, Color(
+                                static_cast<sal_uInt8>(nRed / nDivisor),
+                                static_cast<sal_uInt8>(nGreen / nDivisor),
+                                static_cast<sal_uInt8>(nBlue / nDivisor),
+                                255 - static_cast<sal_uInt8>(nOpacity)));
                         }
                     }
                 }
-                else
-                {
-                    sal_uInt32 nIndex(0);
+            }
+            else
+            {
+                sal_uInt32 nIndex(0);
 
-                    for(sal_uInt32 y(0); y < nHeight; y++)
+                for(sal_uInt32 y(0); y < nHeight; y++)
+                {
+                    for(sal_uInt32 x(0); x < nWidth; x++)
                     {
-                        Scanline pScanlineContent = pContent->GetScanline( y );
-                        Scanline pScanlineAlpha = pAlpha->GetScanline( y );
-                        for(sal_uInt32 x(0); x < nWidth; x++)
-                        {
-                            const basegfx::BPixel& rPixel(rRaster.getBPixel(nIndex++));
+                        const basegfx::BPixel& rPixel(rRaster.getBPixel(nIndex++));
 
-                            if(rPixel.getOpacity())
-                            {
-                                pContent->SetPixelOnData(pScanlineContent, x, BitmapColor(rPixel.getRed(), rPixel.getGreen(), rPixel.getBlue()));
-                                pAlpha->SetPixelOnData(pScanlineAlpha, x, BitmapColor(255 - rPixel.getOpacity()));
-                            }
+                        if(rPixel.getOpacity())
+                        {
+                            aContent.SetPixel(y, x, Color(rPixel.getRed(), rPixel.getGreen(), rPixel.getBlue(), 255 - rPixel.getOpacity()));
                         }
                     }
                 }
             }
 
-            pAlpha.reset();
-            pContent.reset();
-
-            aRetval = BitmapEx(aContent, aAlpha);
+            aRetval = vcl::bitmap::CreateFromData(std::move(aContent));
 
             // #i101811# set PrefMapMode and PrefSize at newly created Bitmap
             aRetval.SetPrefMapMode(MapMode(MapUnit::MapPixel));


More information about the Libreoffice-commits mailing list