diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-11-17 13:03:23 +0000 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2016-05-16 14:56:56 +0200 |
commit | 8dabcecd6cc371d5ad030b7e7793dc863b18a26b (patch) | |
tree | 22d17d9c09a3da810eb113cc2ff5b4e1387b81c9 | |
parent | c5f401b762f90718995ec5d8503b1db0ab6c43ad (diff) |
establish that Virtual Devices either match Physical Device depth or ...
are 1 or (rarely) 8 bit and lock that down.
Change-Id: I3d946ebef34ffb71c5adea7aa420af50e9584e05
46 files changed, 249 insertions, 154 deletions
diff --git a/canvas/source/directx/dx_textlayout_drawhelper.cxx b/canvas/source/directx/dx_textlayout_drawhelper.cxx index c46a49ffda25..323ad1bcf683 100644 --- a/canvas/source/directx/dx_textlayout_drawhelper.cxx +++ b/canvas/source/directx/dx_textlayout_drawhelper.cxx @@ -86,12 +86,12 @@ namespace dxcanvas SystemGraphicsData aSystemGraphicsData; aSystemGraphicsData.nSize = sizeof(SystemGraphicsData); aSystemGraphicsData.hDC = reinterpret_cast< ::HDC >(hdc); - VirtualDevice aVirtualDevice(&aSystemGraphicsData, Size(1, 1), 0); + ScopedVclPtrInstance<VirtualDevice> xVirtualDevice(&aSystemGraphicsData, Size(1, 1), DeviceFormat::FULLCOLOR); // disable font antialiasing - GDI does not handle alpha // surfaces properly. if( bAlphaSurface ) - aVirtualDevice.SetAntialiasing(AntialiasingFlags::DisableText); + xVirtualDevice->SetAntialiasing(AntialiasingFlags::DisableText); if(rText.Length) { @@ -107,7 +107,7 @@ namespace dxcanvas rRenderState.DeviceColor, mxGraphicDevice->getDeviceColorSpace()); aColor.SetTransparency(0); - aVirtualDevice.SetTextColor(aColor); + xVirtualDevice->SetTextColor(aColor); // create the font const ::com::sun::star::rendering::FontRequest& rFontRequest = rCanvasFont->getFontRequest(); @@ -134,7 +134,7 @@ namespace dxcanvas // adjust to stretched font if(!::rtl::math::approxEqual(rFontMatrix.m00, rFontMatrix.m11)) { - const Size aSize = aVirtualDevice.GetFontMetric( aFont ).GetSize(); + const Size aSize = xVirtualDevice->GetFontMetric( aFont ).GetSize(); const double fDividend( rFontMatrix.m10 + rFontMatrix.m11 ); double fStretch = (rFontMatrix.m00 + rFontMatrix.m01); @@ -147,7 +147,7 @@ namespace dxcanvas } // set font - aVirtualDevice.SetFont(aFont); + xVirtualDevice->SetFont(aFont); // create world transformation matrix ::basegfx::B2DHomMatrix aWorldTransform; @@ -172,7 +172,7 @@ namespace dxcanvas aClipPoly.transform(aMatrix); const vcl::Region& rClipRegion = vcl::Region(::tools::PolyPolygon(aClipPoly)); - aVirtualDevice.IntersectClipRegion(rClipRegion); + xVirtualDevice->IntersectClipRegion(rClipRegion); } if(rRenderState.Clip.is()) @@ -180,7 +180,7 @@ namespace dxcanvas ::basegfx::B2DPolyPolygon aClipPoly(dxcanvas::tools::polyPolygonFromXPolyPolygon2D(rRenderState.Clip)); aClipPoly.transform(aWorldTransform); const vcl::Region& rClipRegion = vcl::Region(::tools::PolyPolygon(aClipPoly)); - aVirtualDevice.IntersectClipRegion(rClipRegion); + xVirtualDevice->IntersectClipRegion(rClipRegion); } // set world transform @@ -212,7 +212,7 @@ namespace dxcanvas pDXArray[i] = basegfx::fround( rLogicalAdvancements[i] ); // draw the String - aVirtualDevice.DrawTextArray( aEmptyPoint, + xVirtualDevice->DrawTextArray( aEmptyPoint, aText, pDXArray.get(), rText.StartPosition, @@ -221,7 +221,7 @@ namespace dxcanvas else { // draw the String - aVirtualDevice.DrawText( aEmptyPoint, + xVirtualDevice->DrawText( aEmptyPoint, aText, rText.StartPosition, rText.Length ); @@ -242,7 +242,7 @@ namespace dxcanvas SystemGraphicsData aSystemGraphicsData; aSystemGraphicsData.nSize = sizeof(SystemGraphicsData); aSystemGraphicsData.hDC = reinterpret_cast< ::HDC >(GetDC( NULL )); - VirtualDevice aVirtualDevice(&aSystemGraphicsData, Size(1, 1), 0); + ScopedVclPtrInstance<VirtualDevice> xVirtualDevice(&aSystemGraphicsData, Size(1, 1), DeviceFormat::FULLCOLOR); // create the font const ::com::sun::star::rendering::FontRequest& rFontRequest = rCanvasFont->getFontRequest(); @@ -263,7 +263,7 @@ namespace dxcanvas // adjust to stretched font if(!::rtl::math::approxEqual(rFontMatrix.m00, rFontMatrix.m11)) { - const Size aSize = aVirtualDevice.GetFontMetric( aFont ).GetSize(); + const Size aSize = xVirtualDevice->GetFontMetric( aFont ).GetSize(); const double fDividend( rFontMatrix.m10 + rFontMatrix.m11 ); double fStretch = (rFontMatrix.m00 + rFontMatrix.m01); @@ -276,11 +276,11 @@ namespace dxcanvas } // set font - aVirtualDevice.SetFont(aFont); + xVirtualDevice->SetFont(aFont); // need metrics for Y offset, the XCanvas always renders // relative to baseline - const ::FontMetric& aMetric( aVirtualDevice.GetFontMetric() ); + const ::FontMetric& aMetric( xVirtualDevice->GetFontMetric() ); const sal_Int32 nAboveBaseline( -aMetric.GetIntLeading() - aMetric.GetAscent() ); const sal_Int32 nBelowBaseline( aMetric.GetDescent() ); @@ -294,7 +294,7 @@ namespace dxcanvas else { return geometry::RealRectangle2D( 0, nAboveBaseline, - aVirtualDevice.GetTextWidth( + xVirtualDevice->GetTextWidth( rText.Text, ::canvas::tools::numeric_cast<sal_uInt16>(rText.StartPosition), ::canvas::tools::numeric_cast<sal_uInt16>(rText.Length) ), diff --git a/canvas/source/vcl/backbuffer.cxx b/canvas/source/vcl/backbuffer.cxx index 8f3a98054ed7..a7ccf7e215f0 100644 --- a/canvas/source/vcl/backbuffer.cxx +++ b/canvas/source/vcl/backbuffer.cxx @@ -26,7 +26,7 @@ namespace vclcanvas BackBuffer::BackBuffer( const OutputDevice& rRefDevice, bool bMonochromeBuffer ) : maVDev( VclPtr<VirtualDevice>::Create( rRefDevice, - sal_uInt16(bMonochromeBuffer) ) ) + bMonochromeBuffer ? DeviceFormat::BITMASK : DeviceFormat::FULLCOLOR ) ) { if( !bMonochromeBuffer ) { diff --git a/canvas/source/vcl/bitmapbackbuffer.cxx b/canvas/source/vcl/bitmapbackbuffer.cxx index 4fd79bc2df33..7f0c1fb586b4 100644 --- a/canvas/source/vcl/bitmapbackbuffer.cxx +++ b/canvas/source/vcl/bitmapbackbuffer.cxx @@ -112,7 +112,7 @@ namespace vclcanvas // VDev not yet created, do it now. Create an alpha-VDev, // if bitmap has transparency. mpVDev = maBitmap->IsTransparent() ? - VclPtr<VirtualDevice>::Create( mrRefDevice, 0, 0 ) : + VclPtr<VirtualDevice>::Create( mrRefDevice, DeviceFormat::FULLCOLOR, DeviceFormat::FULLCOLOR ) : VclPtr<VirtualDevice>::Create( mrRefDevice ); OSL_ENSURE( mpVDev, diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx index b1354c588eed..45c53d093905 100644 --- a/chart2/source/view/main/3DChartObjects.cxx +++ b/chart2/source/view/main/3DChartObjects.cxx @@ -76,7 +76,8 @@ const TextCacheItem& TextCache::getText(OUString const & rText, bool bIs3dText) if(itr != maTextCache.end()) return *itr->second; - ScopedVclPtrInstance< VirtualDevice > pDevice(*Application::GetDefaultDevice(), 0, 0); + ScopedVclPtrInstance< VirtualDevice > pDevice(*Application::GetDefaultDevice(), + DeviceFormat::FULLCOLOR, DeviceFormat::FULLCOLOR); vcl::Font aFont; if(bIs3dText) aFont = vcl::Font("Brillante St",Size(0,0)); diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx index eec97ff3395d..cdfc240da4ff 100644 --- a/chart2/source/view/main/DummyXShape.cxx +++ b/chart2/source/view/main/DummyXShape.cxx @@ -835,7 +835,8 @@ DummyText::DummyText(const OUString& rText, const tNameSequence& rNames, { vcl::Font aFont; std::for_each(maProperties.begin(), maProperties.end(), FontAttribSetter(aFont)); - ScopedVclPtrInstance< VirtualDevice > pDevice(*Application::GetDefaultDevice(), 0, 0); + ScopedVclPtrInstance< VirtualDevice > pDevice(*Application::GetDefaultDevice(), + DeviceFormat::FULLCOLOR, DeviceFormat::FULLCOLOR); pDevice->Erase(); Rectangle aRect; pDevice->SetFont(aFont); diff --git a/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx b/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx index 4dc23f2a659b..ec1a8218e75c 100644 --- a/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx +++ b/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx @@ -244,7 +244,7 @@ namespace cppcanvas // render our content into an appropriately sized // VirtualDevice with alpha channel ScopedVclPtrInstance<VirtualDevice> aVDev( - *::Application::GetDefaultDevice(), 0, 0 ); + *::Application::GetDefaultDevice(), DeviceFormat::FULLCOLOR, DeviceFormat::FULLCOLOR ); aVDev->SetOutputSizePixel( aBitmapSizePixel ); aVDev->SetMapMode(); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 20a40ce60b8d..4781cd7a3a13 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1001,14 +1001,14 @@ void doc_paintTile(LibreOfficeKitDocument* pThis, SystemGraphicsData aData; aData.rCGContext = reinterpret_cast<CGContextRef>(pBuffer); // the Size argument is irrelevant, I hope - ScopedVclPtrInstance<VirtualDevice> pDevice(&aData, Size(1, 1), (sal_uInt16)0); + ScopedVclPtrInstance<VirtualDevice> pDevice(&aData, Size(1, 1), DeviceFormat::FULLCOLOR); pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight); #elif defined(ANDROID) InitSvpForLibreOfficeKit(); - ScopedVclPtrInstance< VirtualDevice > pDevice(nullptr, Size(1, 1), (sal_uInt16)32) ; + ScopedVclPtrInstance< VirtualDevice > pDevice(nullptr, Size(1, 1), DeviceFormat::FULLCOLOR) ; boost::shared_array<sal_uInt8> aBuffer(pBuffer, NoDelete< sal_uInt8 >()); @@ -1023,7 +1023,7 @@ void doc_paintTile(LibreOfficeKitDocument* pThis, #else InitSvpForLibreOfficeKit(); - ScopedVclPtrInstance< VirtualDevice > pDevice(nullptr, Size(1, 1), (sal_uInt16)32) ; + ScopedVclPtrInstance< VirtualDevice > pDevice(nullptr, Size(1, 1), DeviceFormat::FULLCOLOR) ; // Set background to transparent by default. memset(pBuffer, 0, nCanvasWidth * nCanvasHeight * 4); diff --git a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx index 7ed0045f778a..ce1c9a76fb57 100644 --- a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx +++ b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx @@ -97,7 +97,8 @@ namespace if(maAnimation.Count()) { ScopedVclPtrInstance< VirtualDevice > aVirtualDevice(*Application::GetDefaultDevice()); - ScopedVclPtrInstance< VirtualDevice > aVirtualDeviceMask(*Application::GetDefaultDevice(), 1L); + ScopedVclPtrInstance< VirtualDevice > aVirtualDeviceMask(*Application::GetDefaultDevice(), + DeviceFormat::BITMASK); // Prepare VirtualDevices and their states aVirtualDevice->EnableMapMode(false); diff --git a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx index 7c66c2ce379f..ccf6d30460a6 100644 --- a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx +++ b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx @@ -54,7 +54,7 @@ namespace VDevBuffer(); virtual ~VDevBuffer(); - VirtualDevice* alloc(OutputDevice& rOutDev, const Size& rSizePixel, bool bClear, sal_Int32 nBits); + VirtualDevice* alloc(OutputDevice& rOutDev, const Size& rSizePixel, bool bClear, bool bMonoChrome); void free(VirtualDevice& rDevice); // Timer virtuals @@ -87,13 +87,12 @@ namespace } } - VirtualDevice* VDevBuffer::alloc(OutputDevice& rOutDev, const Size& rSizePixel, bool bClear, sal_Int32 nBits) + VirtualDevice* VDevBuffer::alloc(OutputDevice& rOutDev, const Size& rSizePixel, bool bClear, bool bMonoChrome) { ::osl::MutexGuard aGuard(m_aMutex); VirtualDevice* pRetval = 0; - if (nBits == 0) - nBits = rOutDev.GetBitCount(); + sal_Int32 nBits = bMonoChrome ? 1 : rOutDev.GetBitCount(); bool bOkay(false); if(!maFreeBuffers.empty()) @@ -104,7 +103,7 @@ namespace { assert(*a && "Empty pointer in VDevBuffer (!)"); - if(nBits == (*a)->GetBitCount()) + if (nBits == (*a)->GetBitCount()) { // candidate is valid due to bit depth if(aFound != maFreeBuffers.end()) @@ -185,8 +184,7 @@ namespace // no success yet, create new buffer if(!pRetval) { - pRetval = VclPtr<VirtualDevice>::Create(rOutDev, nBits); - maDeviceTemplates[pRetval] = &rOutDev; + pRetval = VclPtr<VirtualDevice>::Create(rOutDev, bMonoChrome ? DeviceFormat::BITMASK : DeviceFormat::FULLCOLOR); pRetval->SetOutputSizePixel(rSizePixel, bClear); } else @@ -268,9 +266,9 @@ namespace drawinglayer // rendering, especially shadows, is broken on iOS unless // we pass 'true' here. Are virtual devices always de // facto cleared when created on other platforms? - mpContent = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), true, 0); + mpContent = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), true, false); #else - mpContent = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), false, 0); + mpContent = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), false, false); #endif // #i93485# assert when copying from window to VDev is used @@ -386,7 +384,7 @@ namespace drawinglayer assert(mpContent && "impBufferDevice: No content, check isVisible() before accessing (!)"); if (!mpMask) { - mpMask = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), true, 1); + mpMask = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), true, true); mpMask->SetMapMode(mpContent->GetMapMode()); // do NOT copy AA flag for mask! @@ -400,7 +398,7 @@ namespace drawinglayer OSL_ENSURE(mpContent, "impBufferDevice: No content, check isVisible() before accessing (!)"); if(!mpAlpha) { - mpAlpha = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), true, 0); + mpAlpha = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), true, false); mpAlpha->SetMapMode(mpContent->GetMapMode()); // copy AA flag for new target; masking needs to be smooth diff --git a/filter/source/graphicfilter/eps/eps.cxx b/filter/source/graphicfilter/eps/eps.cxx index abdbb4c9c526..e742ae6a9b6c 100644 --- a/filter/source/graphicfilter/eps/eps.cxx +++ b/filter/source/graphicfilter/eps/eps.cxx @@ -2142,7 +2142,7 @@ void PSWriter::ImplText( const OUString& rUniString, const Point& rPos, const lo vcl::Font aNotRotatedFont( maFont ); aNotRotatedFont.SetOrientation( 0 ); - ScopedVclPtrInstance< VirtualDevice > pVirDev( 1 ); + ScopedVclPtrInstance< VirtualDevice > pVirDev(DeviceFormat::BITMASK); pVirDev->SetMapMode( rVDev.GetMapMode() ); pVirDev->SetFont( aNotRotatedFont ); pVirDev->SetTextAlign( eTextAlign ); diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index b68b9af215d4..12992a4110df 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -4416,7 +4416,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r rOutliner.SetStyleSheetPool( static_cast<SfxStyleSheetPool*>(pModel->GetStyleSheetPool()) ); rOutliner.SetUpdateMode( false ); rOutliner.SetText( *pParaObj ); - ScopedVclPtrInstance< VirtualDevice > pVirDev( 1 ); + ScopedVclPtrInstance< VirtualDevice > pVirDev(DeviceFormat::BITMASK); pVirDev->SetMapMode( MAP_100TH_MM ); sal_Int32 i, nParagraphs = rOutliner.GetParagraphCount(); if ( nParagraphs ) diff --git a/include/vcl/salgtype.hxx b/include/vcl/salgtype.hxx index de8a5555fee4..59654f6595d5 100644 --- a/include/vcl/salgtype.hxx +++ b/include/vcl/salgtype.hxx @@ -20,6 +20,10 @@ #ifndef INCLUDED_VCL_SALGTYPE_HXX #define INCLUDED_VCL_SALGTYPE_HXX +#include <sal/types.h> + +enum class DeviceFormat { NONE = -1, FULLCOLOR = 0, BITMASK = 1, GRAYSCALE = 8 }; + typedef sal_uInt32 SalColor; #define MAKE_SALCOLOR( r, g, b ) ((SalColor)(((sal_uInt32)((sal_uInt8)(b))))|(((sal_uInt32)((sal_uInt8)(g)))<<8)|(((sal_uInt32)((sal_uInt8)(r)))<<16)) #define SALCOLOR_RED( n ) ((sal_uInt8)((n)>>16)) diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx index 85e0afd78131..1a58097c5bf0 100644 --- a/include/vcl/virdev.hxx +++ b/include/vcl/virdev.hxx @@ -22,6 +22,7 @@ #include <basebmp/bitmapdevice.hxx> #include <vcl/dllapi.h> +#include <vcl/salgtype.hxx> #include <vcl/outdev.hxx> class SalVirtualDevice; @@ -39,10 +40,11 @@ private: VclPtr<VirtualDevice> mpNext; sal_uInt16 mnBitCount; bool mbScreenComp; - sal_Int8 mnAlphaDepth; + DeviceFormat meFormat; + DeviceFormat meAlphaFormat; sal_uInt8 meRefDevMode; - SAL_DLLPRIVATE void ImplInitVirDev( const OutputDevice* pOutDev, long nDX, long nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData = NULL ); + SAL_DLLPRIVATE void ImplInitVirDev( const OutputDevice* pOutDev, long nDX, long nDY, DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr ); SAL_DLLPRIVATE bool InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase, const basebmp::RawMemorySharedArray &pBuffer, const bool bTopDown ); @@ -79,7 +81,7 @@ public: indicate: take default screen depth. Only 0, 1 and 8 are allowed here, with 1 denoting binary mask and 8 a graylevel mask. */ - explicit VirtualDevice( sal_uInt16 nBitCount = 0 ); + explicit VirtualDevice(DeviceFormat eFormat = DeviceFormat::FULLCOLOR); /** Create a virtual device of size 1x1 @@ -90,8 +92,8 @@ public: Bit depth of the generated virtual device. Use 0 here, to indicate: take default screen depth. */ - explicit VirtualDevice( const OutputDevice& rCompDev, - sal_uInt16 nBitCount = 0 ); + explicit VirtualDevice(const OutputDevice& rCompDev, + DeviceFormat eFormat = DeviceFormat::FULLCOLOR); /** Create a virtual device of size 1x1 with alpha channel @@ -109,14 +111,14 @@ public: are allowed here, with 1 denoting binary mask. */ explicit VirtualDevice( const OutputDevice& rCompDev, - sal_uInt16 nBitCount, sal_uInt16 nAlphaBitCount ); + DeviceFormat eFormat, DeviceFormat eAlphaFormat); /** Create a virtual device using an existing system dependent device or graphics context Any rendering will happen directly on the context and not on any intermediate bitmap. Note: This might not be supported on all platforms ! */ explicit VirtualDevice(const SystemGraphicsData *pData, const Size &rSize, - sal_uInt16 nBitCount); + DeviceFormat eFormat); virtual ~VirtualDevice(); virtual void dispose() SAL_OVERRIDE; diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index 2bdfa30e3160..e20bb33bb8f9 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -193,9 +193,9 @@ VirtualDevice* ScDocument::GetVirtualDevice_100th_mm() if (!pVirtualDevice_100th_mm) { #ifdef IOS - pVirtualDevice_100th_mm = VclPtr<VirtualDevice>::Create( 8 ); + pVirtualDevice_100th_mm = VclPtr<VirtualDevice>::Create(DeviceFormat::GRAYSCALE); #else - pVirtualDevice_100th_mm = VclPtr<VirtualDevice>::Create( 1 ); + pVirtualDevice_100th_mm = VclPtr<VirtualDevice>::Create(DeviceFormat::BITMASK); #endif pVirtualDevice_100th_mm->SetReferenceDevice(VirtualDevice::REFDEV_MODE_MSO1); MapMode aMapMode( pVirtualDevice_100th_mm->GetMapMode() ); diff --git a/sd/source/ui/presenter/PresenterTextView.cxx b/sd/source/ui/presenter/PresenterTextView.cxx index c8d9c364fd05..1b67c27d7fe3 100644 --- a/sd/source/ui/presenter/PresenterTextView.cxx +++ b/sd/source/ui/presenter/PresenterTextView.cxx @@ -242,8 +242,8 @@ PresenterTextView::Implementation::Implementation() msTotalHeightPropertyName("TotalHeight"), mxBitmap(), mpCanvas(), - mpOutputDevice(VclPtr<VirtualDevice>::Create(*Application::GetDefaultDevice(), 0, 0)), - mpEditEngine(NULL), + mpOutputDevice(VclPtr<VirtualDevice>::Create(*Application::GetDefaultDevice(), DeviceFormat::FULLCOLOR, DeviceFormat::FULLCOLOR)), + mpEditEngine(nullptr), mpEditEngineItemPool(EditEngine::CreatePool()), maSize(100,100), maBackgroundColor(0xffffffff), @@ -454,7 +454,8 @@ Reference<rendering::XBitmap> PresenterTextView::Implementation::GetBitmap() if ( ! mxBitmap.is()) { mpOutputDevice.disposeAndClear(); - mpOutputDevice = VclPtr<VirtualDevice>::Create(*Application::GetDefaultDevice(), 0, 0); + mpOutputDevice = VclPtr<VirtualDevice>::Create(*Application::GetDefaultDevice(), + DeviceFormat::FULLCOLOR, DeviceFormat::FULLCOLOR); mpOutputDevice->SetMapMode(MAP_PIXEL); mpOutputDevice->SetOutputSizePixel(maSize, true); mpOutputDevice->SetLineColor(); diff --git a/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx b/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx index cb237454d009..6a336071130b 100644 --- a/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx +++ b/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx @@ -135,7 +135,7 @@ void InsertionIndicatorOverlay::Create ( // Create virtual devices for bitmap and mask whose bitmaps later be // combined to form the BitmapEx of the icon. ScopedVclPtrInstance<VirtualDevice> pContent( - *mrSlideSorter.GetContentWindow(), 0, 0); + *mrSlideSorter.GetContentWindow(), DeviceFormat::FULLCOLOR, DeviceFormat::FULLCOLOR); pContent->SetOutputSizePixel(aIconSize); pContent->SetFillColor(); diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index aef617517544..67aea175981b 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -84,7 +84,8 @@ namespace svt { namespace table Point const aBitmapPos( 0, 0 ); Size const aBitmapSize( nSortIndicatorWidth, nSortIndicatorHeight ); - ScopedVclPtrInstance< VirtualDevice > aDevice( i_device, 0, 0 ); + ScopedVclPtrInstance< VirtualDevice > aDevice(i_device, DeviceFormat::FULLCOLOR, + DeviceFormat::FULLCOLOR); aDevice->SetOutputSizePixel( aBitmapSize ); DecorationView aDecoView(aDevice.get()); diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx index 7e033863237f..b0c6cebb2bd1 100644 --- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx @@ -165,7 +165,7 @@ void CalculateHorizontalScalingFactor( const SdrObject* pCustomShape, aFont.SetOrientation( 0 ); // initializing virtual device - ScopedVclPtrInstance< VirtualDevice > pVirDev( 1 ); + ScopedVclPtrInstance< VirtualDevice > pVirDev(DeviceFormat::BITMASK); pVirDev->SetMapMode( MAP_100TH_MM ); pVirDev->SetFont( aFont ); @@ -259,7 +259,7 @@ void GetTextAreaOutline( const FWData& rFWData, const SdrObject* pCustomShape, F aFont.SetWeight( rWeightItem.GetWeight() ); // initializing virtual device - ScopedVclPtrInstance< VirtualDevice > pVirDev( 1 ); + ScopedVclPtrInstance< VirtualDevice > pVirDev(DeviceFormat::BITMASK); pVirDev->SetMapMode( MAP_100TH_MM ); pVirDev->SetFont( aFont ); pVirDev->EnableRTL( true ); diff --git a/svx/source/dialog/dialcontrol.cxx b/svx/source/dialog/dialcontrol.cxx index c8459b01d378..77703d89462f 100644 --- a/svx/source/dialog/dialcontrol.cxx +++ b/svx/source/dialog/dialcontrol.cxx @@ -35,7 +35,7 @@ namespace svx { const long DIAL_OUTER_WIDTH = 8; DialControlBmp::DialControlBmp(vcl::Window& rParent) : - VirtualDevice(rParent, 0, 0), + VirtualDevice(rParent, DeviceFormat::FULLCOLOR, DeviceFormat::FULLCOLOR), mbEnabled(true), mrParent(rParent), mnCenterX(0), diff --git a/sw/source/core/doc/DocumentDeviceManager.cxx b/sw/source/core/doc/DocumentDeviceManager.cxx index fc1f86b79c09..ccf0df948a6e 100644 --- a/sw/source/core/doc/DocumentDeviceManager.cxx +++ b/sw/source/core/doc/DocumentDeviceManager.cxx @@ -261,9 +261,9 @@ DocumentDeviceManager::~DocumentDeviceManager() VirtualDevice& DocumentDeviceManager::CreateVirtualDevice_() const { #ifdef IOS - VclPtr<VirtualDevice> pNewVir = VclPtr<VirtualDevice>::Create( 8 ); + VclPtr<VirtualDevice> pNewVir = VclPtr<VirtualDevice>::Create(DeviceFormat::GRAYSCALE); #else - VclPtr<VirtualDevice> pNewVir = VclPtr<VirtualDevice>::Create( 1 ); + VclPtr<VirtualDevice> pNewVir = VclPtr<VirtualDevice>::Create(DeviceFormat::BITMASK); #endif pNewVir->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 ); diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 341fadff8b21..0fb6e3b58cbe 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3510,8 +3510,8 @@ void SAL_CALL SwXTextDocument::paintTile( const ::css::uno::Any& Parent, ::sal_I sal_Int64 nWindowHandle; Parent >>= nWindowHandle; aData.hWnd = (HWND) nWindowHandle; - VirtualDevice aDevice(&aData, Size(1, 1), (sal_uInt16)32); - paintTile( aDevice, nOutputWidth, nOutputHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight ); + ScopedVclPtrInstance<VirtualDevice> xDevice(&aData, Size(1, 1), DeviceFormat::FULLCOLOR); + paintTile(*xDevice, nOutputWidth, nOutputHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight); #else // TODO: support other platforms (void)Parent; diff --git a/vcl/inc/opengl/x11/salvd.hxx b/vcl/inc/opengl/x11/salvd.hxx index e4e6ecda0860..ccac4d1f7981 100644 --- a/vcl/inc/opengl/x11/salvd.hxx +++ b/vcl/inc/opengl/x11/salvd.hxx @@ -33,8 +33,9 @@ class X11OpenGLSalVirtualDevice : public SalVirtualDevice public: X11OpenGLSalVirtualDevice( SalGraphics *pGraphics, long &nDX, long &nDY, - sal_uInt16 nBitCount, - const SystemGraphicsData *pData ); + DeviceFormat eFormat, + const SystemGraphicsData *pData, + X11SalGraphics* pNewGraphics); virtual ~X11OpenGLSalVirtualDevice(); // SalGeometryProvider diff --git a/vcl/inc/osx/salinst.h b/vcl/inc/osx/salinst.h index b2d6133495fa..057e2bede9c3 100644 --- a/vcl/inc/osx/salinst.h +++ b/vcl/inc/osx/salinst.h @@ -88,10 +88,10 @@ public: virtual void DestroyFrame( SalFrame* pFrame ) SAL_OVERRIDE; virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool bShow = true ) SAL_OVERRIDE; virtual void DestroyObject( SalObject* pObject ) SAL_OVERRIDE; - virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics, - long &nDX, long &nDY, - sal_uInt16 nBitCount, - const SystemGraphicsData *pData ) SAL_OVERRIDE; + virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics, + long &nDX, long &nDY, + DeviceFormat eFormat, + const SystemGraphicsData *pData ) override; virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, ImplJobSetup* pSetupData ) SAL_OVERRIDE; virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ) SAL_OVERRIDE; diff --git a/vcl/inc/quartz/salvd.h b/vcl/inc/quartz/salvd.h index 4a4e0f666481..36229bba26ee 100644 --- a/vcl/inc/quartz/salvd.h +++ b/vcl/inc/quartz/salvd.h @@ -55,7 +55,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() SAL_OVERRIDE; diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx index eb5317746f96..b04b4ca237a1 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" @@ -89,7 +90,7 @@ public: virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics, long &rDX, long &rDY, - sal_uInt16 nBitCount, const SystemGraphicsData *pData = NULL ) = 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 28bca3645b21..bf506c361a45 100644 --- a/vcl/inc/unx/gtk/gtkinst.hxx +++ b/vcl/inc/unx/gtk/gtkinst.hxx @@ -76,8 +76,8 @@ public: virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) SAL_OVERRIDE; virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics*, long &nDX, long &nDY, - sal_uInt16 nBitCount, - const SystemGraphicsData* ) SAL_OVERRIDE; + DeviceFormat eFormat, + const SystemGraphicsData* ) override; virtual SalBitmap* CreateSalBitmap() SAL_OVERRIDE; virtual void Yield( bool bWait, bool bHandleAllCurrentEvents ) SAL_OVERRIDE; diff --git a/vcl/inc/unx/salinst.h b/vcl/inc/unx/salinst.h index 381ddda2e35f..8678287a2083 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 ) SAL_OVERRIDE; + DeviceFormat eFormat, const SystemGraphicsData *pData = NULL ) override; virtual void PostPrintersChanged() SAL_OVERRIDE; virtual GenPspGraphics *CreatePrintGraphics() SAL_OVERRIDE; diff --git a/vcl/inc/unx/salvd.h b/vcl/inc/unx/salvd.h index 14ad97e9008b..ab310c4d9ae2 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 450d07cfc139..50a563133304 100644 --- a/vcl/inc/win/salinst.h +++ b/vcl/inc/win/salinst.h @@ -43,7 +43,7 @@ public: virtual void DestroyObject( SalObject* pObject ) SAL_OVERRIDE; virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics, long &nDX, long &nDY, - sal_uInt16 nBitCount, const SystemGraphicsData *pData ) SAL_OVERRIDE; + DeviceFormat eFormat, const SystemGraphicsData *pData ) SAL_OVERRIDE; virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, ImplJobSetup* pSetupData ) SAL_OVERRIDE; virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ) SAL_OVERRIDE; diff --git a/vcl/opengl/x11/salvd.cxx b/vcl/opengl/x11/salvd.cxx index a613ce5f84fc..6dc3c8cbb304 100644 --- a/vcl/opengl/x11/salvd.cxx +++ b/vcl/opengl/x11/salvd.cxx @@ -35,14 +35,30 @@ void X11SalGraphics::Init( X11OpenGLSalVirtualDevice *pDevice ) X11OpenGLSalVirtualDevice::X11OpenGLSalVirtualDevice( SalGraphics* pGraphics, long &nDX, long &nDY, - sal_uInt16 nBitCount, - const SystemGraphicsData *pData ) : + DeviceFormat eFormat, + const SystemGraphicsData *pData, + X11SalGraphics* pNewGraphics) : + mpGraphics(pNewGraphics), mbGraphics( false ), 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 == NULL ); (void)pData; diff --git a/vcl/qa/cppunit/lifecycle.cxx b/vcl/qa/cppunit/lifecycle.cxx index a4e7e774e653..880ea798c858 100644 --- a/vcl/qa/cppunit/lifecycle.cxx +++ b/vcl/qa/cppunit/lifecycle.cxx @@ -70,7 +70,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 ae25748dfa12..f22782b2b579 100644 --- a/vcl/quartz/salvd.cxx +++ b/vcl/quartz/salvd.cxx @@ -35,32 +35,42 @@ #include "quartz/utils.h" SalVirtualDevice* AquaSalInstance::CreateVirtualDevice( SalGraphics* pGraphics, - long &nDX, long &nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData ) + long &nDX, long &nDY, + DeviceFormat eFormat, + const SystemGraphicsData *pData ) { // #i92075# can be called first in a thread SalData::ensureThreadAutoreleasePool(); #ifdef IOS if( pData ) - return new AquaSalVirtualDevice( static_cast< AquaSalGraphics* >( pGraphics ), nDX, nDY, nBitCount, pData ); + { + return new AquaSalVirtualDevice( static_cast< AquaSalGraphics* >( pGraphics ), + 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 ); + return new AquaSalVirtualDevice( static_cast< AquaSalGraphics* >( pGraphics ), + nDX, nDY, eFormat, pData ); #endif } -AquaSalVirtualDevice::AquaSalVirtualDevice( AquaSalGraphics* pGraphic, long &nDX, long &nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData ) -: mbGraphicsUsed( false ) -, mxBitmapContext( NULL ) -, mnBitmapDepth( 0 ) -, mxLayer( NULL ) +AquaSalVirtualDevice::AquaSalVirtualDevice( AquaSalGraphics* pGraphic, long &nDX, long &nDY, + 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 << " pData=" << pData << " context=" << (pData ? pData->rCGContext : 0) ); + SAL_INFO( "vcl.virdev", "AquaSalVirtualDevice::AquaSalVirtualDevice() this=" << this + << " size=(" << nDX << "x" << nDY << ") bitcount=" << static_cast<int>(eFormat) << + " pData=" << pData << " context=" << (pData ? pData->rCGContext : nullptr) ); + if( pGraphic && pData && pData->rCGContext ) { // Create virtual device based on existing SystemGraphicsData @@ -92,7 +102,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 19beb4c49d0c..449c8e993e0d 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -705,7 +705,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 8d283dff051a..3715a5c32544 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -892,7 +892,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 44d1f45c197f..679fd6249909 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -2221,7 +2221,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 ee44d30267e8..81c59ddb762f 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 = NULL; if ( !mpVirDev ) @@ -160,13 +160,23 @@ void VirtualDevice::ImplInitVirDev( const OutputDevice* pOutDev, ::com::sun::star::uno::Reference< ::com::sun::star::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 ) -: mpVirDev( NULL ), +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 ) - : mpVirDev( NULL ), +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( NULL ), - 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) -: mpVirDev( NULL ), + 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() @@ -338,7 +342,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(); @@ -398,7 +402,7 @@ bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, { if( InnerImplSetOutputSizePixel(rNewSize, bErase, pBuffer, bTopDown) ) { - if( mnAlphaDepth != -1 ) + if (meAlphaFormat != DeviceFormat::NONE) { // #110958# Setup alpha bitmap if(mpAlphaVDev && mpAlphaVDev->GetOutputSizePixel() != rNewSize) @@ -408,7 +412,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, bTopDown ); @@ -452,7 +456,7 @@ bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer( const basebmp::RawMemorySharedArray &pBuffer, const basebmp::RawMemorySharedArray &pAlphaBuffer, const bool bTopDown ) { 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 17bbb93c835f..931f6d1fb7cc 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -237,7 +237,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 @@ -2519,7 +2519,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 ); @@ -2743,7 +2743,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 7f3b355b6f8a..b06476a61069 100644 --- a/vcl/source/outdev/transparent.cxx +++ b/vcl/source/outdev/transparent.cxx @@ -441,7 +441,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 0dec9d55d75c..5f81deb002d4 100644 --- a/vcl/source/window/paint.cxx +++ b/vcl/source/window/paint.cxx @@ -1442,7 +1442,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 0bc8004c58b8..249519330caf 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 5be944f87e42..c5ec58dd8242 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; @@ -94,6 +93,7 @@ namespace cairo { virtual void flush() const SAL_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 0a5414638338..7f4894c95314 100644 --- a/vcl/unx/generic/gdi/salvd.cxx +++ b/vcl/unx/generic/gdi/salvd.cxx @@ -36,22 +36,19 @@ #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) { if (OpenGLHelper::isVCLOpenGLEnabled()) - return new X11OpenGLSalVirtualDevice( pGraphics, nDX, nDY, nBitCount, pData ); + return new X11OpenGLSalVirtualDevice( pGraphics, nDX, nDY, eFormat, pData, pNewGraphics ); else - { - assert(pNewGraphics); - 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, @@ -91,7 +88,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), @@ -100,8 +97,20 @@ X11SalVirtualDevice::X11SalVirtualDevice(SalGraphics* pGraphics, long &nDX, long SalColormap* pColormap = NULL; 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/app/gtkinst.cxx b/vcl/unx/gtk/app/gtkinst.cxx index 601fd2152d1d..00a92618987a 100644 --- a/vcl/unx/gtk/app/gtkinst.cxx +++ b/vcl/unx/gtk/app/gtkinst.cxx @@ -317,23 +317,20 @@ 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); - - GtkSalGraphics *pNewGraphics = NULL; - if (pGtkSalGraphics) - pNewGraphics = new GtkSalGraphics(pGtkSalGraphics->GetGtkFrame(), pGtkSalGraphics->GetGtkWidget()); - - return CreateX11VirtualDevice(pG, nDX, nDY, nBitCount, pGd, pNewGraphics); + assert(pGtkSalGraphics); + return CreateX11VirtualDevice(pG, nDX, nDY, eFormat, pGd, + new GtkSalGraphics(pGtkSalGraphics->GetGtkFrame(), pGtkSalGraphics->GetGtkWidget())); #endif } diff --git a/vcl/unx/gtk3/gdi/cairo_gtk3_cairo.cxx b/vcl/unx/gtk3/gdi/cairo_gtk3_cairo.cxx index b9a2751fc4aa..fd01b531f22b 100644 --- a/vcl/unx/gtk3/gdi/cairo_gtk3_cairo.cxx +++ b/vcl/unx/gtk3/gdi/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 fd8c01f8ab57..b5ae16b5e3ad 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -788,7 +788,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()); |