Skip to content

Commit

Permalink
Merge 4184149 into 7e9644a
Browse files Browse the repository at this point in the history
  • Loading branch information
devernay committed Jun 14, 2021
2 parents 7e9644a + 4184149 commit 7cc25b0
Show file tree
Hide file tree
Showing 23 changed files with 188 additions and 101 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Expand Up @@ -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
Expand All @@ -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
Expand Down
11 changes: 8 additions & 3 deletions Engine/RotoPaint.cpp
Expand Up @@ -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<RotoDrawableItemPtr>::const_iterator it = drawables.begin(); it != drawables.end(); ++it) {
if ( !(*it)->isGloballyActivated() ) {
continue;
Expand Down Expand Up @@ -1728,6 +1726,7 @@ RotoPaint::drawOverlay(double time,
glColor4dv(curveColor);

for (std::list<std::list<std::pair<Point, double> > >::iterator itStroke = strokes.begin(); itStroke != strokes.end(); ++itStroke) {
glLineWidth(1.5 * screenPixelRatio);
glBegin(GL_LINE_STRIP);
for (std::list<std::pair<Point, double> >::const_iterator it2 = itStroke->begin(); it2 != itStroke->end(); ++it2) {
glVertex2f(it2->first.x, it2->first.y);
Expand Down Expand Up @@ -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<ParametricPoint >::const_iterator it2 = points.begin(); it2 != points.end(); ++it2) {
glVertex2f(it2->x, it2->y);
Expand Down Expand Up @@ -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<ParametricPoint >::const_iterator it2 = featherPoints.begin(); it2 != featherPoints.end(); ++it2) {
glVertex2f(it2->x, it2->y);
Expand Down Expand Up @@ -1907,6 +1907,7 @@ RotoPaint::drawOverlay(double time,
}
} // for(cpIt)

glPointSize(cpWidth * screenPixelRatio);
glBegin(GL_POINTS);
glVertex2f(x,y);
glEnd();
Expand Down Expand Up @@ -1937,6 +1938,7 @@ RotoPaint::drawOverlay(double time,
}

if (drawFeather) {
glPointSize(cpWidth * screenPixelRatio);
glBegin(GL_POINTS);
glVertex2f(xF, yF);
glEnd();
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 5 additions & 2 deletions Engine/RotoPaintInteract.cpp
Expand Up @@ -278,7 +278,7 @@ RotoPaintInteract::drawArrow(double centerX,
bool hovered,
const std::pair<double, double> & pixelScale)
{
GLProtectMatrix p(GL_MODELVIEW);
GLProtectMatrix pm(GL_MODELVIEW);

if (hovered) {
glColor3f(0., 1., 0.);
Expand All @@ -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() );
Expand Down Expand Up @@ -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() );
Expand All @@ -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() );
Expand Down
10 changes: 9 additions & 1 deletion Engine/TrackerNode.cpp
Expand Up @@ -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)
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down Expand Up @@ -1046,13 +1048,15 @@ 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() );
glVertex2d( btmRight.x(), btmRight.y() );
glVertex2d( btmLeft.x(), btmLeft.y() );
glEnd();

glLineWidth(1.5f * screenPixelRatio);
glBegin(GL_LINE_LOOP);
glVertex2d( searchTopLeft.x(), searchTopLeft.y() );
glVertex2d( searchTopRight.x(), searchTopRight.y() );
Expand Down Expand Up @@ -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() );
Expand All @@ -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) ) ) {
Expand Down Expand Up @@ -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);
Expand All @@ -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() );
Expand Down
8 changes: 5 additions & 3 deletions Engine/TrackerNodeInteract.cpp
Expand Up @@ -809,8 +809,8 @@ TrackerNodeInteract::drawSelectedMarkerKeyframes(const std::pair<double, double>
}
}

glLineWidth(1.5 * screenPixelRatio);
glCheckError();
glLineWidth(1.5 * screenPixelRatio);
glBegin(GL_LINE_LOOP);
glVertex2d(textureRectCanonical.x1, textureRectCanonical.y1);
glVertex2d(textureRectCanonical.x1, textureRectCanonical.y2);
Expand All @@ -832,13 +832,15 @@ TrackerNodeInteract::drawSelectedMarkerKeyframes(const std::pair<double, double>

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);
glVertex2d(innerBtmRight.x, innerBtmRight.y);
glVertex2d(innerBtmLeft.x, innerBtmLeft.y);
glEnd();

glPointSize(POINT_SIZE * screenPixelRatio);
glBegin(GL_POINTS);
glVertex2d(centerPointCanonical.x, centerPointCanonical.y);
glEnd();
Expand Down Expand Up @@ -950,7 +952,6 @@ TrackerNodeInteract::drawSelectedMarkerTexture(const std::pair<double, double>&
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);
Expand Down Expand Up @@ -980,14 +981,15 @@ TrackerNodeInteract::drawSelectedMarkerTexture(const std::pair<double, double>&
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);
glVertex2d(innerBtmRight.x, innerBtmRight.y);
glVertex2d(innerBtmLeft.x, innerBtmLeft.y);
glEnd();

glPointSize(POINT_SIZE * screenPixelRatio);
glBegin(GL_POINTS);
glVertex2d(centerPoint.x, centerPoint.y);
glEnd();
Expand Down
9 changes: 6 additions & 3 deletions Gui/CurveGui.cpp
Expand Up @@ -289,7 +289,8 @@ drawLineStrip(const std::vector<float>& vertices,

void
CurveGui::drawCurve(int curveIndex,
int curvesCount)
int curvesCount,
double screenPixelRatio)
{
// always running in the main thread
assert( qApp && qApp->thread() == QThread::currentThread() );
Expand Down Expand Up @@ -324,7 +325,6 @@ CurveGui::drawCurve(int curveIndex,
hasDrawnExpr = true;
}
}
double screenPixelRatio = _curveWidget->getScreenPixelRatio();
bool isPeriodic = false;
std::pair<double,double> parametricRange = std::make_pair(-std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity());
if (isBezier) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion Gui/CurveGui.h
Expand Up @@ -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;
Expand Down
14 changes: 8 additions & 6 deletions Gui/CurveWidget.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 7cc25b0

Please sign in to comment.