1*c82f2877SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*c82f2877SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*c82f2877SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*c82f2877SAndrew Rist * distributed with this work for additional information
6*c82f2877SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*c82f2877SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*c82f2877SAndrew Rist * "License"); you may not use this file except in compliance
9*c82f2877SAndrew Rist * with the License. You may obtain a copy of the License at
10*c82f2877SAndrew Rist *
11*c82f2877SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*c82f2877SAndrew Rist *
13*c82f2877SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*c82f2877SAndrew Rist * software distributed under the License is distributed on an
15*c82f2877SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c82f2877SAndrew Rist * KIND, either express or implied. See the License for the
17*c82f2877SAndrew Rist * specific language governing permissions and limitations
18*c82f2877SAndrew Rist * under the License.
19*c82f2877SAndrew Rist *
20*c82f2877SAndrew Rist *************************************************************/
21*c82f2877SAndrew Rist
22*c82f2877SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <string.h>
28cdf0e10cSrcweir #include <stdio.h>
29cdf0e10cSrcweir #include <errno.h>
30cdf0e10cSrcweir #ifdef FREEBSD
31cdf0e10cSrcweir #include <sys/types.h>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir
34cdf0e10cSrcweir #include <osl/endian.h>
35cdf0e10cSrcweir #include <rtl/memory.h>
36cdf0e10cSrcweir
37cdf0e10cSrcweir #include <vcl/bitmap.hxx>
38cdf0e10cSrcweir #include <vcl/salbtype.hxx>
39cdf0e10cSrcweir
40cdf0e10cSrcweir #include <tools/prex.h>
41cdf0e10cSrcweir #include "unx/Xproto.h"
42cdf0e10cSrcweir #include <tools/postx.h>
43cdf0e10cSrcweir #include <unx/salunx.h>
44cdf0e10cSrcweir #include <unx/saldata.hxx>
45cdf0e10cSrcweir #include <unx/saldisp.hxx>
46cdf0e10cSrcweir #include <unx/salgdi.h>
47cdf0e10cSrcweir #include <unx/salbmp.h>
48cdf0e10cSrcweir #include <unx/salinst.h>
49cdf0e10cSrcweir
50cdf0e10cSrcweir // -----------
51cdf0e10cSrcweir // - Defines -
52cdf0e10cSrcweir // -----------
53cdf0e10cSrcweir
54cdf0e10cSrcweir #define SAL_DRAWPIXMAP_MAX_EXT 4096
55cdf0e10cSrcweir
56cdf0e10cSrcweir // -------------
57cdf0e10cSrcweir // - SalBitmap -
58cdf0e10cSrcweir // -------------
59cdf0e10cSrcweir
CreateSalBitmap()60cdf0e10cSrcweir SalBitmap* X11SalInstance::CreateSalBitmap()
61cdf0e10cSrcweir {
62cdf0e10cSrcweir return new X11SalBitmap();
63cdf0e10cSrcweir }
64cdf0e10cSrcweir
65cdf0e10cSrcweir ImplSalBitmapCache* X11SalBitmap::mpCache = NULL;
66cdf0e10cSrcweir sal_uLong X11SalBitmap::mnCacheInstCount = 0;
67cdf0e10cSrcweir
68cdf0e10cSrcweir // -----------------------------------------------------------------------------
69cdf0e10cSrcweir
X11SalBitmap()70cdf0e10cSrcweir X11SalBitmap::X11SalBitmap() :
71cdf0e10cSrcweir mpDIB( NULL ),
72cdf0e10cSrcweir mpDDB( NULL )
73cdf0e10cSrcweir {
74cdf0e10cSrcweir }
75cdf0e10cSrcweir
76cdf0e10cSrcweir // -----------------------------------------------------------------------------
77cdf0e10cSrcweir
~X11SalBitmap()78cdf0e10cSrcweir X11SalBitmap::~X11SalBitmap()
79cdf0e10cSrcweir {
80cdf0e10cSrcweir Destroy();
81cdf0e10cSrcweir }
82cdf0e10cSrcweir
83cdf0e10cSrcweir // -----------------------------------------------------------------------------
84cdf0e10cSrcweir
ImplCreateCache()85cdf0e10cSrcweir void X11SalBitmap::ImplCreateCache()
86cdf0e10cSrcweir {
87cdf0e10cSrcweir if( !mnCacheInstCount++ )
88cdf0e10cSrcweir mpCache = new ImplSalBitmapCache;
89cdf0e10cSrcweir }
90cdf0e10cSrcweir
91cdf0e10cSrcweir // -----------------------------------------------------------------------------
92cdf0e10cSrcweir
ImplDestroyCache()93cdf0e10cSrcweir void X11SalBitmap::ImplDestroyCache()
94cdf0e10cSrcweir {
95cdf0e10cSrcweir DBG_ASSERT( mnCacheInstCount, "X11SalBitmap::ImplDestroyCache(): underflow" );
96cdf0e10cSrcweir
97cdf0e10cSrcweir if( mnCacheInstCount && !--mnCacheInstCount )
98cdf0e10cSrcweir delete mpCache, mpCache = NULL;
99cdf0e10cSrcweir }
100cdf0e10cSrcweir
101cdf0e10cSrcweir // -----------------------------------------------------------------------------
102cdf0e10cSrcweir
ImplRemovedFromCache()103cdf0e10cSrcweir void X11SalBitmap::ImplRemovedFromCache()
104cdf0e10cSrcweir {
105cdf0e10cSrcweir if( mpDDB )
106cdf0e10cSrcweir delete mpDDB, mpDDB = NULL;
107cdf0e10cSrcweir }
108cdf0e10cSrcweir
109cdf0e10cSrcweir // -----------------------------------------------------------------------------
110cdf0e10cSrcweir
ImplCreateDIB(const Size & rSize,sal_uInt16 nBitCount,const BitmapPalette & rPal)111cdf0e10cSrcweir BitmapBuffer* X11SalBitmap::ImplCreateDIB( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal )
112cdf0e10cSrcweir {
113cdf0e10cSrcweir DBG_ASSERT( nBitCount == 1 || nBitCount == 4 || nBitCount == 8 || nBitCount == 16 || nBitCount == 24, "Unsupported BitCount!" );
114cdf0e10cSrcweir
115cdf0e10cSrcweir BitmapBuffer* pDIB = NULL;
116cdf0e10cSrcweir
117cdf0e10cSrcweir if( rSize.Width() && rSize.Height() )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir try
120cdf0e10cSrcweir {
121cdf0e10cSrcweir pDIB = new BitmapBuffer;
122cdf0e10cSrcweir }
123cdf0e10cSrcweir catch( std::bad_alloc& )
124cdf0e10cSrcweir {
125cdf0e10cSrcweir pDIB = NULL;
126cdf0e10cSrcweir }
127cdf0e10cSrcweir
128cdf0e10cSrcweir if( pDIB )
129cdf0e10cSrcweir {
130cdf0e10cSrcweir const sal_uInt16 nColors = ( nBitCount <= 8 ) ? ( 1 << nBitCount ) : 0;
131cdf0e10cSrcweir
132cdf0e10cSrcweir pDIB->mnFormat = BMP_FORMAT_BOTTOM_UP;
133cdf0e10cSrcweir
134cdf0e10cSrcweir switch( nBitCount )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir case( 1 ): pDIB->mnFormat |= BMP_FORMAT_1BIT_MSB_PAL; break;
137cdf0e10cSrcweir case( 4 ): pDIB->mnFormat |= BMP_FORMAT_4BIT_MSN_PAL; break;
138cdf0e10cSrcweir case( 8 ): pDIB->mnFormat |= BMP_FORMAT_8BIT_PAL; break;
139cdf0e10cSrcweir #ifdef OSL_BIGENDIAN
140cdf0e10cSrcweir case(16 ):
141cdf0e10cSrcweir pDIB->mnFormat|= BMP_FORMAT_16BIT_TC_MSB_MASK;
142cdf0e10cSrcweir pDIB->maColorMask = ColorMask( 0xf800, 0x07e0, 0x001f );
143cdf0e10cSrcweir break;
144cdf0e10cSrcweir #else
145cdf0e10cSrcweir case(16 ):
146cdf0e10cSrcweir pDIB->mnFormat|= BMP_FORMAT_16BIT_TC_LSB_MASK;
147cdf0e10cSrcweir pDIB->maColorMask = ColorMask( 0xf800, 0x07e0, 0x001f );
148cdf0e10cSrcweir break;
149cdf0e10cSrcweir #endif
150cdf0e10cSrcweir default:
151cdf0e10cSrcweir nBitCount = 24;
152cdf0e10cSrcweir //fall through
153cdf0e10cSrcweir case 24:
154cdf0e10cSrcweir pDIB->mnFormat |= BMP_FORMAT_24BIT_TC_BGR;
155cdf0e10cSrcweir break;
156cdf0e10cSrcweir }
157cdf0e10cSrcweir
158cdf0e10cSrcweir pDIB->mnWidth = rSize.Width();
159cdf0e10cSrcweir pDIB->mnHeight = rSize.Height();
160cdf0e10cSrcweir pDIB->mnScanlineSize = AlignedWidth4Bytes( pDIB->mnWidth * nBitCount );
161cdf0e10cSrcweir pDIB->mnBitCount = nBitCount;
162cdf0e10cSrcweir
163cdf0e10cSrcweir if( nColors )
164cdf0e10cSrcweir {
165cdf0e10cSrcweir pDIB->maPalette = rPal;
166cdf0e10cSrcweir pDIB->maPalette.SetEntryCount( nColors );
167cdf0e10cSrcweir }
168cdf0e10cSrcweir
169cdf0e10cSrcweir try
170cdf0e10cSrcweir {
171cdf0e10cSrcweir pDIB->mpBits = new sal_uInt8[ pDIB->mnScanlineSize * pDIB->mnHeight ];
172cdf0e10cSrcweir }
173cdf0e10cSrcweir catch(std::bad_alloc&)
174cdf0e10cSrcweir {
175cdf0e10cSrcweir delete pDIB;
176cdf0e10cSrcweir pDIB = NULL;
177cdf0e10cSrcweir }
178cdf0e10cSrcweir }
179cdf0e10cSrcweir }
180cdf0e10cSrcweir else
181cdf0e10cSrcweir pDIB = NULL;
182cdf0e10cSrcweir
183cdf0e10cSrcweir return pDIB;
184cdf0e10cSrcweir }
185cdf0e10cSrcweir
186cdf0e10cSrcweir // -----------------------------------------------------------------------------
187cdf0e10cSrcweir
ImplCreateDIB(Drawable aDrawable,int nScreen,long nDrawableDepth,long nX,long nY,long nWidth,long nHeight)188cdf0e10cSrcweir BitmapBuffer* X11SalBitmap::ImplCreateDIB( Drawable aDrawable,
189cdf0e10cSrcweir int nScreen,
190cdf0e10cSrcweir long nDrawableDepth,
191cdf0e10cSrcweir long nX, long nY,
192cdf0e10cSrcweir long nWidth, long nHeight )
193cdf0e10cSrcweir {
194cdf0e10cSrcweir BitmapBuffer* pDIB = NULL;
195cdf0e10cSrcweir
196cdf0e10cSrcweir if( aDrawable && nWidth && nHeight && nDrawableDepth )
197cdf0e10cSrcweir {
198cdf0e10cSrcweir SalDisplay* pSalDisp = GetX11SalData()->GetDisplay();
199cdf0e10cSrcweir SalXLib* pXLib = pSalDisp->GetXLib();
200cdf0e10cSrcweir Display* pXDisp = pSalDisp->GetDisplay();
201cdf0e10cSrcweir
202cdf0e10cSrcweir // do not die on XError here
203cdf0e10cSrcweir // alternatively one could check the coordinates for being offscreen
204cdf0e10cSrcweir // but this call can actually work on servers with backing store
205cdf0e10cSrcweir // defaults even if the rectangle is offscreen
206cdf0e10cSrcweir // so better catch the XError
207cdf0e10cSrcweir pXLib->PushXErrorLevel( true );
208cdf0e10cSrcweir XImage* pImage = XGetImage( pXDisp, aDrawable, nX, nY, nWidth, nHeight, AllPlanes, ZPixmap );
209cdf0e10cSrcweir bool bWasError = pXLib->HasXErrorOccured() && pXLib->GetLastXErrorRequestCode() == X_GetImage;
210cdf0e10cSrcweir pXLib->PopXErrorLevel();
211cdf0e10cSrcweir
212cdf0e10cSrcweir if( ! bWasError && pImage && pImage->data )
213cdf0e10cSrcweir {
214cdf0e10cSrcweir const SalTwoRect aTwoRect = { 0, 0, nWidth, nHeight, 0, 0, nWidth, nHeight };
215cdf0e10cSrcweir BitmapBuffer aSrcBuf;
216cdf0e10cSrcweir sal_uLong nDstFormat = BMP_FORMAT_BOTTOM_UP;
217cdf0e10cSrcweir const BitmapPalette* pDstPal = NULL;
218cdf0e10cSrcweir
219cdf0e10cSrcweir aSrcBuf.mnFormat = BMP_FORMAT_TOP_DOWN;
220cdf0e10cSrcweir aSrcBuf.mnWidth = nWidth;
221cdf0e10cSrcweir aSrcBuf.mnHeight = nHeight;
222cdf0e10cSrcweir aSrcBuf.mnBitCount = pImage->bits_per_pixel;
223cdf0e10cSrcweir aSrcBuf.mnScanlineSize = pImage->bytes_per_line;
224cdf0e10cSrcweir aSrcBuf.mpBits = (sal_uInt8*) pImage->data;
225cdf0e10cSrcweir
226cdf0e10cSrcweir pImage->red_mask = pSalDisp->GetVisual( nScreen ).red_mask;
227cdf0e10cSrcweir pImage->green_mask = pSalDisp->GetVisual( nScreen ).green_mask;
228cdf0e10cSrcweir pImage->blue_mask = pSalDisp->GetVisual( nScreen ).blue_mask;
229cdf0e10cSrcweir
230cdf0e10cSrcweir switch( aSrcBuf.mnBitCount )
231cdf0e10cSrcweir {
232cdf0e10cSrcweir case( 1 ):
233cdf0e10cSrcweir {
234cdf0e10cSrcweir aSrcBuf.mnFormat |= ( LSBFirst == pImage->bitmap_bit_order ? BMP_FORMAT_1BIT_LSB_PAL : BMP_FORMAT_1BIT_MSB_PAL );
235cdf0e10cSrcweir nDstFormat |= BMP_FORMAT_1BIT_MSB_PAL;
236cdf0e10cSrcweir }
237cdf0e10cSrcweir break;
238cdf0e10cSrcweir
239cdf0e10cSrcweir case( 4 ):
240cdf0e10cSrcweir {
241cdf0e10cSrcweir aSrcBuf.mnFormat |= ( LSBFirst == pImage->bitmap_bit_order ? BMP_FORMAT_4BIT_LSN_PAL : BMP_FORMAT_4BIT_MSN_PAL );
242cdf0e10cSrcweir nDstFormat |= BMP_FORMAT_4BIT_MSN_PAL;
243cdf0e10cSrcweir }
244cdf0e10cSrcweir break;
245cdf0e10cSrcweir
246cdf0e10cSrcweir case( 8 ):
247cdf0e10cSrcweir {
248cdf0e10cSrcweir aSrcBuf.mnFormat |= BMP_FORMAT_8BIT_PAL;
249cdf0e10cSrcweir nDstFormat |= BMP_FORMAT_8BIT_PAL;
250cdf0e10cSrcweir }
251cdf0e10cSrcweir break;
252cdf0e10cSrcweir
253cdf0e10cSrcweir case( 16 ):
254cdf0e10cSrcweir {
255cdf0e10cSrcweir nDstFormat |= BMP_FORMAT_24BIT_TC_BGR;
256cdf0e10cSrcweir aSrcBuf.maColorMask = ColorMask( pImage->red_mask, pImage->green_mask, pImage->blue_mask );
257cdf0e10cSrcweir
258cdf0e10cSrcweir if( LSBFirst == pImage->byte_order )
259cdf0e10cSrcweir {
260cdf0e10cSrcweir aSrcBuf.mnFormat |= BMP_FORMAT_16BIT_TC_LSB_MASK;
261cdf0e10cSrcweir }
262cdf0e10cSrcweir else
263cdf0e10cSrcweir {
264cdf0e10cSrcweir aSrcBuf.mnFormat |= BMP_FORMAT_16BIT_TC_MSB_MASK;
265cdf0e10cSrcweir // aSrcBuf.maColorMask = ColorMask( pImage->red_mask ), SWAPSHORT( pImage->green_mask ), SWAPSHORT( pImage->blue_mask ) );
266cdf0e10cSrcweir }
267cdf0e10cSrcweir }
268cdf0e10cSrcweir break;
269cdf0e10cSrcweir
270cdf0e10cSrcweir case( 24 ):
271cdf0e10cSrcweir {
272cdf0e10cSrcweir if( ( LSBFirst == pImage->byte_order ) && ( pImage->red_mask == 0xFF ) )
273cdf0e10cSrcweir aSrcBuf.mnFormat |= BMP_FORMAT_24BIT_TC_RGB;
274cdf0e10cSrcweir else
275cdf0e10cSrcweir aSrcBuf.mnFormat |= BMP_FORMAT_24BIT_TC_BGR;
276cdf0e10cSrcweir
277cdf0e10cSrcweir nDstFormat |= BMP_FORMAT_24BIT_TC_BGR;
278cdf0e10cSrcweir }
279cdf0e10cSrcweir break;
280cdf0e10cSrcweir
281cdf0e10cSrcweir case( 32 ):
282cdf0e10cSrcweir {
283cdf0e10cSrcweir if( LSBFirst == pImage->byte_order )
284cdf0e10cSrcweir aSrcBuf.mnFormat |= ( pSalDisp->GetVisual(nScreen).red_mask == 0xFF ? BMP_FORMAT_32BIT_TC_RGBA : BMP_FORMAT_32BIT_TC_BGRA );
285cdf0e10cSrcweir else
286cdf0e10cSrcweir aSrcBuf.mnFormat |= ( pSalDisp->GetVisual(nScreen).red_mask == 0xFF ? BMP_FORMAT_32BIT_TC_ABGR : BMP_FORMAT_32BIT_TC_ARGB );
287cdf0e10cSrcweir
288cdf0e10cSrcweir nDstFormat |= BMP_FORMAT_24BIT_TC_BGR;
289cdf0e10cSrcweir }
290cdf0e10cSrcweir break;
291cdf0e10cSrcweir }
292cdf0e10cSrcweir
293cdf0e10cSrcweir BitmapPalette& rPal = aSrcBuf.maPalette;
294cdf0e10cSrcweir
295cdf0e10cSrcweir if( aSrcBuf.mnBitCount == 1 )
296cdf0e10cSrcweir {
297cdf0e10cSrcweir rPal.SetEntryCount( 2 );
298cdf0e10cSrcweir pDstPal = &rPal;
299cdf0e10cSrcweir
300cdf0e10cSrcweir rPal[ 0 ] = Color( COL_BLACK );
301cdf0e10cSrcweir rPal[ 1 ] = Color( COL_WHITE );
302cdf0e10cSrcweir }
303cdf0e10cSrcweir else if( aSrcBuf.mnBitCount <= 8 )
304cdf0e10cSrcweir {
305cdf0e10cSrcweir const SalColormap& rColMap = pSalDisp->GetColormap( nScreen );
306cdf0e10cSrcweir const sal_uInt16 nCols = Min( (sal_uLong)rColMap.GetUsed(), (sal_uLong)(1 << nDrawableDepth) );
307cdf0e10cSrcweir
308cdf0e10cSrcweir rPal.SetEntryCount( nCols );
309cdf0e10cSrcweir pDstPal = &rPal;
310cdf0e10cSrcweir
311cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nCols; i++ )
312cdf0e10cSrcweir {
313cdf0e10cSrcweir const SalColor nColor( rColMap.GetColor( i ) );
314cdf0e10cSrcweir BitmapColor& rBmpCol = rPal[ i ];
315cdf0e10cSrcweir
316cdf0e10cSrcweir rBmpCol.SetRed( SALCOLOR_RED( nColor ) );
317cdf0e10cSrcweir rBmpCol.SetGreen( SALCOLOR_GREEN( nColor ) );
318cdf0e10cSrcweir rBmpCol.SetBlue( SALCOLOR_BLUE( nColor ) );
319cdf0e10cSrcweir }
320cdf0e10cSrcweir }
321cdf0e10cSrcweir
322cdf0e10cSrcweir nDstFormat = aSrcBuf.mnFormat;
323cdf0e10cSrcweir pDIB = StretchAndConvert( aSrcBuf, aTwoRect, nDstFormat,
324cdf0e10cSrcweir const_cast<BitmapPalette*>(pDstPal), &aSrcBuf.maColorMask );
325cdf0e10cSrcweir XDestroyImage( pImage );
326cdf0e10cSrcweir }
327cdf0e10cSrcweir }
328cdf0e10cSrcweir
329cdf0e10cSrcweir return pDIB;
330cdf0e10cSrcweir }
331cdf0e10cSrcweir
332cdf0e10cSrcweir // -----------------------------------------------------------------------------
333cdf0e10cSrcweir
ImplCreateXImage(SalDisplay * pSalDisp,int nScreen,long nDepth,const SalTwoRect & rTwoRect) const334cdf0e10cSrcweir XImage* X11SalBitmap::ImplCreateXImage( SalDisplay *pSalDisp, int nScreen, long nDepth, const SalTwoRect& rTwoRect ) const
335cdf0e10cSrcweir {
336cdf0e10cSrcweir XImage* pImage = NULL;
337cdf0e10cSrcweir
338cdf0e10cSrcweir if( !mpDIB && mpDDB )
339cdf0e10cSrcweir {
340cdf0e10cSrcweir const_cast<X11SalBitmap*>(this)->mpDIB =
341cdf0e10cSrcweir ImplCreateDIB( mpDDB->ImplGetPixmap(),
342cdf0e10cSrcweir mpDDB->ImplGetScreen(),
343cdf0e10cSrcweir mpDDB->ImplGetDepth(),
344cdf0e10cSrcweir 0, 0,
345cdf0e10cSrcweir mpDDB->ImplGetWidth(),
346cdf0e10cSrcweir mpDDB->ImplGetHeight() );
347cdf0e10cSrcweir }
348cdf0e10cSrcweir
349cdf0e10cSrcweir if( mpDIB && mpDIB->mnWidth && mpDIB->mnHeight )
350cdf0e10cSrcweir {
351cdf0e10cSrcweir Display* pXDisp = pSalDisp->GetDisplay();
352cdf0e10cSrcweir long nWidth = rTwoRect.mnDestWidth;
353cdf0e10cSrcweir long nHeight = rTwoRect.mnDestHeight;
354cdf0e10cSrcweir
355cdf0e10cSrcweir if( 1 == GetBitCount() )
356cdf0e10cSrcweir nDepth = 1;
357cdf0e10cSrcweir
358cdf0e10cSrcweir pImage = XCreateImage( pXDisp, pSalDisp->GetVisual( nScreen ).GetVisual(),
359cdf0e10cSrcweir nDepth, ( 1 == nDepth ) ? XYBitmap :ZPixmap, 0, NULL,
360cdf0e10cSrcweir nWidth, nHeight, 32, 0 );
361cdf0e10cSrcweir
362cdf0e10cSrcweir if( pImage )
363cdf0e10cSrcweir {
364cdf0e10cSrcweir BitmapBuffer* pDstBuf;
365cdf0e10cSrcweir sal_uLong nDstFormat = BMP_FORMAT_TOP_DOWN;
366cdf0e10cSrcweir BitmapPalette* pPal = NULL;
367cdf0e10cSrcweir ColorMask* pMask = NULL;
368cdf0e10cSrcweir
369cdf0e10cSrcweir switch( pImage->bits_per_pixel )
370cdf0e10cSrcweir {
371cdf0e10cSrcweir case( 1 ):
372cdf0e10cSrcweir nDstFormat |= ( LSBFirst == pImage->bitmap_bit_order ? BMP_FORMAT_1BIT_LSB_PAL : BMP_FORMAT_1BIT_MSB_PAL );
373cdf0e10cSrcweir break;
374cdf0e10cSrcweir
375cdf0e10cSrcweir case( 4 ):
376cdf0e10cSrcweir nDstFormat |= ( LSBFirst == pImage->bitmap_bit_order ? BMP_FORMAT_4BIT_LSN_PAL : BMP_FORMAT_4BIT_MSN_PAL );
377cdf0e10cSrcweir break;
378cdf0e10cSrcweir
379cdf0e10cSrcweir case( 8 ):
380cdf0e10cSrcweir nDstFormat |= BMP_FORMAT_8BIT_PAL;
381cdf0e10cSrcweir break;
382cdf0e10cSrcweir
383cdf0e10cSrcweir case( 16 ):
384cdf0e10cSrcweir {
385cdf0e10cSrcweir #ifdef OSL_BIGENDIAN
386cdf0e10cSrcweir
387cdf0e10cSrcweir if( MSBFirst == pImage->byte_order )
388cdf0e10cSrcweir nDstFormat |= BMP_FORMAT_16BIT_TC_MSB_MASK;
389cdf0e10cSrcweir else
390cdf0e10cSrcweir nDstFormat |= BMP_FORMAT_16BIT_TC_LSB_MASK;
391cdf0e10cSrcweir
392cdf0e10cSrcweir #else /* OSL_LITENDIAN */
393cdf0e10cSrcweir
394cdf0e10cSrcweir nDstFormat |= BMP_FORMAT_16BIT_TC_LSB_MASK;
395cdf0e10cSrcweir if( MSBFirst == pImage->byte_order )
396cdf0e10cSrcweir pImage->byte_order = LSBFirst;
397cdf0e10cSrcweir
398cdf0e10cSrcweir #endif
399cdf0e10cSrcweir
400cdf0e10cSrcweir pMask = new ColorMask( pImage->red_mask, pImage->green_mask, pImage->blue_mask );
401cdf0e10cSrcweir }
402cdf0e10cSrcweir break;
403cdf0e10cSrcweir
404cdf0e10cSrcweir case( 24 ):
405cdf0e10cSrcweir {
406cdf0e10cSrcweir if( ( LSBFirst == pImage->byte_order ) && ( pImage->red_mask == 0xFF ) )
407cdf0e10cSrcweir nDstFormat |= BMP_FORMAT_24BIT_TC_RGB;
408cdf0e10cSrcweir else
409cdf0e10cSrcweir nDstFormat |= BMP_FORMAT_24BIT_TC_BGR;
410cdf0e10cSrcweir }
411cdf0e10cSrcweir break;
412cdf0e10cSrcweir
413cdf0e10cSrcweir case( 32 ):
414cdf0e10cSrcweir {
415cdf0e10cSrcweir if( LSBFirst == pImage->byte_order )
416cdf0e10cSrcweir nDstFormat |= ( pImage->red_mask == 0xFF ? BMP_FORMAT_32BIT_TC_RGBA : BMP_FORMAT_32BIT_TC_BGRA );
417cdf0e10cSrcweir else
418cdf0e10cSrcweir nDstFormat |= ( pImage->red_mask == 0xFF ? BMP_FORMAT_32BIT_TC_ABGR : BMP_FORMAT_32BIT_TC_ARGB );
419cdf0e10cSrcweir }
420cdf0e10cSrcweir break;
421cdf0e10cSrcweir }
422cdf0e10cSrcweir
423cdf0e10cSrcweir if( pImage->depth == 1 )
424cdf0e10cSrcweir {
425cdf0e10cSrcweir pPal = new BitmapPalette( 2 );
426cdf0e10cSrcweir (*pPal)[ 0 ] = Color( COL_BLACK );
427cdf0e10cSrcweir (*pPal)[ 1 ] = Color( COL_WHITE );
428cdf0e10cSrcweir }
429cdf0e10cSrcweir else if( pImage->depth <= 8 )
430cdf0e10cSrcweir {
431cdf0e10cSrcweir const SalColormap& rColMap = pSalDisp->GetColormap( nScreen );
432cdf0e10cSrcweir const sal_uInt16 nCols = Min( (sal_uLong)rColMap.GetUsed(), (sal_uLong)(1 << pImage->depth) );
433cdf0e10cSrcweir
434cdf0e10cSrcweir pPal = new BitmapPalette( nCols );
435cdf0e10cSrcweir
436cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nCols; i++ )
437cdf0e10cSrcweir {
438cdf0e10cSrcweir const SalColor nColor( rColMap.GetColor( i ) );
439cdf0e10cSrcweir BitmapColor& rBmpCol = (*pPal)[ i ];
440cdf0e10cSrcweir
441cdf0e10cSrcweir rBmpCol.SetRed( SALCOLOR_RED( nColor ) );
442cdf0e10cSrcweir rBmpCol.SetGreen( SALCOLOR_GREEN( nColor ) );
443cdf0e10cSrcweir rBmpCol.SetBlue( SALCOLOR_BLUE( nColor ) );
444cdf0e10cSrcweir }
445cdf0e10cSrcweir }
446cdf0e10cSrcweir
447cdf0e10cSrcweir pDstBuf = StretchAndConvert( *mpDIB, rTwoRect, nDstFormat, pPal, pMask );
448cdf0e10cSrcweir delete pPal;
449cdf0e10cSrcweir delete pMask;
450cdf0e10cSrcweir
451cdf0e10cSrcweir if( pDstBuf && pDstBuf->mpBits )
452cdf0e10cSrcweir {
453cdf0e10cSrcweir // set data in buffer as data member in pImage
454cdf0e10cSrcweir pImage->data = (char*) pDstBuf->mpBits;
455cdf0e10cSrcweir
456cdf0e10cSrcweir // destroy buffer; don't destroy allocated data in buffer
457cdf0e10cSrcweir delete pDstBuf;
458cdf0e10cSrcweir }
459cdf0e10cSrcweir else
460cdf0e10cSrcweir {
461cdf0e10cSrcweir XDestroyImage( pImage );
462cdf0e10cSrcweir pImage = NULL;
463cdf0e10cSrcweir }
464cdf0e10cSrcweir }
465cdf0e10cSrcweir }
466cdf0e10cSrcweir
467cdf0e10cSrcweir return pImage;
468cdf0e10cSrcweir }
469cdf0e10cSrcweir
470cdf0e10cSrcweir // -----------------------------------------------------------------------------
ImplCreateFromDrawable(Drawable aDrawable,int nScreen,long nDrawableDepth,long nX,long nY,long nWidth,long nHeight)471cdf0e10cSrcweir bool X11SalBitmap::ImplCreateFromDrawable( Drawable aDrawable,
472cdf0e10cSrcweir int nScreen, long nDrawableDepth,
473cdf0e10cSrcweir long nX, long nY, long nWidth, long nHeight )
474cdf0e10cSrcweir {
475cdf0e10cSrcweir Destroy();
476cdf0e10cSrcweir
477cdf0e10cSrcweir if( aDrawable && nWidth && nHeight && nDrawableDepth )
478cdf0e10cSrcweir mpDDB = new ImplSalDDB( aDrawable, nScreen, nDrawableDepth, nX, nY, nWidth, nHeight );
479cdf0e10cSrcweir
480cdf0e10cSrcweir return( mpDDB != NULL );
481cdf0e10cSrcweir }
482cdf0e10cSrcweir // -----------------------------------------------------------------------------
483cdf0e10cSrcweir
484cdf0e10cSrcweir bool
SnapShot(Display * pDisplay,XLIB_Window hWindow)485cdf0e10cSrcweir X11SalBitmap::SnapShot (Display* pDisplay, XLIB_Window hWindow)
486cdf0e10cSrcweir {
487cdf0e10cSrcweir if (hWindow != None)
488cdf0e10cSrcweir {
489cdf0e10cSrcweir XWindowAttributes aAttribute;
490cdf0e10cSrcweir XGetWindowAttributes (pDisplay, hWindow, &aAttribute);
491cdf0e10cSrcweir if (aAttribute.map_state == IsViewable)
492cdf0e10cSrcweir {
493cdf0e10cSrcweir // get coordinates relative to root window
494cdf0e10cSrcweir XLIB_Window hPetitFleur;
495cdf0e10cSrcweir int nRootX, nRootY;
496cdf0e10cSrcweir
497cdf0e10cSrcweir if (XTranslateCoordinates (pDisplay, hWindow, aAttribute.root,
498cdf0e10cSrcweir 0, 0, &nRootX, &nRootY, &hPetitFleur))
499cdf0e10cSrcweir {
500cdf0e10cSrcweir XWindowAttributes aRootAttribute;
501cdf0e10cSrcweir XGetWindowAttributes (pDisplay, aAttribute.root, &aRootAttribute);
502cdf0e10cSrcweir
503cdf0e10cSrcweir int width = aAttribute.width;
504cdf0e10cSrcweir int height = aAttribute.height;
505cdf0e10cSrcweir int x = nRootX;
506cdf0e10cSrcweir int y = nRootY;
507cdf0e10cSrcweir
508cdf0e10cSrcweir // horizontal range check
509cdf0e10cSrcweir if (x < 0)
510cdf0e10cSrcweir {
511cdf0e10cSrcweir width = width + x;
512cdf0e10cSrcweir x = 0;
513cdf0e10cSrcweir }
514cdf0e10cSrcweir else
515cdf0e10cSrcweir if (x > aRootAttribute.width)
516cdf0e10cSrcweir {
517cdf0e10cSrcweir width = 0;
518cdf0e10cSrcweir x = aRootAttribute.width;
519cdf0e10cSrcweir }
520cdf0e10cSrcweir else
521cdf0e10cSrcweir if (x + width > aRootAttribute.width)
522cdf0e10cSrcweir {
523cdf0e10cSrcweir width = aRootAttribute.width - x;
524cdf0e10cSrcweir }
525cdf0e10cSrcweir
526cdf0e10cSrcweir // vertical range check
527cdf0e10cSrcweir if (y < 0)
528cdf0e10cSrcweir {
529cdf0e10cSrcweir height = height + y;
530cdf0e10cSrcweir y = 0;
531cdf0e10cSrcweir }
532cdf0e10cSrcweir else
533cdf0e10cSrcweir if (y > aRootAttribute.height)
534cdf0e10cSrcweir {
535cdf0e10cSrcweir height = 0;
536cdf0e10cSrcweir y = aRootAttribute.height;
537cdf0e10cSrcweir }
538cdf0e10cSrcweir else
539cdf0e10cSrcweir if (y + height > aRootAttribute.height)
540cdf0e10cSrcweir {
541cdf0e10cSrcweir height = aRootAttribute.height - y;
542cdf0e10cSrcweir }
543cdf0e10cSrcweir
544cdf0e10cSrcweir if ((width > 0) && (height > 0))
545cdf0e10cSrcweir {
546cdf0e10cSrcweir XImage* pImage = XGetImage( pDisplay, aAttribute.root,
547cdf0e10cSrcweir x, y, width, height, AllPlanes, ZPixmap );
548cdf0e10cSrcweir bool bSnapShot = ImplCreateFromXImage( pDisplay,
549cdf0e10cSrcweir aAttribute.root,
550cdf0e10cSrcweir XScreenNumberOfScreen( aAttribute.screen ),
551cdf0e10cSrcweir pImage );
552cdf0e10cSrcweir XDestroyImage (pImage);
553cdf0e10cSrcweir
554cdf0e10cSrcweir return bSnapShot;
555cdf0e10cSrcweir }
556cdf0e10cSrcweir }
557cdf0e10cSrcweir }
558cdf0e10cSrcweir }
559cdf0e10cSrcweir
560cdf0e10cSrcweir return False;
561cdf0e10cSrcweir }
562cdf0e10cSrcweir
563cdf0e10cSrcweir bool
ImplCreateFromXImage(Display * pDisplay,XLIB_Window hWindow,int nScreen,XImage * pImage)564cdf0e10cSrcweir X11SalBitmap::ImplCreateFromXImage (Display* pDisplay, XLIB_Window hWindow, int nScreen, XImage* pImage)
565cdf0e10cSrcweir {
566cdf0e10cSrcweir Destroy();
567cdf0e10cSrcweir
568cdf0e10cSrcweir if (pImage != NULL && pImage->width != 0 && pImage->height != 0 && pImage->depth != 0)
569cdf0e10cSrcweir {
570cdf0e10cSrcweir mpDDB = new ImplSalDDB (pDisplay, hWindow, nScreen, pImage);
571cdf0e10cSrcweir return True;
572cdf0e10cSrcweir }
573cdf0e10cSrcweir return False;
574cdf0e10cSrcweir }
575cdf0e10cSrcweir
ImplGetDDB(Drawable aDrawable,int nScreen,long nDrawableDepth,const SalTwoRect & rTwoRect) const576cdf0e10cSrcweir ImplSalDDB* X11SalBitmap::ImplGetDDB( Drawable aDrawable,
577cdf0e10cSrcweir int nScreen,
578cdf0e10cSrcweir long nDrawableDepth,
579cdf0e10cSrcweir const SalTwoRect& rTwoRect ) const
580cdf0e10cSrcweir {
581cdf0e10cSrcweir if( !mpDDB || !mpDDB->ImplMatches( nScreen, nDrawableDepth, rTwoRect ) )
582cdf0e10cSrcweir {
583cdf0e10cSrcweir if( mpDDB )
584cdf0e10cSrcweir {
585cdf0e10cSrcweir // do we already have a DIB? if not, create aDIB from current DDB first
586cdf0e10cSrcweir if( !mpDIB )
587cdf0e10cSrcweir {
588cdf0e10cSrcweir const_cast<X11SalBitmap*>(this)->mpDIB = ImplCreateDIB( mpDDB->ImplGetPixmap(),
589cdf0e10cSrcweir mpDDB->ImplGetScreen(),
590cdf0e10cSrcweir mpDDB->ImplGetDepth(),
591cdf0e10cSrcweir 0, 0,
592cdf0e10cSrcweir mpDDB->ImplGetWidth(),
593cdf0e10cSrcweir mpDDB->ImplGetHeight() );
594cdf0e10cSrcweir }
595cdf0e10cSrcweir
596cdf0e10cSrcweir delete mpDDB, const_cast<X11SalBitmap*>(this)->mpDDB = NULL;
597cdf0e10cSrcweir }
598cdf0e10cSrcweir
599cdf0e10cSrcweir if( mpCache )
600cdf0e10cSrcweir mpCache->ImplRemove( const_cast<X11SalBitmap*>(this) );
601cdf0e10cSrcweir
602cdf0e10cSrcweir SalTwoRect aTwoRect( rTwoRect );
603cdf0e10cSrcweir if( aTwoRect.mnSrcX < 0 )
604cdf0e10cSrcweir {
605cdf0e10cSrcweir aTwoRect.mnSrcWidth += aTwoRect.mnSrcX;
606cdf0e10cSrcweir aTwoRect.mnSrcX = 0;
607cdf0e10cSrcweir }
608cdf0e10cSrcweir if( aTwoRect.mnSrcY < 0 )
609cdf0e10cSrcweir {
610cdf0e10cSrcweir aTwoRect.mnSrcHeight += aTwoRect.mnSrcY;
611cdf0e10cSrcweir aTwoRect.mnSrcY = 0;
612cdf0e10cSrcweir }
613cdf0e10cSrcweir
614cdf0e10cSrcweir // create new DDB from DIB
615cdf0e10cSrcweir const Size aSize( GetSize() );
616cdf0e10cSrcweir if( aTwoRect.mnSrcWidth == aTwoRect.mnDestWidth &&
617cdf0e10cSrcweir aTwoRect.mnSrcHeight == aTwoRect.mnDestHeight )
618cdf0e10cSrcweir {
619cdf0e10cSrcweir aTwoRect.mnSrcX = aTwoRect.mnSrcY = aTwoRect.mnDestX = aTwoRect.mnDestY = 0;
620cdf0e10cSrcweir aTwoRect.mnSrcWidth = aTwoRect.mnDestWidth = aSize.Width();
621cdf0e10cSrcweir aTwoRect.mnSrcHeight = aTwoRect.mnDestHeight = aSize.Height();
622cdf0e10cSrcweir }
623cdf0e10cSrcweir else if( aTwoRect.mnSrcWidth+aTwoRect.mnSrcX > aSize.Width() ||
624cdf0e10cSrcweir aTwoRect.mnSrcHeight+aTwoRect.mnSrcY > aSize.Height() )
625cdf0e10cSrcweir {
626cdf0e10cSrcweir // #i47823# this should not happen at all, but does nonetheless
627cdf0e10cSrcweir // because BitmapEx allows for mask bitmaps of different size
628cdf0e10cSrcweir // than image bitmap (broken)
629cdf0e10cSrcweir if( aTwoRect.mnSrcX >= aSize.Width() ||
630cdf0e10cSrcweir aTwoRect.mnSrcY >= aSize.Height() )
631cdf0e10cSrcweir return NULL; // this would be a really mad case
632cdf0e10cSrcweir
633cdf0e10cSrcweir if( aTwoRect.mnSrcWidth+aTwoRect.mnSrcX > aSize.Width() )
634cdf0e10cSrcweir {
635cdf0e10cSrcweir aTwoRect.mnSrcWidth = aSize.Width()-aTwoRect.mnSrcX;
636cdf0e10cSrcweir if( aTwoRect.mnSrcWidth < 1 )
637cdf0e10cSrcweir {
638cdf0e10cSrcweir aTwoRect.mnSrcX = 0;
639cdf0e10cSrcweir aTwoRect.mnSrcWidth = aSize.Width();
640cdf0e10cSrcweir }
641cdf0e10cSrcweir }
642cdf0e10cSrcweir if( aTwoRect.mnSrcHeight+aTwoRect.mnSrcY > aSize.Height() )
643cdf0e10cSrcweir {
644cdf0e10cSrcweir aTwoRect.mnSrcHeight = aSize.Height() - aTwoRect.mnSrcY;
645cdf0e10cSrcweir if( aTwoRect.mnSrcHeight < 1 )
646cdf0e10cSrcweir {
647cdf0e10cSrcweir aTwoRect.mnSrcY = 0;
648cdf0e10cSrcweir aTwoRect.mnSrcHeight = aSize.Height();
649cdf0e10cSrcweir }
650cdf0e10cSrcweir }
651cdf0e10cSrcweir }
652cdf0e10cSrcweir
653cdf0e10cSrcweir XImage* pImage = ImplCreateXImage( GetX11SalData()->GetDisplay(), nScreen,
654cdf0e10cSrcweir nDrawableDepth, aTwoRect );
655cdf0e10cSrcweir
656cdf0e10cSrcweir if( pImage )
657cdf0e10cSrcweir {
658cdf0e10cSrcweir const_cast<X11SalBitmap*>(this)->mpDDB = new ImplSalDDB( pImage, aDrawable, nScreen, aTwoRect );
659cdf0e10cSrcweir delete[] pImage->data, pImage->data = NULL;
660cdf0e10cSrcweir XDestroyImage( pImage );
661cdf0e10cSrcweir
662cdf0e10cSrcweir if( mpCache )
663cdf0e10cSrcweir mpCache->ImplAdd( const_cast<X11SalBitmap*>(this), mpDDB->ImplGetMemSize() );
664cdf0e10cSrcweir }
665cdf0e10cSrcweir }
666cdf0e10cSrcweir
667cdf0e10cSrcweir return mpDDB;
668cdf0e10cSrcweir }
669cdf0e10cSrcweir
670cdf0e10cSrcweir // -----------------------------------------------------------------------------
671cdf0e10cSrcweir
ImplDraw(Drawable aDrawable,int nScreen,long nDrawableDepth,const SalTwoRect & rTwoRect,const GC & rGC) const672cdf0e10cSrcweir void X11SalBitmap::ImplDraw( Drawable aDrawable,
673cdf0e10cSrcweir int nScreen,
674cdf0e10cSrcweir long nDrawableDepth,
675cdf0e10cSrcweir const SalTwoRect& rTwoRect,
676cdf0e10cSrcweir const GC& rGC ) const
677cdf0e10cSrcweir {
678cdf0e10cSrcweir ImplGetDDB( aDrawable, nScreen, nDrawableDepth, rTwoRect );
679cdf0e10cSrcweir if( mpDDB )
680cdf0e10cSrcweir mpDDB->ImplDraw( aDrawable, nDrawableDepth, rTwoRect, rGC );
681cdf0e10cSrcweir }
682cdf0e10cSrcweir
683cdf0e10cSrcweir // -----------------------------------------------------------------------------
684cdf0e10cSrcweir
Create(const Size & rSize,sal_uInt16 nBitCount,const BitmapPalette & rPal)685cdf0e10cSrcweir bool X11SalBitmap::Create( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal )
686cdf0e10cSrcweir {
687cdf0e10cSrcweir Destroy();
688cdf0e10cSrcweir mpDIB = ImplCreateDIB( rSize, nBitCount, rPal );
689cdf0e10cSrcweir
690cdf0e10cSrcweir return( mpDIB != NULL );
691cdf0e10cSrcweir }
692cdf0e10cSrcweir
693cdf0e10cSrcweir // -----------------------------------------------------------------------------
694cdf0e10cSrcweir
Create(const SalBitmap & rSSalBmp)695cdf0e10cSrcweir bool X11SalBitmap::Create( const SalBitmap& rSSalBmp )
696cdf0e10cSrcweir {
697cdf0e10cSrcweir Destroy();
698cdf0e10cSrcweir
699cdf0e10cSrcweir const X11SalBitmap& rSalBmp = static_cast<const X11SalBitmap&>( rSSalBmp );
700cdf0e10cSrcweir
701cdf0e10cSrcweir if( rSalBmp.mpDIB )
702cdf0e10cSrcweir {
703cdf0e10cSrcweir // TODO: reference counting...
704cdf0e10cSrcweir mpDIB = new BitmapBuffer( *rSalBmp.mpDIB );
705cdf0e10cSrcweir // TODO: get rid of this when BitmapBuffer gets copy constructor
706cdf0e10cSrcweir try
707cdf0e10cSrcweir {
708cdf0e10cSrcweir mpDIB->mpBits = new sal_uInt8[ mpDIB->mnScanlineSize * mpDIB->mnHeight ];
709cdf0e10cSrcweir }
710cdf0e10cSrcweir catch( std::bad_alloc& )
711cdf0e10cSrcweir {
712cdf0e10cSrcweir delete mpDIB;
713cdf0e10cSrcweir mpDIB = NULL;
714cdf0e10cSrcweir }
715cdf0e10cSrcweir
716cdf0e10cSrcweir if( mpDIB )
717cdf0e10cSrcweir memcpy( mpDIB->mpBits, rSalBmp.mpDIB->mpBits, mpDIB->mnScanlineSize * mpDIB->mnHeight );
718cdf0e10cSrcweir }
719cdf0e10cSrcweir else if( rSalBmp.mpDDB )
720cdf0e10cSrcweir ImplCreateFromDrawable( rSalBmp.mpDDB->ImplGetPixmap(),
721cdf0e10cSrcweir rSalBmp.mpDDB->ImplGetScreen(),
722cdf0e10cSrcweir rSalBmp.mpDDB->ImplGetDepth(),
723cdf0e10cSrcweir 0, 0, rSalBmp.mpDDB->ImplGetWidth(), rSalBmp.mpDDB->ImplGetHeight() );
724cdf0e10cSrcweir
725cdf0e10cSrcweir return( ( !rSalBmp.mpDIB && !rSalBmp.mpDDB ) ||
726cdf0e10cSrcweir ( rSalBmp.mpDIB && ( mpDIB != NULL ) ) ||
727cdf0e10cSrcweir ( rSalBmp.mpDDB && ( mpDDB != NULL ) ) );
728cdf0e10cSrcweir }
729cdf0e10cSrcweir
730cdf0e10cSrcweir // -----------------------------------------------------------------------------
731cdf0e10cSrcweir
Create(const SalBitmap &,SalGraphics *)732cdf0e10cSrcweir bool X11SalBitmap::Create( const SalBitmap&, SalGraphics* )
733cdf0e10cSrcweir {
734cdf0e10cSrcweir return sal_False;
735cdf0e10cSrcweir }
736cdf0e10cSrcweir
737cdf0e10cSrcweir // -----------------------------------------------------------------------------
738cdf0e10cSrcweir
Create(const SalBitmap &,sal_uInt16)739cdf0e10cSrcweir bool X11SalBitmap::Create( const SalBitmap&, sal_uInt16 )
740cdf0e10cSrcweir {
741cdf0e10cSrcweir return sal_False;
742cdf0e10cSrcweir }
743cdf0e10cSrcweir
744cdf0e10cSrcweir // -----------------------------------------------------------------------------
745cdf0e10cSrcweir
Destroy()746cdf0e10cSrcweir void X11SalBitmap::Destroy()
747cdf0e10cSrcweir {
748cdf0e10cSrcweir if( mpDIB )
749cdf0e10cSrcweir {
750cdf0e10cSrcweir delete[] mpDIB->mpBits;
751cdf0e10cSrcweir delete mpDIB, mpDIB = NULL;
752cdf0e10cSrcweir }
753cdf0e10cSrcweir
754cdf0e10cSrcweir if( mpDDB )
755cdf0e10cSrcweir delete mpDDB, mpDDB = NULL;
756cdf0e10cSrcweir
757cdf0e10cSrcweir if( mpCache )
758cdf0e10cSrcweir mpCache->ImplRemove( this );
759cdf0e10cSrcweir }
760cdf0e10cSrcweir
761cdf0e10cSrcweir // -----------------------------------------------------------------------------
762cdf0e10cSrcweir
GetSize() const763cdf0e10cSrcweir Size X11SalBitmap::GetSize() const
764cdf0e10cSrcweir {
765cdf0e10cSrcweir Size aSize;
766cdf0e10cSrcweir
767cdf0e10cSrcweir if( mpDIB )
768cdf0e10cSrcweir aSize.Width() = mpDIB->mnWidth, aSize.Height() = mpDIB->mnHeight;
769cdf0e10cSrcweir else if( mpDDB )
770cdf0e10cSrcweir aSize.Width() = mpDDB->ImplGetWidth(), aSize.Height() = mpDDB->ImplGetHeight();
771cdf0e10cSrcweir
772cdf0e10cSrcweir return aSize;
773cdf0e10cSrcweir }
774cdf0e10cSrcweir
775cdf0e10cSrcweir // -----------------------------------------------------------------------------
776cdf0e10cSrcweir
GetBitCount() const777cdf0e10cSrcweir sal_uInt16 X11SalBitmap::GetBitCount() const
778cdf0e10cSrcweir {
779cdf0e10cSrcweir sal_uInt16 nBitCount;
780cdf0e10cSrcweir
781cdf0e10cSrcweir if( mpDIB )
782cdf0e10cSrcweir nBitCount = mpDIB->mnBitCount;
783cdf0e10cSrcweir else if( mpDDB )
784cdf0e10cSrcweir nBitCount = mpDDB->ImplGetDepth();
785cdf0e10cSrcweir else
786cdf0e10cSrcweir nBitCount = 0;
787cdf0e10cSrcweir
788cdf0e10cSrcweir return nBitCount;
789cdf0e10cSrcweir }
790cdf0e10cSrcweir
791cdf0e10cSrcweir // -----------------------------------------------------------------------------
792cdf0e10cSrcweir
AcquireBuffer(bool)793cdf0e10cSrcweir BitmapBuffer* X11SalBitmap::AcquireBuffer( bool )
794cdf0e10cSrcweir {
795cdf0e10cSrcweir if( !mpDIB && mpDDB )
796cdf0e10cSrcweir {
797cdf0e10cSrcweir mpDIB = ImplCreateDIB( mpDDB->ImplGetPixmap(),
798cdf0e10cSrcweir mpDDB->ImplGetScreen(),
799cdf0e10cSrcweir mpDDB->ImplGetDepth(),
800cdf0e10cSrcweir 0, 0, mpDDB->ImplGetWidth(), mpDDB->ImplGetHeight() );
801cdf0e10cSrcweir }
802cdf0e10cSrcweir
803cdf0e10cSrcweir return mpDIB;
804cdf0e10cSrcweir }
805cdf0e10cSrcweir
806cdf0e10cSrcweir // -----------------------------------------------------------------------------
807cdf0e10cSrcweir
ReleaseBuffer(BitmapBuffer *,bool bReadOnly)808cdf0e10cSrcweir void X11SalBitmap::ReleaseBuffer( BitmapBuffer*, bool bReadOnly )
809cdf0e10cSrcweir {
810cdf0e10cSrcweir if( !bReadOnly )
811cdf0e10cSrcweir {
812cdf0e10cSrcweir if( mpDDB )
813cdf0e10cSrcweir delete mpDDB, mpDDB = NULL;
814cdf0e10cSrcweir
815cdf0e10cSrcweir if( mpCache )
816cdf0e10cSrcweir mpCache->ImplRemove( this );
817cdf0e10cSrcweir }
818cdf0e10cSrcweir }
819cdf0e10cSrcweir
820cdf0e10cSrcweir // -----------------------------------------------------------------------------
821cdf0e10cSrcweir
GetSystemData(BitmapSystemData & rData)822cdf0e10cSrcweir bool X11SalBitmap::GetSystemData( BitmapSystemData& rData )
823cdf0e10cSrcweir {
824cdf0e10cSrcweir if( mpDDB )
825cdf0e10cSrcweir {
826cdf0e10cSrcweir // Rename/retype pDummy to your likings (though X11 Pixmap is
827cdf0e10cSrcweir // prolly not a good idea, since it's accessed from
828cdf0e10cSrcweir // non-platform aware code in vcl/bitmap.hxx)
829cdf0e10cSrcweir rData.aPixmap = (void*)mpDDB->ImplGetPixmap();
830cdf0e10cSrcweir rData.mnWidth = mpDDB->ImplGetWidth ();
831cdf0e10cSrcweir rData.mnHeight = mpDDB->ImplGetHeight ();
832cdf0e10cSrcweir return true;
833cdf0e10cSrcweir }
834cdf0e10cSrcweir
835cdf0e10cSrcweir return false;
836cdf0e10cSrcweir }
837cdf0e10cSrcweir
838cdf0e10cSrcweir // --------------
839cdf0e10cSrcweir // - ImplSalDDB -
840cdf0e10cSrcweir // --------------
841cdf0e10cSrcweir
ImplSalDDB(XImage * pImage,Drawable aDrawable,int nScreen,const SalTwoRect & rTwoRect)842cdf0e10cSrcweir ImplSalDDB::ImplSalDDB( XImage* pImage, Drawable aDrawable, int nScreen, const SalTwoRect& rTwoRect ) :
843cdf0e10cSrcweir maPixmap ( 0 ),
844cdf0e10cSrcweir maTwoRect ( rTwoRect ),
845cdf0e10cSrcweir mnDepth ( pImage->depth ),
846cdf0e10cSrcweir mnScreen ( nScreen )
847cdf0e10cSrcweir {
848cdf0e10cSrcweir SalDisplay* pSalDisp = GetX11SalData()->GetDisplay();
849cdf0e10cSrcweir Display* pXDisp = pSalDisp->GetDisplay();
850cdf0e10cSrcweir
851cdf0e10cSrcweir if( (maPixmap = XCreatePixmap( pXDisp, aDrawable, ImplGetWidth(), ImplGetHeight(), ImplGetDepth() )) )
852cdf0e10cSrcweir {
853cdf0e10cSrcweir XGCValues aValues;
854cdf0e10cSrcweir GC aGC;
855cdf0e10cSrcweir int nValues = GCFunction;
856cdf0e10cSrcweir
857cdf0e10cSrcweir aValues.function = GXcopy;
858cdf0e10cSrcweir
859cdf0e10cSrcweir if( 1 == mnDepth )
860cdf0e10cSrcweir {
861cdf0e10cSrcweir nValues |= ( GCForeground | GCBackground );
862cdf0e10cSrcweir aValues.foreground = 1, aValues.background = 0;
863cdf0e10cSrcweir }
864cdf0e10cSrcweir
865cdf0e10cSrcweir aGC = XCreateGC( pXDisp, maPixmap, nValues, &aValues );
866cdf0e10cSrcweir XPutImage( pXDisp, maPixmap, aGC, pImage, 0, 0, 0, 0, maTwoRect.mnDestWidth, maTwoRect.mnDestHeight );
867cdf0e10cSrcweir XFreeGC( pXDisp, aGC );
868cdf0e10cSrcweir }
869cdf0e10cSrcweir }
870cdf0e10cSrcweir
871cdf0e10cSrcweir // -----------------------------------------------------------------------------------------
872cdf0e10cSrcweir // create from XImage
873cdf0e10cSrcweir
ImplSalDDB(Display * pDisplay,XLIB_Window hWindow,int nScreen,XImage * pImage)874cdf0e10cSrcweir ImplSalDDB::ImplSalDDB (Display* pDisplay, XLIB_Window hWindow, int nScreen, XImage* pImage) :
875cdf0e10cSrcweir mnScreen( nScreen )
876cdf0e10cSrcweir {
877cdf0e10cSrcweir maPixmap = XCreatePixmap (pDisplay, hWindow, pImage->width, pImage->height, pImage->depth);
878cdf0e10cSrcweir if (maPixmap != 0)
879cdf0e10cSrcweir {
880cdf0e10cSrcweir XGCValues aValues;
881cdf0e10cSrcweir GC aGC;
882cdf0e10cSrcweir int nValues = GCFunction;
883cdf0e10cSrcweir
884cdf0e10cSrcweir aValues.function = GXcopy;
885cdf0e10cSrcweir
886cdf0e10cSrcweir if (pImage->depth == 1)
887cdf0e10cSrcweir {
888cdf0e10cSrcweir nValues |= ( GCForeground | GCBackground );
889cdf0e10cSrcweir aValues.foreground = 1;
890cdf0e10cSrcweir aValues.background = 0;
891cdf0e10cSrcweir }
892cdf0e10cSrcweir
893cdf0e10cSrcweir aGC = XCreateGC (pDisplay, maPixmap, nValues, &aValues);
894cdf0e10cSrcweir XPutImage (pDisplay, maPixmap, aGC, pImage, 0, 0, 0, 0, pImage->width, pImage->height);
895cdf0e10cSrcweir XFreeGC (pDisplay, aGC);
896cdf0e10cSrcweir
897cdf0e10cSrcweir maTwoRect.mnSrcX = 0;
898cdf0e10cSrcweir maTwoRect.mnSrcY = 0;
899cdf0e10cSrcweir maTwoRect.mnDestX = 0;
900cdf0e10cSrcweir maTwoRect.mnDestY = 0;
901cdf0e10cSrcweir maTwoRect.mnSrcWidth = pImage->width;
902cdf0e10cSrcweir maTwoRect.mnDestWidth = pImage->width;
903cdf0e10cSrcweir maTwoRect.mnSrcHeight = pImage->height;
904cdf0e10cSrcweir maTwoRect.mnDestHeight = pImage->height;
905cdf0e10cSrcweir
906cdf0e10cSrcweir mnDepth = pImage->depth;
907cdf0e10cSrcweir }
908cdf0e10cSrcweir }
909cdf0e10cSrcweir
910cdf0e10cSrcweir // -----------------------------------------------------------------------------
911cdf0e10cSrcweir
ImplSalDDB(Drawable aDrawable,int nScreen,long nDrawableDepth,long nX,long nY,long nWidth,long nHeight)912cdf0e10cSrcweir ImplSalDDB::ImplSalDDB( Drawable aDrawable, int nScreen, long nDrawableDepth, long nX, long nY, long nWidth, long nHeight ) :
913cdf0e10cSrcweir mnDepth( nDrawableDepth ),
914cdf0e10cSrcweir mnScreen( nScreen )
915cdf0e10cSrcweir {
916cdf0e10cSrcweir SalDisplay* pSalDisp = GetX11SalData()->GetDisplay();
917cdf0e10cSrcweir Display* pXDisp = pSalDisp->GetDisplay();
918cdf0e10cSrcweir
919cdf0e10cSrcweir if( (maPixmap = XCreatePixmap( pXDisp, aDrawable, nWidth, nHeight, nDrawableDepth )) )
920cdf0e10cSrcweir {
921cdf0e10cSrcweir XGCValues aValues;
922cdf0e10cSrcweir GC aGC;
923cdf0e10cSrcweir int nValues = GCFunction;
924cdf0e10cSrcweir
925cdf0e10cSrcweir aValues.function = GXcopy;
926cdf0e10cSrcweir
927cdf0e10cSrcweir if( 1 == mnDepth )
928cdf0e10cSrcweir {
929cdf0e10cSrcweir nValues |= ( GCForeground | GCBackground );
930cdf0e10cSrcweir aValues.foreground = 1, aValues.background = 0;
931cdf0e10cSrcweir }
932cdf0e10cSrcweir
933cdf0e10cSrcweir aGC = XCreateGC( pXDisp, maPixmap, nValues, &aValues );
934cdf0e10cSrcweir ImplDraw( aDrawable, nDrawableDepth, maPixmap, mnDepth,
935cdf0e10cSrcweir nX, nY, nWidth, nHeight, 0, 0, aGC );
936cdf0e10cSrcweir XFreeGC( pXDisp, aGC );
937cdf0e10cSrcweir
938cdf0e10cSrcweir maTwoRect.mnSrcX = maTwoRect.mnSrcY = maTwoRect.mnDestX = maTwoRect.mnDestY = 0;
939cdf0e10cSrcweir maTwoRect.mnSrcWidth = maTwoRect.mnDestWidth = nWidth;
940cdf0e10cSrcweir maTwoRect.mnSrcHeight = maTwoRect.mnDestHeight = nHeight;
941cdf0e10cSrcweir }
942cdf0e10cSrcweir }
943cdf0e10cSrcweir
944cdf0e10cSrcweir // -----------------------------------------------------------------------------
945cdf0e10cSrcweir
~ImplSalDDB()946cdf0e10cSrcweir ImplSalDDB::~ImplSalDDB()
947cdf0e10cSrcweir {
948cdf0e10cSrcweir if( maPixmap && ImplGetSVData() )
949cdf0e10cSrcweir XFreePixmap( GetX11SalData()->GetDisplay()->GetDisplay(), maPixmap );
950cdf0e10cSrcweir }
951cdf0e10cSrcweir
952cdf0e10cSrcweir // -----------------------------------------------------------------------------
953cdf0e10cSrcweir
ImplMatches(int nScreen,long nDepth,const SalTwoRect & rTwoRect) const954cdf0e10cSrcweir bool ImplSalDDB::ImplMatches( int nScreen, long nDepth, const SalTwoRect& rTwoRect ) const
955cdf0e10cSrcweir {
956cdf0e10cSrcweir bool bRet = sal_False;
957cdf0e10cSrcweir
958cdf0e10cSrcweir if( ( maPixmap != 0 ) && ( ( mnDepth == nDepth ) || ( 1 == mnDepth ) ) && nScreen == mnScreen)
959cdf0e10cSrcweir {
960cdf0e10cSrcweir if( rTwoRect.mnSrcX == maTwoRect.mnSrcX && rTwoRect.mnSrcY == maTwoRect.mnSrcY &&
961cdf0e10cSrcweir rTwoRect.mnSrcWidth == maTwoRect.mnSrcWidth && rTwoRect.mnSrcHeight == maTwoRect.mnSrcHeight &&
962cdf0e10cSrcweir rTwoRect.mnDestWidth == maTwoRect.mnDestWidth && rTwoRect.mnDestHeight == maTwoRect.mnDestHeight )
963cdf0e10cSrcweir {
964cdf0e10cSrcweir // absolutely indentically
965cdf0e10cSrcweir bRet = sal_True;
966cdf0e10cSrcweir }
967cdf0e10cSrcweir else if( rTwoRect.mnSrcWidth == rTwoRect.mnDestWidth && rTwoRect.mnSrcHeight == rTwoRect.mnDestHeight &&
968cdf0e10cSrcweir maTwoRect.mnSrcWidth == maTwoRect.mnDestWidth && maTwoRect.mnSrcHeight == maTwoRect.mnDestHeight &&
969cdf0e10cSrcweir rTwoRect.mnSrcX >= maTwoRect.mnSrcX && rTwoRect.mnSrcY >= maTwoRect.mnSrcY &&
970cdf0e10cSrcweir ( rTwoRect.mnSrcX + rTwoRect.mnSrcWidth ) <= ( maTwoRect.mnSrcX + maTwoRect.mnSrcWidth ) &&
971cdf0e10cSrcweir ( rTwoRect.mnSrcY + rTwoRect.mnSrcHeight ) <= ( maTwoRect.mnSrcY + maTwoRect.mnSrcHeight ) )
972cdf0e10cSrcweir {
973cdf0e10cSrcweir bRet = sal_True;
974cdf0e10cSrcweir }
975cdf0e10cSrcweir }
976cdf0e10cSrcweir
977cdf0e10cSrcweir return bRet;
978cdf0e10cSrcweir }
979cdf0e10cSrcweir
980cdf0e10cSrcweir // -----------------------------------------------------------------------------
981cdf0e10cSrcweir
ImplDraw(Drawable aDrawable,long nDrawableDepth,const SalTwoRect & rTwoRect,const GC & rGC) const982cdf0e10cSrcweir void ImplSalDDB::ImplDraw( Drawable aDrawable, long nDrawableDepth, const SalTwoRect& rTwoRect, const GC& rGC ) const
983cdf0e10cSrcweir {
984cdf0e10cSrcweir ImplDraw( maPixmap, mnDepth, aDrawable, nDrawableDepth,
985cdf0e10cSrcweir rTwoRect.mnSrcX - maTwoRect.mnSrcX, rTwoRect.mnSrcY - maTwoRect.mnSrcY,
986cdf0e10cSrcweir rTwoRect.mnDestWidth, rTwoRect.mnDestHeight,
987cdf0e10cSrcweir rTwoRect.mnDestX, rTwoRect.mnDestY, rGC );
988cdf0e10cSrcweir }
989cdf0e10cSrcweir
990cdf0e10cSrcweir // -----------------------------------------------------------------------------
991cdf0e10cSrcweir
ImplDraw(Drawable aSrcDrawable,long nSrcDrawableDepth,Drawable aDstDrawable,long,long nSrcX,long nSrcY,long nDestWidth,long nDestHeight,long nDestX,long nDestY,const GC & rGC)992cdf0e10cSrcweir void ImplSalDDB::ImplDraw( Drawable aSrcDrawable, long nSrcDrawableDepth,
993cdf0e10cSrcweir Drawable aDstDrawable, long,
994cdf0e10cSrcweir long nSrcX, long nSrcY,
995cdf0e10cSrcweir long nDestWidth, long nDestHeight,
996cdf0e10cSrcweir long nDestX, long nDestY, const GC& rGC )
997cdf0e10cSrcweir {
998cdf0e10cSrcweir SalDisplay* pSalDisp = GetX11SalData()->GetDisplay();
999cdf0e10cSrcweir Display* pXDisp = pSalDisp->GetDisplay();
1000cdf0e10cSrcweir
1001cdf0e10cSrcweir if( 1 == nSrcDrawableDepth )
1002cdf0e10cSrcweir {
1003cdf0e10cSrcweir XCopyPlane( pXDisp, aSrcDrawable, aDstDrawable, rGC,
1004cdf0e10cSrcweir nSrcX, nSrcY, nDestWidth, nDestHeight, nDestX, nDestY, 1 );
1005cdf0e10cSrcweir }
1006cdf0e10cSrcweir else
1007cdf0e10cSrcweir {
1008cdf0e10cSrcweir XCopyArea( pXDisp, aSrcDrawable, aDstDrawable, rGC,
1009cdf0e10cSrcweir nSrcX, nSrcY, nDestWidth, nDestHeight, nDestX, nDestY );
1010cdf0e10cSrcweir }
1011cdf0e10cSrcweir }
1012cdf0e10cSrcweir
1013cdf0e10cSrcweir // ----------------------
1014cdf0e10cSrcweir // - ImplSalBitmapCache -
1015cdf0e10cSrcweir // ----------------------
1016cdf0e10cSrcweir
1017cdf0e10cSrcweir struct ImplBmpObj
1018cdf0e10cSrcweir {
1019cdf0e10cSrcweir X11SalBitmap* mpBmp;
1020cdf0e10cSrcweir sal_uLong mnMemSize;
1021cdf0e10cSrcweir sal_uLong mnFlags;
1022cdf0e10cSrcweir
ImplBmpObjImplBmpObj1023cdf0e10cSrcweir ImplBmpObj( X11SalBitmap* pBmp, sal_uLong nMemSize, sal_uLong nFlags ) :
1024cdf0e10cSrcweir mpBmp( pBmp ), mnMemSize( nMemSize ), mnFlags( nFlags ) {}
1025cdf0e10cSrcweir };
1026cdf0e10cSrcweir
1027cdf0e10cSrcweir // -----------------------------------------------------------------------------
1028cdf0e10cSrcweir
ImplSalBitmapCache()1029cdf0e10cSrcweir ImplSalBitmapCache::ImplSalBitmapCache() :
1030cdf0e10cSrcweir mnTotalSize( 0UL )
1031cdf0e10cSrcweir {
1032cdf0e10cSrcweir }
1033cdf0e10cSrcweir
1034cdf0e10cSrcweir // -----------------------------------------------------------------------------
1035cdf0e10cSrcweir
~ImplSalBitmapCache()1036cdf0e10cSrcweir ImplSalBitmapCache::~ImplSalBitmapCache()
1037cdf0e10cSrcweir {
1038cdf0e10cSrcweir ImplClear();
1039cdf0e10cSrcweir }
1040cdf0e10cSrcweir
1041cdf0e10cSrcweir // -----------------------------------------------------------------------------
1042cdf0e10cSrcweir
ImplAdd(X11SalBitmap * pBmp,sal_uLong nMemSize,sal_uLong nFlags)1043cdf0e10cSrcweir void ImplSalBitmapCache::ImplAdd( X11SalBitmap* pBmp, sal_uLong nMemSize, sal_uLong nFlags )
1044cdf0e10cSrcweir {
1045cdf0e10cSrcweir ImplBmpObj* pObj;
1046cdf0e10cSrcweir bool bFound = sal_False;
1047cdf0e10cSrcweir
1048cdf0e10cSrcweir for( pObj = (ImplBmpObj*) maBmpList.Last(); pObj && !bFound; pObj = (ImplBmpObj*) maBmpList.Prev() )
1049cdf0e10cSrcweir if( pObj->mpBmp == pBmp )
1050cdf0e10cSrcweir bFound = sal_True;
1051cdf0e10cSrcweir
1052cdf0e10cSrcweir mnTotalSize += nMemSize;
1053cdf0e10cSrcweir
1054cdf0e10cSrcweir if( bFound )
1055cdf0e10cSrcweir {
1056cdf0e10cSrcweir mnTotalSize -= pObj->mnMemSize;
1057cdf0e10cSrcweir pObj->mnMemSize = nMemSize, pObj->mnFlags = nFlags;
1058cdf0e10cSrcweir }
1059cdf0e10cSrcweir else
1060cdf0e10cSrcweir maBmpList.Insert( new ImplBmpObj( pBmp, nMemSize, nFlags ), LIST_APPEND );
1061cdf0e10cSrcweir }
1062cdf0e10cSrcweir
1063cdf0e10cSrcweir // -----------------------------------------------------------------------------
1064cdf0e10cSrcweir
ImplRemove(X11SalBitmap * pBmp)1065cdf0e10cSrcweir void ImplSalBitmapCache::ImplRemove( X11SalBitmap* pBmp )
1066cdf0e10cSrcweir {
1067cdf0e10cSrcweir for( ImplBmpObj* pObj = (ImplBmpObj*) maBmpList.Last(); pObj; pObj = (ImplBmpObj*) maBmpList.Prev() )
1068cdf0e10cSrcweir {
1069cdf0e10cSrcweir if( pObj->mpBmp == pBmp )
1070cdf0e10cSrcweir {
1071cdf0e10cSrcweir maBmpList.Remove( pObj );
1072cdf0e10cSrcweir pObj->mpBmp->ImplRemovedFromCache();
1073cdf0e10cSrcweir mnTotalSize -= pObj->mnMemSize;
1074cdf0e10cSrcweir delete pObj;
1075cdf0e10cSrcweir break;
1076cdf0e10cSrcweir }
1077cdf0e10cSrcweir }
1078cdf0e10cSrcweir }
1079cdf0e10cSrcweir
1080cdf0e10cSrcweir // -----------------------------------------------------------------------------
1081cdf0e10cSrcweir
ImplClear()1082cdf0e10cSrcweir void ImplSalBitmapCache::ImplClear()
1083cdf0e10cSrcweir {
1084cdf0e10cSrcweir for( ImplBmpObj* pObj = (ImplBmpObj*) maBmpList.First(); pObj; pObj = (ImplBmpObj*) maBmpList.Next() )
1085cdf0e10cSrcweir {
1086cdf0e10cSrcweir pObj->mpBmp->ImplRemovedFromCache();
1087cdf0e10cSrcweir delete pObj;
1088cdf0e10cSrcweir }
1089cdf0e10cSrcweir
1090cdf0e10cSrcweir maBmpList.Clear();
1091cdf0e10cSrcweir mnTotalSize = 0;
1092cdf0e10cSrcweir }
1093