RFR: JDK-8294680: Refactor scaled border rendering [v5]

Harshitha Onkar honkar at openjdk.org
Wed Jan 11 23:29:18 UTC 2023


On Wed, 11 Jan 2023 20:37:13 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> Harshitha Onkar has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   moved strokeWidth logic to individual classes
>
> src/java.desktop/share/classes/com/sun/java/swing/SwingUtilities3.java line 196:
> 
>> 194: 
>> 195:         // Step 2: Call respective paintBorder with transformed values
>> 196:         painter.paintUnscaledBorder(c, g, x, y, width, height, scaleFactor);
> 
> Why do you pass the original `x` and `y`? They must be 0 inside `paintUnscaledBorder`. As such, `x` and `y` parameters can be dropped.

Thanks for catching. Removed unused parameters.

> src/java.desktop/share/classes/com/sun/java/swing/SwingUtilities3.java line 203:
> 
>> 201:             Graphics2D g2d = (Graphics2D) g;
>> 202:             g2d.setTransform(at);
>> 203:             g2d.setStroke(oldStk);
> 
> The stroke should always be restored even if the transform wasn't reset. Or it should be done in the implementation of `paintUnscaledBorder`.

@aivanov-jdk Earlier strokeWidth was set when resetTransform was true and it was restored on the same condition. Now since the stroke width is moved to individual implementation of paintUnscaledBorder, it make sense to restore it outside of resetTranform.

To avoid missing this step, I have restored it in common code than in individual paintUnscaledBorder implementations.

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

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



More information about the client-libs-dev mailing list