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 _DXCANVAS_DXSURFACEBITMAP_HXX 29*cdf0e10cSrcweir #define _DXCANVAS_DXSURFACEBITMAP_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <canvas/rendering/isurfaceproxy.hxx> 32*cdf0e10cSrcweir #include <canvas/rendering/isurfaceproxymanager.hxx> 33*cdf0e10cSrcweir #include "dx_ibitmap.hxx" 34*cdf0e10cSrcweir #include "dx_canvasfont.hxx" //winstuff 35*cdf0e10cSrcweir #include "dx_gdiplususer.hxx" 36*cdf0e10cSrcweir #include "dx_rendermodule.hxx" 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir namespace dxcanvas 39*cdf0e10cSrcweir { 40*cdf0e10cSrcweir class DXSurfaceBitmap : public IBitmap 41*cdf0e10cSrcweir { 42*cdf0e10cSrcweir public: 43*cdf0e10cSrcweir DXSurfaceBitmap( const ::basegfx::B2IVector& rSize, 44*cdf0e10cSrcweir const canvas::ISurfaceProxyManagerSharedPtr& rMgr, 45*cdf0e10cSrcweir const IDXRenderModuleSharedPtr& rRenderModule, 46*cdf0e10cSrcweir bool bWithAlpha ); 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir bool resize( const ::basegfx::B2IVector& rSize ); 49*cdf0e10cSrcweir void clear(); 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir virtual GraphicsSharedPtr getGraphics(); 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir virtual BitmapSharedPtr getBitmap() const; 54*cdf0e10cSrcweir virtual ::basegfx::B2IVector getSize() const; 55*cdf0e10cSrcweir virtual bool hasAlpha() const; 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir COMReference<surface_type> getSurface() const { return mpSurface; } 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir bool draw( double fAlpha, 60*cdf0e10cSrcweir const ::basegfx::B2DPoint& rPos, 61*cdf0e10cSrcweir const ::basegfx::B2DHomMatrix& rTransform ); 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir bool draw( const ::basegfx::B2IRange& rArea ); 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir bool draw( double fAlpha, 66*cdf0e10cSrcweir const ::basegfx::B2DPoint& rPos, 67*cdf0e10cSrcweir const ::basegfx::B2DRange& rArea, 68*cdf0e10cSrcweir const ::basegfx::B2DHomMatrix& rTransform ); 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir bool draw( double fAlpha, 71*cdf0e10cSrcweir const ::basegfx::B2DPoint& rPos, 72*cdf0e10cSrcweir const ::basegfx::B2DPolyPolygon& rClipPoly, 73*cdf0e10cSrcweir const ::basegfx::B2DHomMatrix& rTransform ); 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< sal_Int8 > getData( 76*cdf0e10cSrcweir ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 77*cdf0e10cSrcweir const ::com::sun::star::geometry::IntegerRectangle2D& rect ); 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir virtual void setData( 80*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< sal_Int8 >& data, 81*cdf0e10cSrcweir const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 82*cdf0e10cSrcweir const ::com::sun::star::geometry::IntegerRectangle2D& rect ); 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir virtual void setPixel( 85*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< sal_Int8 >& color, 86*cdf0e10cSrcweir const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 87*cdf0e10cSrcweir const ::com::sun::star::geometry::IntegerPoint2D& pos ); 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< sal_Int8 > getPixel( 90*cdf0e10cSrcweir ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 91*cdf0e10cSrcweir const ::com::sun::star::geometry::IntegerPoint2D& pos ); 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir #ifdef DX_DEBUG_IMAGES 94*cdf0e10cSrcweir void imageDebugger(); 95*cdf0e10cSrcweir #endif 96*cdf0e10cSrcweir private: 97*cdf0e10cSrcweir void init(); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir // Refcounted global GDI+ state container 100*cdf0e10cSrcweir GDIPlusUserSharedPtr mpGdiPlusUser; 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir // size of this image in pixels [integral unit] 103*cdf0e10cSrcweir ::basegfx::B2IVector maSize; 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir // pointer to the rendermodule, needed to create surfaces 106*cdf0e10cSrcweir // which are used as container for the actual pixel data. 107*cdf0e10cSrcweir // generally we could use any kind of storage, but GDI+ 108*cdf0e10cSrcweir // is not willing to render antialiased fonts unless we 109*cdf0e10cSrcweir // use this special kind of container, don't ask me why... 110*cdf0e10cSrcweir IDXRenderModuleSharedPtr mpRenderModule; 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir // pointer to the surface manager, needed in case clients 113*cdf0e10cSrcweir // want to resize the bitmap. 114*cdf0e10cSrcweir canvas::ISurfaceProxyManagerSharedPtr mpSurfaceManager; 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir // access point to the surface proxy which handles 117*cdf0e10cSrcweir // the hardware-dependent rendering stuff. 118*cdf0e10cSrcweir canvas::ISurfaceProxySharedPtr mpSurfaceProxy; 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir // container for pixel data, we need to use a directx 121*cdf0e10cSrcweir // surface since GDI+ sucks... 122*cdf0e10cSrcweir COMReference<surface_type> mpSurface; 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir // since GDI+ does not work correctly in case we 125*cdf0e10cSrcweir // run on a 16bit display [don't ask me why] we need 126*cdf0e10cSrcweir // to occasionally render to a native GDI+ bitmap. 127*cdf0e10cSrcweir BitmapSharedPtr mpGDIPlusBitmap; 128*cdf0e10cSrcweir // Graphics for the mpGDIPlusBitmap 129*cdf0e10cSrcweir GraphicsSharedPtr mpGraphics; 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir // internal implementation of the iColorBuffer interface 132*cdf0e10cSrcweir canvas::IColorBufferSharedPtr mpColorBuffer; 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir // indicates wether the associated surface needs 135*cdf0e10cSrcweir // to refresh its contents or not. in other words, 136*cdf0e10cSrcweir // this flag is set iff both representations are 137*cdf0e10cSrcweir // out of sync. 138*cdf0e10cSrcweir mutable bool mbIsSurfaceDirty; 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir // true if the bitmap contains an alpha channel 141*cdf0e10cSrcweir bool mbAlpha; 142*cdf0e10cSrcweir }; 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir typedef ::boost::shared_ptr< DXSurfaceBitmap > DXSurfaceBitmapSharedPtr; 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir #endif 148