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 : : #ifndef _CAIROCANVAS_SPRITECANVAS_HXX_
30 : : #define _CAIROCANVAS_SPRITECANVAS_HXX_
31 : :
32 : : #include <com/sun/star/uno/XComponentContext.hpp>
33 : : #include <com/sun/star/beans/XPropertySet.hpp>
34 : : #include <com/sun/star/lang/XInitialization.hpp>
35 : : #include <com/sun/star/lang/XServiceInfo.hpp>
36 : : #include <com/sun/star/lang/XServiceName.hpp>
37 : : #include <com/sun/star/awt/XWindowListener.hpp>
38 : : #include <com/sun/star/util/XUpdatable.hpp>
39 : : #include <com/sun/star/rendering/XSpriteCanvas.hpp>
40 : : #include <com/sun/star/rendering/XIntegerBitmap.hpp>
41 : : #include <com/sun/star/rendering/XGraphicDevice.hpp>
42 : : #include <com/sun/star/rendering/XBufferController.hpp>
43 : :
44 : : #include <cppuhelper/compbase9.hxx>
45 : : #include <comphelper/uno3.hxx>
46 : :
47 : : #include <canvas/base/spritecanvasbase.hxx>
48 : : #include <canvas/base/disambiguationhelper.hxx>
49 : : #include <canvas/base/bufferedgraphicdevicebase.hxx>
50 : :
51 : : #include <basegfx/vector/b2isize.hxx>
52 : :
53 : : #include "cairo_spritedevicehelper.hxx"
54 : : #include "cairo_repainttarget.hxx"
55 : : #include "cairo_surfaceprovider.hxx"
56 : : #include "cairo_spritecanvashelper.hxx"
57 : :
58 : : #define SPRITECANVAS_SERVICE_NAME "com.sun.star.rendering.SpriteCanvas.Cairo"
59 : : #define SPRITECANVAS_IMPLEMENTATION_NAME "com.sun.star.comp.rendering.SpriteCanvas.Cairo"
60 : :
61 : : namespace cairocanvas
62 : : {
63 : : typedef ::cppu::WeakComponentImplHelper9< ::com::sun::star::rendering::XSpriteCanvas,
64 : : ::com::sun::star::rendering::XIntegerBitmap,
65 : : ::com::sun::star::rendering::XGraphicDevice,
66 : : ::com::sun::star::lang::XMultiServiceFactory,
67 : : ::com::sun::star::rendering::XBufferController,
68 : : ::com::sun::star::awt::XWindowListener,
69 : : ::com::sun::star::util::XUpdatable,
70 : : ::com::sun::star::beans::XPropertySet,
71 : : ::com::sun::star::lang::XServiceName > WindowGraphicDeviceBase_Base;
72 : : typedef ::canvas::BufferedGraphicDeviceBase< ::canvas::DisambiguationHelper< WindowGraphicDeviceBase_Base >,
73 : : SpriteDeviceHelper,
74 : : ::osl::MutexGuard,
75 : : ::cppu::OWeakObject > SpriteCanvasBase_Base;
76 : : /** Mixin SpriteSurface
77 : :
78 : : Have to mixin the SpriteSurface before deriving from
79 : : ::canvas::SpriteCanvasBase, as this template should already
80 : : implement some of those interface methods.
81 : :
82 : : The reason why this appears kinda convoluted is the fact that
83 : : we cannot specify non-IDL types as WeakComponentImplHelperN
84 : : template args, and furthermore, don't want to derive
85 : : ::canvas::SpriteCanvasBase directly from
86 : : ::canvas::SpriteSurface (because derivees of
87 : : ::canvas::SpriteCanvasBase have to explicitly forward the
88 : : XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS)
89 : : anyway). Basically, ::canvas::CanvasCustomSpriteBase should
90 : : remain a base class that provides implementation, not to
91 : : enforce any specific interface on its derivees.
92 : : */
93 : 0 : class SpriteCanvasBaseSpriteSurface_Base : public SpriteCanvasBase_Base,
94 : : public ::canvas::SpriteSurface,
95 : : public SurfaceProvider
96 : : {
97 : : };
98 : :
99 : : typedef ::canvas::SpriteCanvasBase< SpriteCanvasBaseSpriteSurface_Base,
100 : : SpriteCanvasHelper,
101 : : ::osl::MutexGuard,
102 : : ::cppu::OWeakObject > SpriteCanvasBaseT;
103 : :
104 : : /** Product of this component's factory.
105 : :
106 : : The SpriteCanvas object combines the actual Window canvas with
107 : : the XGraphicDevice interface. This is because there's a
108 : : one-to-one relation between them, anyway, since each window
109 : : can have exactly one canvas and one associated
110 : : XGraphicDevice. And to avoid messing around with circular
111 : : references, this is implemented as one single object.
112 : : */
113 : 0 : class SpriteCanvas : public SpriteCanvasBaseT,
114 : : public RepaintTarget
115 : : {
116 : : public:
117 : : SpriteCanvas( const ::com::sun::star::uno::Sequence<
118 : : ::com::sun::star::uno::Any >& aArguments,
119 : : const ::com::sun::star::uno::Reference<
120 : : ::com::sun::star::uno::XComponentContext >& rxContext );
121 : :
122 : : void initialize();
123 : :
124 : : /// Dispose all internal references
125 : : virtual void disposeThis();
126 : :
127 : : // Forwarding the XComponent implementation to the
128 : : // cppu::ImplHelper templated base
129 : : // Classname Base doing refcounting Base implementing the XComponent interface
130 : : // | | |
131 : : // V V V
132 : 0 : DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( SpriteCanvas, WindowGraphicDeviceBase_Base, ::cppu::WeakComponentImplHelperBase );
133 : :
134 : : // XBufferController (partial)
135 : : virtual ::sal_Bool SAL_CALL showBuffer( ::sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException);
136 : : virtual ::sal_Bool SAL_CALL switchBuffer( ::sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException);
137 : :
138 : : // XSpriteCanvas (partial)
139 : : virtual sal_Bool SAL_CALL updateScreen( sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException);
140 : :
141 : : // XServiceName
142 : : virtual ::rtl::OUString SAL_CALL getServiceName( ) throw (::com::sun::star::uno::RuntimeException);
143 : :
144 : : // SurfaceProvider
145 : : virtual SurfaceSharedPtr getSurface();
146 : : virtual SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, Content aContent = CAIRO_CONTENT_COLOR_ALPHA );
147 : : virtual SurfaceSharedPtr createSurface( ::Bitmap& rBitmap );
148 : : virtual SurfaceSharedPtr changeSurface( bool bHasAlpha, bool bCopyContent );
149 : : virtual OutputDevice* getOutputDevice();
150 : :
151 : : // RepaintTarget
152 : : virtual bool repaint( const ::cairo::SurfaceSharedPtr& pSurface,
153 : : const ::com::sun::star::rendering::ViewState& viewState,
154 : : const ::com::sun::star::rendering::RenderState& renderState );
155 : :
156 : : SurfaceSharedPtr getWindowSurface();
157 : : SurfaceSharedPtr getBufferSurface();
158 : :
159 : : const ::basegfx::B2ISize& getSizePixel();
160 : : void setSizePixel( const ::basegfx::B2ISize& rSize );
161 : : void flush();
162 : :
163 : : private:
164 : : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > maArguments;
165 : : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxComponentContext;
166 : : };
167 : :
168 : : typedef ::rtl::Reference< SpriteCanvas > SpriteCanvasRef;
169 : : }
170 : :
171 : : #endif
172 : :
173 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|