1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dx_surfacebitmap.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _DXCANVAS_DXSURFACEBITMAP_HXX
32 #define _DXCANVAS_DXSURFACEBITMAP_HXX
34 #include <canvas/rendering/isurfaceproxy.hxx>
35 #include <canvas/rendering/isurfaceproxymanager.hxx>
36 #include "dx_ibitmap.hxx"
37 #include "dx_canvasfont.hxx" //winstuff
38 #include "dx_gdiplususer.hxx"
39 #include "dx_rendermodule.hxx"
43 class DXSurfaceBitmap
: public IBitmap
46 DXSurfaceBitmap( const ::basegfx::B2IVector
& rSize
,
47 const canvas::ISurfaceProxyManagerSharedPtr
& rMgr
,
48 const IDXRenderModuleSharedPtr
& rRenderModule
,
51 bool resize( const ::basegfx::B2IVector
& rSize
);
54 virtual GraphicsSharedPtr
getGraphics();
56 virtual BitmapSharedPtr
getBitmap() const;
57 virtual ::basegfx::B2IVector
getSize() const;
58 virtual bool hasAlpha() const;
60 COMReference
<surface_type
> getSurface() const { return mpSurface
; }
62 bool draw( double fAlpha
,
63 const ::basegfx::B2DPoint
& rPos
,
64 const ::basegfx::B2DHomMatrix
& rTransform
);
66 bool draw( const ::basegfx::B2IRange
& rArea
);
68 bool draw( double fAlpha
,
69 const ::basegfx::B2DPoint
& rPos
,
70 const ::basegfx::B2DRange
& rArea
,
71 const ::basegfx::B2DHomMatrix
& rTransform
);
73 bool draw( double fAlpha
,
74 const ::basegfx::B2DPoint
& rPos
,
75 const ::basegfx::B2DPolyPolygon
& rClipPoly
,
76 const ::basegfx::B2DHomMatrix
& rTransform
);
78 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> getData(
79 ::com::sun::star::rendering::IntegerBitmapLayout
& bitmapLayout
,
80 const ::com::sun::star::geometry::IntegerRectangle2D
& rect
);
83 const ::com::sun::star::uno::Sequence
< sal_Int8
>& data
,
84 const ::com::sun::star::rendering::IntegerBitmapLayout
& bitmapLayout
,
85 const ::com::sun::star::geometry::IntegerRectangle2D
& rect
);
87 virtual void setPixel(
88 const ::com::sun::star::uno::Sequence
< sal_Int8
>& color
,
89 const ::com::sun::star::rendering::IntegerBitmapLayout
& bitmapLayout
,
90 const ::com::sun::star::geometry::IntegerPoint2D
& pos
);
92 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> getPixel(
93 ::com::sun::star::rendering::IntegerBitmapLayout
& bitmapLayout
,
94 const ::com::sun::star::geometry::IntegerPoint2D
& pos
);
96 #ifdef DX_DEBUG_IMAGES
102 // Refcounted global GDI+ state container
103 GDIPlusUserSharedPtr mpGdiPlusUser
;
105 // size of this image in pixels [integral unit]
106 ::basegfx::B2IVector maSize
;
108 // pointer to the rendermodule, needed to create surfaces
109 // which are used as container for the actual pixel data.
110 // generally we could use any kind of storage, but GDI+
111 // is not willing to render antialiased fonts unless we
112 // use this special kind of container, don't ask me why...
113 IDXRenderModuleSharedPtr mpRenderModule
;
115 // pointer to the surface manager, needed in case clients
116 // want to resize the bitmap.
117 canvas::ISurfaceProxyManagerSharedPtr mpSurfaceManager
;
119 // access point to the surface proxy which handles
120 // the hardware-dependent rendering stuff.
121 canvas::ISurfaceProxySharedPtr mpSurfaceProxy
;
123 // container for pixel data, we need to use a directx
124 // surface since GDI+ sucks...
125 COMReference
<surface_type
> mpSurface
;
127 // since GDI+ does not work correctly in case we
128 // run on a 16bit display [don't ask me why] we need
129 // to occasionally render to a native GDI+ bitmap.
130 BitmapSharedPtr mpGDIPlusBitmap
;
131 // Graphics for the mpGDIPlusBitmap
132 GraphicsSharedPtr mpGraphics
;
134 // internal implementation of the iColorBuffer interface
135 canvas::IColorBufferSharedPtr mpColorBuffer
;
137 // indicates wether the associated surface needs
138 // to refresh its contents or not. in other words,
139 // this flag is set iff both representations are
141 mutable bool mbIsSurfaceDirty
;
143 // true if the bitmap contains an alpha channel
147 typedef ::boost::shared_ptr
< DXSurfaceBitmap
> DXSurfaceBitmapSharedPtr
;