xref: /aoo42x/main/canvas/source/vcl/canvasbitmap.hxx (revision 91c99ff4)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _VCLCANVAS_CANVASBITMAP_HXX
25 #define _VCLCANVAS_CANVASBITMAP_HXX
26 
27 #include <cppuhelper/compbase4.hxx>
28 
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
31 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
32 #include <com/sun/star/beans/XFastPropertySet.hpp>
33 
34 #include <vcl/virdev.hxx>
35 #include <vcl/bitmapex.hxx>
36 
37 #include <canvas/vclwrapper.hxx>
38 
39 #include <canvas/base/integerbitmapbase.hxx>
40 #include <canvasbitmaphelper.hxx>
41 
42 #include "impltools.hxx"
43 #include "repainttarget.hxx"
44 #include "spritecanvas.hxx"
45 
46 
47 /* Definition of CanvasBitmap class */
48 
49 namespace vclcanvas
50 {
51     typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::rendering::XBitmapCanvas,
52 			                         		  ::com::sun::star::rendering::XIntegerBitmap,
53                          			 		  ::com::sun::star::lang::XServiceInfo,
54                                              ::com::sun::star::beans::XFastPropertySet >  	CanvasBitmapBase_Base;
55     typedef ::canvas::IntegerBitmapBase< ::canvas::BaseMutexHelper< CanvasBitmapBase_Base >,
56                                          CanvasBitmapHelper,
57                                          tools::LocalGuard,
58                                          ::cppu::OWeakObject >							CanvasBitmap_Base;
59 
60     class CanvasBitmap : public CanvasBitmap_Base,
61                          public RepaintTarget
62     {
63     public:
64         /** Must be called with locked Solar mutex
65 
66         	@param rSize
67             Size in pixel of the bitmap to generate
68 
69             @param bAlphaBitmap
70             When true, bitmap will have an alpha channel
71 
72             @param rDevice
73             Reference device, with which bitmap should be compatible
74          */
75         CanvasBitmap( const ::Size&                                rSize,
76                       bool                                         bAlphaBitmap,
77                       ::com::sun::star::rendering::XGraphicDevice& rDevice,
78                       const OutDevProviderSharedPtr&               rOutDevProvider );
79 
80         /// Must be called with locked Solar mutex
81         CanvasBitmap( const BitmapEx&                              rBitmap,
82                       ::com::sun::star::rendering::XGraphicDevice& rDevice,
83                       const OutDevProviderSharedPtr&               rOutDevProvider );
84 
85         // overridden because of mpDevice
86         virtual void SAL_CALL disposing();
87 
88         // XServiceInfo
89         virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
90         virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
91         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
92 
93         // RepaintTarget interface
94         virtual bool repaint( const GraphicObjectSharedPtr&                   rGrf,
95                               const ::com::sun::star::rendering::ViewState&   viewState,
96                               const ::com::sun::star::rendering::RenderState& renderState,
97                               const ::Point&                                  rPt,
98                               const ::Size&                                   rSz,
99                               const GraphicAttr&                              rAttr ) const;
100 
101         /// Not threadsafe! Returned object is shared!
102         BitmapEx getBitmap() const;
103 
104         // XFastPropertySet
105         // used to retrieve BitmapEx pointer or X Pixmap handles for this bitmap
106         // handle values have these meanings:
107         // 0 ... get pointer to BitmapEx
108         // 1 ... get X pixmap handle to rgb content
109         // 2 ... get X pitmap handle to alpha mask
110         // returned any contains either BitmapEx pointer or array of three Any value
111         //     1st a bool value: true - free the pixmap after used by XFreePixmap, false do nothing, the pixmap is used internally in the canvas
112         //     2nd the pixmap handle
113         //     3rd the pixmap depth
114         virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle)  throw (::com::sun::star::uno::RuntimeException);
setFastPropertyValue(sal_Int32,const::com::sun::star::uno::Any &)115         virtual void SAL_CALL setFastPropertyValue(sal_Int32, const ::com::sun::star::uno::Any&)  throw (::com::sun::star::uno::RuntimeException) {}
116 
117     private:
118         /** MUST hold here, too, since CanvasHelper only contains a
119             raw pointer (without refcounting)
120         */
121         ::com::sun::star::uno::Reference<com::sun::star::rendering::XGraphicDevice> mxDevice;
122     };
123 }
124 
125 #endif /* _VCLCANVAS_CANVASBITMAP_HXX */
126