Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / inc / unx / salbmp.h
blob65d85ba862e5eb8752d80450a9414aa62c0aade6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_INC_UNX_SALBMP_H
21 #define INCLUDED_VCL_INC_UNX_SALBMP_H
23 #include <prex.h>
24 #include <postx.h>
25 #include <vcl/salgtype.hxx>
26 #include <unx/saldisp.hxx>
27 #include <salbmp.hxx>
28 #include <vclpluginapi.h>
29 #include <list>
31 struct BitmapBuffer;
32 class BitmapPalette;
33 class SalGraphics;
34 class ImplSalDDB;
35 class ImplSalBitmapCache;
37 // - SalBitmap -
39 class VCLPLUG_GEN_PUBLIC X11SalBitmap : public SalBitmap
41 private:
43 static BitmapBuffer* ImplCreateDIB(
44 const Size& rSize,
45 sal_uInt16 nBitCount,
46 const BitmapPalette& rPal
49 static BitmapBuffer* ImplCreateDIB(
50 Drawable aDrawable,
51 SalX11Screen nXScreen,
52 long nDrawableDepth,
53 long nX,
54 long nY,
55 long nWidth,
56 long nHeight,
57 bool bGrey
60 public:
62 static ImplSalBitmapCache* mpCache;
63 static sal_uIntPtr mnCacheInstCount;
65 static void ImplCreateCache();
66 static void ImplDestroyCache();
67 void ImplRemovedFromCache();
69 private:
71 BitmapBuffer* mpDIB;
72 ImplSalDDB* mpDDB;
73 bool mbGrey;
75 public:
77 SAL_DLLPRIVATE bool ImplCreateFromDrawable(
78 Drawable aDrawable,
79 SalX11Screen nXScreen,
80 long nDrawableDepth,
81 long nX,
82 long nY,
83 long nWidth,
84 long nHeight
87 SAL_DLLPRIVATE XImage* ImplCreateXImage(
88 SalDisplay* pSalDisp,
89 SalX11Screen nXScreen,
90 long nDepth,
91 const SalTwoRect& rTwoRect
92 ) const;
94 SAL_DLLPRIVATE ImplSalDDB* ImplGetDDB(
95 Drawable,
96 SalX11Screen nXScreen,
97 long nDrawableDepth,
98 const SalTwoRect&
99 ) const;
101 void ImplDraw(
102 Drawable aDrawable,
103 SalX11Screen nXScreen,
104 long nDrawableDepth,
105 const SalTwoRect& rTwoRect,
106 const GC& rGC
107 ) const;
109 public:
111 X11SalBitmap();
112 virtual ~X11SalBitmap();
114 // override pure virtual methods
115 virtual bool Create(
116 const Size& rSize,
117 sal_uInt16 nBitCount,
118 const BitmapPalette& rPal
119 ) SAL_OVERRIDE;
121 virtual bool Create( const SalBitmap& rSalBmp ) SAL_OVERRIDE;
122 virtual bool Create(
123 const SalBitmap& rSalBmp,
124 SalGraphics* pGraphics
125 ) SAL_OVERRIDE;
127 virtual bool Create(
128 const SalBitmap& rSalBmp,
129 sal_uInt16 nNewBitCount
130 ) SAL_OVERRIDE;
132 virtual bool Create(
133 const ::com::sun::star::uno::Reference<
134 ::com::sun::star::rendering::XBitmapCanvas
135 >& rBitmapCanvas,
136 Size& rSize,
137 bool bMask = false
138 ) SAL_OVERRIDE;
140 virtual void Destroy() SAL_OVERRIDE;
142 virtual Size GetSize() const SAL_OVERRIDE;
143 virtual sal_uInt16 GetBitCount() const SAL_OVERRIDE;
145 virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) SAL_OVERRIDE;
146 virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) SAL_OVERRIDE;
147 virtual bool GetSystemData( BitmapSystemData& rData ) SAL_OVERRIDE;
149 virtual bool Crop( const Rectangle& rRectPixel ) SAL_OVERRIDE;
150 virtual bool Erase( const Color& rFillColor ) SAL_OVERRIDE;
151 virtual bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) SAL_OVERRIDE;
152 virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) SAL_OVERRIDE;
155 // - ImplSalDDB -
157 class ImplSalDDB
159 private:
161 Pixmap maPixmap;
162 SalTwoRect maTwoRect;
163 long mnDepth;
164 SalX11Screen mnXScreen;
166 static void ImplDraw(
167 Drawable aSrcDrawable,
168 long nSrcDrawableDepth,
169 Drawable aDstDrawable,
170 long nDstDrawableDepth,
171 long nSrcX,
172 long nSrcY,
173 long nDestWidth,
174 long nDestHeight,
175 long nDestX,
176 long nDestY,
177 const GC& rGC
180 public:
182 ImplSalDDB(
183 XImage* pImage,
184 Drawable aDrawable,
185 SalX11Screen nXScreen,
186 const SalTwoRect& rTwoRect
189 ImplSalDDB(
190 Drawable aDrawable,
191 SalX11Screen nXScreen,
192 long nDrawableDepth,
193 long nX,
194 long nY,
195 long nWidth,
196 long nHeight
199 ~ImplSalDDB();
201 Pixmap ImplGetPixmap() const { return maPixmap; }
202 long ImplGetWidth() const { return maTwoRect.mnDestWidth; }
203 long ImplGetHeight() const { return maTwoRect.mnDestHeight; }
204 long ImplGetDepth() const { return mnDepth; }
205 sal_uIntPtr ImplGetMemSize() const
207 return( ( maTwoRect.mnDestWidth * maTwoRect.mnDestHeight * mnDepth ) >> 3 );
209 SalX11Screen ImplGetScreen() const { return mnXScreen; }
211 bool ImplMatches( SalX11Screen nXScreen, long nDepth, const SalTwoRect& rTwoRect ) const;
213 void ImplDraw(
214 Drawable aDrawable,
215 long nDrawableDepth,
216 const SalTwoRect& rTwoRect,
217 const GC& rGC
218 ) const;
221 // - ImplSalBitmapCache -
223 struct ImplBmpObj;
225 class ImplSalBitmapCache
227 private:
228 typedef ::std::list< ImplBmpObj* > BmpList_impl;
230 BmpList_impl maBmpList;
231 sal_uIntPtr mnTotalSize;
233 public:
235 ImplSalBitmapCache();
236 ~ImplSalBitmapCache();
238 void ImplAdd( X11SalBitmap* pBmp, sal_uIntPtr nMemSize = 0UL, sal_uIntPtr nFlags = 0UL );
239 void ImplRemove( X11SalBitmap* pBmp );
240 void ImplClear();
243 #endif // INCLUDED_VCL_INC_UNX_SALBMP_H
245 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */