Changeset View
Changeset View
Standalone View
Standalone View
libs/ui/canvas/kis_canvas2.cpp
Show First 20 Lines • Show All 1046 Lines • ▼ Show 20 Line(s) | |||||
1047 | KisImageWSP KisCanvas2::currentImage() const | 1047 | KisImageWSP KisCanvas2::currentImage() const | ||
1048 | { | 1048 | { | ||
1049 | return m_d->view->image(); | 1049 | return m_d->view->image(); | ||
1050 | } | 1050 | } | ||
1051 | 1051 | | |||
1052 | void KisCanvas2::documentOffsetMoved(const QPoint &documentOffset) | 1052 | void KisCanvas2::documentOffsetMoved(const QPoint &documentOffset) | ||
1053 | { | 1053 | { | ||
1054 | QPointF offsetBefore = m_d->coordinatesConverter->imageRectInViewportPixels().topLeft(); | 1054 | QPointF offsetBefore = m_d->coordinatesConverter->imageRectInViewportPixels().topLeft(); | ||
1055 | m_d->coordinatesConverter->setDocumentOffset(documentOffset); | 1055 | | ||
1056 | qreal devicePixelRatio = m_d->coordinatesConverter->devicePixelRatio(); | ||||
1057 | // The given offset is in widget logical pixels. In order to prevent fuzzy | ||||
1058 | // canvas rendering at 100% pixel-perfect zoom level when devicePixelRatio | ||||
1059 | // is not integral, we adjusts the offset to map to whole device pixels. | ||||
1060 | // We use qFloor here since the offset can be negative. | ||||
1061 | int deviceOffsetX = qFloor(documentOffset.x() * devicePixelRatio); | ||||
1062 | int deviceOffsetY = qFloor(documentOffset.y() * devicePixelRatio); | ||||
1063 | // These adjusted offsets will be in logical pixel but is aligned in device | ||||
1064 | // pixel space for pixel-perfect rendering. | ||||
1065 | qreal pixelPerfectOffsetX = deviceOffsetX / devicePixelRatio; | ||||
1066 | qreal pixelPerfectOffsetY = deviceOffsetY / devicePixelRatio; | ||||
1067 | // FIXME: This is a temporary hack for fixing the canvas under fractional | ||||
1068 | // DPI scaling before a new coordinate system is introduced. | ||||
1069 | QPointF offsetAdjusted(pixelPerfectOffsetX, pixelPerfectOffsetY); | ||||
1070 | | ||||
1071 | m_d->coordinatesConverter->setDocumentOffset(offsetAdjusted); | ||||
1056 | QPointF offsetAfter = m_d->coordinatesConverter->imageRectInViewportPixels().topLeft(); | 1072 | QPointF offsetAfter = m_d->coordinatesConverter->imageRectInViewportPixels().topLeft(); | ||
1057 | 1073 | | |||
dkazakov: debug-- | |||||
1058 | QPointF moveOffset = offsetAfter - offsetBefore; | 1074 | QPointF moveOffset = offsetAfter - offsetBefore; | ||
1059 | 1075 | | |||
1060 | if (!m_d->currentCanvasIsOpenGL) | 1076 | if (!m_d->currentCanvasIsOpenGL) | ||
1061 | m_d->prescaledProjection->viewportMoved(moveOffset); | 1077 | m_d->prescaledProjection->viewportMoved(moveOffset); | ||
1062 | 1078 | | |||
1063 | emit documentOffsetUpdateFinished(); | 1079 | emit documentOffsetUpdateFinished(); | ||
1064 | 1080 | | |||
1065 | updateCanvas(); | 1081 | updateCanvas(); | ||
▲ Show 20 Lines • Show All 197 Lines • Show Last 20 Lines |
debug--