fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / canvas / source / vcl / spritedevicehelper.cxx
blobbeaf3545f82a3afb6e2a6c2ce5050336971626c7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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;
36 namespace vclcanvas
38 SpriteDeviceHelper::SpriteDeviceHelper() :
39 mpBackBuffer()
43 void SpriteDeviceHelper::init( const OutDevProviderSharedPtr& pOutDev )
45 DeviceHelper::init(pOutDev);
47 // setup back buffer
48 OutputDevice& rOutDev( pOutDev->getOutDev() );
49 mpBackBuffer.reset( new BackBuffer( rOutDev ));
50 mpBackBuffer->setSize( rOutDev.GetOutputSizePixel() );
52 // #i95645#
53 #if defined( MACOSX )
54 // use AA on VCLCanvas for Mac
55 mpBackBuffer->getOutDev().SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW | mpBackBuffer->getOutDev().GetAntialiasing() );
56 #else
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);
61 #endif
64 ::sal_Int32 SpriteDeviceHelper::createBuffers( ::sal_Int32 nBuffers )
66 (void)nBuffers;
68 // TODO(F3): implement XBufferStrategy interface. For now, we
69 // _always_ will have exactly one backbuffer
70 return 1;
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");
82 return sal_False;
85 ::sal_Bool SpriteDeviceHelper::switchBuffer( bool, ::sal_Bool )
87 OSL_FAIL("Not supposed to be called, handled by SpriteCanvas");
88 return sal_False;
91 void SpriteDeviceHelper::disposing()
93 // release all references
94 mpBackBuffer.reset();
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
111 if( !mpBackBuffer )
112 return uno::Any();
114 return uno::makeAny(
115 reinterpret_cast< sal_Int64 >(&mpBackBuffer->getOutDev()) );
118 void SpriteDeviceHelper::notifySizeUpdate( const awt::Rectangle& rBounds )
120 if( mpBackBuffer )
121 mpBackBuffer->setSize( ::Size(rBounds.Width,
122 rBounds.Height) );
125 void SpriteDeviceHelper::dumpScreenContent() const
127 DeviceHelper::dumpScreenContent();
129 static sal_Int32 nFilePostfixCount(0);
131 if( mpBackBuffer )
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());
145 ++nFilePostfixCount;
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */