Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_VCL_GENERIC_GDI_GDIIMPL_HXX
21 : #define INCLUDED_VCL_GENERIC_GDI_GDIIMPL_HXX
22 :
23 : #include <prex.h>
24 : #include <postx.h>
25 :
26 : #include "unx/saltype.h"
27 : #include "unx/x11/x11gdiimpl.h"
28 :
29 : #include "salgdiimpl.hxx"
30 :
31 : #include <basegfx/polygon/b2dtrapezoid.hxx>
32 :
33 : class SalGraphics;
34 : class SalBitmap;
35 : class SalPolyLine;
36 : class X11SalGraphics;
37 : class Gradient;
38 :
39 : class X11SalGraphicsImpl : public SalGraphicsImpl, public X11GraphicsImpl
40 : {
41 : private:
42 : X11SalGraphics& mrParent;
43 :
44 : SalColor mnBrushColor;
45 : GC mpBrushGC; // Brush attributes
46 : Pixel mnBrushPixel;
47 :
48 : bool mbPenGC : 1; // is Pen GC valid
49 : bool mbBrushGC : 1; // is Brush GC valid
50 : bool mbMonoGC : 1; // is Mono GC valid
51 : bool mbCopyGC : 1; // is Copy GC valid
52 : bool mbInvertGC : 1; // is Invert GC valid
53 : bool mbInvert50GC : 1; // is Invert50 GC valid
54 : bool mbStippleGC : 1; // is Stipple GC valid
55 : bool mbTrackingGC : 1; // is Tracking GC valid
56 : bool mbDitherBrush : 1; // is solid or tile
57 :
58 : bool mbXORMode : 1; // is ROP XOR Mode set
59 :
60 : GC mpPenGC; // Pen attributes
61 : SalColor mnPenColor;
62 : Pixel mnPenPixel;
63 :
64 :
65 : GC mpMonoGC;
66 : GC mpCopyGC;
67 : GC mpMaskGC;
68 : GC mpInvertGC;
69 : GC mpInvert50GC;
70 : GC mpStippleGC;
71 : GC mpTrackingGC;
72 :
73 : GC CreateGC( Drawable hDrawable,
74 : unsigned long nMask = GCGraphicsExposures );
75 :
76 : GC SelectBrush();
77 : GC SelectPen();
78 : inline GC GetCopyGC();
79 : inline GC GetStippleGC();
80 : GC GetTrackingGC();
81 : GC GetInvertGC();
82 : GC GetInvert50GC();
83 : inline GC GetMonoGC( Pixmap hPixmap );
84 :
85 : void DrawLines( sal_uIntPtr nPoints,
86 : const SalPolyLine &rPoints,
87 : GC pGC,
88 : bool bClose
89 : );
90 :
91 : XID GetXRenderPicture();
92 : bool drawFilledTrapezoids( const ::basegfx::B2DTrapezoid*, int nTrapCount, double fTransparency );
93 :
94 : long GetGraphicsHeight() const;
95 :
96 : void drawMaskedBitmap( const SalTwoRect& rPosAry,
97 : const SalBitmap& rSalBitmap,
98 : const SalBitmap& rTransparentBitmap );
99 :
100 : void drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry, bool bClose );
101 :
102 : public:
103 :
104 : explicit X11SalGraphicsImpl(X11SalGraphics& rParent);
105 :
106 : virtual void freeResources() SAL_OVERRIDE;
107 :
108 : virtual ~X11SalGraphicsImpl();
109 :
110 : virtual bool setClipRegion( const vcl::Region& ) SAL_OVERRIDE;
111 : //
112 : // get the depth of the device
113 : virtual sal_uInt16 GetBitCount() const SAL_OVERRIDE;
114 :
115 : // get the width of the device
116 : virtual long GetGraphicsWidth() const SAL_OVERRIDE;
117 :
118 : // set the clip region to empty
119 : virtual void ResetClipRegion() SAL_OVERRIDE;
120 :
121 : // set the line color to transparent (= don't draw lines)
122 :
123 : virtual void SetLineColor() SAL_OVERRIDE;
124 :
125 : // set the line color to a specific color
126 : virtual void SetLineColor( SalColor nSalColor ) SAL_OVERRIDE;
127 :
128 : // set the fill color to transparent (= don't fill)
129 : virtual void SetFillColor() SAL_OVERRIDE;
130 :
131 : // set the fill color to a specific color, shapes will be
132 : // filled accordingly
133 : virtual void SetFillColor( SalColor nSalColor ) SAL_OVERRIDE;
134 :
135 : // enable/disable XOR drawing
136 : virtual void SetXORMode( bool bSet, bool bInvertOnly ) SAL_OVERRIDE;
137 :
138 : // set line color for raster operations
139 : virtual void SetROPLineColor( SalROPColor nROPColor ) SAL_OVERRIDE;
140 :
141 : // set fill color for raster operations
142 : virtual void SetROPFillColor( SalROPColor nROPColor ) SAL_OVERRIDE;
143 :
144 : // draw --> LineColor and FillColor and RasterOp and ClipRegion
145 : virtual void drawPixel( long nX, long nY ) SAL_OVERRIDE;
146 : virtual void drawPixel( long nX, long nY, SalColor nSalColor ) SAL_OVERRIDE;
147 :
148 : virtual void drawLine( long nX1, long nY1, long nX2, long nY2 ) SAL_OVERRIDE;
149 :
150 : virtual void drawRect( long nX, long nY, long nWidth, long nHeight ) SAL_OVERRIDE;
151 :
152 : virtual void drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry ) SAL_OVERRIDE;
153 :
154 : virtual void drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ) SAL_OVERRIDE;
155 :
156 : virtual void drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoints, PCONSTSALPOINT* pPtAry ) SAL_OVERRIDE;
157 : virtual bool drawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double fTransparency ) SAL_OVERRIDE;
158 :
159 : virtual bool drawPolyLine(
160 : const ::basegfx::B2DPolygon&,
161 : double fTransparency,
162 : const ::basegfx::B2DVector& rLineWidths,
163 : basegfx::B2DLineJoin,
164 : com::sun::star::drawing::LineCap) SAL_OVERRIDE;
165 :
166 : virtual bool drawPolyLineBezier(
167 : sal_uInt32 nPoints,
168 : const SalPoint* pPtAry,
169 : const sal_uInt8* pFlgAry ) SAL_OVERRIDE;
170 :
171 : virtual bool drawPolygonBezier(
172 : sal_uInt32 nPoints,
173 : const SalPoint* pPtAry,
174 : const sal_uInt8* pFlgAry ) SAL_OVERRIDE;
175 :
176 : virtual bool drawPolyPolygonBezier(
177 : sal_uInt32 nPoly,
178 : const sal_uInt32* pPoints,
179 : const SalPoint* const* pPtAry,
180 : const sal_uInt8* const* pFlgAry ) SAL_OVERRIDE;
181 :
182 : // CopyArea --> No RasterOp, but ClipRegion
183 : virtual void copyArea(
184 : long nDestX, long nDestY,
185 : long nSrcX, long nSrcY,
186 : long nSrcWidth, long nSrcHeight,
187 : sal_uInt16 nFlags ) SAL_OVERRIDE;
188 :
189 : // CopyBits and DrawBitmap --> RasterOp and ClipRegion
190 : // CopyBits() --> pSrcGraphics == NULL, then CopyBits on same Graphics
191 : virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) SAL_OVERRIDE;
192 :
193 : virtual void drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap ) SAL_OVERRIDE;
194 :
195 : virtual void drawBitmap(
196 : const SalTwoRect& rPosAry,
197 : const SalBitmap& rSalBitmap,
198 : SalColor nTransparentColor ) SAL_OVERRIDE;
199 :
200 : virtual void drawBitmap(
201 : const SalTwoRect& rPosAry,
202 : const SalBitmap& rSalBitmap,
203 : const SalBitmap& rMaskBitmap ) SAL_OVERRIDE;
204 :
205 : virtual void drawMask(
206 : const SalTwoRect& rPosAry,
207 : const SalBitmap& rSalBitmap,
208 : SalColor nMaskColor ) SAL_OVERRIDE;
209 :
210 : virtual SalBitmap* getBitmap( long nX, long nY, long nWidth, long nHeight ) SAL_OVERRIDE;
211 :
212 : virtual SalColor getPixel( long nX, long nY ) SAL_OVERRIDE;
213 :
214 : // invert --> ClipRegion (only Windows or VirDevs)
215 : virtual void invert(
216 : long nX, long nY,
217 : long nWidth, long nHeight,
218 : SalInvert nFlags) SAL_OVERRIDE;
219 :
220 : virtual void invert( sal_uInt32 nPoints, const SalPoint* pPtAry, SalInvert nFlags ) SAL_OVERRIDE;
221 :
222 : virtual bool drawEPS(
223 : long nX, long nY,
224 : long nWidth, long nHeight,
225 : void* pPtr,
226 : sal_uLong nSize ) SAL_OVERRIDE;
227 :
228 : /** Blend bitmap with color channels */
229 : virtual bool blendBitmap(
230 : const SalTwoRect&,
231 : const SalBitmap& rBitmap ) SAL_OVERRIDE;
232 :
233 : /** Render bitmap by blending using the mask and alpha channel */
234 : virtual bool blendAlphaBitmap(
235 : const SalTwoRect&,
236 : const SalBitmap& rSrcBitmap,
237 : const SalBitmap& rMaskBitmap,
238 : const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE;
239 :
240 : /** Render bitmap with alpha channel
241 :
242 : @param rSourceBitmap
243 : Source bitmap to blit
244 :
245 : @param rAlphaBitmap
246 : Alpha channel to use for blitting
247 :
248 : @return true, if the operation succeeded, and false
249 : otherwise. In this case, clients should try to emulate alpha
250 : compositing themselves
251 : */
252 : virtual bool drawAlphaBitmap(
253 : const SalTwoRect&,
254 : const SalBitmap& rSourceBitmap,
255 : const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE;
256 :
257 : /** draw transformed bitmap (maybe with alpha) where Null, X, Y define the coordinate system */
258 : virtual bool drawTransformedBitmap(
259 : const basegfx::B2DPoint& rNull,
260 : const basegfx::B2DPoint& rX,
261 : const basegfx::B2DPoint& rY,
262 : const SalBitmap& rSourceBitmap,
263 : const SalBitmap* pAlphaBitmap) SAL_OVERRIDE;
264 :
265 : /** Render solid rectangle with given transparency
266 :
267 : @param nTransparency
268 : Transparency value (0-255) to use. 0 blits and opaque, 255 a
269 : fully transparent rectangle
270 : */
271 : virtual bool drawAlphaRect(
272 : long nX, long nY,
273 : long nWidth, long nHeight,
274 : sal_uInt8 nTransparency ) SAL_OVERRIDE;
275 :
276 : virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) SAL_OVERRIDE;
277 :
278 0 : virtual void beginPaint() SAL_OVERRIDE { }
279 0 : virtual void endPaint() SAL_OVERRIDE { }
280 :
281 : public:
282 : // implementation of X11GraphicsImpl
283 :
284 : void Init() SAL_OVERRIDE;
285 : bool FillPixmapFromScreen( X11Pixmap* pPixmap, int nX, int nY ) SAL_OVERRIDE;
286 : bool RenderPixmapToScreen( X11Pixmap* pPixmap, X11Pixmap* pMask, int nX, int nY ) SAL_OVERRIDE;
287 : };
288 :
289 : #endif
290 :
291 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|