xref: /trunk/main/vcl/inc/unx/salbmp.h (revision 24f6443d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SV_SALBMP_H
25 #define _SV_SALBMP_H
26 
27 #include <unx/salstd.hxx>
28 #ifndef _SV_SALGTYPE
29 #include <vcl/salgtype.hxx>
30 #endif
31 #include <unx/saldisp.hxx>
32 #include <salbmp.hxx>
33 #include <vclpluginapi.h>
34 
35 struct	BitmapBuffer;
36 class	BitmapPalette;
37 class	SalGraphics;
38 class	ImplSalDDB;
39 class	ImplSalBitmapCache;
40 
41 // -------------
42 // - SalBitmap -
43 // -------------
44 
45 class VCLPLUG_GEN_PUBLIC X11SalBitmap : public SalBitmap
46 {
47 private:
48 
49 	static BitmapBuffer*		ImplCreateDIB( const Size& rSize,
50 											   sal_uInt16 nBitCount,
51 											   const BitmapPalette& rPal );
52 	static BitmapBuffer*		ImplCreateDIB( Drawable aDrawable,
53                                                int nScreen,
54 											   long nDrawableDepth,
55 											   long nX, long nY,
56 											   long nWidth, long nHeight );
57 
58 public:
59 
60 	static ImplSalBitmapCache*	mpCache;
61 	static sal_uIntPtr				mnCacheInstCount;
62 
63 	static void					ImplCreateCache();
64 	static void					ImplDestroyCache();
65     void				        ImplRemovedFromCache();
66 
67     bool                        SnapShot (Display* pDisplay, XLIB_Window hWindow);
68     bool                        ImplCreateFromXImage( Display* pDisplay,
69                                                       XLIB_Window hWindow,
70                                                       int nScreen,
71                                                       XImage* pImage);
72 private:
73 
74 
75 	BitmapBuffer*	mpDIB;
76 	ImplSalDDB*		mpDDB;
77 
78 public:
79 
80 	SAL_DLLPRIVATE bool    ImplCreateFromDrawable( Drawable aDrawable,
81                                                   int nScreen,
82                                                   long nDrawableDepth,
83                                                   long nX, long nY,
84                                                   long nWidth, long nHeight );
85 
86 	SAL_DLLPRIVATE XImage* ImplCreateXImage( SalDisplay* pSalDisp,
87                                             int nScreen, long nDepth,
88 									  		const SalTwoRect& rTwoRect ) const;
89 
90     SAL_DLLPRIVATE ImplSalDDB* ImplGetDDB( Drawable, int nScreen, long nDrawableDepth,
91                                            const SalTwoRect& ) const;
92 	void    ImplDraw( Drawable aDrawable, int nScreen, long nDrawableDepth,
93                       const SalTwoRect& rTwoRect, const GC& rGC ) const;
94 
95 public:
96 
97     X11SalBitmap();
98     virtual ~X11SalBitmap();
99 
100     // overload pure virtual methods
101 	virtual bool			Create( const Size& rSize,
102                             sal_uInt16 nBitCount,
103 							const BitmapPalette& rPal );
104 	virtual bool			Create( const SalBitmap& rSalBmp );
105 	virtual bool			Create( const SalBitmap& rSalBmp,
106                                     SalGraphics* pGraphics );
107 	virtual bool			Create( const SalBitmap& rSalBmp,
108                                     sal_uInt16 nNewBitCount );
109 
110 	virtual void			Destroy();
111 
112 	virtual Size			GetSize() const;
113 	virtual sal_uInt16			GetBitCount() const;
114 
115 	virtual BitmapBuffer*	AcquireBuffer( bool bReadOnly );
116 	virtual void			ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly );
117     virtual bool            GetSystemData( BitmapSystemData& rData );
118 };
119 
120 // --------------
121 // - ImplSalDDB -
122 // --------------
123 
124 class ImplSalDDB
125 {
126 private:
127 
128 	Pixmap			maPixmap;
129 	SalTwoRect		maTwoRect;
130 	long			mnDepth;
131     int             mnScreen;
132 
ImplSalDDB()133 					ImplSalDDB() {}
134 
135     static void	ImplDraw( Drawable aSrcDrawable, long nSrcDrawableDepth,
136                           Drawable aDstDrawable, long nDstDrawableDepth,
137                           long nSrcX, long nSrcY,
138                           long nDestWidth, long nDestHeight,
139                           long nDestX, long nDestY, const GC& rGC );
140 
141 public:
142 
143 					ImplSalDDB( XImage* pImage,
144                                 Drawable aDrawable, int nScreen,
145 								const SalTwoRect& rTwoRect );
146 					ImplSalDDB( Drawable aDrawable,
147                                 int nScreen,
148                                 long nDrawableDepth,
149 								long nX, long nY, long nWidth, long nHeight );
150                     ImplSalDDB( Display* pDisplay,
151                                 XLIB_Window hWindow,
152                                 int nScreen,
153                                 XImage* pImage);
154 					~ImplSalDDB();
155 
ImplGetPixmap() const156 	Pixmap			ImplGetPixmap() const { return maPixmap; }
ImplGetWidth() const157 	long			ImplGetWidth() const { return maTwoRect.mnDestWidth; }
ImplGetHeight() const158 	long			ImplGetHeight() const { return maTwoRect.mnDestHeight; }
ImplGetDepth() const159 	long			ImplGetDepth() const { return mnDepth; }
ImplGetMemSize() const160 	sal_uIntPtr			ImplGetMemSize() const { return( ( maTwoRect.mnDestWidth * maTwoRect.mnDestHeight * mnDepth ) >> 3 ); }
ImplGetScreen() const161     int             ImplGetScreen() const { return mnScreen; }
162 
163 	bool			ImplMatches( int nScreen, long nDepth, const SalTwoRect& rTwoRect ) const;
164 	void			ImplDraw( Drawable aDrawable, long nDrawableDepth,
165                               const SalTwoRect& rTwoRect, const GC& rGC ) const;
166 };
167 
168 // ----------------------
169 // - ImplSalBitmapCache -
170 // ----------------------
171 
172 class ImplSalBitmapCache
173 {
174 private:
175 
176 	List			maBmpList;
177 	sal_uIntPtr			mnTotalSize;
178 
179 public:
180 
181 					ImplSalBitmapCache();
182 					~ImplSalBitmapCache();
183 
184 	void			ImplAdd( X11SalBitmap* pBmp, sal_uIntPtr nMemSize = 0UL, sal_uIntPtr nFlags = 0UL );
185 	void			ImplRemove( X11SalBitmap* pBmp );
186 	void			ImplClear();
187 };
188 
189 #endif // _SV_SALBMP_HXX
190 
191 
192 
193 
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