Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / vcl / inc / unx / salbmp.h
blob1a4c9d0155688cfc7e5a2e4d9f4ccc3dbfc24d65
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 <X11/Xlib.h>
24 #include <X11/Xutil.h>
26 #include <vcl/salgtype.hxx>
27 #include <unx/saldisp.hxx>
28 #include <salbmp.hxx>
29 #include <vclpluginapi.h>
30 #include <list>
32 struct BitmapBuffer;
33 class BitmapPalette;
34 class SalGraphics;
35 class ImplSalDDB;
36 class ImplSalBitmapCache;
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() override;
114 // override pure virtual methods
115 virtual bool Create(
116 const Size& rSize,
117 sal_uInt16 nBitCount,
118 const BitmapPalette& rPal
119 ) override;
121 virtual bool Create( const SalBitmap& rSalBmp ) override;
122 virtual bool Create(
123 const SalBitmap& rSalBmp,
124 SalGraphics* pGraphics
125 ) override;
127 virtual bool Create(
128 const SalBitmap& rSalBmp,
129 sal_uInt16 nNewBitCount
130 ) override;
132 virtual bool Create(
133 const css::uno::Reference< css::rendering::XBitmapCanvas >& rBitmapCanvas,
134 Size& rSize,
135 bool bMask = false
136 ) override;
138 virtual void Destroy() override;
140 virtual Size GetSize() const override;
141 virtual sal_uInt16 GetBitCount() const override;
143 virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) override;
144 virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) override;
145 virtual bool GetSystemData( BitmapSystemData& rData ) override;
147 virtual bool ScalingSupported() const override;
148 virtual bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) override;
149 virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) override;
153 class ImplSalDDB
155 private:
157 Pixmap maPixmap;
158 SalTwoRect maTwoRect;
159 long mnDepth;
160 SalX11Screen mnXScreen;
162 static void ImplDraw(
163 Drawable aSrcDrawable,
164 long nSrcDrawableDepth,
165 Drawable aDstDrawable,
166 long nSrcX,
167 long nSrcY,
168 long nDestWidth,
169 long nDestHeight,
170 long nDestX,
171 long nDestY,
172 const GC& rGC
175 public:
177 ImplSalDDB(
178 XImage* pImage,
179 Drawable aDrawable,
180 SalX11Screen nXScreen,
181 const SalTwoRect& rTwoRect
184 ImplSalDDB(
185 Drawable aDrawable,
186 SalX11Screen nXScreen,
187 long nDrawableDepth,
188 long nX,
189 long nY,
190 long nWidth,
191 long nHeight
194 ~ImplSalDDB();
196 Pixmap ImplGetPixmap() const { return maPixmap; }
197 long ImplGetWidth() const { return maTwoRect.mnDestWidth; }
198 long ImplGetHeight() const { return maTwoRect.mnDestHeight; }
199 long ImplGetDepth() const { return mnDepth; }
200 sal_uIntPtr ImplGetMemSize() const
202 return( ( maTwoRect.mnDestWidth * maTwoRect.mnDestHeight * mnDepth ) >> 3 );
204 const SalX11Screen& ImplGetScreen() const { return mnXScreen; }
206 bool ImplMatches( SalX11Screen nXScreen, long nDepth, const SalTwoRect& rTwoRect ) const;
208 void ImplDraw(
209 Drawable aDrawable,
210 const SalTwoRect& rTwoRect,
211 const GC& rGC
212 ) const;
216 struct ImplBmpObj;
218 class ImplSalBitmapCache
220 private:
221 typedef ::std::list< ImplBmpObj* > BmpList_impl;
223 BmpList_impl maBmpList;
224 sal_uIntPtr mnTotalSize;
226 public:
228 ImplSalBitmapCache();
229 ~ImplSalBitmapCache();
231 void ImplAdd( X11SalBitmap* pBmp, sal_uIntPtr nMemSize );
232 void ImplRemove( X11SalBitmap* pBmp );
233 void ImplClear();
236 #endif // INCLUDED_VCL_INC_UNX_SALBMP_H
238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */