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

RasterFormatException in conjunction with custom composite and clipping

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 7u75, 8u20, 8u31
    • client-libs
    • 2d
    • x86_64
    • linux

      FULL PRODUCT VERSION :
      java version "1.7.0_75"
      OpenJDK Runtime Environment (IcedTea 2.5.4) (7u75-2.5.4-1~trusty1)
      OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Linux 3.13.0-48-generic #80-Ubuntu SMP Thu Mar 12 11:16:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      The following code provided below should execute without an exception (but not yield a meaningful output due to the composite being a stub). Instead, the last line causes a RasterFormatException (see below) to be thrown.

      This issue seems to be the OpenJDK-incarnation of JDK-6943486 and related variants thereof. However, with a very different stack, it does not appear to be a duplicate.

      The bug seems to be caused by the following chain of events:
      - In PiscesRendering.getAATileGenerator(...) the PiscesTileGenerator and PiscesCache is used to determine the bounding-box of a rendering of the clip shape.
      - In the constructor the cache is enlarged by one pixel (likely to accommodate AA).
      - The bbox is subsequently used to cut tiles for compositing.
      - If the actual clip shape touches the device boundaries this will lead to the compositing to exceed the raster by one pixel triggering an AIIOBE.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the code provided above.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Code runs without throwing an exception.
      ACTUAL -
      Last line throws an exception.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.awt.image.RasterFormatException: (x + width) is outside raster
      at sun.awt.image.IntegerInterleavedRaster.createWritableChild(IntegerInterleavedRaster.java:467)
      at sun.awt.image.IntegerInterleavedRaster.createChild(IntegerInterleavedRaster.java:514)
      at sun.java2d.pipe.GeneralCompositePipe.renderPathTile(GeneralCompositePipe.java:106)
      at sun.java2d.pipe.AAShapePipe.renderTiles(AAShapePipe.java:201)
      at sun.java2d.pipe.AAShapePipe.fillParallelogram(AAShapePipe.java:102)
      at sun.java2d.pipe.PixelToParallelogramConverter.fillRectangle(PixelToParallelogramConverter.java:322)
      at sun.java2d.pipe.PixelToParallelogramConverter.fill(PixelToParallelogramConverter.java:159)
      at sun.java2d.pipe.ValidatePipe.fill(ValidatePipe.java:160)
      at sun.java2d.SunGraphics2D.fill(SunGraphics2D.java:2466)
      at tryout.TryoutCompositing.main(TryoutCompositing.java:46)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.Composite;
      import java.awt.CompositeContext;
      import java.awt.Graphics2D;
      import java.awt.RenderingHints;
      import java.awt.geom.Rectangle2D;
      import java.awt.image.BufferedImage;
      import java.awt.image.ColorModel;
      import java.awt.image.Raster;
      import java.awt.image.WritableRaster;

      public class TryoutCompositing {

        public static class DummyComposite implements Composite {
          @Override
          public CompositeContext createContext(ColorModel srcColorModel, ColorModel dstColorModel, RenderingHints hints) {
            return new DummyCompositeContext();
          }
        }
        
        public static class DummyCompositeContext implements CompositeContext {
          @Override
          public void dispose() { }

          @Override
          public void compose(Raster src, Raster dstIn, WritableRaster dstOut) { }
        }
        
        public static void main(String[] args) {
          int SIZE = 100;
          
          BufferedImage bi = new BufferedImage(SIZE, SIZE, BufferedImage.TYPE_INT_ARGB);
          Graphics2D g2d = bi.createGraphics();
          
          g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
          g2d.setComposite(new DummyComposite());
          
          Rectangle2D rect= new Rectangle2D.Double(0,0,SIZE, SIZE);
          g2d.setClip(rect);
          g2d.fill(rect); // throws exception
        }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Any of the following approaches will cause the but to not be triggered:
      - turning off AA
      - using a non-rectangular clip area
      - not filling the device (image) space completely

            prr Philip Race
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: