Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSravan Kumar Lakkimsetti2015-03-13 08:25:41 +0000
committerSravan Kumar Lakkimsetti2015-03-13 08:25:41 +0000
commitab7109c043e8c85185e52688b13da46fc3bccf7a (patch)
tree7c021901bf1f6bcc24c7713f765938410339a6c6
parent8d77310008829ff9b19d48e0ac62dc181237e309 (diff)
parent67701709fd5382aeed1c026ff7a97e650beed1e6 (diff)
downloadeclipse.platform.swt-ab7109c043e8c85185e52688b13da46fc3bccf7a.tar.gz
eclipse.platform.swt-ab7109c043e8c85185e52688b13da46fc3bccf7a.tar.xz
eclipse.platform.swt-ab7109c043e8c85185e52688b13da46fc3bccf7a.zip
Merge branch 'slakkimsetti/hiDpiBranch2' of
ssh://slakkimsetti@git.eclipse.org/gitroot/platform/eclipse.platform.swt.git into slakkimsetti/hiDpiBranch2 Conflicts: bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java Change-Id: I488fae8dda5aad53bc7bc32479ebfdadc1df9292 Signed-off-by: Sravan Kumar Lakkimsetti <sravankumarl@in.ibm.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/DPIUtil.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java18
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java55
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java41
5 files changed, 83 insertions, 38 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/DPIUtil.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/DPIUtil.java
index c99993b526..c97b21a575 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/DPIUtil.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/DPIUtil.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.swt.graphics;
-import java.io.*;
-
/**
* This class hold common constants and utility functions w.r.t. to SWT high DPI
* functionality.
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 4a211a8a59..e53a6965a9 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,6 +15,7 @@ import org.eclipse.swt.internal.cairo.*;
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
/**
* Class <code>GC</code> is where all of the drawing capabilities that are
@@ -875,12 +876,10 @@ public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeig
}
void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) {
+ /* Refresh Image zoom level if required. */
+ srcImage.refreshImageZoomLevel ();
+
int imgWidth, imgHeight;
- boolean imageRepFound = true;
- int zoom = DPIUtil.mapDPIToZoom (device.getActualDPI ());
- if (zoom != srcImage.currentZoomLevel) {
- imageRepFound = srcImage.initImageForZoomLevel(zoom);
- }
if (OS.USE_CAIRO){
imgWidth = srcImage.width;
imgHeight = srcImage.height;
@@ -1012,11 +1011,8 @@ void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight,
}
}
void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, int imgWidth, int imgHeight) {
- boolean imageRepFound = true;
- int zoom = DPIUtil.mapDPIToZoom (device.getActualDPI ());
- if (zoom != srcImage.currentZoomLevel) {
- imageRepFound = srcImage.initImageForZoomLevel(zoom);
- }
+ /* Refresh Image zoom level if required. */
+ srcImage.refreshImageZoomLevel ();
if (srcWidth == destWidth && srcHeight == destHeight) {
OS.gdk_draw_drawable(data.drawable, handle, srcImage.pixmap, srcX, srcY, destX, destY, destWidth, destHeight);
} else {
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 deaa97ece0..d6fe0aa5de 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
@@ -15,6 +15,7 @@ import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
import java.io.*;
@@ -172,9 +173,9 @@ public final class Image extends Resource implements Drawable {
ImageDataProvider imageDataProviderObject = null;
/**
- * attribute to cache current level
+ * Attribute to cache image zoom level
*/
- int currentZoomLevel = 100;
+ int imageZoomLevel = 100;
Image(Device device) {
super(device);
@@ -715,8 +716,8 @@ public Image(Device device, String filename) {
public Image(Device device, FileNameImageProvider fileNameProvider) {
super(device);
fileNameImageProviderObject = fileNameProvider;
- currentZoomLevel = DPIUtil.mapDPIToZoom(device.getActualDPI());
- String filename = fileNameImageProviderObject.getImagePath(currentZoomLevel);
+ imageZoomLevel = getDeviceZoom ();
+ String filename = fileNameImageProviderObject.getImagePath(imageZoomLevel);
if (filename == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
initNative (filename);
if (this.pixmap == 0 && this.surface == 0) init(new ImageData(filename));
@@ -754,12 +755,40 @@ public Image(Device device, FileNameImageProvider fileNameProvider) {
public Image(Device device, ImageDataProvider imageDataProvider) {
super(device);
imageDataProviderObject = imageDataProvider;
- currentZoomLevel = DPIUtil.mapDPIToZoom (device.getActualDPI ());
- ImageData data = imageDataProviderObject.getImageData (currentZoomLevel);
+ imageZoomLevel = getDeviceZoom ();
+ ImageData data = imageDataProviderObject.getImageData (imageZoomLevel);
init (data);
init ();
}
+int getDeviceZoom () {
+ return DPIUtil.mapDPIToZoom (device.getActualDPI ());
+}
+
+/**
+ * Refreshes the zoom level of the image if required.
+ *
+ * @param image to be refreshed
+ * @return true if zoom level is refreshed
+ */
+boolean refreshImageZoomLevel () {
+ int deviceZoomLevel = getDeviceZoom();
+ if (deviceZoomLevel != imageZoomLevel) {
+ if (fileNameImageProviderObject != null) {
+ String filename = fileNameImageProviderObject.getImagePath(deviceZoomLevel);
+ initNative(filename);
+ } else if (imageDataProviderObject != null) {
+ ImageData data = imageDataProviderObject.getImageData(deviceZoomLevel);
+ init(data);
+ } else {
+ return false;
+ }
+ imageZoomLevel = deviceZoomLevel;
+ return true;
+ }
+ return false;
+}
+
void initNative(String filename) {
try {
int length = filename.length ();
@@ -1789,18 +1818,4 @@ public String toString () {
}
}
-boolean initImageForZoomLevel (int zoom) {
- if (fileNameImageProviderObject != null) {
- String filename = fileNameImageProviderObject.getImagePath (zoom);
- initNative (filename);
- } else if (imageDataProviderObject != null) {
- ImageData data = imageDataProviderObject.getImageData (zoom);
- init (data);
- } else {
- return false;
- }
- currentZoomLevel = zoom;
- return true;
-}
-
}
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 3f5c352ae3..177327235f 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -946,6 +946,9 @@ public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeig
}
void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) {
+ /* Refresh Image zoom level if required. */
+ srcImage.refreshImageZoomLevel ();
+
if (data.gdipGraphics != 0) {
//TODO - cache bitmap
long /*int*/ [] gdipImage = srcImage.createGdipImage();
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 aa199e5dc6..e2414eb9fa 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
@@ -134,6 +134,11 @@ public final class Image extends Resource implements Drawable {
ImageDataProvider imageDataProvider;
/**
+ * Attribute to cache image zoom level
+ */
+ int imageZoomLevel = 100;
+
+ /**
* width of the image
*/
int width = -1;
@@ -657,8 +662,8 @@ public Image(Device device, FileNameImageProvider fileNameProvider) {
super(device);
if (fileNameProvider == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
this.fileNameImageProvider = fileNameProvider;
-
- String fileName = fileNameImageProvider.getImagePath (getZoom ());
+ imageZoomLevel = getDeviceZoom ();
+ String fileName = fileNameImageProvider.getImagePath (imageZoomLevel);
if (fileName == null) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
initNative (fileName);
if (this.handle == 0) init(new ImageData (fileName));
@@ -697,14 +702,42 @@ public Image(Device device, ImageDataProvider imageDataProvider) {
super(device);
if (imageDataProvider == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
this.imageDataProvider = imageDataProvider;
- init(imageDataProvider.getImageData(getZoom()));
+ imageZoomLevel = getDeviceZoom ();
+ init(imageDataProvider.getImageData(imageZoomLevel));
init();
}
-int getZoom () {
+int getDeviceZoom () {
return DPIUtil.mapDPIToZoom (device.getDPI ().x);
}
+/**
+ * Refreshes the zoom level of the image if required.
+ *
+ * @param image to be refreshed
+ * @return true if zoom level is refreshed
+ */
+boolean refreshImageZoomLevel () {
+ int deviceZoomLevel = getDeviceZoom();
+ if (deviceZoomLevel != imageZoomLevel) {
+ if (fileNameImageProvider != null) {
+ String filename = fileNameImageProvider.getImagePath(deviceZoomLevel);
+ initNative(filename);
+ if (this.handle == 0) init(new ImageData (filename));
+ init();
+ } else if (imageDataProvider != null) {
+ ImageData data = imageDataProvider.getImageData(deviceZoomLevel);
+ init(data);
+ init();
+ } else {
+ return false;
+ }
+ imageZoomLevel = deviceZoomLevel;
+ return true;
+ }
+ return false;
+}
+
void initNative(String filename) {
boolean gdip = true;
try {

Back to the top