diff --git a/CHANGELOG.md b/CHANGELOG.md index 408ca7c92e..bc6e5f5ded 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ - Fix checkerboard drawing on macOS Catalina and later. #614 - Fix undoing "Reset to default" on parameters. #630 - Fix NodeGraph manipulation and navigation issues. #491 #627 -- Fix Retina/High-DPI display issues on macOS (other platforms need to implement Gui::isHighDPI() or getScreenPixelRatio()). +- Fix Retina/High-DPI display issues on macOS and Windows (other platforms need to implement Gui::devicePixelRatio()). - Fix multi-dimensional parameter linking (bug introduced in 2.4.0 #594). #631 ### Plugins @@ -32,7 +32,7 @@ - Updated documentation. #572 #566 #551 #539 #538 #537 #520 #514 - Handle console output on Windows. #524 -- Detect user installed fonts on Windows 10. #523 +- Detect user installed fonts on Windows 10. #523 - New Windows installer. #596 - Improvements to SequenceFileDialog. #565 - Snap timeline alpha cursor to nearest frame. #574 diff --git a/Engine/RotoPaint.cpp b/Engine/RotoPaint.cpp index 04c9556647..290eb16002 100644 --- a/Engine/RotoPaint.cpp +++ b/Engine/RotoPaint.cpp @@ -1687,11 +1687,9 @@ RotoPaint::drawOverlay(double time, glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_LINE_SMOOTH); glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE); - glLineWidth(1.5 * screenPixelRatio); double cpWidth = kControlPointMidSize * 2; - glPointSize(cpWidth * screenPixelRatio); for (std::list::const_iterator it = drawables.begin(); it != drawables.end(); ++it) { if ( !(*it)->isGloballyActivated() ) { continue; @@ -1728,6 +1726,7 @@ RotoPaint::drawOverlay(double time, glColor4dv(curveColor); for (std::list > >::iterator itStroke = strokes.begin(); itStroke != strokes.end(); ++itStroke) { + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINE_STRIP); for (std::list >::const_iterator it2 = itStroke->begin(); it2 != itStroke->end(); ++it2) { glVertex2f(it2->first.x, it2->first.y); @@ -1764,7 +1763,7 @@ RotoPaint::drawOverlay(double time, curveColor[0] = 0.8; curveColor[1] = 0.8; curveColor[2] = 0.8; curveColor[3] = 1.; } glColor4dv(curveColor); - + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINE_STRIP); for (std::list::const_iterator it2 = points.begin(); it2 != points.end(); ++it2) { glVertex2f(it2->x, it2->y); @@ -1793,6 +1792,7 @@ RotoPaint::drawOverlay(double time, if ( !featherPoints.empty() ) { glLineStipple(2, 0xAAAA); glEnable(GL_LINE_STIPPLE); + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINE_STRIP); for (std::list::const_iterator it2 = featherPoints.begin(); it2 != featherPoints.end(); ++it2) { glVertex2f(it2->x, it2->y); @@ -1907,6 +1907,7 @@ RotoPaint::drawOverlay(double time, } } // for(cpIt) + glPointSize(cpWidth * screenPixelRatio); glBegin(GL_POINTS); glVertex2f(x,y); glEnd(); @@ -1937,6 +1938,7 @@ RotoPaint::drawOverlay(double time, } if (drawFeather) { + glPointSize(cpWidth * screenPixelRatio); glBegin(GL_POINTS); glVertex2f(xF, yF); glEnd(); @@ -1961,6 +1963,7 @@ RotoPaint::drawOverlay(double time, ///draw a link between the feather point and the control point. ///Also extend that link of 20 pixels beyond the feather point. + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINE_STRIP); glVertex2f(x, y); glVertex2f(xF, yF); @@ -1993,6 +1996,7 @@ RotoPaint::drawOverlay(double time, glColor4dv(curveColor); } + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINES); glVertex2f(x, y); glVertex2f(featherPoint.x, featherPoint.y); @@ -2066,6 +2070,7 @@ RotoPaint::drawOverlay(double time, if ( ( (_imp->ui->selectedTool == eRotoToolClone) || (_imp->ui->selectedTool == eRotoToolReveal) ) && ( ( _imp->ui->cloneOffset.first != 0) || ( _imp->ui->cloneOffset.second != 0) ) ) { + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINES); if (_imp->ui->state == eEventStateDraggingCloneOffset) { diff --git a/Engine/RotoPaintInteract.cpp b/Engine/RotoPaintInteract.cpp index 7a3262ce9d..ca22bf761f 100644 --- a/Engine/RotoPaintInteract.cpp +++ b/Engine/RotoPaintInteract.cpp @@ -278,7 +278,7 @@ RotoPaintInteract::drawArrow(double centerX, bool hovered, const std::pair & pixelScale) { - GLProtectMatrix p(GL_MODELVIEW); + GLProtectMatrix pm(GL_MODELVIEW); if (hovered) { glColor3f(0., 1., 0.); @@ -295,6 +295,8 @@ RotoPaintInteract::drawArrow(double centerX, QPointF bottom(0., -arrowLenght); QPointF top(0, arrowLenght); ///the arrow head is 4 pixels long and kTransformArrowWidth * 2 large + double screenPixelRatio = p->publicInterface->getCurrentViewportForOverlays()->getScreenPixelRatio(); + glLineWidth(1 * screenPixelRatio); glBegin(GL_LINES); glVertex2f( top.x(), top.y() ); glVertex2f( bottom.x(), bottom.y() ); @@ -377,13 +379,13 @@ RotoPaintInteract::drawSelectedCpsBBOX() QPointF btmRight = selectedCpsBbox.bottomRight(); double screenPixelRatio = p->publicInterface->getCurrentViewportForOverlays()->getScreenPixelRatio(); - glLineWidth(1.5 * screenPixelRatio); if (hoverState == eHoverStateBbox) { glColor4f(0.9, 0.5, 0, 1.); } else { glColor4f(0.8, 0.8, 0.8, 1.); } + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINE_LOOP); glVertex2f( topLeft.x(), btmRight.y() ); glVertex2f( topLeft.x(), topLeft.y() ); @@ -400,6 +402,7 @@ RotoPaintInteract::drawSelectedCpsBBOX() QLineF selectedCpsCrossVertLine; selectedCpsCrossVertLine.setLine(midX, midY - xHairMidSizeY, midX, midY + xHairMidSizeY); + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINES); glVertex2f( std::max( selectedCpsCrossHorizLine.p1().x(), topLeft.x() ), selectedCpsCrossHorizLine.p1().y() ); glVertex2f( std::min( selectedCpsCrossHorizLine.p2().x(), btmRight.x() ), selectedCpsCrossHorizLine.p2().y() ); diff --git a/Engine/TrackerNode.cpp b/Engine/TrackerNode.cpp index eab9bdc14a..4d9f392b8a 100644 --- a/Engine/TrackerNode.cpp +++ b/Engine/TrackerNode.cpp @@ -793,7 +793,6 @@ TrackerNode::drawOverlay(double time, ///Draw a custom interact, indicating the track isn't selected glEnable(GL_LINE_SMOOTH); glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE); - glLineWidth(1.5f * screenPixelRatio); for (int l = 0; l < 2; ++l) { // shadow (uses GL_PROJECTION) @@ -818,6 +817,7 @@ TrackerNode::drawOverlay(double time, glVertex2d(x, y); glEnd(); + glLineWidth(1.5f * screenPixelRatio); glBegin(GL_LINES); glVertex2d(x - CROSS_SIZE * pixelScaleX, y); glVertex2d(x + CROSS_SIZE * pixelScaleX, y); @@ -1002,6 +1002,7 @@ TrackerNode::drawOverlay(double time, ///Draw center position glEnable(GL_LINE_SMOOTH); glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE); + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINE_STRIP); glColor3f(0.5 * l, 0.5 * l, 0.5 * l); for (CenterPointsMap::iterator it = centerPoints.begin(); it != centerPoints.end(); ++it) { @@ -1013,6 +1014,7 @@ TrackerNode::drawOverlay(double time, glDisable(GL_LINE_SMOOTH); glEnable(GL_POINT_SMOOTH); + glPointSize(POINT_SIZE * screenPixelRatio); glBegin(GL_POINTS); if (!showErrorColor) { glColor3f(0.5 * l, 0.5 * l, 0.5 * l); @@ -1046,6 +1048,7 @@ TrackerNode::drawOverlay(double time, glColor3f( (float)thisMarkerColor[0] * l, (float)thisMarkerColor[1] * l, (float)thisMarkerColor[2] * l ); + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINE_LOOP); glVertex2d( topLeft.x(), topLeft.y() ); glVertex2d( topRight.x(), topRight.y() ); @@ -1053,6 +1056,7 @@ TrackerNode::drawOverlay(double time, glVertex2d( btmLeft.x(), btmLeft.y() ); glEnd(); + glLineWidth(1.5f * screenPixelRatio); glBegin(GL_LINE_LOOP); glVertex2d( searchTopLeft.x(), searchTopLeft.y() ); glVertex2d( searchTopRight.x(), searchTopRight.y() ); @@ -1151,6 +1155,7 @@ TrackerNode::drawOverlay(double time, glEnd(); if ( (offset.x() != 0) || (offset.y() != 0) ) { + glLineWidth(1.5f * screenPixelRatio); glBegin(GL_LINES); glColor3f( (float)thisMarkerColor[0] * l * 0.5, (float)thisMarkerColor[1] * l * 0.5, (float)thisMarkerColor[2] * l * 0.5 ); glVertex2d( center.x(), center.y() ); @@ -1159,6 +1164,7 @@ TrackerNode::drawOverlay(double time, } ///now show small lines at handle positions + glLineWidth(1.5f * screenPixelRatio); glBegin(GL_LINES); if ( isHoverOrDraggedMarker && ( (_imp->ui->hoverState == eDrawStateHoveringInnerMidLeft) || (_imp->ui->eventState == eMouseStateDraggingInnerMidLeft) ) ) { @@ -1266,6 +1272,7 @@ TrackerNode::drawOverlay(double time, glColor4d(0., 1., 0., 0.8); } + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINE_LOOP); glVertex2d(_imp->ui->lastMousePos.x() - addTrackSize * 2 * pixelScaleX, _imp->ui->lastMousePos.y() - addTrackSize * 2 * pixelScaleY); glVertex2d(_imp->ui->lastMousePos.x() - addTrackSize * 2 * pixelScaleX, _imp->ui->lastMousePos.y() + addTrackSize * 2 * pixelScaleY); @@ -1274,6 +1281,7 @@ TrackerNode::drawOverlay(double time, glEnd(); ///draw a cross at the cursor position + glLineWidth(1.5f * screenPixelRatio); glBegin(GL_LINES); glVertex2d( _imp->ui->lastMousePos.x() - addTrackSize * pixelScaleX, _imp->ui->lastMousePos.y() ); glVertex2d( _imp->ui->lastMousePos.x() + addTrackSize * pixelScaleX, _imp->ui->lastMousePos.y() ); diff --git a/Engine/TrackerNodeInteract.cpp b/Engine/TrackerNodeInteract.cpp index 6e9162ca5e..63d3548b7e 100644 --- a/Engine/TrackerNodeInteract.cpp +++ b/Engine/TrackerNodeInteract.cpp @@ -809,8 +809,8 @@ TrackerNodeInteract::drawSelectedMarkerKeyframes(const std::pair } } - glLineWidth(1.5 * screenPixelRatio); glCheckError(); + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINE_LOOP); glVertex2d(textureRectCanonical.x1, textureRectCanonical.y1); glVertex2d(textureRectCanonical.x1, textureRectCanonical.y2); @@ -832,6 +832,7 @@ TrackerNodeInteract::drawSelectedMarkerKeyframes(const std::pair glColor4f(0.8 * l, 0.8 * l, 0.8 * l, 1); + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINE_LOOP); glVertex2d(innerTopLeft.x, innerTopLeft.y); glVertex2d(innerTopRight.x, innerTopRight.y); @@ -839,6 +840,7 @@ TrackerNodeInteract::drawSelectedMarkerKeyframes(const std::pair glVertex2d(innerBtmLeft.x, innerBtmLeft.y); glEnd(); + glPointSize(POINT_SIZE * screenPixelRatio); glBegin(GL_POINTS); glVertex2d(centerPointCanonical.x, centerPointCanonical.y); glEnd(); @@ -950,7 +952,6 @@ TrackerNodeInteract::drawSelectedMarkerTexture(const std::pair& glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(1., 1., 1., 0.5); glLineWidth(1.5 * screenPixelRatio); - glCheckError(); glBegin(GL_LINE_LOOP); glVertex2d(textureRectCanonical.x1, textureRectCanonical.y1); glVertex2d(textureRectCanonical.x1, textureRectCanonical.y2); @@ -980,7 +981,7 @@ TrackerNodeInteract::drawSelectedMarkerTexture(const std::pair& glMatrixMode(GL_MODELVIEW); glColor4f(0.8 * l, 0.8 * l, 0.8 * l, 1); - + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINE_LOOP); glVertex2d(innerTopLeft.x, innerTopLeft.y); glVertex2d(innerTopRight.x, innerTopRight.y); @@ -988,6 +989,7 @@ TrackerNodeInteract::drawSelectedMarkerTexture(const std::pair& glVertex2d(innerBtmLeft.x, innerBtmLeft.y); glEnd(); + glPointSize(POINT_SIZE * screenPixelRatio); glBegin(GL_POINTS); glVertex2d(centerPoint.x, centerPoint.y); glEnd(); diff --git a/Gui/CurveGui.cpp b/Gui/CurveGui.cpp index 66450f34e0..bdf381fa87 100644 --- a/Gui/CurveGui.cpp +++ b/Gui/CurveGui.cpp @@ -289,7 +289,8 @@ drawLineStrip(const std::vector& vertices, void CurveGui::drawCurve(int curveIndex, - int curvesCount) + int curvesCount, + double screenPixelRatio) { // always running in the main thread assert( qApp && qApp->thread() == QThread::currentThread() ); @@ -324,7 +325,6 @@ CurveGui::drawCurve(int curveIndex, hasDrawnExpr = true; } } - double screenPixelRatio = _curveWidget->getScreenPixelRatio(); bool isPeriodic = false; std::pair parametricRange = std::make_pair(-std::numeric_limits::infinity(), std::numeric_limits::infinity()); if (isBezier) { @@ -388,6 +388,7 @@ CurveGui::drawCurve(int curveIndex, QColor minMaxColor; minMaxColor.setRgbF(0.398979, 0.398979, 0.398979); glColor4d(minMaxColor.redF(), minMaxColor.greenF(), minMaxColor.blueF(), 1.); + glLineWidth(1.5f * screenPixelRatio); glBegin(GL_LINES); glVertex2d(btmLeft.x(), curveYRange.min); glVertex2d(topRight.x(), curveYRange.min); @@ -444,7 +445,6 @@ CurveGui::drawCurve(int curveIndex, glColor4f( curveColor.redF(), curveColor.greenF(), curveColor.blueF(), curveColor.alphaF() ); //draw keyframes - glPointSize(7.f * screenPixelRatio); glEnable(GL_POINT_SMOOTH); const SelectedKeys & selectedKeyFrames = _curveWidget->getSelectedKeyFrames(); @@ -483,6 +483,7 @@ CurveGui::drawCurve(int curveIndex, double x = key.getTime(); double y = key.getValue(); + glPointSize(7.f * screenPixelRatio); glBegin(GL_POINTS); glVertex2f(x, y); glEnd(); @@ -497,6 +498,7 @@ CurveGui::drawCurve(int curveIndex, glLineStipple(2, 0xAAAA); glEnable(GL_LINE_STIPPLE); } + glLineWidth(1.5f * screenPixelRatio); glBegin(GL_LINES); glColor4f(1., 0.35, 0.35, 1.); glVertex2f( isSelected->leftTan.first, isSelected->leftTan.second ); @@ -538,6 +540,7 @@ CurveGui::drawCurve(int curveIndex, _curveWidget->renderText( x, _curveWidget->toZoomCoordinates(0, yWidgetCoord).y(), coordStr, QColor(240, 240, 240), _curveWidget->getFont() ); } + glPointSize(7.f * screenPixelRatio); glBegin(GL_POINTS); glVertex2f( isSelected->leftTan.first, isSelected->leftTan.second ); glVertex2f( isSelected->rightTan.first, isSelected->rightTan.second ); diff --git a/Gui/CurveGui.h b/Gui/CurveGui.h index d828c4ffaa..9f6bde9207 100644 --- a/Gui/CurveGui.h +++ b/Gui/CurveGui.h @@ -124,7 +124,7 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON virtual double evaluate(bool useExpr, double x) const = 0; virtual CurvePtr getInternalCurve() const; - void drawCurve(int curveIndex, int curvesCount); + void drawCurve(int curveIndex, int curvesCount, double screenPixelRatio); virtual Curve::YRange getCurveYRange() const; virtual bool areKeyFramesTimeClampedToIntegers() const; diff --git a/Gui/CurveWidget.cpp b/Gui/CurveWidget.cpp index 36491b13a5..033a6e5039 100644 --- a/Gui/CurveWidget.cpp +++ b/Gui/CurveWidget.cpp @@ -474,7 +474,7 @@ CurveWidget::getScreenPixelRatio() const #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) return windowHandle()->devicePixelRatio() #else - return _imp->_gui->isHighDPI() ? 2. : 1.; + return _imp->_gui ? _imp->_gui->devicePixelRatio() : 1.; #endif } #endif @@ -619,6 +619,8 @@ CurveWidget::paintGL() double bgR, bgG, bgB; appPTR->getCurrentSettings()->getCurveEditorBGColor(&bgR, &bgG, &bgB); + double screenPixelRatio = getScreenPixelRatio(); + if ( (zoomLeft == zoomRight) || (zoomTop == zoomBottom) ) { glClearColor(bgR, bgG, bgB, 1.); glClear(GL_COLOR_BUFFER_BIT); @@ -656,22 +658,22 @@ CurveWidget::paintGL() glCheckErrorIgnoreOSXBug(); } - _imp->drawScale(); + _imp->drawScale(screenPixelRatio); if (_imp->_timelineEnabled) { - _imp->drawTimelineMarkers(); + _imp->drawTimelineMarkers(screenPixelRatio); } if (_imp->_drawSelectedKeyFramesBbox) { - _imp->drawSelectedKeyFramesBbox(); + _imp->drawSelectedKeyFramesBbox(screenPixelRatio); } - _imp->drawCurves(); + _imp->drawCurves(screenPixelRatio); if ( !_imp->_selectionRectangle.isNull() ) { - _imp->drawSelectionRectangle(); + _imp->drawSelectionRectangle(screenPixelRatio); } } // GLProtectAttrib a(GL_TRANSFORM_BIT | GL_COLOR_BUFFER_BIT); glCheckError(); diff --git a/Gui/CurveWidgetPrivate.cpp b/Gui/CurveWidgetPrivate.cpp index fdef773ad5..0aac0ae3eb 100644 --- a/Gui/CurveWidgetPrivate.cpp +++ b/Gui/CurveWidgetPrivate.cpp @@ -285,12 +285,11 @@ CurveWidgetPrivate::createMenu() } // createMenu void -CurveWidgetPrivate::drawSelectionRectangle() +CurveWidgetPrivate::drawSelectionRectangle(double screenPixelRatio) { // always running in the main thread assert( qApp && qApp->thread() == QThread::currentThread() ); assert( QGLContext::currentContext() == _widget->context() ); - double screenPixelRatio = _widget->getScreenPixelRatio(); { GLProtectAttrib a(GL_HINT_BIT | GL_ENABLE_BIT | GL_LINE_BIT | GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT); @@ -360,7 +359,7 @@ CurveWidgetPrivate::refreshTimelinePositions() } void -CurveWidgetPrivate::drawTimelineMarkers() +CurveWidgetPrivate::drawTimelineMarkers(double screenPixelRatio) { // always running in the main thread assert( qApp && qApp->thread() == QThread::currentThread() ); @@ -389,6 +388,7 @@ CurveWidgetPrivate::drawTimelineMarkers() double leftBound, rightBound; _gui->getApp()->getFrameRange(&leftBound, &rightBound); + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINES); glVertex2f( leftBound, btmRight.y() ); glVertex2f( leftBound, topLeft.y() ); @@ -422,7 +422,7 @@ CurveWidgetPrivate::drawTimelineMarkers() } // CurveWidgetPrivate::drawTimelineMarkers void -CurveWidgetPrivate::drawCurves() +CurveWidgetPrivate::drawCurves(double screenPixelRatio) { // always running in the main thread assert( qApp && qApp->thread() == QThread::currentThread() ); @@ -434,12 +434,12 @@ CurveWidgetPrivate::drawCurves() int count = (int)visibleCurves.size(); for (int i = 0; i < count; ++i) { - visibleCurves[i]->drawCurve(i, count); + visibleCurves[i]->drawCurve(i, count, screenPixelRatio); } } void -CurveWidgetPrivate::drawScale() +CurveWidgetPrivate::drawScale(double screenPixelRatio) { glCheckError(); // always running in the main thread @@ -470,7 +470,6 @@ CurveWidgetPrivate::drawScale() Image::clamp(scaleG, 0., 1.), Image::clamp(scaleB, 0., 1.) ); - { GLProtectAttrib a(GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT); @@ -503,6 +502,7 @@ CurveWidgetPrivate::drawScale() glCheckError(); glColor4f(gridR, gridG, gridB, alpha); + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINES); if (axis == 0) { glVertex2f( value, btmLeft.y() ); // AXIS-SPECIFIC @@ -543,6 +543,7 @@ CurveWidgetPrivate::drawScale() glCheckError(); glColor4f(gridR, gridG, gridB, 1.); + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINES); glVertex2f(AXIS_MIN, 0); glVertex2f(AXIS_MAX, 0); @@ -555,12 +556,11 @@ CurveWidgetPrivate::drawScale() } // drawScale void -CurveWidgetPrivate::drawSelectedKeyFramesBbox() +CurveWidgetPrivate::drawSelectedKeyFramesBbox(double screenPixelRatio) { // always running in the main thread assert( qApp && qApp->thread() == QThread::currentThread() ); assert( QGLContext::currentContext() == _widget->context() ); - double screenPixelRatio = _widget->getScreenPixelRatio(); { GLProtectAttrib a(GL_HINT_BIT | GL_ENABLE_BIT | GL_LINE_BIT | GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT); @@ -577,9 +577,8 @@ CurveWidgetPrivate::drawSelectedKeyFramesBbox() double xMid = ( topLeft.x() + btmRight.x() ) / 2.; double yMid = ( topLeft.y() + btmRight.y() ) / 2.; - glLineWidth(1.5 * screenPixelRatio); - glColor4f(0.5, 0.5, 0.5, 1.); + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINE_LOOP); glVertex2f( topLeft.x(), btmRight.y() ); glVertex2f( topLeft.x(), topLeft.y() ); @@ -588,6 +587,7 @@ CurveWidgetPrivate::drawSelectedKeyFramesBbox() glEnd(); + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINES); glVertex2f( std::max( _selectedKeyFramesCrossHorizLine.p1().x(), topLeft.x() ), _selectedKeyFramesCrossHorizLine.p1().y() ); glVertex2f( std::min( _selectedKeyFramesCrossHorizLine.p2().x(), btmRight.x() ), _selectedKeyFramesCrossHorizLine.p2().y() ); diff --git a/Gui/CurveWidgetPrivate.h b/Gui/CurveWidgetPrivate.h index ca6472ce4a..46854e0c28 100644 --- a/Gui/CurveWidgetPrivate.h +++ b/Gui/CurveWidgetPrivate.h @@ -85,16 +85,16 @@ class CurveWidgetPrivate ~CurveWidgetPrivate(); - void drawSelectionRectangle(); + void drawSelectionRectangle(double screenPixelRatio); void refreshTimelinePositions(); - void drawTimelineMarkers(); + void drawTimelineMarkers(double screenPixelRatio); - void drawCurves(); + void drawCurves(double screenPixelRatio); - void drawScale(); - void drawSelectedKeyFramesBbox(); + void drawScale(double screenPixelRatio); + void drawSelectedKeyFramesBbox(double screenPixelRatio); /** * @brief Returns whether the click at position pt is nearby the curve. diff --git a/Gui/CustomParamInteract.cpp b/Gui/CustomParamInteract.cpp index 57bc61debf..9a9ccfd824 100644 --- a/Gui/CustomParamInteract.cpp +++ b/Gui/CustomParamInteract.cpp @@ -200,7 +200,7 @@ CustomParamInteract::getScreenPixelRatio() const return windowHandle()->devicePixelRatio() #else KnobGuiPtr k = _imp->knob.lock(); - return (k && k->getGui()->isHighDPI()) ? 2. : 1.; + return (k && k->getGui()) ? k->getGui()->devicePixelRatio() : 1.; #endif } #endif diff --git a/Gui/DopeSheetView.cpp b/Gui/DopeSheetView.cpp index 0ee628bd4d..0203c58ac1 100644 --- a/Gui/DopeSheetView.cpp +++ b/Gui/DopeSheetView.cpp @@ -886,6 +886,8 @@ DopeSheetViewPrivate::drawScale() const Image::clamp(scaleG, 0., 1.), Image::clamp(scaleB, 0., 1.) ); + double screenPixelRatio = q_ptr->getScreenPixelRatio(); + // Perform drawing { GLProtectAttrib a(GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT); @@ -929,6 +931,7 @@ DopeSheetViewPrivate::drawScale() const glColor4f(scaleColor.redF(), scaleColor.greenF(), scaleColor.blueF(), alpha); // Draw the vertical lines belonging to the grid + glLineWidth(1. * screenPixelRatio); glBegin(GL_LINES); glVertex2f( value, bottomLeft.y() ); glVertex2f( value, topRight.y() ); @@ -1113,7 +1116,7 @@ DopeSheetViewPrivate::drawNodeRowSeparation(const DSNodePtr dsNode) const double screenPixelRatio = q_ptr->getScreenPixelRatio(); glLineWidth(appPTR->getCurrentSettings()->getDopeSheetEditorNodeSeparationWith() * screenPixelRatio); glColor4f(0.f, 0.f, 0.f, 1.f); - + glLineWidth(1. * screenPixelRatio); glBegin(GL_LINES); glVertex2f( rowRect.left(), rowRect.top() ); glVertex2f( rowRect.right(), rowRect.top() ); @@ -1177,7 +1180,7 @@ DopeSheetViewPrivate::drawRange(const DSNodePtr &dsNode) const glLineWidth(2 * screenPixelRatio); glColor4f(fillColor.redF(), fillColor.greenF(), fillColor.blueF(), 1.f); - + glLineWidth(1. * screenPixelRatio); glBegin(GL_LINES); //horizontal line @@ -1212,6 +1215,7 @@ DopeSheetViewPrivate::drawRange(const DSNodePtr &dsNode) const if (isSelected) { glColor4f(fillColor.redF(), fillColor.greenF(), fillColor.blueF(), 1.f); + glLineWidth(1. * screenPixelRatio); glBegin(GL_LINE_LOOP); glVertex2f( clipRectZoomCoords.left(), clipRectZoomCoords.top() ); glVertex2f( clipRectZoomCoords.left(), clipRectZoomCoords.bottom() ); @@ -1502,6 +1506,8 @@ DopeSheetViewPrivate::drawProjectBounds() const double colorR, colorG, colorB; settings->getTimelineBoundsColor(&colorR, &colorG, &colorB); + double screenPixelRatio = q_ptr->getScreenPixelRatio(); + // Perform drawing { GLProtectAttrib a(GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT); @@ -1509,12 +1515,14 @@ DopeSheetViewPrivate::drawProjectBounds() const glColor4f(colorR, colorG, colorB, 1.f); // Draw start bound + glLineWidth(1. * screenPixelRatio); glBegin(GL_LINES); glVertex2f(projectStart, top); glVertex2f(projectStart, bottom); glEnd(); // Draw end bound + glLineWidth(1. * screenPixelRatio); glBegin(GL_LINES); glVertex2f(projectEnd, top); glVertex2f(projectEnd, bottom); @@ -1544,6 +1552,8 @@ DopeSheetViewPrivate::drawCurrentFrameIndicator() double colorR, colorG, colorB; settings->getTimelinePlayheadColor(&colorR, &colorG, &colorB); + double screenPixelRatio = q_ptr->getScreenPixelRatio(); + // Perform drawing { GLProtectAttrib a(GL_CURRENT_BIT | GL_HINT_BIT | GL_ENABLE_BIT | @@ -1556,7 +1566,7 @@ DopeSheetViewPrivate::drawCurrentFrameIndicator() glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE); glColor4f(colorR, colorG, colorB, 1.f); - + glLineWidth(1. * screenPixelRatio); glBegin(GL_LINES); glVertex2f(currentFrame, top); glVertex2f(currentFrame, bottom); @@ -1615,6 +1625,7 @@ DopeSheetViewPrivate::drawSelectionRect() const // Draw outline glColor4f(0.5, 0.5, 0.5, 1.); + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINE_LOOP); glVertex2f(selectionRect.x1, selectionRect.y1); glVertex2f(selectionRect.x1, selectionRect.y2); @@ -1646,11 +1657,9 @@ DopeSheetViewPrivate::drawSelectedKeysBRect() const glEnable(GL_LINE_SMOOTH); glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE); - glLineWidth(1.5 * screenPixelRatio); - - glColor4f(0.5, 0.5, 0.5, 1.); - // Draw outline + glColor4f(0.5, 0.5, 0.5, 1.); + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINE_LOOP); glVertex2f( selectedKeysBRect.left(), selectedKeysBRect.bottom() ); glVertex2f( selectedKeysBRect.left(), selectedKeysBRect.top() ); @@ -1667,6 +1676,7 @@ DopeSheetViewPrivate::drawSelectedKeysBRect() const QLineF verticalLine( zoomContext.toZoomCoordinates(bRectCenterWidgetCoords.x(), bRectCenterWidgetCoords.y() - CROSS_LINE_OFFSET), zoomContext.toZoomCoordinates(bRectCenterWidgetCoords.x(), bRectCenterWidgetCoords.y() + CROSS_LINE_OFFSET) ); + glLineWidth(1. * screenPixelRatio); glBegin(GL_LINES); glVertex2f( horizontalLine.p1().x(), horizontalLine.p1().y() ); glVertex2f( horizontalLine.p2().x(), horizontalLine.p2().y() ); @@ -2712,9 +2722,9 @@ double DopeSheetView::getScreenPixelRatio() const { #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) - return windowHandle()->devicePixelRatio() + return windowHandle()->devicePixelRatio(); #else - return _imp->gui->isHighDPI() ? 2. : 1.; + return _imp->gui ? _imp->gui->devicePixelRatio() : 1.; #endif } #endif diff --git a/Gui/Gui.h b/Gui/Gui.h index 59be86acd8..a792424d7f 100644 --- a/Gui/Gui.h +++ b/Gui/Gui.h @@ -489,15 +489,11 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON virtual void ddeOpenFile(const QString& filePath) OVERRIDE FINAL; #endif +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) /** - * @brief Returns true on OS X if on a High DPI (Retina) Display. + * @brief Returns 1.0 on a 96 DPI screen, and 2.0 on a Retina Display. **/ -#ifndef Q_OS_MAC - bool isHighDPI() const { return false; } - -#else - bool isHighDPI() const { return QtMac::isHighDPIInternal(this); } - + qreal devicePixelRatio() const; #endif AppInstancePtr createNewProject(); diff --git a/Gui/Gui50.cpp b/Gui/Gui50.cpp index c9051adf44..0bf9592347 100644 --- a/Gui/Gui50.cpp +++ b/Gui/Gui50.cpp @@ -62,6 +62,9 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON #include #include #include +#ifdef Q_WS_X11 +#include +#endif #include "Global/QtCompat.h" @@ -104,6 +107,12 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON #include "Gui/PropertiesBinWrapper.h" #include "Gui/Histogram.h" +#if defined(Q_WS_WIN32) +#include +#include +#endif + + NATRON_NAMESPACE_ENTER @@ -360,7 +369,7 @@ Gui::handleNativeKeys(int key, return key; } -#ifdef Q_WS_MAC +#ifdef Q_WS_MACX // OS X virtual key codes, from // MacOSX10.11.sdk/System/Library/Frameworks/Carbon.framework/Frameworks/HIToolbox.framework/Headers/Events.h // kVK_ANSI_1 = 0x12, @@ -407,7 +416,7 @@ Gui::handleNativeKeys(int key, return Qt::Key_0; } #endif -#ifdef Q_WS_WIN +#ifdef Q_WS_WIN32 // https://msdn.microsoft.com/en-us/library/aa299374%28v=vs.60%29.aspx // 48 0x30 (VK_0) | 0 key // 49 0x31 (VK_1) | 1 key @@ -1057,6 +1066,34 @@ Gui::ddeOpenFile(const QString& filePath) #endif +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +/** + * @brief Returns 1.0 on a 96 DPI screen, and 2.0 on a Retina Display. + **/ +qreal Gui::devicePixelRatio() const +{ +#if defined(Q_WS_WIN32) + HDC screen = GetDC(winId()); + FLOAT horizontalDPI = GetDeviceCaps(screen, LOGPIXELSX); + ReleaseDC(0, screen); + + return static_cast(horizontalDPI) / 96.; +#elif defined(Q_WS_MACX) + return QtMac::devicePixelRatioInternal(this); +#elif defined(Q_WS_X11) + // Use the Xft.dpi X resource, as described there: + // - https://github.com/glfw/glfw/blob/84f95a7d7fa454ca99efcdd49da89472294b16bf/src/x11_init.c#L971 + // - https://wiki.archlinux.org/title/HiDPI#X_Resources + + // QX11Info uses it to set appDpiX() and appDpiY(), see the code: + // - https://github.com/qt/qt/blob/0a2f2382541424726168804be2c90b91381608c6/src/gui/kernel/qapplication_x11.cpp#L2203 + + return x11Info().appDpiX(x11Info().appScreen()) / 96.; +#else + return 1.; +#endif +} +#endif bool Gui::isFocusStealingPossible() diff --git a/Gui/GuiFwd.h b/Gui/GuiFwd.h index ebc3dd5e26..a2e224b95e 100644 --- a/Gui/GuiFwd.h +++ b/Gui/GuiFwd.h @@ -31,6 +31,7 @@ #include "Engine/EngineFwd.h" // Qt +#include class QAbstractButton; class QAction; @@ -228,14 +229,18 @@ class ViewerGL; class ViewerTab; class ViewerToolButton; class KnobPageGui; + +#ifdef Q_WS_MACX //Implementation in Gui/QtMac.mm namespace QtMac { -bool isHighDPIInternal(const QWidget* w); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +qreal devicePixelRatioInternal(const QWidget* w); +#endif #if OBJC_OLD_DISPATCH_PROTOTYPES != 1 void setupDockClickHandler(void (*)(void)); #endif - } +#endif NATRON_PYTHON_NAMESPACE_ENTER class GuiApp; diff --git a/Gui/Histogram.cpp b/Gui/Histogram.cpp index bd5edb5271..c378b9bb3e 100644 --- a/Gui/Histogram.cpp +++ b/Gui/Histogram.cpp @@ -1547,9 +1547,9 @@ double Histogram::getScreenPixelRatio() const { #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) - return windowHandle()->devicePixelRatio() + return windowHandle()->devicePixelRatio(); #else - return getGui()->isHighDPI() ? 2. : 1.; + return getGui() ? getGui()->devicePixelRatio() : 1.; #endif } @@ -1573,6 +1573,7 @@ HistogramPrivate::drawScale() QFontMetrics fontM(_font); const double smallestTickSizePixel = 5.; // tick size (in pixels) for alpha = 0. const double largestTickSizePixel = 1000.; // tick size (in pixels) for alpha = 1. + double screenPixelRatio = widget->getScreenPixelRatio(); { @@ -1606,6 +1607,7 @@ HistogramPrivate::drawScale() glColor4f(_baseAxisColor.redF(), _baseAxisColor.greenF(), _baseAxisColor.blueF(), alpha); + glLineWidth(1. * screenPixelRatio); glBegin(GL_LINES); if (axis == 0) { glVertex2f( value, btmLeft.y() ); // AXIS-SPECIFIC @@ -1701,8 +1703,6 @@ HistogramPrivate::drawViewerPicker() // always running in the main thread double screenPixelRatio = widget->getScreenPixelRatio(); - glLineWidth(2. * screenPixelRatio); - assert( qApp && qApp->thread() == QThread::currentThread() ); assert( QGLContext::currentContext() == widget->context() ); @@ -1721,36 +1721,42 @@ HistogramPrivate::drawViewerPicker() if (mode == Histogram::eDisplayModeY) { glColor3f(0.398979, 0.398979, 0.398979); double luminance = 0.299 * imgColor[0] + 0.587 * imgColor[1] + 0.114 * imgColor[2]; + glLineWidth(2. * screenPixelRatio); glBegin(GL_LINES); glVertex2d( luminance, topLeft.y() ); glVertex2d( luminance, btmRight.y() ); glEnd(); } else if (mode == Histogram::eDisplayModeR) { glColor3f(0.398979, 0.398979, 0.398979); + glLineWidth(2. * screenPixelRatio); glBegin(GL_LINES); glVertex2d( imgColor[0], topLeft.y() ); glVertex2d( imgColor[0], btmRight.y() ); glEnd(); } else if (mode == Histogram::eDisplayModeG) { glColor3f(0.398979, 0.398979, 0.398979); + glLineWidth(2. * screenPixelRatio); glBegin(GL_LINES); glVertex2d( imgColor[1], topLeft.y() ); glVertex2d( imgColor[1], btmRight.y() ); glEnd(); } else if (mode == Histogram::eDisplayModeB) { glColor3f(0.398979, 0.398979, 0.398979); + glLineWidth(2. * screenPixelRatio); glBegin(GL_LINES); glVertex2d( imgColor[2], topLeft.y() ); glVertex2d( imgColor[2], btmRight.y() ); glEnd(); } else if (mode == Histogram::eDisplayModeA) { glColor3f(0.398979, 0.398979, 0.398979); + glLineWidth(2. * screenPixelRatio); glBegin(GL_LINES); glVertex2d( imgColor[3], topLeft.y() ); glVertex2d( imgColor[3], btmRight.y() ); glEnd(); } else if (mode == Histogram::eDisplayModeRGB) { glColor3f(0.851643, 0.196936, 0.196936); + glLineWidth(2. * screenPixelRatio); glBegin(GL_LINES); glVertex2d( imgColor[0], topLeft.y() ); glVertex2d( imgColor[0], btmRight.y() ); @@ -1917,6 +1923,7 @@ HistogramPrivate::drawHistogramCPU() // always running in the main thread assert( qApp && qApp->thread() == QThread::currentThread() ); assert( QGLContext::currentContext() == widget->context() ); + double screenPixelRatio = widget->getScreenPixelRatio(); glCheckError(); { @@ -1930,6 +1937,7 @@ HistogramPrivate::drawHistogramCPU() double binSize = (vmax - vmin) / binsCount; + glLineWidth(1. * screenPixelRatio); glBegin(GL_LINES); for (unsigned int i = 0; i < binsCount; ++i) { double binMinX = vmin + i * binSize; diff --git a/Gui/HostOverlay.cpp b/Gui/HostOverlay.cpp index e47c8c9ea7..534738a79c 100644 --- a/Gui/HostOverlay.cpp +++ b/Gui/HostOverlay.cpp @@ -969,7 +969,6 @@ PositionInteract::draw(double time, pos.setY(p[1]); } //glPushAttrib(GL_ALL_ATTRIB_BITS); // caller is responsible for protecting attribs - glPointSize(pointSize() * screenPixelRatio); // Draw everything twice // l = 0: shadow // l = 1: drawing @@ -989,6 +988,7 @@ PositionInteract::draw(double time, const double darken = 0.5; glColor3f(pR * l * darken, pG * l * darken, pB * l * darken); + glPointSize(pointSize() * screenPixelRatio); glBegin(GL_POINTS); for (int i=0; i < numKeys; ++i) { double time = p->getKeyTime(i); @@ -998,6 +998,7 @@ PositionInteract::draw(double time, } glEnd(); + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINE_STRIP); double time = p->getKeyTime(0); for (int i = 1; i < numKeys; ++i) { @@ -1015,6 +1016,7 @@ PositionInteract::draw(double time, #endif glColor3f(pR * l, pG * l, pB * l); + glPointSize(pointSize() * screenPixelRatio); glBegin(GL_POINTS); glVertex2d( pos.x(), pos.y() ); glEnd(); @@ -1569,10 +1571,8 @@ CornerPinInteract::draw(double time, //glEnable(GL_POINT_SMOOTH); glEnable(GL_BLEND); glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE); - glLineWidth(1.5f * screenPixelRatio); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glPointSize(CornerPinInteract::pointSize() * screenPixelRatio); // Draw everything twice // l = 0: shadow // l = 1: drawing @@ -1585,6 +1585,7 @@ CornerPinInteract::draw(double time, glMatrixMode(GL_MODELVIEW); // Modelview should be used on Nuke glColor3f( (float)(color.r / 2) * l, (float)(color.g / 2) * l, (float)(color.b / 2) * l ); + glLineWidth(1.5f * screenPixelRatio); glBegin(GL_LINES); for (int i = enableBegin; i < enableEnd; ++i) { if (enable[i]) { @@ -1594,6 +1595,7 @@ CornerPinInteract::draw(double time, } glEnd(); glColor3f( (float)color.r * l, (float)color.g * l, (float)color.b * l ); + glLineWidth(1.5f * screenPixelRatio); glBegin(GL_LINE_LOOP); for (int i = enableBegin; i < enableEnd; ++i) { if (enable[i]) { @@ -1601,6 +1603,8 @@ CornerPinInteract::draw(double time, } } glEnd(); + + glPointSize(CornerPinInteract::pointSize() * screenPixelRatio); glBegin(GL_POINTS); for (int i = enableBegin; i < enableEnd; ++i) { if (enable[i]) { diff --git a/Gui/QtMac.mm b/Gui/QtMac.mm index f359e604fd..c2f5547510 100644 --- a/Gui/QtMac.mm +++ b/Gui/QtMac.mm @@ -88,15 +88,17 @@ - (NSRect)convertRectFromBacking:(NSRect)aRect; NATRON_NAMESPACE_ENTER -bool -QtMac::isHighDPIInternal(const QWidget* w) { - NSView* view = reinterpret_cast(w->winId()); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +qreal +QtMac::devicePixelRatioInternal(const QWidget* w) { CGFloat scaleFactor = 1.0; + NSView* view = reinterpret_cast(w->winId()); if ([[view window] respondsToSelector: @selector(backingScaleFactor)]) scaleFactor = [[view window] backingScaleFactor]; - - return (scaleFactor > 1.0); + + return qreal(scaleFactor); } +#endif #if OBJC_OLD_DISPATCH_PROTOTYPES != 1 void diff --git a/Gui/TabWidget.cpp b/Gui/TabWidget.cpp index 14195c0d5d..2dc0a8b7db 100644 --- a/Gui/TabWidget.cpp +++ b/Gui/TabWidget.cpp @@ -1538,12 +1538,12 @@ TabBar::makePixmapForDrag(int index) QImage tabBarImg = tabBarPixmap.toImage(); QImage currentTabImg = currentTabPixmap.toImage(); -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#if defined(Q_WS_MACX) && (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) ///Prevent a bug with grabWidget and retina display on Qt4 - bool isHighDPI = _tabWidget->getGui()->isHighDPI(); - if (isHighDPI) { - tabBarImg = tabBarImg.scaled(tabBarImg.width() / 2., tabBarImg.height() / 2.); - currentTabImg = currentTabImg.scaled(currentTabImg.width() / 2., currentTabImg.height() / 2.); + qreal devicePixelRatio = _tabWidget->getGui()->devicePixelRatio(); + if (devicePixelRatio > 1) { + tabBarImg = tabBarImg.scaled(tabBarImg.width() / devicePixelRatio, tabBarImg.height() / devicePixelRatio); + currentTabImg = currentTabImg.scaled(currentTabImg.width() / devicePixelRatio, currentTabImg.height() / devicePixelRatio); } #endif diff --git a/Gui/TimeLineGui.cpp b/Gui/TimeLineGui.cpp index c81295780b..bf3e8b218a 100644 --- a/Gui/TimeLineGui.cpp +++ b/Gui/TimeLineGui.cpp @@ -486,6 +486,7 @@ TimeLineGui::paintGL() glColor4f(txtR / 2., txtG / 2., txtB / 2., 1.); + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINES); glVertex2f(btmLeft.x(), lineYpos); glVertex2f(topRight.x(), lineYpos); @@ -533,7 +534,7 @@ TimeLineGui::paintGL() continue; } glColor4f(txtR, txtG, txtB, alpha); - + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINES); glVertex2f(value, tickBottom); glVertex2f(value, tickTop); @@ -739,7 +740,6 @@ TimeLineGui::paintGL() glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE); glCheckError(); glLineWidth(2 * screenPixelRatio); - glCheckError(); glBegin(GL_LINES); for (CachedFrames::const_iterator i = _imp->cachedFrames.begin(); i != _imp->cachedFrames.end(); ++i) { if ( ( i->time >= btmLeft.x() ) && ( i->time <= topRight.x() ) ) { @@ -755,6 +755,7 @@ TimeLineGui::paintGL() glEnd(); ///now draw keyframes + glLineWidth(2 * screenPixelRatio); glBegin(GL_LINES); glColor4f(kfR, kfG, kfB, 1.); std::list remainingUserKeys; diff --git a/Gui/ViewerGL.cpp b/Gui/ViewerGL.cpp index 9fff360e2f..545ac0af81 100644 --- a/Gui/ViewerGL.cpp +++ b/Gui/ViewerGL.cpp @@ -579,14 +579,13 @@ ViewerGL::drawOverlay(unsigned int mipMapLevel) glCheckError(); + double screenPixelRatio = getScreenPixelRatio(); { GLProtectAttrib a(GL_COLOR_BUFFER_BIT | GL_LINE_BIT | GL_CURRENT_BIT | GL_ENABLE_BIT); glDisable(GL_BLEND); - - - + glLineWidth(1. * screenPixelRatio); int activeInputs[2]; getInternalNode()->getActiveInputs(activeInputs[0], activeInputs[1]); @@ -607,6 +606,7 @@ ViewerGL::drawOverlay(unsigned int mipMapLevel) QPoint btmLeft( canonicalFormat.left(), canonicalFormat.bottom() ); QPoint btmRight( canonicalFormat.right(), canonicalFormat.bottom() ); + glLineWidth(1. * screenPixelRatio); glBegin(GL_LINES); glColor4f( _imp->displayWindowOverlayColor.redF(), @@ -648,6 +648,7 @@ ViewerGL::drawOverlay(unsigned int mipMapLevel) QPointF btmRight2( dataW.right(), dataW.bottom() ); glLineStipple(2, 0xAAAA); glEnable(GL_LINE_STIPPLE); + glLineWidth(1. * screenPixelRatio); glBegin(GL_LINES); glColor4f( _imp->rodOverlayColor.redF(), _imp->rodOverlayColor.greenF(), @@ -676,12 +677,12 @@ ViewerGL::drawOverlay(unsigned int mipMapLevel) userRoIEnabled = _imp->userRoIEnabled; } if (userRoIEnabled) { - drawUserRoI(); + drawUserRoI(screenPixelRatio); } ViewerCompositingOperatorEnum compOperator = _imp->viewerTab->getCompositingOperator(); if ( operatorIsWipe(compOperator) ) { - drawWipeControl(); + drawWipeControl(screenPixelRatio); } @@ -698,9 +699,9 @@ ViewerGL::drawOverlay(unsigned int mipMapLevel) glCheckErrorIgnoreOSXBug(); if (_imp->pickerState == ePickerStateRectangle) { - drawPickerRectangle(); + drawPickerRectangle(screenPixelRatio); } else if (_imp->pickerState == ePickerStatePoint) { - drawPickerPixel(); + drawPickerPixel(screenPixelRatio); } } // GLProtectAttrib a(GL_COLOR_BUFFER_BIT | GL_LINE_BIT | GL_CURRENT_BIT | GL_ENABLE_BIT); glCheckError(); @@ -711,7 +712,7 @@ ViewerGL::drawOverlay(unsigned int mipMapLevel) } // drawOverlay void -ViewerGL::drawUserRoI() +ViewerGL::drawUserRoI(double screenPixelRatio) { // always running in the main thread assert( qApp && qApp->thread() == QThread::currentThread() ); @@ -746,6 +747,7 @@ ViewerGL::drawUserRoI() } ///base rect + glLineWidth(1. * screenPixelRatio); glBegin(GL_LINE_LOOP); glVertex2f(userRoI.x1, userRoI.y1); //bottom left glVertex2f(userRoI.x1, userRoI.y2); //top left @@ -753,7 +755,7 @@ ViewerGL::drawUserRoI() glVertex2f(userRoI.x2, userRoI.y1); //bottom right glEnd(); - + glLineWidth(1. * screenPixelRatio); glBegin(GL_LINES); ///border ticks double borderTickWidth = USER_ROI_BORDER_TICK_SIZE * zoomScreenPixelWidth; @@ -851,9 +853,8 @@ ViewerGL::drawUserRoI() } // drawUserRoI void -ViewerGL::drawWipeControl() +ViewerGL::drawWipeControl(double screenPixelRatio) { - double screenPixelRatio = getScreenPixelRatio(); double wipeAngle; QPointF wipeCenter; double mixAmount; @@ -943,7 +944,6 @@ ViewerGL::drawWipeControl() glVertex2d( wipeCenter.x(), wipeCenter.y() ); glVertex2d( mixPos.x(), mixPos.y() ); glEnd(); - glLineWidth(1. * screenPixelRatio); ///if hovering the rotate handle or dragging it show a small bended arrow if ( (_imp->hs == eHoverStateWipeRotateHandle) || (_imp->ms == eMouseStateRotatingWipeHandle) ) { @@ -961,13 +961,14 @@ ViewerGL::drawWipeControl() // center the oval at x_center, y_center glTranslatef (arrowCenterX, 0., 0); // draw the oval using line segments + glLineWidth(1. * screenPixelRatio); glBegin (GL_LINE_STRIP); glVertex2f (0, arrowRadius.y); glVertex2f (arrowRadius.x, 0.); glVertex2f (0, -arrowRadius.y); glEnd (); - + glLineWidth(1. * screenPixelRatio); glBegin(GL_LINES); ///draw the top head glVertex2f(0., arrowRadius.y); @@ -988,8 +989,8 @@ ViewerGL::drawWipeControl() glColor4f(baseColor[0], baseColor[1], baseColor[2], 1.); } - glPointSize(5. * screenPixelRatio); glEnable(GL_POINT_SMOOTH); + glPointSize(5. * screenPixelRatio); glBegin(GL_POINTS); glVertex2d( wipeCenter.x(), wipeCenter.y() ); if ( ( (_imp->hs == eHoverStateWipeMix) && @@ -1007,7 +1008,7 @@ ViewerGL::drawWipeControl() } // drawWipeControl void -ViewerGL::drawPickerRectangle() +ViewerGL::drawPickerRectangle(double screenPixelRatio) { { GLProtectAttrib a(GL_CURRENT_BIT); @@ -1016,6 +1017,7 @@ ViewerGL::drawPickerRectangle() QPointF topLeft = _imp->pickerRect.topLeft(); QPointF btmRight = _imp->pickerRect.bottomRight(); ///base rect + glLineWidth(1.5 * screenPixelRatio); glBegin(GL_LINE_LOOP); glVertex2f( topLeft.x(), btmRight.y() ); //bottom left glVertex2f( topLeft.x(), topLeft.y() ); //top left @@ -1026,19 +1028,18 @@ ViewerGL::drawPickerRectangle() } void -ViewerGL::drawPickerPixel() +ViewerGL::drawPickerPixel(double screenPixelRatio) { - double screenPixelRatio = getScreenPixelRatio(); - { GLProtectAttrib a(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_POINT_BIT | GL_COLOR_BUFFER_BIT); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_POINT_SMOOTH); + double zoomFactor; { QMutexLocker l(&_imp->zoomCtxMutex); - glPointSize(1. * _imp->zoomCtx.factor() * screenPixelRatio); + zoomFactor = _imp->zoomCtx.factor(); } QPointF pos = _imp->lastPickerPos; @@ -1048,6 +1049,7 @@ ViewerGL::drawPickerPixel() pos *= (1 << mipMapLevel); } glColor3f(0.9, 0.7, 0.); + glPointSize(zoomFactor * screenPixelRatio); glBegin(GL_POINTS); glVertex2d( pos.x(), pos.y() ); glEnd(); @@ -3632,7 +3634,7 @@ ViewerGL::getScreenPixelRatio() const #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) return windowHandle()->devicePixelRatio() #else - return _imp->viewerTab->getGui()->isHighDPI() ? 2. : 1.; + return (_imp->viewerTab && _imp->viewerTab->getGui()) ? _imp->viewerTab->getGui()->devicePixelRatio() : 1.; #endif } #endif diff --git a/Gui/ViewerGL.h b/Gui/ViewerGL.h index e506adaa92..7881ef0217 100644 --- a/Gui/ViewerGL.h +++ b/Gui/ViewerGL.h @@ -571,13 +571,13 @@ public Q_SLOTS: /** * @brief Called by drawOverlay to draw the user region of interest. **/ - void drawUserRoI(); + void drawUserRoI(double screenPixelRatio); - void drawPickerRectangle(); + void drawPickerRectangle(double screenPixelRatio); - void drawPickerPixel(); + void drawPickerPixel(double screenPixelRatio); - void drawWipeControl(); + void drawWipeControl(double screenPixelRatio); /** *@brief Draws the persistent message if it is on. diff --git a/Gui/ViewerGLPrivate.cpp b/Gui/ViewerGLPrivate.cpp index 5816f5bf32..e820a67371 100644 --- a/Gui/ViewerGLPrivate.cpp +++ b/Gui/ViewerGLPrivate.cpp @@ -719,7 +719,6 @@ ViewerGL::Implementation::drawSelectionRectangle() glLineWidth(1.5 * screenPixelRatio); - glBegin(GL_LINE_LOOP); glVertex2f( topLeft.x(), btmRight.y() ); glVertex2f( topLeft.x(), topLeft.y() );