JDK-8040635 : [macosx] Printing a shape filled with a texture doesn't work under Mac OS X
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 7u40,8,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • Submitted: 2013-09-23
  • Updated: 2017-11-29
  • Resolved: 2016-11-04
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 8 JDK 9
8u152Fixed 9 b147Fixed
Related Reports
Duplicate :  
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Darwin 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64


EXTRA RELEVANT SYSTEM CONFIGURATION :
I don't think it's bound to the printer since I tested in preview mode and with two printers, and the same bug appeared each time.

A DESCRIPTION OF THE PROBLEM :
Printing a shape with a TexturePaint instance as paint doesn't work

REGRESSION.  Last worked in version 6u45

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the program below, and accept to print.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expected the printed page would show a rectangle filled with a pattern
ACTUAL -
The printed page showed only an empty rectangle

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.awt.print.*;

public class PatternFillBug {
  public static void main(String [] args) throws PrinterException {
    PrinterJob printerJob = PrinterJob.getPrinterJob();
    printerJob.setPrintable(new Printable() {
        public int print(Graphics g, PageFormat pageFormat,
                         int index) throws PrinterException {
          if (index == 1) {
            return NO_SUCH_PAGE;
          }
          // Create a simple pattern
          BufferedImage patternImage = new BufferedImage(2, 2, BufferedImage.TYPE_INT_ARGB);
          Graphics gImage = patternImage.getGraphics();
          gImage.setColor(Color.WHITE);
          gImage.drawLine(0, 1, 1, 0);
          gImage.setColor(Color.BLACK);
          gImage.drawLine(0, 0, 1, 1);
          gImage.dispose();
          
          Graphics2D g2D = (Graphics2D)g;
          // Fill a part of the page with pattern
          Rectangle2D.Double shape = new Rectangle2D.Double(pageFormat.getImageableX(), pageFormat.getImageableY(),
              pageFormat.getImageableWidth() / 5, pageFormat.getImageableHeight() / 5);
          g2D.setPaint(new TexturePaint(patternImage, new Rectangle2D.Double(0, 0,
              pageFormat.getImageableWidth() / 50, pageFormat.getImageableHeight() / 50)));
          g2D.fill(shape);
          // Surround it with a rectangle
          g2D.setPaint(Color.BLACK);
          g2D.draw(shape);
          return PAGE_EXISTS;
        }
      });
    
    // Show print dialog and print
    if (printerJob.printDialog()) {
      printerJob.print();
    }
  }
}
---------- END SOURCE ----------
Comments
The issue was because TexturePaint Evaluate function in native QuartzSurfaceData.m uses LockImage() function to access texture buffered image. In LockImage(), it accesses image data by checking javaImageInfo[sun_java2d_OSXOffScreenSurfaceData_kImageStolenIndex] and javaImageInfo[sun_java2d_OSXOffScreenSurfaceData_kNeedToSyncFromJavaP ixelsIndex] and this variable "kImageStolenIndex" and "kNeedToSyncFromJavaPixelsIndex" are set in OSXOffScreenSurfaceData but OSXSurfaceData uses BufImgSurfaceData.createData which does not set this variables resulting in crash when it tries to access data buffer with wrong unset index. Proposed fix is to use OSXOffscreenSurfaceData where the variables, accessed by native, are set properly
04-11-2016

Note that we also have https://bugs.openjdk.java.net/browse/JDK-8162796 which mentions that LinearGradientPaint *and* RadialGradientPaint do not work. I will *not* currently close that as a dup but will keep it open so we have IDs under which to solve some of these separately. If we fix just one of these I think LinearGradientPaint should be it, since this is coming up multiple times in JavaFX printing.
12-08-2016

The bug: - was reproduced on OS X 10.9.5 with JDK 9 b84, JDK 8u60 b27, JDK 7u85 b15. - could not be reproduced on MS Windows 7 OS with JDK 9 b84, JDK 8u60 b27, JDK 7u85 b15.
08-10-2015

not a regression for 8 and 9
12-12-2014

- this is an issue reported against 7(7u), - there are now affected version 9 filed for this issue - 7u issues are transferred to Sustaining Nevertheless if someone have a report against 9 - please reopen and add affectedVersion 9 or 7u specific escalations might be reopen to Sustaining
10-08-2014

- this is an issue reported against 7(7u), - there are now affected version 9 filed for this issue - 7u issues are transferred to Sustaining Nevertheless if someone have a report against 9 - please reopen and add affectedVersion 9 or 7u specific escalations might be reopen to Sustaining
10-08-2014

Per agreement with Victor sustaining takes all the bugs that formally reported against JDK7. We may return them back after the evaluation if some of them are reproducible on JDK8 or 9.
07-05-2014

Will need review for >= JDK 7 Moving to 7u80 and will review ASAP. Ping me directly with any concerns about this move.
22-04-2014

is it affecting 8 or 9?
17-04-2014