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

Revert 8221166 (8u backport of 8048782)


    • Subcomponent:
    • Introduced In Version:
    • Resolved In Build:


      Filed on behalf of David Alvarez (alvdavi@amazon.com).

      The fix for JDK-8048782 can cause the PiscesRenderingEngine to misalign the rendering tiles when the shape size is a multiple of the tile size (32). This causes the last tile of the first row to be drawn as the first tile of the second row. The error is compounded into subsequent rows.

      The problem is that internally, PiscesCache works with a boundary box that is one pixel larger than originally requested. In certain circumstances, this extra pixel could cause a RasterFormatException. JDK-8048782 fixed this by exposing a "corrected" boundary box to AAShapePipe. However, the PiscesTileGenerator nextTile method still works with the slightly larger bounding box. This means the renderTiles method in AAShapePipe and the next Tile method in PiscesTileGenerator are working with different sizes for the bounding box. For values that are exact multiples of the tile size, renderTiles rolls over to the next row one tile sooner than PiscesTileGenerator, causing the misalignment and rendering issues.

      The supplied program demonstrates this issue by rendering two round rectangles, the left one having a size that is an exact multiple of the tile size. As JDK9 uses MarlinRenderingEngine by default, it is necessary to execute this program passing -Dsun.java2d.renderer=sun.java2d.pisces.PiscesRenderingEngine.
          import java.awt.Graphics;
          import java.awt.Graphics2D;
          import java.awt.RenderingHints;
          import java.awt.geom.RoundRectangle2D;

          import javax.swing.JFrame;
          import javax.swing.JPanel;

          public class PiscesTileMisalignmentBug extends JPanel {
              private static final int SIZE = 160;

              public void paintComponent(Graphics g) {
                  Graphics2D g2 = (Graphics2D) g.create();
                  g2.fill(new RoundRectangle2D.Float(15f, 15f, SIZE, SIZE, 32f, 32f));
                  g2.fill(new RoundRectangle2D.Float(190, 15f, SIZE + 1, SIZE + 1, 32f, 32f));

              public static void main(String[] args) {
                  JFrame f = new JFrame();
                  f.getContentPane().add(new SoftClippingTest());
                  f.setSize(380, 210);


          Issue Links



              • Assignee:
                phh Paul Hohensee
                phh Paul Hohensee
              • Votes:
                0 Vote for this issue
                1 Start watching this issue


                • Created: