Bug 421383 - [Graphics] Scaling issues on high DPI displays
authorMarkus Keller <markus_keller@ch.ibm.com>
Thu, 23 Apr 2015 21:55:12 +0000 (23:55 +0200)
committerMarkus Keller <markus_keller@ch.ibm.com>
Thu, 23 Apr 2015 21:55:12 +0000 (23:55 +0200)
fixed "loadURLImageDescriptorDirectly" debug option for HighDPI

bundles/org.eclipse.jface/src/org/eclipse/jface/resource/URLImageDescriptor.java

index 71ccf65..403097f 100644 (file)
@@ -49,7 +49,7 @@ class URLImageDescriptor extends ImageDescriptor {
                        URL xUrl = getxURL(url, zoom);
                        if (xUrl == null)
                                return null;
-                       return getFilePath(xUrl); // can be null!
+                       return getFilePath(xUrl, zoom == 100); // can be null!
                }
        }
 
@@ -136,9 +136,11 @@ class URLImageDescriptor extends ImageDescriptor {
 
        private static InputStream getStream(URL url) {
                try {
-                       URL platformURL = FileLocator.find(url);
-                       if (platformURL != null) {
-                               url = platformURL;
+                       if (InternalPolicy.OSGI_AVAILABLE) {
+                               URL platformURL = FileLocator.find(url);
+                               if (platformURL != null) {
+                                       url = platformURL;
+                               }
                        }
                        return new BufferedInputStream(url.openStream());
                } catch (IOException e) {
@@ -191,7 +193,7 @@ class URLImageDescriptor extends ImageDescriptor {
         *
         * @return {@link String} or <code>null</code> if the file cannot be found
         */
-       private static String getFilePath(URL url) {
+       private static String getFilePath(URL url, boolean logIOException) {
 
                try {
                        if (!InternalPolicy.OSGI_AVAILABLE) {
@@ -200,13 +202,19 @@ class URLImageDescriptor extends ImageDescriptor {
                                return null;
                        }
 
+                       URL platformURL = FileLocator.find(url);
+                       if (platformURL != null) {
+                               url = platformURL;
+                       }
                        URL locatedURL = FileLocator.toFileURL(url);
                        if (FILE_PROTOCOL.equalsIgnoreCase(locatedURL.getProtocol()))
                                return new Path(locatedURL.getPath()).toOSString();
                        return null;
 
                } catch (IOException e) {
-                       Policy.logException(e);
+                       if (logIOException) {
+                               Policy.logException(e);
+                       }
                        return null;
                }
        }
@@ -221,7 +229,7 @@ class URLImageDescriptor extends ImageDescriptor {
                try {
 
                        if (InternalPolicy.DEBUG_LOAD_URL_IMAGE_DESCRIPTOR_2x) {
-                               if (InternalPolicy.DEBUG_LOAD_URL_IMAGE_DESCRIPTOR_DIRECTLY) {
+                               if (!InternalPolicy.DEBUG_LOAD_URL_IMAGE_DESCRIPTOR_DIRECTLY) {
                                        try {
                                                return new Image(device, new URLImageFileNameProvider(url));
                                        } catch (SWTException exception) {
@@ -256,7 +264,7 @@ class URLImageDescriptor extends ImageDescriptor {
                        }
 
                        // Try to see if we can optimize using SWTs file based image support.
-                       String path = getFilePath(url);
+                       String path = getFilePath(url, true);
                        if (path != null) {
                                try {
                                        return new Image(device, path);