diff --git a/src/core/maprenderer/qgsmaprendererjob.cpp b/src/core/maprenderer/qgsmaprendererjob.cpp index 1b4e01357244..0939965cdbf0 100644 --- a/src/core/maprenderer/qgsmaprendererjob.cpp +++ b/src/core/maprenderer/qgsmaprendererjob.cpp @@ -878,6 +878,12 @@ std::vector< LayerRenderJob > QgsMapRendererJob::prepareSecondPassJobs( std::vec { PictureAndPainter pictureAndPainter = allocatePictureAndPainter( job.context() ); job.picture = std::move( pictureAndPainter.first ); + if ( job.context()->painter()->hasClipping() ) + { + // need to copy clipping paths from original painter, so that e.g. the layout map bounds clipping path is respected + pictureAndPainter.second->setClipping( true ); + pictureAndPainter.second->setClipPath( job.context()->painter()->clipPath() ); + } job.context()->setPainter( pictureAndPainter.second ); // force recreation of layer renderer so it initialize correctly the renderer // especially the RasterLayerRender that need logicalDpiX from painting device @@ -955,6 +961,12 @@ std::vector< LayerRenderJob > QgsMapRendererJob::prepareSecondPassJobs( std::vec else { PictureAndPainter pictureAndPainter = allocatePictureAndPainter( job2.context() ); + if ( job.context()->painter()->hasClipping() ) + { + // need to copy clipping paths from original painter, so that e.g. the layout map bounds clipping path is respected + pictureAndPainter.second->setClipping( true ); + pictureAndPainter.second->setClipPath( job.context()->painter()->clipPath() ); + } job2.picture = std::move( pictureAndPainter.first ); job2.context()->setPainter( pictureAndPainter.second ); } diff --git a/tests/testdata/control_images/selective_masking/layout_export/layout_export.png b/tests/testdata/control_images/selective_masking/layout_export/layout_export.png index da6baa2afc42..3af54e253f36 100644 Binary files a/tests/testdata/control_images/selective_masking/layout_export/layout_export.png and b/tests/testdata/control_images/selective_masking/layout_export/layout_export.png differ diff --git a/tests/testdata/control_images/selective_masking/layout_export/layout_export_mask.png b/tests/testdata/control_images/selective_masking/layout_export/layout_export_mask.png deleted file mode 100644 index 19bae4092352..000000000000 Binary files a/tests/testdata/control_images/selective_masking/layout_export/layout_export_mask.png and /dev/null differ diff --git a/tests/testdata/control_images/selective_masking/layout_export_2_sources_masking/layout_export_2_sources_masking.png b/tests/testdata/control_images/selective_masking/layout_export_2_sources_masking/layout_export_2_sources_masking.png index 59e699208780..1446756fc24f 100644 Binary files a/tests/testdata/control_images/selective_masking/layout_export_2_sources_masking/layout_export_2_sources_masking.png and b/tests/testdata/control_images/selective_masking/layout_export_2_sources_masking/layout_export_2_sources_masking.png differ diff --git a/tests/testdata/control_images/selective_masking/layout_export_2_sources_masking/layout_export_2_sources_masking_mask.png b/tests/testdata/control_images/selective_masking/layout_export_2_sources_masking/layout_export_2_sources_masking_mask.png deleted file mode 100644 index 3bd9d9c2ea56..000000000000 Binary files a/tests/testdata/control_images/selective_masking/layout_export_2_sources_masking/layout_export_2_sources_masking_mask.png and /dev/null differ diff --git a/tests/testdata/control_images/selective_masking/layout_export_force_raster_render/layout_export_force_raster_render.png b/tests/testdata/control_images/selective_masking/layout_export_force_raster_render/layout_export_force_raster_render.png index 7d5807a588b9..30fa05beb72b 100644 Binary files a/tests/testdata/control_images/selective_masking/layout_export_force_raster_render/layout_export_force_raster_render.png and b/tests/testdata/control_images/selective_masking/layout_export_force_raster_render/layout_export_force_raster_render.png differ diff --git a/tests/testdata/control_images/selective_masking/layout_export_force_raster_render/layout_export_force_raster_render_mask.png b/tests/testdata/control_images/selective_masking/layout_export_force_raster_render/layout_export_force_raster_render_mask.png deleted file mode 100644 index ba4ed65a2044..000000000000 Binary files a/tests/testdata/control_images/selective_masking/layout_export_force_raster_render/layout_export_force_raster_render_mask.png and /dev/null differ diff --git a/tests/testdata/control_images/selective_masking/layout_export_marker_masking/layout_export_marker_masking.png b/tests/testdata/control_images/selective_masking/layout_export_marker_masking/layout_export_marker_masking.png index e37e04089985..4e87df40925f 100644 Binary files a/tests/testdata/control_images/selective_masking/layout_export_marker_masking/layout_export_marker_masking.png and b/tests/testdata/control_images/selective_masking/layout_export_marker_masking/layout_export_marker_masking.png differ diff --git a/tests/testdata/control_images/selective_masking/layout_export_marker_masking/layout_export_marker_masking_mask.png b/tests/testdata/control_images/selective_masking/layout_export_marker_masking/layout_export_marker_masking_mask.png deleted file mode 100644 index 987381ec264b..000000000000 Binary files a/tests/testdata/control_images/selective_masking/layout_export_marker_masking/layout_export_marker_masking_mask.png and /dev/null differ diff --git a/tests/testdata/control_images/selective_masking/layout_export_svg_marker_masking/layout_export_svg_marker_masking.png b/tests/testdata/control_images/selective_masking/layout_export_svg_marker_masking/layout_export_svg_marker_masking.png index 18075ca47d73..4063eeac8bda 100644 Binary files a/tests/testdata/control_images/selective_masking/layout_export_svg_marker_masking/layout_export_svg_marker_masking.png and b/tests/testdata/control_images/selective_masking/layout_export_svg_marker_masking/layout_export_svg_marker_masking.png differ diff --git a/tests/testdata/control_images/selective_masking/layout_export_svg_marker_masking/layout_export_svg_marker_masking_mask.png b/tests/testdata/control_images/selective_masking/layout_export_svg_marker_masking/layout_export_svg_marker_masking_mask.png deleted file mode 100644 index 43f2ed23de07..000000000000 Binary files a/tests/testdata/control_images/selective_masking/layout_export_svg_marker_masking/layout_export_svg_marker_masking_mask.png and /dev/null differ diff --git a/tests/testdata/control_images/selective_masking/layout_export_w_raster/layout_export_w_raster_mask.png b/tests/testdata/control_images/selective_masking/layout_export_w_raster/layout_export_w_raster_mask.png index b4c8531e9e3d..989cfddb2bf8 100644 Binary files a/tests/testdata/control_images/selective_masking/layout_export_w_raster/layout_export_w_raster_mask.png and b/tests/testdata/control_images/selective_masking/layout_export_w_raster/layout_export_w_raster_mask.png differ