diff options
51 files changed, 243 insertions, 141 deletions
diff --git a/canvas/source/directx/dx_textlayout_drawhelper.cxx b/canvas/source/directx/dx_textlayout_drawhelper.cxx index 3db3996b9013..574a9693c021 100644 --- a/canvas/source/directx/dx_textlayout_drawhelper.cxx +++ b/canvas/source/directx/dx_textlayout_drawhelper.cxx @@ -84,12 +84,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) { @@ -105,7 +105,7 @@ namespace dxcanvas rRenderState.DeviceColor, mxGraphicDevice->getDeviceColorSpace()); aColor.SetTransparency(0); - aVirtualDevice.SetTextColor(aColor); + xVirtualDevice->SetTextColor(aColor); // create the font const css::rendering::FontRequest& rFontRequest = rCanvasFont->getFontRequest(); @@ -132,7 +132,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); @@ -145,7 +145,7 @@ namespace dxcanvas } // set font - aVirtualDevice.SetFont(aFont); + xVirtualDevice->SetFont(aFont); // create world transformation matrix ::basegfx::B2DHomMatrix aWorldTransform; @@ -170,7 +170,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()) @@ -178,7 +178,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 @@ -210,7 +210,7 @@ namespace dxcanvas pDXArray[i] = basegfx::fround( rLogicalAdvancements[i] ); // draw the String - aVirtualDevice.DrawTextArray( aEmptyPoint, + xVirtualDevice->DrawTextArray( aEmptyPoint, aText, pDXArray.get(), rText.StartPosition, @@ -219,7 +219,7 @@ namespace dxcanvas else { // draw the String - aVirtualDevice.DrawText( aEmptyPoint, + xVirtualDevice->DrawText( aEmptyPoint, aText, rText.StartPosition, rText.Length ); @@ -240,7 +240,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 css::rendering::FontRequest& rFontRequest = rCanvasFont->getFontRequest(); @@ -261,7 +261,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); @@ -274,11 +274,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() ); @@ -292,7 +292,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 64ddc4442d3f..39a1b67af240 100644 --- a/canvas/source/vcl/backbuffer.cxx +++ b/canvas/source/vcl/backbuffer.cxx @@ -27,7 +27,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 3f7fdd0b27c3..1fb22b04cb85 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 1b8cc7b14e8e..9a72479f544f 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 ae242c290258..add14b383ca6 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 11885b00dea0..7962877deac4 100644 --- a/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx +++ b/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx @@ -241,7 +241,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 211371e49879..68eb01dd67ba 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -882,12 +882,12 @@ 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) - ScopedVclPtrInstance< VirtualDevice > pDevice(nullptr, Size(1, 1), (sal_uInt16)0) ; + ScopedVclPtrInstance< VirtualDevice > pDevice(nullptr, Size(1, 1), DeviceFormat::FULLCOLOR) ; boost::shared_array<sal_uInt8> aBuffer(pBuffer, NoDelete< sal_uInt8 >()); @@ -900,7 +900,7 @@ void doc_paintTile (LibreOfficeKitDocument* pThis, pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight); #else - ScopedVclPtrInstance< VirtualDevice > pDevice(nullptr, Size(1, 1), (sal_uInt16)0) ; + 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 21bd6c6244b3..be7ff6541fa7 100644 --- a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx +++ b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx @@ -96,7 +96,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 06b7b5bc9fd3..2d1d498f095d 100644 --- a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx +++ b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx @@ -47,7 +47,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 @@ -80,13 +80,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 = nullptr; - if (nBits == 0) - nBits = rOutDev.GetBitCount(); + sal_Int32 nBits = bMonoChrome ? 1 : rOutDev.GetBitCount(); if(!maFreeBuffers.empty()) { @@ -97,7 +96,7 @@ namespace { OSL_ENSURE(*a, "Empty pointer in VDevBuffer (!)"); - if(nBits == (*a)->GetBitCount()) + if (nBits == (*a)->GetBitCount()) { // candidate is valid due to bit depth if(aFound != maFreeBuffers.end()) @@ -163,7 +162,7 @@ namespace // no success yet, create new buffer if(!pRetval) { - pRetval = VclPtr<VirtualDevice>::Create(rOutDev, nBits); + pRetval = VclPtr<VirtualDevice>::Create(rOutDev, bMonoChrome ? DeviceFormat::BITMASK : DeviceFormat::FULLCOLOR); pRetval->SetOutputSizePixel(rSizePixel, bClear); } else @@ -243,9 +242,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 @@ -361,7 +360,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! @@ -375,7 +374,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 3c63a7695883..8bc304e5ee34 100644 --- a/filter/source/graphicfilter/eps/eps.cxx +++ b/filter/source/graphicfilter/eps/eps.cxx @@ -2125,7 +2125,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 235c2743ea5f..55951e8b7706 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -4394,7 +4394,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 8a340099a11d..59654f6595d5 100644 --- a/include/vcl/salgtype.hxx +++ b/include/vcl/salgtype.hxx @@ -22,6 +22,8 @@ #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 740b9bf7db24..76076ba657fd 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 = nullptr ); + 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 ); SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, @@ -76,7 +78,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 @@ -87,8 +89,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 @@ -106,14 +108,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() override; diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index d975c3f908c1..12be8260b9c9 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 face96dd5e65..db281d63195b 100644 --- a/sd/source/ui/presenter/PresenterTextView.cxx +++ b/sd/source/ui/presenter/PresenterTextView.cxx @@ -242,7 +242,7 @@ PresenterTextView::Implementation::Implementation() msTotalHeightPropertyName("TotalHeight"), mxBitmap(), mpCanvas(), - mpOutputDevice(VclPtr<VirtualDevice>::Create(*Application::GetDefaultDevice(), 0, 0)), + mpOutputDevice(VclPtr<VirtualDevice>::Create(*Application::GetDefaultDevice(), DeviceFormat::FULLCOLOR, DeviceFormat::FULLCOLOR)), mpEditEngine(nullptr), mpEditEngineItemPool(EditEngine::CreatePool()), maSize(100,100), @@ -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); mpOutputDevice->SetLineColor(); diff --git a/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx b/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx index 7e06c12541c8..84590d864b37 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 b3eca3e9c2a1..bae4ee3d0912 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 9fa46c5fc375..5deea9502202 100644 --- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx @@ -166,7 +166,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 ); @@ -260,7 +260,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(); diff --git a/svx/source/dialog/dialcontrol.cxx b/svx/source/dialog/dialcontrol.cxx index 18f6a5c002b7..c93c0ace9e81 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 234a0e2f04b6..1b47d299138f 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 4bede9964e10..738be4b47fa6 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3426,8 +3426,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/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()); |