On Thu, 18 May 2023 23:00:25 GMT, Sergey Bylokhov <s...@openjdk.org> wrote:

>> Perhaps, this needs additional details. The size of checkbox and radio 
>> button is 13 as reported by Theme API for the standard DPI of 96. Being a 
>> prime number, 13 doesn't scale well, there's always fractional part unless 
>> the scale is whole. Thus, the scaled size never matches.
>> 
>> As the result, `CachedPainter` seems to apply a scale to compensate for that 
>> — whether we choose ceil or floor. The above formula gives better results.
>> 
>> The entire thing should have been simpler: a `MultiResolutionImage` which 
>> paints the background according to the scale requested. Yet it proved to be 
>> not as simple. We're planning to look further into simplifying it if 
>> possible and, alternatively or in addition to, considering [dynamic layout 
>> based on graphics 
>> configuration](https://github.com/openjdk/jdk/pull/13701#discussion_r1187985627)
>>  as you suggested above.
>> 
>> The current solution may be not perfect but it provides better rendering 
>> compared to what we have now: *the controls look crisp only on the main 
>> display*.
>
> But still why the size on the components are so different? is it really 
> caused by one "pixel/unit" we requested from the native?

So, basically for w,h =19 we calculate a DPI of 140 and Dimension d = 
getPartSize(getTheme(widget, dpi), part, state); at line 172 of 
ThemeReader.java call returns a part size of 13 x 13 provided by windows as it 
is closer to DPI=120 (for 125% scaling).
While for  w,h =20 we calculate a DPI of 147 and Dimension d = 
getPartSize(getTheme(widget, dpi), part, state); at line 172 of 
ThemeReader.java call returns a part size of 20 x 20 provided by windows as it 
is closer to DPI=144 (for 150% scaling).
Thus part size calculated by us and provided by Windows matches and hence we 
see bigger properly rendered buttons while for the w,h=19 case we have 19x19 , 
while windows gives 13x13 
and hence you see scaled down buttons with bad rendering.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13701#discussion_r1206133530

Reply via email to