diff options
author | Sravan Kumar Lakkimsetti | 2018-06-08 08:03:21 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2018-06-08 11:04:00 +0000 |
commit | 760d4189c5271fd829273566b99655a359a7676c (patch) | |
tree | be56b41dfd3f1abe8331a0c45755e24f95bd1916 | |
parent | 741ada7ac98f21df7aa97e5cc12c8778d581899b (diff) | |
download | eclipse.platform.swt-760d4189c5271fd829273566b99655a359a7676c.tar.gz eclipse.platform.swt-760d4189c5271fd829273566b99655a359a7676c.tar.xz eclipse.platform.swt-760d4189c5271fd829273566b99655a359a7676c.zip |
Bug 535123 - [HiDPI][GTK3] Black bands visible in Eclipse UI on x2
display
Fixes black band issues in snippet 365 and tool bars and CTabFolder.
Revert "Revert "Bug 534817 - screenshots do not change""
This reverts commit 742c1cbd39bb33d4c9827db948582faef531b1ba.
This revert fixes SWTBot problem in capturing screenshots
Change-Id: Ibd8dc7ae70befe6db98d89e9d76f7ce68e7ffc8f
Signed-off-by: Sravan Kumar Lakkimsetti <sravankumarl@in.ibm.com>
3 files changed, 17 insertions, 9 deletions
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 61894e9490..8eebf8d42a 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 @@ -1562,6 +1562,11 @@ void fillGradientRectangleInPixels(int x, int y, int width, int height, boolean fromRGB = backgroundRGB; toRGB = foregroundRGB; } + if (vertical) { + width = width * (DPIUtil.getDeviceZoom() / 100); + } else { + height = height * (DPIUtil.getDeviceZoom() / 100); + } if (fromRGB.equals(toRGB)) { fillRectangleInPixels(x, y, width, height); return; 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 8301156deb..1c31c6dc61 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 @@ -1390,18 +1390,15 @@ void init(int width, int height) { this.type = SWT.BITMAP; /* Create the pixmap */ - if (GTK.GTK3) { - surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_FORMAT_ARGB32, width, height); - } else { - surface = GDK.gdk_window_create_similar_surface(GDK.gdk_get_default_root_window(), Cairo.CAIRO_CONTENT_COLOR, width, height); - } + surface = GDK.gdk_window_create_similar_surface(GDK.gdk_get_default_root_window(), Cairo.CAIRO_CONTENT_COLOR, width, 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 don't scale here. - // Cairo will scale for us + // 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 (!GTK.GTK3) { currentDeviceZoom = DPIUtil.getDeviceZoom(); } else { currentDeviceZoom = 100; + Cairo.cairo_surface_set_device_scale(surface, 1f, 1f); } long /*int*/ cairo = Cairo.cairo_create(surface); if (cairo == 0) SWT.error(SWT.ERROR_NO_HANDLES); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java index a611073ea1..0f38b3fec0 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java @@ -34,9 +34,15 @@ public static long /*int*/ convertSurface(Image image) { int format = Cairo.cairo_surface_get_content(newSurface) == Cairo.CAIRO_CONTENT_COLOR ? Cairo.CAIRO_FORMAT_RGB24 : Cairo.CAIRO_FORMAT_ARGB32; newSurface = Cairo.cairo_image_surface_create(format, bounds.width, bounds.height); if (newSurface == 0) SWT.error(SWT.ERROR_NO_HANDLES); + //retain device scale set in the original surface if (GTK.GTK3) { - double scaleFactor = DPIUtil.getDeviceZoom() / 100f; - Cairo.cairo_surface_set_device_scale(newSurface, scaleFactor, scaleFactor); + double sx[] = new double[1]; + double sy[] = new double[1]; + Cairo.cairo_surface_get_device_scale(image.surface, sx, sy); + if (sx[0] == 0 || sy[0] == 0){ + sx[0] = sy[0] = DPIUtil.getDeviceZoom() / 100f; + } + Cairo.cairo_surface_set_device_scale(newSurface, sx[0], sy[0]); } long /*int*/ cairo = Cairo.cairo_create(newSurface); if (cairo == 0) SWT.error(SWT.ERROR_NO_HANDLES); |