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/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
;
47 SpriteDeviceHelper::SpriteDeviceHelper() :
48 mpSpriteCanvas( NULL
),
54 void SpriteDeviceHelper::init( Window
& rOutputWindow
,
55 SpriteCanvas
& rSpriteCanvas
,
56 const ::basegfx::B2ISize
& rSize
,
59 DeviceHelper::init(rSpriteCanvas
,
62 mpSpriteCanvas
= &rSpriteCanvas
;
63 mbFullScreen
= bFullscreen
;
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
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");
94 ::sal_Bool
SpriteDeviceHelper::switchBuffer( bool, ::sal_Bool
)
96 OSL_FAIL("Not supposed to be called, handled by SpriteCanvas");
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
)
122 DeviceHelper::setSize(rSize
);
124 if( mpBufferSurface
&& maSize
!= rSize
)
125 mpBufferSurface
.reset();
126 if( !mpBufferSurface
)
127 mpBufferSurface
= getWindowSurface()->getSimilar(
129 rSize
.getX(), rSize
.getY() );
131 if( maSize
!= rSize
)
134 mpSpriteCanvas
->setSizePixel( maSize
);
137 const ::basegfx::B2ISize
& SpriteDeviceHelper::getSizePixel()
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();
183 pWinSurface
->flush();
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */