Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8226789

Path rendered incorrectly when it goes outside the clipping region

    XMLWordPrintable

Details

    • x86_64
    • windows_10

    Description

      ADDITIONAL SYSTEM INFORMATION :
      JavaFX 12.0.1 (also tested with Java 13-ea+9 with the same outcome)

      openjdk version "12" 2019-03-19
      OpenJDK Runtime Environment (build 12+33)
      OpenJDK 64-Bit Server VM (build 12+33, mixed mode, sharing)

      Windows 10 version 1903

      A DESCRIPTION OF THE PROBLEM :
      A path in a shape of a square with a circular hole is constructed. Before that, a rectangular clipping region is set so that the lower two vertices of the square are outside of it. Rendering such path produces wrong result.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the provided program.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No path artifacts.
      ACTUAL -
      Wrong path rendered.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.canvas.Canvas;
      import javafx.scene.canvas.GraphicsContext;
      import javafx.scene.layout.StackPane;
      import javafx.scene.paint.Color;
      import javafx.stage.Stage;

      public class PathBug extends Application {

      @Override
      public void start(Stage primaryStage) {
      double w = 400;
      double h = 400;

      Canvas canvas = new Canvas(w, h);
      GraphicsContext gc = canvas.getGraphicsContext2D();


      gc.setFill(Color.BLACK);
      gc.fillRect(0, 0, w, h);

      // Setting the clip to exclude the lower 50 pixels.
      gc.beginPath();
      gc.rect(0, 0, w, h-50);
      gc.closePath();
      gc.clip(); // Comment this line out to see the intended shape.

      // Constructing a path that should look like a square with a hole.
      gc.beginPath();
      gc.rect(20, 20, w-40, h-40);
      gc.arc(200, 200, 100, 100, 0, 360);
      gc.closePath();

      gc.setFill(Color.CORNFLOWERBLUE);
      gc.fill();


      StackPane root = new StackPane();
      root.getChildren().add(canvas);
      Scene scene = new Scene(root);

      primaryStage.setScene(scene);
      primaryStage.show();
      }


      public static void main(String[] args) {
      Application.launch(args);
      }
      }

      ---------- END SOURCE ----------

      FREQUENCY : always


      Attachments

        Issue Links

          Activity

            People

              lbourges Laurent Bourgès
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: