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

Noel Grandin noel.grandin at collabora.co.uk
Wed May 30 21:11:19 UTC 2018


 drawinglayer/source/texture/texture3d.cxx  |  100 +++++------------------------
 include/drawinglayer/texture/texture3d.hxx |    4 -
 2 files changed, 18 insertions(+), 86 deletions(-)

New commits:
commit 63e65d1743264dfa26d2aba615d71978e65784e8
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed May 30 11:11:21 2018 +0200

    dont use GetMask in GeoTexSvxBitmapEx
    
    part of the process of making Bitmap's internals be private to vcl
    
    Change-Id: I3784c14be1572d4df64b9cbdb5adcebdd1b274fd
    Reviewed-on: https://gerrit.libreoffice.org/55050
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/drawinglayer/source/texture/texture3d.cxx b/drawinglayer/source/texture/texture3d.cxx
index 0dac447ccf50..0573c3e4b3f5 100644
--- a/drawinglayer/source/texture/texture3d.cxx
+++ b/drawinglayer/source/texture/texture3d.cxx
@@ -64,39 +64,22 @@ namespace drawinglayer
             const BitmapEx& rBitmapEx,
             const basegfx::B2DRange& rRange)
         :   maBitmapEx(rBitmapEx),
-            maTransparence(),
             maTopLeft(rRange.getMinimum()),
             maSize(rRange.getRange()),
             mfMulX(0.0),
             mfMulY(0.0),
-            mbIsAlpha(false),
-            mbIsTransparent(maBitmapEx.IsTransparent())
+            mbIsAlpha(false)
         {
-            // #121194# Todo: use alpha channel, too (for 3d)
-            maBitmap = maBitmapEx.GetBitmap();
-
-            if(mbIsTransparent)
+            if(maBitmapEx.IsTransparent())
             {
                 if(maBitmapEx.IsAlpha())
                 {
                     mbIsAlpha = true;
-                    maTransparence = rBitmapEx.GetAlpha().GetBitmap();
-                }
-                else
-                {
-                    maTransparence = rBitmapEx.GetMask();
                 }
-
-                mpReadTransparence = Bitmap::ScopedReadAccess(maTransparence);
             }
 
-            mpReadBitmap = Bitmap::ScopedReadAccess(maBitmap);
-            SAL_WARN_IF(!mpReadBitmap, "drawinglayer", "GeoTexSvxBitmapEx: Got no read access to Bitmap");
-            if (mpReadBitmap)
-            {
-                mfMulX = static_cast<double>(mpReadBitmap->Width()) / maSize.getX();
-                mfMulY = static_cast<double>(mpReadBitmap->Height()) / maSize.getY();
-            }
+            mfMulX = static_cast<double>(maBitmapEx.GetSizePixel().Width()) / maSize.getX();
+            mfMulY = static_cast<double>(maBitmapEx.GetSizePixel().Height()) / maSize.getY();
 
             if(maSize.getX() <= 1.0)
             {
@@ -113,60 +96,20 @@ namespace drawinglayer
         {
         }
 
-        sal_uInt8 GeoTexSvxBitmapEx::impGetTransparence(sal_Int32 rX, sal_Int32 rY) const
+        sal_uInt8 GeoTexSvxBitmapEx::impGetTransparence(sal_Int32 nX, sal_Int32 nY) const
         {
-            switch(maBitmapEx.GetTransparentType())
-            {
-                case TransparentType::NONE:
-                {
-                    break;
-                }
-                case TransparentType::Color:
-                {
-                    const BitmapColor aBitmapColor(mpReadBitmap->GetColor(rY, rX));
-
-                    if(maBitmapEx.GetTransparentColor() == aBitmapColor.GetColor())
-                    {
-                        return 255;
-                    }
-
-                    break;
-                }
-                case TransparentType::Bitmap:
-                {
-                    OSL_ENSURE(mpReadTransparence, "OOps, transparence type Bitmap, but no read access created in the constructor (?)");
-                    const BitmapColor aBitmapColor(mpReadTransparence->GetPixel(rY, rX));
-
-                    if(mbIsAlpha)
-                    {
-                        return aBitmapColor.GetIndex();
-                    }
-                    else
-                    {
-                        if(0x00 != aBitmapColor.GetIndex())
-                        {
-                            return 255;
-                        }
-                    }
-                    break;
-                }
-            }
-
-            return 0;
+            return maBitmapEx.GetTransparency(nX, nY);
         }
 
         bool GeoTexSvxBitmapEx::impIsValid(const basegfx::B2DPoint& rUV, sal_Int32& rX, sal_Int32& rY) const
         {
-            if(mpReadBitmap)
-            {
-                rX = static_cast<sal_Int32>((rUV.getX() - maTopLeft.getX()) * mfMulX);
+            rX = static_cast<sal_Int32>((rUV.getX() - maTopLeft.getX()) * mfMulX);
 
-                if(rX >= 0 && rX < mpReadBitmap->Width())
-                {
-                    rY = static_cast<sal_Int32>((rUV.getY() - maTopLeft.getY()) * mfMulY);
+            if(rX >= 0 && rX < maBitmapEx.GetSizePixel().Width())
+            {
+                rY = static_cast<sal_Int32>((rUV.getY() - maTopLeft.getY()) * mfMulY);
 
-                    return (rY >= 0 && rY < mpReadBitmap->Height());
-                }
+                return (rY >= 0 && rY < maBitmapEx.GetSizePixel().Height());
             }
 
             return false;
@@ -179,7 +122,7 @@ namespace drawinglayer
             if(impIsValid(rUV, nX, nY))
             {
                 const double fConvertColor(1.0 / 255.0);
-                const BitmapColor aBMCol(mpReadBitmap->GetColor(nY, nX));
+                const ::Color aBMCol(maBitmapEx.GetPixelColor(nX, nY));
                 const basegfx::BColor aBSource(
                     static_cast<double>(aBMCol.GetRed()) * fConvertColor,
                     static_cast<double>(aBMCol.GetGreen()) * fConvertColor,
@@ -187,10 +130,10 @@ namespace drawinglayer
 
                 rBColor = aBSource;
 
-                if(mbIsTransparent)
+                if(maBitmapEx.IsTransparent())
                 {
                     // when we have a transparence, make use of it
-                    const sal_uInt8 aLuminance(impGetTransparence(nX, nY));
+                    const sal_uInt8 aLuminance = aBMCol.GetTransparency();
 
                     rfOpacity = (static_cast<double>(0xff - aLuminance) * (1.0 / 255.0));
                 }
@@ -211,7 +154,7 @@ namespace drawinglayer
 
             if(impIsValid(rUV, nX, nY))
             {
-                if(mbIsTransparent)
+                if(maBitmapEx.IsTransparent())
                 {
                     // this texture has an alpha part, use it
                     const sal_uInt8 aLuminance(impGetTransparence(nX, nY));
@@ -222,8 +165,7 @@ namespace drawinglayer
                 else
                 {
                     // this texture is a color bitmap used as transparence map
-                    const BitmapColor aBMCol(mpReadBitmap->GetColor(nY, nX));
-                    const Color aColor(aBMCol.GetRed(), aBMCol.GetGreen(), aBMCol.GetBlue());
+                    const ::Color aColor(maBitmapEx.GetPixelColor(nY, nX));
 
                     rfOpacity = (static_cast<double>(0xff - aColor.GetLuminance()) * (1.0 / 255.0));
                 }
@@ -296,18 +238,12 @@ namespace drawinglayer
 
         void GeoTexSvxBitmapExTiled::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const
         {
-            if(mpReadBitmap)
-            {
-                GeoTexSvxBitmapEx::modifyBColor(impGetCorrected(rUV), rBColor, rfOpacity);
-            }
+            GeoTexSvxBitmapEx::modifyBColor(impGetCorrected(rUV), rBColor, rfOpacity);
         }
 
         void GeoTexSvxBitmapExTiled::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const
         {
-            if(mpReadBitmap)
-            {
-                GeoTexSvxBitmapEx::modifyOpacity(impGetCorrected(rUV), rfOpacity);
-            }
+            GeoTexSvxBitmapEx::modifyOpacity(impGetCorrected(rUV), rfOpacity);
         }
     } // end of namespace texture
 } // end of namespace drawinglayer
diff --git a/include/drawinglayer/texture/texture3d.hxx b/include/drawinglayer/texture/texture3d.hxx
index 628edb1ec670..fda5b45b1a2f 100644
--- a/include/drawinglayer/texture/texture3d.hxx
+++ b/include/drawinglayer/texture/texture3d.hxx
@@ -60,16 +60,12 @@ namespace drawinglayer
         protected:
             BitmapEx                                    maBitmapEx;
             Bitmap                                      maBitmap;   // Bitmap held within maBitmapEx, to exist during mpReadBitmap scope
-            Bitmap::ScopedReadAccess                    mpReadBitmap;
-            Bitmap                                      maTransparence;
-            Bitmap::ScopedReadAccess                    mpReadTransparence;
             basegfx::B2DPoint                           maTopLeft;
             basegfx::B2DVector                          maSize;
             double                                      mfMulX;
             double                                      mfMulY;
 
             bool                                        mbIsAlpha : 1;
-            bool                                        mbIsTransparent : 1;
 
             // helpers
             bool impIsValid(const basegfx::B2DPoint& rUV, sal_Int32& rX, sal_Int32& rY) const;


More information about the Libreoffice-commits mailing list