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/cairo.hxx>
35 #include <vcl/canvastools.hxx>
37 #include "cairo_spritecanvas.hxx"
38 #include "cairo_canvasbitmap.hxx"
39 #include "cairo_devicehelper.hxx"
41 using namespace ::cairo
;
42 using namespace ::com::sun::star
;
47 SpriteDeviceHelper::SpriteDeviceHelper() :
48 mpSpriteCanvas( NULL
),
54 void SpriteDeviceHelper::init( vcl::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 bool SpriteDeviceHelper::showBuffer( bool, bool )
77 OSL_FAIL("Not supposed to be called, handled by SpriteCanvas");
81 bool SpriteDeviceHelper::switchBuffer( bool, bool )
83 OSL_FAIL("Not supposed to be called, handled by SpriteCanvas");
87 uno::Any
SpriteDeviceHelper::isAccelerated() const
89 return ::com::sun::star::uno::makeAny(true);
92 uno::Any
SpriteDeviceHelper::getDeviceHandle() const
94 return DeviceHelper::getDeviceHandle();
97 uno::Any
SpriteDeviceHelper::getSurfaceHandle() const
99 return DeviceHelper::getSurfaceHandle();
102 void SpriteDeviceHelper::setSize( const ::basegfx::B2ISize
& rSize
)
106 "device size " << rSize
.getX() << " x " << rSize
.getY());
108 if( !mpSpriteCanvas
)
111 DeviceHelper::setSize(rSize
);
113 if( mpBufferSurface
&& maSize
!= rSize
)
114 mpBufferSurface
.reset();
115 if( !mpBufferSurface
)
116 mpBufferSurface
= getWindowSurface()->getSimilar(
118 rSize
.getX(), rSize
.getY() );
120 if( maSize
!= rSize
)
123 mpSpriteCanvas
->setSizePixel( maSize
);
127 void SpriteDeviceHelper::notifySizeUpdate( const awt::Rectangle
& rBounds
)
129 setSize( ::basegfx::B2ISize(rBounds
.Width
, rBounds
.Height
) );
132 SurfaceSharedPtr
SpriteDeviceHelper::getWindowSurface()
134 return DeviceHelper::getSurface();
137 SurfaceSharedPtr
SpriteDeviceHelper::createSurface( const ::basegfx::B2ISize
& rSize
, int aContent
)
139 if( mpBufferSurface
)
140 return mpBufferSurface
->getSimilar( aContent
, rSize
.getX(), rSize
.getY() );
142 return SurfaceSharedPtr();
145 SurfaceSharedPtr
SpriteDeviceHelper::createSurface( BitmapSystemData
& rData
, const Size
& rSize
)
147 OutputDevice
*pDevice
= getOutputDevice();
149 return pDevice
->CreateBitmapSurface(rData
, rSize
);
150 return SurfaceSharedPtr();
153 /** SpriteDeviceHelper::flush Flush the platform native window
155 * Flushes the window by using the internally stored mpSysData.
158 void SpriteDeviceHelper::flush()
160 SurfaceSharedPtr pWinSurface
=getWindowSurface();
162 pWinSurface
->flush();
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */