Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8220484

JFXPanel renders a slanted image with a hidpi monitor scale of 125% or 175%

    Details

    • Subcomponent:
    • Introduced In Build:
      b114
    • Introduced In Version:
      9
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      ADDITIONAL SYSTEM INFORMATION :
      A monitor (can be the main monitor) is configured to scale text/apps/etc. to 125% or 175%. The bug does not appear without scale or with 150%/200% scale.

      A DESCRIPTION OF THE PROBLEM :
      When using a hidpi monitor on Windows, configured to scale everything with 125% or 175%, certain sizes of a JFXPanel instance (most likely those that when multiplied with 1.25 or 1.75 end on .25, i.e. Math.ceil() and Math.round() matters) look "slanted". More exactly, it looks like an image is drawn pixel-wise, from top to bottom, into an area that is 1 pixel wider than the image. The left border flips to the right side and moves into direction southwest.

      REGRESSION : Last worked in version 8u201

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the SlantedTester and change the width of the window. At some point the whole button becomes slanted. This does not change even when interacting with the button or moving the window. It is "fixed" by changing the width to a non-problematic again.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The button should always look normal.
      ACTUAL -
      The button looks slanted.

      ---------- BEGIN SOURCE ----------
      import java.awt.Dimension;

      import javax.swing.JFrame;

      import javafx.application.Platform;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;

      public class SlantedTester
      {
         public static void main(String[] args)
         {
            new SlantedTester().init();
         }

         private void init()
         {
            JFXPanel fxPanel = new JFXPanel();
            fxPanel.setPreferredSize(new Dimension(600, 400));
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            Platform.runLater(() -> initFX(fxPanel));

            frame.add(fxPanel);
            frame.pack();
            frame.setVisible(true);
         }

         private void initFX(JFXPanel fxPanel)
         {
            Scene scene = createScene();
            fxPanel.setScene(scene);
         }

         private Scene createScene()
         {
            return new Scene(new Button("Button"));
         }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      When using
               int newPixelW = (int) Math.round(pWidth * newScaleFactorX);
               int newPixelH = (int) Math.round(pHeight * newScaleFactorY);
      instead of Math.ceil() in JFXPanel.createResizePixelBuffer() this bug does not appear.

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              psadhukhan Prasanta Sadhukhan
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: