Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / vcl / inc / unx / salbmp.h
blob34c7ff076156cf1a1e0e57326bbe8634fdd2b7dd
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 std::unique_ptr<BitmapBuffer>
44 ImplCreateDIB(
45 const Size& rSize,
46 sal_uInt16 nBitCount,
47 const BitmapPalette& rPal
50 static std::unique_ptr<BitmapBuffer>
51 ImplCreateDIB(
52 Drawable aDrawable,
53 SalX11Screen nXScreen,
54 long nDrawableDepth,
55 long nX,
56 long nY,
57 long nWidth,
58 long nHeight,
59 bool bGrey
62 public:
64 static ImplSalBitmapCache* mpCache;
65 static sal_uIntPtr mnCacheInstCount;
67 static void ImplCreateCache();
68 static void ImplDestroyCache();
69 void ImplRemovedFromCache();
71 private:
73 std::unique_ptr<BitmapBuffer> mpDIB;
74 mutable std::unique_ptr<ImplSalDDB> mpDDB;
75 bool mbGrey;
77 public:
79 SAL_DLLPRIVATE bool ImplCreateFromDrawable(
80 Drawable aDrawable,
81 SalX11Screen nXScreen,
82 long nDrawableDepth,
83 long nX,
84 long nY,
85 long nWidth,
86 long nHeight
89 SAL_DLLPRIVATE XImage* ImplCreateXImage(
90 SalDisplay const * pSalDisp,
91 SalX11Screen nXScreen,
92 long nDepth,
93 const SalTwoRect& rTwoRect
94 ) const;
96 SAL_DLLPRIVATE ImplSalDDB* ImplGetDDB(
97 Drawable,
98 SalX11Screen nXScreen,
99 long nDrawableDepth,
100 const SalTwoRect&
101 ) const;
103 void ImplDraw(
104 Drawable aDrawable,
105 SalX11Screen nXScreen,
106 long nDrawableDepth,
107 const SalTwoRect& rTwoRect,
108 const GC& rGC
109 ) const;
111 public:
113 X11SalBitmap();
114 virtual ~X11SalBitmap() override;
116 // override pure virtual methods
117 virtual bool Create(
118 const Size& rSize,
119 sal_uInt16 nBitCount,
120 const BitmapPalette& rPal
121 ) override;
123 virtual bool Create( const SalBitmap& rSalBmp ) override;
124 virtual bool Create(
125 const SalBitmap& rSalBmp,
126 SalGraphics* pGraphics
127 ) override;
129 virtual bool Create(
130 const SalBitmap& rSalBmp,
131 sal_uInt16 nNewBitCount
132 ) override;
134 virtual bool Create(
135 const css::uno::Reference< css::rendering::XBitmapCanvas >& rBitmapCanvas,
136 Size& rSize,
137 bool bMask = false
138 ) override;
140 virtual void Destroy() override;
142 virtual Size GetSize() const override;
143 virtual sal_uInt16 GetBitCount() const override;
145 virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) override;
146 virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) override;
147 virtual bool GetSystemData( BitmapSystemData& rData ) override;
149 virtual bool ScalingSupported() const override;
150 virtual bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) override;
151 virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) override;
155 class ImplSalDDB
157 private:
159 Pixmap maPixmap;
160 SalTwoRect maTwoRect;
161 long mnDepth;
162 SalX11Screen mnXScreen;
164 static void ImplDraw(
165 Drawable aSrcDrawable,
166 long nSrcDrawableDepth,
167 Drawable aDstDrawable,
168 long nSrcX,
169 long nSrcY,
170 long nDestWidth,
171 long nDestHeight,
172 long nDestX,
173 long nDestY,
174 const GC& rGC
177 public:
179 ImplSalDDB(
180 XImage* pImage,
181 Drawable aDrawable,
182 SalX11Screen nXScreen,
183 const SalTwoRect& rTwoRect
186 ImplSalDDB(
187 Drawable aDrawable,
188 SalX11Screen nXScreen,
189 long nDrawableDepth,
190 long nX,
191 long nY,
192 long nWidth,
193 long nHeight
196 ~ImplSalDDB();
198 Pixmap ImplGetPixmap() const { return maPixmap; }
199 long ImplGetWidth() const { return maTwoRect.mnDestWidth; }
200 long ImplGetHeight() const { return maTwoRect.mnDestHeight; }
201 long ImplGetDepth() const { return mnDepth; }
202 const SalX11Screen& ImplGetScreen() const { return mnXScreen; }
204 bool ImplMatches( SalX11Screen nXScreen, long nDepth, const SalTwoRect& rTwoRect ) const;
206 void ImplDraw(
207 Drawable aDrawable,
208 const SalTwoRect& rTwoRect,
209 const GC& rGC
210 ) const;
214 struct ImplBmpObj;
216 class ImplSalBitmapCache
218 private:
219 typedef ::std::list< ImplBmpObj* > BmpList_impl;
221 BmpList_impl maBmpList;
223 public:
225 ImplSalBitmapCache();
226 ~ImplSalBitmapCache();
228 void ImplAdd( X11SalBitmap* pBmp );
229 void ImplRemove( X11SalBitmap const * pBmp );
230 void ImplClear();
233 #endif // INCLUDED_VCL_INC_UNX_SALBMP_H
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */