1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef _VCLCANVAS_CANVASBITMAP_HXX 29*cdf0e10cSrcweir #define _VCLCANVAS_CANVASBITMAP_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/rendering/XBitmapCanvas.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/rendering/XIntegerBitmap.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/beans/XFastPropertySet.hpp> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <vcl/virdev.hxx> 39*cdf0e10cSrcweir #include <vcl/bitmapex.hxx> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include <canvas/vclwrapper.hxx> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #include <canvas/base/integerbitmapbase.hxx> 44*cdf0e10cSrcweir #include <canvasbitmaphelper.hxx> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir #include "impltools.hxx" 47*cdf0e10cSrcweir #include "repainttarget.hxx" 48*cdf0e10cSrcweir #include "spritecanvas.hxx" 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir /* Definition of CanvasBitmap class */ 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir namespace vclcanvas 54*cdf0e10cSrcweir { 55*cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::rendering::XBitmapCanvas, 56*cdf0e10cSrcweir ::com::sun::star::rendering::XIntegerBitmap, 57*cdf0e10cSrcweir ::com::sun::star::lang::XServiceInfo, 58*cdf0e10cSrcweir ::com::sun::star::beans::XFastPropertySet > CanvasBitmapBase_Base; 59*cdf0e10cSrcweir typedef ::canvas::IntegerBitmapBase< ::canvas::BaseMutexHelper< CanvasBitmapBase_Base >, 60*cdf0e10cSrcweir CanvasBitmapHelper, 61*cdf0e10cSrcweir tools::LocalGuard, 62*cdf0e10cSrcweir ::cppu::OWeakObject > CanvasBitmap_Base; 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir class CanvasBitmap : public CanvasBitmap_Base, 65*cdf0e10cSrcweir public RepaintTarget 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir public: 68*cdf0e10cSrcweir /** Must be called with locked Solar mutex 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir @param rSize 71*cdf0e10cSrcweir Size in pixel of the bitmap to generate 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir @param bAlphaBitmap 74*cdf0e10cSrcweir When true, bitmap will have an alpha channel 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir @param rDevice 77*cdf0e10cSrcweir Reference device, with which bitmap should be compatible 78*cdf0e10cSrcweir */ 79*cdf0e10cSrcweir CanvasBitmap( const ::Size& rSize, 80*cdf0e10cSrcweir bool bAlphaBitmap, 81*cdf0e10cSrcweir ::com::sun::star::rendering::XGraphicDevice& rDevice, 82*cdf0e10cSrcweir const OutDevProviderSharedPtr& rOutDevProvider ); 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir /// Must be called with locked Solar mutex 85*cdf0e10cSrcweir CanvasBitmap( const BitmapEx& rBitmap, 86*cdf0e10cSrcweir ::com::sun::star::rendering::XGraphicDevice& rDevice, 87*cdf0e10cSrcweir const OutDevProviderSharedPtr& rOutDevProvider ); 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir // overridden because of mpDevice 90*cdf0e10cSrcweir virtual void SAL_CALL disposing(); 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir // XServiceInfo 93*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); 94*cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); 95*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir // RepaintTarget interface 98*cdf0e10cSrcweir virtual bool repaint( const GraphicObjectSharedPtr& rGrf, 99*cdf0e10cSrcweir const ::com::sun::star::rendering::ViewState& viewState, 100*cdf0e10cSrcweir const ::com::sun::star::rendering::RenderState& renderState, 101*cdf0e10cSrcweir const ::Point& rPt, 102*cdf0e10cSrcweir const ::Size& rSz, 103*cdf0e10cSrcweir const GraphicAttr& rAttr ) const; 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir /// Not threadsafe! Returned object is shared! 106*cdf0e10cSrcweir BitmapEx getBitmap() const; 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir // XFastPropertySet 109*cdf0e10cSrcweir // used to retrieve BitmapEx pointer or X Pixmap handles for this bitmap 110*cdf0e10cSrcweir // handle values have these meanings: 111*cdf0e10cSrcweir // 0 ... get pointer to BitmapEx 112*cdf0e10cSrcweir // 1 ... get X pixmap handle to rgb content 113*cdf0e10cSrcweir // 2 ... get X pitmap handle to alpha mask 114*cdf0e10cSrcweir // returned any contains either BitmapEx pointer or array of three Any value 115*cdf0e10cSrcweir // 1st a bool value: true - free the pixmap after used by XFreePixmap, false do nothing, the pixmap is used internally in the canvas 116*cdf0e10cSrcweir // 2nd the pixmap handle 117*cdf0e10cSrcweir // 3rd the pixmap depth 118*cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) throw (::com::sun::star::uno::RuntimeException); 119*cdf0e10cSrcweir virtual void SAL_CALL setFastPropertyValue(sal_Int32, const ::com::sun::star::uno::Any&) throw (::com::sun::star::uno::RuntimeException) {} 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir private: 122*cdf0e10cSrcweir /** MUST hold here, too, since CanvasHelper only contains a 123*cdf0e10cSrcweir raw pointer (without refcounting) 124*cdf0e10cSrcweir */ 125*cdf0e10cSrcweir ::com::sun::star::uno::Reference<com::sun::star::rendering::XGraphicDevice> mxDevice; 126*cdf0e10cSrcweir }; 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir #endif /* _VCLCANVAS_CANVASBITMAP_HXX */ 130