RFR: 8220484: JFXPanel renders a slanted image with a hidpi monitor scale of 125% or 175% [v2]

Oliver Schmidtmer github.com+10960818+Schmidor at openjdk.java.net
Fri Jul 3 17:39:55 UTC 2020

On Fri, 3 Jul 2020 00:01:10 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

>> Oliver Schmidtmer has updated the pull request incrementally with one additional commit since the last revision:
>>   Change to Math.ceil and add test
> tests/system/src/test/java/test/javafx/embed/swing/JDK8220484Test.java line 90:
>> 89:         Field fpixelsIm = JFXPanel.class.getDeclaredField("pixelsIm");
>> 90:         fpixelsIm.setAccessible(true);
>> 91:         BufferedImage pixelsIm = (BufferedImage) fpixelsIm.get(myApp.jfxPanel);
> This isn't the pattern we use to access internal fields of a JavaFX class, and won't work.
> We typically use the "shim" pattern for such white-box testing. Can you look into adding shims to the `javafx.swing`
> module? Many of the other modules already have shims, so you can use that as a pattern. It will require adding a
> package-scope `test_getPixelsIm` method to `JFXPanel`.  Alternatively, you can use AWT `Robot` to read the JFXPanel
> pixels.

I've added a shim. I would like to check the backing image directly.

> tests/system/src/test/java/test/javafx/embed/swing/JDK8220484Test.java line 103:
>> 102:             for (int y = 90; y < 115; y++) {
>> 103:                 if(colorOfDiagonal == pixelsIm.getRGB( x, y )) {
>> 104:                     fail( "image is skewed" );
> Are you sure that an equality test will work on all platforms and configurations? We usually use a tolerance when
> comparing colors whose components are other than 0 or 255.
> Somewhat related to this, is the expected value of `181` coming from the default value of the button border? It might
> be more robust to fill the Scene with a stroked rectangle whose color you control (e.g. set to black). Either that or
> set the color of the button border using an inline CSS style so you aren't dependent on the default inherited from the
> `modena.css` style sheet.  Minor: add a space after the `if` and remove the extra spaces surrounding the function
> arguments `x, y`.

done, a rectangle with a defined background & border color. That is definitely more stable.


PR: https://git.openjdk.java.net/jfx/pull/246

More information about the openjfx-dev mailing list