commit 28f6c312a95ba6a2f632c7540b8b69f0f2c0ab02
Author: Guillaume Munch <[email protected]>
Date:   Mon May 23 11:38:48 2016 +0100

    Painter: Add a line style to disable antialiasing
    
    It is not possible to use opacity effects (such as drawing an antialiased 
line
    to strike diagonally through an inset), until the painter is fixed so that 
it
    does not redraw repeatedly over the same spot (otherwise, the usual aritfacs
    appear).
    
    For now, pixellated lines are OK.
---
 src/Changes.cpp                  |   11 ++++++-----
 src/frontends/Painter.h          |    2 ++
 src/frontends/qt4/GuiPainter.cpp |   13 ++++++++-----
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/Changes.cpp b/src/Changes.cpp
index fc05d1c..e9191e3 100644
--- a/src/Changes.cpp
+++ b/src/Changes.cpp
@@ -556,9 +556,9 @@ void Change::paintCue(PainterInfo & pi, double const x1, 
double const y,
                return;
        // Calculate 1/3 height of font
        FontMetrics const & fm = theFontMetrics(font);
-       int const y_bar = int(deleted() ? y - fm.maxAscent() / 3
-               : y + 2 * pi.base.solidLineOffset() + 
pi.base.solidLineThickness());
-       pi.pain.line(int(x1), y_bar, int(x2), y_bar, color(),
+       double const y_bar = deleted() ? y - fm.maxAscent() / 3
+               : y + 2 * pi.base.solidLineOffset() + 
pi.base.solidLineThickness();
+       pi.pain.line(int(x1), int(y_bar), int(x2), int(y_bar), color(),
                     Painter::line_solid, pi.base.solidLineThickness());
 }
 
@@ -586,8 +586,9 @@ void Change::paintCue(PainterInfo & pi, double const x1, 
double const y1,
                y = y1;
                break;
        }
-       pi.pain.line(int(x1), int(y2), int(x2), int(y), 
-                    color(), Painter::line_solid,
+       // we cannot use antialias since we keep drawing on the same background
+       pi.pain.line(int(x1), int(y2), int(x2), int(y),
+                    color(), Painter::line_solid_aliased,
                     pi.base.solidLineThickness());
 }
 
diff --git a/src/frontends/Painter.h b/src/frontends/Painter.h
index b62a4e5..11bd24f 100644
--- a/src/frontends/Painter.h
+++ b/src/frontends/Painter.h
@@ -61,6 +61,8 @@ public:
        /// possible line styles
        enum line_style {
                line_solid, //< solid line
+               line_solid_aliased, //< solid line, no anti-aliasing (used as a
+                                   // workaround to painting issues)
                line_onoffdash //< dashes with spaces
        };
 
diff --git a/src/frontends/qt4/GuiPainter.cpp b/src/frontends/qt4/GuiPainter.cpp
index 2fd2a20..5762c9b 100644
--- a/src/frontends/qt4/GuiPainter.cpp
+++ b/src/frontends/qt4/GuiPainter.cpp
@@ -82,8 +82,11 @@ void GuiPainter::setQPainterPen(QColor const & col,
        pen.setColor(col);
 
        switch (ls) {
-               case line_solid: pen.setStyle(Qt::SolidLine); break;
-               case line_onoffdash: pen.setStyle(Qt::DotLine); break;
+       case line_solid:
+       case line_solid_aliased:
+               pen.setStyle(Qt::SolidLine); break;
+       case line_onoffdash:
+               pen.setStyle(Qt::DotLine); break;
        }
 
        pen.setWidth(lw);
@@ -188,7 +191,7 @@ void GuiPainter::line(int x1, int y1, int x2, int y2,
 
        setQPainterPen(computeColor(col), ls, lw);
        bool const do_antialiasing = renderHints() & TextAntialiasing
-               && x1 != x2 && y1 != y2;
+               && x1 != x2 && y1 != y2 && ls != line_solid_aliased;
        setRenderHint(Antialiasing, do_antialiasing);
        drawLine(x1, y1, x2, y2);
        setRenderHint(Antialiasing, false);
@@ -210,7 +213,7 @@ void GuiPainter::lines(int const * xp, int const * yp, int 
np,
        if (np > points.size())
                points.resize(2 * np);
 
-       bool antialias = false;
+       bool antialias = ls != line_solid_aliased;
        for (int i = 0; i < np; ++i) {
                points[i].setX(xp[i]);
                points[i].setY(yp[i]);
@@ -261,7 +264,7 @@ void GuiPainter::path(int const * xp, int const * yp,
        QColor const color = computeColor(col);
        setQPainterPen(color, ls, lw);
        bool const text_is_antialiased = renderHints() & TextAntialiasing;
-       setRenderHint(Antialiasing, text_is_antialiased);
+       setRenderHint(Antialiasing, text_is_antialiased && ls != 
line_solid_aliased);
        drawPath(bpath);
        if (fs != fill_none)
                fillPath(bpath, QBrush(color));

Reply via email to