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