RFR: 8187759: Background not refreshed when painting over a transparent JFrame [v2]
Alexander Zvegintsev
azvegint at openjdk.org
Thu Feb 1 16:37:06 UTC 2024
On Fri, 12 Jan 2024 07:17:37 GMT, Tejesh R <tr at openjdk.org> wrote:
>> This is happening in linux where `BuffereStrategyPaintManager` is used to paint to offscreen. Here `bsg` bufferStrategy SunGraphics2D is used to paint to offscreen where the background is not refreshed, which does only clipping and then paints to offscreen. In order to handle the screen updated/clear the buffer, `setBackground` to component background color and `clearRect` against the clip area is used which solves the issue without causing any regression.
>> CI is green for the fix and manual test is provided.
>
> Tejesh R has updated the pull request incrementally with one additional commit since the last revision:
>
> Review fix
src/java.desktop/share/classes/javax/swing/BufferStrategyPaintManager.java line 251:
> 249: g2d.setBackground(paintingComponent.getBackground());
> 250: g2d.clearRect(x, y, w, h);
> 251: g2d.setBackground(oldBg);
Shouldn't we limit this change to non-opaque components only?
`if (!bufferComponent.isOpaque())`
Also, it might be worthwhile to find a way not to clear the whole screen/window area (if possible), but only the dirty part.
test/jdk/javax/swing/JFrame/JFrameBackgroundRefreshTest.java line 45:
> 43: * @build PassFailJFrame
> 44: * @summary Test to check if JFrame background is refreshed in Linux.
> 45: * @requires (os.family == "linux")
Why should this test only run on Linux?
test/jdk/javax/swing/JFrame/JFrameBackgroundRefreshTest.java line 77:
> 75:
> 76: frame = new JFrame("JFrame Background refresh test");
> 77: passFailJFrame = new PassFailJFrame("Test Instructions",
This test is unusable with mouse for me(before and after the fix). The windows with the floating text obscures the
"Pass" and "Fail" buttons.
Also, it looks like this test doesn't have to be manual.
It can easily be automated, e.g. by moving the mouse cursor over a white window and then moving it away from that window.
If any non-white pixels are left drawn over the white window, the test fails.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17081#discussion_r1474737554
PR Review Comment: https://git.openjdk.org/jdk/pull/17081#discussion_r1474738798
PR Review Comment: https://git.openjdk.org/jdk/pull/17081#discussion_r1474754202
More information about the client-libs-dev
mailing list