xref: /trunk/main/vcl/inc/unx/salbmp.h (revision cdf0e10c)
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 _SV_SALBMP_H
29 #define _SV_SALBMP_H
30 
31 #include <unx/salstd.hxx>
32 #ifndef _SV_SALGTYPE
33 #include <vcl/salgtype.hxx>
34 #endif
35 #include <unx/saldisp.hxx>
36 #include <salbmp.hxx>
37 #include <vclpluginapi.h>
38 
39 struct	BitmapBuffer;
40 class	BitmapPalette;
41 class	SalGraphics;
42 class	ImplSalDDB;
43 class	ImplSalBitmapCache;
44 
45 // -------------
46 // - SalBitmap -
47 // -------------
48 
49 class VCLPLUG_GEN_PUBLIC X11SalBitmap : public SalBitmap
50 {
51 private:
52 
53 	static BitmapBuffer*		ImplCreateDIB( const Size& rSize,
54 											   sal_uInt16 nBitCount,
55 											   const BitmapPalette& rPal );
56 	static BitmapBuffer*		ImplCreateDIB( Drawable aDrawable,
57                                                int nScreen,
58 											   long nDrawableDepth,
59 											   long nX, long nY,
60 											   long nWidth, long nHeight );
61 
62 public:
63 
64 	static ImplSalBitmapCache*	mpCache;
65 	static sal_uIntPtr				mnCacheInstCount;
66 
67 	static void					ImplCreateCache();
68 	static void					ImplDestroyCache();
69     void				        ImplRemovedFromCache();
70 
71     bool                        SnapShot (Display* pDisplay, XLIB_Window hWindow);
72     bool                        ImplCreateFromXImage( Display* pDisplay,
73                                                       XLIB_Window hWindow,
74                                                       int nScreen,
75                                                       XImage* pImage);
76 private:
77 
78 
79 	BitmapBuffer*	mpDIB;
80 	ImplSalDDB*		mpDDB;
81 
82 public:
83 
84 	SAL_DLLPRIVATE bool    ImplCreateFromDrawable( Drawable aDrawable,
85                                                   int nScreen,
86                                                   long nDrawableDepth,
87                                                   long nX, long nY,
88                                                   long nWidth, long nHeight );
89 
90 	SAL_DLLPRIVATE XImage* ImplCreateXImage( SalDisplay* pSalDisp,
91                                             int nScreen, long nDepth,
92 									  		const SalTwoRect& rTwoRect ) const;
93 
94     SAL_DLLPRIVATE ImplSalDDB* ImplGetDDB( Drawable, int nScreen, long nDrawableDepth,
95                                            const SalTwoRect& ) const;
96 	void    ImplDraw( Drawable aDrawable, int nScreen, long nDrawableDepth,
97                       const SalTwoRect& rTwoRect, const GC& rGC ) const;
98 
99 public:
100 
101     X11SalBitmap();
102     virtual ~X11SalBitmap();
103 
104     // overload pure virtual methods
105 	virtual bool			Create( const Size& rSize,
106                             sal_uInt16 nBitCount,
107 							const BitmapPalette& rPal );
108 	virtual bool			Create( const SalBitmap& rSalBmp );
109 	virtual bool			Create( const SalBitmap& rSalBmp,
110                                     SalGraphics* pGraphics );
111 	virtual bool			Create( const SalBitmap& rSalBmp,
112                                     sal_uInt16 nNewBitCount );
113 
114 	virtual void			Destroy();
115 
116 	virtual Size			GetSize() const;
117 	virtual sal_uInt16			GetBitCount() const;
118 
119 	virtual BitmapBuffer*	AcquireBuffer( bool bReadOnly );
120 	virtual void			ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly );
121     virtual bool            GetSystemData( BitmapSystemData& rData );
122 };
123 
124 // --------------
125 // - ImplSalDDB -
126 // --------------
127 
128 class ImplSalDDB
129 {
130 private:
131 
132 	Pixmap			maPixmap;
133 	SalTwoRect		maTwoRect;
134 	long			mnDepth;
135     int             mnScreen;
136 
137 					ImplSalDDB() {}
138 
139     static void	ImplDraw( Drawable aSrcDrawable, long nSrcDrawableDepth,
140                           Drawable aDstDrawable, long nDstDrawableDepth,
141                           long nSrcX, long nSrcY,
142                           long nDestWidth, long nDestHeight,
143                           long nDestX, long nDestY, const GC& rGC );
144 
145 public:
146 
147 					ImplSalDDB( XImage* pImage,
148                                 Drawable aDrawable, int nScreen,
149 								const SalTwoRect& rTwoRect );
150 					ImplSalDDB( Drawable aDrawable,
151                                 int nScreen,
152                                 long nDrawableDepth,
153 								long nX, long nY, long nWidth, long nHeight );
154                     ImplSalDDB( Display* pDisplay,
155                                 XLIB_Window hWindow,
156                                 int nScreen,
157                                 XImage* pImage);
158 					~ImplSalDDB();
159 
160 	Pixmap			ImplGetPixmap() const { return maPixmap; }
161 	long			ImplGetWidth() const { return maTwoRect.mnDestWidth; }
162 	long			ImplGetHeight() const { return maTwoRect.mnDestHeight; }
163 	long			ImplGetDepth() const { return mnDepth; }
164 	sal_uIntPtr			ImplGetMemSize() const { return( ( maTwoRect.mnDestWidth * maTwoRect.mnDestHeight * mnDepth ) >> 3 ); }
165     int             ImplGetScreen() const { return mnScreen; }
166 
167 	bool			ImplMatches( int nScreen, long nDepth, const SalTwoRect& rTwoRect ) const;
168 	void			ImplDraw( Drawable aDrawable, long nDrawableDepth,
169                               const SalTwoRect& rTwoRect, const GC& rGC ) const;
170 };
171 
172 // ----------------------
173 // - ImplSalBitmapCache -
174 // ----------------------
175 
176 class ImplSalBitmapCache
177 {
178 private:
179 
180 	List			maBmpList;
181 	sal_uIntPtr			mnTotalSize;
182 
183 public:
184 
185 					ImplSalBitmapCache();
186 					~ImplSalBitmapCache();
187 
188 	void			ImplAdd( X11SalBitmap* pBmp, sal_uIntPtr nMemSize = 0UL, sal_uIntPtr nFlags = 0UL );
189 	void			ImplRemove( X11SalBitmap* pBmp );
190 	void			ImplClear();
191 };
192 
193 #endif // _SV_SALBMP_HXX
194 
195 
196 
197 
198 
199 
200 
201 
202 
203 
204 
205 
206 
207 
208 
209 
210 
211 
212 
213 
214 
215 
216 
217 
218 
219 
220 
221 
222 
223 
224 
225 
226 
227 
228 
229 
230 
231 
232 
233 
234 
235 
236 
237 
238