Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <canvas/debug.hxx>
30 : : #include <canvas/verbosetrace.hxx>
31 : : #include <canvas/canvastools.hxx>
32 : :
33 : : #include <osl/mutex.hxx>
34 : : #include <cppuhelper/compbase1.hxx>
35 : :
36 : : #include <com/sun/star/lang/NoSupportException.hpp>
37 : :
38 : : #include <toolkit/helper/vclunohelper.hxx>
39 : : #include <basegfx/tools/canvastools.hxx>
40 : : #include <basegfx/tools/unopolypolygon.hxx>
41 : :
42 : : #include <vcl/syschild.hxx>
43 : : #include <vcl/canvastools.hxx>
44 : :
45 : : #include "cairo_spritecanvas.hxx"
46 : : #include "cairo_canvasbitmap.hxx"
47 : : #include "cairo_devicehelper.hxx"
48 : : #include "cairo_cairo.hxx"
49 : :
50 : : using namespace ::cairo;
51 : : using namespace ::com::sun::star;
52 : :
53 : : namespace cairocanvas
54 : : {
55 : :
56 : 0 : SpriteDeviceHelper::SpriteDeviceHelper() :
57 : : mpSpriteCanvas( NULL ),
58 : : mpBufferSurface(),
59 : : maSize(),
60 : 0 : mbFullScreen( false )
61 : 0 : {}
62 : :
63 : 0 : void SpriteDeviceHelper::init( Window& rOutputWindow,
64 : : SpriteCanvas& rSpriteCanvas,
65 : : const ::basegfx::B2ISize& rSize,
66 : : bool bFullscreen )
67 : : {
68 : : DeviceHelper::init(rSpriteCanvas,
69 : 0 : rOutputWindow);
70 : :
71 : 0 : mpSpriteCanvas = &rSpriteCanvas;
72 : 0 : mbFullScreen = bFullscreen;
73 : :
74 : 0 : setSize( rSize );
75 : 0 : }
76 : :
77 : 0 : void SpriteDeviceHelper::disposing()
78 : : {
79 : : // release all references
80 : 0 : mpBufferSurface.reset();
81 : 0 : mpSpriteCanvas = NULL;
82 : 0 : }
83 : :
84 : 0 : ::sal_Int32 SpriteDeviceHelper::createBuffers( ::sal_Int32 /*nBuffers*/ )
85 : : {
86 : : // TODO(F3): implement XBufferStrategy interface. For now, we
87 : : // _always_ will have exactly one backbuffer
88 : 0 : return 1;
89 : : }
90 : :
91 : 0 : void SpriteDeviceHelper::destroyBuffers()
92 : : {
93 : : // TODO(F3): implement XBufferStrategy interface. For now, we
94 : : // _always_ will have exactly one backbuffer
95 : 0 : }
96 : :
97 : 0 : ::sal_Bool SpriteDeviceHelper::showBuffer( bool, ::sal_Bool )
98 : : {
99 : : OSL_FAIL("Not supposed to be called, handled by SpriteCanvas");
100 : 0 : return sal_False;
101 : : }
102 : :
103 : 0 : ::sal_Bool SpriteDeviceHelper::switchBuffer( bool, ::sal_Bool )
104 : : {
105 : : OSL_FAIL("Not supposed to be called, handled by SpriteCanvas");
106 : 0 : return sal_False;
107 : : }
108 : :
109 : 0 : uno::Any SpriteDeviceHelper::isAccelerated() const
110 : : {
111 : 0 : return ::com::sun::star::uno::makeAny(true);
112 : : }
113 : :
114 : 0 : uno::Any SpriteDeviceHelper::getDeviceHandle() const
115 : : {
116 : 0 : return DeviceHelper::getDeviceHandle();
117 : : }
118 : :
119 : 0 : uno::Any SpriteDeviceHelper::getSurfaceHandle() const
120 : : {
121 : 0 : return DeviceHelper::getSurfaceHandle();
122 : : }
123 : :
124 : 0 : void SpriteDeviceHelper::setSize( const ::basegfx::B2ISize& rSize )
125 : : {
126 : : OSL_TRACE("SpriteDeviceHelper::setSize(): device size %d x %d", rSize.getX(), rSize.getY() );
127 : :
128 : 0 : if( !mpSpriteCanvas )
129 : 0 : return; // disposed
130 : :
131 : 0 : DeviceHelper::setSize(rSize);
132 : :
133 : 0 : if( mpBufferSurface && maSize != rSize )
134 : 0 : mpBufferSurface.reset();
135 : 0 : if( !mpBufferSurface )
136 : 0 : mpBufferSurface = getWindowSurface()->getSimilar(
137 : : CAIRO_CONTENT_COLOR,
138 : 0 : rSize.getX(), rSize.getY() );
139 : :
140 : 0 : if( maSize != rSize )
141 : 0 : maSize = rSize;
142 : :
143 : 0 : mpSpriteCanvas->setSizePixel( maSize );
144 : : }
145 : :
146 : 0 : const ::basegfx::B2ISize& SpriteDeviceHelper::getSizePixel()
147 : : {
148 : 0 : return maSize;
149 : : }
150 : :
151 : 0 : void SpriteDeviceHelper::notifySizeUpdate( const awt::Rectangle& rBounds )
152 : : {
153 : 0 : setSize( ::basegfx::B2ISize(rBounds.Width, rBounds.Height) );
154 : 0 : }
155 : :
156 : 0 : SurfaceSharedPtr SpriteDeviceHelper::getSurface()
157 : : {
158 : 0 : return mpBufferSurface;
159 : : }
160 : :
161 : 0 : SurfaceSharedPtr SpriteDeviceHelper::getBufferSurface()
162 : : {
163 : 0 : return mpBufferSurface;
164 : : }
165 : :
166 : 0 : SurfaceSharedPtr SpriteDeviceHelper::getWindowSurface()
167 : : {
168 : 0 : return DeviceHelper::getSurface();
169 : : }
170 : :
171 : 0 : SurfaceSharedPtr SpriteDeviceHelper::createSurface( const ::basegfx::B2ISize& rSize, Content aContent )
172 : : {
173 : 0 : if( mpBufferSurface )
174 : 0 : return mpBufferSurface->getSimilar( aContent, rSize.getX(), rSize.getY() );
175 : :
176 : 0 : return SurfaceSharedPtr();
177 : : }
178 : :
179 : 0 : SurfaceSharedPtr SpriteDeviceHelper::createSurface( BitmapSystemData& rData, const Size& rSize )
180 : : {
181 : 0 : if( getOutputDevice() )
182 : 0 : return createBitmapSurface( *getOutputDevice(), rData, rSize );
183 : :
184 : 0 : return SurfaceSharedPtr();
185 : : }
186 : :
187 : :
188 : : /** SpriteDeviceHelper::flush Flush the platform native window
189 : : *
190 : : * Flushes the window by using the internally stored mpSysData.
191 : : *
192 : : **/
193 : 0 : void SpriteDeviceHelper::flush()
194 : : {
195 : 0 : SurfaceSharedPtr pWinSurface=getWindowSurface();
196 : 0 : if( pWinSurface )
197 : 0 : pWinSurface->flush();
198 : 0 : }
199 : 0 : }
200 : :
201 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|