xref: /aoo42x/main/canvas/source/vcl/canvasbitmap.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _VCLCANVAS_CANVASBITMAP_HXX
29 #define _VCLCANVAS_CANVASBITMAP_HXX
30 
31 #include <cppuhelper/compbase4.hxx>
32 
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
35 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
36 #include <com/sun/star/beans/XFastPropertySet.hpp>
37 
38 #include <vcl/virdev.hxx>
39 #include <vcl/bitmapex.hxx>
40 
41 #include <canvas/vclwrapper.hxx>
42 
43 #include <canvas/base/integerbitmapbase.hxx>
44 #include <canvasbitmaphelper.hxx>
45 
46 #include "impltools.hxx"
47 #include "repainttarget.hxx"
48 #include "spritecanvas.hxx"
49 
50 
51 /* Definition of CanvasBitmap class */
52 
53 namespace vclcanvas
54 {
55     typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::rendering::XBitmapCanvas,
56 			                         		  ::com::sun::star::rendering::XIntegerBitmap,
57                          			 		  ::com::sun::star::lang::XServiceInfo,
58                                              ::com::sun::star::beans::XFastPropertySet >  	CanvasBitmapBase_Base;
59     typedef ::canvas::IntegerBitmapBase< ::canvas::BaseMutexHelper< CanvasBitmapBase_Base >,
60                                          CanvasBitmapHelper,
61                                          tools::LocalGuard,
62                                          ::cppu::OWeakObject >							CanvasBitmap_Base;
63 
64     class CanvasBitmap : public CanvasBitmap_Base,
65                          public RepaintTarget
66     {
67     public:
68         /** Must be called with locked Solar mutex
69 
70         	@param rSize
71             Size in pixel of the bitmap to generate
72 
73             @param bAlphaBitmap
74             When true, bitmap will have an alpha channel
75 
76             @param rDevice
77             Reference device, with which bitmap should be compatible
78          */
79         CanvasBitmap( const ::Size&                                rSize,
80                       bool                                         bAlphaBitmap,
81                       ::com::sun::star::rendering::XGraphicDevice& rDevice,
82                       const OutDevProviderSharedPtr&               rOutDevProvider );
83 
84         /// Must be called with locked Solar mutex
85         CanvasBitmap( const BitmapEx&                              rBitmap,
86                       ::com::sun::star::rendering::XGraphicDevice& rDevice,
87                       const OutDevProviderSharedPtr&               rOutDevProvider );
88 
89         // overridden because of mpDevice
90         virtual void SAL_CALL disposing();
91 
92         // XServiceInfo
93         virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
94         virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
95         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
96 
97         // RepaintTarget interface
98         virtual bool repaint( const GraphicObjectSharedPtr&                   rGrf,
99                               const ::com::sun::star::rendering::ViewState&   viewState,
100                               const ::com::sun::star::rendering::RenderState& renderState,
101                               const ::Point&                                  rPt,
102                               const ::Size&                                   rSz,
103                               const GraphicAttr&                              rAttr ) const;
104 
105         /// Not threadsafe! Returned object is shared!
106         BitmapEx getBitmap() const;
107 
108         // XFastPropertySet
109         // used to retrieve BitmapEx pointer or X Pixmap handles for this bitmap
110         // handle values have these meanings:
111         // 0 ... get pointer to BitmapEx
112         // 1 ... get X pixmap handle to rgb content
113         // 2 ... get X pitmap handle to alpha mask
114         // returned any contains either BitmapEx pointer or array of three Any value
115         //     1st a bool value: true - free the pixmap after used by XFreePixmap, false do nothing, the pixmap is used internally in the canvas
116         //     2nd the pixmap handle
117         //     3rd the pixmap depth
118         virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle)  throw (::com::sun::star::uno::RuntimeException);
119         virtual void SAL_CALL setFastPropertyValue(sal_Int32, const ::com::sun::star::uno::Any&)  throw (::com::sun::star::uno::RuntimeException) {}
120 
121     private:
122         /** MUST hold here, too, since CanvasHelper only contains a
123             raw pointer (without refcounting)
124         */
125         ::com::sun::star::uno::Reference<com::sun::star::rendering::XGraphicDevice> mxDevice;
126     };
127 }
128 
129 #endif /* _VCLCANVAS_CANVASBITMAP_HXX */
130