fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / canvas / source / cairo / cairo_spritedevicehelper.cxx
blob465771736c17a59d62c0d48214925a432b4055df
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 .
20 #include <canvas/debug.hxx>
21 #include <canvas/verbosetrace.hxx>
22 #include <canvas/canvastools.hxx>
24 #include <osl/mutex.hxx>
25 #include <cppuhelper/compbase1.hxx>
27 #include <com/sun/star/lang/NoSupportException.hpp>
29 #include <toolkit/helper/vclunohelper.hxx>
30 #include <basegfx/tools/canvastools.hxx>
31 #include <basegfx/tools/unopolypolygon.hxx>
33 #include <vcl/syschild.hxx>
34 #include <vcl/canvastools.hxx>
36 #include "cairo_spritecanvas.hxx"
37 #include "cairo_canvasbitmap.hxx"
38 #include "cairo_devicehelper.hxx"
39 #include "cairo_cairo.hxx"
41 using namespace ::cairo;
42 using namespace ::com::sun::star;
44 namespace cairocanvas
47 SpriteDeviceHelper::SpriteDeviceHelper() :
48 mpSpriteCanvas( NULL ),
49 mpBufferSurface(),
50 maSize(),
51 mbFullScreen( false )
54 void SpriteDeviceHelper::init( Window& rOutputWindow,
55 SpriteCanvas& rSpriteCanvas,
56 const ::basegfx::B2ISize& rSize,
57 bool bFullscreen )
59 DeviceHelper::init(rSpriteCanvas,
60 rOutputWindow);
62 mpSpriteCanvas = &rSpriteCanvas;
63 mbFullScreen = bFullscreen;
65 setSize( rSize );
68 void SpriteDeviceHelper::disposing()
70 // release all references
71 mpBufferSurface.reset();
72 mpSpriteCanvas = NULL;
75 ::sal_Int32 SpriteDeviceHelper::createBuffers( ::sal_Int32 /*nBuffers*/ )
77 // TODO(F3): implement XBufferStrategy interface. For now, we
78 // _always_ will have exactly one backbuffer
79 return 1;
82 void SpriteDeviceHelper::destroyBuffers()
84 // TODO(F3): implement XBufferStrategy interface. For now, we
85 // _always_ will have exactly one backbuffer
88 ::sal_Bool SpriteDeviceHelper::showBuffer( bool, ::sal_Bool )
90 OSL_FAIL("Not supposed to be called, handled by SpriteCanvas");
91 return sal_False;
94 ::sal_Bool SpriteDeviceHelper::switchBuffer( bool, ::sal_Bool )
96 OSL_FAIL("Not supposed to be called, handled by SpriteCanvas");
97 return sal_False;
100 uno::Any SpriteDeviceHelper::isAccelerated() const
102 return ::com::sun::star::uno::makeAny(true);
105 uno::Any SpriteDeviceHelper::getDeviceHandle() const
107 return DeviceHelper::getDeviceHandle();
110 uno::Any SpriteDeviceHelper::getSurfaceHandle() const
112 return DeviceHelper::getSurfaceHandle();
115 void SpriteDeviceHelper::setSize( const ::basegfx::B2ISize& rSize )
117 OSL_TRACE("SpriteDeviceHelper::setSize(): device size %d x %d", rSize.getX(), rSize.getY() );
119 if( !mpSpriteCanvas )
120 return; // disposed
122 DeviceHelper::setSize(rSize);
124 if( mpBufferSurface && maSize != rSize )
125 mpBufferSurface.reset();
126 if( !mpBufferSurface )
127 mpBufferSurface = getWindowSurface()->getSimilar(
128 CAIRO_CONTENT_COLOR,
129 rSize.getX(), rSize.getY() );
131 if( maSize != rSize )
132 maSize = rSize;
134 mpSpriteCanvas->setSizePixel( maSize );
137 const ::basegfx::B2ISize& SpriteDeviceHelper::getSizePixel()
139 return maSize;
142 void SpriteDeviceHelper::notifySizeUpdate( const awt::Rectangle& rBounds )
144 setSize( ::basegfx::B2ISize(rBounds.Width, rBounds.Height) );
147 SurfaceSharedPtr SpriteDeviceHelper::getBufferSurface()
149 return mpBufferSurface;
152 SurfaceSharedPtr SpriteDeviceHelper::getWindowSurface()
154 return DeviceHelper::getSurface();
157 SurfaceSharedPtr SpriteDeviceHelper::createSurface( const ::basegfx::B2ISize& rSize, Content aContent )
159 if( mpBufferSurface )
160 return mpBufferSurface->getSimilar( aContent, rSize.getX(), rSize.getY() );
162 return SurfaceSharedPtr();
165 SurfaceSharedPtr SpriteDeviceHelper::createSurface( BitmapSystemData& rData, const Size& rSize )
167 if( getOutputDevice() )
168 return createBitmapSurface( *getOutputDevice(), rData, rSize );
170 return SurfaceSharedPtr();
174 /** SpriteDeviceHelper::flush Flush the platform native window
176 * Flushes the window by using the internally stored mpSysData.
179 void SpriteDeviceHelper::flush()
181 SurfaceSharedPtr pWinSurface=getWindowSurface();
182 if( pWinSurface )
183 pWinSurface->flush();
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */