diff options
author | Caolán McNamara <caolanm@redhat.com> | 2023-01-10 09:17:00 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2023-01-10 19:56:09 +0000 |
commit | 0774025e1a280d3833e340f6a368a3692cdca2c5 (patch) | |
tree | 98ab4243954ed3ab04b0518f413d1a8af75120f8 /vcl/headless | |
parent | 129d4ee902cdc9890c172eb7b91d52b7300ad1e0 (diff) |
cairo_surface_map_to_image giving poor results under gen
for some unknown reason
Change-Id: I6a44b739b7126465e9cf54e31ad4b362badea85d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145254
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/headless')
-rw-r--r-- | vcl/headless/CairoCommon.cxx | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index f347cf47f930..fb25d6a2c391 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -479,7 +479,20 @@ void CairoCommon::doXorOnRelease(sal_Int32 nExtentsLeft, sal_Int32 nExtentsTop, { //in the unlikely case we can't use m_pSurface directly, copy contents //to another temp image surface - target_surface = cairo_surface_map_to_image(target_surface, nullptr); + if (cairo_surface_get_content(m_pSurface) == CAIRO_CONTENT_COLOR_ALPHA) + target_surface = cairo_surface_map_to_image(target_surface, nullptr); + else + { + // for gen, which is CAIRO_FORMAT_RGB24/CAIRO_CONTENT_COLOR I'm getting + // visual corruption in vcldemo with cairo_surface_map_to_image + cairo_t* copycr = createTmpCompatibleCairoContext(); + cairo_rectangle(copycr, nExtentsLeft, nExtentsTop, nExtentsRight - nExtentsLeft, + nExtentsBottom - nExtentsTop); + cairo_set_source_surface(copycr, m_pSurface, 0, 0); + cairo_fill(copycr); + target_surface = cairo_get_target(copycr); + cairo_destroy(copycr); + } } cairo_surface_flush(target_surface); @@ -549,7 +562,19 @@ void CairoCommon::doXorOnRelease(sal_Int32 nExtentsLeft, sal_Int32 nExtentsTop, if (target_surface != m_pSurface) { - cairo_surface_unmap_image(m_pSurface, target_surface); + if (cairo_surface_get_content(m_pSurface) == CAIRO_CONTENT_COLOR_ALPHA) + cairo_surface_unmap_image(m_pSurface, target_surface); + else + { + cairo_t* copycr = cairo_create(m_pSurface); + //copy contents back from image surface + cairo_rectangle(copycr, nExtentsLeft, nExtentsTop, nExtentsRight - nExtentsLeft, + nExtentsBottom - nExtentsTop); + cairo_set_source_surface(copycr, target_surface, 0, 0); + cairo_fill(copycr); + cairo_destroy(copycr); + cairo_surface_destroy(target_surface); + } } cairo_surface_destroy(surface); |