JDK-8055745 : drawImage fails on Direct3D pipeline when doing a XOR operation
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 7,7u5,8,9
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2012-07-22
  • Updated: 2014-08-21
  • Resolved: 2014-08-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Resolved
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.7.0_05"
Java(TM) SE Runtime Environment (build 1.7.0_05-b06)
Java HotSpot(TM) Client VM (build 23.1-b03, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
Also reproduced on Windows 7


A DESCRIPTION OF THE PROBLEM :
The bug applies to AWT applications (standalone and applet). The Direct3D pipeline should be enabled. If you first do a drawImage and then a XOR operation then the image won't appear.

Tested on:
1.6.0_14: OK
1.6.0_32: OK
1.7.0-b147: FAIL
1.7.0_05-b06: FAIL


REGRESSION.  Last worked in version 6u31

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
In your constructor you should create a BufferedImage img.
In your paint method you should do:
1. drawImage(img)
2. setXORMode
3. do something
4. setPaintMode

#!/bin/sh
java -cp . -Dsun.java2d.trace=log,verbose TestCase 0 > no_d3d.log 2>&1
export J2D_D3D=true
export J2D_D3D_NO_HWCHECK=true
java -cp . -Dsun.java2d.trace=log,verbose TestCase 0 > d3d_problem.log 2>&1
java -cp . -Dsun.java2d.trace=log,verbose TestCase 1 > d3d_workaround1.log 2>&1
java -cp . -Dsun.java2d.trace=log,verbose TestCase 2 > d3d_workaround2.log 2>&1
java -cp . -Dsun.java2d.trace=log,verbose TestCase 3 > d3d_workaround3.log 2>&1


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
  To see the img.
ACTUAL -
The img will flash and then disappear.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
In the "Steps to Reproduce" there is a script attached to generate useful log files.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics2D;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.util.Timer;
import java.util.TimerTask;

public class TestCase extends Frame {
    private BufferedImage image;
    public int workaround;
    
    public void init() {
        System.out.println("init enter");
        image = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
        Graphics2D g = image.createGraphics();
        g.setColor(Color.GREEN);
        g.fillRect(0,0,200,200);
        g.setColor(Color.RED);
        g.drawString("Hello, world!", 65, 100);
        System.out.println("init exit");
        Timer timer = new Timer();
        timer.schedule(new TerminateTask(), 3000);
    }
    
    public void paint(Graphics g) {
        System.out.println("paint enter");
        
        if (workaround != 0) {
          System.out.println("  applying workaround " + workaround);
        }
        
        switch (workaround) {
            case 1:
                g.setXORMode(Color.WHITE);
                g.drawLine(0, 0, 0, 0);
                g.setPaintMode();
                break;
            case 2:
                Graphics2D gg = image.createGraphics();
                gg.drawLine(0, 0, 0, 0);
                break;
            case 3:
                image.setRGB(0, 0, image.getRGB(0, 0));
                break;
        }
        
        g.drawImage(image, 0, 0, null);
        g.setXORMode(Color.WHITE);
        g.drawLine(0, 0, 0, 0);
        g.setPaintMode();
        System.out.println("paint exit");
    }
    
    public static void main(String args[]) {
        TestCase x = new TestCase();
        x.workaround = Integer.parseInt(args[0]);
        x.init();
        x.setSize(200, 200);
        x.setVisible(true);
    }
    
    class TerminateTask extends TimerTask {
        public void run() {
            System.exit(0);
        }
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
There are 3 workarounds in the source code.

Comments
Fixed my D3D and this looks like a duplicate of https://bugs.openjdk.java.net/browse/JDK-6986565 This test fails since JDK7 b126 just like that one. It looks like the image is drawn but then I see it painted over.
21-08-2014

I suspect that this is a duplicate but for some reason D3D isn't working on my system although it used to ...
21-08-2014

The bug was reproduced with JDK 9 b26, JDK 8u20 b26, JDK 7u67 b01 by means of test case provided in a description of the bug.
21-08-2014