vcl/headless/SvpGraphicsBackend.cxx | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
New commits: commit b5c039a58dde8992c41f7d7e22cf393a15e1033e Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Sun Aug 21 20:14:20 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> 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 <noel.gran...@collabora.co.uk> 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;