1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 #ifndef _CAIROCANVAS_CANVASBITMAP_HXX
29 #define _CAIROCANVAS_CANVASBITMAP_HXX
31 #include <cppuhelper/compbase4.hxx>
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 #include <comphelper/uno3.hxx>
39 #include <basegfx/vector/b2isize.hxx>
41 #include <boost/shared_ptr.hpp>
43 #include <canvas/base/integerbitmapbase.hxx>
45 #include "cairo_cairo.hxx"
46 #include "cairo_canvashelper.hxx"
47 #include "cairo_repainttarget.hxx"
48 #include "cairo_spritecanvas.hxx"
51 /* Definition of CanvasBitmap class */
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 class CanvasBitmapSpriteSurface_Base
:
60 public ::canvas::BaseMutexHelper
<CanvasBitmapBase_Base
>,
61 public SurfaceProvider
65 typedef ::canvas::IntegerBitmapBase
<
66 CanvasBitmapSpriteSurface_Base
,
69 ::cppu::OWeakObject
> CanvasBitmap_Base
;
71 class CanvasBitmap
: public CanvasBitmap_Base
,
75 /** Create a canvas bitmap for the given surface
81 Reference device, with which bitmap should be compatible
83 CanvasBitmap( const ::basegfx::B2ISize
& rSize
,
84 const SurfaceProviderRef
& rDevice
,
85 ::com::sun::star::rendering::XGraphicDevice
* pDevice
,
88 /// Dispose all internal references
89 virtual void SAL_CALL
disposing();
91 // Forwarding the XComponent implementation to the
92 // cppu::ImplHelper templated base
93 // Classname Base doing refcounting Base implementing the XComponent interface
96 DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( CanvasBitmap
, CanvasBitmapBase_Base
, ::cppu::WeakComponentImplHelperBase
);
99 virtual ::rtl::OUString SAL_CALL
getImplementationName( ) throw (::com::sun::star::uno::RuntimeException
);
100 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
) throw (::com::sun::star::uno::RuntimeException
);
101 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException
);
104 virtual SurfaceSharedPtr
getSurface();
105 virtual SurfaceSharedPtr
createSurface( const ::basegfx::B2ISize
& rSize
, Content aContent
= CAIRO_CONTENT_COLOR_ALPHA
);
106 virtual SurfaceSharedPtr
createSurface( ::Bitmap
& rBitmap
);
107 virtual SurfaceSharedPtr
changeSurface( bool bHasAlpha
, bool bCopyContent
);
108 virtual OutputDevice
* getOutputDevice();
111 virtual bool repaint( const SurfaceSharedPtr
& pSurface
,
112 const ::com::sun::star::rendering::ViewState
& viewState
,
113 const ::com::sun::star::rendering::RenderState
& renderState
);
116 // used to retrieve BitmapEx pointer or X Pixmap handles for this bitmap
117 // handle values have these meanings:
118 // 0 ... get pointer to BitmapEx
119 // 1 ... get X pixmap handle to rgb content
120 // 2 ... get X pitmap handle to alpha mask
121 // returned any contains either BitmapEx pointer or array of three Any value
122 // 1st a bool value: true - free the pixmap after used by XFreePixmap, false do nothing, the pixmap is used internally in the canvas
123 // 2nd the pixmap handle
124 // 3rd the pixmap depth
125 virtual ::com::sun::star::uno::Any SAL_CALL
getFastPropertyValue(sal_Int32 nHandle
) throw (::com::sun::star::uno::RuntimeException
);
126 virtual void SAL_CALL
setFastPropertyValue(sal_Int32
, const ::com::sun::star::uno::Any
&) throw (::com::sun::star::uno::RuntimeException
) {}
129 SurfaceProviderRef mpSurfaceProvider
;
130 ::cairo::SurfaceSharedPtr mpBufferSurface
;
131 ::cairo::CairoSharedPtr mpBufferCairo
;
133 const ::basegfx::B2ISize maSize
;
134 const bool mbHasAlpha
;
138 #endif /* _CAIROCANVAS_CANVASBITMAP_HXX */