RFR: 8260013: Snapshot does not work for nodes in a subscene [v3]
Kevin Rushforth
kcr at openjdk.org
Fri Jan 26 20:43:35 UTC 2024
On Fri, 26 Jan 2024 13:55:59 GMT, Lukasz Kostyra <lkostyra at openjdk.org> wrote:
>> Originally this issue showed the problem of Node being incorrectly rendered (clipped) when snapshotting, compared to a snapshot of the whole Scene. Later on there was another problem added - lights not being taken into account if they are added to a SubScene.
>>
>> As it later turned out, the original problem from this bug report is a problem with ParallelCamera incorrectly estimating near/far clipping planes, which just happened to reveal itself while snapshotting a Node. During testing I found out you can make the Node clip regardless of snapshot mechanism. Clipping issue was moved to a separate bug report and this PR only fixes the inconsistency in lights being gathered for a snapshot.
>>
>> `Scene.doSnapshot()` was expanded to also check if SubScene provided to it is non-null and to fetch lights assigned to it. Scenario was tested with added SnapshotLightsTest.
>>
>> Rest of the tests were checked and don't produce any noticeable regressions.
>
> Lukasz Kostyra has updated the pull request incrementally with two additional commits since the last revision:
>
> - doSnapshot: Adjust light collection
>
> Snapshot now includes lights only from subScene if it is not null, which
> matches how SubScenes are rendered
> - SnapshotLightsTest: Add test for a snapshot with an extra light in scene
Looks good. I left a few minor cleanup comments. I'll reapprove when/if you fix them.
modules/javafx.graphics/src/main/java/javafx/scene/Scene.java line 1350:
> 1348: }
> 1349:
> 1350: // Grab the lights from the scene and/or subscene
Minor: `and/or` should now just be `or`
tests/system/src/test/java/test/javafx/scene/SnapshotLightsTest.java line 28:
> 26: package test.javafx.scene;
> 27:
> 28: import javafx.embed.swing.SwingFXUtils;
Unused import
tests/system/src/test/java/test/javafx/scene/SnapshotLightsTest.java line 41:
> 39: import javafx.scene.shape.Box;
> 40:
> 41: import org.junit.After;
Since this is a new test, maybe use JUnit5?
tests/system/src/test/java/test/javafx/scene/SnapshotLightsTest.java line 54:
> 52: import java.io.IOException;
> 53:
> 54: import javax.imageio.ImageIO;
Unused imports
-------------
Marked as reviewed by kcr (Lead).
PR Review: https://git.openjdk.org/jfx/pull/1332#pullrequestreview-1846400854
PR Review Comment: https://git.openjdk.org/jfx/pull/1332#discussion_r1468057260
PR Review Comment: https://git.openjdk.org/jfx/pull/1332#discussion_r1468059055
PR Review Comment: https://git.openjdk.org/jfx/pull/1332#discussion_r1468060838
PR Review Comment: https://git.openjdk.org/jfx/pull/1332#discussion_r1468061387
More information about the openjfx-dev
mailing list