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