diff options
author | Sravan Kumar Lakkimsetti | 2015-11-02 12:12:10 +0000 |
---|---|---|
committer | Sravan Kumar Lakkimsetti | 2015-11-02 12:12:10 +0000 |
commit | 7f5fed5da6777be0061087841d45bc1a2341439f (patch) | |
tree | ed22264cd762aec044eff527a7470490f1012235 /bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse | |
parent | 9bb1c4786a4c9f317106a36812f6db815342d689 (diff) | |
download | eclipse.platform.swt-7f5fed5da6777be0061087841d45bc1a2341439f.tar.gz eclipse.platform.swt-7f5fed5da6777be0061087841d45bc1a2341439f.tar.xz eclipse.platform.swt-7f5fed5da6777be0061087841d45bc1a2341439f.zip |
Bug 399786 - [Cocoa][GTK][Win32][Retina] GC#draw*(..) needs to support
high-DPI images (was: Line numbers in editors are blurry)
- Windows Work
Change-Id: I7d4b2511ea55bfbdeab77a8581ac83ed6578c3e4
Signed-off-by: Sravan Kumar Lakkimsetti <sravankumarl@in.ibm.com>
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse')
3 files changed, 37 insertions, 4 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java index af0b77bae1..41049c884b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java @@ -67,6 +67,9 @@ public abstract class Device implements Drawable { String[] loadedFonts; boolean disposed; + + /* Auto-Scaling*/ + boolean enableAutoScaling = true; /* * TEMPORARY CODE. When a graphics object is @@ -989,4 +992,12 @@ public void setWarnings (boolean warnings) { checkDevice (); } +boolean getEnableAutoScaling() { + return enableAutoScaling; +} + +void setEnableAutoScaling(boolean value) { + enableAutoScaling = value; +} + } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java index 11e15b241d..91c7710806 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java @@ -644,6 +644,7 @@ static void destroyGdipBrush(long /*int*/ brush) { * <li>ERROR_THREAD_INVALID_ACCESS if not called from the thread that created the drawable</li> * </ul> */ +@Override void destroy() { boolean gdip = data.gdipGraphics != 0; disposeGdip(); @@ -1992,6 +1993,11 @@ public void drawRectangle (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); + if (this.getEnableAutoScaling ()) { + float scaleFactor = this.getDeviceZoom() / 100; + width = (int)(width * scaleFactor); + height = (int)(height * scaleFactor); + } checkGC(DRAW); if (data.gdipGraphics != 0) { drawRoundRectangleGdip(data.gdipGraphics, data.gdipPen, x, y, width, height, arcWidth, arcHeight); @@ -2649,6 +2655,7 @@ void drawTextGDIP(long /*int*/ gdipGraphics, String string, int x, int y, int fl * * @see #hashCode */ +@Override public boolean equals (Object object) { return (object == this) || ((object instanceof GC) && (handle == ((GC)object).handle)); } @@ -3015,6 +3022,11 @@ public void fillPolygon(int[] pointArray) { */ public void fillRectangle (int x, int y, int width, int height) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); + if (this.getEnableAutoScaling ()) { + float scaleFactor = this.getDeviceZoom() / 100; + width = (int)(width * scaleFactor); + height = (int)(height * scaleFactor); + } checkGC(FILL); if (data.gdipGraphics != 0) { if (width < 0) { @@ -3078,6 +3090,11 @@ public void fillRectangle (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); + if (this.getEnableAutoScaling ()) { + float scaleFactor = this.getDeviceZoom() / 100; + width = (int)(width * scaleFactor); + height = (int)(height * scaleFactor); + } checkGC(FILL); if (data.gdipGraphics != 0) { fillRoundRectangleGdip(data.gdipGraphics, data.gdipBrush, x, y, width, height, arcWidth, arcHeight); @@ -3981,6 +3998,7 @@ void init(Drawable drawable, GCData data, long /*int*/ hDC) { * * @see #equals */ +@Override public int hashCode () { return (int)/*64*/handle; } @@ -4025,6 +4043,7 @@ public boolean isClipped() { * * @return <code>true</code> when the GC is disposed and <code>false</code> otherwise */ +@Override public boolean isDisposed() { return handle == 0; } @@ -4812,6 +4831,7 @@ public void setLineWidth(int lineWidth) { * * @deprecated this functionality is not supported on some platforms */ +@Deprecated public void setXORMode(boolean xor) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); OS.SetROP2(handle, xor ? OS.R2_XORPEN : OS.R2_COPYPEN); @@ -5042,6 +5062,7 @@ public Point textExtent(String string, int flags) { * * @return a string representation of the receiver */ +@Override public String toString () { if (isDisposed()) return "GC {*DISPOSED*}"; return "GC {" + handle + "}"; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java index fac03abf10..3c9dd3d373 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java @@ -197,6 +197,11 @@ Image (Device device) { */ public Image(Device device, int width, int height) { super(device); + if (this.getEnableAutoScaling ()) { + float scaleFactor = this.getDeviceZoom() / 100; + width = (int)(width * scaleFactor); + height = (int)(height * scaleFactor); + } init(width, height); init(); } @@ -722,10 +727,6 @@ public Image(Device device, ImageDataProvider imageDataProvider) { init(); } -int getDeviceZoom () { - return DPIUtil.mapDPIToZoom (device._getDPIx ()); -} - /** * Refresh the Image based on the zoom level, if required. * |