/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6514990
* @summary Verifies that calling
* Graphics2D.drawImage(BufferedImage, BufferedImageOp, x, y) to an
* OpenGL-accelerated destination produces the same results when performed
* in software via BufferedImageOp.filter().
* @author campbelc
*/
/**
* REMIND: This testcase was originally intended to automatically compare
* the results of the software BufferedImageOp implementations against
* the OGL-accelerated codepaths. However, there are just too many open
* bugs in the mediaLib-based codepaths (see below), which means that
* creating the reference image may cause crashes or exceptions,
* and even if we work around those cases using the "-ignore" flag,
* the visual results of the reference image are often buggy as well
* (so the comparison will fail even though the OGL results are correct).
* Therefore, for now we will run the testcase with the "-ignore" flag
* but without the "-compare" flag, so at least it will be checking for
* any exceptions/crashes in the OGL code. When we fix all of the
* outstanding bugs with the software codepaths, we can remove the
* "-ignore" flag and maybe even restore the "-compare" flag. In the
* meantime, it stil functions well as a manual testcase (with either
* the "-show" or "-dump" options).
*/
private static boolean done;
/*
* If true, skips tests that are known to trigger bugs (which in
* turn may cause crashes, exceptions, or other artifacts).
*/
private static boolean ignore;
// Test both pow2 and non-pow2 sized images
private static final int[] srcTypes = {
};
private static final RescaleOp
private static final LookupOp
private static final LookupOp
private static final ConvolveOp
private static final ConvolveOp
static {
rescale3band = new RescaleOp(
new float[] { 0.6f, 0.4f, 0.6f },
new float[] { 10.0f, -3.0f, 5.0f },
null);
rescale4band = new RescaleOp(
new float[] { 0.6f, 0.4f, 0.6f, 0.9f },
new float[] { -1.0f, 5.0f, 3.0f, 1.0f },
null);
// REMIND: we should probably test non-zero offsets, but that
// would require massaging the source image data to avoid going
// outside the lookup table array bounds
int offset = 0;
{
byte invert[] = new byte[256];
byte halved[] = new byte[256];
for (int j = 0; j < 256 ; j++) {
invert[j] = (byte) (255-j);
halved[j] = (byte) (j / 2);
}
new ByteLookupTable(offset,
new ByteLookupTable(offset,
}
{
short invert[] = new short[256];
short halved[] = new short[256];
for (int j = 0; j < 256 ; j++) {
}
new ShortLookupTable(offset,
new ShortLookupTable(offset,
}
// 3x3 blur
float[] data3 = {
0.1f, 0.1f, 0.1f,
0.1f, 0.2f, 0.1f,
0.1f, 0.1f, 0.1f,
};
// 5x5 edge
float[] data5 = {
-1.0f, -1.0f, -1.0f, -1.0f, -1.0f,
-1.0f, -1.0f, -1.0f, -1.0f, -1.0f,
-1.0f, -1.0f, 24.0f, -1.0f, -1.0f,
-1.0f, -1.0f, -1.0f, -1.0f, -1.0f,
-1.0f, -1.0f, -1.0f, -1.0f, -1.0f,
};
// 7x7 blur
float[] data7 = {
0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
};
}
synchronized (this) {
if (done) {
return;
}
}
synchronized (this) {
done = true;
notifyAll();
}
}
/*
* foreach source image size (once with pow2, once with non-pow2)
*
* foreach BufferedImage type
*
* RescaleOp (1 band)
* RescaleOp (3 bands, if src has 3 bands)
* RescaleOp (4 bands, if src has 4 bands)
*
* foreach LookupTable type (once with ByteLUT, once with ShortLUT)
* LookupOp (1 band)
* LookupOp (3 bands, if src has 3 bands)
* LookupOp (4 bands, if src has 4 bands)
*
* foreach edge condition (once with ZERO_FILL, once with EDGE_NO_OP)
* ConvolveOp (3x3)
* ConvolveOp (5x5)
* ConvolveOp (7x7)
*/
int yorig = 2;
int xinc = 34;
int y = yorig;
int x = 2;
// RescaleOp
x += xinc;
// REMIND: 3-band RescaleOp.filter() throws IAE for images
// that contain an alpha channel (bug to be filed)
{
}
x += xinc;
}
x += xinc;
// LookupOp
// REMIND: Our LUTs are only 256 elements long, so won't
// currently work with USHORT_GRAY data
x += xinc;
}
x += xinc;
}
x += xinc;
// REMIND: LookupOp.createCompatibleDestImage() throws
// IAE for 3BYTE_BGR/4BYTE_ABGR (bug to be filed)
if (!(ignore &&
{
x += xinc;
// REMIND: 3-band LookupOp.filter() throws IAE for
// images that contain an alpha channel
// (bug to be filed)
{
}
x += xinc;
}
x += xinc;
} else {
x += 3*xinc;
}
} else {
x += 6*xinc;
}
// ConvolveOp
// REMIND: ConvolveOp.filter() throws ImagingOpException
// for 3BYTE_BGR (see 4957775)
x += xinc;
x += xinc;
x += xinc;
x += xinc;
x += xinc;
x += xinc;
} else {
x += 6*xinc;
}
y += srcSize + 2;
}
}
}
return img;
}
return img;
}
}
int tolerance)
{
int x1 = 0;
int y1 = 0;
" (expected="+expected+
" actual="+actual+
")");
}
}
}
}
{
return true;
}
return false;
}
boolean show = false;
boolean dump = false;
boolean compare = false;
show = true;
dump = true;
compare = true;
ignore = true;
}
}
frame.setVisible(true);
// Wait until the component's been painted
synchronized (test) {
while (!done) {
try {
} catch (InterruptedException e) {
throw new RuntimeException("Failed: Interrupted");
}
}
}
"test considered PASSED");
return;
}
// Grab the screen region
try {
} catch (Exception e) {
throw new RuntimeException("Problems creating Robot");
} finally {
if (!show) {
}
}
// Compare the images (allow for +/- 1 bit differences in color comps)
if (dump) {
new File("DrawBufImgOp.ref.png"));
new File("DrawBufImgOp.cap.png"));
}
if (compare) {
}
}
}
}