/hg/gfx-test: Added new test for checking antialiased lines rend...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Mon Sep 6 09:19:54 PDT 2010


changeset 44b7fc94cdca in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=44b7fc94cdca
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Mon Sep 06 18:20:13 2010 +0200

	Added new test for checking antialiased lines rendering.


diffstat:

4 files changed, 148 insertions(+)
Makefile                                                |    2 
src/org/gfxtest/framework/TestImage.java                |    5 
src/org/gfxtest/framework/annotations/RenderStyles.java |    1 
src/org/gfxtest/testsuites/AALines.java                 |  140 +++++++++++++++

diffs (185 lines):

diff -r 8ab660713623 -r 44b7fc94cdca Makefile
--- a/Makefile	Mon Sep 06 16:56:33 2010 +0200
+++ b/Makefile	Mon Sep 06 18:20:13 2010 +0200
@@ -78,6 +78,7 @@ FRAMEWORK_CLASSES = \
 	$(CLASSES)/$(FRAMEWORK_DIR)/Log.class
 
 TESTSUITE_CLASSES = \
+	$(CLASSES)/$(TESTSUITE_DIR)/AALines.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/BlankImage.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/NormalArcs.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/NormalLines.class \
@@ -104,6 +105,7 @@ TESTSUITE_CLASSES = \
 	$(CLASSES)/$(TESTSUITE_DIR)/DashedRectangles.class
 
 COMPARE_RESULTS = \
+	$(RESULTS)/AALines \
 	$(RESULTS)/BlankImage \
 	$(RESULTS)/NormalArcs \
 	$(RESULTS)/NormalLines \
diff -r 8ab660713623 -r 44b7fc94cdca src/org/gfxtest/framework/TestImage.java
--- a/src/org/gfxtest/framework/TestImage.java	Mon Sep 06 16:56:33 2010 +0200
+++ b/src/org/gfxtest/framework/TestImage.java	Mon Sep 06 18:20:13 2010 +0200
@@ -172,4 +172,9 @@ public class TestImage
     {
         this.image.setRGB(x, y, rgb);
     }
+
+    public BufferedImage getImage()
+    {
+        return this.image;
+    }
 }
diff -r 8ab660713623 -r 44b7fc94cdca src/org/gfxtest/framework/annotations/RenderStyles.java
--- a/src/org/gfxtest/framework/annotations/RenderStyles.java	Mon Sep 06 16:56:33 2010 +0200
+++ b/src/org/gfxtest/framework/annotations/RenderStyles.java	Mon Sep 06 18:20:13 2010 +0200
@@ -46,4 +46,5 @@ public enum RenderStyles
     NORMAL,
     DASH,
     FILL,
+    NORMAL_AA,
 }
diff -r 8ab660713623 -r 44b7fc94cdca src/org/gfxtest/testsuites/AALines.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/gfxtest/testsuites/AALines.java	Mon Sep 06 18:20:13 2010 +0200
@@ -0,0 +1,140 @@
+/*
+  Java gfx-test framework
+
+   Copyright (C) 2010  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.testsuites;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.image.BufferedImage;
+
+import org.gfxtest.framework.*;
+import org.gfxtest.framework.annotations.*;
+
+ at TestType(TestTypes.RENDER_TEST)
+ at GraphicsPrimitive(GraphicsPrimitives.LINE)
+ at RenderStyle(RenderStyles.NORMAL_AA)
+ at Transformation(Transformations.NONE)
+ at Zoom(16)
+public class AALines extends GfxTest
+{
+    private static void drawLine(BufferedImage img, Graphics2D g, int x1, int y1, int x2, int y2, Color color)
+    {
+        g.setColor(color);
+        g.drawLine(x1, y1, x2, y2);
+        img.setRGB(x1, y1, 0xff0000);
+        img.setRGB(x2, y2, 0xff0000);
+    }
+
+    private void drawHorizontalJaggedLines(BufferedImage image, Graphics2D graphics)
+    {
+        drawLine(image, graphics,  3,  3, 36,  4, Color.BLACK);
+        drawLine(image, graphics,  3,  9, 36, 10, Color.YELLOW);
+        drawLine(image, graphics,  3, 15, 36, 16, Color.MAGENTA);
+        drawLine(image, graphics,  3, 21, 36, 20, Color.BLUE);
+        drawLine(image, graphics,  3, 26, 36, 25, Color.GRAY);
+    }
+
+    private void drawVerticalJaggedLines(BufferedImage image, Graphics2D graphics)
+    {
+        drawLine(image, graphics,  3, 3,  4, 26, Color.BLACK);
+        drawLine(image, graphics, 11, 3, 12, 26, Color.YELLOW);
+        drawLine(image, graphics, 19, 3, 20, 26, Color.MAGENTA);
+        drawLine(image, graphics, 27, 3, 28, 26, Color.BLUE);
+        drawLine(image, graphics, 35, 3, 34, 26, Color.GRAY);
+    }
+
+    private void setAA1(Graphics2D graphics)
+    {
+        graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+    }
+
+    private void setAA2(Graphics2D graphics)
+    {
+        graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+        graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+    }
+
+    public TestResult test0(TestImage image, Graphics2D graphics)
+    {
+        drawVerticalJaggedLines(image.getImage(), graphics);
+        return TestResult.PASSED;
+    }
+
+    public TestResult test1(TestImage image, Graphics2D graphics)
+    {
+        drawHorizontalJaggedLines(image.getImage(), graphics);
+        return TestResult.PASSED;
+    }
+
+    public TestResult test2(TestImage image, Graphics2D graphics)
+    {
+        setAA1(graphics);
+        drawVerticalJaggedLines(image.getImage(), graphics);
+        return TestResult.PASSED;
+    }
+
+    public TestResult test3(TestImage image, Graphics2D graphics)
+    {
+        setAA1(graphics);
+        drawHorizontalJaggedLines(image.getImage(), graphics);
+        return TestResult.PASSED;
+    }
+
+    public TestResult test4(TestImage image, Graphics2D graphics)
+    {
+        setAA2(graphics);
+        drawVerticalJaggedLines(image.getImage(), graphics);
+        return TestResult.PASSED;
+    }
+
+    public TestResult test5(TestImage image, Graphics2D graphics)
+    {
+        setAA2(graphics);
+        drawHorizontalJaggedLines(image.getImage(), graphics);
+        return TestResult.PASSED;
+    }
+
+    public static void main(String[] args)
+    {
+        new AALines().runTestSuite(args);
+    }
+
+}



More information about the distro-pkg-dev mailing list