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 <sal/config.h>
21 #include <sal/log.hxx>
23 #include <vcl/cairo.hxx>
27 #include "cairo_devicehelper.hxx"
28 #include "cairo_spritecanvas.hxx"
30 using namespace ::cairo
;
31 using namespace ::com::sun::star
;
36 SpriteDeviceHelper::SpriteDeviceHelper() :
37 mpSpriteCanvas( nullptr ),
41 void SpriteDeviceHelper::init( vcl::Window
& rOutputWindow
,
42 SpriteCanvas
& rSpriteCanvas
,
43 const ::basegfx::B2ISize
& rSize
,
46 DeviceHelper::init(rSpriteCanvas
,
47 *rOutputWindow
.GetOutDev());
49 mpSpriteCanvas
= &rSpriteCanvas
;
50 mbFullScreen
= bFullscreen
;
55 void SpriteDeviceHelper::disposing()
57 // release all references
58 mpBufferSurface
.reset();
59 mpSpriteCanvas
= nullptr;
62 bool SpriteDeviceHelper::showBuffer( bool, bool )
64 SAL_WARN("canvas.cairo", "showBuffer Not supposed to be called, handled by SpriteCanvas");
68 bool SpriteDeviceHelper::switchBuffer( bool, bool )
70 SAL_WARN("canvas.cairo", "showBuffer Not supposed to be called, handled by SpriteCanvas");
74 uno::Any
SpriteDeviceHelper::isAccelerated() const
76 return css::uno::Any(true);
79 uno::Any
SpriteDeviceHelper::getDeviceHandle() const
81 return DeviceHelper::getDeviceHandle();
84 uno::Any
SpriteDeviceHelper::getSurfaceHandle() const
86 return DeviceHelper::getSurfaceHandle();
89 void SpriteDeviceHelper::setSize( const ::basegfx::B2ISize
& rSize
)
93 "device size " << rSize
.getWidth() << " x " << rSize
.getHeight());
98 DeviceHelper::setSize(rSize
);
100 if( mpBufferSurface
&& maSize
!= rSize
)
101 mpBufferSurface
.reset();
102 if( !mpBufferSurface
)
103 mpBufferSurface
= getWindowSurface()->getSimilar(
105 rSize
.getWidth(), rSize
.getHeight() );
107 if( maSize
!= rSize
)
110 mpSpriteCanvas
->setSizePixel( maSize
);
114 void SpriteDeviceHelper::notifySizeUpdate( const awt::Rectangle
& rBounds
)
116 setSize( ::basegfx::B2ISize(rBounds
.Width
, rBounds
.Height
) );
119 SurfaceSharedPtr
const & SpriteDeviceHelper::getWindowSurface() const
121 return DeviceHelper::getSurface();
124 SurfaceSharedPtr
SpriteDeviceHelper::createSurface( const ::basegfx::B2ISize
& rSize
, int aContent
)
126 if( mpBufferSurface
)
127 return mpBufferSurface
->getSimilar( aContent
, rSize
.getWidth(), rSize
.getHeight() );
129 return SurfaceSharedPtr();
132 SurfaceSharedPtr
SpriteDeviceHelper::createSurface( BitmapSystemData
const & rData
, const Size
& rSize
)
134 OutputDevice
*pDevice
= getOutputDevice();
136 return pDevice
->CreateBitmapSurface(rData
, rSize
);
137 return SurfaceSharedPtr();
140 /** SpriteDeviceHelper::flush Flush the platform native window
142 * Flushes the window by using the internally stored mpSysData.
145 void SpriteDeviceHelper::flush()
147 SurfaceSharedPtr pWinSurface
=getWindowSurface();
149 pWinSurface
->flush();
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */