From: Ryan Govostes Date: Tue, 19 Mar 2019 23:30:24 +0000 (-0400) Subject: Disable antialiasing on high-DPI displays X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=633e8ade5289eff00c7137f59269361aa547449a;p=pulseview.git Disable antialiasing on high-DPI displays --- diff --git a/pv/views/trace/analogsignal.cpp b/pv/views/trace/analogsignal.cpp index d9b72add..59924641 100644 --- a/pv/views/trace/analogsignal.cpp +++ b/pv/views/trace/analogsignal.cpp @@ -319,6 +319,7 @@ void AnalogSignal::paint_fore(QPainter &p, ViewItemPaintParams &pp) void AnalogSignal::paint_grid(QPainter &p, int y, int left, int right) { + bool wasAntialiased = p.testRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::Antialiasing, false); if (pos_vdivs_ > 0) { @@ -363,7 +364,7 @@ void AnalogSignal::paint_grid(QPainter &p, int y, int left, int right) } } - p.setRenderHint(QPainter::Antialiasing, true); + p.setRenderHint(QPainter::Antialiasing, wasAntialiased); } void AnalogSignal::paint_trace(QPainter &p, diff --git a/pv/views/trace/trace.cpp b/pv/views/trace/trace.cpp index d7e02bca..65abaf0c 100644 --- a/pv/views/trace/trace.cpp +++ b/pv/views/trace/trace.cpp @@ -292,12 +292,13 @@ void Trace::paint_back(QPainter &p, ViewItemPaintParams &pp) void Trace::paint_axis(QPainter &p, ViewItemPaintParams &pp, int y) { + bool wasAntialiased = p.testRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::Antialiasing, false); p.setPen(axis_pen_); p.drawLine(QPointF(pp.left(), y), QPointF(pp.right(), y)); - p.setRenderHint(QPainter::Antialiasing, true); + p.setRenderHint(QPainter::Antialiasing, wasAntialiased); } void Trace::add_color_option(QWidget *parent, QFormLayout *form) @@ -328,10 +329,11 @@ void Trace::paint_hover_marker(QPainter &p) const pair extents = v_extents(); + bool wasAntialiased = p.testRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::Antialiasing, false); p.drawLine(x, get_visual_y() + extents.first, x, get_visual_y() + extents.second); - p.setRenderHint(QPainter::Antialiasing, true); + p.setRenderHint(QPainter::Antialiasing, wasAntialiased); } void Trace::create_popup_form() diff --git a/pv/views/trace/viewport.cpp b/pv/views/trace/viewport.cpp index 83abb7b6..44c912a1 100644 --- a/pv/views/trace/viewport.cpp +++ b/pv/views/trace/viewport.cpp @@ -30,6 +30,8 @@ #include #include +#include +#include #include @@ -172,7 +174,10 @@ void Viewport::paintEvent(QPaintEvent*) [](const shared_ptr &t) { return !t; })); QPainter p(this); - p.setRenderHint(QPainter::Antialiasing); + + bool useAntialiasing = + window()->windowHandle()->screen()->devicePixelRatio() < 2.0; + p.setRenderHint(QPainter::Antialiasing, useAntialiasing); for (LayerPaintFunc *paint_func = layer_paint_funcs; *paint_func; paint_func++) {