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

Caolán McNamara caolanm at redhat.com
Tue Mar 28 14:17:43 UTC 2017


 include/vcl/bitmapaccess.hxx |  423 ++++++++++++++++++-------------------------
 1 file changed, 182 insertions(+), 241 deletions(-)

New commits:
commit 1a99e32f6fd6213981e9272c22f5019ed7444d1d
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Mar 28 15:16:30 2017 +0100

    move inlines into the class
    
    Change-Id: If185834c35c9aa7d48e3305cfee3fde47826180f

diff --git a/include/vcl/bitmapaccess.hxx b/include/vcl/bitmapaccess.hxx
index 0623b74d816e..b215aa08ca01 100644
--- a/include/vcl/bitmapaccess.hxx
+++ b/include/vcl/bitmapaccess.hxx
@@ -37,28 +37,104 @@ public:
     BitmapInfoAccess(Bitmap& rBitmap);
     virtual ~BitmapInfoAccess();
 
-    inline bool operator!() const;
+    bool operator!() const
+    {
+        return mpBuffer == nullptr;
+    }
+
+    long Width() const
+    {
+        return mpBuffer ? mpBuffer->mnWidth : 0L;
+    }
+
+    long Height() const
+    {
+        return mpBuffer ? mpBuffer->mnHeight : 0L;
+    }
+
+    bool IsTopDown() const
+    {
+        assert(mpBuffer && "Access is not valid!");
+
+        return mpBuffer && (mpBuffer->mnFormat & ScanlineFormat::TopDown);
+    }
 
-    inline long Width() const;
-    inline long Height() const;
+    bool IsBottomUp() const
+    {
+        return !IsTopDown();
+    }
+
+    ScanlineFormat GetScanlineFormat() const
+    {
+        assert(mpBuffer && "Access is not valid!");
+
+        return mpBuffer ? RemoveScanline(mpBuffer->mnFormat) : ScanlineFormat::NONE;
+    }
 
-    inline bool  IsTopDown() const;
-    inline bool  IsBottomUp() const;
+    sal_uLong GetScanlineSize() const
+    {
+        assert(mpBuffer && "Access is not valid!");
+
+        return mpBuffer ? mpBuffer->mnScanlineSize : 0UL;
+    }
 
-    inline ScanlineFormat GetScanlineFormat() const;
-    inline sal_uLong GetScanlineSize() const;
+    sal_uInt16 GetBitCount() const
+    {
+        assert(mpBuffer && "Access is not valid!");
 
-    inline sal_uInt16 GetBitCount() const;
-    inline BitmapColor GetBestMatchingColor(const BitmapColor& rBitmapColor);
+        return mpBuffer ? mpBuffer->mnBitCount : 0;
+    }
+
+    BitmapColor GetBestMatchingColor(const BitmapColor& rBitmapColor)
+    {
+        if (HasPalette())
+            return BitmapColor((sal_uInt8) GetBestPaletteIndex(rBitmapColor));
+        else
+            return rBitmapColor;
+    }
+
+    bool HasPalette() const
+    {
+        assert(mpBuffer && "Access is not valid!");
+
+        return mpBuffer && !!mpBuffer->maPalette;
+    }
+
+    const BitmapPalette& GetPalette() const
+    {
+        assert(mpBuffer && "Access is not valid!");
+
+        return mpBuffer->maPalette;
+    }
+
+    sal_uInt16 GetPaletteEntryCount() const
+    {
+        assert(HasPalette() && "Bitmap has no palette!");
+
+        return HasPalette() ? mpBuffer->maPalette.GetEntryCount() : 0;
+    }
+
+    const BitmapColor& GetPaletteColor( sal_uInt16 nColor ) const
+    {
+        assert(mpBuffer && "Access is not valid!");
+        assert(HasPalette() && "Bitmap has no palette!");
+
+        return mpBuffer->maPalette[nColor];
+    }
+
+    const BitmapColor& GetBestPaletteColor(const BitmapColor& rBitmapColor) const
+    {
+        return GetPaletteColor(GetBestPaletteIndex(rBitmapColor));
+    }
 
-    inline bool HasPalette() const;
-    inline const BitmapPalette& GetPalette() const;
-    inline sal_uInt16 GetPaletteEntryCount() const;
-    inline const BitmapColor& GetPaletteColor(sal_uInt16 nColor) const;
-    inline const BitmapColor& GetBestPaletteColor(const BitmapColor& rBitmapColor) const;
     sal_uInt16 GetBestPaletteIndex(const BitmapColor& rBitmapColor) const;
 
-    inline ColorMask&           GetColorMask() const;
+    ColorMask& GetColorMask() const
+    {
+        assert(mpBuffer && "Access is not valid!");
+
+        return mpBuffer->maColorMask;
+    }
 
 private:
     BitmapInfoAccess(const BitmapInfoAccess&) = delete;
@@ -86,16 +162,65 @@ public:
     BitmapReadAccess(Bitmap& rBitmap);
     virtual ~BitmapReadAccess() override;
 
-    inline Scanline GetBuffer() const;
-    inline Scanline GetScanline( long nY ) const;
+    Scanline GetBuffer() const
+    {
+        assert(mpBuffer && "Access is not valid!");
+
+        return mpBuffer ? mpBuffer->mpBits : nullptr;
+    }
+
+    Scanline GetScanline(long nY) const
+    {
+        assert(mpBuffer && "Access is not valid!");
+        assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
+
+        if (mpBuffer->mnFormat & ScanlineFormat::TopDown)
+        {
+            return mpBuffer->mpBits + (nY * mpBuffer->mnScanlineSize);
+        }
+        return mpBuffer->mpBits + ((mpBuffer->mnHeight - 1 - nY) * mpBuffer->mnScanlineSize);
+    }
+
+    BitmapColor GetPixelFromData(const sal_uInt8* pData, long nX) const
+    {
+        assert(pData && "Access is not valid!");
+
+        return mFncGetPixel( pData, nX, maColorMask );
+    }
 
-    inline BitmapColor GetPixelFromData( const sal_uInt8* pData, long nX ) const;
-    inline void SetPixelOnData( sal_uInt8* pData, long nX, const BitmapColor& rBitmapColor );
+    void SetPixelOnData(sal_uInt8* pData, long nX, const BitmapColor& rBitmapColor)
+    {
+        assert(pData && "Access is not valid!");
+
+        mFncSetPixel(pData, nX, rBitmapColor, maColorMask);
+    }
+
+    BitmapColor GetPixel(long nY, long nX) const
+    {
+        assert(mpBuffer && "Access is not valid!");
+        assert(nX < mpBuffer->mnWidth && "x-coordinate out of range!");
+        assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
+
+        return mFncGetPixel(GetScanline(nY), nX, maColorMask );
+    }
+
+    BitmapColor GetColor(long nY, long nX) const
+    {
+        if (HasPalette())
+            return mpBuffer->maPalette[GetPixelIndex(nY, nX)];
+        else
+            return GetPixel(nY, nX);
+    }
+
+    sal_uInt8 GetPixelIndex(long nY, long nX) const
+    {
+        return GetPixel(nY, nX).GetBlueOrIndex();
+    }
 
-    inline BitmapColor GetPixel( long nY, long nX ) const;
-    inline BitmapColor GetColor( long nY, long nX ) const;
-    inline sal_uInt8 GetPixelIndex( long nY, long nX ) const;
-    inline sal_uInt8 GetLuminance( long nY, long nX ) const;
+    sal_uInt8 GetLuminance(long nY, long nX) const
+    {
+        return GetColor(nY, nX).GetLuminance();
+    }
 
     /** Get the interpolated color at coordinates fY, fX; if outside, return rFallback */
     BitmapColor GetInterpolatedColorWithFallback( double fY, double fX, const BitmapColor& rFallback ) const;
@@ -173,12 +298,41 @@ public:
 
     void CopyBuffer( const BitmapReadAccess& rReadAcc );
 
-    inline void SetPalette(const BitmapPalette& rPalette);
-    inline void SetPaletteEntryCount(sal_uInt16 nCount);
-    inline void SetPaletteColor(sal_uInt16 nColor, const BitmapColor& rBitmapColor);
+    void SetPalette(const BitmapPalette& rPalette)
+    {
+        assert(mpBuffer && "Access is not valid!");
+
+        mpBuffer->maPalette = rPalette;
+    }
+
+    void SetPaletteEntryCount(sal_uInt16 nCount)
+    {
+        assert(mpBuffer && "Access is not valid!");
+
+        mpBuffer->maPalette.SetEntryCount(nCount);
+    }
 
-    inline void SetPixel(long nY, long nX, const BitmapColor& rBitmapColor);
-    inline void SetPixelIndex(long nY, long nX, sal_uInt8 cIndex);
+    void SetPaletteColor(sal_uInt16 nColor, const BitmapColor& rBitmapColor)
+    {
+        assert(mpBuffer && "Access is not valid!");
+        assert(HasPalette() && "Bitmap has no palette!");
+
+        mpBuffer->maPalette[nColor] = rBitmapColor;
+    }
+
+    void SetPixel(long nY, long nX, const BitmapColor& rBitmapColor)
+    {
+        assert(mpBuffer && "Access is not valid!");
+        assert(nX < mpBuffer->mnWidth && "x-coordinate out of range!");
+        assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
+
+        mFncSetPixel(GetScanline(nY), nX, rBitmapColor, maColorMask);
+    }
+
+    void SetPixelIndex(long nY, long nX, sal_uInt8 cIndex)
+    {
+        SetPixel(nY, nX, BitmapColor(cIndex));
+    }
 
     void SetLineColor(const Color& rColor);
 
@@ -202,219 +356,6 @@ private:
     BitmapWriteAccess& operator=(const BitmapWriteAccess&) = delete;
 };
 
-
-inline bool BitmapInfoAccess::operator!() const
-{
-    return mpBuffer == nullptr;
-}
-
-
-inline long BitmapInfoAccess::Width() const
-{
-    return mpBuffer ? mpBuffer->mnWidth : 0L;
-}
-
-
-inline long BitmapInfoAccess::Height() const
-{
-    return mpBuffer ? mpBuffer->mnHeight : 0L;
-}
-
-
-inline bool BitmapInfoAccess::IsTopDown() const
-{
-    assert(mpBuffer && "Access is not valid!");
-
-    return mpBuffer && (mpBuffer->mnFormat & ScanlineFormat::TopDown);
-}
-
-
-inline bool BitmapInfoAccess::IsBottomUp() const
-{
-    return !IsTopDown();
-}
-
-
-inline ScanlineFormat BitmapInfoAccess::GetScanlineFormat() const
-{
-    assert(mpBuffer && "Access is not valid!");
-
-    return mpBuffer ? RemoveScanline(mpBuffer->mnFormat) : ScanlineFormat::NONE;
-}
-
-
-inline sal_uLong BitmapInfoAccess::GetScanlineSize() const
-{
-    assert(mpBuffer && "Access is not valid!");
-
-    return mpBuffer ? mpBuffer->mnScanlineSize : 0UL;
-}
-
-
-inline sal_uInt16  BitmapInfoAccess::GetBitCount() const
-{
-    assert(mpBuffer && "Access is not valid!");
-
-    return mpBuffer ? mpBuffer->mnBitCount : 0;
-}
-
-
-inline BitmapColor BitmapInfoAccess::GetBestMatchingColor(const BitmapColor& rBitmapColor)
-{
-    if (HasPalette())
-        return BitmapColor((sal_uInt8) GetBestPaletteIndex(rBitmapColor));
-    else
-        return rBitmapColor;
-}
-
-
-inline bool BitmapInfoAccess::HasPalette() const
-{
-    assert(mpBuffer && "Access is not valid!");
-
-    return mpBuffer && !!mpBuffer->maPalette;
-}
-
-
-inline const BitmapPalette& BitmapInfoAccess::GetPalette() const
-{
-    assert(mpBuffer && "Access is not valid!");
-
-    return mpBuffer->maPalette;
-}
-
-
-inline sal_uInt16 BitmapInfoAccess::GetPaletteEntryCount() const
-{
-    assert(HasPalette() && "Bitmap has no palette!");
-
-    return HasPalette() ? mpBuffer->maPalette.GetEntryCount() : 0;
-}
-
-
-inline const BitmapColor& BitmapInfoAccess::GetPaletteColor( sal_uInt16 nColor ) const
-{
-    assert(mpBuffer && "Access is not valid!");
-    assert(HasPalette() && "Bitmap has no palette!");
-
-    return mpBuffer->maPalette[nColor];
-}
-
-inline const BitmapColor& BitmapInfoAccess::GetBestPaletteColor(const BitmapColor& rBitmapColor) const
-{
-    return GetPaletteColor(GetBestPaletteIndex(rBitmapColor));
-}
-
-inline ColorMask& BitmapInfoAccess::GetColorMask() const
-{
-    assert(mpBuffer && "Access is not valid!");
-
-    return mpBuffer->maColorMask;
-}
-
-inline Scanline BitmapReadAccess::GetBuffer() const
-{
-    assert(mpBuffer && "Access is not valid!");
-
-    return mpBuffer ? mpBuffer->mpBits : nullptr;
-}
-
-inline Scanline BitmapReadAccess::GetScanline(long nY) const
-{
-    assert(mpBuffer && "Access is not valid!");
-    assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
-
-    if (mpBuffer->mnFormat & ScanlineFormat::TopDown)
-    {
-        return mpBuffer->mpBits + (nY * mpBuffer->mnScanlineSize);
-    }
-    return mpBuffer->mpBits + ((mpBuffer->mnHeight - 1 - nY) * mpBuffer->mnScanlineSize);
-}
-
-inline BitmapColor BitmapReadAccess::GetPixel(long nY, long nX) const
-{
-    assert(mpBuffer && "Access is not valid!");
-    assert(nX < mpBuffer->mnWidth && "x-coordinate out of range!");
-    assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
-
-    return mFncGetPixel(GetScanline(nY), nX, maColorMask );
-}
-
-inline sal_uInt8 BitmapReadAccess::GetPixelIndex(long nY, long nX) const
-{
-    return GetPixel(nY, nX).GetBlueOrIndex();
-}
-
-inline BitmapColor BitmapReadAccess::GetPixelFromData(const sal_uInt8* pData, long nX) const
-{
-    assert(pData && "Access is not valid!");
-
-    return mFncGetPixel( pData, nX, maColorMask );
-}
-
-inline void BitmapReadAccess::SetPixelOnData(sal_uInt8* pData, long nX, const BitmapColor& rBitmapColor)
-{
-    assert(pData && "Access is not valid!");
-
-    mFncSetPixel(pData, nX, rBitmapColor, maColorMask);
-}
-
-
-inline BitmapColor BitmapReadAccess::GetColor(long nY, long nX) const
-{
-    if (HasPalette())
-        return mpBuffer->maPalette[GetPixelIndex(nY, nX)];
-    else
-        return GetPixel(nY, nX);
-}
-
-
-inline sal_uInt8 BitmapReadAccess::GetLuminance(long nY, long nX) const
-{
-    return GetColor(nY, nX).GetLuminance();
-}
-
-
-inline void BitmapWriteAccess::SetPalette(const BitmapPalette& rPalette)
-{
-    assert(mpBuffer && "Access is not valid!");
-
-    mpBuffer->maPalette = rPalette;
-}
-
-
-inline void BitmapWriteAccess::SetPaletteEntryCount(sal_uInt16 nCount)
-{
-    assert(mpBuffer && "Access is not valid!");
-
-    mpBuffer->maPalette.SetEntryCount(nCount);
-}
-
-
-inline void BitmapWriteAccess::SetPaletteColor(sal_uInt16 nColor, const BitmapColor& rBitmapColor)
-{
-    assert(mpBuffer && "Access is not valid!");
-    assert(HasPalette() && "Bitmap has no palette!");
-
-    mpBuffer->maPalette[nColor] = rBitmapColor;
-}
-
-
-inline void BitmapWriteAccess::SetPixel(long nY, long nX, const BitmapColor& rBitmapColor)
-{
-    assert(mpBuffer && "Access is not valid!");
-    assert(nX < mpBuffer->mnWidth && "x-coordinate out of range!");
-    assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
-
-    mFncSetPixel(GetScanline(nY), nX, rBitmapColor, maColorMask);
-}
-
-
-inline void BitmapWriteAccess::SetPixelIndex(long nY, long nX, sal_uInt8 cIndex)
-{
-    SetPixel(nY, nX, BitmapColor(cIndex));
-}
-
 #endif // INCLUDED_VCL_BMPACC_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list