Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormgolubev2020-07-22 16:04:24 +0000
committerNiraj Modi2020-09-11 08:02:18 +0000
commitc79e12b16b42d13e2ecba6144d5c4ddc6d96723a (patch)
tree407ed48adb418c006d3ecdaf2da87440b6bc1a56
parent03285ca2c39c48d86b22211483638f53c9a56da6 (diff)
downloadeclipse.platform.swt-c79e12b16b42d13e2ecba6144d5c4ddc6d96723a.tar.gz
eclipse.platform.swt-c79e12b16b42d13e2ecba6144d5c4ddc6d96723a.tar.xz
eclipse.platform.swt-c79e12b16b42d13e2ecba6144d5c4ddc6d96723a.zip
Bug 565439 - Path is printed incorrectly on Windows with scale != 100%
Resources should not autoscale if their device is not isAutoScalable + Transform may be created with device = null, in this case getDevice() call fails inside constructor, use `this.device` instead Change-Id: Idc6ab01107176dfe7ae725389a04c95b0f42d482 Signed-off-by: mgolubev <borlander@gmail.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java62
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Transform.java20
2 files changed, 48 insertions, 34 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java
index d63865c6d0..9ce1e1d2f5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java
@@ -199,10 +199,11 @@ public Path (Device device, PathData data) {
* </ul>
*/
public void addArc (float x, float y, float width, float height, float startAngle, float arcAngle) {
- x = DPIUtil.autoScaleUp(x);
- y = DPIUtil.autoScaleUp(y);
- width = DPIUtil.autoScaleUp(width);
- height = DPIUtil.autoScaleUp(height);
+ Drawable drawable = getDevice();
+ x = DPIUtil.autoScaleUp(drawable, x);
+ y = DPIUtil.autoScaleUp(drawable, y);
+ width = DPIUtil.autoScaleUp(drawable, width);
+ height = DPIUtil.autoScaleUp(drawable, height);
addArcInPixels(x, y, width, height, startAngle, arcAngle);
}
@@ -269,10 +270,11 @@ public void addPath(Path path) {
* </ul>
*/
public void addRectangle (float x, float y, float width, float height) {
- x = DPIUtil.autoScaleUp(x);
- y = DPIUtil.autoScaleUp(y);
- width = DPIUtil.autoScaleUp(width);
- height = DPIUtil.autoScaleUp(height);
+ Drawable drawable = getDevice();
+ x = DPIUtil.autoScaleUp(drawable, x);
+ y = DPIUtil.autoScaleUp(drawable, y);
+ width = DPIUtil.autoScaleUp(drawable, width);
+ height = DPIUtil.autoScaleUp(drawable, height);
addRectangleInPixels(x, y, width, height);
}
@@ -306,8 +308,9 @@ void addRectangleInPixels(float x, float y, float width, float height) {
* </ul>
*/
public void addString (String string, float x, float y, Font font) {
- x = DPIUtil.autoScaleUp(x);
- y = DPIUtil.autoScaleUp(y);
+ Drawable drawable = getDevice();
+ x = DPIUtil.autoScaleUp(drawable, x);
+ y = DPIUtil.autoScaleUp(drawable, y);
addStringInPixels(string, x, y, font);
}
@@ -378,8 +381,9 @@ public void close() {
* </ul>
*/
public boolean contains (float x, float y, GC gc, boolean outline) {
- x = DPIUtil.autoScaleUp(x);
- y = DPIUtil.autoScaleUp(y);
+ Drawable drawable = getDevice();
+ x = DPIUtil.autoScaleUp(drawable, x);
+ y = DPIUtil.autoScaleUp(drawable, y);
return containsInPixels(x, y, gc, outline);
}
@@ -414,12 +418,13 @@ boolean containsInPixels(float x, float y, GC gc, boolean outline) {
* </ul>
*/
public void cubicTo (float cx1, float cy1, float cx2, float cy2, float x, float y) {
- cx1 = DPIUtil.autoScaleUp(cx1);
- cy1 = DPIUtil.autoScaleUp(cy1);
- cx2 = DPIUtil.autoScaleUp(cx2);
- cy2 = DPIUtil.autoScaleUp(cy2);
- x = DPIUtil.autoScaleUp(x);
- y = DPIUtil.autoScaleUp(y);
+ Drawable drawable = getDevice();
+ cx1 = DPIUtil.autoScaleUp(drawable, cx1);
+ cy1 = DPIUtil.autoScaleUp(drawable, cy1);
+ cx2 = DPIUtil.autoScaleUp(drawable, cx2);
+ cy2 = DPIUtil.autoScaleUp(drawable, cy2);
+ x = DPIUtil.autoScaleUp(drawable, x);
+ y = DPIUtil.autoScaleUp(drawable, y);
cubicToInPixels(cx1, cy1, cx2, cy2, x, y);
}
@@ -453,7 +458,7 @@ void destroy() {
public void getBounds (float[] bounds) {
if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
getBoundsInPixels(bounds);
- float[] scaledbounds= DPIUtil.autoScaleDown(bounds);
+ float[] scaledbounds= DPIUtil.autoScaleDown(getDevice(), bounds);
System.arraycopy(scaledbounds, 0, bounds, 0, 4);
}
@@ -485,7 +490,7 @@ void getBoundsInPixels(float[] bounds) {
public void getCurrentPoint (float[] point) {
if (point == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
getCurrentPointInPixels(point);
- float[] scaledpoint= DPIUtil.autoScaleDown(point);
+ float[] scaledpoint= DPIUtil.autoScaleDown(getDevice(), point);
System.arraycopy(scaledpoint, 0, point, 0, 2);
}
@@ -510,7 +515,7 @@ void getCurrentPointInPixels(float[] point) {
public PathData getPathData() {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
PathData result = getPathDataInPixels();
- result.points = DPIUtil.autoScaleDown(result.points);
+ result.points = DPIUtil.autoScaleDown(getDevice(), result.points);
return result;
}
@@ -571,7 +576,8 @@ PathData getPathDataInPixels() {
* </ul>
*/
public void lineTo (float x, float y) {
- lineToInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y));
+ Drawable drawable = getDevice();
+ lineToInPixels(DPIUtil.autoScaleUp(drawable, x), DPIUtil.autoScaleUp(drawable, y));
}
void lineToInPixels(float x, float y) {
@@ -635,7 +641,8 @@ public boolean isDisposed() {
* </ul>
*/
public void moveTo (float x, float y) {
- moveToInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y));
+ Drawable drawable = getDevice();
+ moveToInPixels(DPIUtil.autoScaleUp(drawable, x), DPIUtil.autoScaleUp(drawable, y));
}
void moveToInPixels(float x, float y) {
@@ -658,10 +665,11 @@ void moveToInPixels(float x, float y) {
* </ul>
*/
public void quadTo (float cx, float cy, float x, float y) {
- cx = DPIUtil.autoScaleUp(cx);
- cy = DPIUtil.autoScaleUp(cy);
- x = DPIUtil.autoScaleUp(x);
- y = DPIUtil.autoScaleUp(y);
+ Drawable drawable = getDevice();
+ cx = DPIUtil.autoScaleUp(drawable, cx);
+ cy = DPIUtil.autoScaleUp(drawable, cy);
+ x = DPIUtil.autoScaleUp(drawable, x);
+ y = DPIUtil.autoScaleUp(drawable, y);
quadToInPixels(cx, cy, x, y);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Transform.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Transform.java
index 6e666ba735..f1294d59f2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Transform.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Transform.java
@@ -147,7 +147,8 @@ public Transform(Device device, float[] elements) {
public Transform (Device device, float m11, float m12, float m21, float m22, float dx, float dy) {
super(device);
this.device.checkGDIP();
- handle = Gdip.Matrix_new(m11, m12, m21, m22, DPIUtil.autoScaleUp(dx), DPIUtil.autoScaleUp(dy));
+ handle = Gdip.Matrix_new(m11, m12, m21, m22,
+ DPIUtil.autoScaleUp(this.device, dx), DPIUtil.autoScaleUp(this.device, dy));
if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
init();
}
@@ -183,8 +184,9 @@ public void getElements(float[] elements) {
if (elements == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (elements.length < 6) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
Gdip.Matrix_GetElements(handle, elements);
- elements[4] = DPIUtil.autoScaleDown(elements[4]);
- elements[5] = DPIUtil.autoScaleDown(elements[5]);
+ Drawable drawable = getDevice();
+ elements[4] = DPIUtil.autoScaleDown(drawable, elements[4]);
+ elements[5] = DPIUtil.autoScaleDown(drawable, elements[5]);
}
/**
@@ -315,7 +317,9 @@ 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);
- Gdip.Matrix_SetElements(handle, m11, m12, m21, m22, DPIUtil.autoScaleUp(dx), DPIUtil.autoScaleUp(dy));
+ Drawable drawable = getDevice();
+ Gdip.Matrix_SetElements(handle, m11, m12, m21, m22,
+ DPIUtil.autoScaleUp(drawable, dx), DPIUtil.autoScaleUp(drawable, dy));
}
/**
@@ -354,12 +358,13 @@ public void transform(float[] pointArray) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
int length = pointArray.length;
+ Drawable drawable = getDevice();
for (int i = 0; i < length; i++) {
- pointArray[i] = DPIUtil.autoScaleUp(pointArray[i]);
+ pointArray[i] = DPIUtil.autoScaleUp(drawable, pointArray[i]);
}
Gdip.Matrix_TransformPoints(handle, pointArray, length / 2);
for (int i = 0; i < length; i++) {
- pointArray[i] = DPIUtil.autoScaleDown(pointArray[i]);
+ pointArray[i] = DPIUtil.autoScaleDown(drawable, pointArray[i]);
}
}
@@ -376,7 +381,8 @@ public void transform(float[] pointArray) {
*/
public void translate(float offsetX, float offsetY) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- Gdip.Matrix_Translate(handle, DPIUtil.autoScaleUp(offsetX), DPIUtil.autoScaleUp(offsetY), Gdip.MatrixOrderPrepend);
+ Drawable drawable = getDevice();
+ Gdip.Matrix_Translate(handle, DPIUtil.autoScaleUp(drawable, offsetX), DPIUtil.autoScaleUp(drawable, offsetY), Gdip.MatrixOrderPrepend);
}
/**

Back to the top