/hg/gfx-test: 2011-10-21 Pavel Tisnovsky <ptisnovs at redhat.com>
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Fri Oct 21 01:30:24 PDT 2011
changeset 002b619b4e7e in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=002b619b4e7e
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Fri Oct 21 10:32:21 2011 +0200
2011-10-21 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/gfxtest/testsuites/TexturePaint.java:
Added new tests for rendering shapes filled by a texture.
* src/org/gfxtest/framework/CommonShapesRenderer.java:
Refactoring, new helper methods added.
* src/org/gfxtest/testsuites/ColorPaint.java: Fixed typo.
diffstat:
ChangeLog | 9 +
src/org/gfxtest/framework/CommonShapesRenderer.java | 148 ++++++-
src/org/gfxtest/testsuites/ColorPaint.java | 4 +-
src/org/gfxtest/testsuites/TexturePaint.java | 350 ++++++++++++++++++++
4 files changed, 475 insertions(+), 36 deletions(-)
diffs (truncated from 607 to 500 lines):
diff -r 2b8a0c754127 -r 002b619b4e7e ChangeLog
--- a/ChangeLog Thu Oct 20 14:44:59 2011 +0200
+++ b/ChangeLog Fri Oct 21 10:32:21 2011 +0200
@@ -1,3 +1,12 @@
+2011-10-21 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/gfxtest/testsuites/TexturePaint.java:
+ Added new tests for rendering shapes filled by a texture.
+ * src/org/gfxtest/framework/CommonShapesRenderer.java:
+ Refactoring, new helper methods added.
+ * src/org/gfxtest/testsuites/ColorPaint.java:
+ Fixed typo.
+
2011-10-20 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/gfxtest/framework/CommonShapesRenderer.java:
diff -r 2b8a0c754127 -r 002b619b4e7e src/org/gfxtest/framework/CommonShapesRenderer.java
--- a/src/org/gfxtest/framework/CommonShapesRenderer.java Thu Oct 20 14:44:59 2011 +0200
+++ b/src/org/gfxtest/framework/CommonShapesRenderer.java Fri Oct 21 10:32:21 2011 +0200
@@ -117,7 +117,7 @@
* @param radius
* radius of shape(s)
*/
- public static void drawCrossesForBasicShapes(Graphics2D graphics, int xc, int yc, int radius)
+ private static void drawCrossesForBasicShapes(Graphics2D graphics, int xc, int yc, int radius)
{
// move in vertical direction
for (int y = yc - radius; y <= yc + radius; y += radius)
@@ -131,6 +131,79 @@
}
/**
+ * Draw crosses at interesting points of image.
+ *
+ * @param graphics
+ * graphics context for image
+ * @param width
+ * width of the shape
+ * @param height
+ * height of the shape
+ */
+ private static void drawCrossesForPolygonShape(Graphics2D graphics, int width, int height)
+ {
+ final int offset = GfxTest.OFFSET;
+
+ // draw all marks
+ drawCross(graphics, offset, height >> 1, GfxTest.CROSS_SIZE);
+ drawCross(graphics, width >> 1, offset, GfxTest.CROSS_SIZE);
+ drawCross(graphics, width >> 1, height - offset, GfxTest.CROSS_SIZE);
+ drawCross(graphics, width - offset, height >> 1, GfxTest.CROSS_SIZE);
+ }
+
+ /**
+ * Draw crosses at interesting points of image.
+ *
+ * @param graphics
+ * graphics context for image
+ * @param width
+ * width of the shape
+ * @param height
+ * height of the shape
+ */
+ private static void drawCrossesForClosedPath(Graphics2D graphics, int width, int height)
+ {
+ final int offset = GfxTest.OFFSET;
+
+ // draw all marks
+ drawCross(graphics, offset, height - offset);
+ drawCross(graphics, offset, offset);
+ drawCross(graphics, width >> 1, offset);
+ drawCross(graphics, width - offset, offset);
+ drawCross(graphics, width - offset, height - offset);
+ drawCross(graphics, width >> 1, offset);
+ drawCross(graphics, width >> 1, height - offset);
+ }
+
+ /**
+ * Construct closed path with given size. The path contains quadratic and
+ * also cubic Bezier curve segment.
+ *
+ * @param width
+ * width of the shape
+ * @param height
+ * height of the shape
+ * @return constructed closed path
+ */
+ private static Path2D constructClosedPath(int width, int height)
+ {
+ final int offset = GfxTest.OFFSET;
+
+ // construct closed path
+ Path2D path = new Path2D.Float();
+ path.moveTo(offset, height - offset);
+
+ // path contains quadratic Bezier curve segment
+ path.quadTo(offset, offset, width >> 1, offset);
+ path.quadTo(width - offset, offset, width - offset, height - offset);
+
+ // and also cubic Bezier curve segment
+ path.curveTo(width >> 1, offset, width >> 1, height - offset, offset, height - offset);
+ path.closePath();
+ return path;
+ }
+
+ /**
* Draw circle onto the graphics canvas.
*
* @param image
@@ -192,14 +265,14 @@
int xc = image.getCenterX();
int yc = image.getCenterY();
- // calculate radius of circle
- int radius = calculateRadius(image);
+ // calculate size of rounded rectangle
+ int size = calculateRadius(image);
- // draw the rounded rectangle
- graphics.drawRoundRect(xc - radius, yc - radius, radius << 1, radius << 1, ROUND_RECT_RADIUS, ROUND_RECT_RADIUS);
+ // draw the filled round round rectangle
+ graphics.fillRoundRect(xc - size, yc - size, size << 1, size << 1, ROUND_RECT_RADIUS, ROUND_RECT_RADIUS);
// draw crosses at interesting points of image
- drawCrossesForBasicShapes(graphics, xc, yc, radius);
+ drawCrossesForBasicShapes(graphics, xc, yc, size);
}
/**
@@ -248,10 +321,31 @@
graphics.drawPolygon(xPoints, yPoints, xPoints.length);
// draw crosses at interesting points of image
- drawCross(graphics, GfxTest.OFFSET, h >> 1, GfxTest.CROSS_SIZE);
- drawCross(graphics, w >> 1, GfxTest.OFFSET, GfxTest.CROSS_SIZE);
- drawCross(graphics, w >> 1, h - GfxTest.OFFSET, GfxTest.CROSS_SIZE);
- drawCross(graphics, w - GfxTest.OFFSET, h >> 1, GfxTest.CROSS_SIZE);
+ drawCrossesForPolygonShape(graphics, w, h);
+ }
+
+ /**
+ * Draw filled closed path onto the graphics canvas.
+ *
+ * @param image
+ * image to which two dimensional shape is to be rendered
+ * @param graphics
+ * graphics context for image
+ */
+ public static void drawClosedPath(TestImage image, Graphics2D graphics)
+ {
+ // calculate image size
+ int w = image.getWidth();
+ int h = image.getHeight();
+
+ // construct closed path with given size
+ Path2D path = constructClosedPath(w, h);
+
+ // draw the closed path
+ graphics.draw(path);
+
+ // draw crosses at interesting points of image
+ drawCrossesForClosedPath(graphics, w, h);
}
/**
@@ -340,14 +434,14 @@
int xc = image.getCenterX();
int yc = image.getCenterY();
- // calculate radius of circle
- int radius = calculateRadius(image);
+ // calculate size of rounded rectangle
+ int size = calculateRadius(image);
- // draw the filled rectangle round rectangle
- graphics.fillRoundRect(xc - radius, yc - radius, radius << 1, radius << 1, ROUND_RECT_RADIUS, ROUND_RECT_RADIUS);
+ // draw the filled round round rectangle
+ graphics.fillRoundRect(xc - size, yc - size, size << 1, size << 1, ROUND_RECT_RADIUS, ROUND_RECT_RADIUS);
// draw crosses at interesting points of image
- drawCrossesForBasicShapes(graphics, xc, yc, radius);
+ drawCrossesForBasicShapes(graphics, xc, yc, size);
}
/**
@@ -372,10 +466,7 @@
graphics.fillPolygon(xPoints, yPoints, xPoints.length);
// draw crosses at interesting points of image
- drawCross(graphics, GfxTest.OFFSET, h >> 1, GfxTest.CROSS_SIZE);
- drawCross(graphics, w >> 1, GfxTest.OFFSET, GfxTest.CROSS_SIZE);
- drawCross(graphics, w >> 1, h - GfxTest.OFFSET, GfxTest.CROSS_SIZE);
- drawCross(graphics, w - GfxTest.OFFSET, h >> 1, GfxTest.CROSS_SIZE);
+ drawCrossesForPolygonShape(graphics, w, h);
}
/**
@@ -392,25 +483,14 @@
int w = image.getWidth();
int h = image.getHeight();
- // construct closed path
- Path2D path = new Path2D.Float();
- path.moveTo(GfxTest.OFFSET, h - GfxTest.OFFSET);
- path.quadTo(GfxTest.OFFSET, GfxTest.OFFSET, w >> 1, GfxTest.OFFSET);
- path.quadTo(w - GfxTest.OFFSET, GfxTest.OFFSET, w - GfxTest.OFFSET, h - GfxTest.OFFSET);
- path.curveTo(w >> 1, GfxTest.OFFSET, w >> 1, h - GfxTest.OFFSET, GfxTest.OFFSET, h - GfxTest.OFFSET);
- path.closePath();
+ // construct closed path with given size
+ Path2D path = constructClosedPath(w, h);
// draw the closed path
graphics.fill(path);
// draw crosses at interesting points of image
- drawCross(graphics, GfxTest.OFFSET, h - GfxTest.OFFSET);
- drawCross(graphics, GfxTest.OFFSET, GfxTest.OFFSET);
- drawCross(graphics, w >> 1, GfxTest.OFFSET);
- drawCross(graphics, w - GfxTest.OFFSET, GfxTest.OFFSET);
- drawCross(graphics, w - GfxTest.OFFSET, h - GfxTest.OFFSET);
- drawCross(graphics, w >> 1, GfxTest.OFFSET);
- drawCross(graphics, w >> 1, h - GfxTest.OFFSET);
+ drawCrossesForClosedPath(graphics, w, h);
}
-
+
}
diff -r 2b8a0c754127 -r 002b619b4e7e src/org/gfxtest/testsuites/ColorPaint.java
--- a/src/org/gfxtest/testsuites/ColorPaint.java Thu Oct 20 14:44:59 2011 +0200
+++ b/src/org/gfxtest/testsuites/ColorPaint.java Fri Oct 21 10:32:21 2011 +0200
@@ -2031,7 +2031,7 @@
}
/**
- * Test if path polygon drawn by graphics.fill() is
+ * Test if closed path drawn by graphics.fill() is
* rendered correctly.
*
* @param image
@@ -2044,7 +2044,7 @@
{
// set fill color
CommonRenderingStyles.setFillColor(graphics);
- // draw the filled path
+ // draw the filled closed path
CommonShapesRenderer.drawFilledClosedPath(image, graphics);
// test return value
return TestResult.PASSED;
diff -r 2b8a0c754127 -r 002b619b4e7e src/org/gfxtest/testsuites/TexturePaint.java
--- a/src/org/gfxtest/testsuites/TexturePaint.java Thu Oct 20 14:44:59 2011 +0200
+++ b/src/org/gfxtest/testsuites/TexturePaint.java Fri Oct 21 10:32:21 2011 +0200
@@ -236,6 +236,356 @@
}
/**
+ * Test if filled circle drawn by graphics.fillOval() is rendered correctly.
+ * Texture paint is used for filling this circle.
+ *
+ * @param image
+ * image to which two dimensional shape is to be rendered
+ * @param graphics
+ * graphics context for image
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testCircleTexturePaintUsingDotTexture(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color (it could not be used during the shape rendering)
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set texture
+ CommonRenderingStyles.setTextureFillUsingColorDotsTexture(image, graphics);
+ // draw the circle
+ CommonShapesRenderer.drawFilledCircle(image, graphics);
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test if filled circle drawn by graphics.fillOval() is rendered correctly.
+ * Texture paint is used for filling this circle.
+ *
+ * @param image
+ * image to which two dimensional shape is to be rendered
+ * @param graphics
+ * graphics context for image
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testCircleTexturePaintUsingRGBTexture1(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set fill color
+ CommonRenderingStyles.setTextureFillUsingRGBTexture1(image, graphics);
+ // draw the circle
+ CommonShapesRenderer.drawFilledCircle(image, graphics);
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test if filled circle drawn by graphics.fillOval() is rendered correctly.
+ * Texture paint is used for filling this circle.
+ *
+ * @param image
+ * image to which two dimensional shape is to be rendered
+ * @param graphics
+ * graphics context for image
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testCircleTexturePaintUsingRGBTexture2(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set fill color
+ CommonRenderingStyles.setTextureFillUsingRGBTexture2(image, graphics);
+ // draw the circle
+ CommonShapesRenderer.drawFilledCircle(image, graphics);
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test if filled circle drawn by graphics.fillOval() is rendered correctly.
+ * Texture paint is used for filling this circle.
+ *
+ * @param image
+ * image to which two dimensional shape is to be rendered
+ * @param graphics
+ * graphics context for image
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testCircleTexturePaintUsingRGBTexture3(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set fill color
+ CommonRenderingStyles.setTextureFillUsingRGBTexture3(image, graphics);
+ // draw the circle
+ CommonShapesRenderer.drawFilledCircle(image, graphics);
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test if empty rectangle drawn by graphics.drawRectangle() is rendered
+ * correctly.
+ *
+ * @param image
+ * image to which two dimensional shape is to be rendered
+ * @param graphics
+ * graphics context for image
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testRectangleEmptyFill(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // draw the arc
+ CommonShapesRenderer.drawRectangle(image, graphics);
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test if filled rectangle drawn by graphics.fillRectangle() is rendered correctly.
+ * Texture paint is used for filling this rectangle.
+ *
+ * @param image
+ * image to which two dimensional shape is to be rendered
+ * @param graphics
+ * graphics context for image
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testRectangleTexturePaintUsingCheckerTexture(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color (it could not be used during the shape rendering)
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set texture
+ CommonRenderingStyles.setTextureFillUsingCheckerTexture(image, graphics);
+ // draw the circle
+ CommonShapesRenderer.drawFilledRectangle(image, graphics);
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test if filled rectangle drawn by graphics.fillRectangle() is rendered correctly.
+ * Texture paint is used for filling this rectangle.
+ *
+ * @param image
+ * image to which two dimensional shape is to be rendered
+ * @param graphics
+ * graphics context for image
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testRectangleTexturePaintUsingDiagonalCheckerTexture(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color (it could not be used during the shape rendering)
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set texture
+ CommonRenderingStyles.setTextureFillUsingDiagonalCheckerTexture(image, graphics);
+ // draw the circle
+ CommonShapesRenderer.drawFilledRectangle(image, graphics);
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test if filled rectangle drawn by graphics.fillRectangle() is rendered correctly.
+ * Texture paint is used for filling this rectangle.
+ *
+ * @param image
+ * image to which two dimensional shape is to be rendered
+ * @param graphics
+ * graphics context for image
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testRectangleTexturePaintUsingGridTexture(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color (it could not be used during the shape rendering)
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set texture
+ CommonRenderingStyles.setTextureFillUsingGridTexture(image, graphics);
+ // draw the circle
+ CommonShapesRenderer.drawFilledRectangle(image, graphics);
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test if filled rectangle drawn by graphics.fillRectangle() is rendered correctly.
+ * Texture paint is used for filling this rectangle.
+ *
+ * @param image
+ * image to which two dimensional shape is to be rendered
+ * @param graphics
+ * graphics context for image
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testRectangleTexturePaintUsingDiagonalGridTexture(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color (it could not be used during the shape rendering)
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set texture
+ CommonRenderingStyles.setTextureFillUsingDiagonalGridTexture(image, graphics);
+ // draw the circle
+ CommonShapesRenderer.drawFilledRectangle(image, graphics);
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test if filled rectangle drawn by graphics.fillRectangle() is rendered correctly.
+ * Texture paint is used for filling this rectangle.
+ *
+ * @param image
+ * image to which two dimensional shape is to be rendered
+ * @param graphics
+ * graphics context for image
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testRectangleTexturePaintUsingHorizontalStripesTexture(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color (it could not be used during the shape rendering)
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set texture
+ CommonRenderingStyles.setTextureFillUsingHorizontalStripesTexture(image, graphics);
+ // draw the circle
+ CommonShapesRenderer.drawFilledRectangle(image, graphics);
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test if filled rectangle drawn by graphics.fillRectangle() is rendered correctly.
+ * Texture paint is used for filling this rectangle.
+ *
+ * @param image
+ * image to which two dimensional shape is to be rendered
+ * @param graphics
+ * graphics context for image
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testRectangleTexturePaintUsingVerticalStripesTexture(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color (it could not be used during the shape rendering)
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set texture
+ CommonRenderingStyles.setTextureFillUsingVerticalStripesTexture(image, graphics);
+ // draw the circle
+ CommonShapesRenderer.drawFilledRectangle(image, graphics);
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test if filled rectangle drawn by graphics.fillRectangle() is rendered correctly.
+ * Texture paint is used for filling this rectangle.
+ *
+ * @param image
+ * image to which two dimensional shape is to be rendered
+ * @param graphics
More information about the distro-pkg-dev
mailing list