1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef _SV_SALBMP_H 29*cdf0e10cSrcweir #define _SV_SALBMP_H 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <unx/salstd.hxx> 32*cdf0e10cSrcweir #ifndef _SV_SALGTYPE 33*cdf0e10cSrcweir #include <vcl/salgtype.hxx> 34*cdf0e10cSrcweir #endif 35*cdf0e10cSrcweir #include <unx/saldisp.hxx> 36*cdf0e10cSrcweir #include <salbmp.hxx> 37*cdf0e10cSrcweir #include <vclpluginapi.h> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir struct BitmapBuffer; 40*cdf0e10cSrcweir class BitmapPalette; 41*cdf0e10cSrcweir class SalGraphics; 42*cdf0e10cSrcweir class ImplSalDDB; 43*cdf0e10cSrcweir class ImplSalBitmapCache; 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir // ------------- 46*cdf0e10cSrcweir // - SalBitmap - 47*cdf0e10cSrcweir // ------------- 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir class VCLPLUG_GEN_PUBLIC X11SalBitmap : public SalBitmap 50*cdf0e10cSrcweir { 51*cdf0e10cSrcweir private: 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir static BitmapBuffer* ImplCreateDIB( const Size& rSize, 54*cdf0e10cSrcweir sal_uInt16 nBitCount, 55*cdf0e10cSrcweir const BitmapPalette& rPal ); 56*cdf0e10cSrcweir static BitmapBuffer* ImplCreateDIB( Drawable aDrawable, 57*cdf0e10cSrcweir int nScreen, 58*cdf0e10cSrcweir long nDrawableDepth, 59*cdf0e10cSrcweir long nX, long nY, 60*cdf0e10cSrcweir long nWidth, long nHeight ); 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir public: 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir static ImplSalBitmapCache* mpCache; 65*cdf0e10cSrcweir static sal_uIntPtr mnCacheInstCount; 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir static void ImplCreateCache(); 68*cdf0e10cSrcweir static void ImplDestroyCache(); 69*cdf0e10cSrcweir void ImplRemovedFromCache(); 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir bool SnapShot (Display* pDisplay, XLIB_Window hWindow); 72*cdf0e10cSrcweir bool ImplCreateFromXImage( Display* pDisplay, 73*cdf0e10cSrcweir XLIB_Window hWindow, 74*cdf0e10cSrcweir int nScreen, 75*cdf0e10cSrcweir XImage* pImage); 76*cdf0e10cSrcweir private: 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir BitmapBuffer* mpDIB; 80*cdf0e10cSrcweir ImplSalDDB* mpDDB; 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir public: 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir SAL_DLLPRIVATE bool ImplCreateFromDrawable( Drawable aDrawable, 85*cdf0e10cSrcweir int nScreen, 86*cdf0e10cSrcweir long nDrawableDepth, 87*cdf0e10cSrcweir long nX, long nY, 88*cdf0e10cSrcweir long nWidth, long nHeight ); 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir SAL_DLLPRIVATE XImage* ImplCreateXImage( SalDisplay* pSalDisp, 91*cdf0e10cSrcweir int nScreen, long nDepth, 92*cdf0e10cSrcweir const SalTwoRect& rTwoRect ) const; 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir SAL_DLLPRIVATE ImplSalDDB* ImplGetDDB( Drawable, int nScreen, long nDrawableDepth, 95*cdf0e10cSrcweir const SalTwoRect& ) const; 96*cdf0e10cSrcweir void ImplDraw( Drawable aDrawable, int nScreen, long nDrawableDepth, 97*cdf0e10cSrcweir const SalTwoRect& rTwoRect, const GC& rGC ) const; 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir public: 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir X11SalBitmap(); 102*cdf0e10cSrcweir virtual ~X11SalBitmap(); 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir // overload pure virtual methods 105*cdf0e10cSrcweir virtual bool Create( const Size& rSize, 106*cdf0e10cSrcweir sal_uInt16 nBitCount, 107*cdf0e10cSrcweir const BitmapPalette& rPal ); 108*cdf0e10cSrcweir virtual bool Create( const SalBitmap& rSalBmp ); 109*cdf0e10cSrcweir virtual bool Create( const SalBitmap& rSalBmp, 110*cdf0e10cSrcweir SalGraphics* pGraphics ); 111*cdf0e10cSrcweir virtual bool Create( const SalBitmap& rSalBmp, 112*cdf0e10cSrcweir sal_uInt16 nNewBitCount ); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir virtual void Destroy(); 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir virtual Size GetSize() const; 117*cdf0e10cSrcweir virtual sal_uInt16 GetBitCount() const; 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir virtual BitmapBuffer* AcquireBuffer( bool bReadOnly ); 120*cdf0e10cSrcweir virtual void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly ); 121*cdf0e10cSrcweir virtual bool GetSystemData( BitmapSystemData& rData ); 122*cdf0e10cSrcweir }; 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir // -------------- 125*cdf0e10cSrcweir // - ImplSalDDB - 126*cdf0e10cSrcweir // -------------- 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir class ImplSalDDB 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir private: 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir Pixmap maPixmap; 133*cdf0e10cSrcweir SalTwoRect maTwoRect; 134*cdf0e10cSrcweir long mnDepth; 135*cdf0e10cSrcweir int mnScreen; 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir ImplSalDDB() {} 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir static void ImplDraw( Drawable aSrcDrawable, long nSrcDrawableDepth, 140*cdf0e10cSrcweir Drawable aDstDrawable, long nDstDrawableDepth, 141*cdf0e10cSrcweir long nSrcX, long nSrcY, 142*cdf0e10cSrcweir long nDestWidth, long nDestHeight, 143*cdf0e10cSrcweir long nDestX, long nDestY, const GC& rGC ); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir public: 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir ImplSalDDB( XImage* pImage, 148*cdf0e10cSrcweir Drawable aDrawable, int nScreen, 149*cdf0e10cSrcweir const SalTwoRect& rTwoRect ); 150*cdf0e10cSrcweir ImplSalDDB( Drawable aDrawable, 151*cdf0e10cSrcweir int nScreen, 152*cdf0e10cSrcweir long nDrawableDepth, 153*cdf0e10cSrcweir long nX, long nY, long nWidth, long nHeight ); 154*cdf0e10cSrcweir ImplSalDDB( Display* pDisplay, 155*cdf0e10cSrcweir XLIB_Window hWindow, 156*cdf0e10cSrcweir int nScreen, 157*cdf0e10cSrcweir XImage* pImage); 158*cdf0e10cSrcweir ~ImplSalDDB(); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir Pixmap ImplGetPixmap() const { return maPixmap; } 161*cdf0e10cSrcweir long ImplGetWidth() const { return maTwoRect.mnDestWidth; } 162*cdf0e10cSrcweir long ImplGetHeight() const { return maTwoRect.mnDestHeight; } 163*cdf0e10cSrcweir long ImplGetDepth() const { return mnDepth; } 164*cdf0e10cSrcweir sal_uIntPtr ImplGetMemSize() const { return( ( maTwoRect.mnDestWidth * maTwoRect.mnDestHeight * mnDepth ) >> 3 ); } 165*cdf0e10cSrcweir int ImplGetScreen() const { return mnScreen; } 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir bool ImplMatches( int nScreen, long nDepth, const SalTwoRect& rTwoRect ) const; 168*cdf0e10cSrcweir void ImplDraw( Drawable aDrawable, long nDrawableDepth, 169*cdf0e10cSrcweir const SalTwoRect& rTwoRect, const GC& rGC ) const; 170*cdf0e10cSrcweir }; 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir // ---------------------- 173*cdf0e10cSrcweir // - ImplSalBitmapCache - 174*cdf0e10cSrcweir // ---------------------- 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir class ImplSalBitmapCache 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir private: 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir List maBmpList; 181*cdf0e10cSrcweir sal_uIntPtr mnTotalSize; 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir public: 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir ImplSalBitmapCache(); 186*cdf0e10cSrcweir ~ImplSalBitmapCache(); 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir void ImplAdd( X11SalBitmap* pBmp, sal_uIntPtr nMemSize = 0UL, sal_uIntPtr nFlags = 0UL ); 189*cdf0e10cSrcweir void ImplRemove( X11SalBitmap* pBmp ); 190*cdf0e10cSrcweir void ImplClear(); 191*cdf0e10cSrcweir }; 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir #endif // _SV_SALBMP_HXX 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir 238