-
Bug
-
Resolution: Fixed
-
P3
-
openjdk8u222
-
b05
Filed on behalf of David Alvarez (alvdavi@amazon.com).
The fix forJDK-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;
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g.create();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
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.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(new SoftClippingTest());
f.setSize(380, 210);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
}
```
The fix for
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.
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;
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g.create();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
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.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(new SoftClippingTest());
f.setSize(380, 210);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
}
```
- relates to
-
JDK-8048782 OpenJDK: PiscesCache : xmax/ymax rounding up can cause RasterFormatException
-
- Resolved
-
-
JDK-8221166 OpenJDK: PiscesCache : xmax/ymax rounding up can cause RasterFormatException
-
- Resolved
-