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 "tools/gen.hxx" 32 33 #include "basebmp/bitmapdevice.hxx" 34 35 #include "vcl/salbtype.hxx" 36 37 #include "aqua/salconst.h" 38 #include "aqua/salgdi.h" 39 40 #include "saldata.hxx" 41 #include "salinst.hxx" 42 #include "salvd.hxx" 43 #include "salbmp.hxx" 44 45 #include "salcolorutils.hxx" 46 47 48 // -------------- 49 // - SalBitmap - 50 // -------------- 51 52 struct BitmapBuffer; 53 class BitmapColor; 54 class BitmapPalette; 55 class AquaSalVirtualDevice; 56 class AquaSalGraphics; 57 58 class AquaSalBitmap : public SalBitmap 59 { 60 public: 61 CGContextRef mxGraphicContext; 62 mutable CGImageRef mxCachedImage; 63 BitmapPalette maPalette; 64 basebmp::RawMemorySharedArray maUserBuffer; 65 basebmp::RawMemorySharedArray maContextBuffer; 66 sal_uInt16 mnBits; 67 int mnWidth; 68 int mnHeight; 69 sal_uInt32 mnBytesPerRow; 70 71 public: 72 AquaSalBitmap(); 73 virtual ~AquaSalBitmap(); 74 75 public: 76 77 // SalBitmap methods 78 bool Create( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal ); 79 bool Create( const SalBitmap& rSalBmp ); 80 bool Create( const SalBitmap& rSalBmp, SalGraphics* pGraphics ); 81 bool Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount ); 82 83 void Destroy(); 84 85 Size GetSize() const; 86 sal_uInt16 GetBitCount() const; 87 88 BitmapBuffer *AcquireBuffer( bool bReadOnly ); 89 void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly ); 90 91 bool GetSystemData( BitmapSystemData& rData ); 92 93 private: 94 // quartz helper 95 bool CreateContext(); 96 void DestroyContext(); 97 bool AllocateUserData(); 98 99 void ConvertBitmapData( sal_uInt32 nWidth, sal_uInt32 nHeight, 100 sal_uInt16 nDestBits, sal_uInt32 nDestBytesPerRow, const BitmapPalette& rDestPalette, sal_uInt8* pDestData, 101 sal_uInt16 nSrcBits, sal_uInt32 nSrcBytesPerRow, const BitmapPalette& rSrcPalette, sal_uInt8* pSrcData ); 102 103 public: 104 bool Create( CGLayerRef xLayer, int nBitCount, int nX, int nY, int nWidth, int nHeight, bool bMirrorVert = true ); 105 106 public: 107 CGImageRef CreateWithMask( const AquaSalBitmap& rMask, int nX, int nY, int nWidth, int nHeight ) const; 108 CGImageRef CreateColorMask( int nX, int nY, int nWidth, int nHeight, SalColor nMaskColor ) const; 109 CGImageRef CreateCroppedImage( int nX, int nY, int nWidth, int nHeight ) const; 110 }; 111 112 #endif // _SV_SALBMP_HXX 113