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