changeset 1620:51a85b7f59c2

Fix RT-29164: Port Hi-DPI display support to FX 2.2.X
author flar <James.Graham@oracle.com>
date Mon, 20 May 2013 23:12:27 -0700
parents 4ea478033ced
children 8deb0a939463
files javafx-ui-common/src/com/sun/javafx/tk/PlatformImage.java javafx-ui-common/src/javafx/scene/canvas/GraphicsContext.java javafx-ui-common/src/javafx/scene/image/Image.java test-stub-toolkit/src/com/sun/javafx/pgstub/StubFilterable.java test-stub-toolkit/src/com/sun/javafx/pgstub/StubPlatformImage.java
diffstat 5 files changed, 29 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/com/sun/javafx/tk/PlatformImage.java	Wed May 08 14:29:33 2013 -0700
+++ b/javafx-ui-common/src/com/sun/javafx/tk/PlatformImage.java	Mon May 20 23:12:27 2013 -0700
@@ -38,6 +38,16 @@
  */
 public interface PlatformImage {
     /**
+     * Gets the scale representing how large an area a 72DPI virtual
+     * pixel covers in terms of the pixels of this image.
+     * A 72DPI platform image would return 1.0f.
+     * A 144DPI platform image would return 2.0f.
+     * 
+     * @return the number of actual image pixels per 72DPI virtual pixel
+     */
+    public float getPixelScale();
+
+    /**
      * @param x X coordinate of pixel
      * @param y Y coordinate of pixel
      * @return the non-premultiplied pixel in integer ARGB component ordering.
--- a/javafx-ui-common/src/javafx/scene/canvas/GraphicsContext.java	Wed May 08 14:29:33 2013 -0700
+++ b/javafx-ui-common/src/javafx/scene/canvas/GraphicsContext.java	Mon May 20 23:12:27 2013 -0700
@@ -330,6 +330,7 @@
         if (close) {
             buf.putByte(PGCanvas.CLOSEPATH);
         }
+        buf.putByte(PGCanvas.PATHEND);
         buf.putByte(command);
         // Now that we have changed the PG layer path, we need to mark our path dirty.
         markPathDirty();
--- a/javafx-ui-common/src/javafx/scene/image/Image.java	Wed May 08 14:29:33 2013 -0700
+++ b/javafx-ui-common/src/javafx/scene/image/Image.java	Mon May 20 23:12:27 2013 -0700
@@ -734,9 +734,10 @@
             if (loader.getFrameCount() > 1) {
                 makeAnimationTimeline(loader);
             } else {
-                setPlatformImageWH(loader.getFrame(0),
-                                   loader.getWidth(),
-                                   loader.getHeight());
+                PlatformImage pi = loader.getFrame(0);
+                double w = loader.getWidth() / pi.getPixelScale();
+                double h = loader.getHeight() / pi.getPixelScale();
+                setPlatformImageWH(pi, w, h);
             }
         } else {
             setError(true);
@@ -769,7 +770,10 @@
         // the last frame is shown, the wrap around is "instantaneous"
         keyFrames.add(createPlatformImageSetKeyFrame(duration, frames[0]));
 
-        setPlatformImageWH(frames[0], loader.getWidth(), loader.getHeight());
+        PlatformImage zeroFrame = frames[0];
+        double w = loader.getWidth() / zeroFrame.getPixelScale();
+        double h = loader.getHeight() / zeroFrame.getPixelScale();
+        setPlatformImageWH(zeroFrame, w, h);
         timeline.play();
     }
 
--- a/test-stub-toolkit/src/com/sun/javafx/pgstub/StubFilterable.java	Wed May 08 14:29:33 2013 -0700
+++ b/test-stub-toolkit/src/com/sun/javafx/pgstub/StubFilterable.java	Mon May 20 23:12:27 2013 -0700
@@ -52,6 +52,11 @@
     }
 
     @Override
+    public float getPixelScale() {
+        return image.getPixelScale();
+    }
+
+    @Override
     public void flush() {
     }
 
--- a/test-stub-toolkit/src/com/sun/javafx/pgstub/StubPlatformImage.java	Wed May 08 14:29:33 2013 -0700
+++ b/test-stub-toolkit/src/com/sun/javafx/pgstub/StubPlatformImage.java	Mon May 20 23:12:27 2013 -0700
@@ -47,6 +47,11 @@
         return frame;
     }
 
+    @Override
+    public float getPixelScale() {
+        return 1.0f;
+    }
+
     public StubImageLoader getImageLoader() {
         return imageLoader;
     }