On Thu, 29 Apr 2021 17:04:17 GMT, Alexander Zuev <kiz...@openjdk.org> wrote:

>> src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java line 
>> 1114:
>> 
>>> 1112:                                     bothIcons.put(getLargeIcon? 
>>> SMALL_ICON_SIZE : LARGE_ICON_SIZE, newIcon2);
>>> 1113:                                     newIcon = new 
>>> MultiResolutionIconImage(getLargeIcon ? LARGE_ICON_SIZE
>>> 1114:                                             : SMALL_ICON_SIZE, 
>>> bothIcons);
>> 
>> I still propose to refactor this code to make it clearer. The code always 
>> returns two icons: _small + large_ or _large + small_ — combined in 
>> `MultiResolutionIconImage`.
>> 
>> You can get `smallIcon` and `largeIcon` and then wrap them into 
>> `MultiResolutionIconImage` in the correct order and store each icon in the 
>> cache.
>> 
>> My opinion hasn't changed here.
>> 
>> I still think there's not much value in getting smaller icon size in 
>> addition to larger one. Or does it provide an alternative image for the case 
>> where the system scaling is 200% and the window is moved to a monitor with 
>> scaling of 100%?
>
> Getting smaller icon is relevant in the case of the scaling. I do not think 
> refactoring image caches from icons to multiresolution images will make code 
> much cleaner - at the end we will have to extract images from the 
> multiresolution image to repack them into different multiresolution image 
> because the base size of the image will not be the same and it does matter in 
> how they will be scaled on the different screens. And we still need to 
> extract both images because sometimes small resolution image looks not like 
> the large resolution one and for a reason - so small resolution image is not 
> blurred by the small detail on the large icon when scaling on the low 
> resolution screen.

No, I can't see how it's relevant. If the scale factor is 100% and the 
requested icon size is 16, then 16×16 is used; if the window is moved to a 
monitor with scale factor 200%, then 32×32 icon is used for rendering which is 
already fetched and available in the multi-resolution image — perfect, there's 
the benefit.

But when is it possible that the scale factor is less than 100%?

If `JFileChooser` requests a large icon that is 32×32, then it will be used for 
rendering when the scale factor is 100%. When the scale factor is 200%, the 
icon of 64×64 is required but it's not available, instead there's 16×16 icon. 
For this icon to be used, the scale factor needs to be 50%.

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

PR: https://git.openjdk.java.net/jdk/pull/2875

Reply via email to