On Thu, 4 Apr 2024 17:18:48 GMT, Prasanta Sadhukhan <psadhuk...@openjdk.org> 
wrote:

> > > > > > > Can you please explain why you need to handle 
> > > > > > > MultiResolutionImage for this printing issue for NimbusL&F and 
> > > > > > > why was it not needed for other L&F Also, you need to add this 
> > > > > > > bugid to the test
> > > > > > 
> > > > > > 
> > > > > > The fix is for L&F other than Nimbus. It is working in Nimbus since 
> > > > > > Image drawing is handled by SunGraphics2D class in 
> > > > > > [drawHIDPIImage()](https://github.com/openjdk/jdk/blob/b9da14012da5f1f72d4f6e690c18a43e87523173/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java#L3126)
> > > > > >  method. Whereas other L&F, pathGraphics handles ImageDrawing where 
> > > > > > MultiResolutionImage is not yet handled. The fix which I proposed 
> > > > > > for 
> > > > > > [8210807](https://github.com/openjdk/jdk/commit/38bbbe7588c94d3a0edd1c120ba49cbd0851a720)
> > > > > >  bug fixed for Non-Nimbus L&F but caused regression for Nimbus. 
> > > > > > Hence after further analysis and study the root cause was found out 
> > > > > > to be Non-handling of MultiResolutionImage in 
> > > > > > [getBufferedImage()](https://github.com/openjdk/jdk/blob/b9da14012da5f1f72d4f6e690c18a43e87523173/src/java.desktop/share/classes/sun/print/PathGraphics.java#L1122).
> > > > > 
> > > > > 
> > > > > I guess the PathGraphics path should be used for printing images and 
> > > > > should be common for all so why Nimbus is going via SunGraphics2D? 
> > > > > [and it seems you updated the summary to include Aqua so Aqua is also 
> > > > > going via SunGraphics2D?]
> > > > 
> > > > 
> > > > Yes, the issue is found in Aqua also and that too uses SunGraphics2D. 
> > > > And regarding why SunGraphics2D is used for Nimbus and Aqua, its 
> > > > because in Nimbus PeekGraphics is used which in-turn useses 
> > > > SunGraphics2D and in other its PW/WPathGraphics. I'm not sure why this 
> > > > is different.
> > > 
> > > 
> > > Can you point to the code where it uses PeekGraphics in Nimbus/Aqua and 
> > > the subsequent code from where is starts to bifurcate in other L&F 
> > > meaning where it starts to uses PeekGraphics for Nimbus/Aqua and 
> > > PathGraphics for others?
> > 
> > 
> > Yeah, it is from RasterPrinterJob class 
> > [here](https://github.com/openjdk/jdk/blob/21867c929a2f2c961148f2cd1e79d672ac278d27/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java#L2298).
> >  And that is because of nonSolidColors present in Nimbus and Aqua L&F.
> 
> I didn't get how it creates PeekGraphics for Nimbus/Aqua and PathGraphics for 
> others? I guess RasterPrinterJob will delegate to WPrinterJob in windows and 
> PSPrinterJob in unix and it is not dependant on L&F...

It is because of this condition check `metrics.hasNonSolidColors()` which is 
true for Nimbus & Aqua. 
[Here](https://github.com/openjdk/jdk/blob/0b01144ecec1283adaaaf1a7f53d075a56f030ae/src/java.desktop/share/classes/sun/print/PSPrinterJob.java#L1076).

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

PR Comment: https://git.openjdk.org/jdk/pull/18187#issuecomment-2038909946

Reply via email to