JDK-8220484 : JFXPanel renders a slanted image with a hidpi monitor scale of 125% or 175%
  • Type: Bug
  • Component: javafx
  • Sub-Component: swing
  • Affected Version: openjfx11
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2019-03-06
  • Updated: 2020-10-10
  • Resolved: 2020-07-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
openjfx11.0.9Fixed
Related Reports
Duplicate :  
Relates :  
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



Comments
Changeset: 3cc29e38 Author: Oliver Schmidtmer <O.Schmidtmer@elo.com> Committer: Kevin Rushforth <kcr@openjdk.org> Date: 2020-07-22 14:38:09 +0000 URL: https://git.openjdk.java.net/jfx/commit/3cc29e38
22-07-2020

When ran the provided test case on Windows 10 with scaling 175% and dragged the window left-right to change the width, issue is reproducible. PFA screenshot. 8u212 : Pass 9+113 : Pass 9+114 : Fail <-- regression introduced here 9.0.1+11 : Fail OpenJFX 12-ea+14 : Fail
12-03-2019