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 #include <headless/SvpGraphicsBackend.hxx>
22 SvpGraphicsBackend::SvpGraphicsBackend(CairoCommon
& rCairoCommon
)
23 : m_rCairoCommon(rCairoCommon
)
27 void SvpGraphicsBackend::setClipRegion(const vcl::Region
& i_rClip
)
29 m_rCairoCommon
.m_aClipRegion
= i_rClip
;
32 void SvpGraphicsBackend::ResetClipRegion() { m_rCairoCommon
.m_aClipRegion
.SetNull(); }
34 sal_uInt16
SvpGraphicsBackend::GetBitCount() const { return m_rCairoCommon
.GetBitCount(); }
36 tools::Long
SvpGraphicsBackend::GetGraphicsWidth() const
38 return m_rCairoCommon
.m_pSurface
? m_rCairoCommon
.m_aFrameSize
.getX() : 0;
41 void SvpGraphicsBackend::SetLineColor() { m_rCairoCommon
.m_oLineColor
= std::nullopt
; }
43 void SvpGraphicsBackend::SetLineColor(Color nColor
) { m_rCairoCommon
.m_oLineColor
= nColor
; }
45 void SvpGraphicsBackend::SetFillColor() { m_rCairoCommon
.m_oFillColor
= std::nullopt
; }
47 void SvpGraphicsBackend::SetFillColor(Color nColor
) { m_rCairoCommon
.m_oFillColor
= nColor
; }
49 void SvpGraphicsBackend::SetXORMode(bool bSet
, bool bInvertOnly
)
51 m_rCairoCommon
.SetXORMode(bSet
, bInvertOnly
);
54 void SvpGraphicsBackend::SetROPLineColor(SalROPColor nROPColor
)
56 m_rCairoCommon
.SetROPLineColor(nROPColor
);
59 void SvpGraphicsBackend::SetROPFillColor(SalROPColor nROPColor
)
61 m_rCairoCommon
.SetROPFillColor(nROPColor
);
64 void SvpGraphicsBackend::drawPixel(tools::Long nX
, tools::Long nY
)
66 m_rCairoCommon
.drawPixel(m_rCairoCommon
.m_oLineColor
, nX
, nY
, getAntiAlias());
69 void SvpGraphicsBackend::drawPixel(tools::Long nX
, tools::Long nY
, Color aColor
)
71 m_rCairoCommon
.drawPixel(aColor
, nX
, nY
, getAntiAlias());
74 void SvpGraphicsBackend::drawLine(tools::Long nX1
, tools::Long nY1
, tools::Long nX2
,
77 m_rCairoCommon
.drawLine(nX1
, nY1
, nX2
, nY2
, getAntiAlias());
80 void SvpGraphicsBackend::drawRect(tools::Long nX
, tools::Long nY
, tools::Long nWidth
,
83 m_rCairoCommon
.drawRect(nX
, nY
, nWidth
, nHeight
, getAntiAlias());
86 void SvpGraphicsBackend::drawPolyLine(sal_uInt32 nPoints
, const Point
* pPtAry
)
88 m_rCairoCommon
.drawPolyLine(nPoints
, pPtAry
, getAntiAlias());
91 void SvpGraphicsBackend::drawPolygon(sal_uInt32 nPoints
, const Point
* pPtAry
)
93 m_rCairoCommon
.drawPolygon(nPoints
, pPtAry
, getAntiAlias());
96 void SvpGraphicsBackend::drawPolyPolygon(sal_uInt32 nPoly
, const sal_uInt32
* pPointCounts
,
99 m_rCairoCommon
.drawPolyPolygon(nPoly
, pPointCounts
, pPtAry
, getAntiAlias());
102 void SvpGraphicsBackend::drawPolyPolygon(const basegfx::B2DHomMatrix
& rObjectToDevice
,
103 const basegfx::B2DPolyPolygon
& rPolyPolygon
,
104 double fTransparency
)
106 m_rCairoCommon
.drawPolyPolygon(rObjectToDevice
, rPolyPolygon
, fTransparency
, getAntiAlias());
109 bool SvpGraphicsBackend::drawPolyLine(const basegfx::B2DHomMatrix
& rObjectToDevice
,
110 const basegfx::B2DPolygon
& rPolyLine
, double fTransparency
,
111 double fLineWidth
, const std::vector
<double>* pStroke
,
112 basegfx::B2DLineJoin eLineJoin
,
113 css::drawing::LineCap eLineCap
, double fMiterMinimumAngle
,
114 bool bPixelSnapHairline
)
116 return m_rCairoCommon
.drawPolyLine(rObjectToDevice
, rPolyLine
, fTransparency
, fLineWidth
,
117 pStroke
, eLineJoin
, eLineCap
, fMiterMinimumAngle
,
118 bPixelSnapHairline
, getAntiAlias());
121 bool SvpGraphicsBackend::drawPolyLineBezier(sal_uInt32
, const Point
*, const PolyFlags
*)
123 SAL_INFO("vcl.gdi", "unsupported SvpSalGraphics::drawPolyLineBezier case");
127 bool SvpGraphicsBackend::drawPolygonBezier(sal_uInt32
, const Point
*, const PolyFlags
*)
129 SAL_INFO("vcl.gdi", "unsupported SvpSalGraphics::drawPolygonBezier case");
133 bool SvpGraphicsBackend::drawPolyPolygonBezier(sal_uInt32
, const sal_uInt32
*, const Point
* const*,
134 const PolyFlags
* const*)
136 SAL_INFO("vcl.gdi", "unsupported SvpSalGraphics::drawPolyPolygonBezier case");
140 void SvpGraphicsBackend::copyArea(tools::Long nDestX
, tools::Long nDestY
, tools::Long nSrcX
,
141 tools::Long nSrcY
, tools::Long nSrcWidth
, tools::Long nSrcHeight
,
142 bool /*bWindowInvalidate*/)
144 SalTwoRect
aTR(nSrcX
, nSrcY
, nSrcWidth
, nSrcHeight
, nDestX
, nDestY
, nSrcWidth
, nSrcHeight
);
146 cairo_surface_t
* source
= m_rCairoCommon
.m_pSurface
;
147 m_rCairoCommon
.copyBitsCairo(aTR
, source
, getAntiAlias());
150 void SvpGraphicsBackend::copyBits(const SalTwoRect
& rTR
, SalGraphics
* pSrcGraphics
)
152 cairo_surface_t
* source
= nullptr;
156 SvpGraphicsBackend
* pSrc
= static_cast<SvpGraphicsBackend
*>(pSrcGraphics
->GetImpl());
157 source
= pSrc
->m_rCairoCommon
.m_pSurface
;
161 source
= m_rCairoCommon
.m_pSurface
;
164 m_rCairoCommon
.copyBitsCairo(rTR
, source
, getAntiAlias());
167 void SvpGraphicsBackend::drawBitmap(const SalTwoRect
& rPosAry
, const SalBitmap
& rSalBitmap
)
169 m_rCairoCommon
.drawBitmap(rPosAry
, rSalBitmap
, getAntiAlias());
172 void SvpGraphicsBackend::drawBitmap(const SalTwoRect
& rPosAry
, const SalBitmap
& rSalBitmap
,
173 const SalBitmap
& rTransparentBitmap
)
175 drawAlphaBitmap(rPosAry
, rSalBitmap
, rTransparentBitmap
);
178 void SvpGraphicsBackend::drawMask(const SalTwoRect
& rTR
, const SalBitmap
& rSalBitmap
,
181 m_rCairoCommon
.drawMask(rTR
, rSalBitmap
, nMaskColor
, getAntiAlias());
184 std::shared_ptr
<SalBitmap
> SvpGraphicsBackend::getBitmap(tools::Long nX
, tools::Long nY
,
185 tools::Long nWidth
, tools::Long nHeight
)
187 return m_rCairoCommon
.getBitmap(nX
, nY
, nWidth
, nHeight
);
190 void SvpGraphicsBackend::drawBitmapBuffer(const SalTwoRect
& rTR
, const BitmapBuffer
* pBuffer
,
191 cairo_operator_t eOp
)
193 cairo_surface_t
* source
= CairoCommon::createCairoSurface(pBuffer
);
194 m_rCairoCommon
.copyWithOperator(rTR
, source
, eOp
, getAntiAlias());
195 cairo_surface_destroy(source
);
198 Color
SvpGraphicsBackend::getPixel(tools::Long nX
, tools::Long nY
)
200 return CairoCommon::getPixel(m_rCairoCommon
.m_pSurface
, nX
, nY
);
203 void SvpGraphicsBackend::invert(tools::Long nX
, tools::Long nY
, tools::Long nWidth
,
204 tools::Long nHeight
, SalInvert nFlags
)
206 m_rCairoCommon
.invert(nX
, nY
, nWidth
, nHeight
, nFlags
, getAntiAlias());
209 void SvpGraphicsBackend::invert(sal_uInt32 nPoints
, const Point
* pPtAry
, SalInvert nFlags
)
211 m_rCairoCommon
.invert(nPoints
, pPtAry
, nFlags
, getAntiAlias());
214 bool SvpGraphicsBackend::blendBitmap(const SalTwoRect
& /*rPosAry*/, const SalBitmap
& /*rBitmap*/)
219 bool SvpGraphicsBackend::blendAlphaBitmap(const SalTwoRect
& /*rPosAry*/,
220 const SalBitmap
& /*rSrcBitmap*/,
221 const SalBitmap
& /*rMaskBitmap*/,
222 const SalBitmap
& /*rAlphaBitmap*/)
227 bool SvpGraphicsBackend::drawAlphaBitmap(const SalTwoRect
& rTR
, const SalBitmap
& rSourceBitmap
,
228 const SalBitmap
& rAlphaBitmap
)
230 return m_rCairoCommon
.drawAlphaBitmap(rTR
, rSourceBitmap
, rAlphaBitmap
, getAntiAlias());
233 bool SvpGraphicsBackend::drawTransformedBitmap(const basegfx::B2DPoint
& rNull
,
234 const basegfx::B2DPoint
& rX
,
235 const basegfx::B2DPoint
& rY
,
236 const SalBitmap
& rSourceBitmap
,
237 const SalBitmap
* pAlphaBitmap
, double fAlpha
)
239 return m_rCairoCommon
.drawTransformedBitmap(rNull
, rX
, rY
, rSourceBitmap
, pAlphaBitmap
, fAlpha
,
243 bool SvpGraphicsBackend::drawAlphaRect(tools::Long nX
, tools::Long nY
, tools::Long nWidth
,
244 tools::Long nHeight
, sal_uInt8 nTransparency
)
246 return m_rCairoCommon
.drawAlphaRect(nX
, nY
, nWidth
, nHeight
, nTransparency
, getAntiAlias());
249 bool SvpGraphicsBackend::drawGradient(const tools::PolyPolygon
& rPolyPolygon
,
250 const Gradient
& rGradient
)
252 return m_rCairoCommon
.drawGradient(rPolyPolygon
, rGradient
, getAntiAlias());
255 bool SvpGraphicsBackend::implDrawGradient(basegfx::B2DPolyPolygon
const& rPolyPolygon
,
256 SalGradient
const& rGradient
)
258 return m_rCairoCommon
.implDrawGradient(rPolyPolygon
, rGradient
, getAntiAlias());
261 bool SvpGraphicsBackend::supportsOperation(OutDevSupportType eType
) const
263 return CairoCommon::supportsOperation(eType
);
266 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */