/hg/gfx-test: 2012-01-12 Pavel Tisnovsky <ptisnovs at redhat.com>

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Thu Jan 12 02:51:42 PST 2012


changeset 70e12dbf96c3 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=70e12dbf96c3
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Thu Jan 12 11:54:02 2012 +0100

	2012-01-12 Pavel Tisnovsky <ptisnovs at redhat.com>

	 * src/org/gfxtest/framework/CommonBitmapOperations.java:
	Refactored common bitmapt operations into class.
	        * src/org/gfxtest/framework/ImageFactory.java: Simple fix
	for images with alpha channel.
	        * src/org/gfxtest/testsuites/BitBltBasicTests.java: Added
	new tests.
	        * src/org/gfxtest/testsuites/BitBltScaleImage.java: New test
	case.
	        * Makefile: updated


diffstat:

 ChangeLog                                             |   13 +
 Makefile                                              |    3 +
 src/org/gfxtest/framework/CommonBitmapOperations.java |  177 ++++++++++++
 src/org/gfxtest/framework/ImageFactory.java           |    2 +-
 src/org/gfxtest/testsuites/BitBltBasicTests.java      |  257 ++++++++++-------
 src/org/gfxtest/testsuites/BitBltScaleImage.java      |  151 ++++++++++
 6 files changed, 501 insertions(+), 102 deletions(-)

diffs (truncated from 776 to 500 lines):

diff -r a92f5b0ae82b -r 70e12dbf96c3 ChangeLog
--- a/ChangeLog	Wed Jan 11 13:12:29 2012 +0100
+++ b/ChangeLog	Thu Jan 12 11:54:02 2012 +0100
@@ -1,4 +1,17 @@
+2012-01-12  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/gfxtest/framework/CommonBitmapOperations.java:
+	Refactored common bitmapt operations into class.
+	* src/org/gfxtest/framework/ImageFactory.java:
+	Simple fix for images with alpha channel.
+	* src/org/gfxtest/testsuites/BitBltBasicTests.java:
+	Added new tests.
+	* src/org/gfxtest/testsuites/BitBltScaleImage.java:
+	New test case.
+	* Makefile: updated
+
 2012-01-11  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
 	* src/org/gfxtest/framework/ImageFactory.java:
 	New class containing (ATM) one helper method used by
 	BitBlt tests.
diff -r a92f5b0ae82b -r 70e12dbf96c3 Makefile
--- a/Makefile	Wed Jan 11 13:12:29 2012 +0100
+++ b/Makefile	Thu Jan 12 11:54:02 2012 +0100
@@ -81,6 +81,7 @@
 	$(CLASSES)/$(FRAMEWORK_DIR)/CommonShapesRenderer.class \
 	$(CLASSES)/$(FRAMEWORK_DIR)/CommonClippingOperations.class \
 	$(CLASSES)/$(FRAMEWORK_DIR)/CommonPathsGenerator.class \
+	$(CLASSES)/$(FRAMEWORK_DIR)/CommonBitmapOperations.class \
 	$(CLASSES)/$(FRAMEWORK_DIR)/EntityRenderingStyle.class \
 	$(CLASSES)/$(FRAMEWORK_DIR)/TestResult.class \
 	$(CLASSES)/$(FRAMEWORK_DIR)/ParameterNotFoundException.class \
@@ -108,6 +109,7 @@
 	$(CLASSES)/$(TESTSUITE_DIR)/AlphaComposite.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/BlankImage.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/BitBltBasicTests.class \
+	$(CLASSES)/$(TESTSUITE_DIR)/BitBltScaleImage.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/ColorPaint.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/NormalArcs.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/NormalLines.class \
@@ -170,6 +172,7 @@
 	$(RESULTS)/AlphaComposite \
 	$(RESULTS)/BlankImage \
 	$(RESULTS)/BitBltBasicTests \
+	$(RESULTS)/BitBltScaleImage \
 	$(RESULTS)/ColorPaint \
 	$(RESULTS)/NormalArcs \
 	$(RESULTS)/NormalLines \
diff -r a92f5b0ae82b -r 70e12dbf96c3 src/org/gfxtest/framework/CommonBitmapOperations.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/gfxtest/framework/CommonBitmapOperations.java	Thu Jan 12 11:54:02 2012 +0100
@@ -0,0 +1,177 @@
+/*
+  Java gfx-test framework
+
+   Copyright (C) 2010, 2011, 2012  Red Hat
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+IcedTea 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version.
+*/
+
+package org.gfxtest.framework;
+
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+
+public class CommonBitmapOperations
+{
+    /**
+     * Grid size for images with checker pattern.
+     */
+    private static final int GRID_SIZE = 20;
+
+    /**
+     * Width of tested buffered image.
+     */
+    public final static int DEFAULT_TEST_IMAGE_WIDTH = 256;
+
+    /**
+     * Height of tested buffered image.
+     */
+    public final static int DEFAULT_TEST_IMAGE_HEIGHT = 256;
+
+    /**
+     * Performs BitBlt operation.
+     * 
+     * @param sourceImage
+     *            source image for BitBlt
+     * @param destinationImage
+     *            destination image for BitBlt graphics canvas
+     * @param graphics2d
+     *            instance of class used during rendering
+     * @return if the image has completely loaded and its pixels are no longer
+     *         being changed, then returns true. Otherwise, returns false
+     */
+    private static boolean BitBlt(BufferedImage sourceImage, TestImage destinationImage, Graphics2D graphics2d)
+    {
+        // compute top-left corner coordinates
+        final int x = (destinationImage.getWidth() - DEFAULT_TEST_IMAGE_WIDTH) >> 1;
+        final int y = (destinationImage.getHeight() - DEFAULT_TEST_IMAGE_HEIGHT) >> 1;
+        return graphics2d.drawImage(sourceImage, x, y, null);
+    }
+
+    /**
+     * Performs BitBlt operation.
+     * 
+     * @param sourceImage
+     *            source image for BitBlt
+     * @param destinationImage
+     *            destination image for BitBlt graphics canvas
+     * @param graphics2d
+     *            instance of class used during rendering
+     * @param width
+     * @param height
+     * @return if the image has completely loaded and its pixels are no longer
+     *         being changed, then returns true. Otherwise, returns false
+     */
+    private static boolean BitBlt(BufferedImage sourceImage, TestImage destinationImage, Graphics2D graphics2d, int width, int height)
+    {
+        // compute top-left corner coordinates
+        final int x = (destinationImage.getWidth() - width) >> 1;
+        final int y = (destinationImage.getHeight() - height) >> 1;
+        return graphics2d.drawImage(sourceImage, x, y, width, height, null);
+    }
+
+    /**
+     * Create buffered bitmap with given type.
+     * 
+     * @param type
+     *            type of the created image
+     * @return new buffered bitmap
+     */
+    private static BufferedImage createBufferedBitmap(int type)
+    {
+        return new BufferedImage(DEFAULT_TEST_IMAGE_WIDTH, DEFAULT_TEST_IMAGE_HEIGHT, type);
+    }
+
+    /**
+     * Create new buffered image and then do basic BitBlt test.
+     *
+     * @param image
+     *            image to which another image is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @param type
+     *            type of the created image
+     */
+    public static TestResult doBitBltTestWithEmptyImage(TestImage image, Graphics2D graphics2d, int type)
+    {
+        BufferedImage bufferedImage = createBufferedBitmap(type);
+        if (bufferedImage == null)
+        {
+            return TestResult.FAILED;
+        }
+        return BitBlt(bufferedImage, image, graphics2d) ? TestResult.PASSED : TestResult.FAILED;
+    }
+
+    /**
+     * Create new buffered image containing checker pattern and then do basic BitBlt test.
+     *
+     * @param image
+     *            image to which another image is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @param imageType
+     *            type of the created image
+     */
+    public static TestResult doBitBltTestWithCheckerImage(TestImage image, Graphics2D graphics2d, int imageType)
+    {
+        BufferedImage bufferedImage = ImageFactory.createCheckerImage(GRID_SIZE, DEFAULT_TEST_IMAGE_WIDTH, DEFAULT_TEST_IMAGE_HEIGHT, imageType);
+        if (bufferedImage == null)
+        {
+            return TestResult.FAILED;
+        }
+        return BitBlt(bufferedImage, image, graphics2d) ? TestResult.PASSED : TestResult.FAILED;
+    }
+
+    /**
+     * Create new buffered image containing checker pattern and then do basic BitBlt test.
+     *
+     * @param image
+     *            image to which another image is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @param imageType
+     *            type of the created image
+     */
+    public static TestResult doBitBltTestWithCheckerImage(TestImage image, Graphics2D graphics2d, int imageType, int width, int height)
+    {
+        BufferedImage bufferedImage = ImageFactory.createCheckerImage(GRID_SIZE, DEFAULT_TEST_IMAGE_WIDTH, DEFAULT_TEST_IMAGE_HEIGHT, imageType);
+        if (bufferedImage == null)
+        {
+            return TestResult.FAILED;
+        }
+        return BitBlt(bufferedImage, image, graphics2d, width, height) ? TestResult.PASSED : TestResult.FAILED;
+    }
+
+}
diff -r a92f5b0ae82b -r 70e12dbf96c3 src/org/gfxtest/framework/ImageFactory.java
--- a/src/org/gfxtest/framework/ImageFactory.java	Wed Jan 11 13:12:29 2012 +0100
+++ b/src/org/gfxtest/framework/ImageFactory.java	Thu Jan 12 11:54:02 2012 +0100
@@ -71,7 +71,7 @@
                 boolean evenRow = (y % doubledGridSize) >= gridSize;
                 // compute color for each pixel
                 boolean whiteField = evenColumn ^ evenRow;
-                int color = whiteField ? 0x00ffffff: 0x00000000;
+                int color = whiteField ? 0xffffffff: 0xff000000;
                 image.setRGB(x, y, color);
             }
         }
diff -r a92f5b0ae82b -r 70e12dbf96c3 src/org/gfxtest/testsuites/BitBltBasicTests.java
--- a/src/org/gfxtest/testsuites/BitBltBasicTests.java	Wed Jan 11 13:12:29 2012 +0100
+++ b/src/org/gfxtest/testsuites/BitBltBasicTests.java	Thu Jan 12 11:54:02 2012 +0100
@@ -45,8 +45,8 @@
 
 
 
+import org.gfxtest.framework.CommonBitmapOperations;
 import org.gfxtest.framework.GfxTest;
-import org.gfxtest.framework.ImageFactory;
 import org.gfxtest.framework.TestImage;
 import org.gfxtest.framework.annotations.GraphicsPrimitive;
 import org.gfxtest.framework.annotations.GraphicsPrimitives;
@@ -62,7 +62,7 @@
 
 
 /**
- * This test check the rendering of buffered images (so callet bit block
+ * This test check the rendering of buffered images (so called bit block
  * transfers or Bit Blt) created by various constructors.
  * 
  * @author Pavel Tisnovsky
@@ -75,91 +75,6 @@
 public class BitBltBasicTests extends GfxTest
 {
     /**
-     * Grid size for images with checker pattern.
-     */
-    private static final int GRID_SIZE = 20;
-
-    /**
-     * Width of tested buffered image.
-     */
-    private final static int DEFAULT_TEST_IMAGE_WIDTH = 256;
-
-    /**
-     * Height of tested buffered image.
-     */
-    private final static int DEFAULT_TEST_IMAGE_HEIGHT = 256;
-
-    /**
-     * Performs BitBlt operation
-     * 
-     * @param destinationImage
-     *            destination image for BitBlt graphics canvas
-     * @param sourceImage
-     *            source image for BitBlt
-     * @return if the image has completely loaded and its pixels are no longer
-     *         being changed, then returns true. Otherwise, returns false
-     */
-    private boolean BitBlt(TestImage destinationImage, Graphics2D graphics2d, BufferedImage sourceImage)
-    {
-        // compute top-left corner coordinates
-        final int x = (destinationImage.getWidth() - DEFAULT_TEST_IMAGE_WIDTH) >> 1;
-        final int y = (destinationImage.getHeight() - DEFAULT_TEST_IMAGE_HEIGHT) >> 1;
-        return graphics2d.drawImage(sourceImage, x, y, null);
-    }
-
-    /**
-     * Create buffered bitmap with given type.
-     * 
-     * @param type
-     *            type of the created image
-     * @return new buffered bitmap
-     */
-    private BufferedImage createBufferedBitmap(int type)
-    {
-        return new BufferedImage(DEFAULT_TEST_IMAGE_WIDTH, DEFAULT_TEST_IMAGE_HEIGHT, type);
-    }
-
-    /**
-     * Create new buffered image and then do basic BitBlt test.
-     *
-     * @param image
-     *            image to which another image is to be drawn
-     * @param graphics2d
-     *            graphics canvas
-     * @param type
-     *            type of the created image
-     */
-    private TestResult doBitBltTestWithEmptyImage(TestImage image, Graphics2D graphics2d, int type)
-    {
-        BufferedImage bufferedImage = createBufferedBitmap(type);
-        if (bufferedImage == null)
-        {
-            return TestResult.FAILED;
-        }
-        return BitBlt(image, graphics2d, bufferedImage) ? TestResult.PASSED : TestResult.FAILED;
-    }
-
-    /**
-     * Create new buffered image containing checker pattern and then do basic BitBlt test.
-     *
-     * @param image
-     *            image to which another image is to be drawn
-     * @param graphics2d
-     *            graphics canvas
-     * @param imageType
-     *            type of the created image
-     */
-    private TestResult doBitBltTestWithCheckerImage(TestImage image, Graphics2D graphics2d, int imageType)
-    {
-        BufferedImage bufferedImage = ImageFactory.createCheckerImage(GRID_SIZE, DEFAULT_TEST_IMAGE_WIDTH, DEFAULT_TEST_IMAGE_HEIGHT, imageType);
-        if (bufferedImage == null)
-        {
-            return TestResult.FAILED;
-        }
-        return BitBlt(image, graphics2d, bufferedImage) ? TestResult.PASSED : TestResult.FAILED;
-    }
-
-    /**
      * Test basic BitBlt operation for empty buffered image with type TYPE_3BYTE_BGR.
      *
      * @param image
@@ -170,7 +85,7 @@
      */
     public TestResult testBitBltEmptyBufferedImageType3ByteBGR(TestImage image, Graphics2D graphics2d)
     {
-        return doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_3BYTE_BGR);
+        return CommonBitmapOperations.doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_3BYTE_BGR);
     }
 
     /**
@@ -184,7 +99,7 @@
      */
     public TestResult testBitBltEmptyBufferedImageType4ByteABGR(TestImage image, Graphics2D graphics2d)
     {
-        return doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_4BYTE_ABGR);
+        return CommonBitmapOperations.doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_4BYTE_ABGR);
     }
 
     /**
@@ -198,7 +113,7 @@
      */
     public TestResult testBitBltEmptyBufferedImageType4ByteABGR_Pre(TestImage image, Graphics2D graphics2d)
     {
-        return doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_4BYTE_ABGR_PRE);
+        return CommonBitmapOperations.doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_4BYTE_ABGR_PRE);
     }
 
     /**
@@ -212,7 +127,7 @@
      */
     public TestResult testBitBltEmptyBufferedImageTypeByteBinary(TestImage image, Graphics2D graphics2d)
     {
-        return doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_BYTE_BINARY);
+        return CommonBitmapOperations.doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_BYTE_BINARY);
     }
 
     /**
@@ -226,7 +141,7 @@
      */
     public TestResult testBitBltEmptyBufferedImageTypeIntRGB(TestImage image, Graphics2D graphics2d)
     {
-        return doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_INT_RGB);
+        return CommonBitmapOperations.doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_INT_RGB);
     }
 
     /**
@@ -240,7 +155,7 @@
      */
     public TestResult testBitBltEmptyBufferedImageTypeIntARGB(TestImage image, Graphics2D graphics2d)
     {
-        return doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_INT_ARGB);
+        return CommonBitmapOperations.doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_INT_ARGB);
     }
 
     /**
@@ -254,7 +169,7 @@
      */
     public TestResult testBitBltEmptyBufferedImageTypeIntARGB_Pre(TestImage image, Graphics2D graphics2d)
     {
-        return doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_INT_ARGB_PRE);
+        return CommonBitmapOperations.doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_INT_ARGB_PRE);
     }
 
     /**
@@ -268,7 +183,7 @@
      */
     public TestResult testBitBltEmptyBufferedImageTypeIntBGR(TestImage image, Graphics2D graphics2d)
     {
-        return doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_INT_BGR);
+        return CommonBitmapOperations.doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_INT_BGR);
     }
 
     /**
@@ -282,7 +197,7 @@
      */
     public TestResult testBitBltEmptyBufferedImageTypeUshort565RGB(TestImage image, Graphics2D graphics2d)
     {
-        return doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_USHORT_565_RGB);
+        return CommonBitmapOperations.doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_USHORT_565_RGB);
     }
 
     /**
@@ -296,7 +211,7 @@
      */
     public TestResult testBitBltEmptyBufferedImageTypeUshort555RGB(TestImage image, Graphics2D graphics2d)
     {
-        return doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_USHORT_555_RGB);
+        return CommonBitmapOperations.doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_USHORT_555_RGB);
     }
 
     /**
@@ -310,7 +225,7 @@
      */
     public TestResult testBitBltEmptyBufferedImageTypeByteGray(TestImage image, Graphics2D graphics2d)
     {
-        return doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_BYTE_GRAY);
+        return CommonBitmapOperations.doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_BYTE_GRAY);
     }
 
     /**
@@ -324,7 +239,7 @@
      */
     public TestResult testBitBltEmptyBufferedImageTypeUshortGray(TestImage image, Graphics2D graphics2d)
     {
-        return doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_USHORT_GRAY);
+        return CommonBitmapOperations.doBitBltTestWithEmptyImage(image, graphics2d, BufferedImage.TYPE_USHORT_GRAY);
     }
 
     /**
@@ -338,7 +253,7 @@
      */
     public TestResult testBitBltCheckerBufferedImageTypeByteBinary(TestImage image, Graphics2D graphics2d)
     {
-        return doBitBltTestWithCheckerImage(image, graphics2d, BufferedImage.TYPE_BYTE_BINARY);
+        return CommonBitmapOperations.doBitBltTestWithCheckerImage(image, graphics2d, BufferedImage.TYPE_BYTE_BINARY);
     }
 
     /**
@@ -352,7 +267,147 @@
      */
     public TestResult testBitBltCheckerBufferedImageTypeIntRGB(TestImage image, Graphics2D graphics2d)
     {
-        return doBitBltTestWithCheckerImage(image, graphics2d, BufferedImage.TYPE_INT_RGB);
+        return CommonBitmapOperations.doBitBltTestWithCheckerImage(image, graphics2d, BufferedImage.TYPE_INT_RGB);
+    }
+
+    /**
+     * Test basic BitBlt operation for checker buffered image with type TYPE_INT_BGR.
+     *
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return
+     */
+    public TestResult testBitBltCheckerBufferedImageTypeIntBGR(TestImage image, Graphics2D graphics2d)
+    {
+        return CommonBitmapOperations.doBitBltTestWithCheckerImage(image, graphics2d, BufferedImage.TYPE_INT_BGR);
+    }
+
+    /**
+     * Test basic BitBlt operation for checker buffered image with type TYPE_INT_ARGB.
+     *
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d



More information about the distro-pkg-dev mailing list