[Libreoffice-commits] core.git: 2 commits - vcl/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.com
Wed Apr 30 07:57:51 PDT 2014
vcl/source/outdev/bitmap.cxx | 72 ++++++++++++++++++++++---------------------
1 file changed, 37 insertions(+), 35 deletions(-)
New commits:
commit ebe854c9d967ed1ec4eee40db984717c2275f722
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Wed Apr 30 16:56:08 2014 +0200
vcl: clean-up DrawDeviceBitmap method
Change-Id: I392993ca1d6a62778105026b724c26578b4e1fec
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 4fabf50..c80ee4b 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -488,13 +488,13 @@ BitmapEx OutputDevice::GetBitmapEx( const Point& rSrcPt, const Size& rSize ) con
void OutputDevice::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize,
const Point& rSrcPtPixel, const Size& rSrcSizePixel,
- BitmapEx& rBmpEx )
+ BitmapEx& rBitmapEx )
{
- if(rBmpEx.IsAlpha())
+ if (rBitmapEx.IsAlpha())
{
Size aDestSizePixel(LogicToPixel(rDestSize));
- BitmapEx aScaledBitmapEx(rBmpEx);
+ BitmapEx aScaledBitmapEx(rBitmapEx);
Point aSrcPtPixel(rSrcPtPixel);
Size aSrcSizePixel(rSrcSizePixel);
@@ -515,10 +515,8 @@ void OutputDevice::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize
aSrcPtPixel.Y() = rSrcPtPixel.Y() * fScaleY;
}
DrawDeviceAlphaBitmap(aScaledBitmapEx.GetBitmap(), aScaledBitmapEx.GetAlpha(), rDestPt, rDestSize, aSrcPtPixel, aSrcSizePixel);
- return;
}
-
- if( !( !rBmpEx ) )
+ else if (!!rBitmapEx)
{
SalTwoRect aPosAry;
@@ -531,23 +529,23 @@ void OutputDevice::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize
aPosAry.mnDestWidth = ImplLogicWidthToDevicePixel( rDestSize.Width() );
aPosAry.mnDestHeight = ImplLogicHeightToDevicePixel( rDestSize.Height() );
- const sal_uLong nMirrFlags = AdjustTwoRect( aPosAry, rBmpEx.GetSizePixel() );
+ const sal_uLong nMirrFlags = AdjustTwoRect(aPosAry, rBitmapEx.GetSizePixel());
- if( aPosAry.mnSrcWidth && aPosAry.mnSrcHeight && aPosAry.mnDestWidth && aPosAry.mnDestHeight )
+ if (aPosAry.mnSrcWidth && aPosAry.mnSrcHeight && aPosAry.mnDestWidth && aPosAry.mnDestHeight)
{
- if( nMirrFlags )
- rBmpEx.Mirror( nMirrFlags );
+ if (nMirrFlags)
+ rBitmapEx.Mirror(nMirrFlags);
- const SalBitmap* pSalSrcBmp = rBmpEx.ImplGetBitmapImpBitmap()->ImplGetSalBitmap();
- const ImpBitmap* pMaskBmp = rBmpEx.ImplGetMaskImpBitmap();
+ const SalBitmap* pSalSrcBmp = rBitmapEx.ImplGetBitmapImpBitmap()->ImplGetSalBitmap();
+ const ImpBitmap* pMaskBmp = rBitmapEx.ImplGetMaskImpBitmap();
- if ( pMaskBmp )
+ if (pMaskBmp)
{
SalBitmap* pSalAlphaBmp = pMaskBmp->ImplGetSalBitmap();
bool bTryDirectPaint(pSalSrcBmp && pSalAlphaBmp);
- if(bTryDirectPaint)
+ if (bTryDirectPaint)
{
// only paint direct when no scaling and no MapMode, else the
// more expensive conversions may be done for short-time Bitmap/BitmapEx
@@ -558,7 +556,7 @@ void OutputDevice::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize
}
}
- if(bTryDirectPaint && mpGraphics->DrawAlphaBitmap(aPosAry, *pSalSrcBmp, *pSalAlphaBmp, this))
+ if (bTryDirectPaint && mpGraphics->DrawAlphaBitmap(aPosAry, *pSalSrcBmp, *pSalAlphaBmp, this))
{
// tried to paint as alpha directly. If tis worked, we are done (except
// alpha, see below)
@@ -593,21 +591,21 @@ void OutputDevice::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize
// const double nScaleY( aPosAry.mnDestHeight / aPosAry.mnSrcHeight );
// for now, only identity scales allowed
- if( !aClipRegionBounds.IsEmpty() &&
+ if (!aClipRegionBounds.IsEmpty() &&
aPosAry.mnDestWidth == aPosAry.mnSrcWidth &&
- aPosAry.mnDestHeight == aPosAry.mnSrcHeight )
+ aPosAry.mnDestHeight == aPosAry.mnSrcHeight)
{
// now intersect dest rect with clip region
- aClipRegionBounds.Intersection( Rectangle( aPosAry.mnDestX,
- aPosAry.mnDestY,
- aPosAry.mnDestX + aPosAry.mnDestWidth - 1,
- aPosAry.mnDestY + aPosAry.mnDestHeight - 1 ) );
+ aClipRegionBounds.Intersection(Rectangle(aPosAry.mnDestX,
+ aPosAry.mnDestY,
+ aPosAry.mnDestX + aPosAry.mnDestWidth - 1,
+ aPosAry.mnDestY + aPosAry.mnDestHeight - 1));
// Note: I could theoretically optimize away the
// DrawBitmap below, if the region is empty
// here. Unfortunately, cannot rule out that
// somebody relies on the side effects.
- if( !aClipRegionBounds.IsEmpty() )
+ if (!aClipRegionBounds.IsEmpty())
{
aPosAry.mnSrcX += aClipRegionBounds.Left() - aPosAry.mnDestX;
aPosAry.mnSrcY += aClipRegionBounds.Top() - aPosAry.mnDestY;
@@ -621,9 +619,9 @@ void OutputDevice::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize
}
}
- mpGraphics->DrawBitmap( aPosAry, *pSalSrcBmp,
- *pMaskBmp->ImplGetSalBitmap(),
- this );
+ mpGraphics->DrawBitmap(aPosAry, *pSalSrcBmp,
+ *pMaskBmp->ImplGetSalBitmap(),
+ this);
}
// #110958# Paint mask to alpha channel. Luckily, the
@@ -635,17 +633,17 @@ void OutputDevice::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize
// bitmap content was ever visible. Interestingly
// enough, this can be achieved by taking the mask as
// the transparency mask of itself
- if( mpAlphaVDev )
- mpAlphaVDev->DrawBitmapEx( rDestPt,
- rDestSize,
- BitmapEx( rBmpEx.GetMask(),
- rBmpEx.GetMask() ) );
+ if (mpAlphaVDev)
+ mpAlphaVDev->DrawBitmapEx(rDestPt,
+ rDestSize,
+ BitmapEx(rBitmapEx.GetMask(),
+ rBitmapEx.GetMask()));
}
else
{
- mpGraphics->DrawBitmap( aPosAry, *pSalSrcBmp, this );
+ mpGraphics->DrawBitmap(aPosAry, *pSalSrcBmp, this);
- if( mpAlphaVDev )
+ if (mpAlphaVDev)
{
// #i32109#: Make bitmap area opaque
mpAlphaVDev->ImplFillOpaqueRectangle( Rectangle(rDestPt, rDestSize) );
commit 818a0ed6c6b2f7176551f1db0ff518b5a0bb522e
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Wed Apr 30 16:46:40 2014 +0200
fdo#77126 BitmapEx.Scale already takes care of mirroring
Change-Id: I320a5ec1da62cc1a8b3cb227298ecaf99f305a6f
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index e0841a6..4fabf50 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -501,12 +501,16 @@ void OutputDevice::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize
// we have beautiful scaling algorithms, let's use them
if (aDestSizePixel != rSrcSizePixel && rSrcSizePixel.Width() != 0 && rSrcSizePixel.Height() != 0)
{
- double fScaleX = double(aDestSizePixel.Width()) / rSrcSizePixel.Width();
- double fScaleY = double(aDestSizePixel.Height()) / rSrcSizePixel.Height();
+ double fScaleX = std::abs(aDestSizePixel.Width() / double(rSrcSizePixel.Width()));
+ double fScaleY = std::abs(aDestSizePixel.Height() / double(rSrcSizePixel.Height()));
aScaledBitmapEx.Scale(fScaleX, fScaleY);
- aSrcSizePixel = aDestSizePixel;
+ // Negative size values are used for mirroring, but Scale already takes
+ // care of mirroring so convert all negative values to positive.
+ aSrcSizePixel = Size(std::abs(aDestSizePixel.Width()),
+ std::abs(aDestSizePixel.Height()));
+
aSrcPtPixel.X() = rSrcPtPixel.X() * fScaleX;
aSrcPtPixel.Y() = rSrcPtPixel.Y() * fScaleY;
}
More information about the Libreoffice-commits
mailing list