On Fri, 3 Mar 2023 08:07:12 GMT, Prasanta Sadhukhan <psadhuk...@openjdk.org> 
wrote:

> Refactor-ed Swing interop was calling 
> `JLightweightFrame.notifyDisplayChanged()` with [wrong scale 
> factor](https://github.com/openjdk/jfx/blob/master/modules/javafx.swing/src/main/java/com/sun/javafx/embed/swing/newimpl/SwingNodeInteropN.java#L71-L76)
>  
> as it was passing integer scale and not double so scalefactor of 1.25 is 
> being passed as 1.0 to JLightwieightFrame
> Due to this, the `imagebuffer `which is created for lightweight container to 
> paint its content to an offscreen image 
> is created with wrong[ width/height 
> ](https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/sun/swing/JLightweightFrame.java#L457)
> Fix is made to have Swing interop call double version of the method to get 
> correct scale factor and set the imagebuffer properly.
> 
> I guess we could remove the int version of the method (which anyways is 
> deprecated) and cleanup Swing interop code to just utilise the double 
> version, as all platforms we support uses floating scale, but that cleanup 
> can be done separately for another day

I actually tried testing the LightweightFrame scale factor by adding check in 
reproducer `BlurrySwingNode` testcase


System.setProperty("sun.java2d.uiScale", "1.25");
Object lwFrame = 
com.sun.javafx.embed.swing.SwingNodeHelper.getLightweightFrame(swingLabelNode);
           assertEquals(1.25, 
((sun.swing.JLightweightFrame)lwFrame).getScaleFactorX());

but I get an error for module visibility for fx swing module, although 
sun.swing module is being made visible

`javac --add-modules javafx.swing --add-exports 
javafx.swing/com.sun.javafx.embed.swing=ALL-UNNAMED --add-modules java.desktop 
--add-exports java.desktop/sun.swing=ALL-UNNAMED BlurrySwingNode.java`

BlurrySwingNode.java:49: error: cannot find symbol
            Object lwFrame = 
com.sun.javafx.embed.swing.SwingNodeHelper.getLightweightFrame(swingLabelNode);
                                                                       ^
  symbol:   method getLightweightFrame(SwingNode)
  location: class SwingNodeHelper
BlurrySwingNode.java:50: warning: JLightweightFrame is internal proprietary API 
and may be removed in a future release
            
System.out.println(((sun.swing.JLightweightFrame)lwFrame).getScaleFactorX());
1 error
1 warning

@kevinrushforth @aghaisas Do you have any idea on this?

-------------

PR: https://git.openjdk.org/jdk/pull/12848

Reply via email to