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 .
21 #include <canvas/debug.hxx>
22 #include <canvas/canvastools.hxx>
24 #include <toolkit/helper/vclunohelper.hxx>
25 #include <vcl/canvastools.hxx>
26 #include <basegfx/tools/canvastools.hxx>
28 #include "spritedevicehelper.hxx"
29 #include "spritecanvas.hxx"
30 #include "spritecanvashelper.hxx"
31 #include "canvasbitmap.hxx"
34 using namespace ::com::sun::star
;
38 SpriteDeviceHelper::SpriteDeviceHelper() :
43 void SpriteDeviceHelper::init( const OutDevProviderSharedPtr
& pOutDev
)
45 DeviceHelper::init(pOutDev
);
48 OutputDevice
& rOutDev( pOutDev
->getOutDev() );
49 mpBackBuffer
.reset( new BackBuffer( rOutDev
));
50 mpBackBuffer
->setSize( rOutDev
.GetOutputSizePixel() );
54 // use AA on VCLCanvas for Mac
55 mpBackBuffer
->getOutDev().SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW
| mpBackBuffer
->getOutDev().GetAntialiasing() );
57 // switch off AA for WIN32 and UNIX, the VCLCanvas does not look good with it and
58 // is not required to do AA. It would need to be adapted to use it correctly
59 // (especially gradient painting). This will need extra work.
60 mpBackBuffer
->getOutDev().SetAntialiasing(mpBackBuffer
->getOutDev().GetAntialiasing() & ~ANTIALIASING_ENABLE_B2DDRAW
);
64 ::sal_Int32
SpriteDeviceHelper::createBuffers( ::sal_Int32 nBuffers
)
68 // TODO(F3): implement XBufferStrategy interface. For now, we
69 // _always_ will have exactly one backbuffer
73 void SpriteDeviceHelper::destroyBuffers()
75 // TODO(F3): implement XBufferStrategy interface. For now, we
76 // _always_ will have exactly one backbuffer
79 ::sal_Bool
SpriteDeviceHelper::showBuffer( bool, ::sal_Bool
)
81 OSL_FAIL("Not supposed to be called, handled by SpriteCanvas");
85 ::sal_Bool
SpriteDeviceHelper::switchBuffer( bool, ::sal_Bool
)
87 OSL_FAIL("Not supposed to be called, handled by SpriteCanvas");
91 void SpriteDeviceHelper::disposing()
93 // release all references
96 DeviceHelper::disposing();
99 uno::Any
SpriteDeviceHelper::isAccelerated() const
101 return DeviceHelper::isAccelerated();
104 uno::Any
SpriteDeviceHelper::getDeviceHandle() const
106 return DeviceHelper::getDeviceHandle();
109 uno::Any
SpriteDeviceHelper::getSurfaceHandle() const
115 reinterpret_cast< sal_Int64
>(&mpBackBuffer
->getOutDev()) );
118 void SpriteDeviceHelper::notifySizeUpdate( const awt::Rectangle
& rBounds
)
121 mpBackBuffer
->setSize( ::Size(rBounds
.Width
,
125 void SpriteDeviceHelper::dumpScreenContent() const
127 DeviceHelper::dumpScreenContent();
129 static sal_Int32
nFilePostfixCount(0);
133 OUString
aFilename("dbg_backbuffer");
134 aFilename
+= OUString::valueOf(nFilePostfixCount
);
135 aFilename
+= OUString(".bmp");
137 SvFileStream
aStream( aFilename
, STREAM_STD_READWRITE
);
139 const ::Point aEmptyPoint
;
140 mpBackBuffer
->getOutDev().EnableMapMode( sal_False
);
141 aStream
<< mpBackBuffer
->getOutDev().GetBitmap(aEmptyPoint
,
142 mpBackBuffer
->getOutDev().GetOutputSizePixel());
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */