bump product version to 7.6.3.2-android
[LibreOffice.git] / vcl / headless / SvpGraphicsBackend.cxx
blobdafbe75ff3ca086fdbadacdc00727a89fe1191ae
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 #include <headless/SvpGraphicsBackend.hxx>
22 #include <sal/log.hxx>
23 #include <basegfx/matrix/b2dhommatrixtools.hxx>
24 #include <basegfx/polygon/b2dpolygontools.hxx>
25 #include <vcl/BitmapTools.hxx>
26 #include <headless/BitmapHelper.hxx>
28 SvpGraphicsBackend::SvpGraphicsBackend(CairoCommon& rCairoCommon)
29 : m_rCairoCommon(rCairoCommon)
33 void SvpGraphicsBackend::Init() {}
35 void SvpGraphicsBackend::freeResources() {}
37 void SvpGraphicsBackend::setClipRegion(const vcl::Region& i_rClip)
39 m_rCairoCommon.m_aClipRegion = i_rClip;
42 void SvpGraphicsBackend::ResetClipRegion() { m_rCairoCommon.m_aClipRegion.SetNull(); }
44 sal_uInt16 SvpGraphicsBackend::GetBitCount() const { return m_rCairoCommon.GetBitCount(); }
46 tools::Long SvpGraphicsBackend::GetGraphicsWidth() const
48 return m_rCairoCommon.m_pSurface ? m_rCairoCommon.m_aFrameSize.getX() : 0;
51 void SvpGraphicsBackend::SetLineColor() { m_rCairoCommon.m_oLineColor = std::nullopt; }
53 void SvpGraphicsBackend::SetLineColor(Color nColor) { m_rCairoCommon.m_oLineColor = nColor; }
55 void SvpGraphicsBackend::SetFillColor() { m_rCairoCommon.m_oFillColor = std::nullopt; }
57 void SvpGraphicsBackend::SetFillColor(Color nColor) { m_rCairoCommon.m_oFillColor = nColor; }
59 void SvpGraphicsBackend::SetXORMode(bool bSet, bool bInvertOnly)
61 m_rCairoCommon.SetXORMode(bSet, bInvertOnly);
64 void SvpGraphicsBackend::SetROPLineColor(SalROPColor nROPColor)
66 m_rCairoCommon.SetROPLineColor(nROPColor);
69 void SvpGraphicsBackend::SetROPFillColor(SalROPColor nROPColor)
71 m_rCairoCommon.SetROPFillColor(nROPColor);
74 void SvpGraphicsBackend::drawPixel(tools::Long nX, tools::Long nY)
76 m_rCairoCommon.drawPixel(m_rCairoCommon.m_oLineColor, nX, nY, getAntiAlias());
79 void SvpGraphicsBackend::drawPixel(tools::Long nX, tools::Long nY, Color aColor)
81 m_rCairoCommon.drawPixel(aColor, nX, nY, getAntiAlias());
84 void SvpGraphicsBackend::drawLine(tools::Long nX1, tools::Long nY1, tools::Long nX2,
85 tools::Long nY2)
87 m_rCairoCommon.drawLine(nX1, nY1, nX2, nY2, getAntiAlias());
90 void SvpGraphicsBackend::drawRect(tools::Long nX, tools::Long nY, tools::Long nWidth,
91 tools::Long nHeight)
93 m_rCairoCommon.drawRect(nX, nY, nWidth, nHeight, getAntiAlias());
96 void SvpGraphicsBackend::drawPolyLine(sal_uInt32 nPoints, const Point* pPtAry)
98 m_rCairoCommon.drawPolyLine(nPoints, pPtAry, getAntiAlias());
101 void SvpGraphicsBackend::drawPolygon(sal_uInt32 nPoints, const Point* pPtAry)
103 m_rCairoCommon.drawPolygon(nPoints, pPtAry, getAntiAlias());
106 void SvpGraphicsBackend::drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32* pPointCounts,
107 const Point** pPtAry)
109 m_rCairoCommon.drawPolyPolygon(nPoly, pPointCounts, pPtAry, getAntiAlias());
112 bool SvpGraphicsBackend::drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice,
113 const basegfx::B2DPolyPolygon& rPolyPolygon,
114 double fTransparency)
116 return m_rCairoCommon.drawPolyPolygon(rObjectToDevice, rPolyPolygon, fTransparency,
117 getAntiAlias());
120 bool SvpGraphicsBackend::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice,
121 const basegfx::B2DPolygon& rPolyLine, double fTransparency,
122 double fLineWidth, const std::vector<double>* pStroke,
123 basegfx::B2DLineJoin eLineJoin,
124 css::drawing::LineCap eLineCap, double fMiterMinimumAngle,
125 bool bPixelSnapHairline)
127 return m_rCairoCommon.drawPolyLine(rObjectToDevice, rPolyLine, fTransparency, fLineWidth,
128 pStroke, eLineJoin, eLineCap, fMiterMinimumAngle,
129 bPixelSnapHairline, getAntiAlias());
132 bool SvpGraphicsBackend::drawPolyLineBezier(sal_uInt32, const Point*, const PolyFlags*)
134 SAL_INFO("vcl.gdi", "unsupported SvpSalGraphics::drawPolyLineBezier case");
135 return false;
138 bool SvpGraphicsBackend::drawPolygonBezier(sal_uInt32, const Point*, const PolyFlags*)
140 SAL_INFO("vcl.gdi", "unsupported SvpSalGraphics::drawPolygonBezier case");
141 return false;
144 bool SvpGraphicsBackend::drawPolyPolygonBezier(sal_uInt32, const sal_uInt32*, const Point* const*,
145 const PolyFlags* const*)
147 SAL_INFO("vcl.gdi", "unsupported SvpSalGraphics::drawPolyPolygonBezier case");
148 return false;
151 void SvpGraphicsBackend::copyArea(tools::Long nDestX, tools::Long nDestY, tools::Long nSrcX,
152 tools::Long nSrcY, tools::Long nSrcWidth, tools::Long nSrcHeight,
153 bool /*bWindowInvalidate*/)
155 SalTwoRect aTR(nSrcX, nSrcY, nSrcWidth, nSrcHeight, nDestX, nDestY, nSrcWidth, nSrcHeight);
157 cairo_surface_t* source = m_rCairoCommon.m_pSurface;
158 m_rCairoCommon.copyBitsCairo(aTR, source, getAntiAlias());
161 void SvpGraphicsBackend::copyBits(const SalTwoRect& rTR, SalGraphics* pSrcGraphics)
163 cairo_surface_t* source = nullptr;
165 if (pSrcGraphics)
167 SvpGraphicsBackend* pSrc = static_cast<SvpGraphicsBackend*>(pSrcGraphics->GetImpl());
168 source = pSrc->m_rCairoCommon.m_pSurface;
170 else
172 source = m_rCairoCommon.m_pSurface;
175 m_rCairoCommon.copyBitsCairo(rTR, source, getAntiAlias());
178 void SvpGraphicsBackend::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap)
180 m_rCairoCommon.drawBitmap(rPosAry, rSalBitmap, getAntiAlias());
183 void SvpGraphicsBackend::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap,
184 const SalBitmap& rTransparentBitmap)
186 drawAlphaBitmap(rPosAry, rSalBitmap, rTransparentBitmap);
189 void SvpGraphicsBackend::drawMask(const SalTwoRect& rTR, const SalBitmap& rSalBitmap,
190 Color nMaskColor)
192 m_rCairoCommon.drawMask(rTR, rSalBitmap, nMaskColor, getAntiAlias());
195 std::shared_ptr<SalBitmap> SvpGraphicsBackend::getBitmap(tools::Long nX, tools::Long nY,
196 tools::Long nWidth, tools::Long nHeight)
198 return m_rCairoCommon.getBitmap(nX, nY, nWidth, nHeight);
201 void SvpGraphicsBackend::drawBitmapBuffer(const SalTwoRect& rTR, const BitmapBuffer* pBuffer,
202 cairo_operator_t eOp)
204 cairo_surface_t* source = CairoCommon::createCairoSurface(pBuffer);
205 m_rCairoCommon.copyWithOperator(rTR, source, eOp, getAntiAlias());
206 cairo_surface_destroy(source);
209 Color SvpGraphicsBackend::getPixel(tools::Long nX, tools::Long nY)
211 return CairoCommon::getPixel(m_rCairoCommon.m_pSurface, nX, nY);
214 void SvpGraphicsBackend::invert(tools::Long nX, tools::Long nY, tools::Long nWidth,
215 tools::Long nHeight, SalInvert nFlags)
217 m_rCairoCommon.invert(nX, nY, nWidth, nHeight, nFlags, getAntiAlias());
220 void SvpGraphicsBackend::invert(sal_uInt32 nPoints, const Point* pPtAry, SalInvert nFlags)
222 m_rCairoCommon.invert(nPoints, pPtAry, nFlags, getAntiAlias());
225 bool SvpGraphicsBackend::drawEPS(tools::Long /*nX*/, tools::Long /*nY*/, tools::Long /*nWidth*/,
226 tools::Long /*nHeight*/, void* /*pPtr*/, sal_uInt32 /*nSize*/)
228 return false;
231 bool SvpGraphicsBackend::blendBitmap(const SalTwoRect& /*rPosAry*/, const SalBitmap& /*rBitmap*/)
233 return false;
236 bool SvpGraphicsBackend::blendAlphaBitmap(const SalTwoRect& /*rPosAry*/,
237 const SalBitmap& /*rSrcBitmap*/,
238 const SalBitmap& /*rMaskBitmap*/,
239 const SalBitmap& /*rAlphaBitmap*/)
241 return false;
244 bool SvpGraphicsBackend::drawAlphaBitmap(const SalTwoRect& rTR, const SalBitmap& rSourceBitmap,
245 const SalBitmap& rAlphaBitmap)
247 return m_rCairoCommon.drawAlphaBitmap(rTR, rSourceBitmap, rAlphaBitmap, getAntiAlias());
250 bool SvpGraphicsBackend::drawTransformedBitmap(const basegfx::B2DPoint& rNull,
251 const basegfx::B2DPoint& rX,
252 const basegfx::B2DPoint& rY,
253 const SalBitmap& rSourceBitmap,
254 const SalBitmap* pAlphaBitmap, double fAlpha)
256 return m_rCairoCommon.drawTransformedBitmap(rNull, rX, rY, rSourceBitmap, pAlphaBitmap, fAlpha,
257 getAntiAlias());
260 bool SvpGraphicsBackend::hasFastDrawTransformedBitmap() const
262 return CairoCommon::hasFastDrawTransformedBitmap();
265 bool SvpGraphicsBackend::drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth,
266 tools::Long nHeight, sal_uInt8 nTransparency)
268 return m_rCairoCommon.drawAlphaRect(nX, nY, nWidth, nHeight, nTransparency, getAntiAlias());
271 bool SvpGraphicsBackend::drawGradient(const tools::PolyPolygon& rPolyPolygon,
272 const Gradient& rGradient)
274 return m_rCairoCommon.drawGradient(rPolyPolygon, rGradient, getAntiAlias());
277 bool SvpGraphicsBackend::implDrawGradient(basegfx::B2DPolyPolygon const& rPolyPolygon,
278 SalGradient const& rGradient)
280 return m_rCairoCommon.implDrawGradient(rPolyPolygon, rGradient, getAntiAlias());
283 bool SvpGraphicsBackend::supportsOperation(OutDevSupportType eType) const
285 return CairoCommon::supportsOperation(eType);
288 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */