jdk/test/sun/java2d/loops/Bug7049339.java
author schien
Thu, 25 Aug 2011 17:18:25 -0700
changeset 10304 df130f34ab4c
parent 10042 987fd92d0413
permissions -rw-r--r--
Added tag jdk8-b02 for changeset 88a0fd8156da
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10042
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
     1
/*
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
     2
 * Copyright 2011 Red Hat, Inc.  All Rights Reserved.
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
     3
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
     5
 *
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
     8
 * published by the Free Software Foundation.
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
     9
 *
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    14
 * accompanied this code).
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    15
 *
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    19
 *
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    22
 * questions.
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    23
 */
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    24
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    25
/*
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    26
  @test
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    27
  @bug 7049339
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    28
  @summary Copying images with a non-rectangular clip and a custom composite
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    29
           fails
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    30
  @author Denis Lila <dlila@redhat.com>
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    31
  @run main Bug7049339
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    32
 */
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    33
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    34
import java.awt.Composite;
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    35
import java.awt.CompositeContext;
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    36
import java.awt.Graphics2D;
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    37
import java.awt.RenderingHints;
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    38
import java.awt.Shape;
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    39
import java.awt.geom.Ellipse2D;
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    40
import java.awt.image.BufferedImage;
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    41
import java.awt.image.ColorModel;
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    42
import java.awt.image.Raster;
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    43
import java.awt.image.WritableRaster;
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    44
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    45
public class Bug7049339 {
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    46
    public static void main(String[] argv) {
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    47
        int x = 100, y = 100;
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    48
        BufferedImage src = new BufferedImage(x, y, BufferedImage.TYPE_INT_ARGB);
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    49
        BufferedImage dst = new BufferedImage(x, y, BufferedImage.TYPE_3BYTE_BGR);
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    50
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    51
        Graphics2D dstg2d = dst.createGraphics();
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    52
        dstg2d.setComposite(new Composite() {
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    53
            @Override
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    54
            public CompositeContext createContext(
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    55
                    ColorModel srcColorModel,
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    56
                    ColorModel dstColorModel,
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    57
                    RenderingHints hints)
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    58
            {
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    59
                return new CompositeContext() {
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    60
                    @Override
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    61
                    public void compose(Raster src, Raster dstIn,
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    62
                            WritableRaster dstOut)
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    63
                    {
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    64
                        // do nothing
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    65
                    }
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    66
                    @Override
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    67
                    public void dispose() {
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    68
                    }
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    69
                };
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    70
            }
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    71
        });
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    72
        Shape clip = new Ellipse2D.Double(x/4, y/4, x/2, y/2);
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    73
        dstg2d.setClip(clip);
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    74
        // This will throw a RasterFormatException if the bug is present.
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    75
        dstg2d.drawImage(src, 0, 0, null);
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    76
    }
987fd92d0413 7049339: AnyBlit is broken with non-rectangular clips.
dlila
parents:
diff changeset
    77
}