On Wed, 16 Mar 2022 05:36:04 GMT, Sergey Bylokhov <s...@openjdk.org> wrote:

>>> This might be a rookie question:
>>> 
>>> When it comes to modifying and restoring a Graphics, I've seen two common 
>>> patterns: A. Call `newG = g.create()` and later `newG.dispose()` B. Call 
>>> `g.setX(newValue)` and then call `g.setX(oldValue)` later
>>> 
>>> Is there guidance on when to use which? Or is one always preferred?
>> 
>> Usually i follow the rule of minimal action. When i need to set a lot of 
>> hints that needs to be later unrolled such as changing graphics coordinates 
>> and such - i'm creating a new Graphics. When i only need to manipulate a 
>> single hint and it can easily be unrolled - i am using the same object. In 
>> this case i'm changing just a single hint.
>
> I am not sure that this is the right place to change the hints.
> If we want to always scale the icon using the bicubic interpolation then it 
> is better to do it where we call the paintIcon() method in some 
> jcomponent(this probably may be configured by some option - similar to the 
> text antialisaing). But it will affect performance since the bicubic is much 
> slower.
> 
> But before discussing this shared code change could you please provide some 
> info on why it worked fine before? Why we try to downscale the image and do 
> not get an exact size from the native.

The reason for the issue to manifest is that due to the high resolution icon 
fix on Windows we are returning a multiresolution image now and the new code 
that fetches the icons for some icons returns 32x32 icon no matter what 
resolution is requested so we ended up with an 16x16 multiresolution icon with 
only variant available 32x32 so icon painter is doing the scaling. One of the 
possible solutions i considered is to interpolate the icon in the process of 
creation but that will only hide the problem because you see - in my test i was 
able to reproduce the scaling problem without the Windows code, simply by 
wrapping the larger icon into smaller MultiResolutionIcon. And i do not think 
that changing hints in every component is a good idea - because it will require 
these components to be much more aware of the icon's internal mechanic which is 
not a great idea. And taking into consuderation that we only enable bicubic 
interpolation for icons that really require it - when icon does not ha
 ve a resolution variant that fits the current icon's size - it should not be a 
serious performance impact. In majority of the cases interpolation is not 
required.

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

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

Reply via email to