vcl/headless/CairoCommon.cxx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
New commits: commit 3ad1411746a581357920a1ad6366935700719010 Author: Noel Grandin <[email protected]> AuthorDate: Mon Nov 14 13:44:47 2022 +0200 Commit: Noel Grandin <[email protected]> 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 <[email protected]> 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);
