update dev300-m58
[ooovba.git] / canvas / source / cairo / cairo_canvasbitmap.hxx
blob6cd67c08bfe77881e9b01693bde411f0ed584373
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cairo_canvasbitmap.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CAIROCANVAS_CANVASBITMAP_HXX
32 #define _CAIROCANVAS_CANVASBITMAP_HXX
34 #include <cppuhelper/compbase4.hxx>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
38 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
39 #include <com/sun/star/beans/XFastPropertySet.hpp>
40 #include <comphelper/uno3.hxx>
42 #include <basegfx/vector/b2isize.hxx>
44 #include <boost/shared_ptr.hpp>
46 #include <canvas/base/integerbitmapbase.hxx>
48 #include "cairo_cairo.hxx"
49 #include "cairo_canvashelper.hxx"
50 #include "cairo_repainttarget.hxx"
51 #include "cairo_spritecanvas.hxx"
54 /* Definition of CanvasBitmap class */
56 namespace cairocanvas
58 typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::rendering::XBitmapCanvas,
59 ::com::sun::star::rendering::XIntegerBitmap,
60 ::com::sun::star::lang::XServiceInfo,
61 ::com::sun::star::beans::XFastPropertySet > CanvasBitmapBase_Base;
62 class CanvasBitmapSpriteSurface_Base :
63 public ::canvas::BaseMutexHelper<CanvasBitmapBase_Base>,
64 public SurfaceProvider
68 typedef ::canvas::IntegerBitmapBase<
69 CanvasBitmapSpriteSurface_Base,
70 CanvasHelper,
71 ::osl::MutexGuard,
72 ::cppu::OWeakObject > CanvasBitmap_Base;
74 class CanvasBitmap : public CanvasBitmap_Base,
75 public RepaintTarget
77 public:
78 /** Create a canvas bitmap for the given surface
80 @param rSize
81 Size of the bitmap
83 @param rDevice
84 Reference device, with which bitmap should be compatible
86 CanvasBitmap( const ::basegfx::B2ISize& rSize,
87 const SurfaceProviderRef& rDevice,
88 ::com::sun::star::rendering::XGraphicDevice* pDevice,
89 bool bHasAlpha );
91 /// Dispose all internal references
92 virtual void SAL_CALL disposing();
94 // Forwarding the XComponent implementation to the
95 // cppu::ImplHelper templated base
96 // Classname Base doing refcounting Base implementing the XComponent interface
97 // | | |
98 // V V V
99 DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( CanvasBitmap, CanvasBitmapBase_Base, ::cppu::WeakComponentImplHelperBase );
101 // XServiceInfo
102 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
103 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
104 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
106 // SurfaceProvider
107 virtual SurfaceSharedPtr getSurface();
108 virtual SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, Content aContent = CAIRO_CONTENT_COLOR_ALPHA );
109 virtual SurfaceSharedPtr createSurface( ::Bitmap& rBitmap );
110 virtual SurfaceSharedPtr changeSurface( bool bHasAlpha, bool bCopyContent );
111 virtual OutputDevice* getOutputDevice();
113 // RepaintTarget
114 virtual bool repaint( const SurfaceSharedPtr& pSurface,
115 const ::com::sun::star::rendering::ViewState& viewState,
116 const ::com::sun::star::rendering::RenderState& renderState );
118 // XFastPropertySet
119 // used to retrieve BitmapEx pointer or X Pixmap handles for this bitmap
120 // handle values have these meanings:
121 // 0 ... get pointer to BitmapEx
122 // 1 ... get X pixmap handle to rgb content
123 // 2 ... get X pitmap handle to alpha mask
124 // returned any contains either BitmapEx pointer or array of three Any value
125 // 1st a bool value: true - free the pixmap after used by XFreePixmap, false do nothing, the pixmap is used internally in the canvas
126 // 2nd the pixmap handle
127 // 3rd the pixmap depth
128 virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) throw (::com::sun::star::uno::RuntimeException);
129 virtual void SAL_CALL setFastPropertyValue(sal_Int32, const ::com::sun::star::uno::Any&) throw (::com::sun::star::uno::RuntimeException) {}
131 private:
132 SurfaceProviderRef mpSurfaceProvider;
133 ::cairo::SurfaceSharedPtr mpBufferSurface;
134 ::cairo::CairoSharedPtr mpBufferCairo;
136 const ::basegfx::B2ISize maSize;
137 const bool mbHasAlpha;
141 #endif /* _CAIROCANVAS_CANVASBITMAP_HXX */