[Libreoffice-commits] core.git: include/vcl vcl/source
Chris Sherlock
chris.sherlock79 at gmail.com
Thu Apr 17 07:13:13 PDT 2014
include/vcl/outdev.hxx | 14 +-
vcl/source/outdev/bitmap.cxx | 214 ++++++++++++++++----------------------
vcl/source/outdev/transparent.cxx | 2
3 files changed, 99 insertions(+), 131 deletions(-)
New commits:
commit 2a67712f5ff97ebf04860a10d50ed94a654e1f5e
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date: Fri Apr 18 00:08:53 2014 +1000
Refactor VCL bitmap code
Turns out that all bitmap code eventually calls on ImplDrawBitmap and
ImplDrawBitmapEx, which is called by a version with the same function
signature but without a type parameter. If you make that sal_uLong
parameter a default parameter, you can remove ImplDrawBitmap/Ex and just
call on that version of DrawBitmap/Ex.
Change-Id: Ifd75561bb824b3941c2cf700984ca80e0b851bd3
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index c428c81..c98ff3a 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -20,6 +20,9 @@
#ifndef INCLUDED_VCL_OUTDEV_HXX
#define INCLUDED_VCL_OUTDEV_HXX
+#define META_BMPSCALEPART_ACTION (118)
+#define META_BMPEXSCALEPART_ACTION (121)
+
#include <tools/gen.hxx>
#include <tools/solar.h>
#include <vcl/dllapi.h>
@@ -774,12 +777,6 @@ public:
*/
///@{
SAL_DLLPRIVATE void ImplDrawOutDevDirect ( const OutputDevice* pSrcDev, SalTwoRect& rPosAry );
- SAL_DLLPRIVATE void ImplDrawBitmap ( const Point& rDestPt, const Size& rDestSize,
- const Point& rSrcPtPixel, const Size& rSrcSizePixel,
- const Bitmap& rBitmap, const sal_uLong nAction );
- SAL_DLLPRIVATE void ImplDrawBitmapEx ( const Point& rDestPt, const Size& rDestSize,
- const Point& rSrcPtPixel, const Size& rSrcSizePixel,
- const BitmapEx& rBitmapEx, const sal_uLong nAction );
SAL_DLLPRIVATE void ImplDrawAlpha ( const Bitmap& rBmp, const AlphaMask& rAlpha,
const Point& rDestPt, const Size& rDestSize,
const Point& rSrcPtPixel, const Size& rSrcSizePixel );
@@ -1111,7 +1108,8 @@ public:
const Bitmap& rBitmap );
void DrawBitmap( const Point& rDestPt, const Size& rDestSize,
const Point& rSrcPtPixel, const Size& rSrcSizePixel,
- const Bitmap& rBitmap );
+ const Bitmap& rBitmap, sal_uLong nAction = META_BMPSCALEPART_ACTION );
+
void DrawBitmapEx( const Point& rDestPt,
const BitmapEx& rBitmapEx );
@@ -1119,7 +1117,7 @@ public:
const BitmapEx& rBitmapEx );
void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
const Point& rSrcPtPixel, const Size& rSrcSizePixel,
- const BitmapEx& rBitmapEx );
+ const BitmapEx& rBitmapExi, sal_uLong nAction = META_BMPEXSCALEPART_ACTION );
/** Draw BitampEx transformed
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 80b7c4e..973a604 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -43,54 +43,24 @@
void OutputDevice::DrawBitmap( const Point& rDestPt, const Bitmap& rBitmap )
{
- if( ImplIsRecordLayout() )
- return;
-
const Size aSizePix( rBitmap.GetSizePixel() );
- ImplDrawBitmap( rDestPt, PixelToLogic( aSizePix ), Point(), aSizePix, rBitmap, META_BMP_ACTION );
-
- if( mpAlphaVDev )
- {
- // #i32109#: Make bitmap area opaque
- mpAlphaVDev->ImplFillOpaqueRectangle( Rectangle(rDestPt, PixelToLogic( aSizePix )) );
- }
+ DrawBitmap( rDestPt, PixelToLogic( aSizePix ), Point(), aSizePix, rBitmap, META_BMP_ACTION );
}
void OutputDevice::DrawBitmap( const Point& rDestPt, const Size& rDestSize, const Bitmap& rBitmap )
{
- if( ImplIsRecordLayout() )
- return;
-
- ImplDrawBitmap( rDestPt, rDestSize, Point(), rBitmap.GetSizePixel(), rBitmap, META_BMPSCALE_ACTION );
-
- if( mpAlphaVDev )
- {
- // #i32109#: Make bitmap area opaque
- mpAlphaVDev->ImplFillOpaqueRectangle( Rectangle(rDestPt, rDestSize) );
- }
+ DrawBitmap( rDestPt, rDestSize, Point(), rBitmap.GetSizePixel(), rBitmap, META_BMPSCALE_ACTION );
}
-void OutputDevice::DrawBitmap( const Point& rDestPt, const Size& rDestSize,
- const Point& rSrcPtPixel, const Size& rSrcSizePixel,
- const Bitmap& rBitmap )
-{
- if( ImplIsRecordLayout() )
- return;
-
- ImplDrawBitmap( rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel, rBitmap, META_BMPSCALEPART_ACTION );
-
- if( mpAlphaVDev )
- {
- // #i32109#: Make bitmap area opaque
- mpAlphaVDev->ImplFillOpaqueRectangle( Rectangle(rDestPt, rDestSize) );
- }
-}
-void OutputDevice::ImplDrawBitmap( const Point& rDestPt, const Size& rDestSize,
+void OutputDevice::DrawBitmap( const Point& rDestPt, const Size& rDestSize,
const Point& rSrcPtPixel, const Size& rSrcSizePixel,
const Bitmap& rBitmap, const sal_uLong nAction )
{
+ if( ImplIsRecordLayout() )
+ return;
+
if ( ( mnDrawMode & DRAWMODE_NOBITMAP ) )
{
return;
@@ -183,6 +153,12 @@ void OutputDevice::ImplDrawBitmap( const Point& rDestPt, const Size& rDestSize,
}
}
}
+
+ if( mpAlphaVDev )
+ {
+ // #i32109#: Make bitmap area opaque
+ mpAlphaVDev->ImplFillOpaqueRectangle( Rectangle(rDestPt, rDestSize) );
+ }
}
void OutputDevice::ScaleBitmap (Bitmap &rBmp, SalTwoRect &rPosAry)
@@ -212,7 +188,7 @@ void OutputDevice::DrawBitmapEx( const Point& rDestPt,
else
{
const Size aSizePix( rBitmapEx.GetSizePixel() );
- ImplDrawBitmapEx( rDestPt, PixelToLogic( aSizePix ), Point(), aSizePix, rBitmapEx, META_BMPEX_ACTION );
+ DrawBitmapEx( rDestPt, PixelToLogic( aSizePix ), Point(), aSizePix, rBitmapEx, META_BMPEX_ACTION );
}
}
@@ -228,14 +204,16 @@ void OutputDevice::DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
}
else
{
- ImplDrawBitmapEx( rDestPt, rDestSize, Point(), rBitmapEx.GetSizePixel(), rBitmapEx, META_BMPEXSCALE_ACTION );
+ DrawBitmapEx( rDestPt, rDestSize, Point(), rBitmapEx.GetSizePixel(), rBitmapEx, META_BMPEXSCALE_ACTION );
}
}
+
void OutputDevice::DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
const Point& rSrcPtPixel, const Size& rSrcSizePixel,
- const BitmapEx& rBitmapEx )
+ const BitmapEx& rBitmapEx, const sal_uLong nAction )
{
+
if( ImplIsRecordLayout() )
return;
@@ -245,10 +223,84 @@ void OutputDevice::DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
}
else
{
- ImplDrawBitmapEx( rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel, rBitmapEx, META_BMPEXSCALEPART_ACTION );
+ if ( mnDrawMode & DRAWMODE_NOBITMAP )
+ return;
+
+ if ( ROP_INVERT == meRasterOp )
+ {
+ DrawRect( Rectangle( rDestPt, rDestSize ) );
+ return;
+ }
+
+ BitmapEx aBmpEx( rBitmapEx );
+
+ if ( mnDrawMode & ( DRAWMODE_BLACKBITMAP | DRAWMODE_WHITEBITMAP |
+ DRAWMODE_GRAYBITMAP | DRAWMODE_GHOSTEDBITMAP ) )
+ {
+ if ( mnDrawMode & ( DRAWMODE_BLACKBITMAP | DRAWMODE_WHITEBITMAP ) )
+ {
+ Bitmap aColorBmp( aBmpEx.GetSizePixel(), ( mnDrawMode & DRAWMODE_GHOSTEDBITMAP ) ? 4 : 1 );
+ sal_uInt8 cCmpVal;
+
+ if ( mnDrawMode & DRAWMODE_BLACKBITMAP )
+ cCmpVal = ( mnDrawMode & DRAWMODE_GHOSTEDBITMAP ) ? 0x80 : 0;
+ else
+ cCmpVal = 255;
+
+ aColorBmp.Erase( Color( cCmpVal, cCmpVal, cCmpVal ) );
+
+ if( aBmpEx.IsAlpha() )
+ {
+ // Create one-bit mask out of alpha channel, by
+ // thresholding it at alpha=0.5. As
+ // DRAWMODE_BLACK/WHITEBITMAP requires monochrome
+ // output, having alpha-induced grey levels is not
+ // acceptable.
+ Bitmap aMask( aBmpEx.GetAlpha().GetBitmap() );
+ aMask.MakeMono( 129 );
+ aBmpEx = BitmapEx( aColorBmp, aMask );
+ }
+ else
+ {
+ aBmpEx = BitmapEx( aColorBmp, aBmpEx.GetMask() );
+ }
+ }
+ else if( !!aBmpEx )
+ {
+ if ( mnDrawMode & DRAWMODE_GRAYBITMAP )
+ aBmpEx.Convert( BMP_CONVERSION_8BIT_GREYS );
+
+ if ( mnDrawMode & DRAWMODE_GHOSTEDBITMAP )
+ aBmpEx.Convert( BMP_CONVERSION_GHOSTED );
+ }
+ }
+
+ if ( mpMetaFile )
+ {
+ switch( nAction )
+ {
+ case( META_BMPEX_ACTION ):
+ mpMetaFile->AddAction( new MetaBmpExAction( rDestPt, aBmpEx ) );
+ break;
+
+ case( META_BMPEXSCALE_ACTION ):
+ mpMetaFile->AddAction( new MetaBmpExScaleAction( rDestPt, rDestSize, aBmpEx ) );
+ break;
+
+ case( META_BMPEXSCALEPART_ACTION ):
+ mpMetaFile->AddAction( new MetaBmpExScalePartAction( rDestPt, rDestSize,
+ rSrcPtPixel, rSrcSizePixel, aBmpEx ) );
+ break;
+ }
+ }
+
+ OUTDEV_INIT();
+
+ DrawDeviceBitmap( rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel, aBmpEx );
}
}
+
bool OutputDevice::DrawTransformBitmapExDirect(
const basegfx::B2DHomMatrix& aFullTransform,
const BitmapEx& rBitmapEx)
@@ -505,88 +557,6 @@ void OutputDevice::DrawTransformedBitmapEx(
}
}
-void OutputDevice::ImplDrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
- const Point& rSrcPtPixel, const Size& rSrcSizePixel,
- const BitmapEx& rBitmapEx, const sal_uLong nAction )
-{
- OSL_ENSURE(TRANSPARENT_NONE != rBitmapEx.GetTransparentType(), "ImplDrawBitmapEx not needed, no transparency in BitmapEx (!)");
-
- if ( mnDrawMode & DRAWMODE_NOBITMAP )
- return;
-
- if ( ROP_INVERT == meRasterOp )
- {
- DrawRect( Rectangle( rDestPt, rDestSize ) );
- return;
- }
-
- BitmapEx aBmpEx( rBitmapEx );
-
- if ( mnDrawMode & ( DRAWMODE_BLACKBITMAP | DRAWMODE_WHITEBITMAP |
- DRAWMODE_GRAYBITMAP | DRAWMODE_GHOSTEDBITMAP ) )
- {
- if ( mnDrawMode & ( DRAWMODE_BLACKBITMAP | DRAWMODE_WHITEBITMAP ) )
- {
- Bitmap aColorBmp( aBmpEx.GetSizePixel(), ( mnDrawMode & DRAWMODE_GHOSTEDBITMAP ) ? 4 : 1 );
- sal_uInt8 cCmpVal;
-
- if ( mnDrawMode & DRAWMODE_BLACKBITMAP )
- cCmpVal = ( mnDrawMode & DRAWMODE_GHOSTEDBITMAP ) ? 0x80 : 0;
- else
- cCmpVal = 255;
-
- aColorBmp.Erase( Color( cCmpVal, cCmpVal, cCmpVal ) );
-
- if( aBmpEx.IsAlpha() )
- {
- // Create one-bit mask out of alpha channel, by
- // thresholding it at alpha=0.5. As
- // DRAWMODE_BLACK/WHITEBITMAP requires monochrome
- // output, having alpha-induced grey levels is not
- // acceptable.
- Bitmap aMask( aBmpEx.GetAlpha().GetBitmap() );
- aMask.MakeMono( 129 );
- aBmpEx = BitmapEx( aColorBmp, aMask );
- }
- else
- {
- aBmpEx = BitmapEx( aColorBmp, aBmpEx.GetMask() );
- }
- }
- else if( !!aBmpEx )
- {
- if ( mnDrawMode & DRAWMODE_GRAYBITMAP )
- aBmpEx.Convert( BMP_CONVERSION_8BIT_GREYS );
-
- if ( mnDrawMode & DRAWMODE_GHOSTEDBITMAP )
- aBmpEx.Convert( BMP_CONVERSION_GHOSTED );
- }
- }
-
- if ( mpMetaFile )
- {
- switch( nAction )
- {
- case( META_BMPEX_ACTION ):
- mpMetaFile->AddAction( new MetaBmpExAction( rDestPt, aBmpEx ) );
- break;
-
- case( META_BMPEXSCALE_ACTION ):
- mpMetaFile->AddAction( new MetaBmpExScaleAction( rDestPt, rDestSize, aBmpEx ) );
- break;
-
- case( META_BMPEXSCALEPART_ACTION ):
- mpMetaFile->AddAction( new MetaBmpExScalePartAction( rDestPt, rDestSize,
- rSrcPtPixel, rSrcSizePixel, aBmpEx ) );
- break;
- }
- }
-
- OUTDEV_INIT();
-
- DrawDeviceBitmap( rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel, aBmpEx );
-}
-
void OutputDevice::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize,
const Point& rSrcPtPixel, const Size& rSrcSizePixel,
BitmapEx& rBmpEx )
diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx
index c5b630a..964d255 100644
--- a/vcl/source/outdev/transparent.cxx
+++ b/vcl/source/outdev/transparent.cxx
@@ -168,7 +168,7 @@ void OutputDevice::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask
Bitmap aBandBmp(aPaint);
aBandBmp.Crop(*aRectIter);
- ImplDrawBitmap(aMapPt, aMapSz, Point(), aBandBmp.GetSizePixel(), aBandBmp, META_BMPSCALEPART_ACTION);
+ DrawBitmap(aMapPt, aMapSz, Point(), aBandBmp.GetSizePixel(), aBandBmp, META_BMPSCALEPART_ACTION);
}
mbMap = bOldMap;
More information about the Libreoffice-commits
mailing list