Kaydet (Commit) 4d1111aa authored tarafından Chris Sherlock's avatar Chris Sherlock

fdo#74702 Move device specific bitmap drawing to its own function

Device specific drawing has been moved to its own function.
VirtualDevice and Window draw in the same way, so can be shared in
OutputDevice, however Printer has its only specific ways of drawing
so it needs its own method.

Change-Id: I051fee029a1ec022a131bb12588189178c4109b2
Reviewed-on: https://gerrit.libreoffice.org/8724Reviewed-by: 's avatarChris Sherlock <chris.sherlock79@gmail.com>
Tested-by: 's avatarChris Sherlock <chris.sherlock79@gmail.com>
üst 12d30ef0
...@@ -832,7 +832,13 @@ protected: ...@@ -832,7 +832,13 @@ protected:
basegfx::B2DRange &aVisibleRange, basegfx::B2DRange &aVisibleRange,
double &fMaximumArea); double &fMaximumArea);
virtual void ScaleBitmap ( Bitmap &rBmp, SalTwoRect &rPosAry ); virtual void ScaleBitmap ( Bitmap &rBmp, SalTwoRect &rPosAry );
virtual void DrawDeviceBitmap(
const Point& rDestPt, const Size& rDestSize,
const Point& rSrcPtPixel, const Size& rSrcSizePixel,
BitmapEx& rBitmapEx );
private: private:
typedef void ( OutputDevice::* FontUpdateHandler_t )( bool ); typedef void ( OutputDevice::* FontUpdateHandler_t )( bool );
...@@ -845,7 +851,7 @@ private: ...@@ -845,7 +851,7 @@ private:
SAL_DLLPRIVATE static void ImplUpdateFontDataForAllFrames( FontUpdateHandler_t pHdl, bool bNewFontLists ); SAL_DLLPRIVATE static void ImplUpdateFontDataForAllFrames( FontUpdateHandler_t pHdl, bool bNewFontLists );
SAL_DLLPRIVATE long ImplGetGradientSteps( const Gradient& rGradient, const Rectangle& rRect, bool bMtf ); SAL_DLLPRIVATE long ImplGetGradientSteps( const Gradient& rGradient, const Rectangle& rRect, bool bMtf );
//not implemented; to detect misuses of DrawOutDev(...OutputDevice&); // not implemented; to detect misuses of DrawOutDev(...OutputDevice&);
void DrawOutDev( const Point&, const Size&, const Point&, const Size&, const Printer&); void DrawOutDev( const Point&, const Size&, const Point&, const Size&, const Printer&);
public: public:
...@@ -1039,6 +1045,9 @@ public: ...@@ -1039,6 +1045,9 @@ public:
virtual void DrawOutDev( const Point& rDestPt, const Size& rDestSize, virtual void DrawOutDev( const Point& rDestPt, const Size& rDestSize,
const Point& rSrcPt, const Size& rSrcSize, const Point& rSrcPt, const Size& rSrcSize,
const OutputDevice& rOutDev ); const OutputDevice& rOutDev );
void DrawOutDev( const Point& rDestPt, const Size& rDestSize,
const Point& rSrcPt, const Size& rSrcSize,
const Printer& rOutDev );
virtual void CopyArea( const Point& rDestPt, virtual void CopyArea( const Point& rDestPt,
const Point& rSrcPt, const Size& rSrcSize, const Point& rSrcPt, const Size& rSrcSize,
sal_uInt16 nFlags = 0 ); sal_uInt16 nFlags = 0 );
...@@ -1141,25 +1150,25 @@ public: ...@@ -1141,25 +1150,25 @@ public:
BitmapEx GetBitmapEx( const Point& rSrcPt, const Size& rSize ) const; BitmapEx GetBitmapEx( const Point& rSrcPt, const Size& rSize ) const;
void EnableMapMode( bool bEnable = true ); void EnableMapMode( bool bEnable = true );
bool IsMapModeEnabled() const { return mbMap; } bool IsMapModeEnabled() const { return mbMap; }
// Enabling/disabling RTL only makes sense for OutputDevices that use a mirroring SalGraphisLayout // Enabling/disabling RTL only makes sense for OutputDevices that use a mirroring SalGraphisLayout
virtual void EnableRTL( bool bEnable = true); void EnableRTL( bool bEnable = true);
bool IsRTLEnabled() const { return mbEnableRTL; } bool IsRTLEnabled() const { return mbEnableRTL; }
void SetConnectMetaFile( GDIMetaFile* pMtf ); void SetConnectMetaFile( GDIMetaFile* pMtf );
GDIMetaFile* GetConnectMetaFile() const { return mpMetaFile; } GDIMetaFile* GetConnectMetaFile() const { return mpMetaFile; }
void EnableOutput( bool bEnable = true ); void EnableOutput( bool bEnable = true );
bool IsOutputEnabled() const { return mbOutput; } bool IsOutputEnabled() const { return mbOutput; }
bool IsDeviceOutput() const { return mbDevOutput; } bool IsDeviceOutput() const { return mbDevOutput; }
bool IsDeviceOutputNecessary() const { return (mbOutput && mbDevOutput); } bool IsDeviceOutputNecessary() const { return (mbOutput && mbDevOutput); }
bool IsOutputNecessary() const { return ((mbOutput && mbDevOutput) || (mpMetaFile != NULL)); } bool IsOutputNecessary() const { return ((mbOutput && mbDevOutput) || (mpMetaFile != NULL)); }
void SetClipRegion(); void SetClipRegion();
void SetClipRegion( const Region& rRegion ); void SetClipRegion( const Region& rRegion );
Region GetClipRegion() const; Region GetClipRegion() const;
bool IsClipRegion() const { return mbClipRegion; } bool IsClipRegion() const { return mbClipRegion; }
Region GetActiveClipRegion() const; Region GetActiveClipRegion() const;
void MoveClipRegion( long nHorzMove, long nVertMove ); void MoveClipRegion( long nHorzMove, long nVertMove );
...@@ -1409,16 +1418,16 @@ public: ...@@ -1409,16 +1418,16 @@ public:
sal_Int32* pKashidaPosDropped // invalid kashida positions (out) sal_Int32* pKashidaPosDropped // invalid kashida positions (out)
) const; ) const;
virtual sal_uInt16 GetBitCount() const; sal_uInt16 GetBitCount() const;
bool GetTextIsRTL( const OUString&, sal_Int32 nIndex, sal_Int32 nLen ) const; bool GetTextIsRTL( const OUString&, sal_Int32 nIndex, sal_Int32 nLen ) const;
/** Query the existence and depth of the alpha channel /** Query the existence and depth of the alpha channel
@return 0, if no alpha channel available, and the bit depth of @return 0, if no alpha channel available, and the bit depth of
the alpha channel otherwise. the alpha channel otherwise.
*/ */
virtual sal_uInt16 GetAlphaBitCount() const; sal_uInt16 GetAlphaBitCount() const;
sal_uLong GetColorCount() const; sal_uLong GetColorCount() const;
void Push( sal_uInt16 nFlags = PUSH_ALL ); void Push( sal_uInt16 nFlags = PUSH_ALL );
...@@ -1482,7 +1491,7 @@ public: ...@@ -1482,7 +1491,7 @@ public:
@attention This method ignores negative rDstSz values, thus @attention This method ignores negative rDstSz values, thus
mirroring must happen outside this method (e.g. in DrawBitmap) mirroring must happen outside this method (e.g. in DrawBitmap)
*/ */
Bitmap GetDownsampledBitmap( const Size& rDstSz, Bitmap GetDownsampledBitmap( const Size& rDstSz,
const Point& rSrcPt, const Size& rSrcSz, const Point& rSrcPt, const Size& rSrcSz,
const Bitmap& rBmp, long nMaxBmpDPIX, long nMaxBmpDPIY ); const Bitmap& rBmp, long nMaxBmpDPIX, long nMaxBmpDPIY );
......
...@@ -295,6 +295,10 @@ protected: ...@@ -295,6 +295,10 @@ protected:
basegfx::B2DRange &aVisibleRange, basegfx::B2DRange &aVisibleRange,
double &fMaximumArea); double &fMaximumArea);
void DrawDeviceBitmap(
const Point& rDestPt, const Size& rDestSize,
const Point& rSrcPtPixel, const Size& rSrcSizePixel,
BitmapEx& rBitmapEx );
public: public:
Printer(); Printer();
......
...@@ -966,32 +966,18 @@ void OutputDevice::ImplDrawBitmapEx( const Point& rDestPt, const Size& rDestSize ...@@ -966,32 +966,18 @@ void OutputDevice::ImplDrawBitmapEx( const Point& rDestPt, const Size& rDestSize
OUTDEV_INIT(); OUTDEV_INIT();
if( OUTDEV_PRINTER == meOutDevType ) DrawDeviceBitmap( rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel, aBmpEx );
{ }
if( aBmpEx.IsAlpha() )
{
// #107169# For true alpha bitmaps, no longer masking the
// bitmap, but perform a full alpha blend against a white
// background here.
Bitmap aBmp( aBmpEx.GetBitmap() );
aBmp.Blend( aBmpEx.GetAlpha(), Color( COL_WHITE) );
DrawBitmap( rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel, aBmp );
}
else
{
Bitmap aBmp( aBmpEx.GetBitmap() ), aMask( aBmpEx.GetMask() );
aBmp.Replace( aMask, Color( COL_WHITE ) );
ImplPrintTransparent( aBmp, aMask, rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel );
}
return;
}
if(aBmpEx.IsAlpha()) void OutputDevice::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize,
const Point& rSrcPtPixel, const Size& rSrcSizePixel,
BitmapEx& rBmpEx )
{
if(rBmpEx.IsAlpha())
{ {
Size aDestSizePixel(LogicToPixel(rDestSize)); Size aDestSizePixel(LogicToPixel(rDestSize));
BitmapEx aScaledBitmapEx(aBmpEx); BitmapEx aScaledBitmapEx(rBmpEx);
Point aSrcPtPixel(rSrcPtPixel); Point aSrcPtPixel(rSrcPtPixel);
Size aSrcSizePixel(rSrcSizePixel); Size aSrcSizePixel(rSrcSizePixel);
...@@ -1011,7 +997,7 @@ void OutputDevice::ImplDrawBitmapEx( const Point& rDestPt, const Size& rDestSize ...@@ -1011,7 +997,7 @@ void OutputDevice::ImplDrawBitmapEx( const Point& rDestPt, const Size& rDestSize
return; return;
} }
if( !( !aBmpEx ) ) if( !( !rBmpEx ) )
{ {
SalTwoRect aPosAry; SalTwoRect aPosAry;
...@@ -1024,16 +1010,16 @@ void OutputDevice::ImplDrawBitmapEx( const Point& rDestPt, const Size& rDestSize ...@@ -1024,16 +1010,16 @@ void OutputDevice::ImplDrawBitmapEx( const Point& rDestPt, const Size& rDestSize
aPosAry.mnDestWidth = ImplLogicWidthToDevicePixel( rDestSize.Width() ); aPosAry.mnDestWidth = ImplLogicWidthToDevicePixel( rDestSize.Width() );
aPosAry.mnDestHeight = ImplLogicHeightToDevicePixel( rDestSize.Height() ); aPosAry.mnDestHeight = ImplLogicHeightToDevicePixel( rDestSize.Height() );
const sal_uLong nMirrFlags = ImplAdjustTwoRect( aPosAry, aBmpEx.GetSizePixel() ); const sal_uLong nMirrFlags = ImplAdjustTwoRect( aPosAry, rBmpEx.GetSizePixel() );
if( aPosAry.mnSrcWidth && aPosAry.mnSrcHeight && aPosAry.mnDestWidth && aPosAry.mnDestHeight ) if( aPosAry.mnSrcWidth && aPosAry.mnSrcHeight && aPosAry.mnDestWidth && aPosAry.mnDestHeight )
{ {
if( nMirrFlags ) if( nMirrFlags )
aBmpEx.Mirror( nMirrFlags ); rBmpEx.Mirror( nMirrFlags );
const SalBitmap* pSalSrcBmp = aBmpEx.ImplGetBitmapImpBitmap()->ImplGetSalBitmap(); const SalBitmap* pSalSrcBmp = rBmpEx.ImplGetBitmapImpBitmap()->ImplGetSalBitmap();
const ImpBitmap* pMaskBmp = aBmpEx.ImplGetMaskImpBitmap(); const ImpBitmap* pMaskBmp = rBmpEx.ImplGetMaskImpBitmap();
if ( pMaskBmp ) if ( pMaskBmp )
{ {
...@@ -1131,8 +1117,8 @@ void OutputDevice::ImplDrawBitmapEx( const Point& rDestPt, const Size& rDestSize ...@@ -1131,8 +1117,8 @@ void OutputDevice::ImplDrawBitmapEx( const Point& rDestPt, const Size& rDestSize
if( mpAlphaVDev ) if( mpAlphaVDev )
mpAlphaVDev->DrawBitmapEx( rDestPt, mpAlphaVDev->DrawBitmapEx( rDestPt,
rDestSize, rDestSize,
BitmapEx( aBmpEx.GetMask(), BitmapEx( rBmpEx.GetMask(),
aBmpEx.GetMask() ) ); rBmpEx.GetMask() ) );
} }
else else
{ {
......
...@@ -229,6 +229,27 @@ bool Printer::TransformReduceBitmapExTargetRange( ...@@ -229,6 +229,27 @@ bool Printer::TransformReduceBitmapExTargetRange(
return true; return true;
} }
void Printer::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize,
const Point& rSrcPtPixel, const Size& rSrcSizePixel,
BitmapEx& rBmpEx )
{
if( rBmpEx.IsAlpha() )
{
// #107169# For true alpha bitmaps, no longer masking the
// bitmap, but perform a full alpha blend against a white
// background here.
Bitmap aBmp( rBmpEx.GetBitmap() );
aBmp.Blend( rBmpEx.GetAlpha(), Color( COL_WHITE) );
DrawBitmap( rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel, aBmp );
}
else
{
Bitmap aBmp( rBmpEx.GetBitmap() ), aMask( rBmpEx.GetMask() );
aBmp.Replace( aMask, Color( COL_WHITE ) );
ImplPrintTransparent( aBmp, aMask, rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel );
}
}
void Printer::DrawOutDev( const Point& /*rDestPt*/, const Size& /*rDestSize*/, void Printer::DrawOutDev( const Point& /*rDestPt*/, const Size& /*rDestSize*/,
const Point& /*rSrcPt*/, const Size& /*rSrcSize*/ ) const Point& /*rSrcPt*/, const Size& /*rSrcSize*/ )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment