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

Linear Gradient not rendered properly in j2d pipeline

    Details

    • Type: Bug
    • Status: Open
    • Priority: P5
    • Resolution: Unresolved
    • Affects Version/s: 8
    • Fix Version/s: tbd
    • Component/s: javafx
    • Labels:
    • Environment:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      windows_7

      Description

      Given a JavaFX application with the following start() method:

          public void start(Stage primaryStage) {

              Group mainGroup = new Group();
              Rectangle r = new Rectangle(0, 0, 200, 200);

              Stop[] stops = new Stop[] { new Stop(0, new Color(0.0, 0.0, 1.0, 1.0)),
                                          new Stop(1, new Color(1.0, 1.0, 1.0, 0.0)) };
              LinearGradient lg = new LinearGradient(0, 0, 200, 200, false,
                                                     CycleMethod.NO_CYCLE,
                                                     stops);
              r.setFill(lg);

              mainGroup.getChildren().addAll(r);
              Scene scene = new Scene(mainGroup, 200, 200);
              primaryStage.setScene(scene);
              primaryStage.show();
          }

      This renders as shown in the left window in the attached screenshot. It looks like the opacity is not properly interpolated between the two Stop's. When using the deprecated j2d rendering pipeline with "-Dprism.order=j2d" the output looks as shown in the right window in the attached screenshot, which is the expected output.

      Actually, when we retrieve the center pixels of the image like

         ...
          WritableImage image = scene.snapshot(null);
          PixelReader pixelReader = image.getPixelReader();
          System.out.println("Color: " + pixelReader.getColor((int)image.getWidth()/2, (int)image.getHeight()/2));
         ...
      we get the same value for the alpha channel (seems like opacity is properly interpolated), but different values for the red and green channels:

      Default pipeline: Color: 0x0000ff7f
      -Dprism.order=j2d pipeline: Color: 0x7e7eff7f

      So the issue seems to be that the RGB values are not properly interpolated.

        Attachments

        1. gradientIssue.png
          gradientIssue.png
          87 kB
        2. gradients.png
          gradients.png
          20 kB
        3. html5svg.html
          1 kB

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              afester Andreas Fester
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: