vcl/Library_vcl.mk | 1 vcl/headless/svpprn.cxx | 1 vcl/inc/salprn.hxx | 2 vcl/inc/unx/GenPspGfxBackend.hxx | 126 -------- vcl/inc/unx/genprn.h | 3 vcl/inc/unx/genpspgraphics.h | 16 - vcl/unx/generic/app/sm.cxx | 1 vcl/unx/generic/print/GenPspGfxBackend.cxx | 410 ----------------------------- vcl/unx/generic/print/genprnpsp.cxx | 4 vcl/unx/generic/print/genpspgraphics.cxx | 120 -------- vcl/unx/gtk3/gtkinst.cxx | 1 11 files changed, 28 insertions(+), 657 deletions(-)
New commits: commit 4998de76ed1da4039e30718941d50d6f1dfe4f82 Author: Khaled Hosny <kha...@libreoffice.org> AuthorDate: Sun Jul 30 07:40:48 2023 +0000 Commit: خالد حسني <kha...@libreoffice.org> CommitDate: Sun Jul 30 20:44:50 2023 +0200 tdf#156230: Drop freshly unused GenPspGfxBackend Change-Id: Idfc4364b99ed605462aae58391e98960be6021b5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155064 Tested-by: Jenkins Reviewed-by: خالد حسني <kha...@libreoffice.org> diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 1c18f470cfeb..6293e292b25e 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -564,7 +564,6 @@ vcl_headless_freetype_code=\ vcl/unx/generic/print/glyphset \ vcl/unx/generic/print/printerjob \ vcl/unx/generic/print/psputil \ - vcl/unx/generic/print/GenPspGfxBackend \ vcl/unx/generic/print/genpspgraphics \ vcl/unx/generic/print/genprnpsp \ vcl/unx/generic/print/prtsetup \ diff --git a/vcl/inc/unx/GenPspGfxBackend.hxx b/vcl/inc/unx/GenPspGfxBackend.hxx deleted file mode 100644 index 31d85290361c..000000000000 --- a/vcl/inc/unx/GenPspGfxBackend.hxx +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - */ - -#pragma once - -#include <salgdiimpl.hxx> - -namespace psp -{ -class PrinterGfx; -} - -class GenPspGfxBackend final : public SalGraphicsImpl -{ -private: - psp::PrinterGfx* m_pPrinterGfx; - -public: - GenPspGfxBackend(psp::PrinterGfx* pPrinterGfx); - ~GenPspGfxBackend() override; - - void Init() override; - void freeResources() override; - OUString getRenderBackendName() const override { return "genpsp"; } - - void setClipRegion(vcl::Region const& rRegion) override; - void ResetClipRegion() override; - - sal_uInt16 GetBitCount() const override; - - tools::Long GetGraphicsWidth() const override; - - void SetLineColor() override; - void SetLineColor(Color nColor) override; - void SetFillColor() override; - void SetFillColor(Color nColor) override; - void SetXORMode(bool bSet, bool bInvertOnly) override; - void SetROPLineColor(SalROPColor nROPColor) override; - void SetROPFillColor(SalROPColor nROPColor) override; - - void drawPixel(tools::Long nX, tools::Long nY) override; - void drawPixel(tools::Long nX, tools::Long nY, Color nColor) override; - - void drawLine(tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2) override; - void drawRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight) override; - void drawPolyLine(sal_uInt32 nPoints, const Point* pPointArray) override; - void drawPolygon(sal_uInt32 nPoints, const Point* pPointArray) override; - void drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32* pPoints, - const Point** pPointArray) override; - - bool drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice, - const basegfx::B2DPolyPolygon&, double fTransparency) override; - - bool drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice, const basegfx::B2DPolygon&, - double fTransparency, double fLineWidth, const std::vector<double>* pStroke, - basegfx::B2DLineJoin, css::drawing::LineCap, double fMiterMinimumAngle, - bool bPixelSnapHairline) override; - - bool drawPolyLineBezier(sal_uInt32 nPoints, const Point* pPointArray, - const PolyFlags* pFlagArray) override; - - bool drawPolygonBezier(sal_uInt32 nPoints, const Point* pPointArray, - const PolyFlags* pFlagArray) override; - - bool drawPolyPolygonBezier(sal_uInt32 nPoly, const sal_uInt32* pPoints, - const Point* const* pPointArray, - const PolyFlags* const* pFlagArray) override; - - void copyArea(tools::Long nDestX, tools::Long nDestY, tools::Long nSrcX, tools::Long nSrcY, - tools::Long nSrcWidth, tools::Long nSrcHeight, bool bWindowInvalidate) override; - - void copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics) override; - - void drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap) override; - - void drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap, - const SalBitmap& rMaskBitmap) override; - - void drawMask(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap, - Color nMaskColor) override; - - std::shared_ptr<SalBitmap> getBitmap(tools::Long nX, tools::Long nY, tools::Long nWidth, - tools::Long nHeight) override; - - Color getPixel(tools::Long nX, tools::Long nY) override; - - void invert(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, - SalInvert nFlags) override; - - void invert(sal_uInt32 nPoints, const Point* pPtAry, SalInvert nFlags) override; - - bool drawEPS(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, - void* pPtr, sal_uInt32 nSize) override; - - bool blendBitmap(const SalTwoRect&, const SalBitmap& rBitmap) override; - - bool blendAlphaBitmap(const SalTwoRect&, const SalBitmap& rSrcBitmap, - const SalBitmap& rMaskBitmap, const SalBitmap& rAlphaBitmap) override; - - bool drawAlphaBitmap(const SalTwoRect&, const SalBitmap& rSourceBitmap, - const SalBitmap& rAlphaBitmap) override; - - bool drawTransformedBitmap(const basegfx::B2DPoint& rNull, const basegfx::B2DPoint& rX, - const basegfx::B2DPoint& rY, const SalBitmap& rSourceBitmap, - const SalBitmap* pAlphaBitmap, double fAlpha) override; - - bool hasFastDrawTransformedBitmap() const override; - - bool drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, - sal_uInt8 nTransparency) override; - - bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) override; - bool implDrawGradient(basegfx::B2DPolyPolygon const& rPolyPolygon, - SalGradient const& rGradient) override; - - bool supportsOperation(OutDevSupportType eType) const override; -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/generic/print/GenPspGfxBackend.cxx b/vcl/unx/generic/print/GenPspGfxBackend.cxx deleted file mode 100644 index 7b99553b64d6..000000000000 --- a/vcl/unx/generic/print/GenPspGfxBackend.cxx +++ /dev/null @@ -1,410 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - */ - -#include <unx/GenPspGfxBackend.hxx> -#include <unx/printergfx.hxx> -#include <vcl/BitmapReadAccess.hxx> -#include <salbmp.hxx> - -// ----- Implementation of PrinterBmp by means of SalBitmap/BitmapBuffer --------------- - -namespace -{ -class SalPrinterBmp : public psp::PrinterBmp -{ -private: - BitmapBuffer* mpBmpBuffer; - - FncGetPixel mpFncGetPixel; - Scanline mpScanAccess; - sal_PtrDiff mnScanOffset; - -public: - explicit SalPrinterBmp(BitmapBuffer* pBitmap); - - virtual sal_uInt32 GetPaletteColor(sal_uInt32 nIdx) const override; - virtual sal_uInt32 GetPaletteEntryCount() const override; - virtual sal_uInt32 GetPixelRGB(sal_uInt32 nRow, sal_uInt32 nColumn) const override; - virtual sal_uInt8 GetPixelGray(sal_uInt32 nRow, sal_uInt32 nColumn) const override; - virtual sal_uInt8 GetPixelIdx(sal_uInt32 nRow, sal_uInt32 nColumn) const override; - virtual sal_uInt32 GetDepth() const override; -}; -} - -SalPrinterBmp::SalPrinterBmp(BitmapBuffer* pBuffer) - : mpBmpBuffer(pBuffer) -{ - assert(mpBmpBuffer && "SalPrinterBmp::SalPrinterBmp () can't acquire Bitmap"); - - // calibrate scanline buffer - if (mpBmpBuffer->mnFormat & ScanlineFormat::TopDown) - { - mpScanAccess = mpBmpBuffer->mpBits; - mnScanOffset = mpBmpBuffer->mnScanlineSize; - } - else - { - mpScanAccess - = mpBmpBuffer->mpBits + (mpBmpBuffer->mnHeight - 1) * mpBmpBuffer->mnScanlineSize; - mnScanOffset = -mpBmpBuffer->mnScanlineSize; - } - - // request read access to the pixels - mpFncGetPixel = BitmapReadAccess::GetPixelFunction(mpBmpBuffer->mnFormat); -} - -sal_uInt32 SalPrinterBmp::GetDepth() const -{ - sal_uInt32 nDepth; - - switch (mpBmpBuffer->mnBitCount) - { - case 1: - nDepth = 1; - break; - - case 4: - case 8: - nDepth = 8; - break; - - case 24: - case 32: - nDepth = 24; - break; - - default: - nDepth = 1; - assert(false && "Error: unsupported bitmap depth in SalPrinterBmp::GetDepth()"); - break; - } - - return nDepth; -} - -sal_uInt32 SalPrinterBmp::GetPaletteEntryCount() const -{ - return mpBmpBuffer->maPalette.GetEntryCount(); -} - -sal_uInt32 SalPrinterBmp::GetPaletteColor(sal_uInt32 nIdx) const -{ - BitmapColor aColor(mpBmpBuffer->maPalette[nIdx]); - - return ((aColor.GetBlue()) & 0x000000ff) | ((aColor.GetGreen() << 8) & 0x0000ff00) - | ((aColor.GetRed() << 16) & 0x00ff0000); -} - -sal_uInt32 SalPrinterBmp::GetPixelRGB(sal_uInt32 nRow, sal_uInt32 nColumn) const -{ - Scanline pScan = mpScanAccess + nRow * mnScanOffset; - BitmapColor aColor = mpFncGetPixel(pScan, nColumn, mpBmpBuffer->maColorMask); - - if (!!mpBmpBuffer->maPalette) - GetPaletteColor(aColor.GetIndex()); - - return ((aColor.GetBlue()) & 0x000000ff) | ((aColor.GetGreen() << 8) & 0x0000ff00) - | ((aColor.GetRed() << 16) & 0x00ff0000); -} - -sal_uInt8 SalPrinterBmp::GetPixelGray(sal_uInt32 nRow, sal_uInt32 nColumn) const -{ - Scanline pScan = mpScanAccess + nRow * mnScanOffset; - BitmapColor aColor = mpFncGetPixel(pScan, nColumn, mpBmpBuffer->maColorMask); - - if (!!mpBmpBuffer->maPalette) - aColor = mpBmpBuffer->maPalette[aColor.GetIndex()]; - - return (aColor.GetBlue() * 28UL + aColor.GetGreen() * 151UL + aColor.GetRed() * 77UL) >> 8; -} - -sal_uInt8 SalPrinterBmp::GetPixelIdx(sal_uInt32 nRow, sal_uInt32 nColumn) const -{ - Scanline pScan = mpScanAccess + nRow * mnScanOffset; - BitmapColor aColor = mpFncGetPixel(pScan, nColumn, mpBmpBuffer->maColorMask); - - if (!!mpBmpBuffer->maPalette) - return aColor.GetIndex(); - else - return 0; -} - -GenPspGfxBackend::GenPspGfxBackend(psp::PrinterGfx* pPrinterGfx) - : m_pPrinterGfx(pPrinterGfx) -{ -} - -GenPspGfxBackend::~GenPspGfxBackend() {} - -void GenPspGfxBackend::Init() {} -void GenPspGfxBackend::freeResources() {} - -void GenPspGfxBackend::setClipRegion(vcl::Region const& rRegion) -{ - // TODO: support polygonal clipregions here - RectangleVector aRectangles; - rRegion.GetRegionRectangles(aRectangles); - m_pPrinterGfx->BeginSetClipRegion(); - - for (auto const& rectangle : aRectangles) - { - const tools::Long nWidth(rectangle.GetWidth()); - const tools::Long nHeight(rectangle.GetHeight()); - - if (nWidth && nHeight) - { - m_pPrinterGfx->UnionClipRegion(rectangle.Left(), rectangle.Top(), nWidth, nHeight); - } - } - - m_pPrinterGfx->EndSetClipRegion(); -} - -void GenPspGfxBackend::ResetClipRegion() { m_pPrinterGfx->ResetClipRegion(); } - -sal_uInt16 GenPspGfxBackend::GetBitCount() const { return m_pPrinterGfx->GetBitCount(); } - -tools::Long GenPspGfxBackend::GetGraphicsWidth() const { return 0; } - -void GenPspGfxBackend::SetLineColor() { m_pPrinterGfx->SetLineColor(); } - -void GenPspGfxBackend::SetLineColor(Color nColor) -{ - psp::PrinterColor aColor(nColor.GetRed(), nColor.GetGreen(), nColor.GetBlue()); - m_pPrinterGfx->SetLineColor(aColor); -} - -void GenPspGfxBackend::SetFillColor() { m_pPrinterGfx->SetFillColor(); } - -void GenPspGfxBackend::SetFillColor(Color nColor) -{ - psp::PrinterColor aColor(nColor.GetRed(), nColor.GetGreen(), nColor.GetBlue()); - m_pPrinterGfx->SetFillColor(aColor); -} - -void GenPspGfxBackend::SetXORMode(bool bSet, bool /*bInvertOnly*/) -{ - SAL_WARN_IF(bSet, "vcl", "Error: PrinterGfx::SetXORMode() not implemented"); -} - -void GenPspGfxBackend::SetROPLineColor(SalROPColor /*nROPColor*/) -{ - SAL_WARN("vcl", "Error: PrinterGfx::SetROPLineColor() not implemented"); -} - -void GenPspGfxBackend::SetROPFillColor(SalROPColor /*nROPColor*/) -{ - SAL_WARN("vcl", "Error: PrinterGfx::SetROPFillColor() not implemented"); -} - -void GenPspGfxBackend::drawPixel(tools::Long nX, tools::Long nY) -{ - m_pPrinterGfx->DrawPixel(Point(nX, nY)); -} -void GenPspGfxBackend::drawPixel(tools::Long nX, tools::Long nY, Color nColor) -{ - psp::PrinterColor aColor(nColor.GetRed(), nColor.GetGreen(), nColor.GetBlue()); - m_pPrinterGfx->DrawPixel(Point(nX, nY), aColor); -} - -void GenPspGfxBackend::drawLine(tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2) -{ - m_pPrinterGfx->DrawLine(Point(nX1, nY1), Point(nX2, nY2)); -} -void GenPspGfxBackend::drawRect(tools::Long nX, tools::Long nY, tools::Long nWidth, - tools::Long nHeight) -{ - m_pPrinterGfx->DrawRect(tools::Rectangle(Point(nX, nY), Size(nWidth, nHeight))); -} - -void GenPspGfxBackend::drawPolyLine(sal_uInt32 nPoints, const Point* pPointArray) -{ - m_pPrinterGfx->DrawPolyLine(nPoints, pPointArray); -} - -void GenPspGfxBackend::drawPolygon(sal_uInt32 nPoints, const Point* pPointArray) -{ - // Point must be equal to Point! see include/vcl/salgtype.hxx - m_pPrinterGfx->DrawPolygon(nPoints, pPointArray); -} - -void GenPspGfxBackend::drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32* pPoints, - const Point** pPointArray) -{ - m_pPrinterGfx->DrawPolyPolygon(nPoly, pPoints, pPointArray); -} - -bool GenPspGfxBackend::drawPolyPolygon(const basegfx::B2DHomMatrix& /*rObjectToDevice*/, - const basegfx::B2DPolyPolygon&, double /*fTransparency*/) -{ - // TODO: implement and advertise OutDevSupportType::B2DDraw support - return false; -} - -bool GenPspGfxBackend::drawPolyLine(const basegfx::B2DHomMatrix& /*rObjectToDevice*/, - const basegfx::B2DPolygon& /*rPolygon*/, - double /*fTransparency*/, double /*fLineWidth*/, - const std::vector<double>* /*pStroke*/, basegfx::B2DLineJoin, - css::drawing::LineCap, double /*fMiterMinimumAngle*/, - bool /*bPixelSnapHairline*/) -{ - // TODO: a PS printer can draw B2DPolyLines almost directly - return false; -} - -bool GenPspGfxBackend::drawPolyLineBezier(sal_uInt32 nPoints, const Point* pPointArray, - const PolyFlags* pFlagArray) -{ - m_pPrinterGfx->DrawPolyLineBezier(nPoints, pPointArray, pFlagArray); - return true; -} - -bool GenPspGfxBackend::drawPolygonBezier(sal_uInt32 nPoints, const Point* pPointArray, - const PolyFlags* pFlagArray) -{ - m_pPrinterGfx->DrawPolygonBezier(nPoints, pPointArray, pFlagArray); - return true; -} - -bool GenPspGfxBackend::drawPolyPolygonBezier(sal_uInt32 nPoly, const sal_uInt32* pPoints, - const Point* const* pPointArray, - const PolyFlags* const* pFlagArray) -{ - // Point must be equal to Point! see include/vcl/salgtype.hxx - m_pPrinterGfx->DrawPolyPolygonBezier(nPoly, pPoints, pPointArray, pFlagArray); - return true; -} - -void GenPspGfxBackend::copyArea(tools::Long /*nDestX*/, tools::Long /*nDestY*/, - tools::Long /*nSrcX*/, tools::Long /*nSrcY*/, - tools::Long /*nSrcWidth*/, tools::Long /*nSrcHeight*/, - bool /*bWindowInvalidate*/) -{ - OSL_FAIL("Error: PrinterGfx::CopyArea() not implemented"); -} - -void GenPspGfxBackend::copyBits(const SalTwoRect& /*rPosAry*/, SalGraphics* /*pSrcGraphics*/) -{ - OSL_FAIL("Error: PrinterGfx::CopyBits() not implemented"); -} - -void GenPspGfxBackend::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap) -{ - tools::Rectangle aSrc(Point(rPosAry.mnSrcX, rPosAry.mnSrcY), - Size(rPosAry.mnSrcWidth, rPosAry.mnSrcHeight)); - - tools::Rectangle aDst(Point(rPosAry.mnDestX, rPosAry.mnDestY), - Size(rPosAry.mnDestWidth, rPosAry.mnDestHeight)); - - BitmapBuffer* pBuffer - = const_cast<SalBitmap&>(rSalBitmap).AcquireBuffer(BitmapAccessMode::Read); - - SalPrinterBmp aBmp(pBuffer); - m_pPrinterGfx->DrawBitmap(aDst, aSrc, aBmp); - - const_cast<SalBitmap&>(rSalBitmap).ReleaseBuffer(pBuffer, BitmapAccessMode::Read); -} - -void GenPspGfxBackend::drawBitmap(const SalTwoRect& /*rPosAry*/, const SalBitmap& /*rSalBitmap*/, - const SalBitmap& /*rMaskBitmap*/) -{ - OSL_FAIL("Error: no PrinterGfx::DrawBitmap() for transparent bitmap"); -} - -void GenPspGfxBackend::drawMask(const SalTwoRect& /*rPosAry*/, const SalBitmap& /*rSalBitmap*/, - Color /*nMaskColor*/) -{ - OSL_FAIL("Error: PrinterGfx::DrawMask() not implemented"); -} - -std::shared_ptr<SalBitmap> GenPspGfxBackend::getBitmap(tools::Long /*nX*/, tools::Long /*nY*/, - tools::Long /*nWidth*/, - tools::Long /*nHeight*/) -{ - SAL_INFO("vcl", "Warning: PrinterGfx::GetBitmap() not implemented"); - return nullptr; -} - -Color GenPspGfxBackend::getPixel(tools::Long /*nX*/, tools::Long /*nY*/) -{ - OSL_FAIL("Warning: PrinterGfx::GetPixel() not implemented"); - return Color(); -} - -void GenPspGfxBackend::invert(tools::Long /*nX*/, tools::Long /*nY*/, tools::Long /*nWidth*/, - tools::Long /*nHeight*/, SalInvert /*nFlags*/) -{ - OSL_FAIL("Warning: PrinterGfx::Invert() not implemented"); -} - -void GenPspGfxBackend::invert(sal_uInt32 /*nPoints*/, const Point* /*pPtAry*/, SalInvert /*nFlags*/) -{ - SAL_WARN("vcl", "Error: PrinterGfx::Invert() not implemented"); -} - -bool GenPspGfxBackend::drawEPS(tools::Long nX, tools::Long nY, tools::Long nWidth, - tools::Long nHeight, void* pPtr, sal_uInt32 nSize) -{ - return m_pPrinterGfx->DrawEPS(tools::Rectangle(Point(nX, nY), Size(nWidth, nHeight)), pPtr, - nSize); -} - -bool GenPspGfxBackend::blendBitmap(const SalTwoRect& /*rPosAry*/, const SalBitmap& /*rBitmap*/) -{ - return false; -} - -bool GenPspGfxBackend::blendAlphaBitmap(const SalTwoRect& /*rPosAry*/, - const SalBitmap& /*rSrcBitmap*/, - const SalBitmap& /*rMaskBitmap*/, - const SalBitmap& /*rAlphaBitmap*/) -{ - return false; -} - -bool GenPspGfxBackend::drawAlphaBitmap(const SalTwoRect& /*rPosAry*/, - const SalBitmap& /*rSourceBitmap*/, - const SalBitmap& /*rAlphaBitmap*/) -{ - return false; -} - -bool GenPspGfxBackend::drawTransformedBitmap(const basegfx::B2DPoint& /*rNull*/, - const basegfx::B2DPoint& /*rX*/, - const basegfx::B2DPoint& /*rY*/, - const SalBitmap& /*rSourceBitmap*/, - const SalBitmap* /*pAlphaBitmap*/, double /*fAlpha*/) -{ - return false; -} - -bool GenPspGfxBackend::hasFastDrawTransformedBitmap() const { return false; } - -bool GenPspGfxBackend::drawAlphaRect(tools::Long /*nX*/, tools::Long /*nY*/, tools::Long /*nWidth*/, - tools::Long /*nHeight*/, sal_uInt8 /*nTransparency*/) -{ - return false; -} - -bool GenPspGfxBackend::drawGradient(const tools::PolyPolygon& /*rPolygon*/, - const Gradient& /*rGradient*/) -{ - return false; -} - -bool GenPspGfxBackend::implDrawGradient(basegfx::B2DPolyPolygon const& /*rPolyPolygon*/, - SalGradient const& /*rGradient*/) -{ - return false; -} - -bool GenPspGfxBackend::supportsOperation(OutDevSupportType /*eType*/) const { return false; } - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit e7249131dcfb62cbb68ab1797b9591c90ba2e9e1 Author: Khaled Hosny <kha...@libreoffice.org> AuthorDate: Sun Jul 30 07:29:13 2023 +0000 Commit: خالد حسني <kha...@libreoffice.org> CommitDate: Sun Jul 30 20:44:44 2023 +0200 tdf#156230: Use SvpGraphicsBackend in GenPspGraphics We no longer draw to PostScript, so old backend is unneeded. Change-Id: I069ce735b303721be7de6abf69aa26c1b25a9107 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155063 Tested-by: Jenkins Reviewed-by: خالد حسني <kha...@libreoffice.org> diff --git a/vcl/headless/svpprn.cxx b/vcl/headless/svpprn.cxx index a6b448af68d4..b745ba692e65 100644 --- a/vcl/headless/svpprn.cxx +++ b/vcl/headless/svpprn.cxx @@ -176,7 +176,6 @@ SalInfoPrinter* SvpSalInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueIn PrinterInfoManager& rManager( PrinterInfoManager::get() ); PrinterInfo aInfo( rManager.getPrinterInfo( pQueueInfo->maPrinterName ) ); pPrinter->m_aJobData = aInfo; - pPrinter->m_aPrinterGfx.Init( pPrinter->m_aJobData ); if( pJobSetup->GetDriverData() ) JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), diff --git a/vcl/inc/salprn.hxx b/vcl/inc/salprn.hxx index c6c7657310ca..e7d0859263cc 100644 --- a/vcl/inc/salprn.hxx +++ b/vcl/inc/salprn.hxx @@ -23,10 +23,12 @@ #include <i18nutil/paper.hxx> #include <vcl/prntypes.hxx> #include <vcl/dllapi.h> +#include <tools/gen.hxx> #include "salptype.hxx" #include <vector> +#include <optional> class SalGraphics; class SalFrame; diff --git a/vcl/inc/unx/genprn.h b/vcl/inc/unx/genprn.h index 67bf42bf9547..5b022e8e8ee1 100644 --- a/vcl/inc/unx/genprn.h +++ b/vcl/inc/unx/genprn.h @@ -21,7 +21,6 @@ #define INCLUDED_VCL_INC_GENERIC_GENPRN_H #include <jobdata.hxx> -#include <unx/printergfx.hxx> #include <salprn.hxx> class GenPspGraphics; @@ -30,7 +29,6 @@ class VCL_DLLPUBLIC PspSalInfoPrinter : public SalInfoPrinter public: std::unique_ptr<GenPspGraphics> m_pGraphics; psp::JobData m_aJobData; - psp::PrinterGfx m_aPrinterGfx; PspSalInfoPrinter(); virtual ~PspSalInfoPrinter() override; @@ -59,7 +57,6 @@ public: OUString m_aTmpFile; SalInfoPrinter* m_pInfoPrinter; psp::JobData m_aJobData; - psp::PrinterGfx m_aPrinterGfx; sal_uInt32 m_nCopies; bool m_bCollate; bool m_bPdf; diff --git a/vcl/inc/unx/genpspgraphics.h b/vcl/inc/unx/genpspgraphics.h index 1eba26632e99..16cb2bd9d9d2 100644 --- a/vcl/inc/unx/genpspgraphics.h +++ b/vcl/inc/unx/genpspgraphics.h @@ -28,9 +28,9 @@ #include <salgdi.hxx> #include <sallayout.hxx> -#include <unx/GenPspGfxBackend.hxx> #include <unx/cairotextrender.hxx> +#include <headless/SvpGraphicsBackend.hxx> #include <headless/CairoCommon.hxx> namespace vcl::font @@ -39,7 +39,7 @@ class PhysicalFontFace; class PhysicalFontCollection; } -namespace psp { struct JobData; class PrinterGfx; } +namespace psp { struct JobData; } class FreetypeFontInstance; class FontAttributes; @@ -48,18 +48,18 @@ class FontMetricData; class VCL_DLLPUBLIC GenPspGraphics final : public SalGraphicsAutoDelegateToImpl { - std::unique_ptr<GenPspGfxBackend> m_pBackend; psp::JobData* m_pJobData; CairoCommon m_aCairoCommon; CairoTextRender m_aTextRenderImpl; + std::unique_ptr<SvpGraphicsBackend> m_pBackend; public: GenPspGraphics(); virtual ~GenPspGraphics() override; - void Init( psp::JobData* pJob, psp::PrinterGfx* pGfx ); + void Init(psp::JobData* pJob); // helper methods static FontAttributes Info2FontAttributes(const psp::FastPrintFontInfo&); diff --git a/vcl/unx/generic/app/sm.cxx b/vcl/unx/generic/app/sm.cxx index b6a4c4ad474f..3ad2c855a5c4 100644 --- a/vcl/unx/generic/app/sm.cxx +++ b/vcl/unx/generic/app/sm.cxx @@ -32,6 +32,7 @@ #include <rtl/process.h> #include <osl/security.h> +#include <osl/diagnose.h> #include <X11/Xlib.h> #include <X11/Xatom.h> diff --git a/vcl/unx/generic/print/genprnpsp.cxx b/vcl/unx/generic/print/genprnpsp.cxx index 560f0f4ec62f..015493828acb 100644 --- a/vcl/unx/generic/print/genprnpsp.cxx +++ b/vcl/unx/generic/print/genprnpsp.cxx @@ -43,6 +43,7 @@ #include <rtl/ustrbuf.hxx> #include <rtl/ustring.hxx> #include <sal/log.hxx> +#include <osl/file.hxx> #include <utility> #include <vcl/gdimtf.hxx> @@ -270,7 +271,6 @@ void SalGenericInstance::configurePspInfoPrinter(PspSalInfoPrinter *pPrinter, PrinterInfoManager& rManager( PrinterInfoManager::get() ); PrinterInfo aInfo( rManager.getPrinterInfo( pQueueInfo->maPrinterName ) ); pPrinter->m_aJobData = aInfo; - pPrinter->m_aPrinterGfx.Init( pPrinter->m_aJobData ); if( pJobSetup->GetDriverData() ) JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), @@ -396,7 +396,7 @@ SalGraphics* PspSalInfoPrinter::AcquireGraphics() if( ! m_pGraphics ) { m_pGraphics = GetGenericInstance()->CreatePrintGraphics(); - m_pGraphics->Init(&m_aJobData, &m_aPrinterGfx); + m_pGraphics->Init(&m_aJobData); pRet = m_pGraphics.get(); } return pRet; diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx index fc19e018f121..a8f253629de7 100644 --- a/vcl/unx/generic/print/genpspgraphics.cxx +++ b/vcl/unx/generic/print/genpspgraphics.cxx @@ -41,7 +41,6 @@ #include <unx/freetype_glyphcache.hxx> #include <unx/geninst.h> #include <unx/genpspgraphics.h> -#include <unx/printergfx.hxx> #include <langboost.hxx> #include <font/LogicalFontInstance.hxx> #include <fontattributes.hxx> @@ -61,12 +60,12 @@ using namespace psp; GenPspGraphics::GenPspGraphics() : m_pJobData( nullptr ) , m_aTextRenderImpl(m_aCairoCommon) + , m_pBackend(new SvpGraphicsBackend(m_aCairoCommon)) { } -void GenPspGraphics::Init(psp::JobData* pJob, psp::PrinterGfx* pGfx) +void GenPspGraphics::Init(psp::JobData* pJob) { - m_pBackend = std::make_unique<GenPspGfxBackend>(pGfx); m_pJobData = pJob; SetLayout( SalLayoutFlags::NONE ); } diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index a864141de1d1..df7b8fc32e95 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -17,6 +17,7 @@ #include <dndhelper.hxx> #include <osl/process.h> +#include <osl/file.hxx> #include <unx/gtk/gtkdata.hxx> #include <unx/gtk/gtkinst.hxx> #include <unx/genprn.h> commit 45c3bf8bf38fa9b4b8fb5562178956bdfeef147f Author: Khaled Hosny <kha...@libreoffice.org> AuthorDate: Sun Jul 30 06:59:53 2023 +0000 Commit: خالد حسني <kha...@libreoffice.org> CommitDate: Sun Jul 30 20:44:37 2023 +0200 tdf#156230: Use CairoTextRender in GenPspGraphics We no longer draw to PostScript, so old layout implementation is unneeded. Change-Id: Ifd007f8dd7794e348abb863c1c36d5c79ac7e0e2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155062 Tested-by: Jenkins Reviewed-by: خالد حسني <kha...@libreoffice.org> diff --git a/vcl/inc/unx/genpspgraphics.h b/vcl/inc/unx/genpspgraphics.h index 45842cd27441..1eba26632e99 100644 --- a/vcl/inc/unx/genpspgraphics.h +++ b/vcl/inc/unx/genpspgraphics.h @@ -29,6 +29,9 @@ #include <sallayout.hxx> #include <unx/GenPspGfxBackend.hxx> +#include <unx/cairotextrender.hxx> + +#include <headless/CairoCommon.hxx> namespace vcl::font { @@ -48,10 +51,9 @@ class VCL_DLLPUBLIC GenPspGraphics final : public SalGraphicsAutoDelegateToImpl std::unique_ptr<GenPspGfxBackend> m_pBackend; psp::JobData* m_pJobData; - psp::PrinterGfx* m_pPrinterGfx; - rtl::Reference<FreetypeFontInstance> - m_pFreetypeFont[ MAX_FALLBACK ]; + CairoCommon m_aCairoCommon; + CairoTextRender m_aTextRenderImpl; public: GenPspGraphics(); diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx index 412b0121ec40..fc19e018f121 100644 --- a/vcl/unx/generic/print/genpspgraphics.cxx +++ b/vcl/unx/generic/print/genpspgraphics.cxx @@ -60,7 +60,7 @@ using namespace psp; GenPspGraphics::GenPspGraphics() : m_pJobData( nullptr ) - , m_pPrinterGfx( nullptr ) + , m_aTextRenderImpl(m_aCairoCommon) { } @@ -68,7 +68,6 @@ void GenPspGraphics::Init(psp::JobData* pJob, psp::PrinterGfx* pGfx) { m_pBackend = std::make_unique<GenPspGfxBackend>(pGfx); m_pJobData = pJob; - m_pPrinterGfx = pGfx; SetLayout( SalLayoutFlags::NONE ); } @@ -88,114 +87,29 @@ void GenPspGraphics::GetResolution( sal_Int32 &rDPIX, sal_Int32 &rDPIY ) } } -namespace { - -class PspSalLayout : public GenericSalLayout -{ -public: - PspSalLayout(psp::PrinterGfx&, LogicalFontInstance &rFontInstance); - - void InitFont() const final override; - -private: - ::psp::PrinterGfx& mrPrinterGfx; - sal_IntPtr mnFontID; - int mnFontHeight; - int mnFontWidth; - bool mbVertical; - bool mbArtItalic; - bool mbArtBold; -}; - -} - -PspSalLayout::PspSalLayout(::psp::PrinterGfx& rGfx, LogicalFontInstance &rFontInstance) -: GenericSalLayout(rFontInstance) -, mrPrinterGfx(rGfx) -{ - mnFontID = mrPrinterGfx.GetFontID(); - mnFontHeight = mrPrinterGfx.GetFontHeight(); - mnFontWidth = mrPrinterGfx.GetFontWidth(); - mbVertical = mrPrinterGfx.GetFontVertical(); - mbArtItalic = mrPrinterGfx.GetArtificialItalic(); - mbArtBold = mrPrinterGfx.GetArtificialBold(); -} - -void PspSalLayout::InitFont() const -{ - GenericSalLayout::InitFont(); - mrPrinterGfx.SetFont(mnFontID, mnFontHeight, mnFontWidth, - mnOrientation, mbVertical, mbArtItalic, mbArtBold); -} - void GenPspGraphics::DrawTextLayout(const GenericSalLayout& rLayout) { - const GlyphItem* pGlyph; - basegfx::B2DPoint aPos; - int nStart = 0; - while (rLayout.GetNextGlyph(&pGlyph, aPos, nStart)) - m_pPrinterGfx->DrawGlyph(Point(aPos.getX(), aPos.getY()), *pGlyph); + m_aTextRenderImpl.DrawTextLayout(rLayout, *this); } FontCharMapRef GenPspGraphics::GetFontCharMap() const { - if (!m_pFreetypeFont[0]) - return nullptr; - - return m_pFreetypeFont[0]->GetFontFace()->GetFontCharMap(); + return m_aTextRenderImpl.GetFontCharMap(); } bool GenPspGraphics::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const { - if (!m_pFreetypeFont[0]) - return false; - - return m_pFreetypeFont[0]->GetFontFace()->GetFontCapabilities(rFontCapabilities); + return m_aTextRenderImpl.GetFontCapabilities(rFontCapabilities); } void GenPspGraphics::SetFont(LogicalFontInstance *pFontInstance, int nFallbackLevel) { - // release all fonts that are to be overridden - for( int i = nFallbackLevel; i < MAX_FALLBACK; ++i ) - { - // old server side font is no longer referenced - m_pFreetypeFont[i] = nullptr; - } - - // return early if there is no new font - if (!pFontInstance) - return; - - sal_IntPtr nID = pFontInstance->GetFontFace()->GetFontId(); - - const vcl::font::FontSelectPattern& rEntry = pFontInstance->GetFontSelectPattern(); - - // also set the serverside font for layouting - // requesting a font provided by builtin rasterizer - FreetypeFontInstance* pFreetypeFont = static_cast<FreetypeFontInstance*>(pFontInstance); - m_pFreetypeFont[ nFallbackLevel ] = pFreetypeFont; - - // ignore fonts with e.g. corrupted font files - if (!m_pFreetypeFont[nFallbackLevel]->GetFreetypeFont().TestFont()) - m_pFreetypeFont[nFallbackLevel] = nullptr; - - // set the printer font - m_pPrinterGfx->SetFont( nID, - rEntry.mnHeight, - rEntry.mnWidth, - rEntry.mnOrientation, - rEntry.mbVertical, - pFontInstance->NeedsArtificialItalic(), - pFontInstance->NeedsArtificialBold() - ); + m_aTextRenderImpl.SetFont(pFontInstance, nFallbackLevel); } void GenPspGraphics::SetTextColor( Color nColor ) { - psp::PrinterColor aColor (nColor.GetRed(), - nColor.GetGreen(), - nColor.GetBlue()); - m_pPrinterGfx->SetTextColor (aColor); + m_aTextRenderImpl.SetTextColor(nColor); } bool GenPspGraphics::AddTempDevFontHelper( vcl::font::PhysicalFontCollection* pFontCollection, @@ -237,7 +151,7 @@ bool GenPspGraphics::AddTempDevFont( vcl::font::PhysicalFontCollection* pFontCol const OUString& rFileURL, const OUString& rFontName ) { - return AddTempDevFontHelper(pFontCollection, rFileURL, rFontName); + return m_aTextRenderImpl.AddTempDevFont(pFontCollection, rFileURL, rFontName); } void GenPspGraphics::GetDevFontListHelper( vcl::font::PhysicalFontCollection *pFontCollection ) @@ -274,29 +188,22 @@ void GenPspGraphics::GetDevFontListHelper( vcl::font::PhysicalFontCollection *pF void GenPspGraphics::GetDevFontList( vcl::font::PhysicalFontCollection *pFontCollection ) { - GetDevFontListHelper(pFontCollection); + m_aTextRenderImpl.GetDevFontList(pFontCollection); } void GenPspGraphics::ClearDevFontCache() { - FreetypeManager::get().ClearFontCache(); + m_aTextRenderImpl.ClearDevFontCache(); } void GenPspGraphics::GetFontMetric(FontMetricDataRef& rxFontMetric, int nFallbackLevel) { - if (nFallbackLevel >= MAX_FALLBACK) - return; - - if (m_pFreetypeFont[nFallbackLevel]) - m_pFreetypeFont[nFallbackLevel]->GetFreetypeFont().GetFontMetric(rxFontMetric); + m_aTextRenderImpl.GetFontMetric(rxFontMetric, nFallbackLevel); } std::unique_ptr<GenericSalLayout> GenPspGraphics::GetTextLayout(int nFallbackLevel) { - assert(m_pFreetypeFont[nFallbackLevel]); - if (!m_pFreetypeFont[nFallbackLevel]) - return nullptr; - return std::make_unique<PspSalLayout>(*m_pPrinterGfx, *m_pFreetypeFont[nFallbackLevel]); + return m_aTextRenderImpl.GetTextLayout(nFallbackLevel); } FontAttributes GenPspGraphics::Info2FontAttributes( const psp::FastPrintFontInfo& rInfo )