summaryrefslogtreecommitdiff
path: root/drawinglayer
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-03-19 13:54:12 +0200
committerMichael Meeks <michael.meeks@collabora.com>2015-04-10 12:10:43 +0100
commit820576af4fd6441a752742b43d804e9837839925 (patch)
tree205b0a04d1bd5063ad3005b9679c1facea2ca2c8 /drawinglayer
parentbf739995fc97ed61a586e949a868ac67fc3b7d95 (diff)
start wrapping OutputDevice in VclPtr
Change-Id: If3ecbb0599b50d50ce6b3997ca7892200c332ffe
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/source/primitive2d/controlprimitive2d.cxx8
-rw-r--r--drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx48
-rw-r--r--drawinglayer/source/primitive2d/textlayoutdevice.cxx4
-rw-r--r--drawinglayer/source/processor2d/vclhelperbufferdevice.cxx8
-rw-r--r--drawinglayer/source/processor2d/vclhelperbufferdevice.hxx6
-rw-r--r--drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx40
-rw-r--r--drawinglayer/source/processor2d/vclprocessor2d.hxx3
-rw-r--r--drawinglayer/source/tools/converters.cxx24
8 files changed, 71 insertions, 70 deletions
diff --git a/drawinglayer/source/primitive2d/controlprimitive2d.cxx b/drawinglayer/source/primitive2d/controlprimitive2d.cxx
index b764e02c21d1..bb84b292ab26 100644
--- a/drawinglayer/source/primitive2d/controlprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/controlprimitive2d.cxx
@@ -116,15 +116,15 @@ namespace drawinglayer
if(nSizeX > 0 && nSizeY > 0)
{
// prepare VirtualDevice
- VirtualDevice aVirtualDevice(*Application::GetDefaultDevice());
+ ScopedVclPtr<VirtualDevice> aVirtualDevice(new VirtualDevice(*Application::GetDefaultDevice()));
const Size aSizePixel(nSizeX, nSizeY);
- aVirtualDevice.SetOutputSizePixel(aSizePixel);
+ aVirtualDevice->SetOutputSizePixel(aSizePixel);
// set size at control
xControlWindow->setPosSize(0, 0, nSizeX, nSizeY, awt::PosSize::POSSIZE);
// get graphics and view
- uno::Reference< awt::XGraphics > xGraphics(aVirtualDevice.CreateUnoGraphics());
+ uno::Reference< awt::XGraphics > xGraphics(aVirtualDevice->CreateUnoGraphics());
uno::Reference< awt::XView > xControlView(rXControl, uno::UNO_QUERY);
if(xGraphics.is() && xControlView.is())
@@ -190,7 +190,7 @@ namespace drawinglayer
xControlView->draw(0, 0);
// get bitmap
- const Bitmap aContent(aVirtualDevice.GetBitmap(Point(), aSizePixel));
+ const Bitmap aContent(aVirtualDevice->GetBitmap(Point(), aSizePixel));
// to avoid scaling, use the Bitmap pixel size as primitive size
const Size aBitmapSize(aContent.GetSizePixel());
diff --git a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
index ecf3bb257ce0..1f6ee8d82f9a 100644
--- a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
+++ b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
@@ -96,16 +96,16 @@ namespace
// with a step count of zero
if(maAnimation.Count())
{
- VirtualDevice aVirtualDevice(*Application::GetDefaultDevice());
- VirtualDevice aVirtualDeviceMask(*Application::GetDefaultDevice(), 1L);
+ ScopedVclPtr<VirtualDevice> aVirtualDevice(new VirtualDevice(*Application::GetDefaultDevice()));
+ ScopedVclPtr<VirtualDevice> aVirtualDeviceMask(new VirtualDevice(*Application::GetDefaultDevice(), 1L));
// Prepare VirtualDevices and their states
- aVirtualDevice.EnableMapMode(false);
- aVirtualDeviceMask.EnableMapMode(false);
- aVirtualDevice.SetOutputSizePixel(maAnimation.GetDisplaySizePixel());
- aVirtualDeviceMask.SetOutputSizePixel(maAnimation.GetDisplaySizePixel());
- aVirtualDevice.Erase();
- aVirtualDeviceMask.Erase();
+ aVirtualDevice->EnableMapMode(false);
+ aVirtualDeviceMask->EnableMapMode(false);
+ aVirtualDevice->SetOutputSizePixel(maAnimation.GetDisplaySizePixel());
+ aVirtualDeviceMask->SetOutputSizePixel(maAnimation.GetDisplaySizePixel());
+ aVirtualDevice->Erase();
+ aVirtualDeviceMask->Erase();
for(sal_uInt16 a(0L); a < maAnimation.Count(); a++)
{
@@ -119,20 +119,20 @@ namespace
{
case DISPOSE_NOT:
{
- aVirtualDevice.DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx);
+ aVirtualDevice->DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx);
Bitmap aMask = rAnimBitmap.aBmpEx.GetMask();
if(aMask.IsEmpty())
{
const Point aEmpty;
- const Rectangle aRect(aEmpty, aVirtualDeviceMask.GetOutputSizePixel());
+ const Rectangle aRect(aEmpty, aVirtualDeviceMask->GetOutputSizePixel());
const Wallpaper aWallpaper(COL_BLACK);
- aVirtualDeviceMask.DrawWallpaper(aRect, aWallpaper);
+ aVirtualDeviceMask->DrawWallpaper(aRect, aWallpaper);
}
else
{
BitmapEx aExpandVisibilityMask = BitmapEx(aMask, aMask);
- aVirtualDeviceMask.DrawBitmapEx(rAnimBitmap.aPosPix, aExpandVisibilityMask);
+ aVirtualDeviceMask->DrawBitmapEx(rAnimBitmap.aPosPix, aExpandVisibilityMask);
}
break;
@@ -143,42 +143,42 @@ namespace
const Bitmap aMask(rAnimBitmap.aBmpEx.GetMask());
const Bitmap aContent(rAnimBitmap.aBmpEx.GetBitmap());
- aVirtualDeviceMask.Erase();
- aVirtualDevice.DrawBitmap(rAnimBitmap.aPosPix, aContent);
+ aVirtualDeviceMask->Erase();
+ aVirtualDevice->DrawBitmap(rAnimBitmap.aPosPix, aContent);
if(aMask.IsEmpty())
{
const Rectangle aRect(rAnimBitmap.aPosPix, aContent.GetSizePixel());
- aVirtualDeviceMask.SetFillColor(COL_BLACK);
- aVirtualDeviceMask.SetLineColor();
- aVirtualDeviceMask.DrawRect(aRect);
+ aVirtualDeviceMask->SetFillColor(COL_BLACK);
+ aVirtualDeviceMask->SetLineColor();
+ aVirtualDeviceMask->DrawRect(aRect);
}
else
{
- aVirtualDeviceMask.DrawBitmap(rAnimBitmap.aPosPix, aMask);
+ aVirtualDeviceMask->DrawBitmap(rAnimBitmap.aPosPix, aMask);
}
break;
}
case DISPOSE_FULL:
{
- aVirtualDevice.DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx);
+ aVirtualDevice->DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx);
break;
}
case DISPOSE_PREVIOUS :
{
- aVirtualDevice.DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx);
- aVirtualDeviceMask.DrawBitmap(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx.GetMask());
+ aVirtualDevice->DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx);
+ aVirtualDeviceMask->DrawBitmap(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx.GetMask());
break;
}
}
// create BitmapEx
- Bitmap aMainBitmap = aVirtualDevice.GetBitmap(Point(), aVirtualDevice.GetOutputSizePixel());
+ Bitmap aMainBitmap = aVirtualDevice->GetBitmap(Point(), aVirtualDevice->GetOutputSizePixel());
#if defined(MACOSX) || defined(IOS)
- AlphaMask aMaskBitmap( aVirtualDeviceMask.GetBitmap( Point(), aVirtualDeviceMask.GetOutputSizePixel()));
+ AlphaMask aMaskBitmap( aVirtualDeviceMask->GetBitmap( Point(), aVirtualDeviceMask->GetOutputSizePixel()));
#else
- Bitmap aMaskBitmap = aVirtualDeviceMask.GetBitmap( Point(), aVirtualDeviceMask.GetOutputSizePixel());
+ Bitmap aMaskBitmap = aVirtualDeviceMask->GetBitmap( Point(), aVirtualDeviceMask->GetOutputSizePixel());
#endif
aNextStep.maBitmapEx = BitmapEx(aMainBitmap, aMaskBitmap);
diff --git a/drawinglayer/source/primitive2d/textlayoutdevice.cxx b/drawinglayer/source/primitive2d/textlayoutdevice.cxx
index 919625967845..d34403d819aa 100644
--- a/drawinglayer/source/primitive2d/textlayoutdevice.cxx
+++ b/drawinglayer/source/primitive2d/textlayoutdevice.cxx
@@ -59,7 +59,7 @@ namespace
class ImpTimedRefDev : public Timer
{
scoped_timed_RefDev& mrOwnerOfMe;
- VirtualDevice* mpVirDev;
+ VclPtr<VirtualDevice> mpVirDev;
sal_uInt32 mnUseCount;
public:
@@ -84,7 +84,7 @@ namespace
{
OSL_ENSURE(0L == mnUseCount, "destruction of a still used ImpTimedRefDev (!)");
const SolarMutexGuard aGuard;
- delete mpVirDev;
+ mpVirDev.disposeAndClear();
}
void ImpTimedRefDev::Invoke()
diff --git a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx
index efa41c8565bc..4c22ca4f1c5b 100644
--- a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx
+++ b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx
@@ -32,7 +32,7 @@
namespace
{
- typedef ::std::vector< VirtualDevice* > aBuffers;
+ typedef ::std::vector< VclPtr<VirtualDevice> > aBuffers;
class VDevBuffer : public Timer, protected comphelper::OBaseMutex
{
@@ -69,13 +69,13 @@ namespace
while(!maFreeBuffers.empty())
{
- delete *(maFreeBuffers.end() - 1);
+ (*(maFreeBuffers.end() - 1)).disposeAndClear();
maFreeBuffers.pop_back();
}
while(!maUsedBuffers.empty())
{
- delete *(maUsedBuffers.end() - 1);
+ (*(maUsedBuffers.end() - 1)).disposeAndClear();
maUsedBuffers.pop_back();
}
}
@@ -197,7 +197,7 @@ namespace
while(!maFreeBuffers.empty())
{
- delete *(maFreeBuffers.end() - 1);
+ (*(maFreeBuffers.end() - 1)).disposeAndClear();
maFreeBuffers.pop_back();
}
}
diff --git a/drawinglayer/source/processor2d/vclhelperbufferdevice.hxx b/drawinglayer/source/processor2d/vclhelperbufferdevice.hxx
index 02aa3c0024ab..0ba73114dc4f 100644
--- a/drawinglayer/source/processor2d/vclhelperbufferdevice.hxx
+++ b/drawinglayer/source/processor2d/vclhelperbufferdevice.hxx
@@ -35,9 +35,9 @@ namespace drawinglayer
class impBufferDevice
{
OutputDevice& mrOutDev;
- VirtualDevice* mpContent;
- VirtualDevice* mpMask;
- VirtualDevice* mpAlpha;
+ VclPtr<VirtualDevice> mpContent;
+ VclPtr<VirtualDevice> mpMask;
+ VclPtr<VirtualDevice> mpAlpha;
Rectangle maDestPixel;
public:
diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
index 2b2c0b86d220..935b0b5e9d53 100644
--- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
@@ -252,20 +252,20 @@ namespace drawinglayer
const Rectangle aPrimitiveRectangle(
basegfx::fround(aPrimitiveRange.getMinX()), basegfx::fround(aPrimitiveRange.getMinY()),
basegfx::fround(aPrimitiveRange.getMaxX()), basegfx::fround(aPrimitiveRange.getMaxY()));
- VirtualDevice aContentVDev;
+ ScopedVclPtr<VirtualDevice> aContentVDev = new VirtualDevice;
MapMode aNewMapMode(pLastOutputDevice->GetMapMode());
- mpOutputDevice = &aContentVDev;
+ mpOutputDevice = aContentVDev.get();
mpMetaFile = &o_rContentMetafile;
- aContentVDev.EnableOutput(false);
- aContentVDev.SetMapMode(pLastOutputDevice->GetMapMode());
- o_rContentMetafile.Record(&aContentVDev);
- aContentVDev.SetLineColor(pLastOutputDevice->GetLineColor());
- aContentVDev.SetFillColor(pLastOutputDevice->GetFillColor());
- aContentVDev.SetFont(pLastOutputDevice->GetFont());
- aContentVDev.SetDrawMode(pLastOutputDevice->GetDrawMode());
- aContentVDev.SetSettings(pLastOutputDevice->GetSettings());
- aContentVDev.SetRefPoint(pLastOutputDevice->GetRefPoint());
+ aContentVDev->EnableOutput(false);
+ aContentVDev->SetMapMode(pLastOutputDevice->GetMapMode());
+ o_rContentMetafile.Record(aContentVDev.get());
+ aContentVDev->SetLineColor(pLastOutputDevice->GetLineColor());
+ aContentVDev->SetFillColor(pLastOutputDevice->GetFillColor());
+ aContentVDev->SetFont(pLastOutputDevice->GetFont());
+ aContentVDev->SetDrawMode(pLastOutputDevice->GetDrawMode());
+ aContentVDev->SetSettings(pLastOutputDevice->GetSettings());
+ aContentVDev->SetRefPoint(pLastOutputDevice->GetRefPoint());
// dump to MetaFile
process(rContent);
@@ -2016,7 +2016,7 @@ namespace drawinglayer
const Rectangle aRectPixel(mpOutputDevice->LogicToPixel(aRectLogic));
Size aSizePixel(aRectPixel.GetSize());
const Point aEmptyPoint;
- VirtualDevice aBufferDevice;
+ ScopedVclPtr<VirtualDevice> aBufferDevice = new VirtualDevice;
const sal_uInt32 nMaxQuadratPixels(500000);
const sal_uInt32 nViewVisibleArea(aSizePixel.getWidth() * aSizePixel.getHeight());
double fReduceFactor(1.0);
@@ -2029,20 +2029,20 @@ namespace drawinglayer
basegfx::fround((double)aSizePixel.getHeight() * fReduceFactor));
}
- if(aBufferDevice.SetOutputSizePixel(aSizePixel))
+ if(aBufferDevice->SetOutputSizePixel(aSizePixel))
{
// create and set MapModes for target devices
MapMode aNewMapMode(mpOutputDevice->GetMapMode());
aNewMapMode.SetOrigin(Point(-aRectLogic.Left(), -aRectLogic.Top()));
- aBufferDevice.SetMapMode(aNewMapMode);
+ aBufferDevice->SetMapMode(aNewMapMode);
// prepare view transformation for target renderers
// ATTENTION! Need to apply another scaling because of the potential DPI differences
// between Printer and VDev (mpOutputDevice and aBufferDevice here).
// To get the DPI, LogicToPixel from (1,1) from MAP_INCH needs to be used.
- basegfx::B2DHomMatrix aViewTransform(aBufferDevice.GetViewTransformation());
+ basegfx::B2DHomMatrix aViewTransform(aBufferDevice->GetViewTransformation());
const Size aDPIOld(mpOutputDevice->LogicToPixel(Size(1, 1), MAP_INCH));
- const Size aDPINew(aBufferDevice.LogicToPixel(Size(1, 1), MAP_INCH));
+ const Size aDPINew(aBufferDevice->LogicToPixel(Size(1, 1), MAP_INCH));
const double fDPIXChange((double)aDPIOld.getWidth() / (double)aDPINew.getWidth());
const double fDPIYChange((double)aDPIOld.getHeight() / (double)aDPINew.getHeight());
@@ -2067,16 +2067,16 @@ namespace drawinglayer
getViewInformation2D().getViewTime(),
getViewInformation2D().getExtendedInformationSequence());
- VclPixelProcessor2D aBufferProcessor(aViewInfo, aBufferDevice);
+ VclPixelProcessor2D aBufferProcessor(aViewInfo, *aBufferDevice.get());
// draw content using pixel renderer
aBufferProcessor.process(rContent);
- const Bitmap aBmContent(aBufferDevice.GetBitmap(aEmptyPoint, aSizePixel));
+ const Bitmap aBmContent(aBufferDevice->GetBitmap(aEmptyPoint, aSizePixel));
// draw transparence using pixel renderer
- aBufferDevice.Erase();
+ aBufferDevice->Erase();
aBufferProcessor.process(rTransparence);
- const AlphaMask aBmAlpha(aBufferDevice.GetBitmap(aEmptyPoint, aSizePixel));
+ const AlphaMask aBmAlpha(aBufferDevice->GetBitmap(aEmptyPoint, aSizePixel));
// paint
mpOutputDevice->DrawBitmapEx(
diff --git a/drawinglayer/source/processor2d/vclprocessor2d.hxx b/drawinglayer/source/processor2d/vclprocessor2d.hxx
index 70de6a19aca1..a527bb27c5e3 100644
--- a/drawinglayer/source/processor2d/vclprocessor2d.hxx
+++ b/drawinglayer/source/processor2d/vclprocessor2d.hxx
@@ -26,6 +26,7 @@
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/color/bcolormodifier.hxx>
#include <svtools/optionsdrawinglayer.hxx>
+#include <vcl/vclptr.hxx>
// predefines
@@ -70,7 +71,7 @@ namespace drawinglayer
{
protected:
// the destination OutDev
- OutputDevice* mpOutputDevice;
+ VclPtr<OutputDevice> mpOutputDevice;
// the modifiedColorPrimitive stack
basegfx::BColorModifierStack maBColorModifierStack;
diff --git a/drawinglayer/source/tools/converters.cxx b/drawinglayer/source/tools/converters.cxx
index 188bfa9f5327..e06356cabc82 100644
--- a/drawinglayer/source/tools/converters.cxx
+++ b/drawinglayer/source/tools/converters.cxx
@@ -73,21 +73,21 @@ namespace drawinglayer
const Point aEmptyPoint;
const Size aSizePixel(nDiscreteWidth, nDiscreteHeight);
geometry::ViewInformation2D aViewInformation2D(rViewInformation2D);
- VirtualDevice maContent;
+ ScopedVclPtr<VirtualDevice> maContent = new VirtualDevice;
// prepare vdev
- maContent.SetOutputSizePixel(aSizePixel, false);
- maContent.SetMapMode(aMapModePixel);
+ maContent->SetOutputSizePixel(aSizePixel, false);
+ maContent->SetMapMode(aMapModePixel);
// set to all white
- maContent.SetBackground(Wallpaper(Color(COL_WHITE)));
- maContent.Erase();
+ maContent->SetBackground(Wallpaper(Color(COL_WHITE)));
+ maContent->Erase();
// create pixel processor, also already takes care of AAing and
// checking the getOptionsDrawinglayer().IsAntiAliasing() switch. If
// not wanted, change after this call as needed
processor2d::BaseProcessor2D* pContentProcessor = processor2d::createPixelProcessor2DFromOutputDevice(
- maContent,
+ *maContent.get(),
aViewInformation2D);
if(pContentProcessor)
@@ -96,8 +96,8 @@ namespace drawinglayer
pContentProcessor->process(aSequence);
// get content
- maContent.EnableMapMode(false);
- const Bitmap aContent(maContent.GetBitmap(aEmptyPoint, aSizePixel));
+ maContent->EnableMapMode(false);
+ const Bitmap aContent(maContent->GetBitmap(aEmptyPoint, aSizePixel));
#ifdef DBG_UTIL
if(bDoSaveForVisualControl)
@@ -108,10 +108,10 @@ namespace drawinglayer
}
#endif
// prepare for mask creation
- maContent.SetMapMode(aMapModePixel);
+ maContent->SetMapMode(aMapModePixel);
// set alpha to all white (fully transparent)
- maContent.Erase();
+ maContent->Erase();
// embed primitives to paint them black
const primitive2d::Primitive2DReference xRef(
@@ -127,8 +127,8 @@ namespace drawinglayer
delete pContentProcessor;
// get alpha cahannel from vdev
- maContent.EnableMapMode(false);
- const Bitmap aAlpha(maContent.GetBitmap(aEmptyPoint, aSizePixel));
+ maContent->EnableMapMode(false);
+ const Bitmap aAlpha(maContent->GetBitmap(aEmptyPoint, aSizePixel));
#ifdef DBG_UTIL
if(bDoSaveForVisualControl)
{