-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
8, 9
-
generic
-
generic
FULL PRODUCT VERSION :
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
EXTRA RELEVANT SYSTEM CONFIGURATION :
AMD Radeon HD 6700
A DESCRIPTION OF THE PROBLEM :
The rendering performance is visibly worse when you draw shapes with non-solid strokes instead of solid. In the attached sample code you can drag JavaFX Line with the mouse. If the Lines are drawn with a dashed stroke the movement jerks.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- Start the attached sample.
- Drag the mouse.
- Observe the problem.
- Set the instance variable "dashed" to false.
- Restart the sample.
- Drag the mouse.
- The performance is now much better.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The rendering performance should be independent of the stroke dash.
ACTUAL -
The rendering performance of non-solid lines are much worse.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import javafx.scene.shape.StrokeLineCap;
import javafx.stage.Stage;
/**
* Sample to reproduce the poor rendering performance of dashed strokes.
* Change the value of the variable dashed to switch between solid and non-solid strokes.
* Drag the mouse to watch the rendering performance.
*/
public class TestDashStyle extends Application {
private boolean dashed = true;
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("Performance of Non-Solid Lines");
Group root = new Group();
for (int i = 0; i < 1000; i += 10) {
Line line1 = createLine(i, 0, i, 1000);
Line line2 = createLine(0, i, 1000, i);
root.getChildren().addAll(line1, line2);
}
Scene scene = new Scene(root, 1200, 800);
scene.setOnMouseDragged(event -> {
root.setTranslateX(event.getX());
root.setTranslateY(event.getY());
});
primaryStage.setScene(scene);
primaryStage.show();
}
private Line createLine(double startX, double startY, double endX, double endY) {
double thickness = 1;
Line line = new Line(startX, startY, endX, endY);
line.setStroke(Color.RED);
line.setStrokeWidth(thickness);
if (dashed) {
line.setStrokeLineCap(StrokeLineCap.SQUARE);
line.getStrokeDashArray().addAll(0.0, 3.0 * thickness);
}
return line;
}
}
---------- END SOURCE ----------
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
EXTRA RELEVANT SYSTEM CONFIGURATION :
AMD Radeon HD 6700
A DESCRIPTION OF THE PROBLEM :
The rendering performance is visibly worse when you draw shapes with non-solid strokes instead of solid. In the attached sample code you can drag JavaFX Line with the mouse. If the Lines are drawn with a dashed stroke the movement jerks.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- Start the attached sample.
- Drag the mouse.
- Observe the problem.
- Set the instance variable "dashed" to false.
- Restart the sample.
- Drag the mouse.
- The performance is now much better.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The rendering performance should be independent of the stroke dash.
ACTUAL -
The rendering performance of non-solid lines are much worse.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import javafx.scene.shape.StrokeLineCap;
import javafx.stage.Stage;
/**
* Sample to reproduce the poor rendering performance of dashed strokes.
* Change the value of the variable dashed to switch between solid and non-solid strokes.
* Drag the mouse to watch the rendering performance.
*/
public class TestDashStyle extends Application {
private boolean dashed = true;
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("Performance of Non-Solid Lines");
Group root = new Group();
for (int i = 0; i < 1000; i += 10) {
Line line1 = createLine(i, 0, i, 1000);
Line line2 = createLine(0, i, 1000, i);
root.getChildren().addAll(line1, line2);
}
Scene scene = new Scene(root, 1200, 800);
scene.setOnMouseDragged(event -> {
root.setTranslateX(event.getX());
root.setTranslateY(event.getY());
});
primaryStage.setScene(scene);
primaryStage.show();
}
private Line createLine(double startX, double startY, double endX, double endY) {
double thickness = 1;
Line line = new Line(startX, startY, endX, endY);
line.setStroke(Color.RED);
line.setStrokeWidth(thickness);
if (dashed) {
line.setStrokeLineCap(StrokeLineCap.SQUARE);
line.getStrokeDashArray().addAll(0.0, 3.0 * thickness);
}
return line;
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-8160600 Inadequate performance when rendering dashed stroke
-
- Closed
-