Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2019-09-21 09:32:23 +0000
committerThomas Wolf2019-09-24 07:01:52 +0000
commitea6cc5cbd19baf2a0e504261f86f79386ad54867 (patch)
treed5a7cdd0d9e4d39dcee47e26069f83380c1fc0f3
parentd9ffc72f9cff1ea0ae332ba82e4d59f1ef847624 (diff)
downloadeclipse.platform.text-ea6cc5cbd19baf2a0e504261f86f79386ad54867.tar.gz
eclipse.platform.text-ea6cc5cbd19baf2a0e504261f86f79386ad54867.tar.xz
eclipse.platform.text-ea6cc5cbd19baf2a0e504261f86f79386ad54867.zip
Bug 551341 - Remove work-around for blurry line numbers on Mac HiDPII20190924-1800
This work-around is no longer needed, and slows down scrolling on Mac HiDPI quite a bit. Remove it completely, and set the minimum required version for org.eclipse.swt to the first version in which Cocoa bug 489451 had been fixed (3.110.100). This reverts the changes from bug 516293. Note that the corresponding changes in LogicalLineNumberRulerColumn in EGit must not be undone yet. EGit needs to work on older platforms where the work-around may still be active. It can be removed in EGit only once the baseline of EGit becomes 4.14. Change-Id: Ibb801c98f19f118353842cae2caad6b29852e6e9 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--org.eclipse.jface.text/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java21
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/source/DiffPainter.java27
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberChangeRulerColumn.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java103
5 files changed, 8 insertions, 147 deletions
diff --git a/org.eclipse.jface.text/META-INF/MANIFEST.MF b/org.eclipse.jface.text/META-INF/MANIFEST.MF
index cad51887d..7350b5633 100644
--- a/org.eclipse.jface.text/META-INF/MANIFEST.MF
+++ b/org.eclipse.jface.text/META-INF/MANIFEST.MF
@@ -35,7 +35,7 @@ Export-Package:
Require-Bundle:
org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
org.eclipse.text;bundle-version="[3.8.0,4.0.0)";visibility:=reexport,
- org.eclipse.swt;bundle-version="[3.107.0,4.0.0)",
+ org.eclipse.swt;bundle-version="[3.110.100,4.0.0)",
org.eclipse.jface;bundle-version="[3.15.0,4.0.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: com.ibm.icu.text
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java
index f96276a98..58723425d 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java
@@ -589,11 +589,6 @@ public final class RevisionPainter {
* @since 3.3
*/
private int fLastWidth= -1;
- /**
- * The zoom level for the current painting operation. Workaround for bug 516293.
- * @since 3.12
- */
- private int fZoom= 100;
/**
* Creates a new revision painter for a vertical ruler column.
@@ -664,20 +659,6 @@ public final class RevisionPainter {
}
/**
- * Sets the zoom level for the current painting operation. Workaround for bug 516293.
- *
- * @param zoom the zoom to set
- * @since 3.12
- */
- public void setZoom(int zoom) {
- fZoom= zoom;
- }
-
- private int autoScaleUp(int value) {
- return value * fZoom / 100;
- }
-
- /**
* Delegates the painting of the quick diff colors to this painter. The painter will draw the
* color boxes onto the passed {@link GC} for all model (document) lines in
* <code>visibleModelLines</code>.
@@ -1073,7 +1054,7 @@ public final class RevisionPainter {
int y1= fWidget.getLinePixel(range.getStartLine());
int y2= fWidget.getLinePixel(range.getStartLine() + range.getNumberOfLines());
- return new Rectangle(0, autoScaleUp(y1), autoScaleUp(getWidth()), autoScaleUp(y2 - y1 - 1));
+ return new Rectangle(0, y1, getWidth(), y2 - y1 - 1);
}
/**
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/source/DiffPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/source/DiffPainter.java
index 2c1d4ccc8..0658f4fb8 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/source/DiffPainter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/source/DiffPainter.java
@@ -83,11 +83,6 @@ public final class DiffPainter {
private final AnnotationListener fAnnotationListener= new AnnotationListener();
/** The shared color provider, possibly <code>null</code>. */
private final ISharedTextColors fSharedColors;
- /**
- * The zoom level for the current painting operation. Workaround for bug 516293.
- * @since 3.12
- */
- private int fZoom= 100;
/**
* Creates a new diff painter for a vertical ruler column.
@@ -141,20 +136,6 @@ public final class DiffPainter {
}
/**
- * Sets the zoom level for the current painting operation. Workaround for bug 516293.
- *
- * @param zoom the zoom to set
- * @since 3.12
- */
- public void setZoom(int zoom) {
- fZoom= zoom;
- }
-
- private int autoScaleUp(int value) {
- return value * fZoom / 100;
- }
-
- /**
* Delegates the painting of the quick diff colors to this painter. The painter will draw the
* color boxes onto the passed {@link GC} for all model (document) lines in
* <code>visibleModelLines</code>.
@@ -241,7 +222,7 @@ public final class DiffPainter {
// draw background color if special
if (hasSpecialColor(info)) {
gc.setBackground(getColor(info));
- gc.fillRectangle(0, autoScaleUp(y), autoScaleUp(width), autoScaleUp(lineHeight));
+ gc.fillRectangle(0, y, width, lineHeight);
}
/* Deletion Indicator: Simply a horizontal line */
@@ -249,11 +230,11 @@ public final class DiffPainter {
int delBelow= info.getRemovedLinesBelow();
if (delBefore > 0 || delBelow > 0) {
gc.setForeground(deletionColor);
- gc.setLineWidth(autoScaleUp(1));
+ gc.setLineWidth(1);
if (delBefore > 0)
- gc.drawLine(0, autoScaleUp(y), autoScaleUp(width), autoScaleUp(y));
+ gc.drawLine(0, y, width, y);
if (delBelow > 0)
- gc.drawLine(0, autoScaleUp(y + lineHeight - 1), autoScaleUp(width), autoScaleUp(y + lineHeight - 1));
+ gc.drawLine(0, y + lineHeight - 1, width, y + lineHeight - 1);
}
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberChangeRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberChangeRulerColumn.java
index 326d6e74f..214cdd73f 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberChangeRulerColumn.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberChangeRulerColumn.java
@@ -170,10 +170,8 @@ public class LineNumberChangeRulerColumn extends LineNumberRulerColumn implement
Color foreground= gc.getForeground();
if (visibleLines != null) {
if (fRevisionPainter.hasInformation()) {
- fRevisionPainter.setZoom(fZoom);
fRevisionPainter.paint(gc, visibleLines);
} else if (fDiffPainter.hasInformation()) { // don't paint quick diff colors if revisions are painted
- fDiffPainter.setZoom(fZoom);
fDiffPainter.paint(gc, visibleLines);
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java
index 808fdbcfe..5dd81e123 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java
@@ -18,7 +18,6 @@
*******************************************************************************/
package org.eclipse.jface.text.source;
-import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.function.Consumer;
@@ -32,12 +31,9 @@ import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.events.MouseWheelListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.ImageDataProvider;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Canvas;
@@ -46,8 +42,6 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.TypedListener;
-import org.eclipse.jface.util.Util;
-
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
@@ -68,17 +62,6 @@ import org.eclipse.jface.text.TextEvent;
public class LineNumberRulerColumn implements IVerticalRulerColumn {
/**
- * <code>true</code> if we're on a Mac, where drawing on an Image currently only draws at 100% zoom level,
- * which results in blurry line numbers on a Retina display.
- *
- * @see <a href="https://bugs.eclipse.org/516293">bug 516293</a>
- * @since 3.6
- */
- private final boolean IS_MAC_BUG_516293= Util.isMac()
- && !"false".equals(System.getProperty("LineNumberRulerColumn.retina.workaround")) //$NON-NLS-1$ //$NON-NLS-2$
- && internalSupportsZoomedPaint();
-
- /**
* Internal listener class.
*/
class InternalListener implements ITextListener {
@@ -428,13 +411,6 @@ public class LineNumberRulerColumn implements IVerticalRulerColumn {
};
/* @since 3.2 */
private MouseHandler fMouseHandler;
- /*
- * Zoom level and cached font for the current painting operation. Workaround for bug 516293.
- * @since 3.12
- */
- int fZoom= 100;
- private WeakReference<Font> fLastFont;
- private Font fLastZoomedFont;
/**
* Redraw the ruler handler called when a line height change.
@@ -680,12 +656,6 @@ public class LineNumberRulerColumn implements IVerticalRulerColumn {
fBuffer.dispose();
fBuffer= null;
}
-
- if (fLastZoomedFont != null) {
- fLastZoomedFont.dispose();
- fLastZoomedFont= null;
- fLastFont= null;
- }
}
/**
@@ -757,46 +727,7 @@ public class LineNumberRulerColumn implements IVerticalRulerColumn {
fLastTopModelLine= topModelLine;
fLastNumberOfLines= numberOfLines;
fLastBottomModelLine= bottomModelLine;
- if (IS_MAC_BUG_516293) {
- /* FIXME: Workaround (bug 516293):
- * Relies on SWT implementation detail that GC drawing on macOS only draws at 100% zoom level.
- * For higher zoom levels (200%), we manually scale the font and drawing coordinates,
- * and then use getImageData(100) to extract the high-resolution image data. */
- ILineRange lines= visibleLines;
- newBuffer= new Image(fCanvas.getDisplay(), (ImageDataProvider) zoom -> {
- fZoom= zoom;
- internalSetZoom(zoom);
- int width= size.x * zoom / 100;
- int height= size.y * zoom / 100;
- Image gcImage= new Image(fCanvas.getDisplay(), width, height);
-
- GC gc= new GC(gcImage);
- Font font= fCanvas.getFont();
- if (zoom != 100) {
- if (fLastFont != null && font == fLastFont.get()) {
- font= fLastZoomedFont;
- } else {
- fLastFont= new WeakReference<>(font);
- FontData fontData= font.getFontData()[0];
- fontData.setHeight(fontData.getHeight() * zoom / 100);
- font= new Font(font.getDevice(), fontData);
- fLastZoomedFont= font;
- }
- }
- try {
- initializeGC(gc, font, 0, 0, width, height);
- doPaint(gc, lines);
- } finally {
- gc.dispose();
- fZoom= 100;
- }
-
- ImageData imageData= gcImage.getImageData(100);
- gcImage.dispose();
- return imageData;
- });
- bufferGC.drawImage(newBuffer, 0, bufferY, size.x, bufferH, 0, bufferY, size.x, bufferH);
- } else if (dy != 0) {
+ if (dy != 0) {
// Some rulers may paint outside the line region. Let them paint in a new image,
// the copy the wanted bits.
newBuffer= new Image(fCanvas.getDisplay(), size.x, size.y);
@@ -832,36 +763,6 @@ public class LineNumberRulerColumn implements IVerticalRulerColumn {
}
/**
- * This method is not API and it is expected to disappear in Eclipse 4.8.
- * Subclasses that want to take advantage of the unsupported workaround for bug 516258
- * can re-implement this method and return true.
- *
- * @return true iff this class supports the workaround for bug 516258
- *
- * @nooverride This method is not intended to be re-implemented or extended by clients.
- * @noreference This method is not intended to be referenced by clients.
- * @since 3.12
- */
- protected boolean internalSupportsZoomedPaint() {
- return getClass().getPackage().equals(LineNumberChangeRulerColumn.class.getPackage());
- }
-
- /**
- * This method is not API and it is expected to disappear in Eclipse 4.8.
- * Subclasses that want to take advantage of the unsupported workaround for bug 516258
- * can override this method and store the given zoom level for later use.
- *
- * @param zoom the zoom level to use for drawing operations
- *
- * @nooverride This method is not intended to be re-implemented or extended by clients.
- * @noreference This method is not intended to be referenced by clients.
- * @since 3.12
- */
- protected void internalSetZoom(int zoom) {
- // callback for subclasses
- }
-
- /**
* Returns the view port height in lines.
*
* @return the view port height in lines
@@ -999,7 +900,7 @@ public class LineNumberRulerColumn implements IVerticalRulerColumn {
int indentation= fIndentation[index];
int baselineBias= getBaselineBias(gc, widgetLine);
int verticalIndent= fCachedTextViewer.getTextWidget().getLineVerticalIndent(widgetLine);
- gc.drawString(s, indentation * fZoom / 100, (y + baselineBias + verticalIndent) * fZoom / 100, true);
+ gc.drawString(s, indentation, y + baselineBias + verticalIndent, true);
}
/**

Back to the top