-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
b36
-
generic
-
solaris_9
Jim found that this program can crash the runtime when run in X11 mode,
but runs fine in DGA mode.
Reproducible in 1.4.2, 1.5 b30.
The test app:
-------- ScaleImgTest.java --------
import java.awt.*;
public class ScaleImgTest extends Canvas {
public static final int TESTW = 100;
public static final int TESTH = 100;
public static final int BORDER = 25;
public static final int STEP = 1;
public static final int SIDEW = TESTW + 2 * BORDER;
public static final int SIDEH = TESTH + 2 * BORDER;
public static final int CANVASW = SIDEW * 5;
public static final int CANVASH = SIDEH;
int osx1, osx2, osy1, osy2;
int sx1, sx2, sy1, sy2;
int which; // which corners to move
int distance; // how far the corners have moved from base position
int dir; // corners moving outward or inward?
Image img;
Image srcimg;
public ScaleImgTest() {
osx1 = sx1 = BORDER;
osy1 = sy1 = BORDER;
osx2 = sx2 = TESTW - BORDER;
osy2 = sy2 = TESTH - BORDER;
which = 1;
distance = 0;
dir = 1;
}
public void update(Graphics g) {
paint(g);
}
public void paint(Graphics g) {
if (img == null || srcimg == null) {
img = createImage(CANVASW, CANVASH);
srcimg = createImage(TESTW, TESTH);
Graphics g2 = srcimg.getGraphics();
g2.setColor(Color.green);
g2.fillRect(0, 0, TESTW, TESTH);
g2.setColor(Color.blue);
for (int i = 0; i < TESTW; i += 3) {
g2.fillRect(i, 0, 1, TESTH);
}
for (int i = 0; i < TESTH; i += 3) {
g2.fillRect(0, i, TESTH, 1);
}
g2.dispose();
}
Graphics2D g2 = (Graphics2D) img.getGraphics();
render(g2);
g.drawImage(img, 0, 0, null);
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
//render(g2);
g.drawImage(img, 0, CANVASH, null);
g2.dispose();
}
public void render(Graphics g) {
g.setColor(Color.white);
g.fillRect(0, 0, CANVASW, CANVASH);
g.drawImage(srcimg, BORDER, BORDER, null);
g.setColor(Color.red);
g.drawRect(BORDER + sx1, BORDER + sy1, sx2-sx1-1, sy2-sy1-1);
for (int i = 0; i < 4; i++) {
int x = SIDEW * (i+1);
int sx1, sx2, sy1, sy2;
if (((i >> 0) & 1) == 0) {
sx1 = this.sx1;
sx2 = this.sx2;
} else {
sx1 = this.sx2;
sx2 = this.sx1;
}
if (((i >> 1) & 1) == 0) {
sy1 = this.sy1;
sy2 = this.sy2;
} else {
sy1 = this.sy2;
sy2 = this.sy1;
}
g.drawRect(x+BORDER-1, BORDER-1, TESTW+1, TESTH+1);
g.drawImage(srcimg,
x+BORDER, BORDER,
x+BORDER+TESTW, BORDER+TESTH,
sx1, sy1, sx2, sy2,
null);
break;
}
}
public Dimension getPreferredSize() {
return new Dimension(CANVASW, CANVASH*2);
}
public void start() {
while (true) {
if (dir > 0) {
distance += STEP;
if (distance >= BORDER * 2) {
dir = -1;
}
} else {
distance -= STEP;
if (distance <= 0) {
dir = 1;
which++;
}
}
sx1 = osx1 - ((which >> 0) & 1) * distance;
sy1 = osy1 - ((which >> 1) & 1) * distance;
sx2 = osx2 + ((which >> 2) & 1) * distance;
sy2 = osy2 + ((which >> 3) & 1) * distance;
repaint();
try {
Thread.sleep(10);
} catch (InterruptedException e) {
return;
}
}
}
public static void main(String argv[]) {
Frame f = new Frame();
ScaleImgTest sit = new ScaleImgTest();
f.add(sit);
f.pack();
f.show();
sit.start();
}
}
-------- ScaleImgTest.java --------
###@###.### 2003-12-12
but runs fine in DGA mode.
Reproducible in 1.4.2, 1.5 b30.
The test app:
-------- ScaleImgTest.java --------
import java.awt.*;
public class ScaleImgTest extends Canvas {
public static final int TESTW = 100;
public static final int TESTH = 100;
public static final int BORDER = 25;
public static final int STEP = 1;
public static final int SIDEW = TESTW + 2 * BORDER;
public static final int SIDEH = TESTH + 2 * BORDER;
public static final int CANVASW = SIDEW * 5;
public static final int CANVASH = SIDEH;
int osx1, osx2, osy1, osy2;
int sx1, sx2, sy1, sy2;
int which; // which corners to move
int distance; // how far the corners have moved from base position
int dir; // corners moving outward or inward?
Image img;
Image srcimg;
public ScaleImgTest() {
osx1 = sx1 = BORDER;
osy1 = sy1 = BORDER;
osx2 = sx2 = TESTW - BORDER;
osy2 = sy2 = TESTH - BORDER;
which = 1;
distance = 0;
dir = 1;
}
public void update(Graphics g) {
paint(g);
}
public void paint(Graphics g) {
if (img == null || srcimg == null) {
img = createImage(CANVASW, CANVASH);
srcimg = createImage(TESTW, TESTH);
Graphics g2 = srcimg.getGraphics();
g2.setColor(Color.green);
g2.fillRect(0, 0, TESTW, TESTH);
g2.setColor(Color.blue);
for (int i = 0; i < TESTW; i += 3) {
g2.fillRect(i, 0, 1, TESTH);
}
for (int i = 0; i < TESTH; i += 3) {
g2.fillRect(0, i, TESTH, 1);
}
g2.dispose();
}
Graphics2D g2 = (Graphics2D) img.getGraphics();
render(g2);
g.drawImage(img, 0, 0, null);
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
//render(g2);
g.drawImage(img, 0, CANVASH, null);
g2.dispose();
}
public void render(Graphics g) {
g.setColor(Color.white);
g.fillRect(0, 0, CANVASW, CANVASH);
g.drawImage(srcimg, BORDER, BORDER, null);
g.setColor(Color.red);
g.drawRect(BORDER + sx1, BORDER + sy1, sx2-sx1-1, sy2-sy1-1);
for (int i = 0; i < 4; i++) {
int x = SIDEW * (i+1);
int sx1, sx2, sy1, sy2;
if (((i >> 0) & 1) == 0) {
sx1 = this.sx1;
sx2 = this.sx2;
} else {
sx1 = this.sx2;
sx2 = this.sx1;
}
if (((i >> 1) & 1) == 0) {
sy1 = this.sy1;
sy2 = this.sy2;
} else {
sy1 = this.sy2;
sy2 = this.sy1;
}
g.drawRect(x+BORDER-1, BORDER-1, TESTW+1, TESTH+1);
g.drawImage(srcimg,
x+BORDER, BORDER,
x+BORDER+TESTW, BORDER+TESTH,
sx1, sy1, sx2, sy2,
null);
break;
}
}
public Dimension getPreferredSize() {
return new Dimension(CANVASW, CANVASH*2);
}
public void start() {
while (true) {
if (dir > 0) {
distance += STEP;
if (distance >= BORDER * 2) {
dir = -1;
}
} else {
distance -= STEP;
if (distance <= 0) {
dir = 1;
which++;
}
}
sx1 = osx1 - ((which >> 0) & 1) * distance;
sy1 = osy1 - ((which >> 1) & 1) * distance;
sx2 = osx2 + ((which >> 2) & 1) * distance;
sy2 = osy2 + ((which >> 3) & 1) * distance;
repaint();
try {
Thread.sleep(10);
} catch (InterruptedException e) {
return;
}
}
}
public static void main(String argv[]) {
Frame f = new Frame();
ScaleImgTest sit = new ScaleImgTest();
f.add(sit);
f.pack();
f.show();
sit.start();
}
}
-------- ScaleImgTest.java --------
###@###.### 2003-12-12
- relates to
-
JDK-6220829 Regression: Test 4967812 fails with 1.5.0_02 and mustang but passes with 1.5.0_01-b08
-
- Resolved
-