jdk/test/java/awt/image/DrawImage/IncorrectClipXorModeSW2Surface.java
author goetz
Tue, 14 Jun 2016 10:44:59 +0200
changeset 39056 d99e63b6d962
parent 27283 99c4cb470573
permissions -rw-r--r--
8159690: [TESTBUG] Mark headful tests with @key headful. Reviewed-by: simonis, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27283
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
     1
/*
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 27283
diff changeset
     2
 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
27283
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
     4
 *
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
     8
 *
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    13
 * accompanied this code).
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    14
 *
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    18
 *
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    21
 * questions.
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    22
 */
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    23
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    24
import java.awt.Color;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    25
import java.awt.Graphics2D;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    26
import java.awt.GraphicsConfiguration;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    27
import java.awt.GraphicsEnvironment;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    28
import java.awt.Image;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    29
import java.awt.Rectangle;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    30
import java.awt.Shape;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    31
import java.awt.geom.AffineTransform;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    32
import java.awt.image.BufferedImage;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    33
import java.awt.image.DataBuffer;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    34
import java.awt.image.DataBufferByte;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    35
import java.awt.image.DataBufferInt;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    36
import java.awt.image.DataBufferShort;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    37
import java.awt.image.VolatileImage;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    38
import java.io.File;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    39
import java.io.IOException;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    40
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    41
import javax.imageio.ImageIO;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    42
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    43
import static java.awt.geom.Rectangle2D.Double;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    44
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    45
/**
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    46
 * @test
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 27283
diff changeset
    47
 * @key headful
27283
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    48
 * @bug 8061456
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    49
 * @summary Tests drawing BI to volatile image using different clips + xor mode.
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    50
 *          Results of the blit BI to compatibleImage is used for comparison.
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    51
 * @author Sergey Bylokhov
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    52
 */
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    53
public final class IncorrectClipXorModeSW2Surface {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    54
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    55
    private static int[] SIZES = {2, 10, 100};
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    56
    private static final Shape[] SHAPES = {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    57
                                           new Rectangle(0, 0, 0, 0),
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    58
                                           new Rectangle(0, 0, 1, 1),
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    59
                                           new Rectangle(0, 1, 1, 1),
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    60
                                           new Rectangle(1, 0, 1, 1),
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    61
                                           new Rectangle(1, 1, 1, 1),
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    62
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    63
                                           new Double(0, 0, 0.5, 0.5),
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    64
                                           new Double(0, 0.5, 0.5, 0.5),
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    65
                                           new Double(0.5, 0, 0.5, 0.5),
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    66
                                           new Double(0.5, 0.5, 0.5, 0.5),
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    67
                                           new Double(0.25, 0.25, 0.5, 0.5),
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    68
                                           new Double(0, 0.25, 1, 0.5),
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    69
                                           new Double(0.25, 0, 0.5, 1),
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    70
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    71
                                           new Double(.10, .10, .20, .20),
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    72
                                           new Double(.75, .75, .20, .20),
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    73
                                           new Double(.75, .10, .20, .20),
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    74
                                           new Double(.10, .75, .20, .20),
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    75
    };
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    76
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    77
    public static void main(final String[] args) throws IOException {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    78
        GraphicsEnvironment ge = GraphicsEnvironment
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    79
                .getLocalGraphicsEnvironment();
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    80
        GraphicsConfiguration gc = ge.getDefaultScreenDevice()
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    81
                                     .getDefaultConfiguration();
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    82
        AffineTransform at;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    83
        for (int size : SIZES) {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    84
            at = AffineTransform.getScaleInstance(size, size);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    85
            for (Shape clip : SHAPES) {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    86
                clip = at.createTransformedShape(clip);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    87
                for (Shape to : SHAPES) {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    88
                    to = at.createTransformedShape(to);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    89
                    // Prepare test images
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    90
                    BufferedImage snapshot;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    91
                    BufferedImage bi = getBufferedImage(size);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    92
                    VolatileImage vi = getVolatileImage(gc, size);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    93
                    while (true) {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    94
                        vi.validate(gc);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    95
                        Graphics2D g2d = vi.createGraphics();
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    96
                        g2d.setColor(Color.GREEN);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    97
                        g2d.fillRect(0, 0, size, size);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    98
                        g2d.dispose();
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
    99
                        if (vi.validate(gc) != VolatileImage.IMAGE_OK) {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   100
                            continue;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   101
                        }
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   102
                        draw(clip, to, bi, vi);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   103
                        snapshot = vi.getSnapshot();
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   104
                        if (vi.contentsLost()) {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   105
                            continue;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   106
                        }
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   107
                        break;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   108
                    }
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   109
                    // Prepare gold images
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   110
                    BufferedImage goldvi = getCompatibleImage(gc, size);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   111
                    BufferedImage goldbi = getBufferedImage(size);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   112
                    draw(clip, to, goldbi, goldvi);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   113
                    validate(snapshot, goldvi);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   114
                    vi.flush();
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   115
                }
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   116
            }
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   117
        }
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   118
    }
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   119
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   120
    private static void draw(Shape clip, Shape shape, Image from, Image to) {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   121
        Graphics2D g2d = (Graphics2D) to.getGraphics();
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   122
        g2d.setXORMode(Color.BLACK);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   123
        g2d.setClip(clip);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   124
        Rectangle toBounds = shape.getBounds();
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   125
        g2d.drawImage(from, toBounds.x, toBounds.y, toBounds.width,
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   126
                      toBounds.height, null);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   127
        g2d.dispose();
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   128
    }
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   129
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   130
    private static BufferedImage getBufferedImage(int sw) {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   131
        final BufferedImage bi = new BufferedImage(sw, sw, BufferedImage.TYPE_INT_ARGB);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   132
        Graphics2D g2d = bi.createGraphics();
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   133
        g2d.setColor(Color.RED);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   134
        g2d.fillRect(0, 0, sw, sw);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   135
        g2d.dispose();
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   136
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   137
        final DataBuffer db = bi.getRaster().getDataBuffer();
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   138
        if (db instanceof DataBufferInt) {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   139
            ((DataBufferInt) db).getData();
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   140
        } else if (db instanceof DataBufferShort) {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   141
            ((DataBufferShort) db).getData();
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   142
        } else if (db instanceof DataBufferByte) {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   143
            ((DataBufferByte) db).getData();
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   144
        } else {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   145
            try {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   146
                bi.setAccelerationPriority(0.0f);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   147
            } catch (final Throwable ignored) {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   148
            }
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   149
        }
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   150
        return bi;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   151
    }
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   152
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   153
    private static VolatileImage getVolatileImage(GraphicsConfiguration gc,
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   154
                                                  int size) {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   155
        return gc.createCompatibleVolatileImage(size, size);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   156
    }
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   157
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   158
    private static BufferedImage getCompatibleImage(GraphicsConfiguration gc,
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   159
                                                    int size) {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   160
        BufferedImage image = gc.createCompatibleImage(size, size);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   161
        Graphics2D g2d = image.createGraphics();
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   162
        g2d.setColor(Color.GREEN);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   163
        g2d.fillRect(0, 0, size, size);
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   164
        g2d.dispose();
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   165
        return image;
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   166
    }
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   167
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   168
    private static void validate(BufferedImage bi, BufferedImage goldbi)
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   169
            throws IOException {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   170
        for (int x = 0; x < bi.getWidth(); ++x) {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   171
            for (int y = 0; y < bi.getHeight(); ++y) {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   172
                if (goldbi.getRGB(x, y) != bi.getRGB(x, y)) {
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   173
                    ImageIO.write(bi, "png", new File("actual.png"));
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   174
                    ImageIO.write(goldbi, "png", new File("expected.png"));
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   175
                    throw new RuntimeException("Test failed.");
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   176
                }
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   177
            }
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   178
        }
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   179
    }
99c4cb470573 8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff changeset
   180
}