core.git: vcl/headless
vcl/headless/CairoCommon.cxx | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) New commits: commit 81fa9b03ca8175d2be8ff261916d22c54a4d73a3 Author: Caolán McNamara AuthorDate: Sat Mar 16 21:20:20 2024 + Commit: Caolán McNamara CommitDate: Sun Mar 17 22:17:23 2024 +0100 ofz#66825 Out-of-memory Change-Id: Ic3ce086dc6ba3f85824ec1e68d7501f278f758ab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164935 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 9a84903e5483..38b0bf9418df 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -1095,14 +1095,17 @@ bool CairoCommon::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice, cairo_set_line_join(cr, eCairoLineJoin); cairo_set_line_cap(cr, eCairoLineCap); -constexpr int MaxNormalLineWidth = 64; -if (fLineWidth > MaxNormalLineWidth) +constexpr int MaxNormalLineWidthPx = 64; +if (fLineWidth > MaxNormalLineWidthPx) { const double fLineWidthPixel = bObjectToDeviceIsIdentity ? fLineWidth : (rObjectToDevice * basegfx::B2DVector(fLineWidth, 0)).getLength(); -if (fLineWidthPixel > MaxNormalLineWidth) +constexpr double MaxLineWidth = 0x2000; +// if the width is pixels is excessive, or if the actual number is huge, then +// when fuzzing drop it to something small +if (fLineWidthPixel > MaxNormalLineWidthPx || fLineWidth > MaxLineWidth) { SAL_WARN("vcl.gdi", "drawPolyLine, suspicious input line width of: " << fLineWidth << ", will be " << fLineWidthPixel @@ -,8 +1114,8 @@ bool CairoCommon::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice, { basegfx::B2DHomMatrix aObjectToDeviceInv(rObjectToDevice); aObjectToDeviceInv.invert(); -fLineWidth -= (aObjectToDeviceInv * basegfx::B2DVector(MaxNormalLineWidth, 0)).getLength(); +fLineWidth = (aObjectToDeviceInv * basegfx::B2DVector(MaxNormalLineWidthPx, 0)) + .getLength(); fLineWidth = std::min(fLineWidth, 2048.0); } }
core.git: vcl/headless
vcl/headless/CairoCommon.cxx |4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) New commits: commit 0aaf804de48076bd8bed6459b7c40d87eea4535e Author: Caolán McNamara AuthorDate: Sat Mar 16 19:56:28 2024 + Commit: Caolán McNamara CommitDate: Sat Mar 16 22:29:20 2024 +0100 ofz#67408 Build failure use of undeclared identifier 'SVP_CAIRO_ALPHA Change-Id: I546d2d203929702e46bd6de6242d70c21b636885 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164931 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 182a44b9aaf2..9a84903e5483 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -21,9 +21,7 @@ #include #include #include -#ifdef ANDROID -#include // for correct compilation in only android -#endif +#include #include #include #include
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx | 13 + 1 file changed, 1 insertion(+), 12 deletions(-) New commits: commit da6547ff87d384d016619967359fe8bf340d1daf Author: Noel Grandin AuthorDate: Wed Nov 29 09:24:41 2023 +0200 Commit: Noel Grandin CommitDate: Wed Nov 29 09:31:16 2023 +0100 remove fallback code we have had this assert for long enough now to flush out any problems. Change-Id: Ib732ca8d9156feb3c5d071cdbd44ea97875f6d9f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160060 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 093e970e4dfd..5e97de6aa5d6 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -1893,19 +1893,8 @@ std::shared_ptr CairoCommon::getBitmap(tools::Long nX, tools::Long nY { std::shared_ptr pBitmap = std::make_shared(); BitmapPalette aPal; -vcl::PixelFormat ePixelFormat = vcl::PixelFormat::INVALID; assert(GetBitCount() != 1 && "not supported anymore"); -if (GetBitCount() == 1) -{ -ePixelFormat = vcl::PixelFormat::N8_BPP; -aPal.SetEntryCount(2); -aPal[0] = COL_BLACK; -aPal[1] = COL_WHITE; -} -else -{ -ePixelFormat = vcl::PixelFormat::N32_BPP; -} +vcl::PixelFormat ePixelFormat = vcl::PixelFormat::N32_BPP; if (!pBitmap->ImplCreate(Size(nWidth, nHeight), ePixelFormat, aPal, false)) {
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/osx vcl/source vcl/unx vcl/win
vcl/headless/svpprn.cxx | 14 +++--- vcl/inc/jobdata.hxx |2 +- vcl/inc/jobset.h|9 - vcl/osx/salprn.cxx |3 +-- vcl/source/gdi/jobset.cxx | 30 +- vcl/source/gdi/print.cxx|4 +--- vcl/unx/generic/print/genprnpsp.cxx | 18 ++ vcl/unx/generic/printer/jobdata.cxx |6 +++--- vcl/win/gdi/salprn.cxx | 17 ++--- 9 files changed, 38 insertions(+), 65 deletions(-) New commits: commit d97e0458914991214e3d396273862855aff66234 Author: Thorsten Behrens AuthorDate: Mon Oct 1 03:09:35 2018 +0200 Commit: Thorsten Behrens CommitDate: Sun Oct 29 12:21:34 2023 +0100 vcl: no raw pointers For ImplJobSetup. Also, check memcmp mem size more properly Change-Id: Idcf20bf1b51bc2508f3d37e018efd18e591a6099 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/26648 Tested-by: Jenkins Reviewed-by: Thorsten Behrens diff --git a/vcl/headless/svpprn.cxx b/vcl/headless/svpprn.cxx index b745ba692e65..6c40a0fd8d2f 100644 --- a/vcl/headless/svpprn.cxx +++ b/vcl/headless/svpprn.cxx @@ -146,21 +146,13 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData ) } // copy the whole context -if( pJobSetup->GetDriverData() ) -std::free( const_cast(pJobSetup->GetDriverData()) ); sal_uInt32 nBytes; -void* pBuffer = nullptr; +std::unique_ptr pBuffer; if( rData.getStreamBuffer( pBuffer, nBytes ) ) -{ -pJobSetup->SetDriverDataLen( nBytes ); -pJobSetup->SetDriverData( static_cast(pBuffer) ); -} +pJobSetup->SetDriverData( std::move(pBuffer), nBytes ); else -{ -pJobSetup->SetDriverDataLen( 0 ); -pJobSetup->SetDriverData( nullptr ); -} +pJobSetup->SetDriverData( nullptr, 0 ); } // SalInstance diff --git a/vcl/inc/jobdata.hxx b/vcl/inc/jobdata.hxx index ae9db11e69f6..46110057a888 100644 --- a/vcl/inc/jobdata.hxx +++ b/vcl/inc/jobdata.hxx @@ -69,7 +69,7 @@ struct VCL_DLLPUBLIC JobData // creates a new buffer using new // it is up to the user to delete it again -bool getStreamBuffer( void*& pData, sal_uInt32& bytes ); +bool getStreamBuffer( std::unique_ptr& pData, sal_uInt32& bytes ); static bool constructFromStreamBuffer( const void* pData, sal_uInt32 bytes, JobData& rJobData ); }; diff --git a/vcl/inc/jobset.h b/vcl/inc/jobset.h index e3f154254e35..7c0d0b55a4c3 100644 --- a/vcl/inc/jobset.h +++ b/vcl/inc/jobset.h @@ -25,6 +25,7 @@ #include #include #include +#include // see com.sun.star.portal.client.JobSetupSystem.idl: #define JOBSETUP_SYSTEM_WINDOWS 1 @@ -44,7 +45,7 @@ private: tools::LongmnPaperWidth; //< paper width (100th mm) tools::LongmnPaperHeight; //< paper height (100th mm) sal_uInt32 mnDriverDataLen;//< length of system specific data -sal_uInt8* mpDriverData; //< system specific data (will be streamed a byte block) +std::unique_ptr mpDriverData; //< system specific data (will be streamed a byte block) boolmbPapersizeFromSetup; // setup mode PrinterSetupMode meSetupMode; @@ -86,10 +87,8 @@ public: void SetPaperHeight(tools::Long nHeight); sal_uInt32 GetDriverDataLen() const { return mnDriverDataLen; } -void SetDriverDataLen(sal_uInt32 nDriverDataLen); - -const sal_uInt8* GetDriverData() const { return mpDriverData; } -void SetDriverData(sal_uInt8* pDriverData); +const sal_uInt8* GetDriverData() const { return mpDriverData.get(); } +void SetDriverData(std::unique_ptr pDriverData, sal_uInt32 nDriverDataLen); bool GetPapersizeFromSetup() const { return mbPapersizeFromSetup; } void SetPapersizeFromSetup(bool bPapersizeFromSetup); diff --git a/vcl/osx/salprn.cxx b/vcl/osx/salprn.cxx index e9101e390085..9f9c8c08f3db 100644 --- a/vcl/osx/salprn.cxx +++ b/vcl/osx/salprn.cxx @@ -190,8 +190,7 @@ bool AquaSalInfoPrinter::SetPrinterData( ImplJobSetup* io_pSetupData ) io_pSetupData->SetOrientation( mePageOrientation ); io_pSetupData->SetPaperBin( 0 ); -io_pSetupData->SetDriverData( static_cast(std::malloc( 4 )) ); -io_pSetupData->SetDriverDataLen( 4 ); +io_pSetupData->SetDriverData( std::make_unique(4), 4 ); } else bSuccess = false; diff --git a/vcl/source/gdi/jobset.cxx b/vcl/source/gdi/jobset.cxx index 9969a6165327..c9ed0d9626ec 100644 --- a/vcl/source/gdi/jobset.cxx +++ b/vcl/source/gdi/jobset.cxx @@ -65,7 +65,6 @@ ImplJobSetup::ImplJobSetup() mnPaperWidth= 0; mnPaperHeight = 0; mnDriverDataLen = 0; -mpDriverData= nullptr; mbPapersizeFromSetup = false; meSetupMode =
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/CairoCommon.cxx |2 +- vcl/headless/svpbmp.cxx | 14 +++--- vcl/inc/headless/svpbmp.hxx |5 + 3 files changed, 17 insertions(+), 4 deletions(-) New commits: commit 10a4fc18c48bbcf3dbfe802f7c13405cfe737084 Author: Caolán McNamara AuthorDate: Sat Oct 21 19:42:09 2023 +0100 Commit: Caolán McNamara CommitDate: Sun Oct 22 16:39:28 2023 +0200 SvpGraphicsBackend::getBitmap overwrites the buffer so in this case we don't need to memset it to 0 before seen in VclDrawingArea::DumpAsPropertyTree Change-Id: I339677f091e9e6585e5d6e72f467d439efb43cb8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158325 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 4d29e8a1602f..093e970e4dfd 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -1907,7 +1907,7 @@ std::shared_ptr CairoCommon::getBitmap(tools::Long nX, tools::Long nY ePixelFormat = vcl::PixelFormat::N32_BPP; } -if (!pBitmap->Create(Size(nWidth, nHeight), ePixelFormat, aPal)) +if (!pBitmap->ImplCreate(Size(nWidth, nHeight), ePixelFormat, aPal, false)) { SAL_WARN("vcl.gdi", "SvpSalGraphics::getBitmap, cannot create bitmap"); return nullptr; diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx index 9c12fb91d2c1..bb8153fb87ef 100644 --- a/vcl/headless/svpbmp.cxx +++ b/vcl/headless/svpbmp.cxx @@ -46,7 +46,8 @@ SvpSalBitmap::~SvpSalBitmap() static std::unique_ptr ImplCreateDIB( const Size& rSize, vcl::PixelFormat ePixelFormat, -const BitmapPalette& rPal) +const BitmapPalette& rPal, +bool bClear) { if (!rSize.Width() || !rSize.Height()) return nullptr; @@ -125,6 +126,7 @@ static std::unique_ptr ImplCreateDIB( } else #endif +if (bClear) { std::memset(pDIB->mpBits, 0, size); } @@ -143,13 +145,19 @@ void SvpSalBitmap::Create(std::unique_ptr pBuf) mpDIB = std::move(pBuf); } -bool SvpSalBitmap::Create(const Size& rSize, vcl::PixelFormat ePixelFormat, const BitmapPalette& rPal) +bool SvpSalBitmap::ImplCreate(const Size& rSize, vcl::PixelFormat ePixelFormat, + const BitmapPalette& rPal, bool bClear) { Destroy(); -mpDIB = ImplCreateDIB(rSize, ePixelFormat, rPal); +mpDIB = ImplCreateDIB(rSize, ePixelFormat, rPal, bClear); return mpDIB != nullptr; } +bool SvpSalBitmap::Create(const Size& rSize, vcl::PixelFormat ePixelFormat, const BitmapPalette& rPal) +{ +return ImplCreate(rSize, ePixelFormat, rPal, true); +} + bool SvpSalBitmap::Create(const SalBitmap& rBmp) { Destroy(); diff --git a/vcl/inc/headless/svpbmp.hxx b/vcl/inc/headless/svpbmp.hxx index cd90d23e8e22..b7cfdd2e4f6b 100644 --- a/vcl/inc/headless/svpbmp.hxx +++ b/vcl/inc/headless/svpbmp.hxx @@ -32,6 +32,11 @@ public: SvpSalBitmap(); virtual ~SvpSalBitmap() override; +boolImplCreate(const Size& rSize, + vcl::PixelFormat ePixelFormat, + const BitmapPalette& rPalette, + bool bClear); + // SalBitmap virtual boolCreate(const Size& rSize, vcl::PixelFormat ePixelFormat,
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 2a217a80bf383ddab0a5e0959ab2fd907dfd3406 Author: Andrea Gelmini AuthorDate: Wed Oct 4 15:29:42 2023 +0200 Commit: Julien Nabet CommitDate: Wed Oct 4 23:03:24 2023 +0200 Fix typo Change-Id: I9363004f30c6b49da7911ddf1e4bad468d7aa8b3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157555 Tested-by: Jenkins Reviewed-by: Julien Nabet diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 3c57f065da37..4d29e8a1602f 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -775,7 +775,7 @@ void CairoCommon::drawLine(tools::Long nX1, tools::Long nY1, tools::Long nX2, to releaseCairoContext(cr, false, extents); } -// true if we have a fill color and the line color is the same or non-existant +// true if we have a fill color and the line color is the same or non-existent static bool onlyFillRect(const std::optional& rFillColor, const std::optional& rLineColor) {
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx | 15 +-- 1 file changed, 13 insertions(+), 2 deletions(-) New commits: commit fc5cd82fa5bb85495e34a762fdf1db91b5e93d12 Author: Caolán McNamara AuthorDate: Mon Oct 2 17:23:59 2023 +0100 Commit: Caolán McNamara CommitDate: Tue Oct 3 09:29:42 2023 +0200 optimize DrawRect if we fill but no line color because that's the same as if we had line color the same as fill color Change-Id: I540b31c0dcd07dfddbbd9f8cf396f7df3a4edb4b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157498 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index abd024293314..3c57f065da37 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -775,10 +775,21 @@ void CairoCommon::drawLine(tools::Long nX1, tools::Long nY1, tools::Long nX2, to releaseCairoContext(cr, false, extents); } +// true if we have a fill color and the line color is the same or non-existant +static bool onlyFillRect(const std::optional& rFillColor, + const std::optional& rLineColor) +{ +if (!rFillColor) +return false; +if (!rLineColor) +return true; +return *rFillColor == *rLineColor; +} + void CairoCommon::drawRect(double nX, double nY, double nWidth, double nHeight, bool bAntiAlias) { // fast path for the common case of simply creating a solid block of color -if (m_oFillColor && m_oLineColor && m_oFillColor == m_oLineColor) +if (onlyFillRect(m_oFillColor, m_oLineColor)) { double fTransparency = 0; // don't bother trying to draw stuff which is effectively invisible @@ -828,7 +839,7 @@ void CairoCommon::drawRect(double nX, double nY, double nWidth, double nHeight, if (aOrigLineColor) { // need -1 hack to exclude the bottom and right edges to act like wingdi "Rectangle" -// function which is what this was probably the ultimate origin of this behavior +// function which is what was probably the ultimate origin of this behavior basegfx::B2DPolygon aRect = basegfx::utils::createPolygonFromRect( basegfx::B2DRectangle(nX, nY, nX + nWidth - 1, nY + nHeight - 1));
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) New commits: commit 5b2ae79edde95f485e381741f816d45248798778 Author: Noel Grandin AuthorDate: Mon Oct 2 10:55:04 2023 +0200 Commit: Noel Grandin CommitDate: Mon Oct 2 15:38:47 2023 +0200 tdf#157164 Vertical Position preview does not show red line for baseline regression from commit f510ea2d7962a4325055c6380a0032331b4e87cf Author: Noel Grandin Date: Wed Jan 12 11:49:35 2022 +0200 don't bother trying to draw stuff which is effectively invisible Change-Id: Idc947163521ebfb65b27204fb5c65b1f59fe6de3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157481 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 954e29a2026d..abd024293314 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -886,11 +886,16 @@ void CairoCommon::drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice, return; } -// don't bother trying to draw stuff which is effectively invisible -basegfx::B2DRange aPolygonRange = rPolyPolygon.getB2DRange(); -aPolygonRange.transform(rObjectToDevice); -if (aPolygonRange.getWidth() < 0.1 || aPolygonRange.getHeight() < 0.1) -return; +if (!bHasLine) +{ +// don't bother trying to draw stuff which is effectively invisible, speeds up +// drawing some complex drawings. This optimisation is not valid when we do +// the pixel offset thing (i.e. bHasLine) +basegfx::B2DRange aPolygonRange = rPolyPolygon.getB2DRange(); +aPolygonRange.transform(rObjectToDevice); +if (aPolygonRange.getWidth() < 0.1 || aPolygonRange.getHeight() < 0.1) +return; +} cairo_t* cr = getCairoContext(true, bAntiAlias); if (cairo_status(cr) != CAIRO_STATUS_SUCCESS)
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/qt5 vcl/quartz vcl/skia vcl/source vcl/unx vcl/win
vcl/headless/CairoCommon.cxx| 10 ++ vcl/headless/SvpGraphicsBackend.cxx |5 +-- vcl/inc/headless/CairoCommon.hxx|2 - vcl/inc/headless/SvpGraphicsBackend.hxx |2 - vcl/inc/qt5/QtGraphics.hxx |2 - vcl/inc/quartz/salgdi.h |2 - vcl/inc/salgdi.hxx |8 ++--- vcl/inc/salgdiimpl.hxx |2 - vcl/inc/skia/gdiimpl.hxx|2 - vcl/inc/win/salgdi.h|2 - vcl/qt5/QtGraphics_GDI.cxx |9 ++--- vcl/quartz/AquaGraphicsBackend.cxx | 12 +++ vcl/skia/gdiimpl.cxx|7 +--- vcl/source/gdi/salgdilayout.cxx |7 ++-- vcl/source/outdev/line.cxx |3 + vcl/source/outdev/polygon.cxx | 22 +++--- vcl/source/outdev/transparent.cxx | 37 +++- vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx |5 +-- vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx |2 - vcl/win/gdi/gdiimpl.cxx |6 +-- vcl/win/gdi/gdiimpl.hxx |2 - vcl/win/gdi/salgdi_gdiplus.cxx |4 +- 22 files changed, 71 insertions(+), 82 deletions(-) New commits: commit 74963f654768d6f25ac1ea907736731d9a886853 Author: Caolán McNamara AuthorDate: Sun Jul 30 22:03:39 2023 +0100 Commit: Caolán McNamara CommitDate: Mon Jul 31 09:58:28 2023 +0200 all drawPolyPolygon variants return true now since: commit 4998de76ed1da4039e30718941d50d6f1dfe4f82 Date: Sun Jul 30 07:40:48 2023 + tdf#156230: Drop freshly unused GenPspGfxBackend Change-Id: I7fc2a068f80ed392c5d58772d130bf7f51c8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155076 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 417fd633f87e..d1a20ec1624b 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -872,7 +872,7 @@ void CairoCommon::drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32* pPointCoun drawPolyPolygon(basegfx::B2DHomMatrix(), aPolyPoly, 0.0, bAntiAlias); } -bool CairoCommon::drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice, +void CairoCommon::drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice, const basegfx::B2DPolyPolygon& rPolyPolygon, double fTransparency, bool bAntiAlias) { @@ -882,14 +882,14 @@ bool CairoCommon::drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice, if (0 == rPolyPolygon.count() || !(bHasFill || bHasLine) || fTransparency < 0.0 || fTransparency >= 1.0) { -return true; +return; } // don't bother trying to draw stuff which is effectively invisible basegfx::B2DRange aPolygonRange = rPolyPolygon.getB2DRange(); aPolygonRange.transform(rObjectToDevice); if (aPolygonRange.getWidth() < 0.1 || aPolygonRange.getHeight() < 0.1) -return true; +return; cairo_t* cr = getCairoContext(true, bAntiAlias); if (cairo_status(cr) != CAIRO_STATUS_SUCCESS) @@ -897,7 +897,7 @@ bool CairoCommon::drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice, SAL_WARN("vcl.gdi", "cannot render to surface: " << cairo_status_to_string(cairo_status(cr))); releaseCairoContext(cr, true, basegfx::B2DRange()); -return true; +return; } clipRegion(cr); @@ -949,8 +949,6 @@ bool CairoCommon::drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice, // of damage so they can be correctly redrawn extents.transform(rObjectToDevice); releaseCairoContext(cr, true, extents); - -return true; } void CairoCommon::drawPolyLine(sal_uInt32 nPoints, const Point* pPtAry, bool bAntiAlias) diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index dafbe75ff3ca..e8d582b98fcc 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -109,12 +109,11 @@ void SvpGraphicsBackend::drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32* pPo m_rCairoCommon.drawPolyPolygon(nPoly, pPointCounts, pPtAry, getAntiAlias()); } -bool SvpGraphicsBackend::drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice, +void SvpGraphicsBackend::drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice, const basegfx::B2DPolyPolygon& rPolyPolygon, double fTransparency) { -return m_rCairoCommon.drawPolyPolygon(rObjectToDevice, rPolyPolygon, fTransparency, - getAntiAlias()); +
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/CairoCommon.cxx | 45 +-- vcl/inc/headless/CairoCommon.hxx | 15 + 2 files changed, 40 insertions(+), 20 deletions(-) New commits: commit 7be8430702d433ce981d65fdf12e510c1cddda53 Author: Noel Grandin AuthorDate: Wed May 17 15:56:10 2023 +0200 Commit: Noel Grandin CommitDate: Thu May 18 09:16:22 2023 +0200 tdf#63130 reduce duplicated work when pixel snapping Cache the calculations so we don't repeat work unnecessarily. Shaves 5% off load time. Change-Id: Iffbdd08768fea5b25ac83926b812067f52cba3a2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151883 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index d9c77afa1e56..9c67fb079566 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -160,6 +160,7 @@ size_t AddPolygonToPath(cairo_t* cr, const basegfx::B2DPolygon& rPolygon, const bool bObjectToDeviceUsed(!rObjectToDevice.isIdentity()); basegfx::B2DHomMatrix aObjectToDeviceInv; basegfx::B2DPoint aLast; +PixelSnapper aSnapper; for (sal_uInt32 nPointIdx = 0, nPrevIdx = 0;; nPrevIdx = nPointIdx++) { @@ -209,7 +210,7 @@ size_t AddPolygonToPath(cairo_t* cr, const basegfx::B2DPolygon& rPolygon, { // snap horizontal and vertical lines (mainly used in Chart for // 'nicer' AAing) -aPoint = impPixelSnap(rPolygon, rObjectToDevice, aObjectToDeviceInv, nClosedIdx); +aPoint = aSnapper.snap(rPolygon, rObjectToDevice, aObjectToDeviceInv, nClosedIdx); } if (!nPointIdx) @@ -271,32 +272,44 @@ size_t AddPolygonToPath(cairo_t* cr, const basegfx::B2DPolygon& rPolygon, return nSizeMeasure; } -basegfx::B2DPoint impPixelSnap(const basegfx::B2DPolygon& rPolygon, - const basegfx::B2DHomMatrix& rObjectToDevice, - basegfx::B2DHomMatrix& rObjectToDeviceInv, sal_uInt32 nIndex) +basegfx::B2DPoint PixelSnapper::snap(const basegfx::B2DPolygon& rPolygon, + const basegfx::B2DHomMatrix& rObjectToDevice, + basegfx::B2DHomMatrix& rObjectToDeviceInv, sal_uInt32 nIndex) { const sal_uInt32 nCount(rPolygon.count()); // get the data -const basegfx::B2ITuple aPrevTuple( -basegfx::fround(rObjectToDevice * rPolygon.getB2DPoint((nIndex + nCount - 1) % nCount))); -const basegfx::B2DPoint aCurrPoint(rObjectToDevice * rPolygon.getB2DPoint(nIndex)); -const basegfx::B2ITuple aCurrTuple(basegfx::fround(aCurrPoint)); -const basegfx::B2ITuple aNextTuple( -basegfx::fround(rObjectToDevice * rPolygon.getB2DPoint((nIndex + 1) % nCount))); +if (nIndex == 0) +{ +// if it's the first time, we need to calculate everything +maPrevPoint = rObjectToDevice * rPolygon.getB2DPoint((nIndex + nCount - 1) % nCount); +maCurrPoint = rObjectToDevice * rPolygon.getB2DPoint(nIndex); +maPrevTuple = basegfx::fround(maPrevPoint); +maCurrTuple = basegfx::fround(maCurrPoint); +} +else +{ +// but for all other times, we can re-use the previous iteration computations +maPrevPoint = maCurrPoint; +maPrevTuple = maCurrTuple; +maCurrPoint = maNextPoint; +maCurrTuple = maNextTuple; +} +maNextPoint = rObjectToDevice * rPolygon.getB2DPoint((nIndex + 1) % nCount); +maNextTuple = basegfx::fround(maNextPoint); // get the states -const bool bPrevVertical(aPrevTuple.getX() == aCurrTuple.getX()); -const bool bNextVertical(aNextTuple.getX() == aCurrTuple.getX()); -const bool bPrevHorizontal(aPrevTuple.getY() == aCurrTuple.getY()); -const bool bNextHorizontal(aNextTuple.getY() == aCurrTuple.getY()); +const bool bPrevVertical(maPrevTuple.getX() == maCurrTuple.getX()); +const bool bNextVertical(maNextTuple.getX() == maCurrTuple.getX()); +const bool bPrevHorizontal(maPrevTuple.getY() == maCurrTuple.getY()); +const bool bNextHorizontal(maNextTuple.getY() == maCurrTuple.getY()); const bool bSnapX(bPrevVertical || bNextVertical); const bool bSnapY(bPrevHorizontal || bNextHorizontal); if (bSnapX || bSnapY) { -basegfx::B2DPoint aSnappedPoint(bSnapX ? aCurrTuple.getX() : aCurrPoint.getX(), -bSnapY ? aCurrTuple.getY() : aCurrPoint.getY()); +basegfx::B2DPoint aSnappedPoint(bSnapX ? maCurrTuple.getX() : maCurrPoint.getX(), +bSnapY ? maCurrTuple.getY() : maCurrPoint.getY()); if (rObjectToDeviceInv.isIdentity()) { diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx index 6d280d34a955..f7556ede27ae 100644 --- a/vcl/inc/headless/CairoCommon.hxx +++ b/vcl/inc/headless/CairoCommon.hxx @@
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx | 15 +++ 1 file changed, 15 insertions(+) New commits: commit ba63c4199d19b87d53bb167397180fc2d8686ff5 Author: Caolán McNamara AuthorDate: Thu May 11 09:05:48 2023 +0100 Commit: Caolán McNamara CommitDate: Thu May 11 12:56:35 2023 +0200 ofz#58818 Direct-leak Change-Id: I8974b998397aa521c9ee61651b5ce45d4189b303 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151662 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 2b732f627f30..d9c77afa1e56 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -879,6 +879,13 @@ bool CairoCommon::drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice, return true; cairo_t* cr = getCairoContext(true, bAntiAlias); +if (cairo_status(cr) != CAIRO_STATUS_SUCCESS) +{ +SAL_WARN("vcl.gdi", + "cannot render to surface: " << cairo_status_to_string(cairo_status(cr))); +releaseCairoContext(cr, true, basegfx::B2DRange()); +return true; +} clipRegion(cr); // Set full (Object-to-Device) transformation - if used @@ -1648,6 +1655,14 @@ bool CairoCommon::drawAlphaBitmap(const SalTwoRect& rTR, const SalBitmap& rSourc } cairo_t* cr = getCairoContext(false, bAntiAlias); +if (cairo_status(cr) != CAIRO_STATUS_SUCCESS) +{ +SAL_WARN("vcl.gdi", + "cannot render to surface: " << cairo_status_to_string(cairo_status(cr))); +releaseCairoContext(cr, false, basegfx::B2DRange()); +return true; +} + clipRegion(cr); cairo_rectangle(cr, rTR.mnDestX, rTR.mnDestY, rTR.mnDestWidth, rTR.mnDestHeight);
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx |1 + 1 file changed, 1 insertion(+) New commits: commit 6d8b48d63ca46306e5d4e6e9e5e7da67760e1736 Author: Caolán McNamara AuthorDate: Fri Jan 20 11:05:27 2023 + Commit: Caolán McNamara CommitDate: Fri Jan 20 12:31:25 2023 + ofz#54895 Out-of-memory Change-Id: I2faf68d8ed56e7d2b44bc7cae953716ea6dd7172 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145878 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 1a93f405562c..4706c7e344c0 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -1078,6 +1078,7 @@ bool CairoCommon::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice, aObjectToDeviceInv.invert(); fLineWidth = (aObjectToDeviceInv * basegfx::B2DVector(MaxNormalLineWidth, 0)).getLength(); +fLineWidth = std::min(fLineWidth, 2048.0); } } }
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/unx
vcl/headless/CairoCommon.cxx| 78 vcl/headless/SvpGraphicsBackend.cxx | 73 -- vcl/inc/headless/CairoCommon.hxx|4 + vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx | 15 ++-- 4 files changed, 92 insertions(+), 78 deletions(-) New commits: commit 3be24f151076def167c3a551c0e1811d457d2691 Author: Caolán McNamara AuthorDate: Wed Jan 11 14:56:37 2023 + Commit: Caolán McNamara CommitDate: Thu Jan 12 13:52:35 2023 + move drawTransformedBitmap to CairoCommon and reuse for X11CairoSalGraphicsImpl Change-Id: I9b03d2ec973e2dab28358d7e8041b9d26705e700 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145352 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index a646ebd8d67a..1a93f405562c 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -1684,6 +1684,84 @@ bool CairoCommon::drawAlphaBitmap(const SalTwoRect& rTR, const SalBitmap& rSourc return true; } +bool CairoCommon::drawTransformedBitmap(const basegfx::B2DPoint& rNull, const basegfx::B2DPoint& rX, +const basegfx::B2DPoint& rY, const SalBitmap& rSourceBitmap, +const SalBitmap* pAlphaBitmap, double fAlpha, +bool bAntiAlias) +{ +if (pAlphaBitmap && pAlphaBitmap->GetBitCount() != 8 && pAlphaBitmap->GetBitCount() != 1) +{ +SAL_WARN("vcl.gdi", "unsupported SvpSalGraphics::drawTransformedBitmap alpha depth case: " +<< pAlphaBitmap->GetBitCount()); +return false; +} + +if (fAlpha != 1.0) +return false; + +// MM02 try to access buffered BitmapHelper +std::shared_ptr aSurface; +tryToUseSourceBuffer(rSourceBitmap, aSurface); +const tools::Long nDestWidth(basegfx::fround(basegfx::B2DVector(rX - rNull).getLength())); +const tools::Long nDestHeight(basegfx::fround(basegfx::B2DVector(rY - rNull).getLength())); +cairo_surface_t* source(aSurface->getSurface(nDestWidth, nDestHeight)); + +if (!source) +{ +SAL_WARN("vcl.gdi", "unsupported SvpSalGraphics::drawTransformedBitmap case"); +return false; +} + +// MM02 try to access buffered MaskHelper +std::shared_ptr aMask; +if (nullptr != pAlphaBitmap) +{ +tryToUseMaskBuffer(*pAlphaBitmap, aMask); +} + +// access cairo_surface_t from MaskHelper +cairo_surface_t* mask(nullptr); +if (aMask) +{ +mask = aMask->getSurface(nDestWidth, nDestHeight); +} + +if (nullptr != pAlphaBitmap && nullptr == mask) +{ +SAL_WARN("vcl.gdi", "unsupported SvpSalGraphics::drawTransformedBitmap case"); +return false; +} + +const Size aSize = rSourceBitmap.GetSize(); +cairo_t* cr = getCairoContext(false, bAntiAlias); +clipRegion(cr); + +// setup the image transformation +// using the rNull,rX,rY points as destinations for the (0,0),(0,Width),(Height,0) source points +const basegfx::B2DVector aXRel = rX - rNull; +const basegfx::B2DVector aYRel = rY - rNull; +cairo_matrix_t matrix; +cairo_matrix_init(, aXRel.getX() / aSize.Width(), aXRel.getY() / aSize.Width(), + aYRel.getX() / aSize.Height(), aYRel.getY() / aSize.Height(), rNull.getX(), + rNull.getY()); + +cairo_transform(cr, ); + +cairo_rectangle(cr, 0, 0, aSize.Width(), aSize.Height()); +basegfx::B2DRange extents = getClippedFillDamage(cr); +cairo_clip(cr); + +cairo_set_source_surface(cr, source, 0, 0); +if (mask) +cairo_mask_surface(cr, mask, 0, 0); +else +cairo_paint(cr); + +releaseCairoContext(cr, false, extents); + +return true; +} + void CairoCommon::drawMask(const SalTwoRect& rTR, const SalBitmap& rSalBitmap, Color nMaskColor, bool bAntiAlias) { diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 0f053bb28c17..dafbe75ff3ca 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -253,77 +253,8 @@ bool SvpGraphicsBackend::drawTransformedBitmap(const basegfx::B2DPoint& rNull, const SalBitmap& rSourceBitmap, const SalBitmap* pAlphaBitmap, double fAlpha) { -if (pAlphaBitmap && pAlphaBitmap->GetBitCount() != 8 && pAlphaBitmap->GetBitCount() != 1) -{ -SAL_WARN("vcl.gdi", "unsupported SvpSalGraphics::drawTransformedBitmap alpha depth case: " -<< pAlphaBitmap->GetBitCount()); -return false; -} - -if (fAlpha != 1.0) -return false; - -// MM02 try to access buffered BitmapHelper -std::shared_ptr
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/CairoCommon.cxx|7 +++ vcl/headless/SvpGraphicsBackend.cxx |7 +-- vcl/inc/headless/CairoCommon.hxx|2 ++ 3 files changed, 10 insertions(+), 6 deletions(-) New commits: commit ef5eed8e85490c2f45700bbc31bff3f729966ab2 Author: Caolán McNamara AuthorDate: Tue Jan 10 15:42:42 2023 + Commit: Caolán McNamara CommitDate: Wed Jan 11 10:03:54 2023 + move GetBitCount into CairoCommon Change-Id: I1afc900ec10a9a8f5db29400666fcc78d7bc8f48 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145286 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index fe5f60021aa6..12f42313081b 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -400,6 +400,13 @@ cairo_user_data_key_t* CairoCommon::getDamageKey() return } +sal_uInt16 CairoCommon::GetBitCount() const +{ +if (cairo_surface_get_content(m_pSurface) != CAIRO_CONTENT_COLOR_ALPHA) +return 1; +return 32; +} + cairo_t* CairoCommon::getCairoContext(bool bXorModeAllowed, bool bAntiAlias) const { cairo_t* cr; diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 9a4ef1fc734d..f6674925815e 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -41,12 +41,7 @@ void SvpGraphicsBackend::setClipRegion(const vcl::Region& i_rClip) void SvpGraphicsBackend::ResetClipRegion() { m_rCairoCommon.m_aClipRegion.SetNull(); } -sal_uInt16 SvpGraphicsBackend::GetBitCount() const -{ -if (cairo_surface_get_content(m_rCairoCommon.m_pSurface) != CAIRO_CONTENT_COLOR_ALPHA) -return 1; -return 32; -} +sal_uInt16 SvpGraphicsBackend::GetBitCount() const { return m_rCairoCommon.GetBitCount(); } tools::Long SvpGraphicsBackend::GetGraphicsWidth() const { diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx index ea041a91187c..733118fbd0c0 100644 --- a/vcl/inc/headless/CairoCommon.hxx +++ b/vcl/inc/headless/CairoCommon.hxx @@ -143,6 +143,8 @@ struct VCL_DLLPUBLIC CairoCommon cairo_surface_t* getSurface() const { return m_pSurface; } +sal_uInt16 GetBitCount() const; + cairo_t* getCairoContext(bool bXorModeAllowed, bool bAntiAlias) const; void releaseCairoContext(cairo_t* cr, bool bXorModeAllowed, const basegfx::B2DRange& rExtents) const;
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/unx
vcl/headless/CairoCommon.cxx| 20 ++ vcl/headless/SvpGraphicsBackend.cxx | 13 - vcl/inc/headless/CairoCommon.hxx|5 vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx | 11 + vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx |5 vcl/unx/generic/gdi/gdiimpl.cxx | 195 vcl/unx/generic/gdi/gdiimpl.hxx | 20 -- 7 files changed, 44 insertions(+), 225 deletions(-) New commits: commit cb4cdde132839a232d152b701a147188de8ffc76 Author: Caolán McNamara AuthorDate: Tue Jan 10 09:27:26 2023 + Commit: Caolán McNamara CommitDate: Tue Jan 10 19:56:43 2023 + move invert into CairoCommon and reuse from X11CairoSalGraphicsImpl Change-Id: I4fb52ed1a9d6d9405a76f5d06ca0770bf9b750e6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145256 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 513d94fc4735..fe5f60021aa6 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -1557,6 +1557,26 @@ void CairoCommon::invert(const basegfx::B2DPolygon& rPoly, SalInvert nFlags, boo releaseCairoContext(cr, false, extents); } +void CairoCommon::invert(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, + SalInvert nFlags, bool bAntiAlias) +{ +basegfx::B2DPolygon aRect = basegfx::utils::createPolygonFromRect( +basegfx::B2DRectangle(nX, nY, nX + nWidth, nY + nHeight)); + +invert(aRect, nFlags, bAntiAlias); +} + +void CairoCommon::invert(sal_uInt32 nPoints, const Point* pPtAry, SalInvert nFlags, bool bAntiAlias) +{ +basegfx::B2DPolygon aPoly; +aPoly.append(basegfx::B2DPoint(pPtAry->getX(), pPtAry->getY()), nPoints); +for (sal_uInt32 i = 1; i < nPoints; ++i) +aPoly.setB2DPoint(i, basegfx::B2DPoint(pPtAry[i].getX(), pPtAry[i].getY())); +aPoly.setClosed(true); + +invert(aPoly, nFlags, bAntiAlias); +} + cairo_format_t getCairoFormat(const BitmapBuffer& rBuffer) { cairo_format_t nFormat; diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 6b63f2509eda..9a4ef1fc734d 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -348,21 +348,12 @@ Color SvpGraphicsBackend::getPixel(tools::Long nX, tools::Long nY) void SvpGraphicsBackend::invert(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, SalInvert nFlags) { -basegfx::B2DPolygon aRect = basegfx::utils::createPolygonFromRect( -basegfx::B2DRectangle(nX, nY, nX + nWidth, nY + nHeight)); - -m_rCairoCommon.invert(aRect, nFlags, getAntiAlias()); +m_rCairoCommon.invert(nX, nY, nWidth, nHeight, nFlags, getAntiAlias()); } void SvpGraphicsBackend::invert(sal_uInt32 nPoints, const Point* pPtAry, SalInvert nFlags) { -basegfx::B2DPolygon aPoly; -aPoly.append(basegfx::B2DPoint(pPtAry->getX(), pPtAry->getY()), nPoints); -for (sal_uInt32 i = 1; i < nPoints; ++i) -aPoly.setB2DPoint(i, basegfx::B2DPoint(pPtAry[i].getX(), pPtAry[i].getY())); -aPoly.setClosed(true); - -m_rCairoCommon.invert(aPoly, nFlags, getAntiAlias()); +m_rCairoCommon.invert(nPoints, pPtAry, nFlags, getAntiAlias()); } bool SvpGraphicsBackend::drawEPS(tools::Long /*nX*/, tools::Long /*nY*/, tools::Long /*nWidth*/, diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx index df270b217f3a..ea041a91187c 100644 --- a/vcl/inc/headless/CairoCommon.hxx +++ b/vcl/inc/headless/CairoCommon.hxx @@ -204,6 +204,11 @@ struct VCL_DLLPUBLIC CairoCommon void invert(const basegfx::B2DPolygon& rPoly, SalInvert nFlags, bool bAntiAlias); +void invert(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, +SalInvert nFlags, bool bAntiAlias); + +void invert(sal_uInt32 nPoints, const Point* pPtAry, SalInvert nFlags, bool bAntiAlias); + static cairo_surface_t* createCairoSurface(const BitmapBuffer* pBuffer); static bool supportsOperation(OutDevSupportType eType); diff --git a/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx b/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx index da6845c84eea..c6c4af83039b 100644 --- a/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx +++ b/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx @@ -110,6 +110,17 @@ bool X11CairoSalGraphicsImpl::implDrawGradient(basegfx::B2DPolyPolygon const& rP return mrCairoCommon.implDrawGradient(rPolyPolygon, rGradient, getAntiAlias()); } +void X11CairoSalGraphicsImpl::invert(tools::Long nX, tools::Long nY, tools::Long nWidth, + tools::Long nHeight, SalInvert nFlags) +{ +mrCairoCommon.invert(nX, nY, nWidth, nHeight, nFlags, getAntiAlias()); +} + +void X11CairoSalGraphicsImpl::invert(sal_uInt32
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/unx
vcl/headless/CairoCommon.cxx| 37 vcl/headless/SvpGraphicsBackend.cxx | 30 ++- vcl/inc/headless/CairoCommon.hxx|4 ++ vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx | 18 +++ 4 files changed, 63 insertions(+), 26 deletions(-) New commits: commit 4a652c4b75c1cde920cd7d13d63b38c5c155be07 Author: Caolán McNamara AuthorDate: Mon Jan 9 20:48:49 2023 + Commit: Caolán McNamara CommitDate: Tue Jan 10 19:56:21 2023 + reuse ROP and XOR solutions Change-Id: I52ba669921a4145f02c69ff90e0d8668c4698ad5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145255 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index fb25d6a2c391..513d94fc4735 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -634,6 +634,43 @@ void CairoCommon::clipRegion(cairo_t* cr, const vcl::Region& rClipRegion) void CairoCommon::clipRegion(cairo_t* cr) { CairoCommon::clipRegion(cr, m_aClipRegion); } +void CairoCommon::SetXORMode(bool bSet, bool /*bInvertOnly*/) +{ +m_ePaintMode = bSet ? PaintMode::Xor : PaintMode::Over; +} + +void CairoCommon::SetROPLineColor(SalROPColor nROPColor) +{ +switch (nROPColor) +{ +case SalROPColor::N0: +m_oLineColor = Color(0, 0, 0); +break; +case SalROPColor::N1: +m_oLineColor = Color(0xff, 0xff, 0xff); +break; +case SalROPColor::Invert: +m_oLineColor = Color(0xff, 0xff, 0xff); +break; +} +} + +void CairoCommon::SetROPFillColor(SalROPColor nROPColor) +{ +switch (nROPColor) +{ +case SalROPColor::N0: +m_oFillColor = Color(0, 0, 0); +break; +case SalROPColor::N1: +m_oFillColor = Color(0xff, 0xff, 0xff); +break; +case SalROPColor::Invert: +m_oFillColor = Color(0xff, 0xff, 0xff); +break; +} +} + void CairoCommon::drawPixel(const std::optional& rLineColor, tools::Long nX, tools::Long nY, bool bAntiAlias) { diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 56fca50c8eef..6b63f2509eda 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -61,41 +61,19 @@ void SvpGraphicsBackend::SetFillColor() { m_rCairoCommon.m_oFillColor = std::nul void SvpGraphicsBackend::SetFillColor(Color nColor) { m_rCairoCommon.m_oFillColor = nColor; } -void SvpGraphicsBackend::SetXORMode(bool bSet, bool /*bInvertOnly*/) +void SvpGraphicsBackend::SetXORMode(bool bSet, bool bInvertOnly) { -m_rCairoCommon.m_ePaintMode = bSet ? PaintMode::Xor : PaintMode::Over; +m_rCairoCommon.SetXORMode(bSet, bInvertOnly); } void SvpGraphicsBackend::SetROPLineColor(SalROPColor nROPColor) { -switch (nROPColor) -{ -case SalROPColor::N0: -m_rCairoCommon.m_oLineColor = Color(0, 0, 0); -break; -case SalROPColor::N1: -m_rCairoCommon.m_oLineColor = Color(0xff, 0xff, 0xff); -break; -case SalROPColor::Invert: -m_rCairoCommon.m_oLineColor = Color(0xff, 0xff, 0xff); -break; -} +m_rCairoCommon.SetROPLineColor(nROPColor); } void SvpGraphicsBackend::SetROPFillColor(SalROPColor nROPColor) { -switch (nROPColor) -{ -case SalROPColor::N0: -m_rCairoCommon.m_oFillColor = Color(0, 0, 0); -break; -case SalROPColor::N1: -m_rCairoCommon.m_oFillColor = Color(0xff, 0xff, 0xff); -break; -case SalROPColor::Invert: -m_rCairoCommon.m_oFillColor = Color(0xff, 0xff, 0xff); -break; -} +m_rCairoCommon.SetROPFillColor(nROPColor); } void SvpGraphicsBackend::drawPixel(tools::Long nX, tools::Long nY) diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx index b9ba49737e5b..df270b217f3a 100644 --- a/vcl/inc/headless/CairoCommon.hxx +++ b/vcl/inc/headless/CairoCommon.hxx @@ -153,6 +153,10 @@ struct VCL_DLLPUBLIC CairoCommon void clipRegion(cairo_t* cr); static void clipRegion(cairo_t* cr, const vcl::Region& rClipRegion); +void SetXORMode(bool bSet, bool bInvertOnly); +void SetROPLineColor(SalROPColor nROPColor); +void SetROPFillColor(SalROPColor nROPColor); + void drawPixel(const std::optional& rLineColor, tools::Long nX, tools::Long nY, bool bAntiAlias); diff --git a/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx b/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx index f7e3a13287f9..779e4d7eb796 100644 --- a/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx +++ b/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx @@ -68,6 +68,24 @@ public: X11SalGraphicsImpl::SetFillColor(nColor); } +
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/unx
vcl/headless/CairoCommon.cxx| 49 ++ vcl/headless/SvpGraphicsBackend.cxx | 79 +--- vcl/inc/headless/CairoCommon.hxx|5 + vcl/inc/headless/SvpGraphicsBackend.hxx |3 vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx | 12 +++ vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx |2 vcl/unx/generic/gdi/gdiimpl.cxx | 17 - vcl/unx/generic/gdi/gdiimpl.hxx |2 8 files changed, 74 insertions(+), 95 deletions(-) New commits: commit b3566864db77effddb243717dd0d9a1c791383e6 Author: Caolán McNamara AuthorDate: Fri Jan 6 09:43:21 2023 + Commit: Caolán McNamara CommitDate: Sat Jan 7 10:56:03 2023 + move drawRect into CairoCommon and reuse from X11CairoSalGraphicsImpl Change-Id: I1d9f1dc96788530eb6a226a53a67764918348100 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145139 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 56293738d508..8ea358cbdc34 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -687,6 +687,55 @@ void CairoCommon::drawLine(cairo_t* cr, basegfx::B2DRange* pExtents, const Color cairo_stroke(cr); } +void CairoCommon::drawRect(cairo_t* cr, basegfx::B2DRange* pExtents, + const std::optional& rLineColor, + const std::optional& rFillColor, bool bAntiAlias, double nX, + double nY, double nWidth, double nHeight) +{ +// fast path for the common case of simply creating a solid block of color +if (rFillColor && rLineColor && rFillColor == rLineColor) +{ +double fTransparency = 0; +// don't bother trying to draw stuff which is effectively invisible +if (nWidth < 0.1 || nHeight < 0.1) +return; +bool bPixelSnap = !bAntiAlias; +if (bPixelSnap) +{ +// snap by rounding +nX = basegfx::fround(nX); +nY = basegfx::fround(nY); +nWidth = basegfx::fround(nWidth); +nHeight = basegfx::fround(nHeight); +} +cairo_rectangle(cr, nX, nY, nWidth, nHeight); +CairoCommon::applyColor(cr, *rFillColor, fTransparency); +if (pExtents) +{ +// Get FillDamage +*pExtents = getClippedFillDamage(cr); +} +cairo_fill(cr); +return; +} +// because of the -1 hack we have to do fill and draw separately +if (rFillColor) +{ +basegfx::B2DPolygon aRect = basegfx::utils::createPolygonFromRect( +basegfx::B2DRectangle(nX, nY, nX + nWidth, nY + nHeight)); +drawPolyPolygon(cr, pExtents, std::nullopt, rFillColor, bAntiAlias, basegfx::B2DHomMatrix(), +basegfx::B2DPolyPolygon(aRect), 0.0); +} +if (rLineColor) +{ +// need same -1 hack as X11SalGraphicsImpl::drawRect +basegfx::B2DPolygon aRect = basegfx::utils::createPolygonFromRect( +basegfx::B2DRectangle(nX, nY, nX + nWidth - 1, nY + nHeight - 1)); +drawPolyPolygon(cr, pExtents, rLineColor, std::nullopt, bAntiAlias, basegfx::B2DHomMatrix(), +basegfx::B2DPolyPolygon(aRect), 0.0); +} +} + void CairoCommon::drawPolygon(cairo_t* cr, basegfx::B2DRange* pExtents, const std::optional& rLineColor, const std::optional& rFillColor, bool bAntiAlias, diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 87a5a14debd8..1d2f17c44747 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -130,81 +130,14 @@ void SvpGraphicsBackend::drawLine(tools::Long nX1, tools::Long nY1, tools::Long void SvpGraphicsBackend::drawRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight) { -implDrawRect(nX, nY, nWidth, nHeight); -} - -void SvpGraphicsBackend::implDrawRect(double nX, double nY, double nWidth, double nHeight) -{ -// fast path for the common case of simply creating a solid block of color -if (m_rCairoCommon.m_oFillColor && m_rCairoCommon.m_oLineColor -&& m_rCairoCommon.m_oFillColor == m_rCairoCommon.m_oLineColor) -{ -double fTransparency = 0; - -// don't bother trying to draw stuff which is effectively invisible -if (nWidth < 0.1 || nHeight < 0.1) -return; - -cairo_t* cr = m_rCairoCommon.getCairoContext(true, getAntiAlias()); -m_rCairoCommon.clipRegion(cr); - -// To make releaseCairoContext work, use empty extents -basegfx::B2DRange extents; - -bool bPixelSnap = !getAntiAlias(); -if (bPixelSnap) -{ -// snap by rounding -nX = basegfx::fround(nX); -
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/unx
vcl/headless/CairoCommon.cxx| 14 vcl/headless/SvpGraphicsBackend.cxx | 12 ++-- vcl/inc/headless/CairoCommon.hxx|5 + vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx | 10 +++ vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx |2 vcl/unx/generic/gdi/gdiimpl.cxx | 72 vcl/unx/generic/gdi/gdiimpl.hxx |3 - 7 files changed, 38 insertions(+), 80 deletions(-) New commits: commit a6fe91f6e3ddbad65e534907d29243b138258f6c Author: Caolán McNamara AuthorDate: Fri Jan 6 09:16:33 2023 + Commit: Caolán McNamara CommitDate: Fri Jan 6 16:36:23 2023 + move drawPolygon into CairoCommon and reuse from X11CairoSalGraphicsImpl Change-Id: Ifb7514a72f7bc3a65f7f1ad51707405b1a2bd127 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145137 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index b0c7b505f7cc..56293738d508 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -687,6 +687,20 @@ void CairoCommon::drawLine(cairo_t* cr, basegfx::B2DRange* pExtents, const Color cairo_stroke(cr); } +void CairoCommon::drawPolygon(cairo_t* cr, basegfx::B2DRange* pExtents, + const std::optional& rLineColor, + const std::optional& rFillColor, bool bAntiAlias, + sal_uInt32 nPoints, const Point* pPtAry) +{ +basegfx::B2DPolygon aPoly; +aPoly.append(basegfx::B2DPoint(pPtAry->getX(), pPtAry->getY()), nPoints); +for (sal_uInt32 i = 1; i < nPoints; ++i) +aPoly.setB2DPoint(i, basegfx::B2DPoint(pPtAry[i].getX(), pPtAry[i].getY())); + +drawPolyPolygon(cr, pExtents, rLineColor, rFillColor, bAntiAlias, basegfx::B2DHomMatrix(), +basegfx::B2DPolyPolygon(aPoly), 0.0); +} + void CairoCommon::drawPolyPolygon(cairo_t* cr, basegfx::B2DRange* pExtents, const std::optional& rLineColor, const std::optional& rFillColor, bool bAntiAlias, diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 134c9fc221e0..87a5a14debd8 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -221,12 +221,14 @@ void SvpGraphicsBackend::drawPolyLine(sal_uInt32 nPoints, const Point* pPtAry) void SvpGraphicsBackend::drawPolygon(sal_uInt32 nPoints, const Point* pPtAry) { -basegfx::B2DPolygon aPoly; -aPoly.append(basegfx::B2DPoint(pPtAry->getX(), pPtAry->getY()), nPoints); -for (sal_uInt32 i = 1; i < nPoints; ++i) -aPoly.setB2DPoint(i, basegfx::B2DPoint(pPtAry[i].getX(), pPtAry[i].getY())); +cairo_t* cr = m_rCairoCommon.getCairoContext(true, getAntiAlias()); +basegfx::B2DRange extents; +m_rCairoCommon.clipRegion(cr); -drawPolyPolygon(basegfx::B2DHomMatrix(), basegfx::B2DPolyPolygon(aPoly), 0.0); +CairoCommon::drawPolygon(cr, , m_rCairoCommon.m_oLineColor, m_rCairoCommon.m_oFillColor, + getAntiAlias(), nPoints, pPtAry); + +m_rCairoCommon.releaseCairoContext(cr, true, extents); } void SvpGraphicsBackend::drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32* pPointCounts, diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx index 75aec44a4ec7..73a00c54e7e0 100644 --- a/vcl/inc/headless/CairoCommon.hxx +++ b/vcl/inc/headless/CairoCommon.hxx @@ -162,6 +162,11 @@ struct VCL_DLLPUBLIC CairoCommon bool bAntiAlias, tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2); +static void drawPolygon(cairo_t* cr, basegfx::B2DRange* pExtents, +const std::optional& rLineColor, +const std::optional& rFillColor, bool bAntiAlias, +sal_uInt32 nPoints, const Point* pPtAry); + static void drawPolyPolygon(cairo_t* cr, basegfx::B2DRange* pExtents, const std::optional& rLineColor, const std::optional& rFillColor, bool bAntiAlias, diff --git a/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx b/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx index b1afbc25350f..1f900d91b688 100644 --- a/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx +++ b/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx @@ -30,6 +30,16 @@ X11CairoSalGraphicsImpl::X11CairoSalGraphicsImpl(X11SalGraphics& rParent, X11Com { } +void X11CairoSalGraphicsImpl::drawPolygon(sal_uInt32 nPoints, const Point* pPtAry) +{ +cairo_t* cr = mrX11Common.getCairoContext(mrParent.GetGeometryProvider()); +clipRegion(cr); + +CairoCommon::drawPolygon(cr, nullptr, moPenColor, moFillColor, getAntiAlias(), nPoints, pPtAry); + +
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/unx
vcl/headless/CairoCommon.cxx| 14 vcl/headless/SvpGraphicsBackend.cxx | 16 - vcl/inc/headless/CairoCommon.hxx|6 vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx | 10 vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx |4 vcl/unx/generic/gdi/gdiimpl.cxx | 351 vcl/unx/generic/gdi/gdiimpl.hxx | 17 - 7 files changed, 36 insertions(+), 382 deletions(-) New commits: commit 498f0208f55a5b9ce8a130c940ddfcb9c36d6ff9 Author: Caolán McNamara AuthorDate: Fri Jan 6 09:04:41 2023 + Commit: Caolán McNamara CommitDate: Fri Jan 6 14:49:31 2023 + move drawPolyLine into CairoCommon and reuse from X11CairoSalGraphicsImpl Change-Id: I141b12c99825c67e4698d53633a1fa720cc487be Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145136 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 0779cb65c564..b0c7b505f7cc 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -791,6 +791,20 @@ bool CairoCommon::drawPolyPolygon(cairo_t* cr, basegfx::B2DRange* pExtents, return true; } +void CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const Color& rLineColor, + bool bAntiAlias, sal_uInt32 nPoints, const Point* pPtAry) +{ +basegfx::B2DPolygon aPoly; +aPoly.append(basegfx::B2DPoint(pPtAry->getX(), pPtAry->getY()), nPoints); +for (sal_uInt32 i = 1; i < nPoints; ++i) +aPoly.setB2DPoint(i, basegfx::B2DPoint(pPtAry[i].getX(), pPtAry[i].getY())); +aPoly.setClosed(false); + +drawPolyLine(cr, pExtents, rLineColor, bAntiAlias, basegfx::B2DHomMatrix(), aPoly, 0.0, 1.0, + nullptr, basegfx::B2DLineJoin::Miter, css::drawing::LineCap_BUTT, + basegfx::deg2rad(15.0) /*default*/, false); +} + bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const Color& rLineColor, bool bAntiAlias, const basegfx::B2DHomMatrix& rObjectToDevice, const basegfx::B2DPolygon& rPolyLine, double fTransparency, diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index bf79416d88b7..134c9fc221e0 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -209,16 +209,14 @@ void SvpGraphicsBackend::implDrawRect(double nX, double nY, double nWidth, doubl void SvpGraphicsBackend::drawPolyLine(sal_uInt32 nPoints, const Point* pPtAry) { -basegfx::B2DPolygon aPoly; -aPoly.append(basegfx::B2DPoint(pPtAry->getX(), pPtAry->getY()), nPoints); -for (sal_uInt32 i = 1; i < nPoints; ++i) -aPoly.setB2DPoint(i, basegfx::B2DPoint(pPtAry[i].getX(), pPtAry[i].getY())); -aPoly.setClosed(false); +cairo_t* cr = m_rCairoCommon.getCairoContext(false, getAntiAlias()); +basegfx::B2DRange aExtents; +m_rCairoCommon.clipRegion(cr); -drawPolyLine(basegfx::B2DHomMatrix(), aPoly, 0.0, 1.0, - nullptr, // MM01 - basegfx::B2DLineJoin::Miter, css::drawing::LineCap_BUTT, - basegfx::deg2rad(15.0) /*default*/, false); +CairoCommon::drawPolyLine(cr, , *m_rCairoCommon.m_oLineColor, getAntiAlias(), nPoints, + pPtAry); + +m_rCairoCommon.releaseCairoContext(cr, false, aExtents); } void SvpGraphicsBackend::drawPolygon(sal_uInt32 nPoints, const Point* pPtAry) diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx index 7489ecaad969..75aec44a4ec7 100644 --- a/vcl/inc/headless/CairoCommon.hxx +++ b/vcl/inc/headless/CairoCommon.hxx @@ -173,9 +173,9 @@ struct VCL_DLLPUBLIC CairoCommon const basegfx::B2DHomMatrix& rObjectToDevice, const basegfx::B2DPolyPolygon&, double fTransparency); -// need this static version of ::drawPolyLine for usage from -// vcl/unx/generic/gdi/salgdi.cxx. It gets wrapped by -// ::drawPolyLine with some added parameters (see there) +static void drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const Color& rLineColor, + bool bAntiAlias, sal_uInt32 nPoints, const Point* pPtAry); + static bool drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const Color& rLineColor, bool bAntiAlias, const basegfx::B2DHomMatrix& rObjectToDevice, const basegfx::B2DPolygon& rPolyLine, double fTransparency, diff --git a/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx b/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx index 60cbf1230400..b1afbc25350f 100644 --- a/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx +++ b/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx @@ -93,6 +93,16 @@ void
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/unx
vcl/headless/CairoCommon.cxx| 101 ++ vcl/headless/SvpGraphicsBackend.cxx | 89 +--- vcl/inc/headless/CairoCommon.hxx|9 + vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx | 99 ++--- vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx |4 vcl/unx/generic/gdi/gdiimpl.cxx | 172 vcl/unx/generic/gdi/gdiimpl.hxx |9 - 7 files changed, 141 insertions(+), 342 deletions(-) New commits: commit 1bac4efd7c468179e7530546e1e4ee2ae1e4de54 Author: Caolán McNamara AuthorDate: Thu Jan 5 11:45:05 2023 + Commit: Caolán McNamara CommitDate: Fri Jan 6 08:48:33 2023 + move drawPolyPolygon into CairoCommon and reuse from X11CairoSalGraphicsImpl Change-Id: I8eee16f10f4241ced467e2bf73e518d066f9508d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145111 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index f50705b91584..291bc7e36380 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -687,6 +687,107 @@ void CairoCommon::drawLine(cairo_t* cr, basegfx::B2DRange* pExtents, const Color cairo_stroke(cr); } +void CairoCommon::drawPolyPolygon(cairo_t* cr, basegfx::B2DRange* pExtents, const Color& rLineColor, + const Color& rFillColor, bool bAntiAlias, sal_uInt32 nPoly, + const sal_uInt32* pPointCounts, const Point** pPtAry) +{ +basegfx::B2DPolyPolygon aPolyPoly; +for (sal_uInt32 nPolygon = 0; nPolygon < nPoly; ++nPolygon) +{ +sal_uInt32 nPoints = pPointCounts[nPolygon]; +if (nPoints) +{ +const Point* pPoints = pPtAry[nPolygon]; +basegfx::B2DPolygon aPoly; +aPoly.append(basegfx::B2DPoint(pPoints->getX(), pPoints->getY()), nPoints); +for (sal_uInt32 i = 1; i < nPoints; ++i) +aPoly.setB2DPoint(i, basegfx::B2DPoint(pPoints[i].getX(), pPoints[i].getY())); + +aPolyPoly.append(aPoly); +} +} + +drawPolyPolygon(cr, pExtents, rLineColor, rFillColor, bAntiAlias, basegfx::B2DHomMatrix(), +aPolyPoly, 0.0); +} + +bool CairoCommon::drawPolyPolygon(cairo_t* cr, basegfx::B2DRange* pExtents, const Color& rLineColor, + const Color& rFillColor, bool bAntiAlias, + const basegfx::B2DHomMatrix& rObjectToDevice, + const basegfx::B2DPolyPolygon& rPolyPolygon, double fTransparency) +{ +const bool bHasFill(rFillColor != SALCOLOR_NONE); +const bool bHasLine(rLineColor != SALCOLOR_NONE); + +if (0 == rPolyPolygon.count() || !(bHasFill || bHasLine) || fTransparency < 0.0 +|| fTransparency >= 1.0) +{ +return true; +} + +// don't bother trying to draw stuff which is effectively invisible +basegfx::B2DRange aPolygonRange = rPolyPolygon.getB2DRange(); +aPolygonRange.transform(rObjectToDevice); +if (aPolygonRange.getWidth() < 0.1 || aPolygonRange.getHeight() < 0.1) +return true; + +// Set full (Object-to-Device) transformation - if used +if (!rObjectToDevice.isIdentity()) +{ +cairo_matrix_t aMatrix; + +cairo_matrix_init(, rObjectToDevice.get(0, 0), rObjectToDevice.get(1, 0), + rObjectToDevice.get(0, 1), rObjectToDevice.get(1, 1), + rObjectToDevice.get(0, 2), rObjectToDevice.get(1, 2)); +cairo_set_matrix(cr, ); +} + +if (bHasFill) +{ +add_polygon_path(cr, rPolyPolygon, rObjectToDevice, !bAntiAlias); + +CairoCommon::applyColor(cr, rFillColor, fTransparency); +if (pExtents) +{ +// Get FillDamage (will be extended for LineDamage below) +*pExtents = getClippedFillDamage(cr); +} + +cairo_fill(cr); +} + +if (bHasLine) +{ +// PixelOffset used: Set PixelOffset as linear transformation +cairo_matrix_t aMatrix; +cairo_matrix_init_translate(, 0.5, 0.5); +cairo_set_matrix(cr, ); + +add_polygon_path(cr, rPolyPolygon, rObjectToDevice, !bAntiAlias); + +CairoCommon::applyColor(cr, rLineColor, fTransparency); + +if (pExtents) +{ +// expand with possible StrokeDamage +basegfx::B2DRange stroke_extents = getClippedStrokeDamage(cr); + stroke_extents.transform(basegfx::utils::createTranslateB2DHomMatrix(0.5, 0.5)); +pExtents->expand(stroke_extents); +} + +cairo_stroke(cr); +} + +if (pExtents) +{ +// if transformation has been applied, transform also extents (ranges) +// of damage so they can be correctly redrawn +pExtents->transform(rObjectToDevice); +} + +return
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 9eeacdd6cd5fa4ad0d29b530a627f398be763cc2 Author: Caolán McNamara AuthorDate: Thu Jan 5 17:23:26 2023 + Commit: Caolán McNamara CommitDate: Fri Jan 6 08:48:17 2023 + adjust bodge to be only for CAIRO_CONTENT_ALPHA rather than specifically !CAIRO_CONTENT_COLOR_ALPHA Change-Id: I2b86feb8499b98e750e954c4b246d4c8bc3ef7cf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145110 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 39538a9f9f40..f50705b91584 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -568,7 +568,7 @@ cairo_t* CairoCommon::createTmpCompatibleCairoContext() const void CairoCommon::applyColor(cairo_t* cr, Color aColor, double fTransparency) { -if (cairo_surface_get_content(cairo_get_target(cr)) == CAIRO_CONTENT_COLOR_ALPHA) +if (cairo_surface_get_content(cairo_get_target(cr)) != CAIRO_CONTENT_ALPHA) { cairo_set_source_rgba(cr, aColor.GetRed() / 255.0, aColor.GetGreen() / 255.0, aColor.GetBlue() / 255.0, 1.0 - fTransparency);
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/unx
vcl/headless/CairoCommon.cxx| 33 +++ vcl/headless/SvpGraphicsBackend.cxx | 30 - vcl/inc/headless/CairoCommon.hxx|2 + vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx | 11 +++ vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx |1 vcl/unx/generic/gdi/gdiimpl.cxx | 34 vcl/unx/generic/gdi/gdiimpl.hxx |2 - 7 files changed, 48 insertions(+), 65 deletions(-) New commits: commit ded5e68a58ae4837918e1a381d0c46cd69f7a06a Author: Caolán McNamara AuthorDate: Thu Jan 5 16:41:17 2023 + Commit: Caolán McNamara CommitDate: Fri Jan 6 08:47:52 2023 + move getPixel into CairoCommon and reuse from X11CairoSalGraphicsImpl 2nd attempt. This reverts commit 8d0b7bdb8c9ae8254e5b77b533a158734affc4f5. Change-Id: I8901a1258e0b0d89170f4e056516c5211801456a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145109 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 5781eff048e8..39538a9f9f40 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -623,6 +623,39 @@ void CairoCommon::drawPixel(cairo_t* cr, basegfx::B2DRange* pExtents, const Colo *pExtents = getClippedFillDamage(cr); } +Color CairoCommon::getPixel(cairo_surface_t* pSurface, tools::Long nX, tools::Long nY) +{ +cairo_surface_t* target += cairo_surface_create_similar_image(pSurface, CAIRO_FORMAT_ARGB32, 1, 1); + +cairo_t* cr = cairo_create(target); + +cairo_rectangle(cr, 0, 0, 1, 1); +cairo_set_source_surface(cr, pSurface, -nX, -nY); +cairo_paint(cr); +cairo_destroy(cr); + +cairo_surface_flush(target); +#if !ENABLE_WASM_STRIP_PREMULTIPLY +vcl::bitmap::lookup_table const& unpremultiply_table = vcl::bitmap::get_unpremultiply_table(); +#endif +unsigned char* data = cairo_image_surface_get_data(target); +sal_uInt8 a = data[SVP_CAIRO_ALPHA]; +#if ENABLE_WASM_STRIP_PREMULTIPLY +sal_uInt8 b = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_BLUE]); +sal_uInt8 g = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_GREEN]); +sal_uInt8 r = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_RED]); +#else +sal_uInt8 b = unpremultiply_table[a][data[SVP_CAIRO_BLUE]]; +sal_uInt8 g = unpremultiply_table[a][data[SVP_CAIRO_GREEN]]; +sal_uInt8 r = unpremultiply_table[a][data[SVP_CAIRO_RED]]; +#endif +Color aColor(ColorAlpha, a, r, g, b); +cairo_surface_destroy(target); + +return aColor; +} + void CairoCommon::drawLine(cairo_t* cr, basegfx::B2DRange* pExtents, const Color& rLineColor, bool bAntiAlias, tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2) diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 84d6aa1dcd09..efff52387575 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -566,35 +566,7 @@ void SvpGraphicsBackend::drawBitmapBuffer(const SalTwoRect& rTR, const BitmapBuf Color SvpGraphicsBackend::getPixel(tools::Long nX, tools::Long nY) { -cairo_surface_t* target -= cairo_surface_create_similar_image(m_rCairoCommon.m_pSurface, CAIRO_FORMAT_ARGB32, 1, 1); - -cairo_t* cr = cairo_create(target); - -cairo_rectangle(cr, 0, 0, 1, 1); -cairo_set_source_surface(cr, m_rCairoCommon.m_pSurface, -nX, -nY); -cairo_paint(cr); -cairo_destroy(cr); - -cairo_surface_flush(target); -#if !ENABLE_WASM_STRIP_PREMULTIPLY -vcl::bitmap::lookup_table const& unpremultiply_table = vcl::bitmap::get_unpremultiply_table(); -#endif -unsigned char* data = cairo_image_surface_get_data(target); -sal_uInt8 a = data[SVP_CAIRO_ALPHA]; -#if ENABLE_WASM_STRIP_PREMULTIPLY -sal_uInt8 b = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_BLUE]); -sal_uInt8 g = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_GREEN]); -sal_uInt8 r = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_RED]); -#else -sal_uInt8 b = unpremultiply_table[a][data[SVP_CAIRO_BLUE]]; -sal_uInt8 g = unpremultiply_table[a][data[SVP_CAIRO_GREEN]]; -sal_uInt8 r = unpremultiply_table[a][data[SVP_CAIRO_RED]]; -#endif -Color aColor(ColorAlpha, a, r, g, b); -cairo_surface_destroy(target); - -return aColor; +return CairoCommon::getPixel(m_rCairoCommon.m_pSurface, nX, nY); } void SvpGraphicsBackend::invert(tools::Long nX, tools::Long nY, tools::Long nWidth, diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx index 743c962c9423..3e78b435dbc5 100644 --- a/vcl/inc/headless/CairoCommon.hxx +++ b/vcl/inc/headless/CairoCommon.hxx @@ -155,6 +155,8 @@ struct VCL_DLLPUBLIC CairoCommon static void drawPixel(cairo_t* cr, basegfx::B2DRange* pExtents, const Color& rLineColor,
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/unx
vcl/headless/CairoCommon.cxx| 33 --- vcl/headless/SvpGraphicsBackend.cxx | 30 - vcl/inc/headless/CairoCommon.hxx|2 - vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx | 11 --- vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx |1 vcl/unx/generic/gdi/gdiimpl.cxx | 34 vcl/unx/generic/gdi/gdiimpl.hxx |2 + 7 files changed, 65 insertions(+), 48 deletions(-) New commits: commit e8effd1c4c0a4dd389054d311f432c42f26a3a6b Author: Caolán McNamara AuthorDate: Thu Jan 5 12:02:35 2023 + Commit: Caolán McNamara CommitDate: Fri Jan 6 08:46:43 2023 + Revert "move getPixel into CairoCommon and reuse from X11CairoSalGraphicsImpl" This reverts commit 00b62877fa2f900d1c2dcf7b721f7a956408f8a0. XIOError seen with vcldemo Change-Id: Id75497f8148964372beaed9432ee6097ec8afc47 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145076 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 39538a9f9f40..5781eff048e8 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -623,39 +623,6 @@ void CairoCommon::drawPixel(cairo_t* cr, basegfx::B2DRange* pExtents, const Colo *pExtents = getClippedFillDamage(cr); } -Color CairoCommon::getPixel(cairo_surface_t* pSurface, tools::Long nX, tools::Long nY) -{ -cairo_surface_t* target -= cairo_surface_create_similar_image(pSurface, CAIRO_FORMAT_ARGB32, 1, 1); - -cairo_t* cr = cairo_create(target); - -cairo_rectangle(cr, 0, 0, 1, 1); -cairo_set_source_surface(cr, pSurface, -nX, -nY); -cairo_paint(cr); -cairo_destroy(cr); - -cairo_surface_flush(target); -#if !ENABLE_WASM_STRIP_PREMULTIPLY -vcl::bitmap::lookup_table const& unpremultiply_table = vcl::bitmap::get_unpremultiply_table(); -#endif -unsigned char* data = cairo_image_surface_get_data(target); -sal_uInt8 a = data[SVP_CAIRO_ALPHA]; -#if ENABLE_WASM_STRIP_PREMULTIPLY -sal_uInt8 b = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_BLUE]); -sal_uInt8 g = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_GREEN]); -sal_uInt8 r = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_RED]); -#else -sal_uInt8 b = unpremultiply_table[a][data[SVP_CAIRO_BLUE]]; -sal_uInt8 g = unpremultiply_table[a][data[SVP_CAIRO_GREEN]]; -sal_uInt8 r = unpremultiply_table[a][data[SVP_CAIRO_RED]]; -#endif -Color aColor(ColorAlpha, a, r, g, b); -cairo_surface_destroy(target); - -return aColor; -} - void CairoCommon::drawLine(cairo_t* cr, basegfx::B2DRange* pExtents, const Color& rLineColor, bool bAntiAlias, tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2) diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index efff52387575..84d6aa1dcd09 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -566,7 +566,35 @@ void SvpGraphicsBackend::drawBitmapBuffer(const SalTwoRect& rTR, const BitmapBuf Color SvpGraphicsBackend::getPixel(tools::Long nX, tools::Long nY) { -return CairoCommon::getPixel(m_rCairoCommon.m_pSurface, nX, nY); +cairo_surface_t* target += cairo_surface_create_similar_image(m_rCairoCommon.m_pSurface, CAIRO_FORMAT_ARGB32, 1, 1); + +cairo_t* cr = cairo_create(target); + +cairo_rectangle(cr, 0, 0, 1, 1); +cairo_set_source_surface(cr, m_rCairoCommon.m_pSurface, -nX, -nY); +cairo_paint(cr); +cairo_destroy(cr); + +cairo_surface_flush(target); +#if !ENABLE_WASM_STRIP_PREMULTIPLY +vcl::bitmap::lookup_table const& unpremultiply_table = vcl::bitmap::get_unpremultiply_table(); +#endif +unsigned char* data = cairo_image_surface_get_data(target); +sal_uInt8 a = data[SVP_CAIRO_ALPHA]; +#if ENABLE_WASM_STRIP_PREMULTIPLY +sal_uInt8 b = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_BLUE]); +sal_uInt8 g = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_GREEN]); +sal_uInt8 r = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_RED]); +#else +sal_uInt8 b = unpremultiply_table[a][data[SVP_CAIRO_BLUE]]; +sal_uInt8 g = unpremultiply_table[a][data[SVP_CAIRO_GREEN]]; +sal_uInt8 r = unpremultiply_table[a][data[SVP_CAIRO_RED]]; +#endif +Color aColor(ColorAlpha, a, r, g, b); +cairo_surface_destroy(target); + +return aColor; } void SvpGraphicsBackend::invert(tools::Long nX, tools::Long nY, tools::Long nWidth, diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx index 3e78b435dbc5..743c962c9423 100644 --- a/vcl/inc/headless/CairoCommon.hxx +++ b/vcl/inc/headless/CairoCommon.hxx @@ -155,8 +155,6 @@ struct VCL_DLLPUBLIC CairoCommon static void drawPixel(cairo_t* cr, basegfx::B2DRange* pExtents, const
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/unx
vcl/headless/CairoCommon.cxx| 31 vcl/headless/SvpGraphicsBackend.cxx | 25 ++- vcl/inc/headless/CairoCommon.hxx|4 +++ vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx | 11 vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx |2 + vcl/unx/generic/gdi/gdiimpl.cxx |6 ++-- vcl/unx/generic/gdi/gdiimpl.hxx |4 +-- 7 files changed, 56 insertions(+), 27 deletions(-) New commits: commit d6ded494dbb781d5539ab44fa8765eaf16275688 Author: Caolán McNamara AuthorDate: Wed Jan 4 19:43:20 2023 + Commit: Caolán McNamara CommitDate: Thu Jan 5 10:50:07 2023 + move drawLine into CairoCommon and reuse from X11CairoSalGraphicsImpl Change-Id: I6c667b4aa64c49ad18b7e9a2cd6cc43228369bd6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145050 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 1b83e20adefa..9f890067b7e9 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -609,6 +609,37 @@ void CairoCommon::clipRegion(cairo_t* cr, const vcl::Region& rClipRegion) void CairoCommon::clipRegion(cairo_t* cr) { CairoCommon::clipRegion(cr, m_aClipRegion); } +void CairoCommon::drawLine(cairo_t* cr, basegfx::B2DRange* pExtents, const Color& rLineColor, + bool bAntiAlias, tools::Long nX1, tools::Long nY1, tools::Long nX2, + tools::Long nY2) +{ +basegfx::B2DPolygon aPoly; + +// PixelOffset used: To not mix with possible PixelSnap, cannot do +// directly on coordinates as tried before - despite being already 'snapped' +// due to being integer. If it would be directly added here, it would be +// 'snapped' again when !getAntiAlias(), losing the (0.5, 0.5) offset +aPoly.append(basegfx::B2DPoint(nX1, nY1)); +aPoly.append(basegfx::B2DPoint(nX2, nY2)); + +// PixelOffset used: Set PixelOffset as linear transformation +cairo_matrix_t aMatrix; +cairo_matrix_init_translate(, 0.5, 0.5); +cairo_set_matrix(cr, ); + +AddPolygonToPath(cr, aPoly, basegfx::B2DHomMatrix(), !bAntiAlias, false); + +CairoCommon::applyColor(cr, rLineColor); + +if (pExtents) +{ +*pExtents = getClippedStrokeDamage(cr); +pExtents->transform(basegfx::utils::createTranslateB2DHomMatrix(0.5, 0.5)); +} + +cairo_stroke(cr); +} + bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const Color& rLineColor, bool bAntiAlias, const basegfx::B2DHomMatrix& rObjectToDevice, const basegfx::B2DPolygon& rPolyLine, double fTransparency, diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index c41c31f4d360..b1920f576d81 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -122,31 +122,12 @@ void SvpGraphicsBackend::drawPixel(tools::Long nX, tools::Long nY, Color aColor) void SvpGraphicsBackend::drawLine(tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2) { -basegfx::B2DPolygon aPoly; - -// PixelOffset used: To not mix with possible PixelSnap, cannot do -// directly on coordinates as tried before - despite being already 'snapped' -// due to being integer. If it would be directly added here, it would be -// 'snapped' again when !getAntiAlias(), losing the (0.5, 0.5) offset -aPoly.append(basegfx::B2DPoint(nX1, nY1)); -aPoly.append(basegfx::B2DPoint(nX2, nY2)); - cairo_t* cr = m_rCairoCommon.getCairoContext(false, getAntiAlias()); +basegfx::B2DRange extents; m_rCairoCommon.clipRegion(cr); -// PixelOffset used: Set PixelOffset as linear transformation -cairo_matrix_t aMatrix; -cairo_matrix_init_translate(, 0.5, 0.5); -cairo_set_matrix(cr, ); - -AddPolygonToPath(cr, aPoly, basegfx::B2DHomMatrix(), !getAntiAlias(), false); - -CairoCommon::applyColor(cr, m_rCairoCommon.m_aLineColor); - -basegfx::B2DRange extents = getClippedStrokeDamage(cr); -extents.transform(basegfx::utils::createTranslateB2DHomMatrix(0.5, 0.5)); - -cairo_stroke(cr); +CairoCommon::drawLine(cr, , m_rCairoCommon.m_aLineColor, getAntiAlias(), nX1, nY1, nX2, + nY2); m_rCairoCommon.releaseCairoContext(cr, false, extents); } diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx index 35d33e2fd24e..029060c31962 100644 --- a/vcl/inc/headless/CairoCommon.hxx +++ b/vcl/inc/headless/CairoCommon.hxx @@ -152,6 +152,10 @@ struct VCL_DLLPUBLIC CairoCommon void clipRegion(cairo_t* cr); static void clipRegion(cairo_t* cr, const vcl::Region& rClipRegion); +static void drawLine(cairo_t* cr, basegfx::B2DRange* pExtents, const
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/unx
vcl/headless/CairoCommon.cxx|2 ++ vcl/headless/SvpGraphicsBackend.cxx |5 - vcl/inc/headless/CairoCommon.hxx|1 + vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx |5 + vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx |2 ++ vcl/unx/generic/gdi/gdiimpl.cxx |5 - vcl/unx/generic/gdi/gdiimpl.hxx |2 -- 7 files changed, 14 insertions(+), 8 deletions(-) New commits: commit 4818e7d8d5b99cc9f74985572c113a10f0bbae3b Author: Caolán McNamara AuthorDate: Tue Jan 3 20:21:51 2023 + Commit: Caolán McNamara CommitDate: Thu Jan 5 10:49:24 2023 + move hasFastDrawTransformedBitmap into CairoCommon and reuse Change-Id: I5c70f657fe885da54caf9514bdddf868e9cf8c1d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145029 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index a43849f18ad1..1b83e20adefa 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -1278,6 +1278,8 @@ cairo_surface_t* CairoCommon::createCairoSurface(const BitmapBuffer* pBuffer) return target; } +bool CairoCommon::hasFastDrawTransformedBitmap() { return false; } + bool CairoCommon::supportsOperation(OutDevSupportType eType) { switch (eType) diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 71734759906d..c41c31f4d360 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -815,7 +815,10 @@ bool SvpGraphicsBackend::drawTransformedBitmap(const basegfx::B2DPoint& rNull, return true; } -bool SvpGraphicsBackend::hasFastDrawTransformedBitmap() const { return false; } +bool SvpGraphicsBackend::hasFastDrawTransformedBitmap() const +{ +return CairoCommon::hasFastDrawTransformedBitmap(); +} bool SvpGraphicsBackend::drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency) diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx index c0938ef58e3d..35d33e2fd24e 100644 --- a/vcl/inc/headless/CairoCommon.hxx +++ b/vcl/inc/headless/CairoCommon.hxx @@ -188,6 +188,7 @@ struct VCL_DLLPUBLIC CairoCommon static cairo_surface_t* createCairoSurface(const BitmapBuffer* pBuffer); static bool supportsOperation(OutDevSupportType eType); +static bool hasFastDrawTransformedBitmap(); private: void doXorOnRelease(sal_Int32 nExtentsLeft, sal_Int32 nExtentsTop, sal_Int32 nExtentsRight, diff --git a/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx b/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx index 58c5567cdbd4..799327684e85 100644 --- a/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx +++ b/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx @@ -193,6 +193,11 @@ bool X11CairoSalGraphicsImpl::implDrawGradient(basegfx::B2DPolyPolygon const& rP return bRetval; } +bool X11CairoSalGraphicsImpl::hasFastDrawTransformedBitmap() const +{ +return CairoCommon::hasFastDrawTransformedBitmap(); +} + bool X11CairoSalGraphicsImpl::supportsOperation(OutDevSupportType eType) const { return CairoCommon::supportsOperation(eType); diff --git a/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx b/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx index 853c4cad3252..d450b919d551 100644 --- a/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx +++ b/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx @@ -100,6 +100,8 @@ public: bool implDrawGradient(basegfx::B2DPolyPolygon const& rPolyPolygon, SalGradient const& rGradient) override; +virtual bool hasFastDrawTransformedBitmap() const override; + virtual bool supportsOperation(OutDevSupportType eType) const override; }; diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx index b9ccd388d0f7..d95d65f8d98e 100644 --- a/vcl/unx/generic/gdi/gdiimpl.cxx +++ b/vcl/unx/generic/gdi/gdiimpl.cxx @@ -852,11 +852,6 @@ bool X11SalGraphicsImpl::drawTransformedBitmap( return false; } -bool X11SalGraphicsImpl::hasFastDrawTransformedBitmap() const -{ -return false; -} - void X11SalGraphicsImpl::drawMask( const SalTwoRect& rPosAry, const SalBitmap , Color nMaskColor ) diff --git a/vcl/unx/generic/gdi/gdiimpl.hxx b/vcl/unx/generic/gdi/gdiimpl.hxx index d46e67c1108d..6858f582b1bf 100644 --- a/vcl/unx/generic/gdi/gdiimpl.hxx +++ b/vcl/unx/generic/gdi/gdiimpl.hxx @@ -272,8 +272,6 @@ public: const SalBitmap* pAlphaBitmap, double fAlpha) override; -virtual bool hasFastDrawTransformedBitmap() const override; - public: void Init() override; };
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/unx
vcl/headless/CairoCommon.cxx| 35 vcl/headless/SvpGraphicsBackend.cxx | 29 ++- vcl/inc/headless/CairoCommon.hxx|6 vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx | 14 + vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx |3 ++ vcl/unx/generic/gdi/gdiimpl.cxx |5 --- vcl/unx/generic/gdi/gdiimpl.hxx |1 7 files changed, 62 insertions(+), 31 deletions(-) New commits: commit dcde0b2e640c0fe36dceb49bfed5426842a6fa0a Author: Caolán McNamara AuthorDate: Mon Jan 2 21:29:01 2023 + Commit: Caolán McNamara CommitDate: Wed Jan 4 19:25:42 2023 + move implDrawGradient into CairoCommon and reuse from X11CairoSalGraphicsImpl Change-Id: I341e0b1e3cccd18193c3f9798b875a709fe4871f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144975 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index b79d942709b6..cfd463da41e3 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -887,6 +888,40 @@ bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const C return true; } +bool CairoCommon::implDrawGradient(cairo_t* cr, basegfx::B2DRange* pExtents, bool bAntiAlias, + basegfx::B2DPolyPolygon const& rPolyPolygon, + SalGradient const& rGradient) +{ +basegfx::B2DHomMatrix rObjectToDevice; + +for (auto const& rPolygon : rPolyPolygon) +AddPolygonToPath(cr, rPolygon, rObjectToDevice, !bAntiAlias, false); + +cairo_pattern_t* pattern += cairo_pattern_create_linear(rGradient.maPoint1.getX(), rGradient.maPoint1.getY(), + rGradient.maPoint2.getX(), rGradient.maPoint2.getY()); + +for (SalGradientStop const& rStop : rGradient.maStops) +{ +double r = rStop.maColor.GetRed() / 255.0; +double g = rStop.maColor.GetGreen() / 255.0; +double b = rStop.maColor.GetBlue() / 255.0; +double a = rStop.maColor.GetAlpha() / 255.0; +double offset = rStop.mfOffset; + +cairo_pattern_add_color_stop_rgba(pattern, offset, r, g, b, a); +} +cairo_set_source(cr, pattern); +cairo_pattern_destroy(pattern); + +if (pExtents) +*pExtents = getClippedFillDamage(cr); + +cairo_fill_preserve(cr); + +return true; +} + namespace { basegfx::B2DRange renderWithOperator(cairo_t* cr, const SalTwoRect& rTR, cairo_surface_t* source, diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 63e66d9a31e2..6f527f350760 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -959,36 +959,15 @@ bool SvpGraphicsBackend::implDrawGradient(basegfx::B2DPolyPolygon const& rPolyPo SalGradient const& rGradient) { cairo_t* cr = m_rCairoCommon.getCairoContext(true, getAntiAlias()); +basegfx::B2DRange extents; m_rCairoCommon.clipRegion(cr); -basegfx::B2DHomMatrix rObjectToDevice; - -for (auto const& rPolygon : rPolyPolygon) -AddPolygonToPath(cr, rPolygon, rObjectToDevice, !getAntiAlias(), false); - -cairo_pattern_t* pattern -= cairo_pattern_create_linear(rGradient.maPoint1.getX(), rGradient.maPoint1.getY(), - rGradient.maPoint2.getX(), rGradient.maPoint2.getY()); - -for (SalGradientStop const& rStop : rGradient.maStops) -{ -double r = rStop.maColor.GetRed() / 255.0; -double g = rStop.maColor.GetGreen() / 255.0; -double b = rStop.maColor.GetBlue() / 255.0; -double a = rStop.maColor.GetAlpha() / 255.0; -double offset = rStop.mfOffset; - -cairo_pattern_add_color_stop_rgba(pattern, offset, r, g, b, a); -} -cairo_set_source(cr, pattern); -cairo_pattern_destroy(pattern); - -basegfx::B2DRange extents = getClippedFillDamage(cr); -cairo_fill_preserve(cr); +bool bRetVal( +CairoCommon::implDrawGradient(cr, , getAntiAlias(), rPolyPolygon, rGradient)); m_rCairoCommon.releaseCairoContext(cr, true, extents); -return true; +return bRetVal; } bool SvpGraphicsBackend::supportsOperation(OutDevSupportType eType) const diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx index e232d2167380..dfee58b1a9f2 100644 --- a/vcl/inc/headless/CairoCommon.hxx +++ b/vcl/inc/headless/CairoCommon.hxx @@ -45,6 +45,8 @@ typedef struct _cairo cairo_t; typedef struct _cairo_surface cairo_surface_t; typedef struct _cairo_user_data_key cairo_user_data_key_t; +struct SalGradient; + VCL_DLLPUBLIC void dl_cairo_surface_set_device_scale(cairo_surface_t* surface,
[Libreoffice-commits] core.git: vcl/headless vcl/unx
vcl/headless/SvpGraphicsBackend.cxx |2 -- vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx | 14 -- 2 files changed, 4 insertions(+), 12 deletions(-) New commits: commit b62e3e164ef6af83e03e106e188c06eb5b91f51d Author: Caolán McNamara AuthorDate: Mon Jan 2 21:03:45 2023 + Commit: Caolán McNamara CommitDate: Wed Jan 4 19:24:24 2023 + sync drawPolyLine impls early returns Change-Id: I9b7c49d0e4286245979043e1cb21f8b577676f87 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144972 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index a47332173676..355a971b9b01 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -360,9 +360,7 @@ bool SvpGraphicsBackend::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevi { // short circuit if there is nothing to do if (0 == rPolyLine.count() || fTransparency < 0.0 || fTransparency >= 1.0) -{ return true; -} // Wrap call to static version of ::drawPolyLine by // preparing/getting some local data and parameters diff --git a/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx b/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx index 874bf4bd4cf8..438aaf46b455 100644 --- a/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx +++ b/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx @@ -126,22 +126,16 @@ bool X11CairoSalGraphicsImpl::drawPolyPolygon(const basegfx::B2DHomMatrix& rObje } bool X11CairoSalGraphicsImpl::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice, - const basegfx::B2DPolygon& rPolygon, + const basegfx::B2DPolygon& rPolyLine, double fTransparency, double fLineWidth, const std::vector* pStroke, basegfx::B2DLineJoin eLineJoin, css::drawing::LineCap eLineCap, double fMiterMinimumAngle, bool bPixelSnapHairline) { -if (0 == rPolygon.count()) -{ +// short circuit if there is nothing to do +if (0 == rPolyLine.count() || fTransparency < 0.0 || fTransparency >= 1.0) return true; -} - -if (fTransparency >= 1.0) -{ -return true; -} cairo_t* cr = mrX11Common.getCairoContext(); clipRegion(cr); @@ -149,7 +143,7 @@ bool X11CairoSalGraphicsImpl::drawPolyLine(const basegfx::B2DHomMatrix& rObjectT // Use the now available static drawPolyLine from the Cairo-Headless-Fallback // that will take care of all needed stuff const bool bRetval(CairoCommon::drawPolyLine( -cr, nullptr, mnPenColor, getAntiAlias(), rObjectToDevice, rPolygon, fTransparency, +cr, nullptr, mnPenColor, getAntiAlias(), rObjectToDevice, rPolyLine, fTransparency, fLineWidth, pStroke, eLineJoin, eLineCap, fMiterMinimumAngle, bPixelSnapHairline)); X11Common::releaseCairoContext(cr);
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/svpinst.cxx | 82 --- vcl/inc/headless/svpinst.hxx |9 +++- 2 files changed, 22 insertions(+), 69 deletions(-) New commits: commit 91526a2f53d5c7a703b9fc5fbc1728ee50854cc1 Author: Tor Lillqvist AuthorDate: Thu Dec 29 12:16:25 2022 +0200 Commit: Tor Lillqvist CommitDate: Mon Jan 2 17:57:16 2023 + Use std synchronisation APIs instead of a pipe The immediate reason for this is that pipes are broken in the Emscripten runtime, see https://github.com/emscripten-core/emscripten/issues/13214. But if we can drop the use of a pipe for other platforms, too, why not. Without this, when attemting to run Collabora Online as WASM, I get: Aborted(Assertion failed: nRet == 1, at: .../vcl/headless/svpinst.cxx,538,DoYield) It is quite possible that the code could be simplified drastically. I only replaced the use of a pipe with hopefully equivalent use of a queue, a condition variable, and a mutex. Change-Id: I9259ba36afeabce6474a1aec827d01bcbbd4412b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144944 Reviewed-by: Michael Meeks Tested-by: Jenkins diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx index 5a86826423e3..19eef8997689 100644 --- a/vcl/headless/svpinst.cxx +++ b/vcl/headless/svpinst.cxx @@ -22,9 +22,6 @@ #include -#include -#include -#include #include #include #include @@ -76,14 +73,13 @@ do { \ #define DBG_TESTSVPYIELDMUTEX() ((void)0) #endif -#if !defined(ANDROID) && !defined(IOS) +#if !defined(ANDROID) && !defined(IOS) && !defined(EMSCRIPTEN) static void atfork_child() { if (SvpSalInstance::s_pDefaultInstance != nullptr) { -SvpSalInstance::s_pDefaultInstance->CloseWakeupPipe(false); -SvpSalInstance::s_pDefaultInstance->CreateWakeupPipe(false); +SvpSalInstance::s_pDefaultInstance->CloseWakeupPipe(); } } @@ -97,10 +93,9 @@ SvpSalInstance::SvpSalInstance( std::unique_ptr pMutex ) m_nTimeoutMS= 0; m_MainThread = osl::Thread::getCurrentIdentifier(); -CreateWakeupPipe(true); if( s_pDefaultInstance == nullptr ) s_pDefaultInstance = this; -#if !defined(ANDROID) && !defined(IOS) +#if !defined(ANDROID) && !defined(IOS) && !defined(EMSCRIPTEN) pthread_atfork(nullptr, nullptr, atfork_child); #endif } @@ -109,62 +104,16 @@ SvpSalInstance::~SvpSalInstance() { if( s_pDefaultInstance == this ) s_pDefaultInstance = nullptr; -CloseWakeupPipe(true); +CloseWakeupPipe(); } -void SvpSalInstance::CloseWakeupPipe(bool log) +void SvpSalInstance::CloseWakeupPipe() { SvpSalYieldMutex *const pMutex(dynamic_cast(GetYieldMutex())); if (!pMutex) return; -if (pMutex->m_FeedbackFDs[0] != -1) -{ -if (log) -{ -SAL_INFO("vcl.headless", "CloseWakeupPipe: Closing inherited feedback pipe: [" << pMutex->m_FeedbackFDs[0] << "," << pMutex->m_FeedbackFDs[1] << "]"); -} -close (pMutex->m_FeedbackFDs[0]); -close (pMutex->m_FeedbackFDs[1]); -pMutex->m_FeedbackFDs[0] = pMutex->m_FeedbackFDs[1] = -1; -} -} - -void SvpSalInstance::CreateWakeupPipe(bool log) -{ -SvpSalYieldMutex *const pMutex(dynamic_cast(GetYieldMutex())); -if (!pMutex) -return; -if (pipe (pMutex->m_FeedbackFDs) == -1) -{ -if (log) -{ -SAL_WARN("vcl.headless", "Could not create feedback pipe: " << strerror(errno)); -std::abort(); -} -} -else -{ -if (log) -{ -SAL_INFO("vcl.headless", "CreateWakeupPipe: Created feedback pipe: [" << pMutex->m_FeedbackFDs[0] << "," << pMutex->m_FeedbackFDs[1] << "]"); -} - -int flags; - -// set close-on-exec descriptor flag. -if ((flags = fcntl (pMutex->m_FeedbackFDs[0], F_GETFD)) != -1) -{ -flags |= FD_CLOEXEC; -(void) fcntl(pMutex->m_FeedbackFDs[0], F_SETFD, flags); -} -if ((flags = fcntl (pMutex->m_FeedbackFDs[1], F_GETFD)) != -1) -{ -flags |= FD_CLOEXEC; -(void) fcntl(pMutex->m_FeedbackFDs[1], F_SETFD, flags); -} - -// retain the default blocking I/O for feedback pipe -} +while (!pMutex->m_FeedbackPipe.empty()) +pMutex->m_FeedbackPipe.pop(); } void SvpSalInstance::TriggerUserEventProcessing() @@ -328,9 +277,6 @@ void SvpSalInstance::ProcessEvent( SalUserEvent aEvent ) SvpSalYieldMutex::SvpSalYieldMutex() { -#ifndef IOS -m_FeedbackFDs[0] = m_FeedbackFDs[1] = -1; -#endif } SvpSalYieldMutex::~SvpSalYieldMutex() @@ -367,11 +313,11 @@ void SvpSalYieldMutex::doAcquire(sal_uInt32 const nLockCount) m_bNoYieldLock = true; bool const bEvents = pInst->DoYield(false, request == SvpRequest::MainThreadDispatchAllEvents); m_bNoYieldLock =
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/qt5 vcl/quartz vcl/skia vcl/source vcl/unx vcl/win
vcl/headless/SvpGraphicsBackend.cxx |3 +-- vcl/inc/headless/SvpGraphicsBackend.hxx |2 +- vcl/inc/qt5/QtGraphics.hxx |2 +- vcl/inc/quartz/salgdi.h |2 +- vcl/inc/salgdi.hxx |8 vcl/inc/salgdiimpl.hxx |2 +- vcl/inc/skia/gdiimpl.hxx|2 +- vcl/inc/unx/GenPspGfxBackend.hxx|2 +- vcl/inc/win/salgdi.h|2 +- vcl/qt5/QtGraphics_GDI.cxx |3 +-- vcl/quartz/AquaGraphicsBackend.cxx |4 +--- vcl/skia/gdiimpl.cxx|5 ++--- vcl/source/gdi/salgdilayout.cxx |6 +++--- vcl/source/outdev/clipping.cxx |5 ++--- vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx |4 ++-- vcl/unx/generic/gdi/gdiimpl.cxx |3 +-- vcl/unx/generic/gdi/gdiimpl.hxx |2 +- vcl/unx/generic/print/GenPspGfxBackend.cxx |4 +--- vcl/win/gdi/gdiimpl.cxx |5 + vcl/win/gdi/gdiimpl.hxx |2 +- vcl/win/gdi/salgdi.cxx |4 ++-- 21 files changed, 30 insertions(+), 42 deletions(-) New commits: commit 6f43f00279252265fe4892b46fe0b4686ff721ed Author: Noel Grandin AuthorDate: Tue Dec 20 18:02:32 2022 +0200 Commit: Noel Grandin CommitDate: Wed Dec 21 06:44:59 2022 + No need for bool return value here all of the implementations of this method return true. Change-Id: I6dc02499af1809110edd482a48d9f6d5d42ead19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144620 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index cd5487031a63..10667e53e4dd 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -34,10 +34,9 @@ void SvpGraphicsBackend::Init() {} void SvpGraphicsBackend::freeResources() {} -bool SvpGraphicsBackend::setClipRegion(const vcl::Region& i_rClip) +void SvpGraphicsBackend::setClipRegion(const vcl::Region& i_rClip) { m_rCairoCommon.m_aClipRegion = i_rClip; -return true; } void SvpGraphicsBackend::ResetClipRegion() { m_rCairoCommon.m_aClipRegion.SetNull(); } diff --git a/vcl/inc/headless/SvpGraphicsBackend.hxx b/vcl/inc/headless/SvpGraphicsBackend.hxx index 997f1bc84e9d..7bd78118f6f4 100644 --- a/vcl/inc/headless/SvpGraphicsBackend.hxx +++ b/vcl/inc/headless/SvpGraphicsBackend.hxx @@ -40,7 +40,7 @@ public: OUString getRenderBackendName() const override { return "svp"; } -bool setClipRegion(vcl::Region const& rRegion) override; +void setClipRegion(vcl::Region const& rRegion) override; void ResetClipRegion() override; sal_uInt16 GetBitCount() const override; diff --git a/vcl/inc/qt5/QtGraphics.hxx b/vcl/inc/qt5/QtGraphics.hxx index b8a168d1a3cf..b87e6d80b648 100644 --- a/vcl/inc/qt5/QtGraphics.hxx +++ b/vcl/inc/qt5/QtGraphics.hxx @@ -68,7 +68,7 @@ public: OUString getRenderBackendName() const override { return "qt5"; } -bool setClipRegion(vcl::Region const& rRegion) override; +void setClipRegion(vcl::Region const& rRegion) override; void ResetClipRegion() override; sal_uInt16 GetBitCount() const override; diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h index 9e070c4215ce..8886d19700a7 100644 --- a/vcl/inc/quartz/salgdi.h +++ b/vcl/inc/quartz/salgdi.h @@ -340,7 +340,7 @@ public: return "aqua"; } -bool setClipRegion(vcl::Region const& rRegion) override; +void setClipRegion(vcl::Region const& rRegion) override; void ResetClipRegion() override; sal_uInt16 GetBitCount() const override; diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx index 0b8952b74123..a7fbe287fc48 100644 --- a/vcl/inc/salgdi.hxx +++ b/vcl/inc/salgdi.hxx @@ -183,7 +183,7 @@ public: // non virtual methods; these do possible coordinate mirroring and // then delegate to protected virtual methods -boolSetClipRegion( const vcl::Region&, const OutputDevice& rOutDev ); +voidSetClipRegion( const vcl::Region&, const OutputDevice& rOutDev ); // draw --> LineColor and FillColor and RasterOp and ClipRegion voidDrawPixel( tools::Long nX, tools::Long nY, const OutputDevice& rOutDev ); @@ -426,7 +426,7 @@ protected: friend class vcl::FileDefinitionWidgetDraw; -virtual boolsetClipRegion( const vcl::Region& ) = 0; +virtual voidsetClipRegion( const vcl::Region& ) = 0; // draw --> LineColor and FillColor and RasterOp and ClipRegion virtual voiddrawPixel( tools::Long nX, tools::Long nY ) = 0; @@ -661,9 +661,9 @@ public:
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx |9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) New commits: commit b1b77b4005ceaeb2b9bc11d8a405bb5a467e1d86 Author: Caolán McNamara AuthorDate: Mon Nov 28 09:14:22 2022 + Commit: Caolán McNamara CommitDate: Mon Nov 28 11:16:51 2022 +0100 ofz#53820 Direct-leak cairo_get_source leaks if cairo is in an error state Change-Id: I1ddcf801d5a3fc0944f14001cbc7d152b2071c89 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143364 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 322b1e838463..4f3a4e869746 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -911,9 +911,12 @@ basegfx::B2DRange renderWithOperator(cairo_t* cr, const SalTwoRect& rTR, cairo_s cairo_save(cr); cairo_set_source_surface(cr, source, -rTR.mnSrcX, -rTR.mnSrcY); -//tdf#133716 borders of upscaled images should not be blurred -cairo_pattern_t* sourcepattern = cairo_get_source(cr); -cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_PAD); +if (cairo_status(cr) == CAIRO_STATUS_SUCCESS) +{ +//tdf#133716 borders of upscaled images should not be blurred +cairo_pattern_t* sourcepattern = cairo_get_source(cr); +cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_PAD); +} cairo_set_operator(cr, eOperator); cairo_paint(cr);
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit cb7e6003ad06d71a27baeb435366b91f87bdeb2f Author: Caolán McNamara AuthorDate: Sun Nov 27 15:12:37 2022 + Commit: Caolán McNamara CommitDate: Sun Nov 27 20:33:10 2022 +0100 cid#1517054 Logically dead code Change-Id: I0ea48d79d32920cf5f5ab2b11a5b4f53ddae0dc7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143345 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 401571a7625c..322b1e838463 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -630,8 +630,8 @@ bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const C { SAL_WARN("vcl.gdi", "drawPolyLine, skipping suspicious range of: " << aRange << " for fuzzing performance"); +return true; } -return true; } // need to check/handle LineWidth when ObjectToDevice transformation is used
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) New commits: commit 55d87b3a3fc87dca3114744f4a4e676ec51a9aa1 Author: Caolán McNamara AuthorDate: Mon Nov 21 21:06:51 2022 + Commit: Caolán McNamara CommitDate: Tue Nov 22 11:57:47 2022 +0100 ofz#53586 Out-of-memory Change-Id: I4442f6b6cd010706ccfded454e4c56b4ff001dbc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143077 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 96b119adcb6b..401571a7625c 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -621,6 +621,19 @@ bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const C return true; } +static const bool bFuzzing = utl::ConfigManager::IsFuzzing(); +if (bFuzzing) +{ +const basegfx::B2DRange aRange(basegfx::utils::getRange(rPolyLine)); +if (aRange.getMaxX() - aRange.getMinX() > 0x1000 +|| aRange.getMaxY() - aRange.getMinY() > 0x1000) +{ +SAL_WARN("vcl.gdi", "drawPolyLine, skipping suspicious range of: " +<< aRange << " for fuzzing performance"); +} +return true; +} + // need to check/handle LineWidth when ObjectToDevice transformation is used const bool bObjectToDeviceIsIdentity(rObjectToDevice.isIdentity()); @@ -707,6 +720,7 @@ bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const C cairo_set_line_join(cr, eCairoLineJoin); cairo_set_line_cap(cr, eCairoLineCap); + constexpr int MaxNormalLineWidth = 64; if (fLineWidth > MaxNormalLineWidth) { @@ -719,7 +733,6 @@ bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const C SAL_WARN("vcl.gdi", "drawPolyLine, suspicious input line width of: " << fLineWidth << ", will be " << fLineWidthPixel << " pixels thick"); -static const bool bFuzzing = utl::ConfigManager::IsFuzzing(); if (bFuzzing) { basegfx::B2DHomMatrix aObjectToDeviceInv(rObjectToDevice);
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 783bc24136929f1dc7b3d49b01794df627cc0bdb Author: Caolán McNamara AuthorDate: Wed Nov 16 20:32:31 2022 + Commit: Caolán McNamara CommitDate: Thu Nov 17 10:31:49 2022 +0100 ofz#53434 Out-of-memory Change-Id: Ia148869905cb54f57136fe0e0c2572434a7d37cb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142816 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index be0e6919f99e..96b119adcb6b 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -707,7 +707,7 @@ bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const C cairo_set_line_join(cr, eCairoLineJoin); cairo_set_line_cap(cr, eCairoLineCap); -constexpr int MaxNormalLineWidth = 92; +constexpr int MaxNormalLineWidth = 64; if (fLineWidth > MaxNormalLineWidth) { const double fLineWidthPixel
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) New commits: commit 3ad1411746a581357920a1ad6366935700719010 Author: Noel Grandin AuthorDate: Mon Nov 14 13:44:47 2022 +0200 Commit: Noel Grandin CommitDate: Mon Nov 14 20:49:03 2022 +0100 use cairo_surface_map_to_image if available which is considerably faster than emulating it Change-Id: I9159072caf3142684f8489d291fa0438dce2e4b5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142702 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 164bc2856ee8..ee4234c3c79f 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -472,8 +472,11 @@ void CairoCommon::doXorOnRelease(sal_Int32 nExtentsLeft, sal_Int32 nExtentsTop, cairo_surface_t* target_surface = m_pSurface; if (cairo_surface_get_type(target_surface) != CAIRO_SURFACE_TYPE_IMAGE) { -//in the unlikely case we can't use m_pSurface directly, copy contents -//to another temp image surface +//in the unlikely case we can't use m_pSurface directly, copy contents +//to another temp image surface +#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) +target_surface = cairo_surface_map_to_image(target_surface, nullptr); +#else cairo_t* copycr = createTmpCompatibleCairoContext(); cairo_rectangle(copycr, nExtentsLeft, nExtentsTop, nExtentsRight - nExtentsLeft, nExtentsBottom - nExtentsTop); @@ -481,6 +484,7 @@ void CairoCommon::doXorOnRelease(sal_Int32 nExtentsLeft, sal_Int32 nExtentsTop, cairo_fill(copycr); target_surface = cairo_get_target(copycr); cairo_destroy(copycr); +#endif } cairo_surface_flush(target_surface); @@ -550,6 +554,9 @@ void CairoCommon::doXorOnRelease(sal_Int32 nExtentsLeft, sal_Int32 nExtentsTop, if (target_surface != m_pSurface) { +#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) +cairo_surface_unmap_image(m_pSurface, target_surface); +#else cairo_t* copycr = cairo_create(m_pSurface); //unlikely case we couldn't use m_pSurface directly, copy contents //back from image surface @@ -559,6 +566,7 @@ void CairoCommon::doXorOnRelease(sal_Int32 nExtentsLeft, sal_Int32 nExtentsTop, cairo_fill(copycr); cairo_destroy(copycr); cairo_surface_destroy(target_surface); +#endif } cairo_surface_destroy(surface);
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) New commits: commit 17476f1c9912b5ce31276a947d6a34ec8b9a3ed2 Author: Noel Grandin AuthorDate: Mon Nov 14 12:39:05 2022 +0200 Commit: Noel Grandin CommitDate: Mon Nov 14 20:48:47 2022 +0100 cairo_fill is cheaper than cairo_paint when we are only interested in copying a small chunk of the image. Shaves 25% off the cost of rendering here Change-Id: I3df726a08fad3ab3c330da74d09ee5e735e1bc60 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142701 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index cba7a7328fd4..164bc2856ee8 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -478,7 +478,7 @@ void CairoCommon::doXorOnRelease(sal_Int32 nExtentsLeft, sal_Int32 nExtentsTop, cairo_rectangle(copycr, nExtentsLeft, nExtentsTop, nExtentsRight - nExtentsLeft, nExtentsBottom - nExtentsTop); cairo_set_source_surface(copycr, m_pSurface, 0, 0); -cairo_paint(copycr); +cairo_fill(copycr); target_surface = cairo_get_target(copycr); cairo_destroy(copycr); } @@ -556,7 +556,7 @@ void CairoCommon::doXorOnRelease(sal_Int32 nExtentsLeft, sal_Int32 nExtentsTop, cairo_rectangle(copycr, nExtentsLeft, nExtentsTop, nExtentsRight - nExtentsLeft, nExtentsBottom - nExtentsTop); cairo_set_source_surface(copycr, target_surface, 0, 0); -cairo_paint(copycr); +cairo_fill(copycr); cairo_destroy(copycr); cairo_surface_destroy(target_surface); }
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/CairoCommon.cxx | 194 --- vcl/inc/headless/CairoCommon.hxx |6 + 2 files changed, 106 insertions(+), 94 deletions(-) New commits: commit 95dceefe207da45bd955d07a88bf7a956b274081 Author: Noel Grandin AuthorDate: Sat Nov 12 14:53:46 2022 +0200 Commit: Noel Grandin CommitDate: Mon Nov 14 17:24:36 2022 +0100 split CairoCommon XOR code into its own method Change-Id: If615f08a44a083d53c75f58af3578e59634f9a11 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142700 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 08a14b51bc08..cba7a7328fd4 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -448,114 +448,120 @@ void CairoCommon::releaseCairoContext(cairo_t* cr, bool bXorModeAllowed, //are some edge cases where legacy stuff still supports it, so //emulate it (slowly) here. if (bXoring) +doXorOnRelease(nExtentsLeft, nExtentsTop, nExtentsRight, nExtentsBottom, surface, nWidth); + +cairo_destroy(cr); // unref + +DamageHandler* pDamage += static_cast(cairo_surface_get_user_data(m_pSurface, getDamageKey())); + +if (pDamage) { -cairo_surface_t* target_surface = m_pSurface; -if (cairo_surface_get_type(target_surface) != CAIRO_SURFACE_TYPE_IMAGE) -{ -//in the unlikely case we can't use m_pSurface directly, copy contents -//to another temp image surface -cairo_t* copycr = createTmpCompatibleCairoContext(); -cairo_rectangle(copycr, nExtentsLeft, nExtentsTop, nExtentsRight - nExtentsLeft, -nExtentsBottom - nExtentsTop); -cairo_set_source_surface(copycr, m_pSurface, 0, 0); -cairo_paint(copycr); -target_surface = cairo_get_target(copycr); -cairo_destroy(copycr); -} +pDamage->damaged(pDamage->handle, nExtentsLeft, nExtentsTop, nExtentsRight - nExtentsLeft, + nExtentsBottom - nExtentsTop); +} +} -cairo_surface_flush(target_surface); -unsigned char* target_surface_data = cairo_image_surface_get_data(target_surface); -unsigned char* xor_surface_data = cairo_image_surface_get_data(surface); - -cairo_format_t nFormat = cairo_image_surface_get_format(target_surface); -assert(nFormat == CAIRO_FORMAT_ARGB32 - && "need to implement CAIRO_FORMAT_A1 after all here"); -sal_Int32 nStride = cairo_format_stride_for_width(nFormat, nWidth * m_fScale); -sal_Int32 nUnscaledExtentsLeft = nExtentsLeft * m_fScale; -sal_Int32 nUnscaledExtentsRight = nExtentsRight * m_fScale; -sal_Int32 nUnscaledExtentsTop = nExtentsTop * m_fScale; -sal_Int32 nUnscaledExtentsBottom = nExtentsBottom * m_fScale; - -// Handle headless size forced to (1,1) by SvpSalFrame::GetSurfaceFrameSize(). -int target_surface_width = cairo_image_surface_get_width(target_surface); -if (nUnscaledExtentsLeft > target_surface_width) -nUnscaledExtentsLeft = target_surface_width; -if (nUnscaledExtentsRight > target_surface_width) -nUnscaledExtentsRight = target_surface_width; -int target_surface_height = cairo_image_surface_get_height(target_surface); -if (nUnscaledExtentsTop > target_surface_height) -nUnscaledExtentsTop = target_surface_height; -if (nUnscaledExtentsBottom > target_surface_height) -nUnscaledExtentsBottom = target_surface_height; +void CairoCommon::doXorOnRelease(sal_Int32 nExtentsLeft, sal_Int32 nExtentsTop, + sal_Int32 nExtentsRight, sal_Int32 nExtentsBottom, + cairo_surface_t* const surface, sal_Int32 nWidth) const +{ +//For the most part we avoid the use of XOR these days, but there +//are some edge cases where legacy stuff still supports it, so +//emulate it (slowly) here. +cairo_surface_t* target_surface = m_pSurface; +if (cairo_surface_get_type(target_surface) != CAIRO_SURFACE_TYPE_IMAGE) +{ +//in the unlikely case we can't use m_pSurface directly, copy contents +//to another temp image surface +cairo_t* copycr = createTmpCompatibleCairoContext(); +cairo_rectangle(copycr, nExtentsLeft, nExtentsTop, nExtentsRight - nExtentsLeft, +nExtentsBottom - nExtentsTop); +cairo_set_source_surface(copycr, m_pSurface, 0, 0); +cairo_paint(copycr); +target_surface = cairo_get_target(copycr); +cairo_destroy(copycr); +} + +cairo_surface_flush(target_surface); +unsigned char* target_surface_data = cairo_image_surface_get_data(target_surface); +unsigned char* xor_surface_data = cairo_image_surface_get_data(surface); + +cairo_format_t nFormat =
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit be89fcabd3da94a6441d0e2d07e0980a66d72e98 Author: Caolán McNamara AuthorDate: Fri Nov 11 09:02:54 2022 + Commit: Caolán McNamara CommitDate: Fri Nov 11 14:49:54 2022 +0100 ofz#53196 Out-of-memory Change-Id: I8cb6df1f109a1c10fb025b8ecd229487b73e900d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142578 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index d93ef1f2e5b7..08a14b51bc08 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -715,7 +715,7 @@ bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const C cairo_set_line_join(cr, eCairoLineJoin); cairo_set_line_cap(cr, eCairoLineCap); -constexpr int MaxNormalLineWidth = 94; +constexpr int MaxNormalLineWidth = 92; if (fLineWidth > MaxNormalLineWidth) { const double fLineWidthPixel
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 26edb7447e9f90d3cace16e31316a71148db80fe Author: Caolán McNamara AuthorDate: Sun Nov 6 15:58:01 2022 + Commit: Caolán McNamara CommitDate: Sun Nov 6 17:56:46 2022 +0100 ofz#52723 Out-of-memory Change-Id: Id563d2d7629c88d443360ec6a1086b1079f7f48b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142356 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index a25c508f39ce..d93ef1f2e5b7 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -715,7 +715,7 @@ bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const C cairo_set_line_join(cr, eCairoLineJoin); cairo_set_line_cap(cr, eCairoLineCap); -constexpr int MaxNormalLineWidth = 96; +constexpr int MaxNormalLineWidth = 94; if (fLineWidth > MaxNormalLineWidth) { const double fLineWidthPixel
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) New commits: commit e77beab92dfe1136a59c99af6571de6eae9f7e12 Author: Caolán McNamara AuthorDate: Fri Nov 4 13:16:34 2022 + Commit: Caolán McNamara CommitDate: Fri Nov 4 17:22:59 2022 +0100 ofz#53034 Null-dereference Change-Id: I3be4f2b976b64a2f592eeef9802e6cf8dd15341b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142278 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 8f11fdbd9b6c..a25c508f39ce 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -597,12 +597,20 @@ void CairoCommon::clipRegion(cairo_t* cr, const vcl::Region& rClipRegion) } if (!aRectangles.empty()) { +bool bEmpty = true; for (auto const& rectangle : aRectangles) { +if (rectangle.GetWidth() <= 0 || rectangle.GetHeight() <= 0) +{ +SAL_WARN("vcl.gdi", "bad clip rect of: " << rectangle); +continue; +} cairo_rectangle(cr, rectangle.Left(), rectangle.Top(), rectangle.GetWidth(), rectangle.GetHeight()); +bEmpty = false; } -cairo_clip(cr); +if (!bEmpty) +cairo_clip(cr); } }
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 96d7d4d16cfae09085d0baa41d5d70b5d33da726 Author: Caolán McNamara AuthorDate: Sat Oct 22 20:36:04 2022 +0100 Commit: Caolán McNamara CommitDate: Sat Oct 22 22:26:26 2022 +0200 ofz#52514 OOM Change-Id: Id4f3b3cef27a299e5496276e274406d0720a27fe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141672 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index ec73955f1c0b..8f11fdbd9b6c 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -707,7 +707,7 @@ bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const C cairo_set_line_join(cr, eCairoLineJoin); cairo_set_line_cap(cr, eCairoLineCap); -constexpr int MaxNormalLineWidth = 128; +constexpr int MaxNormalLineWidth = 96; if (fLineWidth > MaxNormalLineWidth) { const double fLineWidthPixel
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/source vcl/win
vcl/headless/BitmapHelper.cxx |8 vcl/headless/svpbmp.cxx |5 + vcl/inc/headless/svpbmp.hxx | 23 ++- vcl/inc/salbmp.hxx| 34 ++ vcl/inc/win/salbmp.h | 23 ++- vcl/source/bitmap/salbmp.cxx |6 ++ vcl/win/gdi/salbmp.cxx|9 +++-- 7 files changed, 60 insertions(+), 48 deletions(-) New commits: commit 2c5c611077278edd86247c58a078398ecf17a701 Author: Armin Le Grand (allotropia) AuthorDate: Mon Oct 17 14:22:08 2022 +0200 Commit: Armin Le Grand CommitDate: Mon Oct 17 19:13:53 2022 +0200 Move access to SystemDependentDataHolder to SalBitmap To be able to buffer BitmapData which is created based on Bitmap class data, move the access to basegfx::SystemDependentDataHolder from classes where it was used until now (WinSalBitmap and SvpSalBitmap) up to SalBitmap which is accessible outside vcl. This is a reorder plus a virtual access method to detect/access that helper layer, no functional change. It will be needed for system-dependent renderers when they want to use that standard buffering e.g. already used in the headless & windows backends. Change-Id: Ib30e7b98e722b977bb0c87ad253e3ffc1841e87e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141456 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/vcl/headless/BitmapHelper.cxx b/vcl/headless/BitmapHelper.cxx index ddd7e10db689..6657abec673e 100644 --- a/vcl/headless/BitmapHelper.cxx +++ b/vcl/headless/BitmapHelper.cxx @@ -206,7 +206,7 @@ void tryToUseSourceBuffer(const SalBitmap& rSourceBitmap, std::shared_ptr(rSourceBitmap)); pSystemDependentData_BitmapHelper -= rSrcBmp.getSystemDependentData(); += rSrcBmp.getSystemDependentDataT(); if (pSystemDependentData_BitmapHelper) { @@ -225,7 +225,7 @@ void tryToUseSourceBuffer(const SalBitmap& rSourceBitmap, std::shared_ptr(rSourceBitmap)); - rSrcBmp.addOrReplaceSystemDependentData( + rSrcBmp.addOrReplaceSystemDependentDataT( ImplGetSystemDependentDataManager(), rSurface); } } @@ -242,7 +242,7 @@ void tryToUseMaskBuffer(const SalBitmap& rMaskBitmap, std::shared_ptr(rMaskBitmap)); pSystemDependentData_MaskHelper -= rSrcBmp.getSystemDependentData(); += rSrcBmp.getSystemDependentDataT(); if (pSystemDependentData_MaskHelper) { @@ -261,7 +261,7 @@ void tryToUseMaskBuffer(const SalBitmap& rMaskBitmap, std::shared_ptr(rMaskBitmap)); - rSrcBmp.addOrReplaceSystemDependentData( + rSrcBmp.addOrReplaceSystemDependentDataT( ImplGetSystemDependentDataManager(), rMask); } } diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx index 167a5165a893..a72774068d30 100644 --- a/vcl/headless/svpbmp.cxx +++ b/vcl/headless/svpbmp.cxx @@ -268,4 +268,9 @@ bool SvpSalBitmap::Replace( const ::Color& /*rSearchColor*/, const ::Color& /*rR return false; } +const basegfx::SystemDependentDataHolder* SvpSalBitmap::accessSystemDependentDataHolder() const +{ +return this; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/headless/svpbmp.hxx b/vcl/inc/headless/svpbmp.hxx index 2c347372a4d4..29e730ad4d6f 100644 --- a/vcl/inc/headless/svpbmp.hxx +++ b/vcl/inc/headless/svpbmp.hxx @@ -61,27 +61,8 @@ public: virtual boolScale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) override; virtual boolReplace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) override; -// MM02 exclusive management op's for SystemDependentData at WinSalBitmap -template -std::shared_ptr getSystemDependentData() const -{ -return std::static_pointer_cast(basegfx::SystemDependentDataHolder::getSystemDependentData(typeid(T).hash_code())); -} - -template -std::shared_ptr addOrReplaceSystemDependentData(basegfx::SystemDependentDataManager& manager, Args&&... args) const -{ -std::shared_ptr r = std::make_shared(manager, std::forward(args)...); - -// tdf#129845 only add to buffer if a relevant buffer time is estimated -if(r->calculateCombinedHoldCyclesInSeconds() > 0) -{ -basegfx::SystemDependentData_SharedPtr r2(r); -const_cast< SvpSalBitmap* >(this)->basegfx::SystemDependentDataHolder::addOrReplaceSystemDependentData(r2); -} - -return r; -} +protected: +virtual const basegfx::SystemDependentDataHolder* accessSystemDependentDataHolder() const override; }; #endif // INCLUDED_VCL_INC_HEADLESS_SVPBMP_HXX diff --git a/vcl/inc/salbmp.hxx b/vcl/inc/salbmp.hxx index f04ea291aa84..32b1ffa14598 100644 --- a/vcl/inc/salbmp.hxx +++ b/vcl/inc/salbmp.hxx @@ -27,6 +27,7 @@ #include #include #include +#include
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx | 24 +++- 1 file changed, 19 insertions(+), 5 deletions(-) New commits: commit f72cd57a3397088433df32baed5c1eb5210a6712 Author: Caolán McNamara AuthorDate: Fri Oct 14 13:17:15 2022 +0100 Commit: Caolán McNamara CommitDate: Fri Oct 14 15:45:05 2022 +0200 ofz#52353 Out-of-memory with ultrathick lines Change-Id: Id907795a0e8f7646462edd510dfbc62ad2c26617 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141368 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index b0f93c1eaf41..11d4a9c0483a 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -708,12 +708,26 @@ bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const C cairo_set_line_join(cr, eCairoLineJoin); cairo_set_line_cap(cr, eCairoLineCap); constexpr int MaxNormalLineWidth = 128; -if (bObjectToDeviceIsIdentity && fLineWidth > MaxNormalLineWidth) +if (fLineWidth > MaxNormalLineWidth) { -SAL_WARN("vcl.gdi", "drawPolyLine, suspicious line width of: " << fLineWidth); -static const bool bFuzzing = utl::ConfigManager::IsFuzzing(); -if (bFuzzing) -fLineWidth = MaxNormalLineWidth; +const double fLineWidthPixel += bObjectToDeviceIsIdentity + ? fLineWidth + : (rObjectToDevice * basegfx::B2DVector(fLineWidth, 0)).getLength(); +if (fLineWidthPixel > MaxNormalLineWidth) +{ +SAL_WARN("vcl.gdi", "drawPolyLine, suspicious input line width of: " +<< fLineWidth << ", will be " << fLineWidthPixel +<< " pixels thick"); +static const bool bFuzzing = utl::ConfigManager::IsFuzzing(); +if (bFuzzing) +{ +basegfx::B2DHomMatrix aObjectToDeviceInv(rObjectToDevice); +aObjectToDeviceInv.invert(); +fLineWidth += (aObjectToDeviceInv * basegfx::B2DVector(MaxNormalLineWidth, 0)).getLength(); +} +} } cairo_set_line_width(cr, fLineWidth); cairo_set_miter_limit(cr, fMiterLimit);
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/SvpGraphicsBackend.cxx |9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) New commits: commit 937a96c7b8e9c02b6cc7dde3f2822d03c3c1cb4d Author: Caolán McNamara AuthorDate: Thu Oct 13 17:02:43 2022 +0100 Commit: Caolán McNamara CommitDate: Fri Oct 14 09:52:52 2022 +0200 ofz#52337 Direct-leak cairo starts leaking things when a surface is in an error state Change-Id: I0be0d9f8e3c8938073cec1aa765ab82826ceb6d9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141335 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 21917cd4a258..a0bbd789b9a0 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -528,9 +528,12 @@ void SvpGraphicsBackend::drawMask(const SalTwoRect& rTR, const SalBitmap& rSalBi cairo_scale(cr, fXScale, fYScale); cairo_set_source_surface(cr, aSurface.getSurface(), -rTR.mnSrcX, -rTR.mnSrcY); -//tdf#133716 borders of upscaled images should not be blurred -cairo_pattern_t* sourcepattern = cairo_get_source(cr); -cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_PAD); +if (cairo_status(cr) == CAIRO_STATUS_SUCCESS) +{ +//tdf#133716 borders of upscaled images should not be blurred +cairo_pattern_t* sourcepattern = cairo_get_source(cr); +cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_PAD); +} cairo_paint(cr);
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit f518928c322d45cdec4163c0182b0008da0da729 Author: Caolán McNamara AuthorDate: Tue Oct 11 20:18:20 2022 +0100 Commit: Caolán McNamara CommitDate: Wed Oct 12 00:15:27 2022 +0200 only interested in genuinely bizarely thick lines Change-Id: I107a46cc11127910f28977b88152c41e8b6c6467 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141239 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index fb6888bc91c9..b0f93c1eaf41 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -708,7 +708,7 @@ bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const C cairo_set_line_join(cr, eCairoLineJoin); cairo_set_line_cap(cr, eCairoLineCap); constexpr int MaxNormalLineWidth = 128; -if (fLineWidth > MaxNormalLineWidth) +if (bObjectToDeviceIsIdentity && fLineWidth > MaxNormalLineWidth) { SAL_WARN("vcl.gdi", "drawPolyLine, suspicious line width of: " << fLineWidth); static const bool bFuzzing = utl::ConfigManager::IsFuzzing();
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit f8afeb0e026ba70a4c8544ce7443caca601552f1 Author: Caolán McNamara AuthorDate: Sat Oct 8 21:01:19 2022 +0100 Commit: Caolán McNamara CommitDate: Sun Oct 9 09:48:53 2022 +0200 ofz#51852 Out-of-memory Change-Id: I945bb7d7ed90e8f5f4c085b4527f1ec7a4c08eae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141126 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index aa10f4ed3b49..fb6888bc91c9 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -707,7 +707,7 @@ bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const C cairo_set_line_join(cr, eCairoLineJoin); cairo_set_line_cap(cr, eCairoLineCap); -constexpr int MaxNormalLineWidth = 512; +constexpr int MaxNormalLineWidth = 128; if (fLineWidth > MaxNormalLineWidth) { SAL_WARN("vcl.gdi", "drawPolyLine, suspicious line width of: " << fLineWidth);
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/qt5 vcl/quartz vcl/source vcl/unx vcl/win
vcl/headless/svptext.cxx | 10 - vcl/inc/headless/svpgdi.hxx|2 - vcl/inc/qt5/QtGraphics.hxx |4 -- vcl/inc/quartz/salgdi.h|9 vcl/inc/salgdi.hxx |9 vcl/inc/textrender.hxx |3 - vcl/inc/unx/freetypetextrender.hxx |3 - vcl/inc/unx/genpspgraphics.h |4 -- vcl/inc/unx/salgdi.h |3 - vcl/inc/win/salgdi.h |8 vcl/qt5/QtGraphics_Text.cxx|8 vcl/quartz/salgdi.cxx | 12 -- vcl/source/font/PhysicalFontFace.cxx |6 ++- vcl/source/gdi/embeddedfontshelper.cxx |9 ++-- vcl/unx/generic/gdi/font.cxx | 10 - vcl/unx/generic/gdi/freetypetextrender.cxx | 10 - vcl/unx/generic/print/genpspgraphics.cxx | 47 - vcl/win/gdi/salfont.cxx| 53 - 18 files changed, 10 insertions(+), 200 deletions(-) New commits: commit 112d07027c4484dd571519911596d11eae897524 Author: Khaled Hosny AuthorDate: Sat Oct 1 08:21:58 2022 +0200 Commit: خالد حسني CommitDate: Sat Oct 1 13:09:48 2022 +0200 vcl: Use PhysicalFontFace::GetRawFontData() for font embedding Change-Id: I6f7c4508f7cef022eaf65a998cb242078d3771c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140826 Tested-by: Jenkins Reviewed-by: خالد حسني diff --git a/vcl/headless/svptext.cxx b/vcl/headless/svptext.cxx index 782caba56971..a41d3df1705a 100644 --- a/vcl/headless/svptext.cxx +++ b/vcl/headless/svptext.cxx @@ -62,16 +62,6 @@ bool SvpSalGraphics::AddTempDevFont( vcl::font::PhysicalFontCollection* pFontCol return m_aTextRenderImpl.AddTempDevFont(pFontCollection, rFileURL, rFontName); } -const void* SvpSalGraphics::GetEmbedFontData(const vcl::font::PhysicalFontFace* pFont, tools::Long* pDataLen) -{ -return m_aTextRenderImpl.GetEmbedFontData(pFont, pDataLen); -} - -void SvpSalGraphics::FreeEmbedFontData( const void* pData, tools::Long nLen ) -{ -m_aTextRenderImpl.FreeEmbedFontData(pData, nLen); -} - std::unique_ptr SvpSalGraphics::GetTextLayout(int nFallbackLevel) { return m_aTextRenderImpl.GetTextLayout(nFallbackLevel); diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index 7158a020eb6b..9197e83c20db 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -77,8 +77,6 @@ public: virtual voidGetDevFontList( vcl::font::PhysicalFontCollection* ) override; virtual void ClearDevFontCache() override; virtual boolAddTempDevFont( vcl::font::PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName ) override; -virtual const void* GetEmbedFontData(const vcl::font::PhysicalFontFace*, tools::Long* pDataLen) override; -virtual voidFreeEmbedFontData( const void* pData, tools::Long nDataLen ) override; virtual std::unique_ptr GetTextLayout(int nFallbackLevel) override; virtual voidDrawTextLayout( const GenericSalLayout& ) override; diff --git a/vcl/inc/qt5/QtGraphics.hxx b/vcl/inc/qt5/QtGraphics.hxx index 987ab1601f38..b8a168d1a3cf 100644 --- a/vcl/inc/qt5/QtGraphics.hxx +++ b/vcl/inc/qt5/QtGraphics.hxx @@ -232,10 +232,6 @@ public: virtual bool AddTempDevFont(vcl::font::PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName) override; -virtual const void* GetEmbedFontData(const vcl::font::PhysicalFontFace*, - tools::Long* pDataLen) override; -virtual void FreeEmbedFontData(const void* pData, tools::Long nDataLen) override; - virtual std::unique_ptr GetTextLayout(int nFallbackLevel) override; virtual void DrawTextLayout(const GenericSalLayout&) override; }; diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h index ec63592431e3..0bf004033c52 100644 --- a/vcl/inc/quartz/salgdi.h +++ b/vcl/inc/quartz/salgdi.h @@ -536,15 +536,6 @@ public: virtual voidClearDevFontCache() override; virtual boolAddTempDevFont( vcl::font::PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName ) override; -// GetEmbedFontData: gets the font data for a font marked -// embeddable by GetDevFontList or NULL in case of error -// parameters: pFont: describes the font in question -// pDataLen: out parameter, contains the byte length of the returned buffer -virtual const void* GetEmbedFontData(const vcl::font::PhysicalFontFace*, tools::Long* pDataLen) -override; -// frees the font data again -virtual voidFreeEmbedFontData( const void* pData, tools::Long nDataLen ) override; - virtual std::unique_ptr
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/win
vcl/headless/svpframe.cxx|1 + vcl/inc/headless/svpinst.hxx |3 --- vcl/inc/salsys.hxx |3 +++ vcl/win/window/salframe.cxx |7 +++ 4 files changed, 11 insertions(+), 3 deletions(-) New commits: commit 322ea272bba63ba779120ca5ead4a4b40d1bb93f Author: Stephan Bergmann AuthorDate: Mon Sep 26 11:04:09 2022 +0200 Commit: Stephan Bergmann CommitDate: Tue Sep 27 11:32:21 2022 +0200 Fix some headless window sizes on Windows, to make `make check` more reliable ...by making it more resilient against varying screen sizes. On my 2560x1600 Windows laptop, three `make check` tests systematically failed, and apparently all of them were caused by that larger-than-average screen (similar to what has been detailed in the commit message of 3db6a93c558c55eed085b4386228f9951bb08936 "Compute a better GetDefaultCenterPos"): * CppunitTest_sw_layoutwriter > test/source/xmltesttools.cxx:191:testTdf134298::TestBody > equality assertion failed > - Expected: 2 > - Actual : 3 > - In <>, XPath '/root/page' number of nodes is incorrect * CppunitTest_sw_ooxmlexport12 > sw/qa/extras/ooxmlexport/ooxmlexport12.cxx:526:testObjectCrossReference::TestBody > equality assertion failed > - Expected: Text 2 > - Actual : 2 * CppunitTest_sw_uiwriter2 > sw/qa/extras/uiwriter/uiwriter2.cxx:2702:testTdf122942::TestBody > equality assertion failed > - Expected: 2 > - Actual : 1 Those tests are all run with both SAL_USE_VCLPLUGIN=svp and --headless. But svp is only present on Linux and is thus ignored on Windows. And --headless, while preventing any windows from actually being shown, nevertheless uses the GUI code to set up window sizes. So the idea here is to hack the Windows backend in strategic places so that it uses "appropriate" window sizes in --headless mode to make `make check` succeed. The Linux svp backend has a single place in vcl/headless/svpframe.cxx where it hardcodes the number of monitors to 1 and the screen size to 1024x768. However, for the Windows backend, code determining and using those values is somewhat spread, but it turned out that there is one strategic place in ImplSalGetWorkArea that does what we want (without touching the reported number of monitors at all), without (it appears) negatively affecting other scenarios. (It appears that macOS, also not supporting an svp backend, is similarly affected. But it looks harder there to come up with such a strategic place to hardcode --headless window sizes, and at least my own macOS build's `make check` is unaffected as I use a default scaled 1829x1080 screen resolution there instead of the "raw" 3840x2160.) Change-Id: I822241f81497b9f6bed8e9688eddbe7d798c6b34 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140588 Reviewed-by: Mike Kaganski Tested-by: Jenkins Reviewed-by: Stephan Bergmann diff --git a/vcl/headless/svpframe.cxx b/vcl/headless/svpframe.cxx index 23a7e2595bda..5c6a713572d2 100644 --- a/vcl/headless/svpframe.cxx +++ b/vcl/headless/svpframe.cxx @@ -27,6 +27,7 @@ #ifndef IOS #include #endif +#include #include diff --git a/vcl/inc/headless/svpinst.hxx b/vcl/inc/headless/svpinst.hxx index 874ce672d97a..e9aada5bc001 100644 --- a/vcl/inc/headless/svpinst.hxx +++ b/vcl/inc/headless/svpinst.hxx @@ -32,9 +32,6 @@ #include -#define VIRTUAL_DESKTOP_WIDTH 1024 -#define VIRTUAL_DESKTOP_HEIGHT 768 - #ifdef IOS #define SvpSalInstance AquaSalInstance #endif diff --git a/vcl/inc/salsys.hxx b/vcl/inc/salsys.hxx index dff65b2f35cd..265380a1de2e 100644 --- a/vcl/inc/salsys.hxx +++ b/vcl/inc/salsys.hxx @@ -82,6 +82,9 @@ public: VCL_DLLPUBLIC SalSystem* ImplGetSalSystem(); +#define VIRTUAL_DESKTOP_WIDTH 1024 +#define VIRTUAL_DESKTOP_HEIGHT 768 + #endif // INCLUDED_VCL_INC_SALSYS_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index 9880613e7fa3..95cb08e20b07 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -174,6 +174,13 @@ void WinSalFrame::UpdateFrameState() // if pParentRect is set, the workarea of the monitor that contains pParentRect is returned void ImplSalGetWorkArea( HWND hWnd, RECT *pRect, const RECT *pParentRect ) { +if (Application::IsHeadlessModeEnabled()) { +pRect->left = 0; +pRect->top = 0; +pRect->right = VIRTUAL_DESKTOP_WIDTH; +pRect->bottom = VIRTUAL_DESKTOP_HEIGHT; +return; +} // check if we or our parent is fullscreen, then the taskbar should be ignored bool bIgnoreTaskbar = false; WinSalFrame* pFrame = GetWindowPtr( hWnd );
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/svpgdi.cxx |9 + vcl/inc/headless/svpgdi.hxx |2 ++ 2 files changed, 11 insertions(+) New commits: commit ce4e3d6f39cb4db138ff2445b27d7af7ad01ff33 Author: Caolán McNamara AuthorDate: Wed Sep 14 16:44:03 2022 +0100 Commit: Caolán McNamara CommitDate: Wed Sep 14 22:19:18 2022 +0200 Resolves: tdf#144583 reuse lok hidpi icon scheme for gtk Change-Id: I91dc9f7123b878e49a1ad57e5f40b6741ab04487 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139945 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index c97048dada12..322dab644f2a 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -51,6 +51,15 @@ void SvpSalGraphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) rDPIX = rDPIY = 96; } +bool SvpSalGraphics::ShouldDownscaleIconsAtSurface(double* pScaleOut) const +{ +if (comphelper::LibreOfficeKit::isActive()) +return SalGraphics::ShouldDownscaleIconsAtSurface(pScaleOut); +if (pScaleOut) +*pScaleOut = m_aCairoCommon.m_fScale; +return true; +} + #if ENABLE_CAIRO_CANVAS bool SvpSalGraphics::SupportsCairo() const { diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index 04e6bfa3eddf..7158a020eb6b 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -83,6 +83,8 @@ public: GetTextLayout(int nFallbackLevel) override; virtual voidDrawTextLayout( const GenericSalLayout& ) override; +virtual boolShouldDownscaleIconsAtSurface(double* pScaleOut) const override; + virtual SystemGraphicsData GetGraphicsData() const override; #if ENABLE_CAIRO_CANVAS
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/qt5 vcl/quartz vcl/source vcl/unx vcl/win
vcl/headless/svptext.cxx| 11 -- vcl/inc/font/PhysicalFontFace.hxx | 14 +++ vcl/inc/headless/svpgdi.hxx |7 - vcl/inc/qt5/QtGraphics.hxx |5 - vcl/inc/quartz/salgdi.h | 19 vcl/inc/salgdi.hxx | 21 - vcl/inc/textrender.hxx |7 - vcl/inc/unx/fontmanager.hxx | 18 vcl/inc/unx/freetypetextrender.hxx |7 - vcl/inc/unx/genpspgraphics.h|6 - vcl/inc/unx/salgdi.h|8 - vcl/inc/win/salgdi.h| 19 vcl/qt5/QtGraphics_Text.cxx | 32 --- vcl/quartz/salgdicommon.cxx | 44 -- vcl/source/font/PhysicalFontFace.cxx| 35 vcl/source/gdi/pdfwriter_impl.cxx | 13 --- vcl/unx/generic/fontmanager/fontmanager.cxx | 113 vcl/unx/generic/gdi/font.cxx| 13 --- vcl/unx/generic/gdi/freetypetextrender.cxx | 19 vcl/unx/generic/print/genpspgraphics.cxx| 19 vcl/win/gdi/salfont.cxx | 33 21 files changed, 53 insertions(+), 410 deletions(-) New commits: commit 38db900c1f7b471dfdf575bbda522a792db51372 Author: Khaled Hosny AuthorDate: Sun Sep 11 06:27:23 2022 +0200 Commit: خالد حسني CommitDate: Sun Sep 11 09:54:16 2022 +0200 vcl: Move CreateFontSubset() to PhysicalFontFace Having it in SalGraphics is not necessary as the code now depends on PhysicalFontFace for accessing raw font data, and this consolidates all the near identical copies of this code into one. Change-Id: I8a411f102fd2188a456bdeb8a0d794078d74e47b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139762 Tested-by: Jenkins Reviewed-by: خالد حسني diff --git a/vcl/headless/svptext.cxx b/vcl/headless/svptext.cxx index 26d0d3966f4e..782caba56971 100644 --- a/vcl/headless/svptext.cxx +++ b/vcl/headless/svptext.cxx @@ -62,17 +62,6 @@ bool SvpSalGraphics::AddTempDevFont( vcl::font::PhysicalFontCollection* pFontCol return m_aTextRenderImpl.AddTempDevFont(pFontCollection, rFileURL, rFontName); } -bool SvpSalGraphics::CreateFontSubset( -const OUString& rToFile, -const vcl::font::PhysicalFontFace* pFont, -const sal_GlyphId* pGlyphIds, -const sal_uInt8* pEncoding, -int nGlyphCount, -FontSubsetInfo& rInfo) -{ -return m_aTextRenderImpl.CreateFontSubset(rToFile, pFont, pGlyphIds, pEncoding, nGlyphCount, rInfo); -} - const void* SvpSalGraphics::GetEmbedFontData(const vcl::font::PhysicalFontFace* pFont, tools::Long* pDataLen) { return m_aTextRenderImpl.GetEmbedFontData(pFont, pDataLen); diff --git a/vcl/inc/font/PhysicalFontFace.hxx b/vcl/inc/font/PhysicalFontFace.hxx index 3f59dd3b25e4..8521ce752f32 100644 --- a/vcl/inc/font/PhysicalFontFace.hxx +++ b/vcl/inc/font/PhysicalFontFace.hxx @@ -29,6 +29,7 @@ #include #include +#include #include @@ -111,6 +112,19 @@ public: bool IsBetterMatch(const vcl::font::FontSelectPattern&, FontMatchStatus&) const; sal_Int32 CompareIgnoreSize(const PhysicalFontFace&) const; +// CreateFontSubset: a method to get a subset of glyhps of a font inside a +// new valid font file +// returns true if creation of subset was successful +// parameters: rToFile: contains an osl file URL to write the subset to +// pGlyphIDs: the glyph ids to be extracted +// pEncoding: the character code corresponding to each glyph +// nGlyphs: the number of glyphs +// rInfo: additional outgoing information +// implementation note: encoding 0 with glyph id 0 should be added implicitly +// as "undefined character" +bool CreateFontSubset(const OUString&, const sal_GlyphId*, const sal_uInt8*, const int, + FontSubsetInfo&) const; + virtual hb_face_t* GetHbFace() const; virtual hb_blob_t* GetHbTable(hb_tag_t) const { diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index 441ccf201861..04e6bfa3eddf 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -77,13 +77,6 @@ public: virtual voidGetDevFontList( vcl::font::PhysicalFontCollection* ) override; virtual void ClearDevFontCache() override; virtual boolAddTempDevFont( vcl::font::PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName ) override; -virtual boolCreateFontSubset( const OUString& rToFile, - const vcl::font::PhysicalFontFace*, - const sal_GlyphId* pGlyphIds, - const sal_uInt8* pEncoding, - int nGlyphs, -
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/qt5 vcl/quartz vcl/source vcl/unx vcl/win
vcl/headless/svptext.cxx|3 +-- vcl/inc/fontsubset.hxx |8 vcl/inc/headless/svpgdi.hxx |1 - vcl/inc/qt5/QtGraphics.hxx |2 +- vcl/inc/quartz/salgdi.h |1 - vcl/inc/salgdi.hxx |7 +++ vcl/inc/textrender.hxx |1 - vcl/inc/unx/fontmanager.hxx |1 - vcl/inc/unx/freetypetextrender.hxx |1 - vcl/inc/unx/genpspgraphics.h|1 - vcl/inc/unx/salgdi.h|1 - vcl/inc/win/salgdi.h|1 - vcl/qt5/QtGraphics_Text.cxx |7 +++ vcl/quartz/salgdicommon.cxx |8 vcl/source/fontsubset/cff.cxx | 14 -- vcl/source/fontsubset/fontsubset.cxx| 15 +++ vcl/source/gdi/pdfwriter_impl.cxx |4 ++-- vcl/source/gdi/salgdilayout.cxx | 23 --- vcl/unx/generic/fontmanager/fontmanager.cxx | 23 +-- vcl/unx/generic/gdi/font.cxx|3 +-- vcl/unx/generic/gdi/freetypetextrender.cxx |2 -- vcl/unx/generic/print/genpspgraphics.cxx|2 -- vcl/win/gdi/salfont.cxx |8 23 files changed, 39 insertions(+), 98 deletions(-) New commits: commit 394655636307de3ba3c4b2d52f3c1abf4b900e18 Author: Khaled Hosny AuthorDate: Mon Sep 5 22:36:20 2022 +0200 Commit: خالد حسني CommitDate: Tue Sep 6 15:09:57 2022 +0200 vcl: Drop unused SalGraphics::CreateFontSubset() argument pWidths is always nullptr. Change-Id: I1c666f146865786269e9513cbb6c8ffdc7df96e7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139461 Tested-by: Jenkins Reviewed-by: خالد حسني diff --git a/vcl/headless/svptext.cxx b/vcl/headless/svptext.cxx index 269061ea831d..26d0d3966f4e 100644 --- a/vcl/headless/svptext.cxx +++ b/vcl/headless/svptext.cxx @@ -67,11 +67,10 @@ bool SvpSalGraphics::CreateFontSubset( const vcl::font::PhysicalFontFace* pFont, const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncoding, -sal_Int32* pWidths, int nGlyphCount, FontSubsetInfo& rInfo) { -return m_aTextRenderImpl.CreateFontSubset(rToFile, pFont, pGlyphIds, pEncoding, pWidths, nGlyphCount, rInfo); +return m_aTextRenderImpl.CreateFontSubset(rToFile, pFont, pGlyphIds, pEncoding, nGlyphCount, rInfo); } const void* SvpSalGraphics::GetEmbedFontData(const vcl::font::PhysicalFontFace* pFont, tools::Long* pDataLen) diff --git a/vcl/inc/fontsubset.hxx b/vcl/inc/fontsubset.hxx index 2aed0a393e82..fef6603cd2fd 100644 --- a/vcl/inc/fontsubset.hxx +++ b/vcl/inc/fontsubset.hxx @@ -59,7 +59,7 @@ public: boolCreateFontSubset( FontType nOutFontTypeMask, FILE* pOutFile, const char* pOutFontName, const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncodedIds, -int nReqGlyphCount, sal_Int32* pOutGlyphWidths = nullptr ); +int nReqGlyphCount); public: // TODO: make subsetter results private and provide accessor methods instead // subsetter-provided subset details needed by e.g. Postscript or PDF @@ -85,9 +85,9 @@ private: const sal_uInt8*mpReqEncodedIds; int mnReqGlyphCount; -boolCreateFontSubsetFromCff( sal_Int32* pOutGlyphWidths ); -boolCreateFontSubsetFromSfnt( sal_Int32* pOutGlyphWidths ); -static bool CreateFontSubsetFromType1( const sal_Int32* pOutGlyphWidths ); +boolCreateFontSubsetFromCff(); +boolCreateFontSubsetFromSfnt(); +static bool CreateFontSubsetFromType1(); }; int VCL_DLLPUBLIC TestFontSubset(const void* data, sal_uInt32 size); diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index 83db19878f4d..441ccf201861 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -81,7 +81,6 @@ public: const vcl::font::PhysicalFontFace*, const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncoding, - sal_Int32* pWidths, int nGlyphs, FontSubsetInfo& rInfo ) override; diff --git a/vcl/inc/qt5/QtGraphics.hxx b/vcl/inc/qt5/QtGraphics.hxx index d7b25a9a150a..e8f5fdd9a58e 100644 --- a/vcl/inc/qt5/QtGraphics.hxx +++ b/vcl/inc/qt5/QtGraphics.hxx @@ -233,7 +233,7 @@ public: const OUString& rFontName) override; virtual bool CreateFontSubset(const OUString& rToFile, const vcl::font::PhysicalFontFace* pFont, const sal_GlyphId*
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/qt5 vcl/quartz vcl/source vcl/unx vcl/win
vcl/headless/svptext.cxx|8 vcl/inc/headless/svpgdi.hxx |4 -- vcl/inc/qt5/QtGraphics.hxx |3 - vcl/inc/quartz/salgdi.h |5 -- vcl/inc/salgdi.hxx | 15 --- vcl/inc/textrender.hxx |5 -- vcl/inc/unx/fontmanager.hxx |4 -- vcl/inc/unx/freetypetextrender.hxx |5 -- vcl/inc/unx/genpspgraphics.h|8 vcl/inc/unx/salgdi.h|6 --- vcl/inc/win/salgdi.h|4 -- vcl/qt5/QtGraphics_Text.cxx |9 vcl/quartz/salgdi.cxx | 26 - vcl/source/gdi/salgdilayout.cxx | 46 vcl/unx/generic/fontmanager/fontmanager.cxx | 53 vcl/unx/generic/gdi/font.cxx|8 vcl/unx/generic/gdi/freetypetextrender.cxx |8 vcl/unx/generic/print/genpspgraphics.cxx| 17 vcl/win/gdi/salfont.cxx | 28 -- 19 files changed, 262 deletions(-) New commits: commit 70e97793769baaa8e0fbb8d8d3949655c4aeb654 Author: Khaled Hosny AuthorDate: Mon Sep 5 21:50:05 2022 +0200 Commit: خالد حسني CommitDate: Tue Sep 6 15:08:34 2022 +0200 vcl: Drop now unused SalGraphics::GetGlyphWidths() Change-Id: Iec8974d6fc67d9d599c5e92aa325225963da0021 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139459 Tested-by: Jenkins Reviewed-by: خالد حسني diff --git a/vcl/headless/svptext.cxx b/vcl/headless/svptext.cxx index d702ec89a5ca..269061ea831d 100644 --- a/vcl/headless/svptext.cxx +++ b/vcl/headless/svptext.cxx @@ -84,14 +84,6 @@ void SvpSalGraphics::FreeEmbedFontData( const void* pData, tools::Long nLen ) m_aTextRenderImpl.FreeEmbedFontData(pData, nLen); } -void SvpSalGraphics::GetGlyphWidths( const vcl::font::PhysicalFontFace* pFont, - bool bVertical, - std::vector< sal_Int32 >& rWidths, - Ucs2UIntMap& rUnicodeEnc ) -{ -m_aTextRenderImpl.GetGlyphWidths(pFont, bVertical, rWidths, rUnicodeEnc); -} - std::unique_ptr SvpSalGraphics::GetTextLayout(int nFallbackLevel) { return m_aTextRenderImpl.GetTextLayout(nFallbackLevel); diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index a63e7f289abf..83db19878f4d 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -87,10 +87,6 @@ public: ) override; virtual const void* GetEmbedFontData(const vcl::font::PhysicalFontFace*, tools::Long* pDataLen) override; virtual voidFreeEmbedFontData( const void* pData, tools::Long nDataLen ) override; -virtual voidGetGlyphWidths( const vcl::font::PhysicalFontFace*, -bool bVertical, -std::vector< sal_Int32 >& rWidths, -Ucs2UIntMap& rUnicodeEnc ) override; virtual std::unique_ptr GetTextLayout(int nFallbackLevel) override; virtual voidDrawTextLayout( const GenericSalLayout& ) override; diff --git a/vcl/inc/qt5/QtGraphics.hxx b/vcl/inc/qt5/QtGraphics.hxx index fed7c2cb88f0..d7b25a9a150a 100644 --- a/vcl/inc/qt5/QtGraphics.hxx +++ b/vcl/inc/qt5/QtGraphics.hxx @@ -241,9 +241,6 @@ public: tools::Long* pDataLen) override; virtual void FreeEmbedFontData(const void* pData, tools::Long nDataLen) override; -virtual void GetGlyphWidths(const vcl::font::PhysicalFontFace*, bool bVertical, -std::vector& rWidths, Ucs2UIntMap& rUnicodeEnc) override; - virtual std::unique_ptr GetTextLayout(int nFallbackLevel) override; virtual void DrawTextLayout(const GenericSalLayout&) override; }; diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h index 6ec586ac1bdd..e2bd63306158 100644 --- a/vcl/inc/quartz/salgdi.h +++ b/vcl/inc/quartz/salgdi.h @@ -566,11 +566,6 @@ public: // frees the font data again virtual voidFreeEmbedFontData( const void* pData, tools::Long nDataLen ) override; -virtual voidGetGlyphWidths( const vcl::font::PhysicalFontFace*, -bool bVertical, -std::vector< sal_Int32 >& rWidths, -Ucs2UIntMap& rUnicodeEnc ) override; - virtual std::unique_ptr GetTextLayout(int nFallbackLevel) override; virtual voidDrawTextLayout( const GenericSalLayout& ) override; diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx index a050e4588042..4b2304ac8efd 100644 ---
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/SvpGraphicsBackend.cxx | 39 1 file changed, 39 insertions(+) New commits: commit b5c039a58dde8992c41f7d7e22cf393a15e1033e Author: Noel Grandin AuthorDate: Sun Aug 21 20:14:20 2022 +0200 Commit: Noel Grandin CommitDate: Fri Sep 2 11:15:48 2022 +0200 tdf#136370 speedup bitmap fill operations when drawing to an internal bitmap, we can use cairo_rect instead of cairo_polygon Change-Id: If298cddea71c6db2ffc3d3bcf15317e92b738f80 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139212 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 3907f2dd05a0..21917cd4a258 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -160,6 +160,45 @@ void SvpGraphicsBackend::drawRect(tools::Long nX, tools::Long nY, tools::Long nW void SvpGraphicsBackend::implDrawRect(double nX, double nY, double nWidth, double nHeight) { +// fast path for the common case of simply creating a solid block of color +if (m_rCairoCommon.m_aFillColor != SALCOLOR_NONE && m_rCairoCommon.m_aLineColor != SALCOLOR_NONE +&& m_rCairoCommon.m_aFillColor == m_rCairoCommon.m_aLineColor) +{ +double fTransparency = 0; + +// don't bother trying to draw stuff which is effectively invisible +if (nWidth < 0.1 || nHeight < 0.1) +return; + +cairo_t* cr = m_rCairoCommon.getCairoContext(true, getAntiAlias()); +m_rCairoCommon.clipRegion(cr); + +// To make releaseCairoContext work, use empty extents +basegfx::B2DRange extents; + +bool bPixelSnap = !getAntiAlias(); +if (bPixelSnap) +{ +// snap by rounding +nX = basegfx::fround(nX); +nY = basegfx::fround(nY); +nWidth = basegfx::fround(nWidth); +nHeight = basegfx::fround(nHeight); +} + +cairo_rectangle(cr, nX, nY, nWidth, nHeight); + +m_rCairoCommon.applyColor(cr, m_rCairoCommon.m_aFillColor, fTransparency); +// Get FillDamage (will be extended for LineDamage below) +extents = getClippedFillDamage(cr); + +cairo_fill(cr); + +m_rCairoCommon.releaseCairoContext(cr, true, extents); + +return; +} + // because of the -1 hack we have to do fill and draw separately Color aOrigFillColor = m_rCairoCommon.m_aFillColor; Color aOrigLineColor = m_rCairoCommon.m_aLineColor;
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit e15a5e6087eb0069f6e01089a3574314521f9244 Author: Caolán McNamara AuthorDate: Fri Aug 19 17:10:15 2022 +0100 Commit: Caolán McNamara CommitDate: Fri Aug 19 20:36:04 2022 +0200 ofz#50271 Out-of-memory with outsize line thickness Change-Id: Ia99e31c27b53110ae342cc49ba835a0b2f0224f1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138559 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index df4dae90778f..aa10f4ed3b49 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -707,7 +707,7 @@ bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const C cairo_set_line_join(cr, eCairoLineJoin); cairo_set_line_cap(cr, eCairoLineCap); -constexpr int MaxNormalLineWidth = 2048; +constexpr int MaxNormalLineWidth = 512; if (fLineWidth > MaxNormalLineWidth) { SAL_WARN("vcl.gdi", "drawPolyLine, suspicious line width of: " << fLineWidth);
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/unx
vcl/headless/svpinst.cxx |7 --- vcl/headless/svpvd.cxx | 10 +++--- vcl/inc/headless/svpvd.hxx |2 +- vcl/unx/gtk3/gtkinst.cxx |7 --- 4 files changed, 16 insertions(+), 10 deletions(-) New commits: commit d2d01d5128b6c01bbf5bf3febb2c0ac18ebc7eda Author: Caolán McNamara AuthorDate: Sat Aug 13 20:23:57 2022 +0100 Commit: Caolán McNamara CommitDate: Sun Aug 14 12:57:38 2022 +0200 ofz#50202 Direct-leak detect and flag as error failure to sucessfully create a cairo surface Change-Id: I6981ec3058e37f4f4f196f6136f1d81865623c52 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138238 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx index bf53dc24faf3..5a86826423e3 100644 --- a/vcl/headless/svpinst.cxx +++ b/vcl/headless/svpinst.cxx @@ -260,9 +260,10 @@ std::unique_ptr SvpSalInstance::CreateVirtualDevice(SalGraphic (void)pGd; cairo_surface_t* pPreExistingTarget = nullptr; #endif -std::unique_ptr pNew(new SvpSalVirtualDevice(pSvpSalGraphics->getSurface(), pPreExistingTarget)); -pNew->SetSize( nDX, nDY ); -return pNew; +std::unique_ptr xNew(new SvpSalVirtualDevice(pSvpSalGraphics->getSurface(), pPreExistingTarget)); +if (!xNew->SetSize(nDX, nDY)) +xNew.reset(); +return xNew; } cairo_surface_t* get_underlying_cairo_surface(const VirtualDevice& rDevice) diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx index 162bd78ec75a..ffbc3dc37190 100644 --- a/vcl/headless/svpvd.cxx +++ b/vcl/headless/svpvd.cxx @@ -69,7 +69,7 @@ bool SvpSalVirtualDevice::SetSize( tools::Long nNewDX, tools::Long nNewDY ) return SetSizeUsingBuffer(nNewDX, nNewDY, nullptr); } -void SvpSalVirtualDevice::CreateSurface(tools::Long nNewDX, tools::Long nNewDY, sal_uInt8 *const pBuffer) +bool SvpSalVirtualDevice::CreateSurface(tools::Long nNewDX, tools::Long nNewDY, sal_uInt8 *const pBuffer) { if (m_pSurface) { @@ -111,11 +111,14 @@ void SvpSalVirtualDevice::CreateSurface(tools::Long nNewDX, tools::Long nNewDY, } SAL_WARN_IF(cairo_surface_status(m_pSurface) != CAIRO_STATUS_SUCCESS, "vcl", "surface of size " << nNewDX << " by " << nNewDY << " creation failed with status of: " << cairo_status_to_string(cairo_surface_status(m_pSurface))); +return cairo_surface_status(m_pSurface) == CAIRO_STATUS_SUCCESS; } bool SvpSalVirtualDevice::SetSizeUsingBuffer( tools::Long nNewDX, tools::Long nNewDY, sal_uInt8 *const pBuffer) { +bool bSuccess = true; + if (nNewDX == 0) nNewDX = 1; if (nNewDY == 0) @@ -127,7 +130,7 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( tools::Long nNewDX, tools::Long nN m_aFrameSize = basegfx::B2IVector(nNewDX, nNewDY); if (m_bOwnsSurface) -CreateSurface(nNewDX, nNewDY, pBuffer); +bSuccess = CreateSurface(nNewDX, nNewDY, pBuffer); assert(m_pSurface); @@ -135,7 +138,8 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( tools::Long nNewDX, tools::Long nN for (auto const& graphic : m_aGraphics) graphic->setSurface(m_pSurface, m_aFrameSize); } -return true; + +return bSuccess; } tools::Long SvpSalVirtualDevice::GetWidth() const diff --git a/vcl/inc/headless/svpvd.hxx b/vcl/inc/headless/svpvd.hxx index ca9e38cee31a..f76b78c1df67 100644 --- a/vcl/inc/headless/svpvd.hxx +++ b/vcl/inc/headless/svpvd.hxx @@ -37,7 +37,7 @@ class VCL_DLLPUBLIC SvpSalVirtualDevice : public SalVirtualDevice basegfx::B2IVector m_aFrameSize; std::vector< SvpSalGraphics* > m_aGraphics; -void CreateSurface(tools::Long nNewDX, tools::Long nNewDY, sal_uInt8 *const pBuffer); +bool CreateSurface(tools::Long nNewDX, tools::Long nNewDY, sal_uInt8 *const pBuffer); protected: SvpSalGraphics* AddGraphics(SvpSalGraphics* aGraphics); diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index c434996c9552..74df879c85e1 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -383,9 +383,10 @@ std::unique_ptr GtkInstance::CreateVirtualDevice( SalGraphics assert(pSvpSalGraphics); // tdf#127529 see SvpSalInstance::CreateVirtualDevice for the rare case of a non-null pPreExistingTarget cairo_surface_t* pPreExistingTarget = pGd ? static_cast(pGd->pSurface) : nullptr; -std::unique_ptr pNew(new SvpSalVirtualDevice(pSvpSalGraphics->getSurface(), pPreExistingTarget)); -pNew->SetSize( nDX, nDY ); -return pNew; +std::unique_ptr xNew(new SvpSalVirtualDevice(pSvpSalGraphics->getSurface(), pPreExistingTarget)); +if (!xNew->SetSize(nDX, nDY)) +xNew.reset(); +return xNew; } std::shared_ptr GtkInstance::CreateSalBitmap()
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/svpframe.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit dbaf5f6fad2ec10f69cf46f9cb697b8760c2a01f Author: Jan-Marek Glogowski AuthorDate: Mon Jun 20 14:45:07 2022 +0200 Commit: Jan-Marek Glogowski CommitDate: Tue Jun 21 17:01:18 2022 +0200 svp: fix UB SalGraphics vector access Change-Id: Ic417ffbf91b04ebd6e6f18ac03b155fd01bbb316 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136226 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski diff --git a/vcl/headless/svpframe.cxx b/vcl/headless/svpframe.cxx index 9ab3864aa7cd..23a7e2595bda 100644 --- a/vcl/headless/svpframe.cxx +++ b/vcl/headless/svpframe.cxx @@ -423,7 +423,7 @@ void SvpSalFrame::UpdateSettings( AllSettings& rSettings ) aStdFont.SetFontSize(Size(0, 12)); aStyleSettings.SetMenuFont(aStdFont); -SvpSalGraphics* pGraphics = m_aGraphics.back(); +SvpSalGraphics* pGraphics = m_aGraphics.empty() ? nullptr : m_aGraphics.back(); bool bFreeGraphics = false; if (!pGraphics) {
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/osx vcl/qt5 vcl/source vcl/unx vcl/win
vcl/headless/svpframe.cxx |4 vcl/inc/headless/svpframe.hxx |1 - vcl/inc/osx/salframe.h |1 - vcl/inc/qt5/QtFrame.hxx |1 - vcl/inc/salframe.hxx|1 - vcl/inc/unx/gtk/gtkframe.hxx|1 - vcl/inc/unx/salframe.h |1 - vcl/inc/win/salframe.h |1 - vcl/osx/salframe.cxx|4 vcl/qt5/QtFrame.cxx |2 -- vcl/source/window/menubarwindow.cxx |3 --- vcl/unx/generic/window/salframe.cxx |5 - vcl/unx/gtk3/gtkframe.cxx |4 vcl/win/window/salframe.cxx |5 - 14 files changed, 34 deletions(-) New commits: commit 14dfbfe1da056d9570c85df8b5d5bed3943d46e9 Author: Jan-Marek Glogowski AuthorDate: Sat Jun 11 01:49:02 2022 +0200 Commit: Jan-Marek Glogowski CommitDate: Wed Jun 15 12:17:36 2022 +0200 Drop SalMenu::DrawMenuBar (is WIN-only) This follow-up on commit 483f3125ecd4744cbcc2f8fd3cdf243d81a601ff ("WIN drop effectively empty ImplDrawMenuBar") should probably have been included in it. Windows was the only implementation of that API, but the API is just called for a native menubar, which Windows doesn't use (VisibleMenuBar returns false). Maybe Windows SalFrame::SetMenu should also be dropped? Change-Id: Ic3600e66c91ce9d56d7f911bce5674e0a9ee833c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135633 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski diff --git a/vcl/headless/svpframe.cxx b/vcl/headless/svpframe.cxx index 62b43dfd0824..9ab3864aa7cd 100644 --- a/vcl/headless/svpframe.cxx +++ b/vcl/headless/svpframe.cxx @@ -200,10 +200,6 @@ void SvpSalFrame::SetMenu( SalMenu* ) { } -void SvpSalFrame::DrawMenuBar() -{ -} - void SvpSalFrame::SetExtendedFrameStyle( SalExtStyle ) { } diff --git a/vcl/inc/headless/svpframe.hxx b/vcl/inc/headless/svpframe.hxx index f2fce5c420b4..bb15711aef53 100644 --- a/vcl/inc/headless/svpframe.hxx +++ b/vcl/inc/headless/svpframe.hxx @@ -80,7 +80,6 @@ public: virtual voidSetTitle( const OUString& rTitle ) override; virtual voidSetIcon( sal_uInt16 nIcon ) override; virtual voidSetMenu( SalMenu* pMenu ) override; -virtual voidDrawMenuBar() override; virtual voidSetExtendedFrameStyle( SalExtStyle nExtStyle ) override; virtual voidShow( bool bVisible, bool bNoActivate = false ) override; diff --git a/vcl/inc/osx/salframe.h b/vcl/inc/osx/salframe.h index 953a17adbcc9..71b8eb45b772 100644 --- a/vcl/inc/osx/salframe.h +++ b/vcl/inc/osx/salframe.h @@ -116,7 +116,6 @@ public: virtual voidSetIcon( sal_uInt16 nIcon ) override; virtual voidSetRepresentedURL( const OUString& ) override; virtual voidSetMenu( SalMenu* pSalMenu ) override; -virtual voidDrawMenuBar() override; virtual voidShow( bool bVisible, bool bNoActivate = false ) override; virtual voidSetMinClientSize( tools::Long nWidth, tools::Long nHeight ) override; diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx index dcdca17844ae..562c7d3ba89a 100644 --- a/vcl/inc/qt5/QtFrame.hxx +++ b/vcl/inc/qt5/QtFrame.hxx @@ -160,7 +160,6 @@ public: virtual void SetTitle(const OUString& rTitle) override; virtual void SetIcon(sal_uInt16 nIcon) override; virtual void SetMenu(SalMenu* pMenu) override; -virtual void DrawMenuBar() override; virtual void registerDragSource(QtDragSource* pDragSource); virtual void deregisterDragSource(QtDragSource const* pDragSource); diff --git a/vcl/inc/salframe.hxx b/vcl/inc/salframe.hxx index e6c111c1dab5..45ed72956656 100644 --- a/vcl/inc/salframe.hxx +++ b/vcl/inc/salframe.hxx @@ -144,7 +144,6 @@ public: virtual voidSetIcon( sal_uInt16 nIcon ) = 0; virtual voidSetRepresentedURL( const OUString& ); virtual voidSetMenu( SalMenu *pSalMenu ) = 0; -virtual voidDrawMenuBar() = 0; virtual voidSetExtendedFrameStyle( SalExtStyle nExtStyle ) = 0; diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx index 2adacd1ee5ba..80696439ea79 100644 --- a/vcl/inc/unx/gtk/gtkframe.hxx +++ b/vcl/inc/unx/gtk/gtkframe.hxx @@ -506,7 +506,6 @@ public: virtual voidSetIcon( sal_uInt16 nIcon ) override; virtual voidSetMenu( SalMenu *pSalMenu ) override; SalMenu*GetMenu(); -virtual voidDrawMenuBar() override; voidEnsureAppMenuWatch(); virtual voidSetExtendedFrameStyle( SalExtStyle nExtStyle ) override; diff --git a/vcl/inc/unx/salframe.h b/vcl/inc/unx/salframe.h index 46d23f71aaf9..597657333128 100644 ---
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx |8 1 file changed, 8 insertions(+) New commits: commit c776524c5dda930a6c82cb81b594769802445c79 Author: Caolán McNamara AuthorDate: Tue Jun 14 15:10:33 2022 +0100 Commit: Caolán McNamara CommitDate: Tue Jun 14 21:39:48 2022 +0200 ofz#47668 OOM on massive line widths Change-Id: I310a9d438ef6f50ecc5931cea12fb26b7ed600c8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135832 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index d44724e8a710..1888989b130b 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -707,6 +707,14 @@ bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const C cairo_set_line_join(cr, eCairoLineJoin); cairo_set_line_cap(cr, eCairoLineCap); +constexpr int MaxNormalLineWidth = 4096; +if (fLineWidth > MaxNormalLineWidth) +{ +SAL_WARN("vcl.gdi", "drawPolyLine, suspicious line width of: " << fLineWidth); +static const bool bFuzzing = utl::ConfigManager::IsFuzzing(); +if (bFuzzing) +fLineWidth = MaxNormalLineWidth; +} cairo_set_line_width(cr, fLineWidth); cairo_set_miter_limit(cr, fMiterLimit);
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx|2 +- vcl/headless/SvpGraphicsBackend.cxx |4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) New commits: commit 6b12ba07be44099725b722c8d86227d7ec79885f Author: Andrea Gelmini AuthorDate: Tue May 17 13:00:49 2022 +0200 Commit: Julien Nabet CommitDate: Wed May 18 20:48:02 2022 +0200 Fix typo Change-Id: I476e2eb0769a542ca17b440fa98838f39a12efcc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134467 Tested-by: Jenkins Reviewed-by: Julien Nabet diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 9897334d4532..d44724e8a710 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -877,7 +877,7 @@ basegfx::B2DRange renderWithOperator(cairo_t* cr, const SalTwoRect& rTR, cairo_s cairo_save(cr); cairo_set_source_surface(cr, source, -rTR.mnSrcX, -rTR.mnSrcY); -//tdf#133716 borders of upscaled images should not be blured +//tdf#133716 borders of upscaled images should not be blurred cairo_pattern_t* sourcepattern = cairo_get_source(cr); cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_PAD); diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 0566f444013d..209e2e880c83 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -489,7 +489,7 @@ void SvpGraphicsBackend::drawMask(const SalTwoRect& rTR, const SalBitmap& rSalBi cairo_scale(cr, fXScale, fYScale); cairo_set_source_surface(cr, aSurface.getSurface(), -rTR.mnSrcX, -rTR.mnSrcY); -//tdf#133716 borders of upscaled images should not be blured +//tdf#133716 borders of upscaled images should not be blurred cairo_pattern_t* sourcepattern = cairo_get_source(cr); cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_PAD); @@ -675,7 +675,7 @@ bool SvpGraphicsBackend::drawAlphaBitmap(const SalTwoRect& rTR, const SalBitmap& cairo_pattern_t* sourcepattern = cairo_get_source(cr); -//tdf#133716 borders of upscaled images should not be blured +//tdf#133716 borders of upscaled images should not be blurred //tdf#114117 when stretching a single or multi pixel width/height source to fit an area //the image will be extended into that size. cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_PAD);
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx| 11 +-- vcl/headless/SvpGraphicsBackend.cxx | 28 2 files changed, 17 insertions(+), 22 deletions(-) New commits: commit 20f0ab23b1c0b60ca36a053464f3ba41bf27c80e Author: dldld AuthorDate: Sat May 14 17:54:35 2022 +0200 Commit: Caolán McNamara CommitDate: Sat May 14 20:00:56 2022 +0200 tdf#133716: Fix edge gradient when upscaling image When an image is getting upscaled with cario as engine it got blured borders. The issue that was worked on showed, in the PresenterConsole, that the borders of the previews and control area had an unnecessary gradient in it. As these borders are build from images which are getting upscaled, either in width or height a graident ocurred. This was because the cairo rending didn't had the correct pattern extention set: CAIRO_EXTEND_PAD. Nearly same issue also occured when adding an image to a presentation and upscaling it, the borders got blured. For images with either height or width equal to one this was a while back fixed: tdf#114117, but not for the general case. Using another extend mode fixes this, because the PAD extend mode doesn't blur the borders. CAIRO_EXTEND_PAD: pixels outside of the pattern copy the closest pixel from the source Change-Id: I39f8a14a69f035a43a93afb303f0a2e7ec8699c7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134325 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 73a6b72f802e..9897334d4532 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -876,12 +876,11 @@ basegfx::B2DRange renderWithOperator(cairo_t* cr, const SalTwoRect& rTR, cairo_s cairo_save(cr); cairo_set_source_surface(cr, source, -rTR.mnSrcX, -rTR.mnSrcY); -if ((fXScale != 1.0 && rTR.mnSrcWidth == 1) || (fYScale != 1.0 && rTR.mnSrcHeight == 1)) -{ -cairo_pattern_t* sourcepattern = cairo_get_source(cr); -cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_REPEAT); -cairo_pattern_set_filter(sourcepattern, CAIRO_FILTER_NEAREST); -} + +//tdf#133716 borders of upscaled images should not be blured +cairo_pattern_t* sourcepattern = cairo_get_source(cr); +cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_PAD); + cairo_set_operator(cr, eOperator); cairo_paint(cr); cairo_restore(cr); diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 14a9a017ed94..0566f444013d 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -488,12 +488,11 @@ void SvpGraphicsBackend::drawMask(const SalTwoRect& rTR, const SalBitmap& rSalBi double fYScale = static_cast(rTR.mnDestHeight) / rTR.mnSrcHeight; cairo_scale(cr, fXScale, fYScale); cairo_set_source_surface(cr, aSurface.getSurface(), -rTR.mnSrcX, -rTR.mnSrcY); -if ((fXScale != 1.0 && rTR.mnSrcWidth == 1) || (fYScale != 1.0 && rTR.mnSrcHeight == 1)) -{ -cairo_pattern_t* sourcepattern = cairo_get_source(cr); -cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_REPEAT); -cairo_pattern_set_filter(sourcepattern, CAIRO_FILTER_NEAREST); -} + +//tdf#133716 borders of upscaled images should not be blured +cairo_pattern_t* sourcepattern = cairo_get_source(cr); +cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_PAD); + cairo_paint(cr); m_rCairoCommon.releaseCairoContext(cr, false, extents); @@ -674,16 +673,13 @@ bool SvpGraphicsBackend::drawAlphaBitmap(const SalTwoRect& rTR, const SalBitmap& cairo_scale(cr, fXScale, fYScale); cairo_set_source_surface(cr, source, -rTR.mnSrcX, -rTR.mnSrcY); -//tdf#114117 when stretching a single pixel width/height source to fit an area -//set extend and filter to stretch it with simplest expected interpolation -if ((fXScale != 1.0 && rTR.mnSrcWidth == 1) || (fYScale != 1.0 && rTR.mnSrcHeight == 1)) -{ -cairo_pattern_t* sourcepattern = cairo_get_source(cr); -cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_REPEAT); -cairo_pattern_set_filter(sourcepattern, CAIRO_FILTER_NEAREST); -cairo_pattern_set_extend(maskpattern, CAIRO_EXTEND_REPEAT); -cairo_pattern_set_filter(maskpattern, CAIRO_FILTER_NEAREST); -} +cairo_pattern_t* sourcepattern = cairo_get_source(cr); + +//tdf#133716 borders of upscaled images should not be blured +//tdf#114117 when stretching a single or multi pixel width/height source to fit an area +//the image will be extended into that size. +cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_PAD); +cairo_pattern_set_extend(maskpattern, CAIRO_EXTEND_PAD); //this block is just "cairo_mask_surface", but we have to make it explicit //because of the cairo_pattern_set_filter etc we may want
[Libreoffice-commits] core.git: vcl/headless vcl/source
vcl/headless/CairoCommon.cxx | 14 +++--- vcl/source/window/cursor.cxx |8 +++- 2 files changed, 10 insertions(+), 12 deletions(-) New commits: commit 6dc41e33e087032a52ee11832ff1299632b4f5dd Author: Caolán McNamara AuthorDate: Mon May 9 17:34:46 2022 +0100 Commit: Caolán McNamara CommitDate: Mon May 9 22:30:22 2022 +0200 Related: tdf#148433 experiment with SAL_DISABLE_CURSOR_INDICATOR to turn off the arrow indicators in BiDi cursor Change-Id: I5ed96bccf17432e63564bdfc1c7d2ad4fecdd2a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134090 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 2e2dcaecec6f..73a6b72f802e 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -960,16 +960,8 @@ cairo_pattern_t* create_stipple() } } // end anonymous ns -namespace -{ -// check for env var that deciding to disable CAIRO_OPERATOR_DIFFERENCE -const char* pDisableDifference(getenv("SAL_DISABLE_CAIRO_DIFFERENCE")); -bool bDisableDifference(nullptr != pDisableDifference); -} - #if defined CAIRO_VERSION && CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 10, 0) #define CAIRO_OPERATOR_DIFFERENCE (static_cast(23)) -#define CAIRO_OPERATOR_EXCLUSION (static_cast(24)) #endif void CairoCommon::invert(const basegfx::B2DPolygon& rPoly, SalInvert nFlags, bool bAntiAlias) @@ -984,13 +976,13 @@ void CairoCommon::invert(const basegfx::B2DPolygon& rPoly, SalInvert nFlags, boo cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); -if (bDisableDifference) +if (cairo_version() >= CAIRO_VERSION_ENCODE(1, 10, 0)) { -cairo_set_operator(cr, CAIRO_OPERATOR_EXCLUSION); +cairo_set_operator(cr, CAIRO_OPERATOR_DIFFERENCE); } else { -cairo_set_operator(cr, CAIRO_OPERATOR_DIFFERENCE); +SAL_WARN("vcl.gdi", "SvpSalGraphics::invert, archaic cairo"); } if (nFlags & SalInvert::TrackFrame) diff --git a/vcl/source/window/cursor.cxx b/vcl/source/window/cursor.cxx index 6a186da9432c..406491ed1d65 100644 --- a/vcl/source/window/cursor.cxx +++ b/vcl/source/window/cursor.cxx @@ -43,6 +43,12 @@ struct ImplCursorData VclPtr mpWindow; // assigned window }; +namespace +{ +const char* pDisableCursorIndicator(getenv("SAL_DISABLE_CURSOR_INDICATOR")); +bool bDisableCursorIndicator(nullptr != pDisableCursorIndicator); +} + static tools::Rectangle ImplCursorInvert(vcl::RenderContext* pRenderContext, ImplCursorData const * pData) { tools::Rectangle aPaintRect; @@ -65,7 +71,7 @@ static tools::Rectangle ImplCursorInvert(vcl::RenderContext* pRenderContext, Imp aPoly[2].AdjustX(1 ); // apply direction flag after slant to use the correct shape -if ( pData->mnDirection != CursorDirection::NONE) +if (!bDisableCursorIndicator && pData->mnDirection != CursorDirection::NONE) { Point pAry[7]; // Related system settings for "delta" could be:
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx |5 - 1 file changed, 4 insertions(+), 1 deletion(-) New commits: commit 10f3cb6aa8794d063ae5990066fcfa006d47c512 Author: Caolán McNamara AuthorDate: Mon May 9 12:10:16 2022 +0100 Commit: Caolán McNamara CommitDate: Mon May 9 16:07:01 2022 +0200 ofz#46070 Out-of-memory Change-Id: Ie7417f5f7e0ed49cfc3b38eda3117d53c8a2a59e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134053 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 7cf2951b9da6..2e2dcaecec6f 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -313,9 +314,11 @@ SystemDependentData_CairoPath::SystemDependentData_CairoPath( , mbNoJoin(bNoJoin) , mbAntiAlias(bAntiAlias) { +static const bool bFuzzing = utl::ConfigManager::IsFuzzing(); + // tdf#129845 only create a copy of the path when nSizeMeasure is // bigger than some decent threshold -if (nSizeMeasure > 50) +if (!bFuzzing && nSizeMeasure > 50) { mpCairoPath = cairo_copy_path(cr);
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/SvpGraphicsBackend.cxx |5 + vcl/inc/headless/SvpGraphicsBackend.hxx |3 +++ 2 files changed, 8 insertions(+) New commits: commit fd4a089df684a38cff18e77217961ee4bee0c497 Author: Caolán McNamara AuthorDate: Sun May 8 15:30:42 2022 +0100 Commit: Caolán McNamara CommitDate: Sun May 8 20:33:58 2022 +0200 ofz#46607 Integer-overflow Change-Id: Id759423176b2e47fc00b8e7babd936b480956617 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134025 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 223b333e9bef..14a9a017ed94 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -154,6 +154,11 @@ void SvpGraphicsBackend::drawLine(tools::Long nX1, tools::Long nY1, tools::Long void SvpGraphicsBackend::drawRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight) +{ +implDrawRect(nX, nY, nWidth, nHeight); +} + +void SvpGraphicsBackend::implDrawRect(double nX, double nY, double nWidth, double nHeight) { // because of the -1 hack we have to do fill and draw separately Color aOrigFillColor = m_rCairoCommon.m_aFillColor; diff --git a/vcl/inc/headless/SvpGraphicsBackend.hxx b/vcl/inc/headless/SvpGraphicsBackend.hxx index 16f9213576fd..997f1bc84e9d 100644 --- a/vcl/inc/headless/SvpGraphicsBackend.hxx +++ b/vcl/inc/headless/SvpGraphicsBackend.hxx @@ -134,6 +134,9 @@ public: void drawBitmapBuffer(const SalTwoRect& rPosAry, const BitmapBuffer* pBuffer, cairo_operator_t eOp); + +private: +void implDrawRect(double nX, double nY, double nWidth, double nHeight); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx |7 --- 1 file changed, 4 insertions(+), 3 deletions(-) New commits: commit 00e43c14558fa4d0369820fa3d2cd7b987e61377 Author: Caolán McNamara AuthorDate: Sun May 1 15:58:22 2022 +0100 Commit: Caolán McNamara CommitDate: Mon May 2 18:37:33 2022 +0200 Related: tdf#148433 experiment with CAIRO_OPERATOR_EXCLUSION export SAL_DISABLE_CAIRO_DIFFERENCE=1 to experiment with this Change-Id: If0e5fee8c71ae3d2181b1e0b90bf9ecd6536ffc0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133671 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 02c281fea3cb..7cf2951b9da6 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -966,6 +966,7 @@ bool bDisableDifference(nullptr != pDisableDifference); #if defined CAIRO_VERSION && CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 10, 0) #define CAIRO_OPERATOR_DIFFERENCE (static_cast(23)) +#define CAIRO_OPERATOR_EXCLUSION (static_cast(24)) #endif void CairoCommon::invert(const basegfx::B2DPolygon& rPoly, SalInvert nFlags, bool bAntiAlias) @@ -980,13 +981,13 @@ void CairoCommon::invert(const basegfx::B2DPolygon& rPoly, SalInvert nFlags, boo cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); -if (cairo_version() >= CAIRO_VERSION_ENCODE(1, 10, 0) && !bDisableDifference) +if (bDisableDifference) { -cairo_set_operator(cr, CAIRO_OPERATOR_DIFFERENCE); +cairo_set_operator(cr, CAIRO_OPERATOR_EXCLUSION); } else { -SAL_WARN("vcl.gdi", "SvpSalGraphics::invert, archaic cairo"); +cairo_set_operator(cr, CAIRO_OPERATOR_DIFFERENCE); } if (nFlags & SalInvert::TrackFrame)
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx |9 - 1 file changed, 8 insertions(+), 1 deletion(-) New commits: commit 90057e372cd07b41c8dbba4e7b7f107568a5f451 Author: Caolán McNamara AuthorDate: Mon Apr 25 20:03:35 2022 +0100 Commit: Caolán McNamara CommitDate: Tue Apr 26 11:37:08 2022 +0200 Related: tdf#148433 test if CAIRO_OPERATOR_DIFFERENCE is the problem export SAL_DISABLE_CAIRO_DIFFERENCE=1 to experiment with this Change-Id: I61ec30c818727cb6ab382b4cf9fe9bd29d8d179d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133419 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index cc5d9df10243..02c281fea3cb 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -957,6 +957,13 @@ cairo_pattern_t* create_stipple() } } // end anonymous ns +namespace +{ +// check for env var that deciding to disable CAIRO_OPERATOR_DIFFERENCE +const char* pDisableDifference(getenv("SAL_DISABLE_CAIRO_DIFFERENCE")); +bool bDisableDifference(nullptr != pDisableDifference); +} + #if defined CAIRO_VERSION && CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 10, 0) #define CAIRO_OPERATOR_DIFFERENCE (static_cast(23)) #endif @@ -973,7 +980,7 @@ void CairoCommon::invert(const basegfx::B2DPolygon& rPoly, SalInvert nFlags, boo cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); -if (cairo_version() >= CAIRO_VERSION_ENCODE(1, 10, 0)) +if (cairo_version() >= CAIRO_VERSION_ENCODE(1, 10, 0) && !bDisableDifference) { cairo_set_operator(cr, CAIRO_OPERATOR_DIFFERENCE); }
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/CairoCommon.cxx |4 vcl/headless/svpgdi.cxx |7 --- 2 files changed, 4 insertions(+), 7 deletions(-) New commits: commit 2739f18fa93733a128321255aa49ddbefde36314 Author: Caolán McNamara AuthorDate: Mon Apr 25 19:57:20 2022 +0100 Commit: Caolán McNamara CommitDate: Tue Apr 26 09:45:45 2022 +0200 CAIRO_OPERATOR_DIFFERENCE define should have followed its usage when that was moved to here Change-Id: I34565d3568c7e75a9f0abac94360e3ff769afbd0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133418 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index ab8cdb0b30bc..cc5d9df10243 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -957,6 +957,10 @@ cairo_pattern_t* create_stipple() } } // end anonymous ns +#if defined CAIRO_VERSION && CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 10, 0) +#define CAIRO_OPERATOR_DIFFERENCE (static_cast(23)) +#endif + void CairoCommon::invert(const basegfx::B2DPolygon& rPoly, SalInvert nFlags, bool bAntiAlias) { cairo_t* cr = getCairoContext(false, bAntiAlias); diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 881d42be256c..c97048dada12 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -25,13 +25,6 @@ #include #include - -#if ENABLE_CAIRO_CANVAS -# if defined CAIRO_VERSION && CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 10, 0) -# define CAIRO_OPERATOR_DIFFERENCE (static_cast(23)) -# endif -#endif - SvpSalGraphics::SvpSalGraphics() : m_aTextRenderImpl(*this) , m_pBackend(new SvpGraphicsBackend(m_aCairoCommon))
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/svptext.cxx |3 --- 1 file changed, 3 deletions(-) New commits: commit 8182d26ddc66b1d89b60653fffec2780d4ec1b71 Author: Caolán McNamara AuthorDate: Sun Apr 10 20:45:35 2022 +0100 Commit: Caolán McNamara CommitDate: Sun Apr 10 22:50:51 2022 +0200 ofz#46587 Integer-overflow Change-Id: Icdc3d899a403f5c6dfa7247a3b71a97721e83f25 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132789 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/svptext.cxx b/vcl/headless/svptext.cxx index c79dadc9a4fc..d702ec89a5ca 100644 --- a/vcl/headless/svptext.cxx +++ b/vcl/headless/svptext.cxx @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -95,8 +94,6 @@ void SvpSalGraphics::GetGlyphWidths( const vcl::font::PhysicalFontFace* pFont, std::unique_ptr SvpSalGraphics::GetTextLayout(int nFallbackLevel) { -if (utl::ConfigManager::IsFuzzing()) -return nullptr; return m_aTextRenderImpl.GetTextLayout(nFallbackLevel); }
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/qt5 vcl/unx
vcl/headless/svpcairotextrender.cxx |4 ++-- vcl/inc/headless/svpgdi.hxx |8 vcl/qt5/QtSvpSurface.cxx |2 +- vcl/unx/gtk3/gtkcairo.cxx |2 +- vcl/unx/gtk3/salnativewidgets-gtk.cxx |2 +- 5 files changed, 9 insertions(+), 9 deletions(-) New commits: commit 463c851ac898a81465632d090a1d2c8fcc3ca297 Author: Noel Grandin AuthorDate: Thu Mar 24 09:05:07 2022 +0200 Commit: Noel Grandin CommitDate: Thu Mar 24 19:54:04 2022 +0100 loplugin:constantparam Change-Id: I6bfbd0cb5c2eac60bdac69fd862154fb2f537a89 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132030 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/vcl/headless/svpcairotextrender.cxx b/vcl/headless/svpcairotextrender.cxx index 9abd5902864d..c64bafae0969 100644 --- a/vcl/headless/svpcairotextrender.cxx +++ b/vcl/headless/svpcairotextrender.cxx @@ -16,7 +16,7 @@ SvpCairoTextRender::SvpCairoTextRender(SvpSalGraphics& rParent) { } -cairo_t* SvpCairoTextRender::getCairoContext() { return mrParent.getCairoContext(false); } +cairo_t* SvpCairoTextRender::getCairoContext() { return mrParent.getCairoContext(); } void SvpCairoTextRender::getSurfaceOffset(double& nDX, double& nDY) { @@ -28,7 +28,7 @@ void SvpCairoTextRender::clipRegion(cairo_t* cr) { mrParent.clipRegion(cr); } void SvpCairoTextRender::releaseCairoContext(cairo_t* cr) { -mrParent.releaseCairoContext(cr, false, basegfx::B2DRange()); +mrParent.releaseCairoContext(cr, basegfx::B2DRange()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index b3b932cc3d73..a63e7f289abf 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -105,14 +105,14 @@ public: virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) const override; #endif // ENABLE_CAIRO_CANVAS -cairo_t* getCairoContext(bool bXorModeAllowed) const +cairo_t* getCairoContext() const { -return m_aCairoCommon.getCairoContext(bXorModeAllowed, getAntiAlias()); +return m_aCairoCommon.getCairoContext(/*bXorModeAllowed*/false, getAntiAlias()); } -void releaseCairoContext(cairo_t* cr, bool bXorModeAllowed, const basegfx::B2DRange& rExtents) const +void releaseCairoContext(cairo_t* cr, const basegfx::B2DRange& rExtents) const { -return m_aCairoCommon.releaseCairoContext(cr, bXorModeAllowed, rExtents); +return m_aCairoCommon.releaseCairoContext(cr, /*bXorModeAllowed*/false, rExtents); } void clipRegion(cairo_t* cr) diff --git a/vcl/qt5/QtSvpSurface.cxx b/vcl/qt5/QtSvpSurface.cxx index 456de177ce2c..a2a39c12b387 100644 --- a/vcl/qt5/QtSvpSurface.cxx +++ b/vcl/qt5/QtSvpSurface.cxx @@ -42,7 +42,7 @@ QtSvpSurface::QtSvpSurface(const CairoSurfaceSharedPtr& pSurface) QtSvpSurface::QtSvpSurface(const QtSvpGraphics* pGraphics, int x, int y, int width, int height) : m_pGraphics(pGraphics) -, m_pCairoContext(pGraphics->getCairoContext(false)) +, m_pCairoContext(pGraphics->getCairoContext()) { cairo_surface_t* surface = cairo_get_target(m_pCairoContext); m_pSurface.reset(cairo_surface_create_for_rectangle(surface, x, y, width, height), diff --git a/vcl/unx/gtk3/gtkcairo.cxx b/vcl/unx/gtk3/gtkcairo.cxx index 8c684295f046..202e3244d617 100644 --- a/vcl/unx/gtk3/gtkcairo.cxx +++ b/vcl/unx/gtk3/gtkcairo.cxx @@ -55,7 +55,7 @@ namespace cairo **/ Gtk3Surface::Gtk3Surface(const GtkSalGraphics* pGraphics, int x, int y, int width, int height) : mpGraphics(pGraphics) -, cr(pGraphics->getCairoContext(false)) +, cr(pGraphics->getCairoContext()) { cairo_surface_t* surface = cairo_get_target(cr); mpSurface.reset( diff --git a/vcl/unx/gtk3/salnativewidgets-gtk.cxx b/vcl/unx/gtk3/salnativewidgets-gtk.cxx index 0505010bea81..e2cef41100ec 100644 --- a/vcl/unx/gtk3/salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/salnativewidgets-gtk.cxx @@ -1802,7 +1802,7 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co return false; } -cairo_t *cr = getCairoContext(false); +cairo_t *cr = getCairoContext(); clipRegion(cr); cairo_translate(cr, rControlRegion.Left(), rControlRegion.Top());
[Libreoffice-commits] core.git: vcl/headless vcl/quartz
vcl/headless/CairoCommon.cxx |2 +- vcl/quartz/AquaGraphicsBackend.cxx |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) New commits: commit 3b491e84dc2bec4117060bbbfa52b38b7871a220 Author: Luboš Luňák AuthorDate: Tue Feb 1 11:19:11 2022 +0100 Commit: Luboš Luňák CommitDate: Wed Feb 2 10:16:40 2022 +0100 fix std::min() used instead of std::max() In 534fc16a9f8cd01bb88485e2cf6b9cd33aed3745 I got this backwards, if the value is not supposed to be 0, then it should be at least the small value, not at most. Change-Id: Ic55d2b2402985d26e77be0d1605b9ba5985b5ac7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129277 Tested-by: Jenkins Reviewed-by: Luboš Luňák diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index b497e1716f8a..ab8cdb0b30bc 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -675,7 +675,7 @@ bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const C } // convert miter minimum angle to miter limit -double fMiterLimit = 1.0 / sin(std::min(fMiterMinimumAngle, 0.01 * M_PI) / 2.0); +double fMiterLimit = 1.0 / sin(std::max(fMiterMinimumAngle, 0.01 * M_PI) / 2.0); // setup cap attribute cairo_line_cap_t eCairoLineCap(CAIRO_LINE_CAP_BUTT); diff --git a/vcl/quartz/AquaGraphicsBackend.cxx b/vcl/quartz/AquaGraphicsBackend.cxx index 690cbf78ae9c..383fdc0f7fd0 100644 --- a/vcl/quartz/AquaGraphicsBackend.cxx +++ b/vcl/quartz/AquaGraphicsBackend.cxx @@ -820,7 +820,7 @@ bool AquaGraphicsBackend::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDev break; } // convert miter minimum angle to miter limit -CGFloat fCGMiterLimit = 1.0 / sin(std::min(fMiterMinimumAngle, 0.01 * M_PI) / 2.0); +CGFloat fCGMiterLimit = 1.0 / sin(std::max(fMiterMinimumAngle, 0.01 * M_PI) / 2.0); // setup cap attribute CGLineCap aCGLineCap(kCGLineCapButt);
[Libreoffice-commits] core.git: vcl/headless vcl/quartz vcl/skia
vcl/headless/CairoCommon.cxx |2 +- vcl/quartz/AquaGraphicsBackend.cxx |2 +- vcl/skia/gdiimpl.cxx | 29 +++-- 3 files changed, 13 insertions(+), 20 deletions(-) New commits: commit 534fc16a9f8cd01bb88485e2cf6b9cd33aed3745 Author: Luboš Luňák AuthorDate: Wed Jan 26 20:07:48 2022 +0100 Commit: Luboš Luňák CommitDate: Wed Jan 26 21:36:45 2022 +0100 make sure to not divide by zero when computing miter limit The minimal angle is valid only if the line join style is miter, and e.g. FileDefinitionWidgetDraw can call these with round join style and 0 angle, which would divide by 0. So either clamp the value or compute it only when needed. Change-Id: I2a2c71481490c03ec6d01b8e33cab991400adb35 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129006 Tested-by: Jenkins Reviewed-by: Luboš Luňák diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index d77b35d55781..b497e1716f8a 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -675,7 +675,7 @@ bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const C } // convert miter minimum angle to miter limit -double fMiterLimit = 1.0 / sin(fMiterMinimumAngle / 2.0); +double fMiterLimit = 1.0 / sin(std::min(fMiterMinimumAngle, 0.01 * M_PI) / 2.0); // setup cap attribute cairo_line_cap_t eCairoLineCap(CAIRO_LINE_CAP_BUTT); diff --git a/vcl/quartz/AquaGraphicsBackend.cxx b/vcl/quartz/AquaGraphicsBackend.cxx index fdcbae1e3870..690cbf78ae9c 100644 --- a/vcl/quartz/AquaGraphicsBackend.cxx +++ b/vcl/quartz/AquaGraphicsBackend.cxx @@ -820,7 +820,7 @@ bool AquaGraphicsBackend::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDev break; } // convert miter minimum angle to miter limit -CGFloat fCGMiterLimit = 1.0 / sin(fMiterMinimumAngle / 2.0); +CGFloat fCGMiterLimit = 1.0 / sin(std::min(fMiterMinimumAngle, 0.01 * M_PI) / 2.0); // setup cap attribute CGLineCap aCGLineCap(kCGLineCapButt); diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index 930865591ac7..c2efb62f96dc 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -1045,45 +1045,38 @@ bool SkiaSalGraphicsImpl::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDev aPolyLine = basegfx::utils::snapPointsOfHorizontalOrVerticalEdges(aPolyLine); } -// Setup Line Join -SkPaint::Join eSkLineJoin = SkPaint::kMiter_Join; +SkPaint aPaint = makeLinePaint(fTransparency); + switch (eLineJoin) { case basegfx::B2DLineJoin::Bevel: -eSkLineJoin = SkPaint::kBevel_Join; +aPaint.setStrokeJoin(SkPaint::kBevel_Join); break; case basegfx::B2DLineJoin::Round: -eSkLineJoin = SkPaint::kRound_Join; +aPaint.setStrokeJoin(SkPaint::kRound_Join); break; case basegfx::B2DLineJoin::NONE: +break; case basegfx::B2DLineJoin::Miter: -eSkLineJoin = SkPaint::kMiter_Join; +aPaint.setStrokeJoin(SkPaint::kMiter_Join); +// convert miter minimum angle to miter limit +aPaint.setStrokeMiter(1.0 / std::sin(fMiterMinimumAngle / 2.0)); break; } -// convert miter minimum angle to miter limit -double fMiterLimit = 1.0 / std::sin(fMiterMinimumAngle / 2.0); - -// Setup Line Cap -SkPaint::Cap eSkLineCap(SkPaint::kButt_Cap); - switch (eLineCap) { case css::drawing::LineCap_ROUND: -eSkLineCap = SkPaint::kRound_Cap; +aPaint.setStrokeCap(SkPaint::kRound_Cap); break; case css::drawing::LineCap_SQUARE: -eSkLineCap = SkPaint::kSquare_Cap; +aPaint.setStrokeCap(SkPaint::kSquare_Cap); break; default: // css::drawing::LineCap_BUTT: -eSkLineCap = SkPaint::kButt_Cap; +aPaint.setStrokeCap(SkPaint::kButt_Cap); break; } -SkPaint aPaint = makeLinePaint(fTransparency); -aPaint.setStrokeCap(eSkLineCap); -aPaint.setStrokeJoin(eSkLineJoin); -aPaint.setStrokeMiter(fMiterLimit); aPaint.setStrokeWidth(fLineWidth); aPaint.setAntiAlias(mParent.getAntiAlias()); // See the tdf#134346 comment above.
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/svpvd.cxx |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) New commits: commit 67240ca4191bfda561b2949905d29e6c2ed4a09f Author: Caolán McNamara AuthorDate: Tue Jan 25 16:49:49 2022 + Commit: Caolán McNamara CommitDate: Tue Jan 25 20:40:50 2022 +0100 don't use oversized surfaces which leads to warnings of "rendering text failed with stretch ratio of: 10, invalid value (typically too big) for the size of the input (surface, pattern, etc.)" on my 200% scaled hidpi a problem since: commit cf9be3417bc2be5f772c03180b7cbd248b82cad5 Date: Tue Jan 11 19:08:50 2022 +0100 avoid Xlib cairo surfaces for small virtual devices (bsc#1183308) where the nNewDX/nNewDY passed to the cairo_surface_create_similar branch should remain as the unscaled sizes. This does change the meaning of (nNewDX <= 32 && nNewDY <= 32) for the hidpi case, but presumably that's ok Change-Id: I663a399c0e9c8480437a5663329cf753d69eb155 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128938 Tested-by: Jenkins Reviewed-by: Luboš Luňák Reviewed-by: Caolán McNamara diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx index 92c54a013e0e..76cb53fc1745 100644 --- a/vcl/headless/svpvd.cxx +++ b/vcl/headless/svpvd.cxx @@ -85,18 +85,22 @@ void SvpSalVirtualDevice::CreateSurface(tools::Long nNewDX, tools::Long nNewDY, else { dl_cairo_surface_get_device_scale(m_pRefSurface, , ); -nNewDX *= fXScale; -nNewDY *= fYScale; } if (pBuffer) { +nNewDX *= fXScale; +nNewDY *= fYScale; + m_pSurface = cairo_image_surface_create_for_data(pBuffer, CAIRO_FORMAT_ARGB32, nNewDX, nNewDY, cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, nNewDX)); dl_cairo_surface_set_device_scale(m_pSurface, fXScale, fYScale); } else if(nNewDX <= 32 && nNewDY <= 32) { +nNewDX *= fXScale; +nNewDY *= fYScale; + // Force image-based surface if small. Small VirtualDevice instances are often used for small // temporary bitmaps that will eventually have GetBitmap() called on them, which would cause // X Server roundtrip with Xlib-based surface, which may be way more costly than doing the drawing
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/svpvd.cxx |2 ++ 1 file changed, 2 insertions(+) New commits: commit 02363fb279d60f3f5a0328f43a048960028ac5c3 Author: Caolán McNamara AuthorDate: Tue Jan 25 16:45:04 2022 + Commit: Caolán McNamara CommitDate: Tue Jan 25 20:38:45 2022 +0100 log where cairo surface error really started otherwise later seen at: vcl/unx/generic/gdi/cairotextrender.cxx:283: rendering text failed with stretch ratio of: 10, invalid value (typically too big) for the size of the input (surface, pattern, etc.) Change-Id: Iaf65213bbfcf64f09bae8c83efea75e70b8a9c4d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128937 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx index 4d82a46e50c4..92c54a013e0e 100644 --- a/vcl/headless/svpvd.cxx +++ b/vcl/headless/svpvd.cxx @@ -109,6 +109,8 @@ void SvpSalVirtualDevice::CreateSurface(tools::Long nNewDX, tools::Long nNewDY, m_pSurface = cairo_surface_create_similar(m_pRefSurface, CAIRO_CONTENT_COLOR_ALPHA, nNewDX, nNewDY); // Device scale is inherited in this case. } + +SAL_WARN_IF(cairo_surface_status(m_pSurface) != CAIRO_STATUS_SUCCESS, "vcl", "surface of size " << nNewDX << " by " << nNewDY << " creation failed with status of: " << cairo_status_to_string(cairo_surface_status(m_pSurface))); } bool SvpSalVirtualDevice::SetSizeUsingBuffer( tools::Long nNewDX, tools::Long nNewDY,
[Libreoffice-commits] core.git: vcl/headless vcl/ios vcl/source
vcl/headless/headlessinst.cxx |2 -- vcl/ios/iosinst.cxx |2 -- vcl/source/app/salplug.cxx|6 -- vcl/source/app/svmain.cxx |2 ++ 4 files changed, 2 insertions(+), 10 deletions(-) New commits: commit e9da6bdabaf2e5b49c78e7ba54243f8f33622b15 Author: Jan-Marek Glogowski AuthorDate: Fri Jan 14 18:28:32 2022 +0100 Commit: Jan-Marek Glogowski CommitDate: Fri Jan 14 19:36:41 2022 +0100 VCL move SolarMutex (un)locking into (De)InitVCL Fixes all the backends, where SolarMutex access needs SalInstance. The ImplSVData::SalInstance is just set fron the return value of CreateSalInstance, so it can't be accessed earlier, globally. Regression from commit ad94bb5d23d9c4ecbb2ca84807f01623862de43e ("VCL drop m_pInstance from *nix SalData). Change-Id: I13259009571a9973ea7e3ded20c0ea4c660ee214 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128420 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski diff --git a/vcl/headless/headlessinst.cxx b/vcl/headless/headlessinst.cxx index a1fa7a78b217..3c47e82333e8 100644 --- a/vcl/headless/headlessinst.cxx +++ b/vcl/headless/headlessinst.cxx @@ -71,13 +71,11 @@ SalInstance *CreateSalInstance() { HeadlessSalInstance* pInstance = new HeadlessSalInstance(std::make_unique()); new SvpSalData(); -pInstance->AcquireYieldMutex(); return pInstance; } void DestroySalInstance( SalInstance *pInst ) { -pInst->ReleaseYieldMutexAll(); delete pInst; } diff --git a/vcl/ios/iosinst.cxx b/vcl/ios/iosinst.cxx index 3579395924a0..416b53912fec 100644 --- a/vcl/ios/iosinst.cxx +++ b/vcl/ios/iosinst.cxx @@ -166,13 +166,11 @@ SalInstance *CreateSalInstance() { IosSalInstance* pInstance = new IosSalInstance( std::make_unique() ); new SvpSalData(pInstance); -pInstance->AcquireYieldMutex(); return pInstance; } void DestroySalInstance( SalInstance *pInst ) { -pInst->ReleaseYieldMutexAll(); delete pInst; } diff --git a/vcl/source/app/salplug.cxx b/vcl/source/app/salplug.cxx index 264e46c7aed1..e56c6dcffb3d 100644 --- a/vcl/source/app/salplug.cxx +++ b/vcl/source/app/salplug.cxx @@ -319,17 +319,11 @@ SalInstance *CreateSalInstance() _exit( 1 ); } -// acquire SolarMutex -pInst->AcquireYieldMutex(); - return pInst; } void DestroySalInstance( SalInstance *pInst ) { -// release SolarMutex -pInst->ReleaseYieldMutexAll(); - delete pInst; #ifndef DISABLE_DYNLOADING if( pCloseModule ) diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx index 3a9019e006fa..652c7acaad24 100644 --- a/vcl/source/app/svmain.cxx +++ b/vcl/source/app/svmain.cxx @@ -321,6 +321,7 @@ bool InitVCL() pSVData->mpDefInst = CreateSalInstance(); if ( !pSVData->mpDefInst ) return false; +pSVData->mpDefInst->AcquireYieldMutex(); // Desktop Environment context (to be able to get value of "system.desktop-environment" as soon as possible) css::uno::setCurrentContext( @@ -598,6 +599,7 @@ void DeInitVCL() // Deinit Sal if (pSVData->mpDefInst) { +pSVData->mpDefInst->ReleaseYieldMutexAll(); DestroySalInstance( pSVData->mpDefInst ); pSVData->mpDefInst = nullptr; }
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/headlessinst.cxx |5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) New commits: commit adc7fb85b9f525dfee8619c030ec57b2ba71ea37 Author: Caolán McNamara AuthorDate: Fri Jan 14 13:54:03 2022 + Commit: Caolán McNamara CommitDate: Fri Jan 14 15:10:58 2022 +0100 ofz: fix build. error: missing member 'm_pPIManager' probably since... commit bc3f70f220091f09ad02c148a6a49fdccb7b85c5 Date: Thu Jan 13 20:15:39 2022 +0100 VCL move PrinterInfoManager into GenericUnixSalData ... and use a std::unique_ptr. Change-Id: I07ffed4f722e30269ddf4828ffba3ac34952adb2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128417 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara diff --git a/vcl/headless/headlessinst.cxx b/vcl/headless/headlessinst.cxx index f0692e3e7273..c2458756ba24 100644 --- a/vcl/headless/headlessinst.cxx +++ b/vcl/headless/headlessinst.cxx @@ -66,9 +66,8 @@ const OUString& SalGetDesktopEnvironment() return aEnv; } -SalData::SalData() : -m_pInstance( nullptr ), -m_pPIManager( nullptr ) +SalData::SalData() +: m_pInstance(nullptr) { }
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/SvpGraphicsBackend.cxx |6 ++ 1 file changed, 6 insertions(+) New commits: commit f510ea2d7962a4325055c6380a0032331b4e87cf Author: Noel Grandin AuthorDate: Wed Jan 12 11:49:35 2022 +0200 Commit: Noel Grandin CommitDate: Wed Jan 12 14:06:28 2022 +0100 don't bother trying to draw stuff which is effectively invisible speeds up rendering of complex drawings with fine lines Change-Id: I62924c5ddb6293f993eef9ca200a43cba753d53e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128312 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index f564b7e78958..86b804c47146 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -247,6 +247,12 @@ bool SvpGraphicsBackend::drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToD return true; } +// don't bother trying to draw stuff which is effectively invisible +basegfx::B2DRange aPolygonRange = rPolyPolygon.getB2DRange(); +aPolygonRange.transform(rObjectToDevice); +if (aPolygonRange.getWidth() < 0.1 || aPolygonRange.getHeight() < 0.1) +return true; + cairo_t* cr = m_rCairoCommon.getCairoContext(true, getAntiAlias()); m_rCairoCommon.clipRegion(cr);
[Libreoffice-commits] core.git: vcl/headless
vcl/headless/svpgdi.cxx | 29 ++--- 1 file changed, 2 insertions(+), 27 deletions(-) New commits: commit 43befdeda4a66a71bd3c204a79f06cb96c7b0145 Author: Tomaž Vajngerl AuthorDate: Thu Dec 30 00:32:24 2021 +0900 Commit: Tomaž Vajngerl CommitDate: Wed Jan 5 05:01:57 2022 +0100 vcl: cleanup SvpSalGraphics includes Change-Id: I16619e55acfff7510803aff7ebf27c8d892a0d75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127983 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 23f68c80fe3c..881d42be256c 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -23,33 +23,8 @@ #include #include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include + #if ENABLE_CAIRO_CANVAS # if defined CAIRO_VERSION && CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 10, 0) @@ -75,7 +50,7 @@ void SvpSalGraphics::setSurface(cairo_surface_t* pSurface, const basegfx::B2IVec m_aCairoCommon.m_pSurface = pSurface; m_aCairoCommon.m_aFrameSize = rSize; dl_cairo_surface_get_device_scale(pSurface, _aCairoCommon.m_fScale, nullptr); -ResetClipRegion(); +GetImpl()->ResetClipRegion(); } void SvpSalGraphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY )
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/SvpGraphicsBackend.cxx | 44 vcl/headless/svpgdi.cxx | 42 -- vcl/inc/headless/svpgdi.hxx |2 - 3 files changed, 40 insertions(+), 48 deletions(-) New commits: commit c138cfa104ec0cd7f6e97885553b08f98d9f5848 Author: Tomaž Vajngerl AuthorDate: Thu Dec 30 00:24:44 2021 +0900 Commit: Tomaž Vajngerl CommitDate: Wed Jan 5 04:36:44 2022 +0100 vcl: move getBitmap to SvpGraphicsBackend Change-Id: Ic72e1fdd3994a5bffef40bb70b713f10c1112903 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127982 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 2ac40e8e7b20..f564b7e78958 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -480,11 +480,47 @@ void SvpGraphicsBackend::drawMask(const SalTwoRect& rTR, const SalBitmap& rSalBi m_rCairoCommon.releaseCairoContext(cr, false, extents); } -std::shared_ptr SvpGraphicsBackend::getBitmap(tools::Long /*nX*/, tools::Long /*nY*/, - tools::Long /*nWidth*/, - tools::Long /*nHeight*/) +std::shared_ptr SvpGraphicsBackend::getBitmap(tools::Long nX, tools::Long nY, + tools::Long nWidth, tools::Long nHeight) { -return std::shared_ptr(); +std::shared_ptr pBitmap = std::make_shared(); +BitmapPalette aPal; +vcl::PixelFormat ePixelFormat = vcl::PixelFormat::INVALID; +if (GetBitCount() == 1) +{ +ePixelFormat = vcl::PixelFormat::N1_BPP; +aPal.SetEntryCount(2); +aPal[0] = COL_BLACK; +aPal[1] = COL_WHITE; +} +else +{ +ePixelFormat = vcl::PixelFormat::N32_BPP; +} + +if (!pBitmap->Create(Size(nWidth, nHeight), ePixelFormat, aPal)) +{ +SAL_WARN("vcl.gdi", "SvpSalGraphics::getBitmap, cannot create bitmap"); +return nullptr; +} + +cairo_surface_t* target = CairoCommon::createCairoSurface(pBitmap->GetBuffer()); +if (!target) +{ +SAL_WARN("vcl.gdi", "SvpSalGraphics::getBitmap, cannot create cairo surface"); +return nullptr; +} +cairo_t* cr = cairo_create(target); + +SalTwoRect aTR(nX, nY, nWidth, nHeight, 0, 0, nWidth, nHeight); +CairoCommon::renderSource(cr, aTR, m_rCairoCommon.m_pSurface); + +cairo_destroy(cr); +cairo_surface_destroy(target); + +Toggle1BitTransparency(*pBitmap->GetBuffer()); + +return pBitmap; } void SvpGraphicsBackend::drawBitmapBuffer(const SalTwoRect& rTR, const BitmapBuffer* pBuffer, diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index b9c4cabee2bc..23f68c80fe3c 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -83,48 +83,6 @@ void SvpSalGraphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) rDPIX = rDPIY = 96; } -std::shared_ptr SvpSalGraphics::getBitmap( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) -{ -std::shared_ptr pBitmap = std::make_shared(); -BitmapPalette aPal; -vcl::PixelFormat ePixelFormat = vcl::PixelFormat::INVALID; -if (GetBitCount() == 1) -{ -ePixelFormat = vcl::PixelFormat::N1_BPP; -aPal.SetEntryCount(2); -aPal[0] = COL_BLACK; -aPal[1] = COL_WHITE; -} -else -{ -ePixelFormat = vcl::PixelFormat::N32_BPP; -} - -if (!pBitmap->Create(Size(nWidth, nHeight), ePixelFormat, aPal)) -{ -SAL_WARN("vcl.gdi", "SvpSalGraphics::getBitmap, cannot create bitmap"); -return nullptr; -} - -cairo_surface_t* target = CairoCommon::createCairoSurface(pBitmap->GetBuffer()); -if (!target) -{ -SAL_WARN("vcl.gdi", "SvpSalGraphics::getBitmap, cannot create cairo surface"); -return nullptr; -} -cairo_t* cr = cairo_create(target); - -SalTwoRect aTR(nX, nY, nWidth, nHeight, 0, 0, nWidth, nHeight); -CairoCommon::renderSource(cr, aTR, m_aCairoCommon.m_pSurface); - -cairo_destroy(cr); -cairo_surface_destroy(target); - -Toggle1BitTransparency(*pBitmap->GetBuffer()); - -return pBitmap; -} - #if ENABLE_CAIRO_CANVAS bool SvpSalGraphics::SupportsCairo() const { diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index eb15f1563a62..b3b932cc3d73 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -95,8 +95,6 @@ public: GetTextLayout(int nFallbackLevel) override; virtual voidDrawTextLayout( const GenericSalLayout& ) override; -virtual std::shared_ptr getBitmap( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override; - virtual SystemGraphicsData GetGraphicsData() const override; #if
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/SvpGraphicsBackend.cxx | 84 --- vcl/headless/svpgdi.cxx | 86 vcl/inc/headless/svpgdi.hxx |9 --- 3 files changed, 77 insertions(+), 102 deletions(-) New commits: commit 507ca0eb16707917eab3608674243ed0eeacda72 Author: Tomaž Vajngerl AuthorDate: Thu Dec 30 00:20:44 2021 +0900 Commit: Tomaž Vajngerl CommitDate: Wed Jan 5 04:36:27 2022 +0100 vcl: move drawAlphaBitmap to SvpGraphicsBackend Change-Id: I182d775318a9b43a5955a5868e78a4b09c4a74c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127981 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index c67f19d5665d..2ac40e8e7b20 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -394,7 +394,7 @@ void SvpGraphicsBackend::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& return; } -#if 0 // LO code is not yet bitmap32-ready. \ +#if 0 // LO code is not yet bitmap32-ready. // if m_bSupportsBitmap32 becomes true for Svp revisit this m_rCairoCommon.copyWithOperator(rPosAry, source, CAIRO_OPERATOR_OVER, getAntiAlias()); #else @@ -636,13 +636,83 @@ bool SvpGraphicsBackend::drawAlphaBitmap(const SalTwoRect& rTR, const SalBitmap& return true; } -bool SvpGraphicsBackend::drawTransformedBitmap(const basegfx::B2DPoint& /*rNull*/, - const basegfx::B2DPoint& /*rX*/, - const basegfx::B2DPoint& /*rY*/, - const SalBitmap& /*rSourceBitmap*/, - const SalBitmap* /*pAlphaBitmap*/, double /*fAlpha*/) +bool SvpGraphicsBackend::drawTransformedBitmap(const basegfx::B2DPoint& rNull, + const basegfx::B2DPoint& rX, + const basegfx::B2DPoint& rY, + const SalBitmap& rSourceBitmap, + const SalBitmap* pAlphaBitmap, double fAlpha) { -return false; +if (pAlphaBitmap && pAlphaBitmap->GetBitCount() != 8 && pAlphaBitmap->GetBitCount() != 1) +{ +SAL_WARN("vcl.gdi", "unsupported SvpSalGraphics::drawTransformedBitmap alpha depth case: " +<< pAlphaBitmap->GetBitCount()); +return false; +} + +if (fAlpha != 1.0) +return false; + +// MM02 try to access buffered BitmapHelper +std::shared_ptr aSurface; +tryToUseSourceBuffer(rSourceBitmap, aSurface); +const tools::Long nDestWidth(basegfx::fround(basegfx::B2DVector(rX - rNull).getLength())); +const tools::Long nDestHeight(basegfx::fround(basegfx::B2DVector(rY - rNull).getLength())); +cairo_surface_t* source(aSurface->getSurface(nDestWidth, nDestHeight)); + +if (!source) +{ +SAL_WARN("vcl.gdi", "unsupported SvpSalGraphics::drawTransformedBitmap case"); +return false; +} + +// MM02 try to access buffered MaskHelper +std::shared_ptr aMask; +if (nullptr != pAlphaBitmap) +{ +tryToUseMaskBuffer(*pAlphaBitmap, aMask); +} + +// access cairo_surface_t from MaskHelper +cairo_surface_t* mask(nullptr); +if (aMask) +{ +mask = aMask->getSurface(nDestWidth, nDestHeight); +} + +if (nullptr != pAlphaBitmap && nullptr == mask) +{ +SAL_WARN("vcl.gdi", "unsupported SvpSalGraphics::drawTransformedBitmap case"); +return false; +} + +const Size aSize = rSourceBitmap.GetSize(); +cairo_t* cr = m_rCairoCommon.getCairoContext(false, getAntiAlias()); +m_rCairoCommon.clipRegion(cr); + +// setup the image transformation +// using the rNull,rX,rY points as destinations for the (0,0),(0,Width),(Height,0) source points +const basegfx::B2DVector aXRel = rX - rNull; +const basegfx::B2DVector aYRel = rY - rNull; +cairo_matrix_t matrix; +cairo_matrix_init(, aXRel.getX() / aSize.Width(), aXRel.getY() / aSize.Width(), + aYRel.getX() / aSize.Height(), aYRel.getY() / aSize.Height(), rNull.getX(), + rNull.getY()); + +cairo_transform(cr, ); + +cairo_rectangle(cr, 0, 0, aSize.Width(), aSize.Height()); +basegfx::B2DRange extents = getClippedFillDamage(cr); +cairo_clip(cr); + +cairo_set_source_surface(cr, source, 0, 0); +if (mask) +cairo_mask_surface(cr, mask, 0, 0); +else +cairo_paint(cr); + +m_rCairoCommon.releaseCairoContext(cr, false, extents); + +return true; } bool SvpGraphicsBackend::hasFastDrawTransformedBitmap() const { return false; } diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/qt5
vcl/headless/SvpGraphicsBackend.cxx | 177 +- vcl/headless/svpgdi.cxx | 185 vcl/inc/headless/SvpGraphicsBackend.hxx |3 vcl/inc/headless/svpgdi.hxx | 13 -- vcl/qt5/QtSvpGraphics.cxx |3 5 files changed, 175 insertions(+), 206 deletions(-) New commits: commit 581bed6233f31ec5eafb1231fcb93bc3f583f9cb Author: Tomaž Vajngerl AuthorDate: Thu Dec 30 00:14:26 2021 +0900 Commit: Tomaž Vajngerl CommitDate: Wed Jan 5 04:36:06 2022 +0100 vcl: move drawBitmap, drawMask functions to SvpGraphicsBackend Also fix the QTSvpGraphics that uses a special drawBitmap (renamed to drawBitmapBuffer) call and moved in also to SvpGraphicsBackend. Change-Id: Ic50630ba23e35a62ea3d5aaa0955a7666f2bca68 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127980 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 71670cb37bd1..c67f19d5665d 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -23,6 +23,7 @@ #include #include #include +#include SvpGraphicsBackend::SvpGraphicsBackend(CairoCommon& rCairoCommon) : m_rCairoCommon(rCairoCommon) @@ -380,18 +381,103 @@ void SvpGraphicsBackend::copyBits(const SalTwoRect& rTR, SalGraphics* pSrcGraphi m_rCairoCommon.copyBitsCairo(rTR, source, getAntiAlias()); } -void SvpGraphicsBackend::drawBitmap(const SalTwoRect& /*rPosAry*/, const SalBitmap& /*rSalBitmap*/) +void SvpGraphicsBackend::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap) { +// MM02 try to access buffered BitmapHelper +std::shared_ptr aSurface; +tryToUseSourceBuffer(rSalBitmap, aSurface); +cairo_surface_t* source = aSurface->getSurface(rPosAry.mnDestWidth, rPosAry.mnDestHeight); + +if (!source) +{ +SAL_WARN("vcl.gdi", "unsupported SvpSalGraphics::drawAlphaBitmap case"); +return; +} + +#if 0 // LO code is not yet bitmap32-ready. \ +// if m_bSupportsBitmap32 becomes true for Svp revisit this +m_rCairoCommon.copyWithOperator(rPosAry, source, CAIRO_OPERATOR_OVER, getAntiAlias()); +#else +m_rCairoCommon.copyWithOperator(rPosAry, source, CAIRO_OPERATOR_SOURCE, getAntiAlias()); +#endif } -void SvpGraphicsBackend::drawBitmap(const SalTwoRect& /*rPosAry*/, const SalBitmap& /*rSalBitmap*/, -const SalBitmap& /*rMaskBitmap*/) +void SvpGraphicsBackend::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap, +const SalBitmap& rTransparentBitmap) { +drawAlphaBitmap(rPosAry, rSalBitmap, rTransparentBitmap); } -void SvpGraphicsBackend::drawMask(const SalTwoRect& /*rPosAry*/, const SalBitmap& /*rSalBitmap*/, - Color /*nMaskColor*/) +void SvpGraphicsBackend::drawMask(const SalTwoRect& rTR, const SalBitmap& rSalBitmap, + Color nMaskColor) { +/** creates an image from the given rectangle, replacing all black pixels + * with nMaskColor and make all other full transparent */ +// MM02 here decided *against* using buffered BitmapHelper +// because the data gets somehow 'unmuliplied'. This may also be +// done just once, but I am not sure if this is safe to do. +// So for now dispense re-using data here. +BitmapHelper aSurface(rSalBitmap, true); // The mask is argb32 +if (!aSurface.getSurface()) +{ +SAL_WARN("vcl.gdi", "unsupported SvpSalGraphics::drawMask case"); +return; +} +sal_Int32 nStride; +unsigned char* mask_data = aSurface.getBits(nStride); +vcl::bitmap::lookup_table const& unpremultiply_table = vcl::bitmap::get_unpremultiply_table(); +for (tools::Long y = rTR.mnSrcY; y < rTR.mnSrcY + rTR.mnSrcHeight; ++y) +{ +unsigned char* row = mask_data + (nStride * y); +unsigned char* data = row + (rTR.mnSrcX * 4); +for (tools::Long x = rTR.mnSrcX; x < rTR.mnSrcX + rTR.mnSrcWidth; ++x) +{ +sal_uInt8 a = data[SVP_CAIRO_ALPHA]; +sal_uInt8 b = unpremultiply_table[a][data[SVP_CAIRO_BLUE]]; +sal_uInt8 g = unpremultiply_table[a][data[SVP_CAIRO_GREEN]]; +sal_uInt8 r = unpremultiply_table[a][data[SVP_CAIRO_RED]]; +if (r == 0 && g == 0 && b == 0) +{ +data[0] = nMaskColor.GetBlue(); +data[1] = nMaskColor.GetGreen(); +data[2] = nMaskColor.GetRed(); +data[3] = 0xff; +} +else +{ +data[0] = 0; +data[1] = 0; +data[2] = 0; +data[3] = 0; +} +data += 4; +} +} +
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/BitmapHelper.cxx | 82 ++ vcl/headless/svpgdi.cxx | 78 vcl/inc/headless/BitmapHelper.hxx |5 ++ 3 files changed, 87 insertions(+), 78 deletions(-) New commits: commit 86fdd581a832c7476d7556f3f4fb7d83f5de4d8b Author: Tomaž Vajngerl AuthorDate: Wed Dec 29 15:47:42 2021 +0900 Commit: Tomaž Vajngerl CommitDate: Wed Jan 5 04:35:45 2022 +0100 vcl: move tryToUse{Source,Mask}Buffer to BitmapHelper Change-Id: I9352aec388db56596fef3f5f323244b1df26cdcb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127979 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/BitmapHelper.cxx b/vcl/headless/BitmapHelper.cxx index 8d56631a4fee..2b9c670dfb3f 100644 --- a/vcl/headless/BitmapHelper.cxx +++ b/vcl/headless/BitmapHelper.cxx @@ -18,6 +18,7 @@ */ #include +#include BitmapHelper::BitmapHelper(const SalBitmap& rSourceBitmap, const bool bForceARGB32) #ifdef HAVE_CAIRO_FORMAT_RGB24_888 @@ -183,4 +184,85 @@ sal_Int64 SystemDependentData_MaskHelper::estimateUsageInBytes() const { return estimateUsageInBytesForSurfaceHelper(maMaskHelper.get()); } + +namespace +{ +// MM02 decide to use buffers or not +const char* pDisableMM02Goodies(getenv("SAL_DISABLE_MM02_GOODIES")); +bool bUseBuffer(nullptr == pDisableMM02Goodies); +const tools::Long nMinimalSquareSizeToBuffer(64 * 64); +} + +void tryToUseSourceBuffer(const SalBitmap& rSourceBitmap, std::shared_ptr& rSurface) +{ +// MM02 try to access buffered BitmapHelper +std::shared_ptr pSystemDependentData_BitmapHelper; +const bool bBufferSource(bUseBuffer + && rSourceBitmap.GetSize().Width() * rSourceBitmap.GetSize().Height() +> nMinimalSquareSizeToBuffer); + +if (bBufferSource) +{ +const SvpSalBitmap& rSrcBmp(static_cast(rSourceBitmap)); +pSystemDependentData_BitmapHelper += rSrcBmp.getSystemDependentData(); + +if (pSystemDependentData_BitmapHelper) +{ +// reuse buffered data +rSurface = pSystemDependentData_BitmapHelper->getBitmapHelper(); +} +} + +if (rSurface) +return; + +// create data on-demand +rSurface = std::make_shared(rSourceBitmap); + +if (bBufferSource) +{ +// add to buffering mechanism to potentially reuse next time +const SvpSalBitmap& rSrcBmp(static_cast(rSourceBitmap)); + rSrcBmp.addOrReplaceSystemDependentData( +ImplGetSystemDependentDataManager(), rSurface); +} +} + +void tryToUseMaskBuffer(const SalBitmap& rMaskBitmap, std::shared_ptr& rMask) +{ +// MM02 try to access buffered MaskHelper +std::shared_ptr pSystemDependentData_MaskHelper; +const bool bBufferMask(bUseBuffer + && rMaskBitmap.GetSize().Width() * rMaskBitmap.GetSize().Height() + > nMinimalSquareSizeToBuffer); + +if (bBufferMask) +{ +const SvpSalBitmap& rSrcBmp(static_cast(rMaskBitmap)); +pSystemDependentData_MaskHelper += rSrcBmp.getSystemDependentData(); + +if (pSystemDependentData_MaskHelper) +{ +// reuse buffered data +rMask = pSystemDependentData_MaskHelper->getMaskHelper(); +} +} + +if (rMask) +return; + +// create data on-demand +rMask = std::make_shared(rMaskBitmap); + +if (bBufferMask) +{ +// add to buffering mechanism to potentially reuse next time +const SvpSalBitmap& rSrcBmp(static_cast(rMaskBitmap)); + rSrcBmp.addOrReplaceSystemDependentData( +ImplGetSystemDependentDataManager(), rMask); +} +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 3a321af10293..04849793efd9 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -57,84 +57,6 @@ # endif #endif -namespace -{ -// MM02 decide to use buffers or not -const char* pDisableMM02Goodies(getenv("SAL_DISABLE_MM02_GOODIES")); -bool bUseBuffer(nullptr == pDisableMM02Goodies); -const tools::Long nMinimalSquareSizeToBuffer(64*64); - -void tryToUseSourceBuffer(const SalBitmap& rSourceBitmap, std::shared_ptr& rSurface) -{ -// MM02 try to access buffered BitmapHelper -std::shared_ptr pSystemDependentData_BitmapHelper; -const bool bBufferSource(bUseBuffer -&& rSourceBitmap.GetSize().Width() * rSourceBitmap.GetSize().Height() > nMinimalSquareSizeToBuffer); - -if(bBufferSource) -{ -const SvpSalBitmap& rSrcBmp(static_cast(rSourceBitmap)); -pSystemDependentData_BitmapHelper = rSrcBmp.getSystemDependentData(); - -if(pSystemDependentData_BitmapHelper) -{ -// reuse buffered data -
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/BitmapHelper.cxx | 62 ++ vcl/headless/CairoCommon.cxx | 28 - vcl/headless/svpgdi.cxx | 55 + vcl/inc/headless/BitmapHelper.hxx | 28 + vcl/inc/headless/CairoCommon.hxx |2 - 5 files changed, 92 insertions(+), 83 deletions(-) New commits: commit 5a7cdbfbd3cbf3ea92c38e78a3b159fdffed7740 Author: Tomaž Vajngerl AuthorDate: Wed Dec 29 15:38:28 2021 +0900 Commit: Tomaž Vajngerl CommitDate: Wed Jan 5 04:35:15 2022 +0100 vcl: move SystemDependentData classes to BitmapHelper SystemDependentData_BitmapHelper, SystemDependentData_MaskHelper to BitmapHelper.{hxx,cxx} files. Change-Id: I23f3b4badd8e262c442e5c6387876b078f22fd73 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127926 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/BitmapHelper.cxx b/vcl/headless/BitmapHelper.cxx index 359db01bb45d..8d56631a4fee 100644 --- a/vcl/headless/BitmapHelper.cxx +++ b/vcl/headless/BitmapHelper.cxx @@ -121,4 +121,66 @@ MaskHelper::MaskHelper(const SalBitmap& rAlphaBitmap) pMaskBuf->mnScanlineSize)); } } + +namespace +{ +// check for env var that decides for using downscale pattern +const char* pDisableDownScale(getenv("SAL_DISABLE_CAIRO_DOWNSCALE")); +bool bDisableDownScale(nullptr != pDisableDownScale); + +sal_Int64 estimateUsageInBytesForSurfaceHelper(const SurfaceHelper* pHelper) +{ +sal_Int64 nRetval(0); + +if (nullptr != pHelper) +{ +cairo_surface_t* pSurface(pHelper->getSurface()); + +if (pSurface) +{ +const tools::Long nStride(cairo_image_surface_get_stride(pSurface)); +const tools::Long nHeight(cairo_image_surface_get_height(pSurface)); + +nRetval = nStride * nHeight; + +// if we do downscale, size will grow by 1/4 + 1/16 + 1/32 + ..., +// rough estimation just multiplies by 1.25, should be good enough +// for estimation of buffer survival time +if (!bDisableDownScale) +{ +nRetval = (nRetval * 5) / 4; +} +} +} + +return nRetval; +} + +} // end anonymous namespace + +SystemDependentData_BitmapHelper::SystemDependentData_BitmapHelper( +basegfx::SystemDependentDataManager& rSystemDependentDataManager, +const std::shared_ptr& rBitmapHelper) +: basegfx::SystemDependentData(rSystemDependentDataManager) +, maBitmapHelper(rBitmapHelper) +{ +} + +sal_Int64 SystemDependentData_BitmapHelper::estimateUsageInBytes() const +{ +return estimateUsageInBytesForSurfaceHelper(maBitmapHelper.get()); +} + +SystemDependentData_MaskHelper::SystemDependentData_MaskHelper( +basegfx::SystemDependentDataManager& rSystemDependentDataManager, +const std::shared_ptr& rMaskHelper) +: basegfx::SystemDependentData(rSystemDependentDataManager) +, maMaskHelper(rMaskHelper) +{ +} + +sal_Int64 SystemDependentData_MaskHelper::estimateUsageInBytes() const +{ +return estimateUsageInBytesForSurfaceHelper(maMaskHelper.get()); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 6de48a501b98..94ca2c3158be 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -1180,34 +1180,6 @@ const char* pDisableDownScale(getenv("SAL_DISABLE_CAIRO_DOWNSCALE")); bool bDisableDownScale(nullptr != pDisableDownScale); } -sal_Int64 estimateUsageInBytesForSurfaceHelper(const SurfaceHelper* pHelper) -{ -sal_Int64 nRetval(0); - -if (nullptr != pHelper) -{ -cairo_surface_t* pSurface(pHelper->getSurface()); - -if (pSurface) -{ -const tools::Long nStride(cairo_image_surface_get_stride(pSurface)); -const tools::Long nHeight(cairo_image_surface_get_height(pSurface)); - -nRetval = nStride * nHeight; - -// if we do downscale, size will grow by 1/4 + 1/16 + 1/32 + ..., -// rough estimation just multiplies by 1.25, should be good enough -// for estimation of buffer survival time -if (!bDisableDownScale) -{ -nRetval = (nRetval * 5) / 4; -} -} -} - -return nRetval; -} - cairo_surface_t* SurfaceHelper::implCreateOrReuseDownscale(unsigned long nTargetWidth, unsigned long nTargetHeight) { diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 33e4e220cc69..3a321af10293 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -60,60 +59,12 @@ namespace { -class SystemDependentData_BitmapHelper : public
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/CairoCommon.cxx | 28 vcl/headless/svpgdi.cxx | 32 vcl/inc/headless/CairoCommon.hxx |2 ++ 3 files changed, 30 insertions(+), 32 deletions(-) New commits: commit fed7cc51c9bea947478a2451d545cd9fa53ebd1d Author: Tomaž Vajngerl AuthorDate: Wed Dec 29 15:18:03 2021 +0900 Commit: Tomaž Vajngerl CommitDate: Wed Jan 5 04:34:59 2022 +0100 vcl: move estimateUsageInBytesForSurfaceHelper to CairoCommon Change-Id: I3c4140f99db4867109b04416317b96b268d9d8c5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127925 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 94ca2c3158be..6de48a501b98 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -1180,6 +1180,34 @@ const char* pDisableDownScale(getenv("SAL_DISABLE_CAIRO_DOWNSCALE")); bool bDisableDownScale(nullptr != pDisableDownScale); } +sal_Int64 estimateUsageInBytesForSurfaceHelper(const SurfaceHelper* pHelper) +{ +sal_Int64 nRetval(0); + +if (nullptr != pHelper) +{ +cairo_surface_t* pSurface(pHelper->getSurface()); + +if (pSurface) +{ +const tools::Long nStride(cairo_image_surface_get_stride(pSurface)); +const tools::Long nHeight(cairo_image_surface_get_height(pSurface)); + +nRetval = nStride * nHeight; + +// if we do downscale, size will grow by 1/4 + 1/16 + 1/32 + ..., +// rough estimation just multiplies by 1.25, should be good enough +// for estimation of buffer survival time +if (!bDisableDownScale) +{ +nRetval = (nRetval * 5) / 4; +} +} +} + +return nRetval; +} + cairo_surface_t* SurfaceHelper::implCreateOrReuseDownscale(unsigned long nTargetWidth, unsigned long nTargetHeight) { diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 77553761e040..33e4e220cc69 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -60,38 +60,6 @@ namespace { -// check for env var that decides for using downscale pattern -const char* pDisableDownScale(getenv("SAL_DISABLE_CAIRO_DOWNSCALE")); -bool bDisableDownScale(nullptr != pDisableDownScale); - -sal_Int64 estimateUsageInBytesForSurfaceHelper(const SurfaceHelper* pHelper) -{ -sal_Int64 nRetval(0); - -if(nullptr != pHelper) -{ -cairo_surface_t* pSurface(pHelper->getSurface()); - -if(pSurface) -{ -const tools::Long nStride(cairo_image_surface_get_stride(pSurface)); -const tools::Long nHeight(cairo_image_surface_get_height(pSurface)); - -nRetval = nStride * nHeight; - -// if we do downscale, size will grow by 1/4 + 1/16 + 1/32 + ..., -// rough estimation just multiplies by 1.25, should be good enough -// for estimation of buffer survival time -if(!bDisableDownScale) -{ -nRetval = (nRetval * 5) / 4; -} -} -} - -return nRetval; -} - class SystemDependentData_BitmapHelper : public basegfx::SystemDependentData { private: diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx index e8b1a4927e21..8d5dd22b1a75 100644 --- a/vcl/inc/headless/CairoCommon.hxx +++ b/vcl/inc/headless/CairoCommon.hxx @@ -227,4 +227,6 @@ public: unsigned long nTargetHeight = 0) const; }; +VCL_DLLPUBLIC sal_Int64 estimateUsageInBytesForSurfaceHelper(const SurfaceHelper* pHelper); + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/Library_vcl.mk
vcl/Library_vcl.mk|1 vcl/headless/BitmapHelper.cxx | 124 vcl/headless/svpgdi.cxx | 129 -- vcl/inc/headless/BitmapHelper.hxx | 48 ++ vcl/inc/headless/CairoCommon.hxx |1 5 files changed, 175 insertions(+), 128 deletions(-) New commits: commit 94bef9ce68b35e1d6d2c7ce4ffae2c6b301686ea Author: Tomaž Vajngerl AuthorDate: Wed Dec 29 12:51:59 2021 +0900 Commit: Tomaž Vajngerl CommitDate: Wed Jan 5 04:34:32 2022 +0100 vcl: move BitmapHelper and MaskHelper into own file Change-Id: If6f2a489be7cb51f62c55a2d4c804fcc741579bf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127924 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index c7c03a52f44f..4712da2f716f 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -528,6 +528,7 @@ vcl_headless_code= \ vcl/headless/svpgdi \ vcl/headless/SvpGraphicsBackend \ vcl/headless/CairoCommon \ +vcl/headless/BitmapHelper \ $(if $(ENABLE_HEADLESS),vcl/headless/svpdata) \ ) \ vcl/headless/svpdummies \ diff --git a/vcl/headless/BitmapHelper.cxx b/vcl/headless/BitmapHelper.cxx new file mode 100644 index ..359db01bb45d --- /dev/null +++ b/vcl/headless/BitmapHelper.cxx @@ -0,0 +1,124 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include + +BitmapHelper::BitmapHelper(const SalBitmap& rSourceBitmap, const bool bForceARGB32) +#ifdef HAVE_CAIRO_FORMAT_RGB24_888 +: m_bForceARGB32(bForceARGB32) +#endif +{ +const SvpSalBitmap& rSrcBmp = static_cast(rSourceBitmap); +#ifdef HAVE_CAIRO_FORMAT_RGB24_888 +if ((rSrcBmp.GetBitCount() != 32 && rSrcBmp.GetBitCount() != 24) || bForceARGB32) +#else +(void)bForceARGB32; +if (rSrcBmp.GetBitCount() != 32) +#endif +{ +//big stupid copy here +const BitmapBuffer* pSrc = rSrcBmp.GetBuffer(); +const SalTwoRect aTwoRect += { 0, 0, pSrc->mnWidth, pSrc->mnHeight, 0, 0, pSrc->mnWidth, pSrc->mnHeight }; +std::unique_ptr pTmp += (pSrc->mnFormat == SVP_24BIT_FORMAT + ? FastConvert24BitRgbTo32BitCairo(pSrc) + : StretchAndConvert(*pSrc, aTwoRect, SVP_CAIRO_FORMAT)); +aTmpBmp.Create(std::move(pTmp)); + +assert(aTmpBmp.GetBitCount() == 32); +implSetSurface(CairoCommon::createCairoSurface(aTmpBmp.GetBuffer())); +} +else +{ +implSetSurface(CairoCommon::createCairoSurface(rSrcBmp.GetBuffer())); +} +} + +void BitmapHelper::mark_dirty() { cairo_surface_mark_dirty(implGetSurface()); } + +unsigned char* BitmapHelper::getBits(sal_Int32& rStride) +{ +cairo_surface_flush(implGetSurface()); + +unsigned char* mask_data = cairo_image_surface_get_data(implGetSurface()); + +const cairo_format_t nFormat = cairo_image_surface_get_format(implGetSurface()); +#ifdef HAVE_CAIRO_FORMAT_RGB24_888 +if (!m_bForceARGB32) +assert(nFormat == CAIRO_FORMAT_RGB24_888 && "Expected RGB24_888 image"); +else +#endif +{ +assert(nFormat == CAIRO_FORMAT_ARGB32 + && "need to implement CAIRO_FORMAT_A1 after all here"); +} + +rStride += cairo_format_stride_for_width(nFormat, cairo_image_surface_get_width(implGetSurface())); + +return mask_data; +} + +MaskHelper::MaskHelper(const SalBitmap& rAlphaBitmap) +{ +const SvpSalBitmap& rMask = static_cast(rAlphaBitmap); +const BitmapBuffer* pMaskBuf = rMask.GetBuffer(); + +if (rAlphaBitmap.GetBitCount() == 8) +{ +// the alpha values need to be inverted for Cairo +// so big stupid copy and invert here +const int nImageSize = pMaskBuf->mnHeight * pMaskBuf->mnScanlineSize; +pAlphaBits.reset(new unsigned char[nImageSize]); +memcpy(pAlphaBits.get(), pMaskBuf->mpBits, nImageSize); + +// TODO: make upper layers use standard alpha +sal_uInt32* pLDst = reinterpret_cast(pAlphaBits.get()); +for (int i =
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/CairoCommon.cxx | 124 +++ vcl/headless/svpgdi.cxx | 136 --- vcl/inc/headless/CairoCommon.hxx | 27 +++ 3 files changed, 151 insertions(+), 136 deletions(-) New commits: commit eee703970581545b56f3b2faa5b5911923ec28ea Author: Tomaž Vajngerl AuthorDate: Tue Dec 28 14:21:03 2021 +0900 Commit: Tomaž Vajngerl CommitDate: Tue Jan 4 15:16:30 2022 +0100 vcl: move SurfaceHelper class to CairoCommon Intermediate step beore moving bitmap related members. Change-Id: Icf2d4cfb787dfb029f299cba4b4ffabae563bf6d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127923 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 6194d976ab7b..94ca2c3158be 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -1173,4 +1173,128 @@ void Toggle1BitTransparency(const BitmapBuffer& rBuf) } } +namespace +{ +// check for env var that decides for using downscale pattern +const char* pDisableDownScale(getenv("SAL_DISABLE_CAIRO_DOWNSCALE")); +bool bDisableDownScale(nullptr != pDisableDownScale); +} + +cairo_surface_t* SurfaceHelper::implCreateOrReuseDownscale(unsigned long nTargetWidth, + unsigned long nTargetHeight) +{ +const unsigned long nSourceWidth(cairo_image_surface_get_width(pSurface)); +const unsigned long nSourceHeight(cairo_image_surface_get_height(pSurface)); + +// zoomed in, need to stretch at paint, no pre-scale useful +if (nTargetWidth >= nSourceWidth || nTargetHeight >= nSourceHeight) +{ +return pSurface; +} + +// calculate downscale factor +unsigned long nWFactor(1); +unsigned long nW((nSourceWidth + 1) / 2); +unsigned long nHFactor(1); +unsigned long nH((nSourceHeight + 1) / 2); + +while (nW > nTargetWidth && nW > 1) +{ +nW = (nW + 1) / 2; +nWFactor *= 2; +} + +while (nH > nTargetHeight && nH > 1) +{ +nH = (nH + 1) / 2; +nHFactor *= 2; +} + +if (1 == nWFactor && 1 == nHFactor) +{ +// original size *is* best binary size, use it +return pSurface; +} + +// go up one scale again - look for no change +nW = (1 == nWFactor) ? nTargetWidth : nW * 2; +nH = (1 == nHFactor) ? nTargetHeight : nH * 2; + +// check if we have a downscaled version of required size +// bail out if the multiplication for the key would overflow +if (nW >= SAL_MAX_UINT32 || nH >= SAL_MAX_UINT32) +return pSurface; +const sal_uInt64 key((nW * static_cast(SAL_MAX_UINT32)) + nH); +auto isHit(maDownscaled.find(key)); + +if (isHit != maDownscaled.end()) +{ +return isHit->second; +} + +// create new surface in the targeted size +cairo_surface_t* pSurfaceTarget += cairo_surface_create_similar(pSurface, cairo_surface_get_content(pSurface), nW, nH); + +// made a version to scale self first that worked well, but would've +// been hard to support CAIRO_FORMAT_A1 including bit shifting, so +// I decided to go with cairo itself - use CAIRO_FILTER_FAST or +// CAIRO_FILTER_GOOD though. Please modify as needed for +// performance/quality +cairo_t* cr = cairo_create(pSurfaceTarget); +const double fScaleX(static_cast(nW) / static_cast(nSourceWidth)); +const double fScaleY(static_cast(nH) / static_cast(nSourceHeight)); +cairo_scale(cr, fScaleX, fScaleY); +cairo_set_source_surface(cr, pSurface, 0.0, 0.0); +cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_GOOD); +cairo_paint(cr); +cairo_destroy(cr); + +// need to set device_scale for downscale surfaces to get +// them handled correctly +cairo_surface_set_device_scale(pSurfaceTarget, fScaleX, fScaleY); + +// add entry to cached entries +maDownscaled[key] = pSurfaceTarget; + +return pSurfaceTarget; +} + +bool SurfaceHelper::isTrivial() const +{ +constexpr unsigned long nMinimalSquareSizeToBuffer(64 * 64); +const unsigned long nSourceWidth(cairo_image_surface_get_width(pSurface)); +const unsigned long nSourceHeight(cairo_image_surface_get_height(pSurface)); + +return nSourceWidth * nSourceHeight < nMinimalSquareSizeToBuffer; +} + +SurfaceHelper::SurfaceHelper() +: pSurface(nullptr) +{ +} + +SurfaceHelper::~SurfaceHelper() +{ +cairo_surface_destroy(pSurface); +for (auto& candidate : maDownscaled) +{ +cairo_surface_destroy(candidate.second); +} +} + +cairo_surface_t* SurfaceHelper::getSurface(unsigned long nTargetWidth, + unsigned long nTargetHeight) const +{ +if (bDisableDownScale || 0 == nTargetWidth || 0 == nTargetHeight || !pSurface || isTrivial()) +{ +// caller asks for original or disabled or trivial (smaller then
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/CairoCommon.cxx | 13 + vcl/headless/svpgdi.cxx | 13 - vcl/inc/headless/CairoCommon.hxx |2 ++ 3 files changed, 15 insertions(+), 13 deletions(-) New commits: commit 971b029308c527737d4085559e91fa8495b93d9c Author: Tomaž Vajngerl AuthorDate: Tue Dec 28 14:12:19 2021 +0900 Commit: Tomaž Vajngerl CommitDate: Tue Jan 4 13:48:54 2022 +0100 vcl: move Toggle1BitTransparency to CairoCommon Intermediate step beore moving bitmap related members. Change-Id: Iaa30fd53d3b14c08fd502b33d370950569994139 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127922 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 5316b88e699f..6194d976ab7b 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -1160,4 +1160,17 @@ std::unique_ptr FastConvert24BitRgbTo32BitCairo(const BitmapBuffer return pDst; } +void Toggle1BitTransparency(const BitmapBuffer& rBuf) +{ +assert(rBuf.maPalette.GetBestIndex(BitmapColor(COL_BLACK)) == 0); +// TODO: make upper layers use standard alpha +if (getCairoFormat(rBuf) == CAIRO_FORMAT_A1) +{ +const int nImageSize = rBuf.mnHeight * rBuf.mnScanlineSize; +unsigned char* pDst = rBuf.mpBits; +for (int i = nImageSize; --i >= 0; ++pDst) +*pDst = ~*pDst; +} +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 25f385a8396a..92c0cbe39fbb 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -59,19 +59,6 @@ namespace { -void Toggle1BitTransparency(const BitmapBuffer& rBuf) -{ -assert(rBuf.maPalette.GetBestIndex(BitmapColor(COL_BLACK)) == 0); -// TODO: make upper layers use standard alpha -if (getCairoFormat(rBuf) == CAIRO_FORMAT_A1) -{ -const int nImageSize = rBuf.mnHeight * rBuf.mnScanlineSize; -unsigned char* pDst = rBuf.mpBits; -for (int i = nImageSize; --i >= 0; ++pDst) -*pDst = ~*pDst; -} -} - // check for env var that decides for using downscale pattern const char* pDisableDownScale(getenv("SAL_DISABLE_CAIRO_DOWNSCALE")); bool bDisableDownScale(nullptr != pDisableDownScale); diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx index c79b2297e106..b1f6a8198a60 100644 --- a/vcl/inc/headless/CairoCommon.hxx +++ b/vcl/inc/headless/CairoCommon.hxx @@ -125,6 +125,8 @@ VCL_DLLPUBLIC cairo_format_t getCairoFormat(const BitmapBuffer& rBuffer); VCL_DLLPUBLIC std::unique_ptr FastConvert24BitRgbTo32BitCairo(const BitmapBuffer* pSrc); +VCL_DLLPUBLIC void Toggle1BitTransparency(const BitmapBuffer& rBuf); + enum class PaintMode { Over,
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/CairoCommon.cxx | 94 +++ vcl/headless/svpgdi.cxx | 81 - vcl/inc/headless/CairoCommon.hxx |3 + 3 files changed, 97 insertions(+), 81 deletions(-) New commits: commit a2eb140692f2671c9b01c2a691ce73575e409a71 Author: Tomaž Vajngerl AuthorDate: Tue Dec 28 14:09:55 2021 +0900 Commit: Tomaž Vajngerl CommitDate: Tue Jan 4 06:56:16 2022 +0100 vcl: move FastConvert24BitRgbTo32BitCairo to CairoCommon Intermediate step beore moving bitmap related members. Change-Id: Ic0adff8ba8fadd0687ec903460e0caf7507e99b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127846 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index af4ee260c1c6..5316b88e699f 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -1066,4 +1067,97 @@ cairo_surface_t* CairoCommon::createCairoSurface(const BitmapBuffer* pBuffer) return target; } +std::unique_ptr FastConvert24BitRgbTo32BitCairo(const BitmapBuffer* pSrc) +{ +if (pSrc == nullptr) +return nullptr; + +assert(pSrc->mnFormat == SVP_24BIT_FORMAT); +const tools::Long nWidth = pSrc->mnWidth; +const tools::Long nHeight = pSrc->mnHeight; +std::unique_ptr pDst(new BitmapBuffer); +pDst->mnFormat = (ScanlineFormat::N32BitTcArgb | ScanlineFormat::TopDown); +pDst->mnWidth = nWidth; +pDst->mnHeight = nHeight; +pDst->mnBitCount = 32; +pDst->maColorMask = pSrc->maColorMask; +pDst->maPalette = pSrc->maPalette; + +tools::Long nScanlineBase; +const bool bFail = o3tl::checked_multiply(pDst->mnBitCount, nWidth, nScanlineBase); +if (bFail) +{ +SAL_WARN("vcl.gdi", "checked multiply failed"); +pDst->mpBits = nullptr; +return nullptr; +} + +pDst->mnScanlineSize = AlignedWidth4Bytes(nScanlineBase); +if (pDst->mnScanlineSize < nScanlineBase / 8) +{ +SAL_WARN("vcl.gdi", "scanline calculation wraparound"); +pDst->mpBits = nullptr; +return nullptr; +} + +try +{ +pDst->mpBits = new sal_uInt8[pDst->mnScanlineSize * nHeight]; +} +catch (const std::bad_alloc&) +{ +// memory exception, clean up +pDst->mpBits = nullptr; +return nullptr; +} + +for (tools::Long y = 0; y < nHeight; ++y) +{ +sal_uInt8* pS = pSrc->mpBits + y * pSrc->mnScanlineSize; +sal_uInt8* pD = pDst->mpBits + y * pDst->mnScanlineSize; +for (tools::Long x = 0; x < nWidth; ++x) +{ +#if defined(ANDROID) && !HAVE_FEATURE_ANDROID_LOK +static_assert((SVP_CAIRO_FORMAT & ~ScanlineFormat::TopDown) + == ScanlineFormat::N32BitTcRgba, + "Expected SVP_CAIRO_FORMAT set to N32BitTcBgra"); +static_assert((SVP_24BIT_FORMAT & ~ScanlineFormat::TopDown) + == ScanlineFormat::N24BitTcRgb, + "Expected SVP_24BIT_FORMAT set to N24BitTcRgb"); +pD[0] = pS[0]; +pD[1] = pS[1]; +pD[2] = pS[2]; +pD[3] = 0xff; // Alpha +#elif defined OSL_BIGENDIAN +static_assert((SVP_CAIRO_FORMAT & ~ScanlineFormat::TopDown) + == ScanlineFormat::N32BitTcArgb, + "Expected SVP_CAIRO_FORMAT set to N32BitTcBgra"); +static_assert((SVP_24BIT_FORMAT & ~ScanlineFormat::TopDown) + == ScanlineFormat::N24BitTcRgb, + "Expected SVP_24BIT_FORMAT set to N24BitTcRgb"); +pD[0] = 0xff; // Alpha +pD[1] = pS[0]; +pD[2] = pS[1]; +pD[3] = pS[2]; +#else +static_assert((SVP_CAIRO_FORMAT & ~ScanlineFormat::TopDown) + == ScanlineFormat::N32BitTcBgra, + "Expected SVP_CAIRO_FORMAT set to N32BitTcBgra"); +static_assert((SVP_24BIT_FORMAT & ~ScanlineFormat::TopDown) + == ScanlineFormat::N24BitTcBgr, + "Expected SVP_24BIT_FORMAT set to N24BitTcBgr"); +pD[0] = pS[0]; +pD[1] = pS[1]; +pD[2] = pS[2]; +pD[3] = 0xff; // Alpha +#endif + +pS += 3; +pD += 4; +} +} + +return pDst; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 5b685178940b..25f385a8396a 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -72,87 +72,6 @@ namespace } } -std::unique_ptr FastConvert24BitRgbTo32BitCairo(const BitmapBuffer* pSrc) -{ -if (pSrc == nullptr) -return nullptr; - -
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/CairoCommon.cxx | 56 vcl/headless/svpgdi.cxx | 67 ++- vcl/inc/headless/CairoCommon.hxx |5 ++ vcl/inc/headless/svpgdi.hxx |1 4 files changed, 65 insertions(+), 64 deletions(-) New commits: commit 5b185397198171bf8adaa99439931d12f42eff51 Author: Tomaž Vajngerl AuthorDate: Tue Dec 28 14:00:02 2021 +0900 Commit: Tomaž Vajngerl CommitDate: Tue Jan 4 06:55:57 2022 +0100 vcl: move createCairoSurface to CairoCommon Intermediate step beore moving bitmap related members. Change-Id: Ia3321ddd1ca3adb11e2b4610c3fb6b0be5ee6515 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127845 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 234bfe29fcce..af4ee260c1c6 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -1010,4 +1010,60 @@ void CairoCommon::invert(const basegfx::B2DPolygon& rPoly, SalInvert nFlags, boo releaseCairoContext(cr, false, extents); } +cairo_format_t getCairoFormat(const BitmapBuffer& rBuffer) +{ +cairo_format_t nFormat; +#ifdef HAVE_CAIRO_FORMAT_RGB24_888 +assert(rBuffer.mnBitCount == 32 || rBuffer.mnBitCount == 24 || rBuffer.mnBitCount == 1); +#else +assert(rBuffer.mnBitCount == 32 || rBuffer.mnBitCount == 1); +#endif + +if (rBuffer.mnBitCount == 32) +nFormat = CAIRO_FORMAT_ARGB32; +#ifdef HAVE_CAIRO_FORMAT_RGB24_888 +else if (rBuffer.mnBitCount == 24) +nFormat = CAIRO_FORMAT_RGB24_888; +#endif +else +nFormat = CAIRO_FORMAT_A1; +return nFormat; +} + +namespace +{ +bool isCairoCompatible(const BitmapBuffer* pBuffer) +{ +if (!pBuffer) +return false; + +// We use Cairo that supports 24-bit RGB. +#ifdef HAVE_CAIRO_FORMAT_RGB24_888 +if (pBuffer->mnBitCount != 32 && pBuffer->mnBitCount != 24 && pBuffer->mnBitCount != 1) +#else +if (pBuffer->mnBitCount != 32 && pBuffer->mnBitCount != 1) +#endif +return false; + +cairo_format_t nFormat = getCairoFormat(*pBuffer); +return (cairo_format_stride_for_width(nFormat, pBuffer->mnWidth) == pBuffer->mnScanlineSize); +} +} + +cairo_surface_t* CairoCommon::createCairoSurface(const BitmapBuffer* pBuffer) +{ +if (!isCairoCompatible(pBuffer)) +return nullptr; + +cairo_format_t nFormat = getCairoFormat(*pBuffer); +cairo_surface_t* target = cairo_image_surface_create_for_data( +pBuffer->mpBits, nFormat, pBuffer->mnWidth, pBuffer->mnHeight, pBuffer->mnScanlineSize); +if (cairo_surface_status(target) != CAIRO_STATUS_SUCCESS) +{ +cairo_surface_destroy(target); +return nullptr; +} +return target; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 46016e0e3349..5b685178940b 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -59,26 +59,6 @@ namespace { -cairo_format_t getCairoFormat(const BitmapBuffer& rBuffer) -{ -cairo_format_t nFormat; -#ifdef HAVE_CAIRO_FORMAT_RGB24_888 -assert(rBuffer.mnBitCount == 32 || rBuffer.mnBitCount == 24 || rBuffer.mnBitCount == 1); -#else -assert(rBuffer.mnBitCount == 32 || rBuffer.mnBitCount == 1); -#endif - -if (rBuffer.mnBitCount == 32) -nFormat = CAIRO_FORMAT_ARGB32; -#ifdef HAVE_CAIRO_FORMAT_RGB24_888 -else if (rBuffer.mnBitCount == 24) -nFormat = CAIRO_FORMAT_RGB24_888; -#endif -else -nFormat = CAIRO_FORMAT_A1; -return nFormat; -} - void Toggle1BitTransparency(const BitmapBuffer& rBuf) { assert(rBuf.maPalette.GetBestIndex(BitmapColor(COL_BLACK)) == 0); @@ -347,11 +327,11 @@ namespace aTmpBmp.Create(std::move(pTmp)); assert(aTmpBmp.GetBitCount() == 32); - implSetSurface(SvpSalGraphics::createCairoSurface(aTmpBmp.GetBuffer())); + implSetSurface(CairoCommon::createCairoSurface(aTmpBmp.GetBuffer())); } else { - implSetSurface(SvpSalGraphics::createCairoSurface(rSrcBmp.GetBuffer())); + implSetSurface(CairoCommon::createCairoSurface(rSrcBmp.GetBuffer())); } } void mark_dirty() @@ -807,7 +787,7 @@ void SvpSalGraphics::drawBitmap(const SalTwoRect& rTR, const SalBitmap& rSourceB void SvpSalGraphics::drawBitmap(const SalTwoRect& rTR, const BitmapBuffer* pBuffer, cairo_operator_t eOp) { -cairo_surface_t* source = createCairoSurface( pBuffer ); +cairo_surface_t* source = CairoCommon::createCairoSurface(pBuffer); m_aCairoCommon.copyWithOperator(rTR, source, eOp, getAntiAlias()); cairo_surface_destroy(source); } @@ -915,7 +895,7 @@ std::shared_ptr SvpSalGraphics::getBitmap( tools::Long nX, tools::Lon
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/SvpGraphicsBackend.cxx | 57 +--- vcl/headless/svpgdi.cxx | 55 -- vcl/inc/headless/svpgdi.hxx |1 3 files changed, 53 insertions(+), 60 deletions(-) New commits: commit 96b62c331c5c780100de7a5b474af259c8fbb916 Author: Tomaž Vajngerl AuthorDate: Tue Dec 28 13:09:15 2021 +0900 Commit: Tomaž Vajngerl CommitDate: Tue Jan 4 06:55:04 2022 +0100 vcl: drawAlphaRect to SvpGraphicsBackend Change-Id: I44f388b6578d4f9e7d0e5b75e17fab534574da1b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127844 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 460d869766c7..71670cb37bd1 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -486,11 +486,60 @@ bool SvpGraphicsBackend::drawTransformedBitmap(const basegfx::B2DPoint& /*rNull* bool SvpGraphicsBackend::hasFastDrawTransformedBitmap() const { return false; } -bool SvpGraphicsBackend::drawAlphaRect(tools::Long /*nX*/, tools::Long /*nY*/, - tools::Long /*nWidth*/, tools::Long /*nHeight*/, - sal_uInt8 /*nTransparency*/) +bool SvpGraphicsBackend::drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth, + tools::Long nHeight, sal_uInt8 nTransparency) { -return false; +const bool bHasFill(m_rCairoCommon.m_aFillColor != SALCOLOR_NONE); +const bool bHasLine(m_rCairoCommon.m_aLineColor != SALCOLOR_NONE); + +if (!(bHasFill || bHasLine)) +{ +return true; +} + +cairo_t* cr = m_rCairoCommon.getCairoContext(false, getAntiAlias()); +m_rCairoCommon.clipRegion(cr); + +const double fTransparency = nTransparency * (1.0 / 100); + +// To make releaseCairoContext work, use empty extents +basegfx::B2DRange extents; + +if (bHasFill) +{ +cairo_rectangle(cr, nX, nY, nWidth, nHeight); + +m_rCairoCommon.applyColor(cr, m_rCairoCommon.m_aFillColor, fTransparency); + +// set FillDamage +extents = getClippedFillDamage(cr); + +cairo_fill(cr); +} + +if (bHasLine) +{ +// PixelOffset used: Set PixelOffset as linear transformation +// Note: Was missing here - probably not by purpose (?) +cairo_matrix_t aMatrix; +cairo_matrix_init_translate(, 0.5, 0.5); +cairo_set_matrix(cr, ); + +cairo_rectangle(cr, nX, nY, nWidth, nHeight); + +m_rCairoCommon.applyColor(cr, m_rCairoCommon.m_aLineColor, fTransparency); + +// expand with possible StrokeDamage +basegfx::B2DRange stroke_extents = getClippedStrokeDamage(cr); + stroke_extents.transform(basegfx::utils::createTranslateB2DHomMatrix(0.5, 0.5)); +extents.expand(stroke_extents); + +cairo_stroke(cr); +} + +m_rCairoCommon.releaseCairoContext(cr, false, extents); + +return true; } bool SvpGraphicsBackend::drawGradient(const tools::PolyPolygon& rPolyPolygon, diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index eb8edacafbd3..46016e0e3349 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -756,61 +756,6 @@ bool SvpSalGraphics::drawTransformedBitmap( return true; } -bool SvpSalGraphics::drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency) -{ -const bool bHasFill(m_aCairoCommon.m_aFillColor != SALCOLOR_NONE); -const bool bHasLine(m_aCairoCommon.m_aLineColor != SALCOLOR_NONE); - -if(!(bHasFill || bHasLine)) -{ -return true; -} - -cairo_t* cr = m_aCairoCommon.getCairoContext(false, getAntiAlias()); -clipRegion(cr); - -const double fTransparency = nTransparency * (1.0/100); - -// To make releaseCairoContext work, use empty extents -basegfx::B2DRange extents; - -if (bHasFill) -{ -cairo_rectangle(cr, nX, nY, nWidth, nHeight); - -m_aCairoCommon.applyColor(cr, m_aCairoCommon.m_aFillColor, fTransparency); - -// set FillDamage -extents = getClippedFillDamage(cr); - -cairo_fill(cr); -} - -if (bHasLine) -{ -// PixelOffset used: Set PixelOffset as linear transformation -// Note: Was missing here - probably not by purpose (?) -cairo_matrix_t aMatrix; -cairo_matrix_init_translate(, 0.5, 0.5); -cairo_set_matrix(cr, ); - -cairo_rectangle(cr, nX, nY, nWidth, nHeight); - -m_aCairoCommon.applyColor(cr, m_aCairoCommon.m_aLineColor, fTransparency); - -// expand with possible StrokeDamage -basegfx::B2DRange stroke_extents = getClippedStrokeDamage(cr); - stroke_extents.transform(basegfx::utils::createTranslateB2DHomMatrix(0.5, 0.5)); -extents.expand(stroke_extents); - -
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/svpgdi.cxx | 26 -- vcl/inc/headless/svpgdi.hxx |7 --- 2 files changed, 33 deletions(-) New commits: commit dd8ab22bd615bba1a5016f3b418157900bed921c Author: Tomaž Vajngerl AuthorDate: Tue Dec 28 10:29:39 2021 +0900 Commit: Tomaž Vajngerl CommitDate: Tue Jan 4 06:54:49 2022 +0100 vcl: move empty blendBitmap, hasFastDraw,.. to SvpGraphicsBackend Moves blendBitmap, blendAlphaBitmap, hasFastDrawTransformedBitmap, supportsOperation to the SvpGraphicsBackend. Most these are empty stub implementations that aren't supported by the backend. The exception is supportsOperation, which already had been implemented but not removed from svpgdi.*xx files. Change-Id: I240a803d9a8614f1c4ed763a8fc34296202045fa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127843 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 4ec12998a163..eb8edacafbd3 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -57,16 +57,6 @@ # endif #endif -bool SvpSalGraphics::blendBitmap( const SalTwoRect&, const SalBitmap& /*rBitmap*/ ) -{ -return false; -} - -bool SvpSalGraphics::blendAlphaBitmap( const SalTwoRect&, const SalBitmap&, const SalBitmap&, const SalBitmap& ) -{ -return false; -} - namespace { cairo_format_t getCairoFormat(const BitmapBuffer& rBuffer) @@ -766,11 +756,6 @@ bool SvpSalGraphics::drawTransformedBitmap( return true; } -bool SvpSalGraphics::hasFastDrawTransformedBitmap() const -{ -return false; -} - bool SvpSalGraphics::drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency) { const bool bHasFill(m_aCairoCommon.m_aFillColor != SALCOLOR_NONE); @@ -1076,15 +1061,4 @@ SystemGraphicsData SvpSalGraphics::GetGraphicsData() const return SystemGraphicsData(); } -bool SvpSalGraphics::supportsOperation(OutDevSupportType eType) const -{ -switch (eType) -{ -case OutDevSupportType::TransparentRect: -case OutDevSupportType::B2DDraw: -return true; -} -return false; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index 04c507f2d3f9..d304b355ab88 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -59,11 +59,6 @@ protected: std::unique_ptr m_pBackend; protected: -virtual bool blendBitmap( const SalTwoRect&, const SalBitmap& rBitmap ) override; -virtual bool blendAlphaBitmap( const SalTwoRect&, - const SalBitmap& rSrcBitmap, - const SalBitmap& rMaskBitmap, - const SalBitmap& rAlphaBitmap ) override; virtual bool drawAlphaBitmap( const SalTwoRect&, const SalBitmap& rSourceBitmap, const SalBitmap& rAlphaBitmap ) override; virtual bool drawTransformedBitmap( const basegfx::B2DPoint& rNull, @@ -72,7 +67,6 @@ protected: const SalBitmap& rSourceBitmap, const SalBitmap* pAlphaBitmap, double fAlpha) override; -virtual bool hasFastDrawTransformedBitmap() const override; virtual bool drawAlphaRect( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency ) override; cairo_t* createTmpCompatibleCairoContext() const; @@ -110,7 +104,6 @@ public: virtual std::unique_ptr GetTextLayout(int nFallbackLevel) override; virtual voidDrawTextLayout( const GenericSalLayout& ) override; -virtual boolsupportsOperation( OutDevSupportType ) const override; virtual voiddrawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap ) override;
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/CairoCommon.cxx| 94 +- vcl/headless/SvpGraphicsBackend.cxx | 26 +++- vcl/headless/svpgdi.cxx | 112 +--- vcl/inc/headless/CairoCommon.hxx| 10 +++ vcl/inc/headless/svpgdi.hxx | 17 + 5 files changed, 133 insertions(+), 126 deletions(-) New commits: commit 52c903c6a48d62d6ed7841ba2d1021300c8189b3 Author: Tomaž Vajngerl AuthorDate: Tue Dec 28 10:17:53 2021 +0900 Commit: Tomaž Vajngerl CommitDate: Tue Jan 4 05:21:33 2022 +0100 vcl: copyArea and copyBits to SvpGraphicsBackend Also move the used (sub)functions to the CarioCommon: copyBitsCairo, copySource, copyWithOperator, renderSource and renderWithOperator. Also use these functions in some calls needed by drawBitmap & co. Change-Id: I51395953545827951b6f255a9833e828aec7ea60 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127842 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 79baec8ff497..234bfe29fcce 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -834,6 +834,98 @@ bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const C return true; } +namespace +{ +basegfx::B2DRange renderWithOperator(cairo_t* cr, const SalTwoRect& rTR, cairo_surface_t* source, + cairo_operator_t eOperator = CAIRO_OPERATOR_SOURCE) +{ +cairo_rectangle(cr, rTR.mnDestX, rTR.mnDestY, rTR.mnDestWidth, rTR.mnDestHeight); + +basegfx::B2DRange extents = getClippedFillDamage(cr); + +cairo_clip(cr); + +cairo_translate(cr, rTR.mnDestX, rTR.mnDestY); +double fXScale = 1.0f; +double fYScale = 1.0f; +if (rTR.mnSrcWidth != 0 && rTR.mnSrcHeight != 0) +{ +fXScale = static_cast(rTR.mnDestWidth) / rTR.mnSrcWidth; +fYScale = static_cast(rTR.mnDestHeight) / rTR.mnSrcHeight; +cairo_scale(cr, fXScale, fYScale); +} + +cairo_save(cr); +cairo_set_source_surface(cr, source, -rTR.mnSrcX, -rTR.mnSrcY); +if ((fXScale != 1.0 && rTR.mnSrcWidth == 1) || (fYScale != 1.0 && rTR.mnSrcHeight == 1)) +{ +cairo_pattern_t* sourcepattern = cairo_get_source(cr); +cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_REPEAT); +cairo_pattern_set_filter(sourcepattern, CAIRO_FILTER_NEAREST); +} +cairo_set_operator(cr, eOperator); +cairo_paint(cr); +cairo_restore(cr); + +return extents; +} + +} // end anonymous ns + +basegfx::B2DRange CairoCommon::renderSource(cairo_t* cr, const SalTwoRect& rTR, +cairo_surface_t* source) +{ +return renderWithOperator(cr, rTR, source, CAIRO_OPERATOR_SOURCE); +} + +void CairoCommon::copyWithOperator(const SalTwoRect& rTR, cairo_surface_t* source, + cairo_operator_t eOp, bool bAntiAlias) +{ +cairo_t* cr = getCairoContext(false, bAntiAlias); +clipRegion(cr); + +basegfx::B2DRange extents = renderWithOperator(cr, rTR, source, eOp); + +releaseCairoContext(cr, false, extents); +} + +void CairoCommon::copySource(const SalTwoRect& rTR, cairo_surface_t* source, bool bAntiAlias) +{ +copyWithOperator(rTR, source, CAIRO_OPERATOR_SOURCE, bAntiAlias); +} + +void CairoCommon::copyBitsCairo(const SalTwoRect& rTR, cairo_surface_t* pSourceSurface, +bool bAntiAlias) +{ +SalTwoRect aTR(rTR); + +cairo_surface_t* pCopy = nullptr; + +if (pSourceSurface == getSurface()) +{ +//self copy is a problem, so dup source in that case +pCopy += cairo_surface_create_similar(pSourceSurface, cairo_surface_get_content(getSurface()), + aTR.mnSrcWidth * m_fScale, aTR.mnSrcHeight * m_fScale); +dl_cairo_surface_set_device_scale(pCopy, m_fScale, m_fScale); +cairo_t* cr = cairo_create(pCopy); +cairo_set_source_surface(cr, pSourceSurface, -aTR.mnSrcX, -aTR.mnSrcY); +cairo_rectangle(cr, 0, 0, aTR.mnSrcWidth, aTR.mnSrcHeight); +cairo_fill(cr); +cairo_destroy(cr); + +pSourceSurface = pCopy; + +aTR.mnSrcX = 0; +aTR.mnSrcY = 0; +} + +copySource(aTR, pSourceSurface, bAntiAlias); + +if (pCopy) +cairo_surface_destroy(pCopy); +} + namespace { cairo_pattern_t* create_stipple() @@ -847,7 +939,7 @@ cairo_pattern_t* create_stipple() cairo_pattern_set_filter(pattern, CAIRO_FILTER_NEAREST); return pattern; } -} +} // end anonymous ns void CairoCommon::invert(const basegfx::B2DPolygon& rPoly, SalInvert nFlags, bool bAntiAlias) { diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 6a50ca17353c..460d869766c7 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -353,14
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/SvpGraphicsBackend.cxx | 29 - vcl/headless/svpgdi.cxx | 28 vcl/inc/headless/svpgdi.hxx |2 +- 3 files changed, 29 insertions(+), 30 deletions(-) New commits: commit 3aaf8506b3ee0d4a1bb86be7c6ca4d9402467d49 Author: Tomaž Vajngerl AuthorDate: Tue Dec 28 09:48:30 2021 +0900 Commit: Tomaž Vajngerl CommitDate: Mon Jan 3 08:03:20 2022 +0100 vcl: move getPixel to SvpGraphicsBackend Change-Id: I409581a2bdc9e18420bb159ce349fb5a5b86c463 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127825 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 10c02d4644f9..d5dd2fe48b27 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -383,7 +383,34 @@ std::shared_ptr SvpGraphicsBackend::getBitmap(tools::Long /*nX*/, too return std::shared_ptr(); } -Color SvpGraphicsBackend::getPixel(tools::Long /*nX*/, tools::Long /*nY*/) { return Color(); } +Color SvpGraphicsBackend::getPixel(tools::Long nX, tools::Long nY) +{ +#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) +cairo_surface_t* target += cairo_surface_create_similar_image(m_rCairoCommon.m_pSurface, CAIRO_FORMAT_ARGB32, 1, 1); +#else +cairo_surface_t* target = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); +#endif + +cairo_t* cr = cairo_create(target); + +cairo_rectangle(cr, 0, 0, 1, 1); +cairo_set_source_surface(cr, m_rCairoCommon.m_pSurface, -nX, -nY); +cairo_paint(cr); +cairo_destroy(cr); + +cairo_surface_flush(target); +vcl::bitmap::lookup_table const& unpremultiply_table = vcl::bitmap::get_unpremultiply_table(); +unsigned char* data = cairo_image_surface_get_data(target); +sal_uInt8 a = data[SVP_CAIRO_ALPHA]; +sal_uInt8 b = unpremultiply_table[a][data[SVP_CAIRO_BLUE]]; +sal_uInt8 g = unpremultiply_table[a][data[SVP_CAIRO_GREEN]]; +sal_uInt8 r = unpremultiply_table[a][data[SVP_CAIRO_RED]]; +Color aColor(ColorAlpha, a, r, g, b); +cairo_surface_destroy(target); + +return aColor; +} void SvpGraphicsBackend::invert(tools::Long /*nX*/, tools::Long /*nY*/, tools::Long /*nWidth*/, tools::Long /*nHeight*/, SalInvert /*nFlags*/) diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 523a76fbb530..bc6a6231d1c1 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -1108,34 +1108,6 @@ std::shared_ptr SvpSalGraphics::getBitmap( tools::Long nX, tools::Lon return pBitmap; } -Color SvpSalGraphics::getPixel( tools::Long nX, tools::Long nY ) -{ -#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) -cairo_surface_t *target = cairo_surface_create_similar_image(m_aCairoCommon.m_pSurface, CAIRO_FORMAT_ARGB32, 1, 1); -#else -cairo_surface_t *target = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); -#endif - -cairo_t* cr = cairo_create(target); - -cairo_rectangle(cr, 0, 0, 1, 1); -cairo_set_source_surface(cr, m_aCairoCommon.m_pSurface, -nX, -nY); -cairo_paint(cr); -cairo_destroy(cr); - -cairo_surface_flush(target); -vcl::bitmap::lookup_table const & unpremultiply_table = vcl::bitmap::get_unpremultiply_table(); -unsigned char *data = cairo_image_surface_get_data(target); -sal_uInt8 a = data[SVP_CAIRO_ALPHA]; -sal_uInt8 b = unpremultiply_table[a][data[SVP_CAIRO_BLUE]]; -sal_uInt8 g = unpremultiply_table[a][data[SVP_CAIRO_GREEN]]; -sal_uInt8 r = unpremultiply_table[a][data[SVP_CAIRO_RED]]; -Color aColor(ColorAlpha, a, r, g, b); -cairo_surface_destroy(target); - -return aColor; -} - namespace { cairo_pattern_t * create_stipple() diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index 0d36a2cf8442..ba4dec8d29e8 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -140,7 +140,7 @@ public: const SalBitmap& rSalBitmap, Color nMaskColor ) override; virtual std::shared_ptr getBitmap( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override; -virtual Color getPixel( tools::Long nX, tools::Long nY ) override; + virtual voidinvert( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, SalInvert nFlags ) override; virtual voidinvert( sal_uInt32 nPoints, const Point* pPtAry, SalInvert nFlags ) override;
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/unx
vcl/headless/CairoCommon.cxx| 249 ++ vcl/headless/SvpGraphicsBackend.cxx | 52 - vcl/headless/svpgdi.cxx | 337 vcl/inc/headless/CairoCommon.hxx| 15 + vcl/inc/headless/svpgdi.hxx | 29 --- vcl/unx/generic/gdi/salgdi.cxx |2 6 files changed, 307 insertions(+), 377 deletions(-) New commits: commit 8d6343e6b29fc6162d88b25dfa3a165e0d1b063d Author: Tomaž Vajngerl AuthorDate: Wed Dec 15 11:56:09 2021 +0900 Commit: Tomaž Vajngerl CommitDate: Sat Jan 1 16:04:27 2022 +0100 vcl: move drawPolyLine (+legacy) to SvpGraphicsBackend Also moves drawPolyLine with cairo context param. to CairoCommon as it is also needed in X11SalGraphics::drawPolyLine. Change-Id: I49b24bc31ecf3f6ab3cebca4eaab351c91564db5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127740 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 40115a90db1f..7161feb7f29f 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -22,6 +22,10 @@ #include #include #include +#include +#include +#include + void dl_cairo_surface_set_device_scale(cairo_surface_t* surface, double x_scale, double y_scale) { #ifdef ANDROID @@ -584,4 +588,249 @@ void CairoCommon::clipRegion(cairo_t* cr, const vcl::Region& rClipRegion) void CairoCommon::clipRegion(cairo_t* cr) { CairoCommon::clipRegion(cr, m_aClipRegion); } +bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const Color& rLineColor, + bool bAntiAlias, const basegfx::B2DHomMatrix& rObjectToDevice, + const basegfx::B2DPolygon& rPolyLine, double fTransparency, + double fLineWidth, const std::vector* pStroke, + basegfx::B2DLineJoin eLineJoin, css::drawing::LineCap eLineCap, + double fMiterMinimumAngle, bool bPixelSnapHairline) +{ +// short circuit if there is nothing to do +if (0 == rPolyLine.count() || fTransparency < 0.0 || fTransparency >= 1.0) +{ +return true; +} + +// need to check/handle LineWidth when ObjectToDevice transformation is used +const bool bObjectToDeviceIsIdentity(rObjectToDevice.isIdentity()); + +// tdf#124848 calculate-back logical LineWidth for a hairline +// since this implementation hands over the transformation to +// the graphic sub-system +if (fLineWidth == 0) +{ +fLineWidth = 1.0; + +if (!bObjectToDeviceIsIdentity) +{ +basegfx::B2DHomMatrix aObjectToDeviceInv(rObjectToDevice); +aObjectToDeviceInv.invert(); +fLineWidth = (aObjectToDeviceInv * basegfx::B2DVector(fLineWidth, 0)).getLength(); +} +} + +// PixelOffset used: Need to reflect in linear transformation +cairo_matrix_t aMatrix; +basegfx::B2DHomMatrix aDamageMatrix(basegfx::utils::createTranslateB2DHomMatrix(0.5, 0.5)); + +if (bObjectToDeviceIsIdentity) +{ +// Set PixelOffset as requested +cairo_matrix_init_translate(, 0.5, 0.5); +} +else +{ +// Prepare ObjectToDevice transformation. Take PixelOffset for Lines into +// account: Multiply from left to act in DeviceCoordinates +aDamageMatrix = aDamageMatrix * rObjectToDevice; +cairo_matrix_init(, aDamageMatrix.get(0, 0), aDamageMatrix.get(1, 0), + aDamageMatrix.get(0, 1), aDamageMatrix.get(1, 1), aDamageMatrix.get(0, 2), + aDamageMatrix.get(1, 2)); +} + +// set linear transformation +cairo_set_matrix(cr, ); + +// setup line attributes +cairo_line_join_t eCairoLineJoin = CAIRO_LINE_JOIN_MITER; +switch (eLineJoin) +{ +case basegfx::B2DLineJoin::Bevel: +eCairoLineJoin = CAIRO_LINE_JOIN_BEVEL; +break; +case basegfx::B2DLineJoin::Round: +eCairoLineJoin = CAIRO_LINE_JOIN_ROUND; +break; +case basegfx::B2DLineJoin::NONE: +case basegfx::B2DLineJoin::Miter: +eCairoLineJoin = CAIRO_LINE_JOIN_MITER; +break; +} + +// convert miter minimum angle to miter limit +double fMiterLimit = 1.0 / sin(fMiterMinimumAngle / 2.0); + +// setup cap attribute +cairo_line_cap_t eCairoLineCap(CAIRO_LINE_CAP_BUTT); + +switch (eLineCap) +{ +default: // css::drawing::LineCap_BUTT: +{ +eCairoLineCap = CAIRO_LINE_CAP_BUTT; +break; +} +case css::drawing::LineCap_ROUND: +{ +eCairoLineCap = CAIRO_LINE_CAP_ROUND; +break; +} +case css::drawing::LineCap_SQUARE: +{ +eCairoLineCap = CAIRO_LINE_CAP_SQUARE; +break; +} +
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/svpgdi.cxx | 25 - vcl/inc/headless/svpgdi.hxx | 11 --- 2 files changed, 36 deletions(-) New commits: commit 102a29d59a0a195ee42a52d5563adf99fa32a541 Author: Tomaž Vajngerl AuthorDate: Sat Nov 27 21:46:42 2021 +0100 Commit: Tomaž Vajngerl CommitDate: Sat Jan 1 03:51:20 2022 +0100 vcl: move the draw*Bezier methods to SvpGraphicsBackend These methods only return false (for fallback implementation to kick-in). Change-Id: I167dda09d401e69ca4a2296e8024ab0f203b097a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127739 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 51de3dc1d9b6..c4f0810c8b83 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -1202,31 +1202,6 @@ bool SvpSalGraphics::drawPolyLine( return true; } -bool SvpSalGraphics::drawPolyLineBezier( sal_uInt32, - const Point*, - const PolyFlags* ) -{ -SAL_INFO("vcl.gdi", "unsupported SvpSalGraphics::drawPolyLineBezier case"); -return false; -} - -bool SvpSalGraphics::drawPolygonBezier( sal_uInt32, -const Point*, -const PolyFlags* ) -{ -SAL_INFO("vcl.gdi", "unsupported SvpSalGraphics::drawPolygonBezier case"); -return false; -} - -bool SvpSalGraphics::drawPolyPolygonBezier( sal_uInt32, -const sal_uInt32*, -const Point* const*, -const PolyFlags* const* ) -{ -SAL_INFO("vcl.gdi", "unsupported SvpSalGraphics::drawPolyPolygonBezier case"); -return false; -} - bool SvpSalGraphics::drawGradient(const tools::PolyPolygon& rPolyPolygon, const Gradient& rGradient) { if (rGradient.GetStyle() != GradientStyle::Linear diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index 0db4fb0a73ed..b9ece62a2267 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -150,17 +150,6 @@ public: virtual voiddrawPolyLine( sal_uInt32 nPoints, const Point* pPtAry ) override; virtual voiddrawPolygon( sal_uInt32 nPoints, const Point* pPtAry ) override; -virtual booldrawPolyLineBezier( sal_uInt32 nPoints, -const Point* pPtAry, -const PolyFlags* pFlgAry ) override; -virtual booldrawPolygonBezier( sal_uInt32 nPoints, - const Point* pPtAry, - const PolyFlags* pFlgAry ) override; -virtual booldrawPolyPolygonBezier( sal_uInt32 nPoly, - const sal_uInt32* pPoints, - const Point* const* pPtAry, - const PolyFlags* const* pFlgAry ) override; - virtual bool drawGradient(tools::PolyPolygon const & rPolyPolygon, Gradient const & rGradient) override; virtual bool implDrawGradient(basegfx::B2DPolyPolygon const & rPolyPolygon, SalGradient const & rGradient) override;
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/SvpGraphicsBackend.cxx | 21 +++-- vcl/headless/svpgdi.cxx | 26 -- vcl/inc/headless/svpgdi.hxx |4 +--- 3 files changed, 20 insertions(+), 31 deletions(-) New commits: commit 96107b0196a0b91e8966db1f12052f5c3d32c944 Author: Tomaž Vajngerl AuthorDate: Sat Nov 27 21:40:41 2021 +0100 Commit: Tomaž Vajngerl CommitDate: Sat Jan 1 03:51:00 2022 +0100 vcl: move drawPolyPolygon(..., Point**) to SvpGraphicsBackend This moves the legacy drawPolyPolygon, which takes a 2D array of points as the input. The implementation just converts it to a B2dPolyPolygon and calls the regular drawPolyPolygon. Change-Id: I5be8b818bcdf58a15e575b904ed20bb8f97bcffc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127738 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index b44ba3dda90f..f19749196cab 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -191,9 +191,26 @@ void SvpGraphicsBackend::drawPolyLine(sal_uInt32 /*nPoints*/, const Point* /*pPt void SvpGraphicsBackend::drawPolygon(sal_uInt32 /*nPoints*/, const Point* /*pPtAry*/) {} -void SvpGraphicsBackend::drawPolyPolygon(sal_uInt32 /*nPoly*/, const sal_uInt32* /*pPointCounts*/, - const Point** /*pPtAry*/) +void SvpGraphicsBackend::drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32* pPointCounts, + const Point** pPtAry) { +basegfx::B2DPolyPolygon aPolyPoly; +for (sal_uInt32 nPolygon = 0; nPolygon < nPoly; ++nPolygon) +{ +sal_uInt32 nPoints = pPointCounts[nPolygon]; +if (nPoints) +{ +const Point* pPoints = pPtAry[nPolygon]; +basegfx::B2DPolygon aPoly; +aPoly.append(basegfx::B2DPoint(pPoints->getX(), pPoints->getY()), nPoints); +for (sal_uInt32 i = 1; i < nPoints; ++i) +aPoly.setB2DPoint(i, basegfx::B2DPoint(pPoints[i].getX(), pPoints[i].getY())); + +aPolyPoly.append(aPoly); +} +} + +drawPolyPolygon(basegfx::B2DHomMatrix(), aPolyPoly, 0.0); } bool SvpGraphicsBackend::drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice, diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 65f9e13aafd5..51de3dc1d9b6 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -885,32 +885,6 @@ void SvpSalGraphics::drawPolygon(sal_uInt32 nPoints, const Point* pPtAry) 0.0); } -void SvpSalGraphics::drawPolyPolygon(sal_uInt32 nPoly, - const sal_uInt32* pPointCounts, - const Point** pPtAry) -{ -basegfx::B2DPolyPolygon aPolyPoly; -for(sal_uInt32 nPolygon = 0; nPolygon < nPoly; ++nPolygon) -{ -sal_uInt32 nPoints = pPointCounts[nPolygon]; -if (nPoints) -{ -const Point* pPoints = pPtAry[nPolygon]; -basegfx::B2DPolygon aPoly; -aPoly.append( basegfx::B2DPoint(pPoints->getX(), pPoints->getY()), nPoints); -for (sal_uInt32 i = 1; i < nPoints; ++i) -aPoly.setB2DPoint(i, basegfx::B2DPoint( pPoints[i].getX(), pPoints[i].getY())); - -aPolyPoly.append(aPoly); -} -} - -GetImpl()->drawPolyPolygon( -basegfx::B2DHomMatrix(), -aPolyPoly, -0.0); -} - bool SvpSalGraphics::drawPolyLine( const basegfx::B2DHomMatrix& rObjectToDevice, const basegfx::B2DPolygon& rPolyLine, diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index 1196b29ca26e..0db4fb0a73ed 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -149,9 +149,7 @@ public: bool bPixelSnapHairline) override; virtual voiddrawPolyLine( sal_uInt32 nPoints, const Point* pPtAry ) override; virtual voiddrawPolygon( sal_uInt32 nPoints, const Point* pPtAry ) override; -virtual voiddrawPolyPolygon( sal_uInt32 nPoly, - const sal_uInt32* pPoints, - const Point** pPtAry ) override; + virtual booldrawPolyLineBezier( sal_uInt32 nPoints, const Point* pPtAry, const PolyFlags* pFlgAry ) override;
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/CairoCommon.cxx| 83 +++- vcl/headless/SvpGraphicsBackend.cxx | 104 ++- vcl/headless/svpgdi.cxx | 247 vcl/inc/headless/CairoCommon.hxx| 32 vcl/inc/headless/svpgdi.hxx |7 - 5 files changed, 214 insertions(+), 259 deletions(-) New commits: commit a2da849163cbbba5ab4272999b9fb081240f1786 Author: Tomaž Vajngerl AuthorDate: Sat Nov 27 21:29:15 2021 +0100 Commit: Tomaž Vajngerl CommitDate: Sat Jan 1 03:50:45 2022 +0100 vcl: move drawRect and drawPolyPolygon to SvpGraphicsBackend Also move add_polygon_path and SystemDependentData_CairoPath class to CairoCommon. SystemDependentData_CairoPath is temporary made public until other dependencies are moved too. Change-Id: I381407fc7c168c8982fcfd8c886cf622f95591fd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127711 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index e79a6b2d6a9b..40115a90db1f 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -20,8 +20,8 @@ #include #include #include +#include #include - void dl_cairo_surface_set_device_scale(cairo_surface_t* surface, double x_scale, double y_scale) { #ifdef ANDROID @@ -298,6 +298,87 @@ basegfx::B2DPoint impPixelSnap(const basegfx::B2DPolygon& rPolygon, return rPolygon.getB2DPoint(nIndex); } +SystemDependentData_CairoPath::SystemDependentData_CairoPath( +basegfx::SystemDependentDataManager& rSystemDependentDataManager, size_t nSizeMeasure, +cairo_t* cr, bool bNoJoin, bool bAntiAlias, const std::vector* pStroke) +: basegfx::SystemDependentData(rSystemDependentDataManager) +, mpCairoPath(nullptr) +, mbNoJoin(bNoJoin) +, mbAntiAlias(bAntiAlias) +{ +// tdf#129845 only create a copy of the path when nSizeMeasure is +// bigger than some decent threshold +if (nSizeMeasure > 50) +{ +mpCairoPath = cairo_copy_path(cr); + +if (nullptr != pStroke) +{ +maStroke = *pStroke; +} +} +} + +SystemDependentData_CairoPath::~SystemDependentData_CairoPath() +{ +if (nullptr != mpCairoPath) +{ +cairo_path_destroy(mpCairoPath); +mpCairoPath = nullptr; +} +} + +sal_Int64 SystemDependentData_CairoPath::estimateUsageInBytes() const +{ +// tdf#129845 by using the default return value of zero when no path +// was created, SystemDependentData::calculateCombinedHoldCyclesInSeconds +// will do the right thing and not buffer this entry at all +sal_Int64 nRetval(0); + +if (nullptr != mpCairoPath) +{ +// per node +// - num_data incarnations of +// - sizeof(cairo_path_data_t) which is a union of defines and point data +// thus may 2 x sizeof(double) +nRetval = mpCairoPath->num_data * sizeof(cairo_path_data_t); +} + +return nRetval; +} + +void add_polygon_path(cairo_t* cr, const basegfx::B2DPolyPolygon& rPolyPolygon, + const basegfx::B2DHomMatrix& rObjectToDevice, bool bPixelSnap) +{ +// try to access buffered data +std::shared_ptr pSystemDependentData_CairoPath( +rPolyPolygon.getSystemDependentData()); + +if (pSystemDependentData_CairoPath) +{ +// re-use data +cairo_append_path(cr, pSystemDependentData_CairoPath->getCairoPath()); +} +else +{ +// create data +size_t nSizeMeasure(0); + +for (const auto& rPoly : rPolyPolygon) +{ +// PixelOffset used: Was dependent of 'm_aLineColor != SALCOLOR_NONE' +// Adapt setupPolyPolygon-users to set a linear transformation to achieve PixelOffset +nSizeMeasure += AddPolygonToPath(cr, rPoly, rObjectToDevice, bPixelSnap, false); +} + +// copy and add to buffering mechanism +// for decisions how/what to buffer, see Note in WinSalGraphicsImpl::drawPolyPolygon +pSystemDependentData_CairoPath += rPolyPolygon.addOrReplaceSystemDependentData( +ImplGetSystemDependentDataManager(), nSizeMeasure, cr, false, false, nullptr); +} +} + cairo_user_data_key_t* CairoCommon::getDamageKey() { static cairo_user_data_key_t aDamageKey; diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index d3a53fefe3f1..b44ba3dda90f 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -151,9 +151,40 @@ void SvpGraphicsBackend::drawLine(tools::Long nX1, tools::Long nY1, tools::Long m_rCairoCommon.releaseCairoContext(cr, false, extents); } -void SvpGraphicsBackend::drawRect(tools::Long /*nX*/, tools::Long /*nY*/, tools::Long /*nWidth*/, - tools::Long /*nHeight*/) +void SvpGraphicsBackend::drawRect(tools::Long nX,
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/CairoCommon.cxx| 207 + vcl/headless/SvpGraphicsBackend.cxx | 31 vcl/headless/svpgdi.cxx | 250 vcl/inc/headless/CairoCommon.hxx| 12 + vcl/inc/headless/svpgdi.hxx |1 5 files changed, 248 insertions(+), 253 deletions(-) New commits: commit f1cbb458e158c8f62c9c47917f8ab0ef76ba0ced Author: Tomaž Vajngerl AuthorDate: Fri Nov 26 19:53:59 2021 +0100 Commit: Tomaž Vajngerl CommitDate: Thu Dec 30 16:20:39 2021 +0100 vcl: move drawLine to SvpGraphicsBackend Also move getClippedStrokeDamage, AddPolygonToPath, impPixelSnap to CairoCommon, as it is needed by the move. Change-Id: I002f0094935e5f5d4836bb973f7cf7bea0218ff2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127710 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 5ba1ebb0edf1..e79a6b2d6a9b 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -91,6 +91,213 @@ basegfx::B2DRange getClippedFillDamage(cairo_t* cr) return aDamageRect; } +basegfx::B2DRange getStrokeDamage(cairo_t* cr) +{ +double x1, y1, x2, y2; + +// less accurate, but much faster +cairo_path_extents(cr, , , , ); + +// support B2DRange::isEmpty() +if (0.0 != x1 || 0.0 != y1 || 0.0 != x2 || 0.0 != y2) +{ +return basegfx::B2DRange(x1, y1, x2, y2); +} + +return basegfx::B2DRange(); +} + +basegfx::B2DRange getClippedStrokeDamage(cairo_t* cr) +{ +basegfx::B2DRange aDamageRect(getStrokeDamage(cr)); +aDamageRect.intersect(getClipBox(cr)); +return aDamageRect; +} + +// Remove bClosePath: Checked that the already used mechanism for Win using +// Gdiplus already relies on rPolygon.isClosed(), so should be safe to replace +// this. +// For PixelSnap we need the ObjectToDevice transformation here now. This is a +// special case relative to the also executed LineDraw-Offset of (0.5, 0.5) in +// DeviceCoordinates: The LineDraw-Offset is applied *after* the snap, so we +// need the ObjectToDevice transformation *without* that offset here to do the +// same. The LineDraw-Offset will be applied by the callers using a linear +// transformation for Cairo now +// For support of PixelSnapHairline we also need the ObjectToDevice transformation +// and a method (same as in gdiimpl.cxx for Win and Gdiplus). This is needed e.g. +// for Chart-content visualization. CAUTION: It's not the same as PixelSnap (!) +// tdf#129845 add reply value to allow counting a point/byte/size measurement to +// be included +size_t AddPolygonToPath(cairo_t* cr, const basegfx::B2DPolygon& rPolygon, +const basegfx::B2DHomMatrix& rObjectToDevice, bool bPixelSnap, +bool bPixelSnapHairline) +{ +// short circuit if there is nothing to do +const sal_uInt32 nPointCount(rPolygon.count()); +size_t nSizeMeasure(0); + +if (0 == nPointCount) +{ +return nSizeMeasure; +} + +const bool bHasCurves(rPolygon.areControlPointsUsed()); +const bool bClosePath(rPolygon.isClosed()); +const bool bObjectToDeviceUsed(!rObjectToDevice.isIdentity()); +basegfx::B2DHomMatrix aObjectToDeviceInv; +basegfx::B2DPoint aLast; + +for (sal_uInt32 nPointIdx = 0, nPrevIdx = 0;; nPrevIdx = nPointIdx++) +{ +int nClosedIdx = nPointIdx; +if (nPointIdx >= nPointCount) +{ +// prepare to close last curve segment if needed +if (bClosePath && (nPointIdx == nPointCount)) +{ +nClosedIdx = 0; +} +else +{ +break; +} +} + +basegfx::B2DPoint aPoint(rPolygon.getB2DPoint(nClosedIdx)); + +if (bPixelSnap) +{ +// snap device coordinates to full pixels +if (bObjectToDeviceUsed) +{ +// go to DeviceCoordinates +aPoint *= rObjectToDevice; +} + +// snap by rounding +aPoint.setX(basegfx::fround(aPoint.getX())); +aPoint.setY(basegfx::fround(aPoint.getY())); + +if (bObjectToDeviceUsed) +{ +if (aObjectToDeviceInv.isIdentity()) +{ +aObjectToDeviceInv = rObjectToDevice; +aObjectToDeviceInv.invert(); +} + +// go back to ObjectCoordinates +aPoint *= aObjectToDeviceInv; +} +} + +if (bPixelSnapHairline) +{ +// snap horizontal and vertical lines (mainly used in Chart for +// 'nicer' AAing) +aPoint = impPixelSnap(rPolygon, rObjectToDevice, aObjectToDeviceInv, nClosedIdx); +} + +if (!nPointIdx) +{ +// first point => just move there +
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/CairoCommon.cxx| 38 +++ vcl/headless/SvpGraphicsBackend.cxx | 21 +++- vcl/headless/svpgdi.cxx | 59 vcl/inc/headless/CairoCommon.hxx|4 ++ vcl/inc/headless/svpgdi.hxx |3 - 5 files changed, 62 insertions(+), 63 deletions(-) New commits: commit c14ca07fdcb7dee9b0099ec9c9ec419affe68779 Author: Tomaž Vajngerl AuthorDate: Fri Nov 26 19:40:51 2021 +0100 Commit: Tomaž Vajngerl CommitDate: Thu Dec 30 16:20:10 2021 +0100 vcl: move drawPixel to SvpGraphicsBackend Includes moving getClippedFillDamage and dependent functions to CairoCommon. Change-Id: Iea7c39377816c3639de1b97cea47efa71ca47315 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127709 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 37a77d866456..5ba1ebb0edf1 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -53,6 +53,44 @@ void dl_cairo_surface_get_device_scale(cairo_surface_t* surface, double* x_scale #endif } +basegfx::B2DRange getFillDamage(cairo_t* cr) +{ +double x1, y1, x2, y2; + +// this is faster than cairo_fill_extents, at the cost of some overdraw +cairo_path_extents(cr, , , , ); + +// support B2DRange::isEmpty() +if (0.0 != x1 || 0.0 != y1 || 0.0 != x2 || 0.0 != y2) +{ +return basegfx::B2DRange(x1, y1, x2, y2); +} + +return basegfx::B2DRange(); +} + +basegfx::B2DRange getClipBox(cairo_t* cr) +{ +double x1, y1, x2, y2; + +cairo_clip_extents(cr, , , , ); + +// support B2DRange::isEmpty() +if (0.0 != x1 || 0.0 != y1 || 0.0 != x2 || 0.0 != y2) +{ +return basegfx::B2DRange(x1, y1, x2, y2); +} + +return basegfx::B2DRange(); +} + +basegfx::B2DRange getClippedFillDamage(cairo_t* cr) +{ +basegfx::B2DRange aDamageRect(getFillDamage(cr)); +aDamageRect.intersect(getClipBox(cr)); +return aDamageRect; +} + cairo_user_data_key_t* CairoCommon::getDamageKey() { static cairo_user_data_key_t aDamageKey; diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 8b318e2737fb..c4bfe42d4844 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -98,9 +98,26 @@ void SvpGraphicsBackend::SetROPFillColor(SalROPColor nROPColor) } } -void SvpGraphicsBackend::drawPixel(tools::Long /*nX*/, tools::Long /*nY*/) {} +void SvpGraphicsBackend::drawPixel(tools::Long nX, tools::Long nY) +{ +if (m_rCairoCommon.m_aLineColor != SALCOLOR_NONE) +{ +drawPixel(nX, nY, m_rCairoCommon.m_aLineColor); +} +} -void SvpGraphicsBackend::drawPixel(tools::Long /*nX*/, tools::Long /*nY*/, Color /*aColor*/) {} +void SvpGraphicsBackend::drawPixel(tools::Long nX, tools::Long nY, Color aColor) +{ +cairo_t* cr = m_rCairoCommon.getCairoContext(true, getAntiAlias()); +m_rCairoCommon.clipRegion(cr); + +cairo_rectangle(cr, nX, nY, 1, 1); +m_rCairoCommon.applyColor(cr, aColor, 0.0); +cairo_fill(cr); + +basegfx::B2DRange extents = getClippedFillDamage(cr); +m_rCairoCommon.releaseCairoContext(cr, true, extents); +} void SvpGraphicsBackend::drawLine(tools::Long /*nX1*/, tools::Long /*nY1*/, tools::Long /*nX2*/, tools::Long /*nY2*/) diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index d6c7fd16c17e..4c2695b5c999 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -59,44 +59,6 @@ namespace { -basegfx::B2DRange getClipBox(cairo_t* cr) -{ -double x1, y1, x2, y2; - -cairo_clip_extents(cr, , , , ); - -// support B2DRange::isEmpty() -if(0.0 != x1 || 0.0 != y1 || 0.0 != x2 || 0.0 != y2) -{ -return basegfx::B2DRange(x1, y1, x2, y2); -} - -return basegfx::B2DRange(); -} - -basegfx::B2DRange getFillDamage(cairo_t* cr) -{ -double x1, y1, x2, y2; - -// this is faster than cairo_fill_extents, at the cost of some overdraw -cairo_path_extents(cr, , , , ); - -// support B2DRange::isEmpty() -if(0.0 != x1 || 0.0 != y1 || 0.0 != x2 || 0.0 != y2) -{ -return basegfx::B2DRange(x1, y1, x2, y2); -} - -return basegfx::B2DRange(); -} - -basegfx::B2DRange getClippedFillDamage(cairo_t* cr) -{ -basegfx::B2DRange aDamageRect(getFillDamage(cr)); -aDamageRect.intersect(getClipBox(cr)); -return aDamageRect; -} - basegfx::B2DRange getStrokeDamage(cairo_t* cr) { double x1, y1, x2, y2; @@ -916,27 +878,6 @@ void SvpSalGraphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) rDPIX = rDPIY = 96; } -void SvpSalGraphics::drawPixel( tools::Long nX, tools::Long nY ) -{ -if (m_aCairoCommon.m_aLineColor != SALCOLOR_NONE) -{ -
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/unx
vcl/headless/CairoCommon.cxx | 35 ++ vcl/headless/svpgdi.cxx | 51 --- vcl/inc/headless/CairoCommon.hxx |4 +++ vcl/inc/headless/svpgdi.hxx |8 +++--- vcl/unx/generic/gdi/salgdi.cxx |6 +++- 5 files changed, 54 insertions(+), 50 deletions(-) New commits: commit 9d895ff47126b4fd95b95c8138bc8fdb8abbf1cc Author: Tomaž Vajngerl AuthorDate: Tue Nov 16 22:15:58 2021 +0100 Commit: Tomaž Vajngerl CommitDate: Thu Dec 30 16:19:48 2021 +0100 vcl: move applyColor and clipRegion to CairoCommon Change-Id: I0a207b10017923c4336d49ebc8abd53c78d809ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127708 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index f4aea95a1bdd..37a77d866456 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -223,4 +223,39 @@ cairo_t* CairoCommon::createTmpCompatibleCairoContext() const return cairo_create(target); } +void CairoCommon::applyColor(cairo_t* cr, Color aColor, double fTransparency) +{ +if (cairo_surface_get_content(m_pSurface) == CAIRO_CONTENT_COLOR_ALPHA) +{ +cairo_set_source_rgba(cr, aColor.GetRed() / 255.0, aColor.GetGreen() / 255.0, + aColor.GetBlue() / 255.0, 1.0 - fTransparency); +} +else +{ +double fSet = aColor == COL_BLACK ? 1.0 : 0.0; +cairo_set_source_rgba(cr, 1, 1, 1, fSet); +cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); +} +} + +void CairoCommon::clipRegion(cairo_t* cr, const vcl::Region& rClipRegion) +{ +RectangleVector aRectangles; +if (!rClipRegion.IsEmpty()) +{ +rClipRegion.GetRegionRectangles(aRectangles); +} +if (!aRectangles.empty()) +{ +for (auto const& rectangle : aRectangles) +{ +cairo_rectangle(cr, rectangle.Left(), rectangle.Top(), rectangle.GetWidth(), +rectangle.GetHeight()); +} +cairo_clip(cr); +} +} + +void CairoCommon::clipRegion(cairo_t* cr) { CairoCommon::clipRegion(cr, m_aClipRegion); } + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index b119a0b749e4..d6c7fd16c17e 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -835,28 +835,6 @@ bool SvpSalGraphics::hasFastDrawTransformedBitmap() const return false; } -void SvpSalGraphics::clipRegion(cairo_t* cr, const vcl::Region& rClipRegion) -{ -RectangleVector aRectangles; -if (!rClipRegion.IsEmpty()) -{ -rClipRegion.GetRegionRectangles(aRectangles); -} -if (!aRectangles.empty()) -{ -for (auto const& rectangle : aRectangles) -{ -cairo_rectangle(cr, rectangle.Left(), rectangle.Top(), rectangle.GetWidth(), rectangle.GetHeight()); -} -cairo_clip(cr); -} -} - -void SvpSalGraphics::clipRegion(cairo_t* cr) -{ -SvpSalGraphics::clipRegion(cr, m_aCairoCommon.m_aClipRegion); -} - bool SvpSalGraphics::drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency) { const bool bHasFill(m_aCairoCommon.m_aFillColor != SALCOLOR_NONE); @@ -879,7 +857,7 @@ bool SvpSalGraphics::drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long n { cairo_rectangle(cr, nX, nY, nWidth, nHeight); -applyColor(cr, m_aCairoCommon.m_aFillColor, fTransparency); +m_aCairoCommon.applyColor(cr, m_aCairoCommon.m_aFillColor, fTransparency); // set FillDamage extents = getClippedFillDamage(cr); @@ -897,7 +875,7 @@ bool SvpSalGraphics::drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long n cairo_rectangle(cr, nX, nY, nWidth, nHeight); -applyColor(cr, m_aCairoCommon.m_aLineColor, fTransparency); +m_aCairoCommon.applyColor(cr, m_aCairoCommon.m_aLineColor, fTransparency); // expand with possible StrokeDamage basegfx::B2DRange stroke_extents = getClippedStrokeDamage(cr); @@ -952,7 +930,7 @@ void SvpSalGraphics::drawPixel( tools::Long nX, tools::Long nY, Color aColor ) clipRegion(cr); cairo_rectangle(cr, nX, nY, 1, 1); -applyColor(cr, aColor, 0.0); +m_aCairoCommon.applyColor(cr, aColor, 0.0); cairo_fill(cr); basegfx::B2DRange extents = getClippedFillDamage(cr); @@ -1271,7 +1249,7 @@ void SvpSalGraphics::drawLine( tools::Long nX1, tools::Long nY1, tools::Long nX2 !getAntiAlias(), false); -applyColor(cr, m_aCairoCommon.m_aLineColor); +m_aCairoCommon.applyColor(cr, m_aCairoCommon.m_aLineColor); basegfx::B2DRange extents = getClippedStrokeDamage(cr); extents.transform(basegfx::utils::createTranslateB2DHomMatrix(0.5, 0.5)); @@ -1793,7 +1771,7 @@ bool SvpSalGraphics::drawPolyPolygon( {
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/CairoCommon.cxx | 204 + vcl/headless/svpgdi.cxx | 267 --- vcl/inc/headless/CairoCommon.hxx | 26 +++ vcl/inc/headless/svpgdi.hxx | 31 ++-- 4 files changed, 276 insertions(+), 252 deletions(-) New commits: commit 26836c3a4f7032f597b829f4d6b896294404ef8f Author: Tomaž Vajngerl AuthorDate: Tue Nov 16 22:01:14 2021 +0100 Commit: Tomaž Vajngerl CommitDate: Thu Dec 30 11:48:03 2021 +0100 vcl: move getting and releasing cairo context to CairoCommon The getting/creating and releasing of the cairo context is needed by the SvpGraphicBackend. Change-Id: I133b181b8a6b114e08c8acc4596ccefb88a3f514 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127707 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 3db6f14f8417..f4aea95a1bdd 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -18,5 +18,209 @@ */ #include +#include +#include +#include + +void dl_cairo_surface_set_device_scale(cairo_surface_t* surface, double x_scale, double y_scale) +{ +#ifdef ANDROID +cairo_surface_set_device_scale(surface, x_scale, y_scale); +#else +static auto func = reinterpret_cast( +dlsym(nullptr, "cairo_surface_set_device_scale")); +if (func) +func(surface, x_scale, y_scale); +#endif +} + +void dl_cairo_surface_get_device_scale(cairo_surface_t* surface, double* x_scale, double* y_scale) +{ +#ifdef ANDROID +cairo_surface_get_device_scale(surface, x_scale, y_scale); +#else +static auto func = reinterpret_cast( +dlsym(nullptr, "cairo_surface_get_device_scale")); +if (func) +func(surface, x_scale, y_scale); +else +{ +if (x_scale) +*x_scale = 1.0; +if (y_scale) +*y_scale = 1.0; +} +#endif +} + +cairo_user_data_key_t* CairoCommon::getDamageKey() +{ +static cairo_user_data_key_t aDamageKey; +return +} + +cairo_t* CairoCommon::getCairoContext(bool bXorModeAllowed, bool bAntiAlias) const +{ +cairo_t* cr; +if (m_ePaintMode == PaintMode::Xor && bXorModeAllowed) +cr = createTmpCompatibleCairoContext(); +else +cr = cairo_create(m_pSurface); +cairo_set_line_width(cr, 1); +cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD); +cairo_set_antialias(cr, bAntiAlias ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE); +cairo_set_operator(cr, CAIRO_OPERATOR_OVER); + +// ensure no linear transformation and no PathInfo in local cairo_path_t +cairo_identity_matrix(cr); +cairo_new_path(cr); + +return cr; +} + +void CairoCommon::releaseCairoContext(cairo_t* cr, bool bXorModeAllowed, + const basegfx::B2DRange& rExtents) const +{ +const bool bXoring = (m_ePaintMode == PaintMode::Xor && bXorModeAllowed); + +if (rExtents.isEmpty()) +{ +//nothing changed, return early +if (bXoring) +{ +cairo_surface_t* surface = cairo_get_target(cr); +cairo_surface_destroy(surface); +} +cairo_destroy(cr); +return; +} + +basegfx::B2IRange aIntExtents(basegfx::unotools::b2ISurroundingRangeFromB2DRange(rExtents)); +sal_Int32 nExtentsLeft(aIntExtents.getMinX()), nExtentsTop(aIntExtents.getMinY()); +sal_Int32 nExtentsRight(aIntExtents.getMaxX()), nExtentsBottom(aIntExtents.getMaxY()); +sal_Int32 nWidth = m_aFrameSize.getX(); +sal_Int32 nHeight = m_aFrameSize.getY(); +nExtentsLeft = std::max(nExtentsLeft, 0); +nExtentsTop = std::max(nExtentsTop, 0); +nExtentsRight = std::min(nExtentsRight, nWidth); +nExtentsBottom = std::min(nExtentsBottom, nHeight); + +cairo_surface_t* surface = cairo_get_target(cr); +cairo_surface_flush(surface); + +//For the most part we avoid the use of XOR these days, but there +//are some edge cases where legacy stuff still supports it, so +//emulate it (slowly) here. +if (bXoring) +{ +cairo_surface_t* target_surface = m_pSurface; +if (cairo_surface_get_type(target_surface) != CAIRO_SURFACE_TYPE_IMAGE) +{ +//in the unlikely case we can't use m_pSurface directly, copy contents +//to another temp image surface +cairo_t* copycr = createTmpCompatibleCairoContext(); +cairo_rectangle(copycr, nExtentsLeft, nExtentsTop, nExtentsRight - nExtentsLeft, +nExtentsBottom - nExtentsTop); +cairo_set_source_surface(copycr, m_pSurface, 0, 0); +cairo_paint(copycr); +target_surface = cairo_get_target(copycr); +cairo_destroy(copycr); +} + +cairo_surface_flush(target_surface); +unsigned char* target_surface_data = cairo_image_surface_get_data(target_surface); +unsigned char*
[Libreoffice-commits] core.git: vcl/headless vcl/inc
vcl/headless/SvpGraphicsBackend.cxx | 45 --- vcl/headless/svpgdi.cxx | 108 vcl/inc/headless/CairoCommon.hxx| 12 vcl/inc/headless/svpgdi.hxx | 15 - 4 files changed, 74 insertions(+), 106 deletions(-) New commits: commit 96113a1d1df9b1f0e2bf75a90e6111a65250334d Author: Tomaž Vajngerl AuthorDate: Sun Nov 14 23:07:31 2021 +0100 Commit: Tomaž Vajngerl CommitDate: Thu Dec 30 11:47:46 2021 +0100 vcl: move lineColor, fillColor and paintMode to SvpGraphicBackend The member variables are moved to CairoCommon. Change-Id: Ia03f613c7ad02ec2e7d70705c7666ec25d63f003 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127706 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index e41cc5449b88..8b318e2737fb 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -53,19 +53,50 @@ tools::Long SvpGraphicsBackend::GetGraphicsWidth() const return m_rCairoCommon.m_pSurface ? m_rCairoCommon.m_aFrameSize.getX() : 0; } -void SvpGraphicsBackend::SetLineColor() {} +void SvpGraphicsBackend::SetLineColor() { m_rCairoCommon.m_aLineColor = SALCOLOR_NONE; } -void SvpGraphicsBackend::SetLineColor(Color /*nColor*/) {} +void SvpGraphicsBackend::SetLineColor(Color nColor) { m_rCairoCommon.m_aLineColor = nColor; } -void SvpGraphicsBackend::SetFillColor() {} +void SvpGraphicsBackend::SetFillColor() { m_rCairoCommon.m_aFillColor = SALCOLOR_NONE; } -void SvpGraphicsBackend::SetFillColor(Color /*nColor*/) {} +void SvpGraphicsBackend::SetFillColor(Color nColor) { m_rCairoCommon.m_aFillColor = nColor; } -void SvpGraphicsBackend::SetXORMode(bool /*bSet*/, bool /*bInvertOnly*/) {} +void SvpGraphicsBackend::SetXORMode(bool bSet, bool /*bInvertOnly*/) +{ +m_rCairoCommon.m_ePaintMode = bSet ? PaintMode::Xor : PaintMode::Over; +} -void SvpGraphicsBackend::SetROPLineColor(SalROPColor /*nROPColor*/) {} +void SvpGraphicsBackend::SetROPLineColor(SalROPColor nROPColor) +{ +switch (nROPColor) +{ +case SalROPColor::N0: +m_rCairoCommon.m_aLineColor = Color(0, 0, 0); +break; +case SalROPColor::N1: +m_rCairoCommon.m_aLineColor = Color(0xff, 0xff, 0xff); +break; +case SalROPColor::Invert: +m_rCairoCommon.m_aLineColor = Color(0xff, 0xff, 0xff); +break; +} +} -void SvpGraphicsBackend::SetROPFillColor(SalROPColor /*nROPColor*/) {} +void SvpGraphicsBackend::SetROPFillColor(SalROPColor nROPColor) +{ +switch (nROPColor) +{ +case SalROPColor::N0: +m_rCairoCommon.m_aFillColor = Color(0, 0, 0); +break; +case SalROPColor::N1: +m_rCairoCommon.m_aFillColor = Color(0xff, 0xff, 0xff); +break; +case SalROPColor::Invert: +m_rCairoCommon.m_aFillColor = Color(0xff, 0xff, 0xff); +break; +} +} void SvpGraphicsBackend::drawPixel(tools::Long /*nX*/, tools::Long /*nY*/) {} diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index e8e4ec764ac0..af105897efae 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -859,8 +859,8 @@ void SvpSalGraphics::clipRegion(cairo_t* cr) bool SvpSalGraphics::drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency) { -const bool bHasFill(m_aFillColor != SALCOLOR_NONE); -const bool bHasLine(m_aLineColor != SALCOLOR_NONE); +const bool bHasFill(m_aCairoCommon.m_aFillColor != SALCOLOR_NONE); +const bool bHasLine(m_aCairoCommon.m_aLineColor != SALCOLOR_NONE); if(!(bHasFill || bHasLine)) { @@ -879,7 +879,7 @@ bool SvpSalGraphics::drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long n { cairo_rectangle(cr, nX, nY, nWidth, nHeight); -applyColor(cr, m_aFillColor, fTransparency); +applyColor(cr, m_aCairoCommon.m_aFillColor, fTransparency); // set FillDamage extents = getClippedFillDamage(cr); @@ -897,7 +897,7 @@ bool SvpSalGraphics::drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long n cairo_rectangle(cr, nX, nY, nWidth, nHeight); -applyColor(cr, m_aLineColor, fTransparency); +applyColor(cr, m_aCairoCommon.m_aLineColor, fTransparency); // expand with possible StrokeDamage basegfx::B2DRange stroke_extents = getClippedStrokeDamage(cr); @@ -914,9 +914,6 @@ bool SvpSalGraphics::drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long n SvpSalGraphics::SvpSalGraphics() : m_fScale(1.0) -, m_aLineColor(Color(0x00, 0x00, 0x00)) -, m_aFillColor(Color(0xFF, 0xFF, 0XFF)) -, m_ePaintMode(PaintMode::Over) , m_aTextRenderImpl(*this) , m_pBackend(new SvpGraphicsBackend(m_aCairoCommon)) { @@ -942,68 +939,11 @@ void
[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/Library_vcl.mk
vcl/Library_vcl.mk |1 vcl/headless/CairoCommon.cxx | 22 +++ vcl/headless/svpgdi.cxx | 43 ++ vcl/inc/headless/CairoCommon.hxx | 75 +++ vcl/inc/headless/svpgdi.hxx | 41 ++--- 5 files changed, 124 insertions(+), 58 deletions(-) New commits: commit 70a1f26a5ebb839279f1c7d58ffd9f085bfb1f0b Author: Tomaž Vajngerl AuthorDate: Mon Oct 25 16:43:16 2021 +0200 Commit: Tomaž Vajngerl CommitDate: Thu Dec 30 11:46:43 2021 +0100 vcl: Introduce CairoCommon to manage the cairo functions CairoCommon is needed so that SvpSalGraphics and SvpGraphicBackend can both access the same cairo constructs. Currently the common one is the cairo surface. Change-Id: Ia23c30489c9df889a348da5720ee84c82c792374 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127703 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 02eadd06805a..c7c03a52f44f 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -527,6 +527,7 @@ vcl_headless_code= \ vcl/headless/svpbmp \ vcl/headless/svpgdi \ vcl/headless/SvpGraphicsBackend \ +vcl/headless/CairoCommon \ $(if $(ENABLE_HEADLESS),vcl/headless/svpdata) \ ) \ vcl/headless/svpdummies \ diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx new file mode 100644 index ..3db6f14f8417 --- /dev/null +++ b/vcl/headless/CairoCommon.cxx @@ -0,0 +1,22 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 223956076471..1e6a6edf7100 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -913,8 +913,7 @@ bool SvpSalGraphics::drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long n } SvpSalGraphics::SvpSalGraphics() -: m_pSurface(nullptr) -, m_fScale(1.0) +: m_fScale(1.0) , m_aLineColor(Color(0x00, 0x00, 0x00)) , m_aFillColor(Color(0xFF, 0xFF, 0XFF)) , m_ePaintMode(PaintMode::Over) @@ -932,7 +931,7 @@ SvpSalGraphics::~SvpSalGraphics() void SvpSalGraphics::setSurface(cairo_surface_t* pSurface, const basegfx::B2IVector& rSize) { -m_pSurface = pSurface; +m_aCairoCommon.m_pSurface = pSurface; m_aFrameSize = rSize; dl_cairo_surface_get_device_scale(pSurface, _fScale, nullptr); ResetClipRegion(); @@ -945,14 +944,14 @@ void SvpSalGraphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) sal_uInt16 SvpSalGraphics::GetBitCount() const { -if (cairo_surface_get_content(m_pSurface) != CAIRO_CONTENT_COLOR_ALPHA) +if (cairo_surface_get_content(m_aCairoCommon.m_pSurface) != CAIRO_CONTENT_COLOR_ALPHA) return 1; return 32; } tools::Long SvpSalGraphics::GetGraphicsWidth() const { -return m_pSurface ? m_aFrameSize.getX() : 0; +return m_aCairoCommon.m_pSurface ? m_aFrameSize.getX() : 0; } void SvpSalGraphics::ResetClipRegion() @@ -2027,7 +2026,7 @@ bool SvpSalGraphics::implDrawGradient(basegfx::B2DPolyPolygon const & rPolyPolyg void SvpSalGraphics::applyColor(cairo_t *cr, Color aColor, double fTransparency) { -if (cairo_surface_get_content(m_pSurface) == CAIRO_CONTENT_COLOR_ALPHA) +if (cairo_surface_get_content(m_aCairoCommon.m_pSurface) == CAIRO_CONTENT_COLOR_ALPHA) { cairo_set_source_rgba(cr, aColor.GetRed()/255.0, aColor.GetGreen()/255.0, @@ -2117,14 +2116,14 @@ void SvpSalGraphics::copyBits( const SalTwoRect& rTR, SvpSalGraphics* pSrc = pSrcGraphics ? static_cast(pSrcGraphics) : this; -cairo_surface_t* source = pSrc->m_pSurface; +cairo_surface_t* source = pSrc->m_aCairoCommon.m_pSurface; cairo_surface_t *pCopy = nullptr; if (pSrc == this) { //self copy is a problem, so dup source in that case pCopy = cairo_surface_create_similar(source, -