[poppler] splash/Splash.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Nov 16 08:06:47 UTC 2020


 splash/Splash.cc |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit db5f849ab74798f3a0481d506331ef3244862314
Author: Tobias Deiminger <haxtibal at posteo.de>
Date:   Sun Nov 15 13:08:56 2020 +0100

    Splash: Fix wrong x adjustment during clipping
    
    If a line segment goes beyond the current clip region, Splash::strokeNarrow
    tries to cut off the segment line to the intersection of the segment line
    with the clip border.
    
    Therefore it has to calculate a new endpoint (=intersection point) of the
    segment. It does this by using the known segment slope dxdy.
    
    Required information (segment start, segment slope, clip border) is known
    in double precision. However the calculation used the integerized clip
    border, which necessarily suffers from rounding errors. This error can
    become very visible when we have a high dxdy (i.e, a flat-angle line).
    
    Use SplashClip::getYMin and SplashClip::getYMax instead of getYMinI and getYMaxI,
    and we get visibly correct results.
    
    Fixes #990.

diff --git a/splash/Splash.cc b/splash/Splash.cc
index 584e65c7..11393ce7 100644
--- a/splash/Splash.cc
+++ b/splash/Splash.cc
@@ -1971,11 +1971,11 @@ void Splash::strokeNarrow(SplashPath *path)
                 dxdy = seg->dxdy;
                 if (y0 < state->clip->getYMinI()) {
                     y0 = state->clip->getYMinI();
-                    x0 = splashFloor(seg->x0 + ((SplashCoord)y0 - seg->y0) * dxdy);
+                    x0 = splashFloor(seg->x0 + (state->clip->getYMin() - seg->y0) * dxdy);
                 }
                 if (y1 > state->clip->getYMaxI()) {
                     y1 = state->clip->getYMaxI();
-                    x1 = splashFloor(seg->x0 + ((SplashCoord)y1 - seg->y0) * dxdy);
+                    x1 = splashFloor(seg->x0 + (state->clip->getYMax() - seg->y0) * dxdy);
                 }
                 if (x0 <= x1) {
                     xa = x0;


More information about the poppler mailing list