1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 #ifndef _DXCANVAS_DXSURFACEBITMAP_HXX
29 #define _DXCANVAS_DXSURFACEBITMAP_HXX
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"
40 class DXSurfaceBitmap
: public IBitmap
43 DXSurfaceBitmap( const ::basegfx::B2IVector
& rSize
,
44 const canvas::ISurfaceProxyManagerSharedPtr
& rMgr
,
45 const IDXRenderModuleSharedPtr
& rRenderModule
,
48 bool resize( const ::basegfx::B2IVector
& rSize
);
51 virtual GraphicsSharedPtr
getGraphics();
53 virtual BitmapSharedPtr
getBitmap() const;
54 virtual ::basegfx::B2IVector
getSize() const;
55 virtual bool hasAlpha() const;
57 COMReference
<surface_type
> getSurface() const { return mpSurface
; }
59 bool draw( double fAlpha
,
60 const ::basegfx::B2DPoint
& rPos
,
61 const ::basegfx::B2DHomMatrix
& rTransform
);
63 bool draw( const ::basegfx::B2IRange
& rArea
);
65 bool draw( double fAlpha
,
66 const ::basegfx::B2DPoint
& rPos
,
67 const ::basegfx::B2DRange
& rArea
,
68 const ::basegfx::B2DHomMatrix
& rTransform
);
70 bool draw( double fAlpha
,
71 const ::basegfx::B2DPoint
& rPos
,
72 const ::basegfx::B2DPolyPolygon
& rClipPoly
,
73 const ::basegfx::B2DHomMatrix
& rTransform
);
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
);
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
);
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
);
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
);
93 #ifdef DX_DEBUG_IMAGES
99 // Refcounted global GDI+ state container
100 GDIPlusUserSharedPtr mpGdiPlusUser
;
102 // size of this image in pixels [integral unit]
103 ::basegfx::B2IVector maSize
;
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
;
112 // pointer to the surface manager, needed in case clients
113 // want to resize the bitmap.
114 canvas::ISurfaceProxyManagerSharedPtr mpSurfaceManager
;
116 // access point to the surface proxy which handles
117 // the hardware-dependent rendering stuff.
118 canvas::ISurfaceProxySharedPtr mpSurfaceProxy
;
120 // container for pixel data, we need to use a directx
121 // surface since GDI+ sucks...
122 COMReference
<surface_type
> mpSurface
;
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
;
131 // internal implementation of the iColorBuffer interface
132 canvas::IColorBufferSharedPtr mpColorBuffer
;
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
138 mutable bool mbIsSurfaceDirty
;
140 // true if the bitmap contains an alpha channel
144 typedef ::boost::shared_ptr
< DXSurfaceBitmap
> DXSurfaceBitmapSharedPtr
;