On Tue, 14 Jun 2022 08:42:11 GMT, Sergey Bylokhov <s...@openjdk.org> wrote:

> That was the whole purpose of the initial 8182043 issue, to provide a 
> HiDPI(or various DPI) icons for the user. If the user asks for the 16x16 we 
> will provide them the MRI where the base image is 16x16, but that MRI could 
> also provide large images by request. If that 16x16 image renders on 
> scale=1.25 then the MRI should generate the image which looks good on that 
> screen.

[JDK-8182043](https://bugs.openjdk.org/browse/JDK-8182043) has enhanced support 
for High DPI, which can be confirmed by displaying a JFileChooser (in 
SwingSet2) and moving it from one monitor to another or changing the scale of a 
monitor where it's displayed.

Before JDK-8182043, the icon was either 16×16 or 32×32 and didn't change if the 
scale was changed. Now the icon gets updated after the scale changes, it's 
noticeable on folder icons in user's home because a set of icons is fetched.

There are still two different ways where icons are fetched from the Windows 
shell: `Java_sun_awt_shell_Win32ShellFolder2_getIcon` and 
`Java_sun_awt_shell_Win32ShellFolder2_extractIcon`. As @azuev-java notes, at 
times the returned size doesn't match the requested size.

> This current proposal generates it on the fly using java code, but I think it 
> should request that information from the native system, this was the purpose 
> of the new getSystemIcon(file,w,w) method.

This current proposal handles the situation where the returned icon doesn't 
have the requested size.

So, there are drawbacks and limitations in the current implementation, and 
there are opportunities to improve it, some of them are listed in [my comment 
above](https://github.com/openjdk/jdk/pull/7805#discussion_r893306463). I shall 
submit them so that we don't forget about them, if no one else has already done 
it.

> We do not need to always request the icon via COM thread, we can initially 
> load the low dpi image, or the image for the main screen scale, then if the 
> scale changed we can request to load the HiDPI image, and use it when ready.

Why not? To request the icon of a larger size, the object which stores the icon 
should keep the reference to the file or folder, folders could have custom 
icons, and Documents, Downloads, Pictures are the examples of such folders. 
This must be done on COM thread because the icons are requested from the 
Windows shell.


I agree that we should not get all possible resolutions of an icon when only 
one is needed. But it's out of scope of this particular issue.

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

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

Reply via email to