JavaFX FadeTransistion会导致巨大的CPU负载

时间:2018-01-22 03:42:02

标签: java performance javafx

在嵌入滚动窗格的HBox(容器)中有一个简单的矩形。 此矩形应用了以下过渡:

attentionRectangle = new Rectangle(1, 1, container.getWidth(), container.getHeight());
attentionRectangle.setManaged(false);

attentionRectangle.setFill(Color.LIME);

attentionRectangleTransition = new FadeTransition(Duration.millis(3000), attentionRectangle);
attentionRectangleTransition.setFromValue(0.2);
attentionRectangleTransition.setToValue(0.8);
                    attentionRectangleTransition.setCycleCount(Timeline.INDEFINITE);
attentionRectangleTransition.setAutoReverse(true);

attentionRectangleTransition.play();

现在可以注意到并重现以下行为(至少在我的项目中):  1.如果滚动窗格完全为空,则java机器的CPU负载为~1%  2.如果带有闪烁矩形的元素单独位于滚动窗格内,则Java的CPU负载约为3-4%  3.如果其他没有闪烁的简单元素在滚动窗格内,则cpu负载约为2-3%  4.如果简单元素和闪烁的元素在滚动窗格内,CPU负载会发出15-17%,这几乎是一个完全加载的虚拟线程(由于我的机器上有8个可用线程)。

嗯,这是正常的吗? 或者有人建议如何改进?

真的很感激。

如果使用" -Dprism.verbose = true"执行控制台输出:

Prism pipeline init order: d3d sw 
Using native-based Pisces rasterizer
Using dirty region optimizations
Not using texture mask for primitives
Not forcing power of 2 sizes for textures
Using hardware CLAMP_TO_ZERO mode
Opting in for HiDPI pixel scaling
Prism pipeline name = com.sun.prism.d3d.D3DPipeline
Loading D3D native library ...
    succeeded.
D3DPipelineManager: Created D3D9Ex device
Direct3D initialization succeeded
(X) Got class = class com.sun.prism.d3d.D3DPipeline
Initialized prism pipeline: com.sun.prism.d3d.D3DPipeline
Maximum supported texture size: 16384
Maximum texture size clamped to 4096
OS Information:
    Windows version 10.0 build 16299
D3D Driver Information:
    Radeon (TM) RX 480 Graphics
    \\.\DISPLAY1
    Driver aticfx32.dll, version 22.19.677.257
    Pixel Shader version 3.0
    Device : ven_1002, dev_67DF, subsys_94801682
    Max Multisamples supported: 4
 vsync: true vpipe: true

Loading Prism common native library ...
    succeeded.
PPSRenderer: scenario.effect - createShader: LinearConvolveShadow_8
PPSRenderer: scenario.effect - createShader: LinearConvolveShadow_16
PPSRenderer: scenario.effect - createShader: LinearConvolveShadow_12
PPSRenderer: scenario.effect - createShader: LinearConvolveShadow_4

PPSRenderer: scenario.effect - createShader: LinearConvolveShadow_20

动画开始时会发生最后一行!

0 个答案:

没有答案