1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <canvas/debug.hxx>
21 #include <canvas/canvastools.hxx>
22 #include <toolkit/helper/vclunohelper.hxx>
23 #include <vcl/canvastools.hxx>
24 #include <basegfx/tools/canvastools.hxx>
25 #include <vcl/dibtools.hxx>
27 #include "spritedevicehelper.hxx"
28 #include "spritecanvas.hxx"
29 #include "spritecanvashelper.hxx"
30 #include "canvasbitmap.hxx"
32 using namespace ::com::sun::star
;
36 SpriteDeviceHelper::SpriteDeviceHelper() :
41 void SpriteDeviceHelper::init( const OutDevProviderSharedPtr
& pOutDev
)
43 DeviceHelper::init(pOutDev
);
46 OutputDevice
& rOutDev( pOutDev
->getOutDev() );
47 mpBackBuffer
.reset( new BackBuffer( rOutDev
));
48 mpBackBuffer
->setSize( rOutDev
.GetOutputSizePixel() );
52 // use AA on VCLCanvas for Mac
53 mpBackBuffer
->getOutDev().SetAntialiasing( AntialiasingFlags::EnableB2dDraw
| mpBackBuffer
->getOutDev().GetAntialiasing() );
55 // switch off AA for WIN32 and UNIX, the VCLCanvas does not look good with it and
56 // is not required to do AA. It would need to be adapted to use it correctly
57 // (especially gradient painting). This will need extra work.
58 mpBackBuffer
->getOutDev().SetAntialiasing(mpBackBuffer
->getOutDev().GetAntialiasing() & ~AntialiasingFlags::EnableB2dDraw
);
62 bool SpriteDeviceHelper::showBuffer( bool, bool )
64 OSL_FAIL("Not supposed to be called, handled by SpriteCanvas");
68 bool SpriteDeviceHelper::switchBuffer( bool, bool )
70 OSL_FAIL("Not supposed to be called, handled by SpriteCanvas");
74 void SpriteDeviceHelper::disposing()
76 // release all references
79 DeviceHelper::disposing();
82 uno::Any
SpriteDeviceHelper::isAccelerated() const
84 return DeviceHelper::isAccelerated();
87 uno::Any
SpriteDeviceHelper::getDeviceHandle() const
89 return DeviceHelper::getDeviceHandle();
92 uno::Any
SpriteDeviceHelper::getSurfaceHandle() const
98 reinterpret_cast< sal_Int64
>(&mpBackBuffer
->getOutDev()) );
101 void SpriteDeviceHelper::notifySizeUpdate( const awt::Rectangle
& rBounds
)
104 mpBackBuffer
->setSize( ::Size(rBounds
.Width
,
108 void SpriteDeviceHelper::dumpScreenContent() const
110 DeviceHelper::dumpScreenContent();
112 static sal_Int32
nFilePostfixCount(0);
116 OUString aFilename
= "dbg_backbuffer" + OUString::number(nFilePostfixCount
) + ".bmp";
118 SvFileStream
aStream( aFilename
, STREAM_STD_READWRITE
);
120 const ::Point aEmptyPoint
;
121 mpBackBuffer
->getOutDev().EnableMapMode( false );
122 mpBackBuffer
->getOutDev().SetAntialiasing( AntialiasingFlags::EnableB2dDraw
);
123 WriteDIB(mpBackBuffer
->getOutDev().GetBitmap(aEmptyPoint
, mpBackBuffer
->getOutDev().GetOutputSizePixel()), aStream
, false, true);
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */