From 96860ffe93637bd7698706c3bb85b65bd0d8a979 Mon Sep 17 00:00:00 2001 From: Stefan Schimanski Date: Sat, 19 May 2007 10:52:47 +0000 Subject: [PATCH] * only antialias the whole polyline or no segment at all * Sqrt and Root draw their vertical horizontal line with a single line command to make them showup non-antialiased. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18419 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/QLPainter.cpp | 24 +++++++++++++++--------- src/mathed/InsetMathRoot.cpp | 17 +++++++++-------- src/mathed/InsetMathSqrt.cpp | 15 ++++++++------- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/frontends/qt4/QLPainter.cpp b/src/frontends/qt4/QLPainter.cpp index 9420fc1c5a..45f6b040ae 100644 --- a/src/frontends/qt4/QLPainter.cpp +++ b/src/frontends/qt4/QLPainter.cpp @@ -113,16 +113,22 @@ void QLPainter::lines(int const * xp, int const * yp, int np, { if (!isDrawingEnabled()) return; - - bool const text_is_antialiased = renderHints() & TextAntialiasing; - setQPainterPen(col, ls, lw); - for (int i = 1; i < np; ++i) { - bool const do_antialiasing = text_is_antialiased - && xp[i-1] != xp[i] && yp[i-1] != yp[i]; - setRenderHint(Antialiasing, do_antialiasing); - drawLine(xp[i-1], yp[i-1], xp[i], yp[i]); - setRenderHint(Antialiasing, false); + + // Must use new as np is not known at compile time. + boost::scoped_array points(new QPoint[np]); + + bool antialias = false; + for (int i = 0; i < np; ++i) { + points[i].setX(xp[i]); + points[i].setY(yp[i]); + if (i != 0) + antialias |= xp[i-1] != xp[i] && yp[i-1] != yp[i]; } + setQPainterPen(col, ls, lw); + bool const text_is_antialiased = renderHints() & TextAntialiasing; + setRenderHint(Antialiasing, antialias && text_is_antialiased); + drawPolyline(points.get(), np); + setRenderHint(Antialiasing, false); } diff --git a/src/mathed/InsetMathRoot.cpp b/src/mathed/InsetMathRoot.cpp index fc7d1d5ade..5442fd1be4 100644 --- a/src/mathed/InsetMathRoot.cpp +++ b/src/mathed/InsetMathRoot.cpp @@ -61,14 +61,15 @@ void InsetMathRoot::draw(PainterInfo & pi, int x, int y) const cell(1).draw(pi, x + w + 8, y); int const a = dim_.ascent(); int const d = dim_.descent(); - int xp[5]; - int yp[5]; - xp[0] = x + dim_.width(); yp[0] = y - a + 1; - xp[1] = x + w + 4; yp[1] = y - a + 1; - xp[2] = x + w; yp[2] = y + d; - xp[3] = x + w - 2; yp[3] = y + (d - a)/2 + 2; - xp[4] = x + w - 5; yp[4] = y + (d - a)/2 + 4; - pi.pain.lines(xp, yp, 5, Color::math); + int xp[4]; + int yp[4]; + pi.pain.line(x + dim_.width(), y - a + 1, + x + w + 4, y - a + 1, Color::math); + xp[0] = x + w + 4; yp[0] = y - a + 1; + xp[1] = x + w; yp[1] = y + d; + xp[2] = x + w - 2; yp[2] = y + (d - a)/2 + 2; + xp[3] = x + w - 5; yp[3] = y + (d - a)/2 + 4; + pi.pain.lines(xp, yp, 4, Color::math); drawMarkers(pi, x, y); } diff --git a/src/mathed/InsetMathSqrt.cpp b/src/mathed/InsetMathSqrt.cpp index 95df08bd2b..73cb054306 100644 --- a/src/mathed/InsetMathSqrt.cpp +++ b/src/mathed/InsetMathSqrt.cpp @@ -53,13 +53,14 @@ void InsetMathSqrt::draw(PainterInfo & pi, int x, int y) const cell(0).draw(pi, x + 10, y); int const a = dim_.ascent(); int const d = dim_.descent(); - int xp[4]; - int yp[4]; - xp[0] = x + dim_.width(); yp[0] = y - a + 1; - xp[1] = x + 8; yp[1] = y - a + 1; - xp[2] = x + 5; yp[2] = y + d - 1; - xp[3] = x; yp[3] = y + (d - a)/2; - pi.pain.lines(xp, yp, 4, Color::math); + int xp[3]; + int yp[3]; + pi.pain.line(x + dim_.width(), y - a + 1, + x + 8, y - a + 1, Color::math); + xp[0] = x + 8; yp[0] = y - a + 1; + xp[1] = x + 5; yp[1] = y + d - 1; + xp[2] = x; yp[2] = y + (d - a)/2; + pi.pain.lines(xp, yp, 3, Color::math); drawMarkers(pi, x, y); } -- 2.39.5