滚动时以及每当场景需要重新渲染时,我的 JavaFX 应用程序都会遇到一些延迟。在 JavaFX 中启用脉冲记录器,我可以看到在每个脉冲中重新渲染了许多节点(如下例所示)。
PULSE: 3310 [16ms:26ms]
T1 (0 +0ms): CSS Pass
T1 (0 +0ms): Layout Pass
T1 (0 +0ms): Update bounds
T1 (0 +13ms): Waiting for previous rendering
T1 (13 +0ms): Copy state to render graph
T7 (14 +0ms): Dirty Opts Computed
T7 : 1 different dirty regions to render
T7 : Dirty Region 0: RectBounds { minX:366.0, minY:143.0, maxX:374.0, maxY:539.0} (w:8.0, h:396.0)
T7 : Render Root Path 0: [com.sun.javafx.sg.prism.NGRegion@bd6cd80, com.sun.javafx.sg.prism.NGRegion@b6f5240, com.sun.javafx.sg.prism.NGRegion@1347d5a0, com.sun.javafx.sg.prism.NGRegion@b982360, com.sun.javafx.sg.prism.NGRegion@b9826c0]
T7 (14 +0ms): Render Roots Discovered
T7 (14 +1ms): Painting
T7 (16 +10ms): Presenting
Counters:
CacheFilter rebuilding: 1
Nodes cached: 8
Nodes rendered: 19
Nodes visited during render: 25
有没有一种简单的方法可以找到重新渲染的这 19 个节点,以便我可以缓存它们以提高性能?