jdk/test/sun/java2d/OpenGL/DrawBufImgOp.java
author sherman
Tue, 22 Jun 2010 14:04:36 -0400
changeset 5962 0913689fd3a0
parent 5506 202f599c92aa
child 39056 d99e63b6d962
permissions -rw-r--r--
6963156: TEST_BUG: Several tests under sun/nio/cs failed Summary: Updated the test cases and removed them from ProblemList.txt Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 887
diff changeset
     2
 * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
     4
 *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
     7
 * published by the Free Software Foundation.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
     8
 *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    13
 * accompanied this code).
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    14
 *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 887
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 887
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 887
diff changeset
    21
 * questions.
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    22
 */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    23
/*
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    24
 * @test
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    25
 * @bug 6514990
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    26
 * @summary Verifies that calling
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    27
 * Graphics2D.drawImage(BufferedImage, BufferedImageOp, x, y) to an
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    28
 * OpenGL-accelerated destination produces the same results when performed
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    29
 * in software via BufferedImageOp.filter().
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    30
 * @run main/othervm -Dsun.java2d.opengl=True DrawBufImgOp -ignore
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    31
 * @author campbelc
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    32
 */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    33
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    34
import java.awt.*;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    35
import java.awt.image.*;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    36
import java.io.File;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    37
import javax.imageio.ImageIO;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    38
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    39
/**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    40
 * REMIND: This testcase was originally intended to automatically compare
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    41
 * the results of the software BufferedImageOp implementations against
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    42
 * the OGL-accelerated codepaths.  However, there are just too many open
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    43
 * bugs in the mediaLib-based codepaths (see below), which means that
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    44
 * creating the reference image may cause crashes or exceptions,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    45
 * and even if we work around those cases using the "-ignore" flag,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    46
 * the visual results of the reference image are often buggy as well
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    47
 * (so the comparison will fail even though the OGL results are correct).
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    48
 * Therefore, for now we will run the testcase with the "-ignore" flag
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    49
 * but without the "-compare" flag, so at least it will be checking for
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    50
 * any exceptions/crashes in the OGL code.  When we fix all of the
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    51
 * outstanding bugs with the software codepaths, we can remove the
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    52
 * "-ignore" flag and maybe even restore the "-compare" flag.  In the
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    53
 * meantime, it stil functions well as a manual testcase (with either
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    54
 * the "-show" or "-dump" options).
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    55
 */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    56
public class DrawBufImgOp extends Canvas {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    57
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    58
    private static final int TESTW = 600;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    59
    private static final int TESTH = 500;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    60
    private static boolean done;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    61
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    62
    /*
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    63
     * If true, skips tests that are known to trigger bugs (which in
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    64
     * turn may cause crashes, exceptions, or other artifacts).
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    65
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    66
    private static boolean ignore;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    67
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    68
    // Test both pow2 and non-pow2 sized images
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    69
    private static final int[] srcSizes = { 32, 17 };
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    70
    private static final int[] srcTypes = {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    71
        BufferedImage.TYPE_INT_RGB,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    72
        BufferedImage.TYPE_INT_ARGB,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    73
        BufferedImage.TYPE_INT_ARGB_PRE,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    74
        BufferedImage.TYPE_INT_BGR,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    75
        BufferedImage.TYPE_3BYTE_BGR,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    76
        BufferedImage.TYPE_4BYTE_ABGR,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    77
        BufferedImage.TYPE_USHORT_565_RGB,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    78
        BufferedImage.TYPE_BYTE_GRAY,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    79
        BufferedImage.TYPE_USHORT_GRAY,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    80
    };
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    81
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    82
    private static final RescaleOp
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    83
        rescale1band, rescale3band, rescale4band;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    84
    private static final LookupOp
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    85
        lookup1bandbyte, lookup3bandbyte, lookup4bandbyte;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    86
    private static final LookupOp
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    87
        lookup1bandshort, lookup3bandshort, lookup4bandshort;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    88
    private static final ConvolveOp
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    89
        convolve3x3zero, convolve5x5zero, convolve7x7zero;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    90
    private static final ConvolveOp
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    91
        convolve3x3noop, convolve5x5noop, convolve7x7noop;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    92
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    93
    static {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    94
        rescale1band = new RescaleOp(0.5f, 10.0f, null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    95
        rescale3band = new RescaleOp(
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    96
            new float[] {  0.6f,  0.4f, 0.6f },
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    97
            new float[] { 10.0f, -3.0f, 5.0f },
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    98
            null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    99
        rescale4band = new RescaleOp(
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   100
            new float[] {  0.6f, 0.4f, 0.6f, 0.9f },
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   101
            new float[] { -1.0f, 5.0f, 3.0f, 1.0f },
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   102
            null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   103
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   104
        // REMIND: we should probably test non-zero offsets, but that
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   105
        // would require massaging the source image data to avoid going
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   106
        // outside the lookup table array bounds
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   107
        int offset = 0;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   108
        {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   109
            byte invert[] = new byte[256];
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   110
            byte halved[] = new byte[256];
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   111
            for (int j = 0; j < 256 ; j++) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   112
                invert[j] = (byte) (255-j);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   113
                halved[j] = (byte) (j / 2);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   114
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   115
            ByteLookupTable lut1 = new ByteLookupTable(offset, invert);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   116
            lookup1bandbyte = new LookupOp(lut1, null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   117
            ByteLookupTable lut3 =
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   118
                new ByteLookupTable(offset,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   119
                                    new byte[][] {invert, halved, invert});
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   120
            lookup3bandbyte = new LookupOp(lut3, null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   121
            ByteLookupTable lut4 =
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   122
                new ByteLookupTable(offset,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   123
                               new byte[][] {invert, halved, invert, halved});
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   124
            lookup4bandbyte = new LookupOp(lut4, null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   125
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   126
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   127
        {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   128
            short invert[] = new short[256];
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   129
            short halved[] = new short[256];
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   130
            for (int j = 0; j < 256 ; j++) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   131
                invert[j] = (short) ((255-j) * 255);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   132
                halved[j] = (short) ((j / 2) * 255);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   133
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   134
            ShortLookupTable lut1 = new ShortLookupTable(offset, invert);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   135
            lookup1bandshort = new LookupOp(lut1, null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   136
            ShortLookupTable lut3 =
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   137
                new ShortLookupTable(offset,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   138
                                     new short[][] {invert, halved, invert});
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   139
            lookup3bandshort = new LookupOp(lut3, null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   140
            ShortLookupTable lut4 =
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   141
                new ShortLookupTable(offset,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   142
                              new short[][] {invert, halved, invert, halved});
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   143
            lookup4bandshort = new LookupOp(lut4, null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   144
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   145
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   146
        // 3x3 blur
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   147
        float[] data3 = {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   148
            0.1f, 0.1f, 0.1f,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   149
            0.1f, 0.2f, 0.1f,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   150
            0.1f, 0.1f, 0.1f,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   151
        };
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   152
        Kernel k3 = new Kernel(3, 3, data3);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   153
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   154
        // 5x5 edge
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   155
        float[] data5 = {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   156
            -1.0f, -1.0f, -1.0f, -1.0f, -1.0f,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   157
            -1.0f, -1.0f, -1.0f, -1.0f, -1.0f,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   158
            -1.0f, -1.0f, 24.0f, -1.0f, -1.0f,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   159
            -1.0f, -1.0f, -1.0f, -1.0f, -1.0f,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   160
            -1.0f, -1.0f, -1.0f, -1.0f, -1.0f,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   161
        };
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   162
        Kernel k5 = new Kernel(5, 5, data5);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   163
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   164
        // 7x7 blur
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   165
        float[] data7 = {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   166
            0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   167
            0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   168
            0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   169
            0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   170
            0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   171
            0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   172
            0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   173
        };
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   174
        Kernel k7 = new Kernel(7, 7, data7);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   175
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   176
        convolve3x3zero = new ConvolveOp(k3, ConvolveOp.EDGE_ZERO_FILL, null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   177
        convolve5x5zero = new ConvolveOp(k5, ConvolveOp.EDGE_ZERO_FILL, null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   178
        convolve7x7zero = new ConvolveOp(k7, ConvolveOp.EDGE_ZERO_FILL, null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   179
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   180
        convolve3x3noop = new ConvolveOp(k3, ConvolveOp.EDGE_NO_OP, null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   181
        convolve5x5noop = new ConvolveOp(k5, ConvolveOp.EDGE_NO_OP, null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   182
        convolve7x7noop = new ConvolveOp(k7, ConvolveOp.EDGE_NO_OP, null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   183
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   184
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   185
    public void paint(Graphics g) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   186
        synchronized (this) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   187
            if (done) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   188
                return;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   189
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   190
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   191
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   192
        VolatileImage vimg = createVolatileImage(TESTW, TESTH);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   193
        vimg.validate(getGraphicsConfiguration());
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   194
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   195
        Graphics2D g2d = vimg.createGraphics();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   196
        renderTest(g2d);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   197
        g2d.dispose();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   198
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   199
        g.drawImage(vimg, 0, 0, null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   200
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   201
        Toolkit.getDefaultToolkit().sync();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   202
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   203
        synchronized (this) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   204
            done = true;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   205
            notifyAll();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   206
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   207
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   208
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   209
    /*
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   210
     * foreach source image size (once with pow2, once with non-pow2)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   211
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   212
     *   foreach BufferedImage type
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   213
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   214
     *     RescaleOp (1 band)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   215
     *     RescaleOp (3 bands, if src has 3 bands)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   216
     *     RescaleOp (4 bands, if src has 4 bands)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   217
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   218
     *     foreach LookupTable type (once with ByteLUT, once with ShortLUT)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   219
     *       LookupOp (1 band)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   220
     *       LookupOp (3 bands, if src has 3 bands)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   221
     *       LookupOp (4 bands, if src has 4 bands)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   222
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   223
     *     foreach edge condition (once with ZERO_FILL, once with EDGE_NO_OP)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   224
     *       ConvolveOp (3x3)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   225
     *       ConvolveOp (5x5)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   226
     *       ConvolveOp (7x7)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   227
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   228
    private void renderTest(Graphics2D g2d) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   229
        g2d.setColor(Color.white);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   230
        g2d.fillRect(0, 0, TESTW, TESTH);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   231
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   232
        int yorig = 2;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   233
        int xinc = 34;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   234
        int yinc = srcSizes[0] + srcSizes[1] + 2 + 2;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   235
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   236
        for (int srcType : srcTypes) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   237
            int y = yorig;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   238
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   239
            for (int srcSize : srcSizes) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   240
                int x = 2;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   241
                System.out.printf("type=%d size=%d\n", srcType, srcSize);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   242
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   243
                BufferedImage srcImg = makeSourceImage(srcSize, srcType);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   244
                ColorModel srcCM = srcImg.getColorModel();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   245
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   246
                // RescaleOp
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   247
                g2d.drawImage(srcImg, rescale1band, x, y);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   248
                x += xinc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   249
                // REMIND: 3-band RescaleOp.filter() throws IAE for images
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   250
                //         that contain an alpha channel (bug to be filed)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   251
                if (srcCM.getNumColorComponents() == 3 &&
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   252
                    !(ignore && srcCM.hasAlpha()))
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   253
                {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   254
                    g2d.drawImage(srcImg, rescale3band, x, y);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   255
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   256
                x += xinc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   257
                if (srcCM.getNumComponents() == 4) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   258
                    g2d.drawImage(srcImg, rescale4band, x, y);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   259
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   260
                x += xinc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   261
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   262
                // LookupOp
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   263
                // REMIND: Our LUTs are only 256 elements long, so won't
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   264
                //         currently work with USHORT_GRAY data
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   265
                if (srcType != BufferedImage.TYPE_USHORT_GRAY) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   266
                    g2d.drawImage(srcImg, lookup1bandbyte, x, y);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   267
                    x += xinc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   268
                    if (srcCM.getNumColorComponents() == 3) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   269
                        g2d.drawImage(srcImg, lookup3bandbyte, x, y);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   270
                    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   271
                    x += xinc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   272
                    if (srcCM.getNumComponents() == 4) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   273
                        g2d.drawImage(srcImg, lookup4bandbyte, x, y);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   274
                    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   275
                    x += xinc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   276
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   277
                    // REMIND: LookupOp.createCompatibleDestImage() throws
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   278
                    //         IAE for 3BYTE_BGR/4BYTE_ABGR (bug to be filed)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   279
                    if (!(ignore &&
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   280
                          (srcType == BufferedImage.TYPE_3BYTE_BGR ||
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   281
                           srcType == BufferedImage.TYPE_4BYTE_ABGR)))
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   282
                    {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   283
                        g2d.drawImage(srcImg, lookup1bandshort, x, y);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   284
                        x += xinc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   285
                        // REMIND: 3-band LookupOp.filter() throws IAE for
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   286
                        //         images that contain an alpha channel
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   287
                        //         (bug to be filed)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   288
                        if (srcCM.getNumColorComponents() == 3 &&
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   289
                            !(ignore && srcCM.hasAlpha()))
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   290
                        {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   291
                            g2d.drawImage(srcImg, lookup3bandshort, x, y);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   292
                        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   293
                        x += xinc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   294
                        if (srcCM.getNumComponents() == 4) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   295
                            g2d.drawImage(srcImg, lookup4bandshort, x, y);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   296
                        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   297
                        x += xinc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   298
                    } else {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   299
                        x += 3*xinc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   300
                    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   301
                } else {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   302
                    x += 6*xinc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   303
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   304
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   305
                // ConvolveOp
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   306
                // REMIND: ConvolveOp.filter() throws ImagingOpException
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   307
                //         for 3BYTE_BGR (see 4957775)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   308
                if (srcType != BufferedImage.TYPE_3BYTE_BGR) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   309
                    g2d.drawImage(srcImg, convolve3x3zero, x, y);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   310
                    x += xinc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   311
                    g2d.drawImage(srcImg, convolve5x5zero, x, y);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   312
                    x += xinc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   313
                    g2d.drawImage(srcImg, convolve7x7zero, x, y);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   314
                    x += xinc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   315
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   316
                    g2d.drawImage(srcImg, convolve3x3noop, x, y);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   317
                    x += xinc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   318
                    g2d.drawImage(srcImg, convolve5x5noop, x, y);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   319
                    x += xinc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   320
                    g2d.drawImage(srcImg, convolve7x7noop, x, y);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   321
                    x += xinc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   322
                } else {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   323
                    x += 6*xinc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   324
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   325
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   326
                y += srcSize + 2;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   327
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   328
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   329
            yorig += yinc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   330
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   331
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   332
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   333
    private BufferedImage makeSourceImage(int size, int type) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   334
        int s2 = size/2;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   335
        BufferedImage img = new BufferedImage(size, size, type);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   336
        Graphics2D g2d = img.createGraphics();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   337
        g2d.setComposite(AlphaComposite.Src);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   338
        g2d.setColor(Color.orange);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   339
        g2d.fillRect(0, 0, size, size);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   340
        g2d.setColor(Color.red);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   341
        g2d.fillRect(0, 0, s2, s2);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   342
        g2d.setColor(Color.green);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   343
        g2d.fillRect(s2, 0, s2, s2);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   344
        g2d.setColor(Color.blue);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   345
        g2d.fillRect(0, s2, s2, s2);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   346
        g2d.setColor(new Color(255, 255, 0, 128));
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   347
        g2d.fillRect(s2, s2, s2, s2);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   348
        g2d.setColor(Color.pink);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   349
        g2d.fillOval(s2-3, s2-3, 6, 6);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   350
        g2d.dispose();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   351
        return img;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   352
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   353
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   354
    public BufferedImage makeReferenceImage() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   355
        BufferedImage img = new BufferedImage(TESTW, TESTH,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   356
                                              BufferedImage.TYPE_INT_RGB);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   357
        Graphics2D g2d = img.createGraphics();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   358
        renderTest(g2d);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   359
        g2d.dispose();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   360
        return img;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   361
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   362
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   363
    public Dimension getPreferredSize() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   364
        return new Dimension(TESTW, TESTH);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   365
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   366
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   367
    private static void compareImages(BufferedImage refImg,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   368
                                      BufferedImage testImg,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   369
                                      int tolerance)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   370
    {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   371
        int x1 = 0;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   372
        int y1 = 0;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   373
        int x2 = refImg.getWidth();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   374
        int y2 = refImg.getHeight();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   375
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   376
        for (int y = y1; y < y2; y++) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   377
            for (int x = x1; x < x2; x++) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   378
                Color expected = new Color(refImg.getRGB(x, y));
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   379
                Color actual   = new Color(testImg.getRGB(x, y));
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   380
                if (!isSameColor(expected, actual, tolerance)) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   381
                    throw new RuntimeException("Test failed at x="+x+" y="+y+
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   382
                                               " (expected="+expected+
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   383
                                               " actual="+actual+
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   384
                                               ")");
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   385
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   386
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   387
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   388
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   389
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   390
    private static boolean isSameColor(Color c1, Color c2, int e) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   391
        int r1 = c1.getRed();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   392
        int g1 = c1.getGreen();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   393
        int b1 = c1.getBlue();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   394
        int r2 = c2.getRed();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   395
        int g2 = c2.getGreen();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   396
        int b2 = c2.getBlue();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   397
        int rmin = Math.max(r2-e, 0);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   398
        int gmin = Math.max(g2-e, 0);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   399
        int bmin = Math.max(b2-e, 0);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   400
        int rmax = Math.min(r2+e, 255);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   401
        int gmax = Math.min(g2+e, 255);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   402
        int bmax = Math.min(b2+e, 255);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   403
        if (r1 >= rmin && r1 <= rmax &&
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   404
            g1 >= gmin && g1 <= gmax &&
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   405
            b1 >= bmin && b1 <= bmax)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   406
        {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   407
            return true;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   408
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   409
        return false;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   410
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   411
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   412
    public static void main(String[] args) throws Exception {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   413
        boolean show = false;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   414
        boolean dump = false;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   415
        boolean compare = false;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   416
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   417
        for (String arg : args) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   418
            if (arg.equals("-show")) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   419
                show = true;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   420
            } else if (arg.equals("-dump")) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   421
                dump = true;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   422
            } else if (arg.equals("-compare")) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   423
                compare = true;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   424
            } else if (arg.equals("-ignore")) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   425
                ignore = true;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   426
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   427
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   428
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   429
        DrawBufImgOp test = new DrawBufImgOp();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   430
        Frame frame = new Frame();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   431
        frame.add(test);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   432
        frame.pack();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   433
        frame.setVisible(true);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   434
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   435
        // Wait until the component's been painted
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   436
        synchronized (test) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   437
            while (!done) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   438
                try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   439
                    test.wait();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   440
                } catch (InterruptedException e) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   441
                    throw new RuntimeException("Failed: Interrupted");
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   442
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   443
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   444
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   445
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   446
        GraphicsConfiguration gc = frame.getGraphicsConfiguration();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   447
        if (gc.getColorModel() instanceof IndexColorModel) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   448
            System.out.println("IndexColorModel detected: " +
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   449
                               "test considered PASSED");
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   450
            frame.dispose();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   451
            return;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   452
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   453
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   454
        // Grab the screen region
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   455
        BufferedImage capture = null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   456
        try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   457
            Robot robot = new Robot();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   458
            Point pt1 = test.getLocationOnScreen();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   459
            Rectangle rect = new Rectangle(pt1.x, pt1.y, TESTW, TESTH);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   460
            capture = robot.createScreenCapture(rect);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   461
        } catch (Exception e) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   462
            throw new RuntimeException("Problems creating Robot");
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   463
        } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   464
            if (!show) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   465
                frame.dispose();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   466
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   467
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   468
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   469
        // Compare the images (allow for +/- 1 bit differences in color comps)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   470
        if (dump || compare) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   471
            BufferedImage ref = test.makeReferenceImage();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   472
            if (dump) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   473
                ImageIO.write(ref,     "png",
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   474
                              new File("DrawBufImgOp.ref.png"));
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   475
                ImageIO.write(capture, "png",
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   476
                              new File("DrawBufImgOp.cap.png"));
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   477
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   478
            if (compare) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   479
                test.compareImages(ref, capture, 1);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   480
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   481
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   482
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   483
}