diff options
Diffstat (limited to 'vcl')
30 files changed, 180 insertions, 86 deletions
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx index 8c0363bbfdc0..722b4dd39200 100644 --- a/vcl/headless/svpbmp.cxx +++ b/vcl/headless/svpbmp.cxx @@ -45,7 +45,7 @@ bool SvpSalBitmap::Create( const Size& rSize, SvpSalInstance* pInst = SvpSalInstance::s_pDefaultInstance; assert( pInst ); - basebmp::Format nFormat = pInst->getFormatForBitCount( nBitCount ); + basebmp::Format nFormat = pInst->getBaseBmpFormatForBitCount( nBitCount ); B2IVector aSize( rSize.Width(), rSize.Height() ); if( aSize.getX() == 0 ) diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx index fc2420010be3..fe381fb16a04 100644 --- a/vcl/headless/svpinst.cxx +++ b/vcl/headless/svpinst.cxx @@ -227,10 +227,10 @@ void SvpSalInstance::DestroyObject( SalObject* pObject ) SalVirtualDevice* SvpSalInstance::CreateVirtualDevice( SalGraphics* /* pGraphics */, long &nDX, long &nDY, - sal_uInt16 nBitCount, + DeviceFormat eFormat, const SystemGraphicsData* /* pData */ ) { - SvpSalVirtualDevice* pNew = new SvpSalVirtualDevice( nBitCount ); + SvpSalVirtualDevice* pNew = new SvpSalVirtualDevice(eFormat); pNew->SetSize( nDX, nDY ); return pNew; } @@ -416,7 +416,7 @@ void SvpSalTimer::Start( sal_uLong nMS ) m_pInstance->StartTimer( nMS ); } -Format SvpSalInstance::getFormatForBitCount( sal_uInt16 nBitCount ) +Format SvpSalInstance::getBaseBmpFormatForBitCount( sal_uInt16 nBitCount ) { switch( nBitCount ) { @@ -439,4 +439,19 @@ Format SvpSalInstance::getFormatForBitCount( sal_uInt16 nBitCount ) } } + +Format SvpSalInstance::getBaseBmpFormatForDeviceFormat(DeviceFormat eFormat) +{ + switch (eFormat) + { + case DeviceFormat::BITMASK: + return Format::OneBitMsbPal; + case DeviceFormat::GRAYSCALE: + return Format::EightBitPal; + default: + return SVP_CAIRO_FORMAT; + } + +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx index f861ac76a9d5..3cc8b5f7d91e 100644 --- a/vcl/headless/svpvd.cxx +++ b/vcl/headless/svpvd.cxx @@ -67,10 +67,10 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, { SvpSalInstance* pInst = SvpSalInstance::s_pDefaultInstance; assert( pInst ); - basebmp::Format nFormat = pInst->getFormatForBitCount( m_nBitCount ); + basebmp::Format nFormat = pInst->getBaseBmpFormatForDeviceFormat(m_eFormat); sal_Int32 nStride = basebmp::getBitmapDeviceStrideForWidth(nFormat, aDevSize.getX()); - if ( m_nBitCount == 1 ) + if (m_eFormat == DeviceFormat::BITMASK) { std::vector< basebmp::Color > aDevPal(2); aDevPal[0] = basebmp::Color( 0, 0, 0 ); diff --git a/vcl/inc/headless/svpinst.hxx b/vcl/inc/headless/svpinst.hxx index 5d926f5ba469..cf30aae0428e 100644 --- a/vcl/inc/headless/svpinst.hxx +++ b/vcl/inc/headless/svpinst.hxx @@ -125,7 +125,7 @@ public: // pData allows for using a system dependent graphics or device context virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics, long &nDX, long &nDY, - sal_uInt16 nBitCount, const SystemGraphicsData *pData = nullptr ) override; + DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr ) override; // Printer // pSetupData->mpDriverData can be 0 @@ -167,7 +167,8 @@ public: virtual GenPspGraphics *CreatePrintGraphics() override; - ::basebmp::Format getFormatForBitCount( sal_uInt16 ); + ::basebmp::Format getBaseBmpFormatForBitCount(sal_uInt16); + ::basebmp::Format getBaseBmpFormatForDeviceFormat(DeviceFormat); }; #endif // INCLUDED_VCL_INC_HEADLESS_SVPINST_HXX diff --git a/vcl/inc/headless/svpvd.hxx b/vcl/inc/headless/svpvd.hxx index bfa055f99f40..4241d383a989 100644 --- a/vcl/inc/headless/svpvd.hxx +++ b/vcl/inc/headless/svpvd.hxx @@ -28,12 +28,12 @@ class SvpSalGraphics; class VCL_DLLPUBLIC SvpSalVirtualDevice : public SalVirtualDevice { - sal_uInt16 m_nBitCount; + DeviceFormat m_eFormat; basebmp::BitmapDeviceSharedPtr m_aDevice; std::list< SvpSalGraphics* > m_aGraphics; public: - SvpSalVirtualDevice( sal_uInt16 nBitCount ) : m_nBitCount(nBitCount) {} + SvpSalVirtualDevice(DeviceFormat eFormat) : m_eFormat(eFormat) {} virtual ~SvpSalVirtualDevice(); // SalVirtualDevice diff --git a/vcl/inc/opengl/x11/salvd.hxx b/vcl/inc/opengl/x11/salvd.hxx index 0ab611eb7baf..49931944a0b0 100644 --- a/vcl/inc/opengl/x11/salvd.hxx +++ b/vcl/inc/opengl/x11/salvd.hxx @@ -33,7 +33,7 @@ class X11OpenGLSalVirtualDevice : public SalVirtualDevice public: X11OpenGLSalVirtualDevice( SalGraphics *pGraphics, long &nDX, long &nDY, - sal_uInt16 nBitCount, + DeviceFormat eFormat, const SystemGraphicsData *pData, X11SalGraphics* pNewGraphics); virtual ~X11OpenGLSalVirtualDevice(); diff --git a/vcl/inc/osx/salinst.h b/vcl/inc/osx/salinst.h index 2e909ee1174c..151da029b58c 100644 --- a/vcl/inc/osx/salinst.h +++ b/vcl/inc/osx/salinst.h @@ -88,7 +88,7 @@ public: virtual void DestroyObject( SalObject* pObject ) override; virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics, long &nDX, long &nDY, - sal_uInt16 nBitCount, + DeviceFormat eFormat, const SystemGraphicsData *pData ) override; virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, ImplJobSetup* pSetupData ) override; diff --git a/vcl/inc/quartz/salvd.h b/vcl/inc/quartz/salvd.h index 7159d166d9d3..4dec3719110f 100644 --- a/vcl/inc/quartz/salvd.h +++ b/vcl/inc/quartz/salvd.h @@ -53,7 +53,7 @@ private: void Destroy(); public: - AquaSalVirtualDevice( AquaSalGraphics* pGraphic, long &nDX, long &nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData ); + AquaSalVirtualDevice( AquaSalGraphics* pGraphic, long &nDX, long &nDY, DeviceFormat eFormat, const SystemGraphicsData *pData ); virtual ~AquaSalVirtualDevice(); virtual SalGraphics* AcquireGraphics() override; diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx index a5f8806a27de..6ed84b909230 100644 --- a/vcl/inc/salinst.hxx +++ b/vcl/inc/salinst.hxx @@ -28,6 +28,7 @@ #include "tools/solar.h" #include "displayconnectiondispatch.hxx" #include "vcl/dllapi.h" +#include "vcl/salgtype.hxx" #include <sal/types.h> #include "rtl/ref.hxx" @@ -90,7 +91,7 @@ public: virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics, long &rDX, long &rDY, - sal_uInt16 nBitCount, const SystemGraphicsData *pData = nullptr ) = 0; + DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr ) = 0; // Printer // pSetupData->mpDriverData can be 0 diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx index ca469a2f83ba..3dd8f0d6da37 100644 --- a/vcl/inc/unx/gtk/gtkinst.hxx +++ b/vcl/inc/unx/gtk/gtkinst.hxx @@ -76,7 +76,7 @@ public: virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) override; virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics*, long &nDX, long &nDY, - sal_uInt16 nBitCount, + DeviceFormat eFormat, const SystemGraphicsData* ) override; virtual SalBitmap* CreateSalBitmap() override; diff --git a/vcl/inc/unx/salinst.h b/vcl/inc/unx/salinst.h index e736faa4106e..5ccb9a1a7a89 100644 --- a/vcl/inc/unx/salinst.h +++ b/vcl/inc/unx/salinst.h @@ -57,11 +57,11 @@ public: /// Gtk vclplug needs to pass GtkSalGraphics to X11SalVirtualDevice, so create it, and pass as pNewGraphics. virtual SalVirtualDevice* CreateX11VirtualDevice(SalGraphics* pGraphics, long &nDX, long &nDY, - sal_uInt16 nBitCount, const SystemGraphicsData* pData, X11SalGraphics* pNewGraphics); + DeviceFormat eFormat, const SystemGraphicsData* pData, X11SalGraphics* pNewGraphics); virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics, long &nDX, long &nDY, - sal_uInt16 nBitCount, const SystemGraphicsData *pData = NULL ) override; + DeviceFormat eFormat, const SystemGraphicsData *pData = NULL ) override; virtual void PostPrintersChanged() override; virtual GenPspGraphics *CreatePrintGraphics() override; diff --git a/vcl/inc/unx/salvd.h b/vcl/inc/unx/salvd.h index fbe173feeb52..ca83c84340a9 100644 --- a/vcl/inc/unx/salvd.h +++ b/vcl/inc/unx/salvd.h @@ -45,7 +45,7 @@ class X11SalVirtualDevice : public SalVirtualDevice public: X11SalVirtualDevice(SalGraphics *pGraphics, long &nDX, long &nDY, - sal_uInt16 nBitCount, const SystemGraphicsData *pData, X11SalGraphics* pNewGraphics); + DeviceFormat eFormat, const SystemGraphicsData *pData, X11SalGraphics* pNewGraphics); virtual ~X11SalVirtualDevice(); diff --git a/vcl/inc/win/salinst.h b/vcl/inc/win/salinst.h index 4c1bc7f7f055..c50aaa57dd3c 100644 --- a/vcl/inc/win/salinst.h +++ b/vcl/inc/win/salinst.h @@ -53,7 +53,7 @@ public: virtual void DestroyObject( SalObject* pObject ) override; virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics, long &nDX, long &nDY, - sal_uInt16 nBitCount, const SystemGraphicsData *pData ) override; + DeviceFormat eFormat, const SystemGraphicsData *pData ) override; virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, ImplJobSetup* pSetupData ) override; virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ) override; diff --git a/vcl/opengl/x11/salvd.cxx b/vcl/opengl/x11/salvd.cxx index 9c8c20e02f0e..627661acf632 100644 --- a/vcl/opengl/x11/salvd.cxx +++ b/vcl/opengl/x11/salvd.cxx @@ -35,7 +35,7 @@ void X11SalGraphics::Init( X11OpenGLSalVirtualDevice *pDevice ) X11OpenGLSalVirtualDevice::X11OpenGLSalVirtualDevice( SalGraphics* pGraphics, long &nDX, long &nDY, - sal_uInt16 nBitCount, + DeviceFormat eFormat, const SystemGraphicsData *pData, X11SalGraphics* pNewGraphics) : mpGraphics(pNewGraphics), @@ -43,9 +43,22 @@ X11OpenGLSalVirtualDevice::X11OpenGLSalVirtualDevice( SalGraphics* pGraphics, mnXScreen( 0 ) { assert(mpGraphics); + // TODO Do we really need the requested bit count? - if( !nBitCount && pGraphics ) - nBitCount = pGraphics->GetBitCount(); + sal_uInt16 nBitCount; + switch (eFormat) + { + case DeviceFormat::BITMASK: + nBitCount = 1; + break; + case DeviceFormat::GRAYSCALE: + nBitCount = 8; + break; + default: + nBitCount = pGraphics->GetBitCount(); + break; + + } // TODO Check where a VirtualDevice is created from SystemGraphicsData assert( pData == nullptr ); (void)pData; diff --git a/vcl/qa/cppunit/lifecycle.cxx b/vcl/qa/cppunit/lifecycle.cxx index 748f603d3b6d..0d6c0c1beb8e 100644 --- a/vcl/qa/cppunit/lifecycle.cxx +++ b/vcl/qa/cppunit/lifecycle.cxx @@ -74,7 +74,7 @@ void LifecycleTest::testVirtualDevice() VclPtr<VirtualDevice> pVDev = VclPtr< VirtualDevice >::Create(); ScopedVclPtrInstance< VirtualDevice > pVDev2; VclPtrInstance<VirtualDevice> pVDev3; - VclPtrInstance<VirtualDevice> pVDev4( 1 ); + VclPtrInstance<VirtualDevice> pVDev4(DeviceFormat::BITMASK); CPPUNIT_ASSERT(!!pVDev && !!pVDev2 && !!pVDev3 && !!pVDev4); } diff --git a/vcl/quartz/salvd.cxx b/vcl/quartz/salvd.cxx index 485ac2018757..b7717fa0f433 100644 --- a/vcl/quartz/salvd.cxx +++ b/vcl/quartz/salvd.cxx @@ -38,7 +38,7 @@ SalVirtualDevice* AquaSalInstance::CreateVirtualDevice( SalGraphics* pGraphics, long &nDX, long &nDY, - sal_uInt16 nBitCount, + DeviceFormat eFormat, const SystemGraphicsData *pData ) { // #i92075# can be called first in a thread @@ -48,29 +48,29 @@ SalVirtualDevice* AquaSalInstance::CreateVirtualDevice( SalGraphics* pGraphics, if( pData ) { return new AquaSalVirtualDevice( static_cast< AquaSalGraphics* >( pGraphics ), - nDX, nDY, nBitCount, pData ); + nDX, nDY, eFormat, pData ); } else { - AquaSalVirtualDevice* pNew = new AquaSalVirtualDevice( NULL, nDX, nDY, nBitCount, NULL ); + AquaSalVirtualDevice* pNew = new AquaSalVirtualDevice( NULL, nDX, nDY, eFormat, NULL ); pNew->SetSize( nDX, nDY ); return pNew; } #else return new AquaSalVirtualDevice( static_cast< AquaSalGraphics* >( pGraphics ), - nDX, nDY, nBitCount, pData ); + nDX, nDY, eFormat, pData ); #endif } AquaSalVirtualDevice::AquaSalVirtualDevice( AquaSalGraphics* pGraphic, long &nDX, long &nDY, - sal_uInt16 nBitCount, const SystemGraphicsData *pData ) + DeviceFormat eFormat, const SystemGraphicsData *pData ) : mbGraphicsUsed( false ) , mxBitmapContext( nullptr ) , mnBitmapDepth( 0 ) , mxLayer( nullptr ) { SAL_INFO( "vcl.virdev", "AquaSalVirtualDevice::AquaSalVirtualDevice() this=" << this - << " size=(" << nDX << "x" << nDY << ") bitcount=" << nBitCount << + << " size=(" << nDX << "x" << nDY << ") bitcount=" << static_cast<int>(eFormat) << " pData=" << pData << " context=" << (pData ? pData->rCGContext : nullptr) ); if( pGraphic && pData && pData->rCGContext ) @@ -110,7 +110,18 @@ AquaSalVirtualDevice::AquaSalVirtualDevice( AquaSalGraphics* pGraphic, long &nDX // create empty new virtual device mbForeignContext = false; // the mxContext is created within VCL mpGraphics = new AquaSalGraphics(); // never fails - mnBitmapDepth = nBitCount; + switch (eFormat) + { + case DeviceFormat::BITMASK: + mnBitmapDepth = 1; + break; + case DeviceFormat::GRAYSCALE: + mnBitmapDepth = 8; + break; + default: + mnBitmapDepth = 0; + break; + } #ifdef MACOSX // inherit resolution from reference device if( pGraphic ) diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index 906d3eb114fb..a75afd6afbf0 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -697,7 +697,8 @@ BitmapEx BitmapEx:: AutoScaleBitmap(BitmapEx & aBitmap, const long aStandardSize Size aStdSize( aStandardSize, aStandardSize ); Rectangle aRect(aEmptyPoint, aStdSize ); - ScopedVclPtrInstance< VirtualDevice > aVirDevice( *Application::GetDefaultDevice(), 0, 1 ); + ScopedVclPtrInstance< VirtualDevice > aVirDevice(*Application::GetDefaultDevice(), + DeviceFormat::FULLCOLOR, DeviceFormat::BITMASK); aVirDevice->SetOutputSizePixel( aStdSize ); aVirDevice->SetFillColor( COL_TRANSPARENT ); aVirDevice->SetLineColor( COL_TRANSPARENT ); diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index 51fb545b7323..b7be53beb206 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -886,7 +886,7 @@ void GDIMetaFile::ImplAddGradientEx( GDIMetaFile& rMtf, const Gradient& rGrad ) { // Generate comment, GradientEx and Gradient actions (within DrawGradient) - ScopedVclPtrInstance< VirtualDevice > aVDev( rMapDev, 0 ); + ScopedVclPtrInstance< VirtualDevice > aVDev(rMapDev, DeviceFormat::FULLCOLOR); aVDev->EnableOutput( false ); GDIMetaFile aGradMtf; diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 2384ef37cece..a454704cfb3c 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -2222,7 +2222,7 @@ OutputDevice* PDFWriterImpl::getReferenceDevice() { if( ! m_pReferenceDevice ) { - VclPtrInstance<VirtualDevice> pVDev( 0 ); + VclPtrInstance<VirtualDevice> pVDev(DeviceFormat::FULLCOLOR); m_pReferenceDevice = pVDev; diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx index 41a604bb19ef..4557dc232c94 100644 --- a/vcl/source/gdi/virdev.cxx +++ b/vcl/source/gdi/virdev.cxx @@ -125,9 +125,9 @@ void VirtualDevice::ReleaseGraphics( bool bRelease ) } void VirtualDevice::ImplInitVirDev( const OutputDevice* pOutDev, - long nDX, long nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData ) + long nDX, long nDY, DeviceFormat eFormat, const SystemGraphicsData *pData ) { - SAL_INFO( "vcl.virdev", "ImplInitVirDev(" << nDX << "," << nDY << "," << nBitCount << ")" ); + SAL_INFO( "vcl.virdev", "ImplInitVirDev(" << nDX << "," << nDY << "," << static_cast<int>(eFormat) << ")" ); bool bErase = nDX > 0 && nDY > 0; @@ -149,7 +149,7 @@ void VirtualDevice::ImplInitVirDev( const OutputDevice* pOutDev, (void)pOutDev->AcquireGraphics(); pGraphics = pOutDev->mpGraphics; if ( pGraphics ) - mpVirDev = pSVData->mpDefInst->CreateVirtualDevice( pGraphics, nDX, nDY, nBitCount, pData ); + mpVirDev = pSVData->mpDefInst->CreateVirtualDevice(pGraphics, nDX, nDY, eFormat, pData); else mpVirDev = nullptr; if ( !mpVirDev ) @@ -160,13 +160,23 @@ void VirtualDevice::ImplInitVirDev( const OutputDevice* pOutDev, css::uno::Reference< css::uno::XInterface >() ); } - mnBitCount = ( nBitCount ? nBitCount : pOutDev->GetBitCount() ); + meFormat = eFormat; + switch (meFormat) + { + case DeviceFormat::BITMASK: + mnBitCount = 1; + case DeviceFormat::GRAYSCALE: + mnBitCount = 8; + default: + mnBitCount = pOutDev->GetBitCount(); + break; + } mnOutWidth = nDX; mnOutHeight = nDY; mbScreenComp = true; - mnAlphaDepth = -1; + meAlphaFormat = DeviceFormat::NONE; - if( mnBitCount < 8 ) + if (meFormat == DeviceFormat::BITMASK) SetAntialiasing( AntialiasingFlags::DisableText ); if ( pOutDev->GetOutDevType() == OUTDEV_PRINTER ) @@ -206,52 +216,46 @@ void VirtualDevice::ImplInitVirDev( const OutputDevice* pOutDev, pSVData->maGDIData.mpFirstVirDev = this; } -VirtualDevice::VirtualDevice( sal_uInt16 nBitCount ) +VirtualDevice::VirtualDevice(DeviceFormat eFormat) : mpVirDev( nullptr ), meRefDevMode( REFDEV_NONE ) { - SAL_WARN_IF( nBitCount > 1 && nBitCount != 8, "vcl.gdi", - "VirtualDevice::VirtualDevice(): Only 0, 1 or 8 allowed for BitCount, not " << nBitCount ); - SAL_INFO( "vcl.gdi", "VirtualDevice::VirtualDevice( " << nBitCount << " )" ); + SAL_INFO( "vcl.gdi", "VirtualDevice::VirtualDevice( " << static_cast<int>(eFormat) << " )" ); - ImplInitVirDev( Application::GetDefaultDevice(), 0, 0, nBitCount ); + ImplInitVirDev(Application::GetDefaultDevice(), 0, 0, eFormat); } -VirtualDevice::VirtualDevice( const OutputDevice& rCompDev, sal_uInt16 nBitCount ) +VirtualDevice::VirtualDevice(const OutputDevice& rCompDev, DeviceFormat eFormat) : mpVirDev( nullptr ), meRefDevMode( REFDEV_NONE ) { - SAL_WARN_IF( nBitCount > 1 && nBitCount != 8 && nBitCount != rCompDev.GetBitCount(), "vcl.gdi", - "VirtualDevice::VirtualDevice(): Only 0, 1 or 8 allowed for BitCount, not " << nBitCount ); - SAL_INFO( "vcl.gdi", "VirtualDevice::VirtualDevice( " << nBitCount << " )" ); + SAL_INFO( "vcl.gdi", "VirtualDevice::VirtualDevice( " << static_cast<int>(eFormat) << " )" ); - ImplInitVirDev( &rCompDev, 0, 0, nBitCount ); + ImplInitVirDev(&rCompDev, 0, 0, eFormat); } -VirtualDevice::VirtualDevice( const OutputDevice& rCompDev, sal_uInt16 nBitCount, sal_uInt16 nAlphaBitCount ) - : mpVirDev( nullptr ), - meRefDevMode( REFDEV_NONE ) +VirtualDevice::VirtualDevice(const OutputDevice& rCompDev, DeviceFormat eFormat, DeviceFormat eAlphaFormat) + : mpVirDev( nullptr ) + , meRefDevMode( REFDEV_NONE ) { - SAL_WARN_IF( nBitCount > 1 && nBitCount != 8, "vcl.gdi", - "VirtualDevice::VirtualDevice(): Only 0, 1 or 8 allowed for BitCount, not " << nBitCount ); SAL_INFO( "vcl.gdi", - "VirtualDevice::VirtualDevice( " << nBitCount << ", " << nAlphaBitCount << " )" ); + "VirtualDevice::VirtualDevice( " << static_cast<int>(eFormat) << ", " << static_cast<int>(eAlphaFormat) << " )" ); - ImplInitVirDev( &rCompDev, 0, 0, nBitCount ); + ImplInitVirDev(&rCompDev, 0, 0, eFormat); // Enable alpha channel - mnAlphaDepth = sal::static_int_cast<sal_Int8>(nAlphaBitCount); + meAlphaFormat = eAlphaFormat; } VirtualDevice::VirtualDevice(const SystemGraphicsData *pData, const Size &rSize, - sal_uInt16 nBitCount) + DeviceFormat eFormat) : mpVirDev( nullptr ), meRefDevMode( REFDEV_NONE ) { - SAL_INFO( "vcl.gdi", "VirtualDevice::VirtualDevice( " << nBitCount << " )" ); + SAL_INFO( "vcl.gdi", "VirtualDevice::VirtualDevice( " << static_cast<int>(eFormat) << " )" ); ImplInitVirDev(Application::GetDefaultDevice(), rSize.Width(), rSize.Height(), - nBitCount, pData); + eFormat, pData); } VirtualDevice::~VirtualDevice() @@ -337,7 +341,7 @@ bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bEra return false; } - pNewVirDev = pSVData->mpDefInst->CreateVirtualDevice( mpGraphics, nNewWidth, nNewHeight, mnBitCount ); + pNewVirDev = pSVData->mpDefInst->CreateVirtualDevice(mpGraphics, nNewWidth, nNewHeight, meFormat); if ( pNewVirDev ) { SalGraphics* pGraphics = pNewVirDev->AcquireGraphics(); @@ -396,7 +400,7 @@ bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, { if( InnerImplSetOutputSizePixel(rNewSize, bErase, pBuffer) ) { - if( mnAlphaDepth != -1 ) + if (meAlphaFormat != DeviceFormat::NONE) { // #110958# Setup alpha bitmap if(mpAlphaVDev && mpAlphaVDev->GetOutputSizePixel() != rNewSize) @@ -406,7 +410,7 @@ bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, if( !mpAlphaVDev ) { - mpAlphaVDev = VclPtr<VirtualDevice>::Create( *this, mnAlphaDepth ); + mpAlphaVDev = VclPtr<VirtualDevice>::Create(*this, meAlphaFormat); mpAlphaVDev->InnerImplSetOutputSizePixel(rNewSize, bErase, pAlphaBuffer); } @@ -449,7 +453,7 @@ bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer( const basebmp::RawMemorySharedArray &pBuffer, const basebmp::RawMemorySharedArray &pAlphaBuffer ) { if (pAlphaBuffer) - mnAlphaDepth = 8; + meAlphaFormat = DeviceFormat::GRAYSCALE; if (pBuffer) { MapMode mm = GetMapMode(); diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index 9a745bea0db5..097d21c396e4 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -236,7 +236,7 @@ bool OutputDevice::ImplDrawRotateText( SalLayout& rSalLayout ) // cache virtual device for rotation if (!mpOutDevData->mpRotateDev) - mpOutDevData->mpRotateDev = VclPtr<VirtualDevice>::Create( *this, 1 ); + mpOutDevData->mpRotateDev = VclPtr<VirtualDevice>::Create(*this, DeviceFormat::BITMASK); VirtualDevice* pVDev = mpOutDevData->mpRotateDev; // size it accordingly @@ -2508,7 +2508,7 @@ bool OutputDevice::GetTextBoundRect( Rectangle& rRect, // fall back to bitmap method to get the bounding rectangle, // so we need a monochrome virtual device with matching font - ScopedVclPtrInstance< VirtualDevice > aVDev( 1 ); + ScopedVclPtrInstance< VirtualDevice > aVDev(DeviceFormat::BITMASK); vcl::Font aFont( GetFont() ); aFont.SetShadow( false ); aFont.SetOutline( false ); @@ -2732,7 +2732,7 @@ bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector, + mnEmphasisDescent; pSalLayout->Release(); - ScopedVclPtrInstance< VirtualDevice > aVDev( 1 ); + ScopedVclPtrInstance< VirtualDevice > aVDev(DeviceFormat::BITMASK); vcl::Font aFont(GetFont()); aFont.SetShadow(false); diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx index d53303d9bbab..4c8a4050f862 100644 --- a/vcl/source/outdev/transparent.cxx +++ b/vcl/source/outdev/transparent.cxx @@ -431,7 +431,7 @@ void OutputDevice::EmulateDrawTransparent ( const tools::PolyPolygon& rPolyPoly, if( !bDrawn ) { - ScopedVclPtrInstance< VirtualDevice > aVDev( *this, 1 ); + ScopedVclPtrInstance< VirtualDevice > aVDev(*this, DeviceFormat::BITMASK); const Size aDstSz( aDstRect.GetSize() ); const sal_uInt8 cTrans = (sal_uInt8) MinMax( FRound( nTransparencePercent * 2.55 ), 0, 255 ); diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx index 22f98498aaff..d2b452c3c6b6 100644 --- a/vcl/source/window/paint.cxx +++ b/vcl/source/window/paint.cxx @@ -1436,7 +1436,9 @@ void Window::ImplPaintToDevice( OutputDevice* i_pTargetOutDev, const Point& i_rP mpWindowImpl->mbReallyVisible = bRVisible; // paint metafile to VDev - VclPtrInstance<VirtualDevice> pMaskedDevice( *i_pTargetOutDev, 0, 0 ); + VclPtrInstance<VirtualDevice> pMaskedDevice(*i_pTargetOutDev, + DeviceFormat::FULLCOLOR, + DeviceFormat::FULLCOLOR); pMaskedDevice->SetOutputSizePixel( GetOutputSizePixel() ); pMaskedDevice->EnableRTL( IsRTLEnabled() ); aMtf.WindStart(); diff --git a/vcl/unx/generic/gdi/cairo_xlib_cairo.cxx b/vcl/unx/generic/gdi/cairo_xlib_cairo.cxx index 71cba584eb22..a45faa4f8061 100644 --- a/vcl/unx/generic/gdi/cairo_xlib_cairo.cxx +++ b/vcl/unx/generic/gdi/cairo_xlib_cairo.cxx @@ -271,7 +271,7 @@ namespace cairo return VclPtr<VirtualDevice>( VclPtr<VirtualDevice>::Create(&aSystemGraphicsData, Size(width, height), - std::max(getDepth(), 0))); + getFormat())); } /** @@ -306,6 +306,26 @@ namespace cairo return -1; } + + /** + * Surface::getFormat: Get the device format of the Canvas surface. + * + * @return color format + **/ + DeviceFormat X11Surface::getFormat() const + { + if (!maSysData.pRenderFormat) + return DeviceFormat::FULLCOLOR; + switch (static_cast<XRenderPictFormat*>(maSysData.pRenderFormat)->depth) + { + case 1: + return DeviceFormat::BITMASK; + case 8: + return DeviceFormat::GRAYSCALE; + default: + return DeviceFormat::FULLCOLOR; + } + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/generic/gdi/cairo_xlib_cairo.hxx b/vcl/unx/generic/gdi/cairo_xlib_cairo.hxx index 319344770a6a..0ccf98a92aca 100644 --- a/vcl/unx/generic/gdi/cairo_xlib_cairo.hxx +++ b/vcl/unx/generic/gdi/cairo_xlib_cairo.hxx @@ -21,10 +21,9 @@ #define INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_XLIB_CAIRO_HXX #include <sal/config.h> - #include <sal/types.h> - #include <vcl/cairo.hxx> +#include <vcl/salgtype.hxx> struct BitmapSystemData; struct SystemEnvData; @@ -92,6 +91,7 @@ namespace cairo { virtual void flush() const override; int getDepth() const; + DeviceFormat getFormat() const; X11PixmapSharedPtr getPixmap() const { return mpPixmap; } void* getRenderFormat() const { return maSysData.pRenderFormat; } long getDrawable() const { return mpPixmap ? mpPixmap->mhDrawable : maSysData.hDrawable; } diff --git a/vcl/unx/generic/gdi/salvd.cxx b/vcl/unx/generic/gdi/salvd.cxx index 8aa87bfc8d46..d86677beb12d 100644 --- a/vcl/unx/generic/gdi/salvd.cxx +++ b/vcl/unx/generic/gdi/salvd.cxx @@ -36,20 +36,20 @@ #include <opengl/x11/salvd.hxx> SalVirtualDevice* X11SalInstance::CreateX11VirtualDevice(SalGraphics* pGraphics, - long &nDX, long &nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData, + long &nDX, long &nDY, DeviceFormat eFormat, const SystemGraphicsData *pData, X11SalGraphics* pNewGraphics) { assert(pNewGraphics); if (OpenGLHelper::isVCLOpenGLEnabled()) - return new X11OpenGLSalVirtualDevice( pGraphics, nDX, nDY, nBitCount, pData, pNewGraphics ); + return new X11OpenGLSalVirtualDevice( pGraphics, nDX, nDY, eFormat, pData, pNewGraphics ); else - return new X11SalVirtualDevice(pGraphics, nDX, nDY, nBitCount, pData, pNewGraphics); + return new X11SalVirtualDevice(pGraphics, nDX, nDY, eFormat, pData, pNewGraphics); } SalVirtualDevice* X11SalInstance::CreateVirtualDevice(SalGraphics* pGraphics, - long &nDX, long &nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData) + long &nDX, long &nDY, DeviceFormat eFormat, const SystemGraphicsData *pData) { - return CreateX11VirtualDevice(pGraphics, nDX, nDY, nBitCount, pData, new X11SalGraphics()); + return CreateX11VirtualDevice(pGraphics, nDX, nDY, eFormat, pData, new X11SalGraphics()); } void X11SalGraphics::Init( X11SalVirtualDevice *pDevice, SalColormap* pColormap, @@ -89,7 +89,7 @@ void X11SalGraphics::Init( X11SalVirtualDevice *pDevice, SalColormap* pColormap, } X11SalVirtualDevice::X11SalVirtualDevice(SalGraphics* pGraphics, long &nDX, long &nDY, - sal_uInt16 nBitCount, const SystemGraphicsData *pData, + DeviceFormat eFormat, const SystemGraphicsData *pData, X11SalGraphics* pNewGraphics) : pGraphics_(pNewGraphics), m_nXScreen(0), @@ -98,8 +98,20 @@ X11SalVirtualDevice::X11SalVirtualDevice(SalGraphics* pGraphics, long &nDX, long SalColormap* pColormap = nullptr; bool bDeleteColormap = false; - if( !nBitCount && pGraphics ) - nBitCount = pGraphics->GetBitCount(); + sal_uInt16 nBitCount; + switch (eFormat) + { + case DeviceFormat::BITMASK: + nBitCount = 1; + break; + case DeviceFormat::GRAYSCALE: + nBitCount = 8; + break; + default: + nBitCount = pGraphics->GetBitCount(); + break; + + } pDisplay_ = vcl_sal::getSalDisplay(GetGenericData()); nDepth_ = nBitCount; diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx index 0e7ba5e7e0cd..ec13855308bc 100644 --- a/vcl/unx/gtk/gtkinst.cxx +++ b/vcl/unx/gtk/gtkinst.cxx @@ -315,19 +315,19 @@ void GtkYieldMutex::ThreadsLeave() SalVirtualDevice* GtkInstance::CreateVirtualDevice( SalGraphics *pG, long &nDX, long &nDY, - sal_uInt16 nBitCount, + DeviceFormat eFormat, const SystemGraphicsData *pGd ) { EnsureInit(); #if GTK_CHECK_VERSION(3,0,0) (void)pG; (void) pGd; - SvpSalVirtualDevice* pNew = new SvpSalVirtualDevice( nBitCount ); + SvpSalVirtualDevice* pNew = new SvpSalVirtualDevice(eFormat); pNew->SetSize( nDX, nDY ); return pNew; #else GtkSalGraphics *pGtkSalGraphics = dynamic_cast<GtkSalGraphics*>(pG); assert(pGtkSalGraphics); - return CreateX11VirtualDevice(pG, nDX, nDY, nBitCount, pGd, + return CreateX11VirtualDevice(pG, nDX, nDY, eFormat, pGd, new GtkSalGraphics(pGtkSalGraphics->GetGtkFrame(), pGtkSalGraphics->GetGtkWidget())); #endif } diff --git a/vcl/unx/gtk3/cairo_gtk3_cairo.cxx b/vcl/unx/gtk3/cairo_gtk3_cairo.cxx index ec5e641f150e..25e5a0ce1264 100644 --- a/vcl/unx/gtk3/cairo_gtk3_cairo.cxx +++ b/vcl/unx/gtk3/cairo_gtk3_cairo.cxx @@ -109,7 +109,7 @@ namespace cairo VclPtr<VirtualDevice> Gtk3Surface::createVirtualDevice() const { - return VclPtrInstance<VirtualDevice>(nullptr, Size(1, 1), 0); + return VclPtrInstance<VirtualDevice>(nullptr, Size(1, 1), DeviceFormat::FULLCOLOR); } } diff --git a/vcl/win/source/gdi/salvd.cxx b/vcl/win/source/gdi/salvd.cxx index 2a492b83413b..9b2136c0a0ca 100644 --- a/vcl/win/source/gdi/salvd.cxx +++ b/vcl/win/source/gdi/salvd.cxx @@ -68,11 +68,25 @@ HBITMAP WinSalVirtualDevice::ImplCreateVirDevBitmap(HDC hDC, long nDX, long nDY, SalVirtualDevice* WinSalInstance::CreateVirtualDevice( SalGraphics* pSGraphics, long &nDX, long &nDY, - sal_uInt16 nBitCount, + DeviceFormat eFormat, const SystemGraphicsData* pData ) { WinSalGraphics* pGraphics = static_cast<WinSalGraphics*>(pSGraphics); + sal_uInt16 nBitCount; + switch (eFormat) + { + case DeviceFormat::BITMASK: + nBitCount = 1; + break; + case DeviceFormat::GRAYSCALE: + nBitCount = 8; + break; + default: + nBitCount = 0; + break; + } + HDC hDC = NULL; HBITMAP hBmp = NULL; bool bOk = FALSE; diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 76ec17d0f0f8..7e398ed12daf 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -789,7 +789,7 @@ public: if ((int)eType < RENDER_AS_BITMAPEX) pNested = VclPtr<VirtualDevice>::Create(rDev).get(); else - pNested = VclPtr<VirtualDevice>::Create(rDev,0,0).get(); + pNested = VclPtr<VirtualDevice>::Create(rDev,DeviceFormat::FULLCOLOR,DeviceFormat::FULLCOLOR).get(); pNested->SetOutputSizePixel(r.GetSize()); Rectangle aWhole(Point(0,0), r.GetSize()); |