summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordldld <LibreOfficeContribution@dldld.de>2022-05-14 17:54:35 +0200
committerCaolán McNamara <caolanm@redhat.com>2022-05-14 20:00:56 +0200
commit20f0ab23b1c0b60ca36a053464f3ba41bf27c80e (patch)
tree48f84663ad2575b353632534e82ec627ae76d215
parent86050db1b0c15651335d1b0bf89ee8f6409dee1d (diff)
tdf#133716: Fix edge gradient when upscaling image
When an image is getting upscaled with cario as engine it got blured borders. The issue that was worked on showed, in the PresenterConsole, that the borders of the previews and control area had an unnecessary gradient in it. As these borders are build from images which are getting upscaled, either in width or height a graident ocurred. This was because the cairo rending didn't had the correct pattern extention set: CAIRO_EXTEND_PAD. Nearly same issue also occured when adding an image to a presentation and upscaling it, the borders got blured. For images with either height or width equal to one this was a while back fixed: tdf#114117, but not for the general case. Using another extend mode fixes this, because the PAD extend mode doesn't blur the borders. CAIRO_EXTEND_PAD: pixels outside of the pattern copy the closest pixel from the source Change-Id: I39f8a14a69f035a43a93afb303f0a2e7ec8699c7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134325 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/headless/CairoCommon.cxx11
-rw-r--r--vcl/headless/SvpGraphicsBackend.cxx28
2 files changed, 17 insertions, 22 deletions
diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx
index 73a6b72f802e..9897334d4532 100644
--- a/vcl/headless/CairoCommon.cxx
+++ b/vcl/headless/CairoCommon.cxx
@@ -876,12 +876,11 @@ basegfx::B2DRange renderWithOperator(cairo_t* cr, const SalTwoRect& rTR, cairo_s
cairo_save(cr);
cairo_set_source_surface(cr, source, -rTR.mnSrcX, -rTR.mnSrcY);
- if ((fXScale != 1.0 && rTR.mnSrcWidth == 1) || (fYScale != 1.0 && rTR.mnSrcHeight == 1))
- {
- cairo_pattern_t* sourcepattern = cairo_get_source(cr);
- cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_REPEAT);
- cairo_pattern_set_filter(sourcepattern, CAIRO_FILTER_NEAREST);
- }
+
+ //tdf#133716 borders of upscaled images should not be blured
+ cairo_pattern_t* sourcepattern = cairo_get_source(cr);
+ cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_PAD);
+
cairo_set_operator(cr, eOperator);
cairo_paint(cr);
cairo_restore(cr);
diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx
index 14a9a017ed94..0566f444013d 100644
--- a/vcl/headless/SvpGraphicsBackend.cxx
+++ b/vcl/headless/SvpGraphicsBackend.cxx
@@ -488,12 +488,11 @@ void SvpGraphicsBackend::drawMask(const SalTwoRect& rTR, const SalBitmap& rSalBi
double fYScale = static_cast<double>(rTR.mnDestHeight) / rTR.mnSrcHeight;
cairo_scale(cr, fXScale, fYScale);
cairo_set_source_surface(cr, aSurface.getSurface(), -rTR.mnSrcX, -rTR.mnSrcY);
- if ((fXScale != 1.0 && rTR.mnSrcWidth == 1) || (fYScale != 1.0 && rTR.mnSrcHeight == 1))
- {
- cairo_pattern_t* sourcepattern = cairo_get_source(cr);
- cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_REPEAT);
- cairo_pattern_set_filter(sourcepattern, CAIRO_FILTER_NEAREST);
- }
+
+ //tdf#133716 borders of upscaled images should not be blured
+ cairo_pattern_t* sourcepattern = cairo_get_source(cr);
+ cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_PAD);
+
cairo_paint(cr);
m_rCairoCommon.releaseCairoContext(cr, false, extents);
@@ -674,16 +673,13 @@ bool SvpGraphicsBackend::drawAlphaBitmap(const SalTwoRect& rTR, const SalBitmap&
cairo_scale(cr, fXScale, fYScale);
cairo_set_source_surface(cr, source, -rTR.mnSrcX, -rTR.mnSrcY);
- //tdf#114117 when stretching a single pixel width/height source to fit an area
- //set extend and filter to stretch it with simplest expected interpolation
- if ((fXScale != 1.0 && rTR.mnSrcWidth == 1) || (fYScale != 1.0 && rTR.mnSrcHeight == 1))
- {
- cairo_pattern_t* sourcepattern = cairo_get_source(cr);
- cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_REPEAT);
- cairo_pattern_set_filter(sourcepattern, CAIRO_FILTER_NEAREST);
- cairo_pattern_set_extend(maskpattern, CAIRO_EXTEND_REPEAT);
- cairo_pattern_set_filter(maskpattern, CAIRO_FILTER_NEAREST);
- }
+ cairo_pattern_t* sourcepattern = cairo_get_source(cr);
+
+ //tdf#133716 borders of upscaled images should not be blured
+ //tdf#114117 when stretching a single or multi pixel width/height source to fit an area
+ //the image will be extended into that size.
+ cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_PAD);
+ cairo_pattern_set_extend(maskpattern, CAIRO_EXTEND_PAD);
//this block is just "cairo_mask_surface", but we have to make it explicit
//because of the cairo_pattern_set_filter etc we may want applied