1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski  *
3*b1cdbd2cSJim Jagielski  * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski  * or more contributor license agreements.  See the NOTICE file
5*b1cdbd2cSJim Jagielski  * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski  * regarding copyright ownership.  The ASF licenses this file
7*b1cdbd2cSJim Jagielski  * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski  * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski  * with the License.  You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski  *
11*b1cdbd2cSJim Jagielski  *   http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski  *
13*b1cdbd2cSJim Jagielski  * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski  * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski  * KIND, either express or implied.  See the License for the
17*b1cdbd2cSJim Jagielski  * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski  * under the License.
19*b1cdbd2cSJim Jagielski  *
20*b1cdbd2cSJim Jagielski  *************************************************************/
21*b1cdbd2cSJim Jagielski 
22*b1cdbd2cSJim Jagielski 
23*b1cdbd2cSJim Jagielski 
24*b1cdbd2cSJim Jagielski #ifndef _CAIROCANVAS_CANVASBITMAP_HXX
25*b1cdbd2cSJim Jagielski #define _CAIROCANVAS_CANVASBITMAP_HXX
26*b1cdbd2cSJim Jagielski 
27*b1cdbd2cSJim Jagielski #include <cppuhelper/compbase4.hxx>
28*b1cdbd2cSJim Jagielski 
29*b1cdbd2cSJim Jagielski #include <com/sun/star/lang/XServiceInfo.hpp>
30*b1cdbd2cSJim Jagielski #include <com/sun/star/rendering/XBitmapCanvas.hpp>
31*b1cdbd2cSJim Jagielski #include <com/sun/star/rendering/XIntegerBitmap.hpp>
32*b1cdbd2cSJim Jagielski #include <com/sun/star/beans/XFastPropertySet.hpp>
33*b1cdbd2cSJim Jagielski #include <comphelper/uno3.hxx>
34*b1cdbd2cSJim Jagielski 
35*b1cdbd2cSJim Jagielski #include <basegfx/vector/b2isize.hxx>
36*b1cdbd2cSJim Jagielski 
37*b1cdbd2cSJim Jagielski #include <boost/shared_ptr.hpp>
38*b1cdbd2cSJim Jagielski 
39*b1cdbd2cSJim Jagielski #include <canvas/base/integerbitmapbase.hxx>
40*b1cdbd2cSJim Jagielski 
41*b1cdbd2cSJim Jagielski #include "cairo_cairo.hxx"
42*b1cdbd2cSJim Jagielski #include "cairo_canvashelper.hxx"
43*b1cdbd2cSJim Jagielski #include "cairo_repainttarget.hxx"
44*b1cdbd2cSJim Jagielski #include "cairo_spritecanvas.hxx"
45*b1cdbd2cSJim Jagielski 
46*b1cdbd2cSJim Jagielski 
47*b1cdbd2cSJim Jagielski /* Definition of CanvasBitmap class */
48*b1cdbd2cSJim Jagielski 
49*b1cdbd2cSJim Jagielski namespace cairocanvas
50*b1cdbd2cSJim Jagielski {
51*b1cdbd2cSJim Jagielski     typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::rendering::XBitmapCanvas,
52*b1cdbd2cSJim Jagielski 											  ::com::sun::star::rendering::XIntegerBitmap,
53*b1cdbd2cSJim Jagielski                                               ::com::sun::star::lang::XServiceInfo,
54*b1cdbd2cSJim Jagielski                                               ::com::sun::star::beans::XFastPropertySet >  	CanvasBitmapBase_Base;
55*b1cdbd2cSJim Jagielski 	class CanvasBitmapSpriteSurface_Base :
56*b1cdbd2cSJim Jagielski         public ::canvas::BaseMutexHelper<CanvasBitmapBase_Base>,
57*b1cdbd2cSJim Jagielski         public SurfaceProvider
58*b1cdbd2cSJim Jagielski     {
59*b1cdbd2cSJim Jagielski     };
60*b1cdbd2cSJim Jagielski 
61*b1cdbd2cSJim Jagielski     typedef ::canvas::IntegerBitmapBase<
62*b1cdbd2cSJim Jagielski           CanvasBitmapSpriteSurface_Base,
63*b1cdbd2cSJim Jagielski           CanvasHelper,
64*b1cdbd2cSJim Jagielski           ::osl::MutexGuard,
65*b1cdbd2cSJim Jagielski           ::cppu::OWeakObject >							CanvasBitmap_Base;
66*b1cdbd2cSJim Jagielski 
67*b1cdbd2cSJim Jagielski     class CanvasBitmap : public CanvasBitmap_Base,
68*b1cdbd2cSJim Jagielski 						 public RepaintTarget
69*b1cdbd2cSJim Jagielski     {
70*b1cdbd2cSJim Jagielski     public:
71*b1cdbd2cSJim Jagielski         /** Create a canvas bitmap for the given surface
72*b1cdbd2cSJim Jagielski 
73*b1cdbd2cSJim Jagielski             @param rSize
74*b1cdbd2cSJim Jagielski             Size of the bitmap
75*b1cdbd2cSJim Jagielski 
76*b1cdbd2cSJim Jagielski             @param rDevice
77*b1cdbd2cSJim Jagielski             Reference device, with which bitmap should be compatible
78*b1cdbd2cSJim Jagielski 		*/
79*b1cdbd2cSJim Jagielski         CanvasBitmap( const ::basegfx::B2ISize& rSize,
80*b1cdbd2cSJim Jagielski                       const SurfaceProviderRef& rDevice,
81*b1cdbd2cSJim Jagielski                       ::com::sun::star::rendering::XGraphicDevice* pDevice,
82*b1cdbd2cSJim Jagielski                       bool                      bHasAlpha );
83*b1cdbd2cSJim Jagielski 
84*b1cdbd2cSJim Jagielski         /// Dispose all internal references
85*b1cdbd2cSJim Jagielski         virtual void SAL_CALL disposing();
86*b1cdbd2cSJim Jagielski 
87*b1cdbd2cSJim Jagielski 		// Forwarding the XComponent implementation to the
88*b1cdbd2cSJim Jagielski         // cppu::ImplHelper templated base
89*b1cdbd2cSJim Jagielski         //                                    Classname     Base doing refcounting        Base implementing the XComponent interface
90*b1cdbd2cSJim Jagielski         //                                       |                 |                            |
91*b1cdbd2cSJim Jagielski         //                                       V                 V                            V
92*b1cdbd2cSJim Jagielski         DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( CanvasBitmap, CanvasBitmapBase_Base, ::cppu::WeakComponentImplHelperBase );
93*b1cdbd2cSJim Jagielski 
94*b1cdbd2cSJim Jagielski         // XServiceInfo
95*b1cdbd2cSJim Jagielski         virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
96*b1cdbd2cSJim Jagielski         virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
97*b1cdbd2cSJim Jagielski         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
98*b1cdbd2cSJim Jagielski 
99*b1cdbd2cSJim Jagielski         // SurfaceProvider
100*b1cdbd2cSJim Jagielski 		virtual SurfaceSharedPtr getSurface();
101*b1cdbd2cSJim Jagielski 		virtual SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, Content aContent = CAIRO_CONTENT_COLOR_ALPHA );
102*b1cdbd2cSJim Jagielski 		virtual SurfaceSharedPtr createSurface( ::Bitmap& rBitmap );
103*b1cdbd2cSJim Jagielski 		virtual SurfaceSharedPtr changeSurface( bool bHasAlpha, bool bCopyContent );
104*b1cdbd2cSJim Jagielski 		virtual OutputDevice* getOutputDevice();
105*b1cdbd2cSJim Jagielski 
106*b1cdbd2cSJim Jagielski         // RepaintTarget
107*b1cdbd2cSJim Jagielski         virtual bool repaint( const SurfaceSharedPtr&                         pSurface,
108*b1cdbd2cSJim Jagielski 							  const ::com::sun::star::rendering::ViewState&	  viewState,
109*b1cdbd2cSJim Jagielski 							  const ::com::sun::star::rendering::RenderState& renderState );
110*b1cdbd2cSJim Jagielski 
111*b1cdbd2cSJim Jagielski         // XFastPropertySet
112*b1cdbd2cSJim Jagielski         // used to retrieve BitmapEx pointer or X Pixmap handles for this bitmap
113*b1cdbd2cSJim Jagielski         // handle values have these meanings:
114*b1cdbd2cSJim Jagielski         // 0 ... get pointer to BitmapEx
115*b1cdbd2cSJim Jagielski         // 1 ... get X pixmap handle to rgb content
116*b1cdbd2cSJim Jagielski         // 2 ... get X pitmap handle to alpha mask
117*b1cdbd2cSJim Jagielski         // returned any contains either BitmapEx pointer or array of three Any value
118*b1cdbd2cSJim Jagielski         //     1st a bool value: true - free the pixmap after used by XFreePixmap, false do nothing, the pixmap is used internally in the canvas
119*b1cdbd2cSJim Jagielski         //     2nd the pixmap handle
120*b1cdbd2cSJim Jagielski         //     3rd the pixmap depth
121*b1cdbd2cSJim Jagielski         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 &)122*b1cdbd2cSJim Jagielski         virtual void SAL_CALL setFastPropertyValue(sal_Int32, const ::com::sun::star::uno::Any&)  throw (::com::sun::star::uno::RuntimeException) {}
123*b1cdbd2cSJim Jagielski 
124*b1cdbd2cSJim Jagielski     private:
125*b1cdbd2cSJim Jagielski         SurfaceProviderRef        mpSurfaceProvider;
126*b1cdbd2cSJim Jagielski 		::cairo::SurfaceSharedPtr mpBufferSurface;
127*b1cdbd2cSJim Jagielski 		::cairo::CairoSharedPtr   mpBufferCairo;
128*b1cdbd2cSJim Jagielski 
129*b1cdbd2cSJim Jagielski         const ::basegfx::B2ISize  maSize;
130*b1cdbd2cSJim Jagielski 		const bool                mbHasAlpha;
131*b1cdbd2cSJim Jagielski     };
132*b1cdbd2cSJim Jagielski }
133*b1cdbd2cSJim Jagielski 
134*b1cdbd2cSJim Jagielski #endif /* _CAIROCANVAS_CANVASBITMAP_HXX */
135