1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_WIN_GDI_GDIIMPL_HXX
21 #define INCLUDED_VCL_WIN_GDI_GDIIMPL_HXX
23 #include <salgdiimpl.hxx>
24 #include <win/salgdi.h>
26 #include <vcl/gradient.hxx>
29 #include <ControlCacheKey.hxx>
33 class WinSalGraphicsImpl
: public SalGraphicsImpl
37 WinSalGraphics
& mrParent
;
38 bool mbXORMode
: 1; // _every_ output with RasterOp XOR
39 bool mbPen
: 1; // is Pen (FALSE == NULL_PEN)
41 bool mbStockPen
: 1; // is Pen a stockpen
42 bool mbBrush
: 1; // is Brush (FALSE == NULL_BRUSH)
43 bool mbStockBrush
: 1; // is Brush a stockbrush
44 HBRUSH mhBrush
; // Brush
45 COLORREF mnPenColor
; // PenColor
46 COLORREF mnBrushColor
; // BrushColor
48 // remember RGB values for SetLineColor/SetFillColor
52 bool TryDrawBitmapGDIPlus(const SalTwoRect
& rTR
, const SalBitmap
& rSrcBitmap
);
53 void DrawPixelImpl(long nX
, long nY
, COLORREF crColor
);
55 HPEN
SearchStockPen(COLORREF nPenColor
);
56 HPEN
MakePen(Color nColor
);
57 void ResetPen(HPEN hNewPen
);
59 HBRUSH
SearchStockBrush(COLORREF nBrushColor
);
60 HBRUSH
MakeBrush(Color nColor
);
61 void ResetBrush(HBRUSH hNewBrush
);
64 explicit WinSalGraphicsImpl(WinSalGraphics
& rParent
);
66 virtual ~WinSalGraphicsImpl() override
;
68 virtual void Init() override
;
70 virtual void freeResources() override
;
72 virtual bool setClipRegion( const vcl::Region
& ) override
;
74 // get the depth of the device
75 virtual sal_uInt16
GetBitCount() const override
;
77 // get the width of the device
78 virtual long GetGraphicsWidth() const override
;
80 // set the clip region to empty
81 virtual void ResetClipRegion() override
;
83 // set the line color to transparent (= don't draw lines)
85 virtual void SetLineColor() override
;
87 // set the line color to a specific color
88 virtual void SetLineColor( Color nColor
) override
;
90 // set the fill color to transparent (= don't fill)
91 virtual void SetFillColor() override
;
93 // set the fill color to a specific color, shapes will be
95 virtual void SetFillColor( Color nColor
) override
;
97 // enable/disable XOR drawing
98 virtual void SetXORMode( bool bSet
, bool bInvertOnly
) override
;
100 // set line color for raster operations
101 virtual void SetROPLineColor( SalROPColor nROPColor
) override
;
103 // set fill color for raster operations
104 virtual void SetROPFillColor( SalROPColor nROPColor
) override
;
106 // draw --> LineColor and FillColor and RasterOp and ClipRegion
107 virtual void drawPixel( long nX
, long nY
) override
;
108 virtual void drawPixel( long nX
, long nY
, Color nColor
) override
;
110 virtual void drawLine( long nX1
, long nY1
, long nX2
, long nY2
) override
;
112 virtual void drawRect( long nX
, long nY
, long nWidth
, long nHeight
) override
;
114 virtual void drawPolyLine( sal_uInt32 nPoints
, const SalPoint
* pPtAry
) override
;
116 virtual void drawPolygon( sal_uInt32 nPoints
, const SalPoint
* pPtAry
) override
;
118 virtual void drawPolyPolygon( sal_uInt32 nPoly
, const sal_uInt32
* pPoints
, PCONSTSALPOINT
* pPtAry
) override
;
120 virtual bool drawPolyPolygon(
121 const basegfx::B2DHomMatrix
& rObjectToDevice
,
122 const basegfx::B2DPolyPolygon
&,
123 double fTransparency
) override
;
125 virtual bool drawPolyLine(
126 const basegfx::B2DHomMatrix
& rObjectToDevice
,
127 const basegfx::B2DPolygon
&,
128 double fTransparency
,
129 const basegfx::B2DVector
& rLineWidths
,
130 basegfx::B2DLineJoin
,
131 css::drawing::LineCap
,
132 double fMiterMinimumAngle
,
133 bool bPixelSnapHairline
) override
;
135 virtual bool drawPolyLineBezier(
137 const SalPoint
* pPtAry
,
138 const PolyFlags
* pFlgAry
) override
;
140 virtual bool drawPolygonBezier(
142 const SalPoint
* pPtAry
,
143 const PolyFlags
* pFlgAry
) override
;
145 virtual bool drawPolyPolygonBezier(
147 const sal_uInt32
* pPoints
,
148 const SalPoint
* const* pPtAry
,
149 const PolyFlags
* const* pFlgAry
) override
;
151 // CopyArea --> No RasterOp, but ClipRegion
152 virtual void copyArea(
153 long nDestX
, long nDestY
,
154 long nSrcX
, long nSrcY
,
155 long nSrcWidth
, long nSrcHeight
, bool bWindowInvalidate
) override
;
157 // CopyBits and DrawBitmap --> RasterOp and ClipRegion
158 // CopyBits() --> pSrcGraphics == NULL, then CopyBits on same Graphics
159 virtual void copyBits( const SalTwoRect
& rPosAry
, SalGraphics
* pSrcGraphics
) override
;
161 virtual void drawBitmap( const SalTwoRect
& rPosAry
, const SalBitmap
& rSalBitmap
) override
;
163 virtual void drawBitmap(
164 const SalTwoRect
& rPosAry
,
165 const SalBitmap
& rSalBitmap
,
166 const SalBitmap
& rMaskBitmap
) override
;
168 virtual void drawMask(
169 const SalTwoRect
& rPosAry
,
170 const SalBitmap
& rSalBitmap
,
171 Color nMaskColor
) override
;
173 virtual std::shared_ptr
<SalBitmap
> getBitmap( long nX
, long nY
, long nWidth
, long nHeight
) override
;
175 virtual Color
getPixel( long nX
, long nY
) override
;
177 // invert --> ClipRegion (only Windows or VirDevs)
180 long nWidth
, long nHeight
,
181 SalInvert nFlags
) override
;
183 virtual void invert( sal_uInt32 nPoints
, const SalPoint
* pPtAry
, SalInvert nFlags
) override
;
185 virtual bool drawEPS(
187 long nWidth
, long nHeight
,
189 sal_uInt32 nSize
) override
;
191 virtual bool blendBitmap(
193 const SalBitmap
& rBitmap
) override
;
195 virtual bool blendAlphaBitmap(
197 const SalBitmap
& rSrcBitmap
,
198 const SalBitmap
& rMaskBitmap
,
199 const SalBitmap
& rAlphaBitmap
) override
;
201 /** Render bitmap with alpha channel
204 Source bitmap to blit
207 Alpha channel to use for blitting
209 @return true, if the operation succeeded, and false
210 otherwise. In this case, clients should try to emulate alpha
211 compositing themselves
213 virtual bool drawAlphaBitmap(
215 const SalBitmap
& rSourceBitmap
,
216 const SalBitmap
& rAlphaBitmap
) override
;
218 /** draw transformed bitmap (maybe with alpha) where Null, X, Y define the coordinate system */
219 virtual bool drawTransformedBitmap(
220 const basegfx::B2DPoint
& rNull
,
221 const basegfx::B2DPoint
& rX
,
222 const basegfx::B2DPoint
& rY
,
223 const SalBitmap
& rSourceBitmap
,
224 const SalBitmap
* pAlphaBitmap
) override
;
226 /** Render solid rectangle with given transparency
229 Transparency value (0-255) to use. 0 blits and opaque, 255 a
230 fully transparent rectangle
232 virtual bool drawAlphaRect(
234 long nWidth
, long nHeight
,
235 sal_uInt8 nTransparency
) override
;
238 virtual bool drawGradient(const tools::PolyPolygon
& rPolygon
,
239 const Gradient
& rGradient
) override
;
241 virtual bool TryRenderCachedNativeControl(ControlCacheKey
& rControlCacheKey
, int nX
, int nY
);
243 virtual bool RenderAndCacheNativeControl(OpenGLCompatibleDC
& rWhite
, OpenGLCompatibleDC
& rBlack
,
244 int nX
, int nY
, ControlCacheKey
& aControlCacheKey
);
247 #endif // INCLUDED_VCL_WIN_GDI_GDIIMPL_HXX
249 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */