1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: spritedevicehelper.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_canvas.hxx"
34 #include <canvas/debug.hxx>
35 #include <canvas/canvastools.hxx>
37 #include <toolkit/helper/vclunohelper.hxx>
38 #include <vcl/canvastools.hxx>
39 #include <basegfx/tools/canvastools.hxx>
41 #include "spritedevicehelper.hxx"
42 #include "spritecanvas.hxx"
43 #include "spritecanvashelper.hxx"
44 #include "canvasbitmap.hxx"
47 using namespace ::com::sun::star
;
51 SpriteDeviceHelper::SpriteDeviceHelper() :
56 void SpriteDeviceHelper::init( const OutDevProviderSharedPtr
& pOutDev
)
58 DeviceHelper::init(pOutDev
);
61 OutputDevice
& rOutDev( pOutDev
->getOutDev() );
62 mpBackBuffer
.reset( new BackBuffer( rOutDev
));
63 mpBackBuffer
->setSize( rOutDev
.GetOutputSizePixel() );
67 // use AA on VCLCanvas for Mac
68 mpBackBuffer
->getOutDev().SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW
| mpBackBuffer
->getOutDev().GetAntialiasing() );
70 // switch off AA for WIN32 and UNIX, the VCLCanvas does not look good with it and
71 // is not required to do AA. It would need to be adapted to use it correctly
72 // (especially gradient painting). This will need extra work.
73 mpBackBuffer
->getOutDev().SetAntialiasing(mpBackBuffer
->getOutDev().GetAntialiasing() & !ANTIALIASING_ENABLE_B2DDRAW
);
77 ::sal_Int32
SpriteDeviceHelper::createBuffers( ::sal_Int32 nBuffers
)
81 // TODO(F3): implement XBufferStrategy interface. For now, we
82 // _always_ will have exactly one backbuffer
86 void SpriteDeviceHelper::destroyBuffers()
88 // TODO(F3): implement XBufferStrategy interface. For now, we
89 // _always_ will have exactly one backbuffer
92 ::sal_Bool
SpriteDeviceHelper::showBuffer( bool, ::sal_Bool
)
94 OSL_ENSURE(false,"Not supposed to be called, handled by SpriteCanvas");
98 ::sal_Bool
SpriteDeviceHelper::switchBuffer( bool, ::sal_Bool
)
100 OSL_ENSURE(false,"Not supposed to be called, handled by SpriteCanvas");
104 void SpriteDeviceHelper::disposing()
106 // release all references
107 mpBackBuffer
.reset();
109 DeviceHelper::disposing();
112 uno::Any
SpriteDeviceHelper::isAccelerated() const
114 return DeviceHelper::isAccelerated();
117 uno::Any
SpriteDeviceHelper::getDeviceHandle() const
119 return DeviceHelper::getDeviceHandle();
122 uno::Any
SpriteDeviceHelper::getSurfaceHandle() const
128 reinterpret_cast< sal_Int64
>(&mpBackBuffer
->getOutDev()) );
131 void SpriteDeviceHelper::notifySizeUpdate( const awt::Rectangle
& rBounds
)
134 mpBackBuffer
->setSize( ::Size(rBounds
.Width
,
138 void SpriteDeviceHelper::dumpScreenContent() const
140 DeviceHelper::dumpScreenContent();
142 static sal_uInt32
nFilePostfixCount(0);
146 String
aFilename( String::CreateFromAscii("dbg_backbuffer") );
147 aFilename
+= String::CreateFromInt32(nFilePostfixCount
);
148 aFilename
+= String::CreateFromAscii(".bmp");
150 SvFileStream
aStream( aFilename
, STREAM_STD_READWRITE
);
152 const ::Point aEmptyPoint
;
153 mpBackBuffer
->getOutDev().EnableMapMode( FALSE
);
154 aStream
<< mpBackBuffer
->getOutDev().GetBitmap(aEmptyPoint
,
155 mpBackBuffer
->getOutDev().GetOutputSizePixel());