1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cairo_canvasbitmap.hxx,v $
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 */
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
,
72 ::cppu::OWeakObject
> CanvasBitmap_Base
;
74 class CanvasBitmap
: public CanvasBitmap_Base
,
78 /** Create a canvas bitmap for the given surface
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
,
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
99 DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( CanvasBitmap
, CanvasBitmapBase_Base
, ::cppu::WeakComponentImplHelperBase
);
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
);
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();
114 virtual bool repaint( const SurfaceSharedPtr
& pSurface
,
115 const ::com::sun::star::rendering::ViewState
& viewState
,
116 const ::com::sun::star::rendering::RenderState
& renderState
);
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
) {}
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 */