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