From a335821ebda4208d3afef522eaf01dc698187400 Mon Sep 17 00:00:00 2001 From: Deepika Udayagiri Date: Wed, 26 Jun 2024 10:59:44 +0530 Subject: [PATCH] [GTK][HiDpi] Code cleanup for removal of non-cairo scale path Fixes https://github.com/eclipse-platform/eclipse.platform.swt/issues/1300 --- .../gtk/org/eclipse/swt/awt/SWT_AWT.java | 6 +- .../swt/accessibility/AccessibleObject.java | 6 +- .../gtk/org/eclipse/swt/dnd/DropTarget.java | 2 +- .../swt/dnd/TableDropTargetEffect.java | 4 +- .../eclipse/swt/dnd/TreeDropTargetEffect.java | 2 +- .../gtk/org/eclipse/swt/opengl/GLCanvas.java | 3 +- .../gtk/org/eclipse/swt/browser/WebKit.java | 2 +- .../cairo/org/eclipse/swt/graphics/Path.java | 56 +---- .../org/eclipse/swt/graphics/Pattern.java | 5 - .../org/eclipse/swt/graphics/Transform.java | 10 +- .../gtk/org/eclipse/swt/graphics/Device.java | 4 - .../gtk/org/eclipse/swt/graphics/GC.java | 190 ++--------------- .../gtk/org/eclipse/swt/graphics/Image.java | 59 +----- .../gtk/org/eclipse/swt/graphics/Region.java | 64 +----- .../org/eclipse/swt/graphics/TextLayout.java | 199 +++++------------- 15 files changed, 110 insertions(+), 502 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java index ad34ca74296..c6b32e3e51a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java +++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java @@ -231,7 +231,7 @@ public static Frame new_Frame (final Composite parent) { }); break; case SWT.Resize: - final Rectangle clientArea = DPIUtil.autoScaleUp(parent.getClientArea()); + final Rectangle clientArea = parent.getClientArea(); EventQueue.invokeLater(() -> frame[0].setSize (clientArea.width, clientArea.height)); break; } @@ -241,7 +241,7 @@ public static Frame new_Frame (final Composite parent) { parent.getDisplay().asyncExec(() -> { if (parent.isDisposed()) return; - final Rectangle clientArea = DPIUtil.autoScaleUp(parent.getClientArea()); + final Rectangle clientArea = parent.getClientArea(); EventQueue.invokeLater(() -> { frame[0].setSize (clientArea.width, clientArea.height); frame[0].validate (); @@ -285,7 +285,7 @@ public void componentResized (ComponentEvent e) { display.syncExec (() -> { if (shell.isDisposed()) return; Dimension dim = parent.getSize (); - shell.setSize (DPIUtil.autoScaleDown(new Point(dim.width, dim.height))); + shell.setSize (new Point(dim.width, dim.height)); }); } }; diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/AccessibleObject.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/AccessibleObject.java index 6eeb54a0d2a..73e3c8c6364 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/AccessibleObject.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/AccessibleObject.java @@ -4534,10 +4534,8 @@ static long toDisplay (long gdkResource, long x, long y) { } else { GDK.gdk_window_get_origin (gdkResource, origin_x, origin_y); } - int scaledX = DPIUtil.autoScaleDown (origin_x [0]); - int scaledY = DPIUtil.autoScaleDown (origin_y [0]); - C.memmove (x, new int[] {scaledX}, 4); - C.memmove (y, new int[] {scaledY}, 4); + C.memmove (x, origin_x, 4); + C.memmove (y, origin_y, 4); return 0; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java index 8830850b1cb..78675f78b53 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java @@ -792,7 +792,7 @@ boolean setEventData(long context, int x, int y, int time, DNDEvent event) { long window = GTK3.gtk_widget_get_window (control.handle); GDK.gdk_window_get_origin(window, origin_x, origin_y); } - Point coordinates = DPIUtil.autoScaleDown(new Point(origin_x[0] + x, origin_y[0] + y)); + Point coordinates = new Point(origin_x[0] + x, origin_y[0] + y); event.widget = this; event.x = coordinates.x; diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDropTargetEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDropTargetEffect.java index 8b14b6f23b3..9fa476f9fb1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDropTargetEffect.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDropTargetEffect.java @@ -136,7 +136,7 @@ public void dragOver(DropTargetEvent event) { long handle = table.handle; int effect = checkEffect(event.feedback); Point coordinates = new Point(event.x, event.y); - coordinates = DPIUtil.autoScaleUp(table.toControl(coordinates)); + coordinates = table.toControl(coordinates); long [] path = new long [1]; GTK.gtk_tree_view_get_path_at_pos (handle, coordinates.x, coordinates.y, path, null, null, null); int index = -1; @@ -154,7 +154,7 @@ public void dragOver(DropTargetEvent event) { } else { if (index != -1 && scrollIndex == index && scrollBeginTime != 0) { if (System.currentTimeMillis() >= scrollBeginTime) { - if (coordinates.y < DPIUtil.autoScaleUp(table.getItemHeight())) { + if (coordinates.y < table.getItemHeight()) { GTK.gtk_tree_path_prev(path[0]); } else { GTK.gtk_tree_path_next(path[0]); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDropTargetEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDropTargetEffect.java index 0f77fc07745..3269b1b1dc8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDropTargetEffect.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDropTargetEffect.java @@ -150,7 +150,7 @@ public void dragOver(DropTargetEvent event) { long handle = tree.handle; Point coordinates = new Point(event.x, event.y); - coordinates = DPIUtil.autoScaleUp(tree.toControl(coordinates)); + coordinates = tree.toControl(coordinates); long [] path = new long [1]; GTK.gtk_tree_view_get_path_at_pos (handle, coordinates.x, coordinates.y, path, null, null, null); int index = -1; diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java index d7dd4873eba..c4ded786ef9 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java @@ -15,7 +15,6 @@ import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; -import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.gtk.*; import org.eclipse.swt.internal.gtk3.*; import org.eclipse.swt.internal.opengl.glx.*; @@ -164,7 +163,7 @@ public GLCanvas (Composite parent, int style, GLData data) { GLX.glViewport (viewport [0],viewport [1],viewport [2],viewport [3]); break; case SWT.Resize: - Rectangle clientArea = DPIUtil.autoScaleUp(getClientArea()); + Rectangle clientArea = getClientArea(); GDK.gdk_window_move (glWindow, clientArea.x, clientArea.y); GDK.gdk_window_resize (glWindow, clientArea.width, clientArea.height); break; diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java index 68b8f4cdc61..74fda155d7b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java +++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java @@ -1817,7 +1817,7 @@ void onDispose (Event e) { } void onResize (Event e) { - Rectangle rect = DPIUtil.autoScaleUp(browser.getClientArea ()); + Rectangle rect = browser.getClientArea (); if (webView == 0) return; GTK.gtk_widget_set_size_request (webView, rect.width, rect.height); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java index d7ca68d5136..2273df459c5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java @@ -219,14 +219,6 @@ public Path (Device device, PathData data) { public void addArc(float x, float y, float width, float height, float startAngle, float arcAngle) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (width == 0 || height == 0 || arcAngle == 0) return; - x = DPIUtil.autoScaleUp(x); - y = DPIUtil.autoScaleUp(y); - width = DPIUtil.autoScaleUp(width); - height = DPIUtil.autoScaleUp(height); - addArcInPixels(x, y, width, height, startAngle, arcAngle); -} - -void addArcInPixels(float x, float y, float width, float height, float startAngle, float arcAngle) { moved = true; if (width == height) { float angle = -startAngle * (float)Math.PI / 180; @@ -292,14 +284,6 @@ public void addPath(Path path) { */ public void addRectangle(float x, float y, float width, float height) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - x = DPIUtil.autoScaleUp(x); - y = DPIUtil.autoScaleUp(y); - width = DPIUtil.autoScaleUp(width); - height = DPIUtil.autoScaleUp(height); - addRectangleInPixels(x, y, width, height); -} - -void addRectangleInPixels(float x, float y, float width, float height) { moved = false; Cairo.cairo_rectangle(handle, x, y, width, height); closed = true; @@ -326,19 +310,14 @@ public void addString(String string, float x, float y, Font font) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (font == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - x = DPIUtil.autoScaleUp(x); - y = DPIUtil.autoScaleUp(y); // Scale up the font FontData fd = font.getFontData()[0]; - fd.setHeight(DPIUtil.autoScaleUp(fd.getHeight())); + fd.setHeight(fd.getHeight()); Font scaledFont = new Font(font.getDevice(), fd); - addStringInPixels(string, x, y, scaledFont); - scaledFont.dispose(); // Dispose the scaled up font -} -void addStringInPixels(String string, float x, float y, Font font) { moved = false; GC.addCairoString(handle, string, x, y, font); closed = true; + scaledFont.dispose(); // Dispose the scaled up font } /** @@ -384,11 +363,6 @@ public boolean contains(float x, float y, GC gc, boolean outline) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - x = DPIUtil.autoScaleUp(x); - y = DPIUtil.autoScaleUp(y); - return containsInPixels(x, y, gc, outline); -} -boolean containsInPixels(float x, float y, GC gc, boolean outline) { //TODO - see Windows gc.initCairo(); gc.checkGC(GC.LINE_CAP | GC.LINE_JOIN | GC.LINE_STYLE | GC.LINE_WIDTH); @@ -423,15 +397,6 @@ boolean containsInPixels(float x, float y, GC gc, boolean outline) { */ public void cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - cx1 = DPIUtil.autoScaleUp(cx1); - cy1 = DPIUtil.autoScaleUp(cy1); - cx2 = DPIUtil.autoScaleUp(cx2); - cy2 = DPIUtil.autoScaleUp(cy2); - x = DPIUtil.autoScaleUp(x); - y = DPIUtil.autoScaleUp(y); - cubicToInPixels(cx1, cy1, cx2, cy2, x, y); -} -void cubicToInPixels(float cx1, float cy1, float cx2, float cy2, float x, float y) { if (!moved) { double[] currentX = new double[1], currentY = new double[1]; Cairo.cairo_get_current_point(handle, currentX, currentY); @@ -647,11 +612,6 @@ PathData getPathDataInPixels() { */ public void lineTo(float x, float y) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - x = DPIUtil.autoScaleUp(x); - y = DPIUtil.autoScaleUp(y); - lineToInPixels(x, y); -} -void lineToInPixels(float x, float y) { if (!moved) { double[] currentX = new double[1], currentY = new double[1]; Cairo.cairo_get_current_point(handle, currentX, currentY); @@ -676,11 +636,6 @@ void lineToInPixels(float x, float y) { */ public void moveTo(float x, float y) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - x = DPIUtil.autoScaleUp(x); - y = DPIUtil.autoScaleUp(y); - moveToInPixels(x, y); -} -void moveToInPixels(float x, float y) { /* * Bug in Cairo. If cairo_move_to() is not called at the * begining of a subpath, the first cairo_line_to() or @@ -707,13 +662,6 @@ void moveToInPixels(float x, float y) { */ public void quadTo(float cx, float cy, float x, float y) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - x = DPIUtil.autoScaleUp(x); - y = DPIUtil.autoScaleUp(y); - cx = DPIUtil.autoScaleUp(cx); - cy = DPIUtil.autoScaleUp(cy); - quadToInPixels(cx, cy, x, y); -} -void quadToInPixels(float cx, float cy, float x, float y) { double[] currentX = new double[1], currentY = new double[1]; Cairo.cairo_get_current_point(handle, currentX, currentY); if (!moved) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java index 91a15888442..51a3424ae59 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java @@ -14,7 +14,6 @@ package org.eclipse.swt.graphics; import org.eclipse.swt.*; -import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.cairo.*; /** @@ -173,10 +172,6 @@ public Pattern(Device device, float x1, float y1, float x2, float y2, Color colo */ public Pattern(Device device, float x1, float y1, float x2, float y2, Color color1, int alpha1, Color color2, int alpha2) { super(device); - x1 = DPIUtil.autoScaleUp(x1); - y1 = DPIUtil.autoScaleUp(y1); - x2 = DPIUtil.autoScaleUp(x2); - y2 = DPIUtil.autoScaleUp(y2); if (color1 == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (color1.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); if (color2 == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Transform.java b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Transform.java index f9484fdba88..4ed39f4b218 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Transform.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Transform.java @@ -147,7 +147,7 @@ public Transform (Device device, float m11, float m12, float m21, float m22, flo super(device); handle = new double[6]; if (handle == null) SWT.error(SWT.ERROR_NO_HANDLES); - Cairo.cairo_matrix_init(handle, m11, m12, m21, m22, DPIUtil.autoScaleUp(dx), DPIUtil.autoScaleUp(dy)); + Cairo.cairo_matrix_init(handle, m11, m12, m21, m22, dx, dy); init(); } @@ -320,7 +320,7 @@ public void scale(float scaleX, float scaleY) { */ public void setElements(float m11, float m12, float m21, float m22, float dx, float dy) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Cairo.cairo_matrix_init(handle, m11, m12, m21, m22, DPIUtil.autoScaleUp(dx), DPIUtil.autoScaleUp(dy)); + Cairo.cairo_matrix_init(handle, m11, m12, m21, m22, dx, dy); } /** @@ -362,8 +362,8 @@ public void transform(float[] pointArray) { double[] dx = new double[1], dy = new double[1]; int length = pointArray.length / 2; for (int i = 0, j = 0; i < length; i++, j += 2) { - dx[0] = DPIUtil.autoScaleUp(pointArray[j]); - dy[0] = DPIUtil.autoScaleUp(pointArray[j + 1]); + dx[0] = pointArray[j]; + dy[0] = pointArray[j + 1]; Cairo.cairo_matrix_transform_point(handle, dx, dy); pointArray[j] = DPIUtil.autoScaleDown((float)dx[0]); pointArray[j + 1] = DPIUtil.autoScaleDown((float)dy[0]); @@ -383,7 +383,7 @@ public void transform(float[] pointArray) { */ public void translate(float offsetX, float offsetY) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Cairo.cairo_matrix_translate(handle, DPIUtil.autoScaleUp(offsetX), DPIUtil.autoScaleUp(offsetY)); + Cairo.cairo_matrix_translate(handle, offsetX, offsetY); } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java index 3363ea5ae86..77cf257f985 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java @@ -346,10 +346,6 @@ protected void destroy () { */ public Rectangle getBounds () { checkDevice (); - return DPIUtil.autoScaleDown (getBoundsInPixels ()); -} - -private Rectangle getBoundsInPixels () { return new Rectangle(0, 0, 0, 0); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java index 70632dbc2ca..8c6842bb2c4 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java @@ -343,7 +343,7 @@ void checkGC (int mask) { Cairo.cairo_set_line_join(cairo, join_style); } if ((state & LINE_WIDTH) != 0) { - Cairo.cairo_set_line_width(cairo, data.lineWidth == 0 ? DPIUtil.autoScaleUp(drawable, 1) : data.lineWidth); + Cairo.cairo_set_line_width(cairo, data.lineWidth == 0 ? 1 : data.lineWidth); switch (data.lineStyle) { case SWT.LINE_DOT: case SWT.LINE_DASH: @@ -467,10 +467,6 @@ public void copyArea(Image image, int x, int y) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - Point loc = DPIUtil.autoScaleUp(drawable, new Point(x, y)); - copyAreaInPixels(image, loc.x, loc.y); -} -void copyAreaInPixels(Image image, int x, int y) { long cairo = Cairo.cairo_create(image.surface); if (cairo == 0) SWT.error(SWT.ERROR_NO_HANDLES); Cairo.cairo_translate(cairo, -x, -y); @@ -507,13 +503,7 @@ void copyAreaInPixels(Image image, int x, int y) { */ public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle src = DPIUtil.autoScaleUp(drawable, new Rectangle(srcX, srcY, width, height)); - Point dest = DPIUtil.autoScaleUp(drawable, new Point(destX, destY)); - copyAreaInPixels(src.x, src.y, src.width, src.height, dest.x, dest.y); -} - -void copyAreaInPixels(int srcX, int srcY, int width, int height, int destX, int destY) { - copyAreaInPixels(srcX, srcY, width, height, destX, destY, true); + copyArea(srcX, srcY, width, height, destX, destY, true); } /** * Copies a rectangular area of the receiver at the source @@ -535,11 +525,6 @@ void copyAreaInPixels(int srcX, int srcY, int width, int height, int destX, int */ public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY, boolean paint) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle srcLoc = DPIUtil.autoScaleUp(drawable, new Rectangle(srcX, srcY, width, height)); - Point destLoc = DPIUtil.autoScaleUp(drawable, new Point(destX, destY)); - copyAreaInPixels(srcLoc.x, srcLoc.y, srcLoc.width, srcLoc.height, destLoc.x, destLoc.y, paint); -} -void copyAreaInPixels(int srcX, int srcY, int width, int height, int destX, int destY, boolean paint) { if (width <= 0 || height <= 0) return; int deltaX = destX - srcX, deltaY = destY - srcY; if (deltaX == 0 && deltaY == 0) return; @@ -720,10 +705,6 @@ void destroy() { */ public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle loc = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height)); - drawArcInPixels(loc.x, loc.y, loc.width, loc.height, startAngle, arcAngle); -} -void drawArcInPixels(int x, int y, int width, int height, int startAngle, int arcAngle) { checkGC(DRAW); if (width < 0) { x = x + width; @@ -775,10 +756,6 @@ void drawArcInPixels(int x, int y, int width, int height, int startAngle, int ar */ public void drawFocus(int x, int y, int width, int height) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle loc = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height)); - drawFocusInPixels(loc.x, loc.y, loc.width, loc.height); -} -void drawFocusInPixels(int x, int y, int width, int height) { long cairo = data.cairo; checkGC(FOREGROUND); long context = GTK.gtk_widget_get_style_context(data.device.shellHandle); @@ -808,10 +785,6 @@ public void drawImage(Image image, int x, int y) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - Point loc = DPIUtil.autoScaleUp(drawable, new Point(x, y)); - drawImageInPixels(image, loc.x, loc.y); -} -void drawImageInPixels(Image image, int x, int y) { drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true); } @@ -855,8 +828,7 @@ public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeig } if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - Rectangle destRect = DPIUtil.autoScaleUp(drawable, new Rectangle(destX, destY, destWidth, destHeight)); - drawImage(image, srcX, srcY, srcWidth, srcHeight, destRect.x, destRect.y, destRect.width, destRect.height, false); + drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false); } void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) { /* Refresh Image as per zoom level, if required. */ @@ -933,11 +905,6 @@ void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, */ public void drawLine(int x1, int y1, int x2, int y2) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Point loc1 = DPIUtil.autoScaleUp(drawable, new Point(x1, y1)); - Point loc2 = DPIUtil.autoScaleUp(drawable, new Point(x2, y2)); - drawLineInPixels(loc1.x, loc1.y, loc2.x, loc2.y); -} -void drawLineInPixels(int x1, int y1, int x2, int y2) { checkGC(DRAW); long cairo = data.cairo; double xOffset = data.cairoXoffset, yOffset = data.cairoYoffset; @@ -972,10 +939,6 @@ void drawLineInPixels(int x1, int y1, int x2, int y2) { */ public void drawOval(int x, int y, int width, int height) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle rect = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height)); - drawOvalInPixels(rect.x, rect.y, rect.width, rect.height); -} -void drawOvalInPixels(int x, int y, int width, int height) { checkGC(DRAW); if (width < 0) { x = x + width; @@ -1059,10 +1022,6 @@ public void drawPath(Path path) { */ public void drawPoint (int x, int y) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Point loc = DPIUtil.autoScaleUp(drawable, new Point(x, y)); - drawPointInPixels(loc.x, loc.y); -} -void drawPointInPixels (int x, int y) { checkGC(DRAW); long cairo = data.cairo; Cairo.cairo_rectangle(cairo, x, y, 1, 1); @@ -1089,10 +1048,6 @@ void drawPointInPixels (int x, int y) { public void drawPolygon(int[] pointArray) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - int [] scaledPointArray = DPIUtil.autoScaleUp(drawable, pointArray); - drawPolygonInPixels(scaledPointArray); -} -void drawPolygonInPixels(int[] pointArray) { checkGC(DRAW); long cairo = data.cairo; drawPolyline(cairo, pointArray, true); @@ -1119,10 +1074,6 @@ void drawPolygonInPixels(int[] pointArray) { public void drawPolyline(int[] pointArray) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - int [] scaledPointArray = DPIUtil.autoScaleUp(drawable, pointArray); - drawPolylineInPixels(scaledPointArray); -} -void drawPolylineInPixels(int[] pointArray) { checkGC(DRAW); long cairo = data.cairo; drawPolyline(cairo, pointArray, false); @@ -1157,9 +1108,6 @@ void drawPolyline(long cairo, int[] pointArray, boolean close) { */ public void drawRectangle(int x, int y, int width, int height) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - drawRectangle(new Rectangle(x, y, width, height)); -} -void drawRectangleInPixels(int x, int y, int width, int height) { checkGC(DRAW); if (width < 0) { x = x + width; @@ -1193,10 +1141,7 @@ void drawRectangleInPixels(int x, int y, int width, int height) { */ public void drawRectangle(Rectangle rect) { if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - drawRectangleInPixels(DPIUtil.autoScaleUp(drawable, rect)); -} -void drawRectangleInPixels(Rectangle rect) { - drawRectangleInPixels (rect.x, rect.y, rect.width, rect.height); + drawRectangle (rect.x, rect.y, rect.width, rect.height); } /** * Draws the outline of the round-cornered rectangle specified by @@ -1221,11 +1166,6 @@ void drawRectangleInPixels(Rectangle rect) { */ public void drawRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle rect = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height)); - Point arcSize = DPIUtil.autoScaleUp(drawable, new Point(arcWidth, arcHeight)); - drawRoundRectangleInPixels(rect.x, rect.y, rect.width, rect.height, arcSize.x, arcSize.y); -} -void drawRoundRectangleInPixels(int x, int y, int width, int height, int arcWidth, int arcHeight) { checkGC(DRAW); int nx = x; int ny = y; @@ -1294,9 +1234,6 @@ public void drawString (String string, int x, int y) { drawString (string, x, y, false); } -void drawStringInPixels (String string, int x, int y) { - drawStringInPixels(string, x, y, false); -} /** * Draws the given string, using the receiver's current font and * foreground color. No tab expansion or carriage return processing @@ -1327,12 +1264,7 @@ void drawStringInPixels (String string, int x, int y) { public void drawString(String string, int x, int y, boolean isTransparent) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - Point loc = DPIUtil.autoScaleUp(drawable, new Point(x, y)); - drawStringInPixels(string, loc.x, loc.y, isTransparent); -} - -void drawStringInPixels(String string, int x, int y, boolean isTransparent) { - drawTextInPixels(string, x, y, isTransparent ? SWT.DRAW_TRANSPARENT : 0); + drawText(string, x, y, isTransparent ? SWT.DRAW_TRANSPARENT : 0); } /** @@ -1360,9 +1292,6 @@ void drawStringInPixels(String string, int x, int y, boolean isTransparent) { public void drawText(String string, int x, int y) { drawText(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB); } -void drawTextInPixels(String string, int x, int y) { - drawTextInPixels(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB); -} /** * Draws the given string, using the receiver's current font and @@ -1389,13 +1318,9 @@ void drawTextInPixels(String string, int x, int y) { * */ public void drawText(String string, int x, int y, boolean isTransparent) { - Point loc = DPIUtil.autoScaleUp(drawable, new Point (x, y)); - drawTextInPixels(string, loc.x, loc.y, isTransparent); -} -void drawTextInPixels(String string, int x, int y, boolean isTransparent) { int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB; if (isTransparent) flags |= SWT.DRAW_TRANSPARENT; - drawTextInPixels(string, x, y, flags); + drawText(string, x, y, flags); } /** @@ -1438,10 +1363,6 @@ void drawTextInPixels(String string, int x, int y, boolean isTransparent) { * */ public void drawText (String string, int x, int y, int flags) { - Point loc = DPIUtil.autoScaleUp(drawable, new Point (x, y)); - drawTextInPixels(string, loc.x, loc.y, flags); -} -void drawTextInPixels (String string, int x, int y, int flags) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (string.length() == 0) return; @@ -1524,10 +1445,6 @@ public boolean equals(Object object) { */ public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle rect = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height)); - fillArcInPixels(rect.x, rect.y, rect.width, rect.height, startAngle, arcAngle); -} -void fillArcInPixels(int x, int y, int width, int height, int startAngle, int arcAngle) { checkGC(FILL); if (width < 0) { x = x + width; @@ -1583,11 +1500,6 @@ void fillArcInPixels(int x, int y, int width, int height, int startAngle, int ar */ public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle rect = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height)); - fillGradientRectangleInPixels(rect.x, rect.y, rect.width, rect.height, vertical); -} - -void fillGradientRectangleInPixels(int x, int y, int width, int height, boolean vertical) { if ((width == 0) || (height == 0)) return; /* Rewrite this to use GdkPixbuf */ @@ -1615,22 +1527,14 @@ void fillGradientRectangleInPixels(int x, int y, int width, int height, boolean long cairo = data.cairo; long pattern; - if (DPIUtil.useCairoAutoScale() ) { - /* - * Here the co-ordinates passed are in points for GTK3. - * That means the user is expecting surface to be at - * device scale equal to current scale factor. So need - * to set the device scale to current scale factor - */ - long surface = Cairo.cairo_get_target(cairo); - if (surface != 0) { - float scaleFactor = DPIUtil.getDeviceZoom() / 100f; - Cairo.cairo_surface_set_device_scale(surface, scaleFactor, scaleFactor); - } + long surface = Cairo.cairo_get_target(cairo); + if (surface != 0) { + float scaleFactor = DPIUtil.getDeviceZoom() / 100f; + Cairo.cairo_surface_set_device_scale(surface, scaleFactor, scaleFactor); } if (fromRGB.equals(toRGB)) { - fillRectangleInPixels(x, y, width, height); + fillRectangle(x, y, width, height); return; } @@ -1669,10 +1573,6 @@ void fillGradientRectangleInPixels(int x, int y, int width, int height, boolean */ public void fillOval(int x, int y, int width, int height) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle rect = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height)); - fillOvalInPixels(rect.x, rect.y, rect.width, rect.height); -} -void fillOvalInPixels(int x, int y, int width, int height) { checkGC(FILL); if (width < 0) { x = x + width; @@ -1754,10 +1654,6 @@ public void fillPath (Path path) { public void fillPolygon(int[] pointArray) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - int [] scaledPointArray = DPIUtil.autoScaleUp(drawable, pointArray); - fillPolygonInPixels(scaledPointArray); -} -void fillPolygonInPixels(int[] pointArray) { checkGC(FILL); long cairo = data.cairo; drawPolyline(cairo, pointArray, true); @@ -1781,9 +1677,6 @@ void fillPolygonInPixels(int[] pointArray) { */ public void fillRectangle(int x, int y, int width, int height) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - fillRectangle(new Rectangle(x, y, width, height)); -} -void fillRectangleInPixels(int x, int y, int width, int height) { checkGC(FILL); if (width < 0) { x = x + width; @@ -1820,10 +1713,7 @@ void fillRectangleInPixels(int x, int y, int width, int height) { public void fillRectangle(Rectangle rect) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - fillRectangleInPixels(DPIUtil.autoScaleUp(drawable, rect)); -} -void fillRectangleInPixels(Rectangle rect) { - fillRectangleInPixels(rect.x, rect.y, rect.width, rect.height); + fillRectangle(rect.x, rect.y, rect.width, rect.height); } /** @@ -1845,11 +1735,6 @@ void fillRectangleInPixels(Rectangle rect) { */ public void fillRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle rect = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height)); - Point arcSize = DPIUtil.autoScaleUp(drawable, new Point(arcWidth, arcHeight)); - fillRoundRectangleInPixels(rect.x, rect.y, rect.width, rect.height, arcSize.x, arcSize.y); -} -void fillRoundRectangleInPixels(int x, int y, int width, int height, int arcWidth, int arcHeight) { checkGC(FILL); int nx = x; int ny = y; @@ -1922,7 +1807,7 @@ int fixMnemonic (char [] buffer) { public int getAdvanceWidth(char ch) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); //BOGUS - return stringExtentInPixels(new String(new char[]{ch})).x; + return stringExtent(new String(new char[]{ch})).x; } /** @@ -2053,7 +1938,7 @@ public Pattern getBackgroundPattern() { public int getCharWidth(char ch) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); //BOGUS - return stringExtentInPixels(new String(new char[]{ch})).x; + return stringExtent(new String(new char[]{ch})).x; } /** @@ -2070,9 +1955,6 @@ public int getCharWidth(char ch) { */ public Rectangle getClipping() { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return DPIUtil.autoScaleDown(drawable, getClippingInPixels()); -} -Rectangle getClippingInPixels() { /* Calculate visible bounds in device space */ int x = 0, y = 0, width = 0, height = 0; int[] w = new int[1], h = new int[1]; @@ -2247,11 +2129,11 @@ public FontMetrics getFontMetrics() { FontMetrics fm = new FontMetrics(); int ascent = OS.pango_font_metrics_get_ascent(metrics); int descent = OS.pango_font_metrics_get_descent(metrics); - int ascentInPoints = DPIUtil.autoScaleDown(drawable, OS.PANGO_PIXELS(ascent)); + int ascentInPoints = OS.PANGO_PIXELS(ascent); fm.ascentInPoints = ascentInPoints; - int heightInPoints = DPIUtil.autoScaleDown(drawable, OS.PANGO_PIXELS(ascent + descent)); + int heightInPoints = OS.PANGO_PIXELS(ascent + descent); fm.descentInPoints = heightInPoints - ascentInPoints; - fm.averageCharWidthInPoints = DPIUtil.autoScaleDown(drawable, OS.PANGO_PIXELS(OS.pango_font_metrics_get_approximate_char_width(metrics))); + fm.averageCharWidthInPoints = OS.PANGO_PIXELS(OS.pango_font_metrics_get_approximate_char_width(metrics)); OS.pango_font_metrics_unref(metrics); return fm; } @@ -2347,11 +2229,6 @@ public int getInterpolation() { */ public LineAttributes getLineAttributes() { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - LineAttributes attributes = getLineAttributesInPixels(); - attributes.width = DPIUtil.autoScaleDown(drawable, attributes.width); - return attributes; -} -LineAttributes getLineAttributesInPixels() { float[] dashes = null; if (data.lineDashes != null) { dashes = new float[data.lineDashes.length]; @@ -2449,9 +2326,6 @@ public int getLineStyle() { */ public int getLineWidth() { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return (int)DPIUtil.autoScaleDown(drawable, data.lineWidth); -} -int getLineWidthInPixels() { return (int)data.lineWidth; } @@ -3108,9 +2982,6 @@ void setClipping(long clipRgn) { */ public void setClipping(int x, int y, int width, int height) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - setClippingInPixels(DPIUtil.autoScaleUp(drawable, x), DPIUtil.autoScaleUp(drawable, y), DPIUtil.autoScaleUp(drawable, width), DPIUtil.autoScaleUp(drawable, height)); -} -void setClippingInPixels(int x, int y, int width, int height) { if (width < 0) { x = x + width; width = -width; @@ -3186,13 +3057,10 @@ public void setClipping(Path path) { */ public void setClipping(Rectangle rect) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - setClippingInPixels(DPIUtil.autoScaleUp(drawable, rect)); -} -void setClippingInPixels(Rectangle rect) { if (rect == null) { resetClipping(); } else { - setClippingInPixels(rect.x, rect.y, rect.width, rect.height); + setClipping(rect.x, rect.y, rect.width, rect.height); } } @@ -3411,10 +3279,7 @@ public void setInterpolation(int interpolation) { public void setLineAttributes(LineAttributes attributes) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (attributes == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - attributes.width = DPIUtil.autoScaleUp(drawable, attributes.width); - setLineAttributesInPixels(attributes); -} -void setLineAttributesInPixels(LineAttributes attributes) { + attributes.width = attributes.width; int mask = 0; float lineWidth = attributes.width; if (lineWidth != data.lineWidth) { @@ -3665,9 +3530,6 @@ public void setLineStyle(int lineStyle) { */ public void setLineWidth(int lineWidth) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - setLineWidthInPixels(DPIUtil.autoScaleUp(drawable, lineWidth)); -} -void setLineWidthInPixels(int lineWidth) { if (data.lineWidth == lineWidth) return; data.lineWidth = lineWidth; data.state &= ~(LINE_WIDTH | DRAW_OFFSET); @@ -3849,10 +3711,7 @@ public void setXORMode(boolean xor) { * */ public Point stringExtent(String string) { - return DPIUtil.autoScaleDown(drawable, stringExtentInPixels(string)); -} -Point stringExtentInPixels(String string) { - return textExtentInPixels(string, 0); + return textExtent(string, 0); } /** @@ -3875,11 +3734,7 @@ Point stringExtentInPixels(String string) { * */ public Point textExtent(String string) { - return DPIUtil.autoScaleDown(drawable, textExtentInPixels(string)); -} - -Point textExtentInPixels(String string) { - return textExtentInPixels(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB); + return textExtent(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB); } /** @@ -3916,9 +3771,6 @@ Point textExtentInPixels(String string) { public Point textExtent(String string, int flags) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - return DPIUtil.autoScaleDown(drawable, textExtentInPixels(string, flags)); -} -Point textExtentInPixels(String string, int flags) { setString(string, flags); checkGC(FONT); if (data.stringWidth == -1) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java index 6a44fc0c61a..14276c683cc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java @@ -205,9 +205,8 @@ public final class Image extends Resource implements Drawable { */ public Image(Device device, int width, int height) { super(device); - Point size = DPIUtil.autoScaleUp(new Point(width, height)); currentDeviceZoom = DPIUtil.getDeviceZoom(); - init(size.x, size.y); + init(width, height); init(); } @@ -275,7 +274,7 @@ public Image(Device device, Image srcImage, int flag) { boolean hasAlpha = format == Cairo.CAIRO_FORMAT_ARGB32; surface = Cairo.cairo_image_surface_create(format, width, height); if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES); - if (DPIUtil.getDeviceZoom() != currentDeviceZoom && DPIUtil.useCairoAutoScale()) { + if (DPIUtil.getDeviceZoom() != currentDeviceZoom) { double scaleFactor = DPIUtil.getDeviceZoom() / 100f; Cairo.cairo_surface_set_device_scale(surface, scaleFactor, scaleFactor); } @@ -383,8 +382,7 @@ public Image(Device device, Rectangle bounds) { super(device); if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); currentDeviceZoom = DPIUtil.getDeviceZoom(); - Rectangle bounds1 = DPIUtil.autoScaleUp (bounds); - init(bounds1.width, bounds1.height); + init(bounds.width, bounds.height); init(); } @@ -415,7 +413,6 @@ public Image(Device device, ImageData data) { super(device); if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); currentDeviceZoom = DPIUtil.getDeviceZoom(); - data = DPIUtil.autoScaleUp (device, data); init(data); init(); } @@ -458,8 +455,6 @@ public Image(Device device, ImageData source, ImageData mask) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } currentDeviceZoom = DPIUtil.getDeviceZoom(); - source = DPIUtil.autoScaleUp (device, source); - mask = DPIUtil.autoScaleUp (device, mask); mask = ImageData.convertMask (mask); ImageData image = new ImageData(source.width, source.height, source.depth, source.palette, source.scanlinePad, source.data); image.maskPad = mask.scanlinePad; @@ -525,7 +520,6 @@ public Image(Device device, InputStream stream) { super(device); ImageData data = new ImageData(stream); currentDeviceZoom = DPIUtil.getDeviceZoom(); - data = DPIUtil.autoScaleUp (device, data); init(data); init(); } @@ -568,7 +562,6 @@ public Image(Device device, String filename) { ImageData data = new ImageData(filename); currentDeviceZoom = DPIUtil.getDeviceZoom(); - data = DPIUtil.autoScaleUp (device, data); init(data); init(); } @@ -722,19 +715,6 @@ boolean refreshImageForZoom () { refreshed = true; currentDeviceZoom = deviceZoomLevel; } - } else { - if (!DPIUtil.useCairoAutoScale()) { - int deviceZoomLevel = deviceZoom; - if (deviceZoomLevel != currentDeviceZoom) { - ImageData data = getImageDataAtCurrentZoom(); - destroy (); - ImageData resizedData = DPIUtil.autoScaleImageData(device, data, deviceZoomLevel, currentDeviceZoom); - init(resizedData); - init(); - refreshed = true; - currentDeviceZoom = deviceZoomLevel; - } - } } return refreshed; } @@ -772,7 +752,7 @@ void createFromPixbuf(int type, long pixbuf) { // Initialize surface with dimensions received from the pixbuf and set device_scale appropriately surface = Cairo.cairo_image_surface_create(format, pixbufWidth, pixbufHeight); if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES); - if (DPIUtil.useCairoAutoScale()) Cairo.cairo_surface_set_device_scale(surface, scaleFactor, scaleFactor); + Cairo.cairo_surface_set_device_scale(surface, scaleFactor, scaleFactor); long data = Cairo.cairo_image_surface_get_data(surface); int cairoStride = Cairo.cairo_image_surface_get_stride(surface); @@ -946,27 +926,6 @@ public Color getBackground() { * */ public Rectangle getBounds() { - if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return DPIUtil.autoScaleDown(getBoundsInPixels()); -} - -/** - * Returns the bounds of the receiver. The rectangle will always - * have x and y values of 0, and the width and height of the - * image in pixels. - * - * @return a rectangle specifying the image's bounds in pixels. - * - * @exception SWTException - * @since 3.105 - * @deprecated This API doesn't serve the purpose in an environment having - * multiple monitors with different DPIs, hence deprecated. - */ -@Deprecated -public Rectangle getBoundsInPixels() { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (width != -1 && height != -1) { return new Rectangle(0, 0, width, height); @@ -1199,12 +1158,8 @@ void init(int width, int height) { if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES); // When we create a blank image we need to set it to 100 in GTK3 as we draw using 100% scale. // Cairo will take care of scaling for us when image needs to be scaled. - if (DPIUtil.useCairoAutoScale()) { - currentDeviceZoom = 100; - Cairo.cairo_surface_set_device_scale(surface, 1f, 1f); - } else { - currentDeviceZoom = DPIUtil.getDeviceZoom(); - } + currentDeviceZoom = 100; + Cairo.cairo_surface_set_device_scale(surface, 1f, 1f); long cairo = Cairo.cairo_create(surface); if (cairo == 0) SWT.error(SWT.ERROR_NO_HANDLES); Cairo.cairo_set_source_rgb(cairo, 1, 1, 1); @@ -1238,7 +1193,7 @@ void init(ImageData image) { // Initialize surface with dimensions received from the ImageData and set device_scale appropriately surface = Cairo.cairo_image_surface_create(format, imageDataWidth, imageDataHeight); if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES); - if (DPIUtil.useCairoAutoScale()) Cairo.cairo_surface_set_device_scale(surface, scaleFactor, scaleFactor); + Cairo.cairo_surface_set_device_scale(surface, scaleFactor, scaleFactor); int stride = Cairo.cairo_image_surface_get_stride(surface); long data = Cairo.cairo_image_surface_get_data(surface); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java index 283d19df049..b678ecfda6b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java @@ -15,7 +15,6 @@ import org.eclipse.swt.*; -import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.cairo.*; import org.eclipse.swt.internal.gtk.*; @@ -156,9 +155,6 @@ static void cairo_region_get_rectangles(long region, long [] rectangles, int[] n public void add (int[] pointArray) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - addInPixels(DPIUtil.autoScaleUp(pointArray)); -} -void addInPixels (int[] pointArray) { /* * Bug in GTK. If gdk_region_polygon() is called with one point, * it segment faults. The fix is to make sure that it is called @@ -187,10 +183,7 @@ void addInPixels (int[] pointArray) { public void add(Rectangle rect) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - addInPixels(DPIUtil.autoScaleUp(rect)); -} -void addInPixels(Rectangle rect) { - addInPixels (rect.x, rect.y, rect.width, rect.height); + add(rect.x, rect.y, rect.width, rect.height); } /** @@ -214,9 +207,6 @@ void addInPixels(Rectangle rect) { public void add(int x, int y, int width, int height) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - add(new Rectangle(x, y, width, height)); -} -void addInPixels(int x, int y, int width, int height) { cairo_rectangle_int_t rect = new cairo_rectangle_int_t(); rect.x = x; rect.y = y; @@ -262,9 +252,6 @@ public void add(Region region) { */ public boolean contains(int x, int y) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return contains(new Point(x, y)); -} -boolean containsInPixels(int x, int y) { return Cairo.cairo_region_contains_point(handle, x, y); } @@ -285,11 +272,8 @@ boolean containsInPixels(int x, int y) { */ public boolean contains(Point pt) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return containsInPixels(DPIUtil.autoScaleUp(pt)); -} -boolean containsInPixels(Point pt) { if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - return containsInPixels(pt.x, pt.y); + return contains(pt.x, pt.y); } @Override @@ -331,9 +315,6 @@ public boolean equals(Object object) { */ public Rectangle getBounds() { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return DPIUtil.autoScaleDown(getBoundsInPixels()); -} -Rectangle getBoundsInPixels() { cairo_rectangle_int_t rect = new cairo_rectangle_int_t(); Cairo.cairo_region_get_extents(handle, rect); return new Rectangle(rect.x, rect.y, rect.width, rect.height); @@ -393,11 +374,7 @@ public int hashCode() { public void intersect(Rectangle rect) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - intersectInPixels(DPIUtil.autoScaleUp(rect)); -} - -void intersectInPixels(Rectangle rect) { - intersectInPixels (rect.x, rect.y, rect.width, rect.height); + intersect(rect.x, rect.y, rect.width, rect.height); } /** @@ -421,10 +398,6 @@ void intersectInPixels(Rectangle rect) { public void intersect(int x, int y, int width, int height) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - intersect(new Rectangle(x, y, width, height)); -} - -void intersectInPixels(int x, int y, int width, int height) { cairo_rectangle_int_t rect = new cairo_rectangle_int_t(); rect.x = x; rect.y = y; @@ -478,10 +451,6 @@ public void intersect(Region region) { */ public boolean intersects (int x, int y, int width, int height) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return intersects(new Rectangle(x, y, width, height)); -} - -boolean intersectsInPixels (int x, int y, int width, int height) { cairo_rectangle_int_t rect = new cairo_rectangle_int_t(); rect.x = x; rect.y = y; @@ -509,11 +478,7 @@ boolean intersectsInPixels (int x, int y, int width, int height) { public boolean intersects(Rectangle rect) { if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return intersectsInPixels(DPIUtil.autoScaleUp(rect)); -} - -boolean intersectsInPixels(Rectangle rect) { - return intersectsInPixels(rect.x, rect.y, rect.width, rect.height); + return intersects(rect.x, rect.y, rect.width, rect.height); } /** @@ -565,10 +530,6 @@ public boolean isEmpty() { public void subtract (int[] pointArray) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - subtractInPixels(DPIUtil.autoScaleUp(pointArray)); -} - -void subtractInPixels (int[] pointArray) { /* * Bug in GTK. If gdk_region_polygon() is called with one point, * it segment faults. The fix is to make sure that it is called @@ -598,11 +559,7 @@ void subtractInPixels (int[] pointArray) { public void subtract(Rectangle rect) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - subtractInPixels(DPIUtil.autoScaleUp(rect)); -} - -void subtractInPixels(Rectangle rect) { - subtractInPixels (rect.x, rect.y, rect.width, rect.height); + subtract(rect.x, rect.y, rect.width, rect.height); } /** @@ -626,10 +583,6 @@ void subtractInPixels(Rectangle rect) { public void subtract(int x, int y, int width, int height) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - subtract(new Rectangle(x, y, width, height)); -} - -void subtractInPixels(int x, int y, int width, int height) { cairo_rectangle_int_t rect = new cairo_rectangle_int_t (); rect.x = x; rect.y = y; @@ -682,10 +635,6 @@ public void translate (int x, int y) { translate(new Point(x, y)); } -void translateInPixels (int x, int y) { - Cairo.cairo_region_translate (handle, x, y); -} - /** * Translate all of the polygons the receiver maintains to describe * its area by the specified point. @@ -704,8 +653,7 @@ void translateInPixels (int x, int y) { public void translate (Point pt) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - pt = DPIUtil.autoScaleUp(pt); - translateInPixels(pt.x, pt.y); + Cairo.cairo_region_translate (handle, pt.x, pt.y); } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java index a0eb06dee5e..7313a8f8d5e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java @@ -107,9 +107,9 @@ public FontMetrics getFixedLineMetrics(Device device) { } FontMetrics result = new FontMetrics(); - result.ascentInPoints = DPIUtil.autoScaleDown(device, lineMetricsInPixels.ascentInPoints); - result.descentInPoints = DPIUtil.autoScaleDown(device, lineMetricsInPixels.descentInPoints); - result.averageCharWidthInPoints = DPIUtil.autoScaleDown(device, lineMetricsInPixels.averageCharWidthInPoints); + result.ascentInPoints = lineMetricsInPixels.ascentInPoints; + result.descentInPoints = lineMetricsInPixels.descentInPoints; + result.averageCharWidthInPoints = lineMetricsInPixels.averageCharWidthInPoints; return result; } @@ -121,9 +121,9 @@ public void setFixedLineMetrics(Device device, FontMetrics metrics) { } FontMetrics result = new FontMetrics(); - result.ascentInPoints = DPIUtil.autoScaleUp(device, metrics.ascentInPoints); - result.descentInPoints = DPIUtil.autoScaleUp(device, metrics.descentInPoints); - result.averageCharWidthInPoints = DPIUtil.autoScaleUp(device, metrics.averageCharWidthInPoints); + result.ascentInPoints = metrics.ascentInPoints; + result.descentInPoints = metrics.descentInPoints; + result.averageCharWidthInPoints = metrics.averageCharWidthInPoints; lineMetricsInPixels = result; } @@ -296,8 +296,8 @@ void computeRuns () { boolean useMinAscentDescent = !metricsAdapter.isFixedMetrics() && (ascentInPoints != -1 || descentInPoints != -1); if (useMinAscentDescent && segementsLength > 0) { PangoRectangle rect = new PangoRectangle(); - if (ascentInPoints != -1) rect.y = -(DPIUtil.autoScaleUp(getDevice(), ascentInPoints) * OS.PANGO_SCALE); - rect.height = DPIUtil.autoScaleUp(getDevice(), (Math.max(0, ascentInPoints) + Math.max(0, descentInPoints))) * OS.PANGO_SCALE; + if (ascentInPoints != -1) rect.y = -(ascentInPoints * OS.PANGO_SCALE); + rect.height = (Math.max(0, ascentInPoints) + Math.max(0, descentInPoints)) * OS.PANGO_SCALE; int lineCount = OS.pango_layout_get_line_count(layout); chars = new char[segementsLength + lineCount * 2]; lineOffsets = new int [lineCount]; @@ -481,9 +481,9 @@ void computeRuns () { GlyphMetrics metrics = style.metrics; if (metrics != null) { PangoRectangle rect = new PangoRectangle(); - rect.y = -(DPIUtil.autoScaleUp(getDevice(), metrics.ascent) * OS.PANGO_SCALE); - rect.height = DPIUtil.autoScaleUp(getDevice(), (metrics.ascent + metrics.descent)) * OS.PANGO_SCALE; - rect.width = DPIUtil.autoScaleUp(getDevice(), metrics.width) * OS.PANGO_SCALE; + rect.y = -(metrics.ascent) * OS.PANGO_SCALE; + rect.height = (metrics.ascent + metrics.descent) * OS.PANGO_SCALE; + rect.width = metrics.width * OS.PANGO_SCALE; long attr = OS.pango_attr_shape_new (rect, rect); OS.memmove (attribute, attr, PangoAttribute.sizeof); attribute.start_index = byteStart; @@ -494,7 +494,7 @@ void computeRuns () { } int rise = style.rise; if (rise != 0) { - long attr = OS.pango_attr_rise_new (DPIUtil.autoScaleUp(getDevice(), rise) * OS.PANGO_SCALE); + long attr = OS.pango_attr_rise_new (rise * OS.PANGO_SCALE); OS.memmove (attribute, attr, PangoAttribute.sizeof); attribute.start_index = byteStart; attribute.end_index = byteEnd; @@ -559,13 +559,7 @@ void destroy() { * */ public void draw(GC gc, int x, int y) { - x = DPIUtil.autoScaleUp(getDevice(), x); - y = DPIUtil.autoScaleUp(getDevice(), y); - drawInPixels(gc, x, y); -} - -void drawInPixels(GC gc, int x, int y) { - drawInPixels(gc, x, y, -1, -1, null, null); + draw(gc, x, y, -1, -1, null, null); } /** @@ -589,12 +583,7 @@ void drawInPixels(GC gc, int x, int y) { */ public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) { checkLayout (); - x = DPIUtil.autoScaleUp(getDevice(), x); - y = DPIUtil.autoScaleUp(getDevice(), y); - drawInPixels(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground); -} -void drawInPixels(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) { - drawInPixels(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground, 0); + draw(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground, 0); } /** @@ -625,12 +614,6 @@ void drawInPixels(GC gc, int x, int y, int selectionStart, int selectionEnd, Col * @since 3.3 */ public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground, int flags) { - checkLayout (); - x = DPIUtil.autoScaleUp(getDevice(), x); - y = DPIUtil.autoScaleUp(getDevice(), y); - drawInPixels(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground, flags); -} -void drawInPixels(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground, int flags) { checkLayout (); computeRuns(); if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); @@ -685,7 +668,7 @@ void drawInPixels(GC gc, int x, int y, int selectionStart, int selectionEnd, Col int lineY = y + OS.PANGO_PIXELS(rect.y); int height = OS.PANGO_PIXELS(rect.height); if (ascentInPoints != -1 && descentInPoints != -1) { - height = Math.max (height, DPIUtil.autoScaleUp(getDevice(), ascentInPoints + descentInPoints)); + height = Math.max (height, ascentInPoints + descentInPoints); } int width = (flags & SWT.FULL_SELECTION) != 0 ? 0x7fff : height / 3; Cairo.cairo_rectangle(cairo, lineX, lineY, width, height); @@ -907,11 +890,7 @@ public int getAscent () { * @see #getLineBounds(int) */ public Rectangle getBounds() { - int spacingInPixels = getSpacingInPixels(); - return DPIUtil.autoScaleDown(getDevice(), getBoundsInPixels(spacingInPixels)); -} - -Rectangle getBoundsInPixels(int spacingInPixels) { + int spacing = getSpacing(); checkLayout(); computeRuns(); int[] w = new int[1], h = new int[1]; @@ -921,9 +900,9 @@ Rectangle getBoundsInPixels(int spacingInPixels) { int width = OS.PANGO_PIXELS(w[0]); int height = OS.PANGO_PIXELS(h[0]); if (ascentInPoints != -1 && descentInPoints != -1) { - height = Math.max (height, DPIUtil.autoScaleUp(getDevice(), ascentInPoints + descentInPoints)); + height = Math.max (height, ascentInPoints + descentInPoints); } - height += spacingInPixels; + height += spacing; return new Rectangle(0, 0, width, height + getScaledVerticalIndent()); } @@ -942,11 +921,6 @@ Rectangle getBoundsInPixels(int spacingInPixels) { * */ public Rectangle getBounds(int start, int end) { - checkLayout(); - return DPIUtil.autoScaleDown(getDevice(), getBoundsInPixels(start, end)); -} - -Rectangle getBoundsInPixels(int start, int end) { checkLayout(); computeRuns(); int length = text.length(); @@ -1049,10 +1023,6 @@ public Font getFont () { */ public int getIndent () { checkLayout(); - return DPIUtil.autoScaleDown(getDevice(), getIndentInPixels()); -} - -int getIndentInPixels () { return indent; } @@ -1131,10 +1101,6 @@ public int getLevel(int offset) { */ public Rectangle getLineBounds(int lineIndex) { checkLayout(); - return DPIUtil.autoScaleDown(getDevice(), getLineBoundsInPixels(lineIndex)); -} - -Rectangle getLineBoundsInPixels(int lineIndex) { computeRuns(); int lineCount = OS.pango_layout_get_line_count(layout); if (!(0 <= lineIndex && lineIndex < lineCount)) SWT.error(SWT.ERROR_INVALID_RANGE); @@ -1142,12 +1108,6 @@ Rectangle getLineBoundsInPixels(int lineIndex) { for (int i = 0; i < lineIndex; i++) { OS.pango_layout_iter_next_line(iter); } - Rectangle lineBoundsInPixels = getLineBoundsInPixels(lineIndex, iter); - OS.pango_layout_iter_free(iter); - return lineBoundsInPixels; -} - -private Rectangle getLineBoundsInPixels(int lineIndex, long iter) { if (iter == 0) SWT.error(SWT.ERROR_NO_HANDLES); PangoRectangle rect = new PangoRectangle(); metricsAdapter.pango_layout_iter_get_line_extents(iter, null, rect); @@ -1156,10 +1116,12 @@ private Rectangle getLineBoundsInPixels(int lineIndex, long iter) { int width = OS.PANGO_PIXELS(rect.width); int height = OS.PANGO_PIXELS(rect.height); if (ascentInPoints != -1 && descentInPoints != -1) { - height = Math.max (height, DPIUtil.autoScaleUp(getDevice(), ascentInPoints + descentInPoints)); + height = Math.max (height, ascentInPoints + descentInPoints); } x += Math.min (indent, wrapIndent); - return new Rectangle(x, y, width, height); + Rectangle lineBounds = new Rectangle(x, y, width, height); + OS.pango_layout_iter_free(iter); + return lineBounds; } /** @@ -1245,14 +1207,14 @@ public FontMetrics getLineMetrics (int lineIndex) { long metrics = OS.pango_context_get_metrics(context, font, lang); int ascent = OS.pango_font_metrics_get_ascent(metrics); int descent = OS.pango_font_metrics_get_descent(metrics); - ascentInPoints = DPIUtil.autoScaleDown(getDevice(), OS.PANGO_PIXELS(ascent)); - heightInPoints = DPIUtil.autoScaleDown(getDevice(), OS.PANGO_PIXELS(ascent + descent)); + ascentInPoints = OS.PANGO_PIXELS(ascent); + heightInPoints = OS.PANGO_PIXELS(ascent + descent); OS.pango_font_metrics_unref(metrics); } else { PangoRectangle rect = new PangoRectangle(); metricsAdapter.pango_layout_line_get_extents(OS.pango_layout_get_line(layout, lineIndex), null, rect); - ascentInPoints = DPIUtil.autoScaleDown(getDevice(), OS.PANGO_PIXELS(-rect.y)); - heightInPoints = DPIUtil.autoScaleDown(getDevice(), OS.PANGO_PIXELS(rect.height)); + ascentInPoints = OS.PANGO_PIXELS(-rect.y); + heightInPoints = OS.PANGO_PIXELS(rect.height); } heightInPoints = Math.max(this.ascentInPoints + this.descentInPoints, heightInPoints); ascentInPoints = Math.max(this.ascentInPoints, ascentInPoints); @@ -1310,10 +1272,6 @@ public int[] getLineOffsets() { */ public Point getLocation(int offset, boolean trailing) { checkLayout(); - return DPIUtil.autoScaleDown(getDevice(), getLocationInPixels(offset, trailing)); -} - -Point getLocationInPixels(int offset, boolean trailing) { computeRuns(); int length = text.length(); if (!(0 <= offset && offset <= length)) SWT.error(SWT.ERROR_INVALID_RANGE); @@ -1449,43 +1407,9 @@ int _getOffset (int offset, int movement, boolean forward) { */ public int getOffset(Point point, int[] trailing) { checkLayout(); - return getOffsetInPixels(DPIUtil.autoScaleUp(getDevice(), point), trailing); -} - -int getOffsetInPixels(Point point, int[] trailing) { if (point == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - return getOffsetInPixels(point.x, point.y, trailing); -} - -/** - * Returns the character offset for the specified point. - * For a typical character, the trailing argument will be filled in to - * indicate whether the point is closer to the leading edge (0) or - * the trailing edge (1). When the point is over a cluster composed - * of multiple characters, the trailing argument will be filled with the - * position of the character in the cluster that is closest to - * the point. - * - * @param x the x coordinate of the point - * @param y the y coordinate of the point - * @param trailing the trailing buffer - * @return the character offset - * - * @exception IllegalArgumentException - * @exception SWTException - * - * @see #getLocation(int, boolean) - */ -public int getOffset(int x, int y, int[] trailing) { - checkLayout(); - return getOffset(new Point(x, y), trailing); -} - -int getOffsetInPixels(int x, int y, int[] trailing) { + int x = point.x; + int y = point.y; computeRuns(); if (trailing != null && trailing.length < 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT); x -= Math.min (indent, wrapIndent); @@ -1531,6 +1455,35 @@ int getOffsetInPixels(int x, int y, int[] trailing) { return untranslateOffset(offset); } +/** + * Returns the character offset for the specified point. + * For a typical character, the trailing argument will be filled in to + * indicate whether the point is closer to the leading edge (0) or + * the trailing edge (1). When the point is over a cluster composed + * of multiple characters, the trailing argument will be filled with the + * position of the character in the cluster that is closest to + * the point. + * + * @param x the x coordinate of the point + * @param y the y coordinate of the point + * @param trailing the trailing buffer + * @return the character offset + * + * @exception IllegalArgumentException + * @exception SWTException + * + * @see #getLocation(int, boolean) + */ +public int getOffset(int x, int y, int[] trailing) { + checkLayout(); + return getOffset(new Point(x, y), trailing); +} + +/** /** * Returns the orientation of the receiver. * @@ -1675,10 +1628,6 @@ String getSegmentsText() { */ public int getSpacing () { checkLayout(); - return DPIUtil.autoScaleDown(getDevice(), getSpacingInPixels()); -} - -int getSpacingInPixels () { return OS.PANGO_PIXELS(OS.pango_layout_get_spacing(layout)); } @@ -1707,7 +1656,7 @@ private int getScaledVerticalIndent() { if (verticalIndentInPoints == 0) { return verticalIndentInPoints; } - return DPIUtil.autoScaleUp(getDevice(), verticalIndentInPoints); + return verticalIndentInPoints; } /** @@ -1777,10 +1726,6 @@ public TextStyle[] getStyles () { */ public int[] getTabs() { checkLayout(); - return DPIUtil.autoScaleDown (getDevice(), getTabsInPixels ()); -} - -int[] getTabsInPixels () { return tabs; } @@ -1824,10 +1769,6 @@ public int getTextDirection () { */ public int getWidth () { checkLayout (); - return DPIUtil.autoScaleDown(getDevice(), getWidthInPixels()); -} - -int getWidthInPixels () { return wrapWidth; } @@ -1844,9 +1785,6 @@ int getWidthInPixels () { */ public int getWrapIndent () { checkLayout (); - return DPIUtil.autoScaleDown(getDevice(), getWrapIndentInPixels()); -} -int getWrapIndentInPixels () { return wrapIndent; } @@ -2031,11 +1969,6 @@ public void setFont (Font font) { * @since 3.2 */ public void setIndent (int indent) { - checkLayout (); - setIndentInPixels(DPIUtil.autoScaleUp(getDevice(), indent)); -} - -void setIndentInPixels (int indent) { checkLayout(); if (indent < 0) return; if (this.indent == indent) return; @@ -2105,10 +2038,6 @@ public void setOrientation(int orientation) { public void setSpacing (int spacing) { checkLayout(); if (spacing < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - setSpacingInPixels(DPIUtil.autoScaleUp(getDevice(), spacing)); -} - -void setSpacingInPixels (int spacing) { OS.pango_layout_set_spacing(layout, spacing * OS.PANGO_SCALE); } @@ -2328,10 +2257,6 @@ public void setStyle (TextStyle style, int start, int end) { public void setTabs(int[] tabs) { checkLayout(); if (this.tabs == null && tabs == null) return; - setTabsInPixels (DPIUtil.autoScaleUp (getDevice(), tabs)); -} - -void setTabsInPixels (int[] tabs) { if (Arrays.equals (this.tabs, tabs)) return; this.tabs = tabs; if (tabs == null) { @@ -2424,10 +2349,6 @@ public void setTextDirection (int textDirection) { public void setWidth (int width) { checkLayout (); if (width < -1 || width == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - setWidthInPixels(DPIUtil.autoScaleUp(getDevice(), width)); -} - -void setWidthInPixels (int width) { if (wrapWidth == width) return; freeRuns(); wrapWidth = width; @@ -2462,10 +2383,6 @@ void setWidth () { public void setWrapIndent (int wrapIndent) { checkLayout(); if (wrapIndent < 0) return; - setWrapIndentInPixels(DPIUtil.autoScaleUp(getDevice(), wrapIndent)); -} - -void setWrapIndentInPixels (int wrapIndent) { if (this.wrapIndent == wrapIndent) return; this.wrapIndent = wrapIndent; OS.pango_layout_set_indent(layout, (indent - wrapIndent) * OS.PANGO_SCALE);