Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSravan Kumar Lakkimsetti2018-05-21 04:24:07 -0400
committerSravan Kumar Lakkimsetti2018-05-21 07:05:54 -0400
commit809b38a9c2e5537b4a532a4680f7fc06d8c7dbb2 (patch)
tree5e8d66b1dcf7e937ec35ffe89bf8c668269ec954
parenta675ff4e3da41e9ffc9fd6b1d7acc3a1ad723b3c (diff)
downloadeclipse.platform.swt-809b38a9c2e5537b4a532a4680f7fc06d8c7dbb2.tar.gz
eclipse.platform.swt-809b38a9c2e5537b4a532a4680f7fc06d8c7dbb2.tar.xz
eclipse.platform.swt-809b38a9c2e5537b4a532a4680f7fc06d8c7dbb2.zip
Bug 534817 - screenshots do not change
Change-Id: I8cf7d72ab79e6dc04a456da999c8901cf2f4d2a6 Signed-off-by: Sravan Kumar Lakkimsetti <sravankumarl@in.ibm.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java10
2 files changed, 12 insertions, 9 deletions
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);

Back to the top