diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-10-02 17:23:59 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-10-03 09:29:42 +0200 |
commit | fc5cd82fa5bb85495e34a762fdf1db91b5e93d12 (patch) | |
tree | 25c9e1303322140454c646b19c63949abe81e73e /vcl | |
parent | 89367021a4c960b6873370ea9472b36457c51ef3 (diff) |
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 <caolan.mcnamara@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/headless/CairoCommon.cxx | 15 |
1 files changed, 13 insertions, 2 deletions
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<Color>& rFillColor, + const std::optional<Color>& 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)); |