Hi,

Why does applying a DropShadow on a large region cause problem when
animating nodes contained in that region?

> package fxbugs;
> 
> import javafx.animation.ScaleTransition;
> import javafx.application.Application;
> import javafx.geometry.Insets;
> import javafx.scene.Node;
> import javafx.scene.Scene;
> import javafx.scene.control.Button;
> import javafx.scene.effect.BlurType;
> import javafx.scene.effect.DropShadow;
> import javafx.scene.layout.BorderPane;
> import javafx.scene.layout.GridPane;
> import javafx.scene.paint.Color;
> import javafx.stage.Stage;
> import javafx.util.Duration;
> 
> public class DropShadowPerformance extends Application {
> 
>     @Override
>     public void start(Stage primaryStage) throws Exception {
>         BorderPane p = new BorderPane();
>         p.setPadding(new Insets(30));
>         
>         GridPane container = new GridPane();
>         container.setHgap(10);
>         container.setVgap(10);
>         container.setStyle("-fx-background-color: green; -fx-padding: 10;");
>         container.setEffect(new DropShadow(BlurType.GAUSSIAN, Color.rgb(0, 0, 
> 0, 0.3), 10, 0.5, 0, 0));
>         for( int i = 0; i < 8; i++ ) {
>             for( int j = 0; j < 14; j++ ) {
>                 container.add(createButton(), i, j);
>             }
>         }
>         p.setCenter(container);
>         
>         Scene s = new Scene(p, 800, 600);
>         primaryStage.setScene(s);
>         primaryStage.show();
>     }
> 
>     private Node createButton() {
>         Button button = new Button("hello world");
>         button.hoverProperty().addListener((ob,ol,ne) -> {
>             ScaleTransition t = new ScaleTransition(Duration.millis(500), 
> button);
>             
>             if( ne ) {
>                 t.setFromX(1);
>                 t.setFromY(1);
>                 t.setToX(1.2);
>                 t.setToY(1.2);
>             } else {
>                 t.setFromX(1.2);
>                 t.setFromY(1.2);
>                 t.setToX(1);
>                 t.setToY(1);
>             }
>             
>             t.play();
>         });
>         return button;
>     }
>     
>     public static void main(String[] args) {
>         launch(args);
>     }
> }


If you run the following application:
* Maximize the window
* Hover over a button (eg the one in the right lower corner)

You'll notice that the animation is not smooth, setting cache flags on
the container does not improve the situation, nor does using a ONE_PASS_BOX.

Removing the effect on the container node "fixes" the problem.

This is on a MacBook Pro and Windows Surface both having a Intel Iris
Plus 650 graphics card.

Tom

-- 
Tom Schindl, CTO
BestSolution.at EDV Systemhaus GmbH
Eduard-Bodem-Gasse 5-7. A-6020 Innsbruck
Reg. Nr. FN 222302s am Firmenbuchgericht Innsbruck

Reply via email to