/hg/gfx-test: Refactoring, added factory methods to create three...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Fri Apr 19 02:23:57 PDT 2013


changeset 5501ae1df2f1 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=5501ae1df2f1
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Fri Apr 19 11:26:49 2013 +0200

	Refactoring, added factory methods to create three new procedural
	textures.


diffstat:

 ChangeLog                                               |    6 +
 src/org/gfxtest/framework/ProceduralTextureFactory.java |  214 +++++++++++++++-
 2 files changed, 208 insertions(+), 12 deletions(-)

diffs (278 lines):

diff -r 548fd0068224 -r 5501ae1df2f1 ChangeLog
--- a/ChangeLog	Wed Apr 17 09:33:25 2013 +0200
+++ b/ChangeLog	Fri Apr 19 11:26:49 2013 +0200
@@ -1,3 +1,9 @@
+2013-04-19  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/gfxtest/framework/ProceduralTextureFactory.java:
+	Refactoring, added factory methods to create three new procedural
+	textures.
+
 2013-04-17  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/gfxtest/testsuites/BitBltBasicTests.java:
diff -r 548fd0068224 -r 5501ae1df2f1 src/org/gfxtest/framework/ProceduralTextureFactory.java
--- a/src/org/gfxtest/framework/ProceduralTextureFactory.java	Wed Apr 17 09:33:25 2013 +0200
+++ b/src/org/gfxtest/framework/ProceduralTextureFactory.java	Fri Apr 19 11:26:49 2013 +0200
@@ -120,6 +120,21 @@
     private static BufferedImage RGBTexture3 = null;
 
     /**
+     * Image used for creating texture containing various RGB colors.
+     */
+    private static BufferedImage RGBTexture4 = null;
+
+    /**
+     * Image used for creating texture containing various RGB colors.
+     */
+    private static BufferedImage RGBTexture5 = null;
+
+    /**
+     * Image used for creating texture containing various RGB colors.
+     */
+    private static BufferedImage RGBTexture6 = null;
+
+    /**
      * Eight basic colors.
      */
     private static final int[] EIGHT_BASIC_COLOR_PALETTE = {
@@ -512,7 +527,7 @@
                     int red = x % 4 == 1 ? 0x00 : 0xff;
                     int green = y % 4 == 1 ? 0x00 : 0xff;
                     int blue = 0;
-                    color = (0xff << 24) | (red << 16) | (green << 8) | blue;
+                    color = makeRGBColor(red, green, blue);
                 }
                 colorDotsTexture.setRGB(x, y, color);
             }
@@ -546,10 +561,10 @@
             // for all columns on a line
             for (int x = 0; x < width; x++)
             {
-                int red = (x - (width >> 1)) & 0xff;
-                int green = (y - (height >> 1)) & 0xff;
+                int red = colorComponentFromXOrYCoordinate(width, x);
+                int green = colorComponentFromXOrYCoordinate(height, y);
                 int blue = 0;
-                int color = (0xff << 24) | (red << 16) | (green << 8) | blue;
+                int color = makeRGBColor(red, green, blue);
                 RGBTexture1.setRGB(x, y, color);
             }
         }
@@ -582,10 +597,10 @@
             // for all columns on a line
             for (int x = 0; x < width; x++)
             {
-                int red = 0;
-                int green = (y - (height >> 1)) & 0xff;
-                int blue = (x - (width >> 1)) & 0xff;
-                int color = (0xff << 24) | (red << 16) | (green << 8) | blue;
+                int red = colorComponentFromXOrYCoordinate(width, x);
+                int green = colorComponentFromXOrYCoordinate(height, y);
+                int blue = 0xff;
+                int color = makeRGBColor(red, green, blue);
                 RGBTexture2.setRGB(x, y, color);
             }
         }
@@ -618,10 +633,10 @@
             // for all columns on a line
             for (int x = 0; x < width; x++)
             {
-                int red = 0xff;
-                int green = (x - (width >> 1)) & 0xff;
-                int blue = (y - (height >> 1)) & 0xff;
-                int color = (0xff << 24) | (red << 16) | (green << 8) | blue;
+                int red = 0;
+                int green = colorComponentFromXOrYCoordinate(height, y);
+                int blue = colorComponentFromXOrYCoordinate(width, x);
+                int color = makeRGBColor(red, green, blue);
                 RGBTexture3.setRGB(x, y, color);
             }
         }
@@ -629,6 +644,136 @@
     }
 
     /**
+     * Create fourth version of RGB texture.
+     * 
+     * @param width
+     *            width of a texture
+     * @param height
+     *            height of a texture
+     * @return buffered image containing texture
+     */
+    private static BufferedImage RGBTexture4Factory(int width, int height)
+    {
+        // if the texture already exists, return it
+        if (RGBTexture4 != null)
+        {
+            return RGBTexture4;
+        }
+
+        // create new texture instead
+        RGBTexture4  = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+
+        // for all lines in a raster image
+        for (int y = 0; y < height; y++)
+        {
+            // for all columns on a line
+            for (int x = 0; x < width; x++)
+            {
+                int red = 0xff;
+                int green = colorComponentFromXOrYCoordinate(width, x);
+                int blue = colorComponentFromXOrYCoordinate(height, y);
+                int color = makeRGBColor(red, green, blue);
+                RGBTexture4.setRGB(x, y, color);
+            }
+        }
+        return RGBTexture4;
+    }
+
+    /**
+     * Create fifth version of RGB texture.
+     * 
+     * @param width
+     *            width of a texture
+     * @param height
+     *            height of a texture
+     * @return buffered image containing texture
+     */
+    private static BufferedImage RGBTexture5Factory(int width, int height)
+    {
+        // if the texture already exists, return it
+        if (RGBTexture5 != null)
+        {
+            return RGBTexture5;
+        }
+
+        // create new texture instead
+        RGBTexture5  = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+
+        // for all lines in a raster image
+        for (int y = 0; y < height; y++)
+        {
+            // for all columns on a line
+            for (int x = 0; x < width; x++)
+            {
+                int red = colorComponentFromXOrYCoordinate(width, x);
+                int green = 0;
+                int blue = colorComponentFromXOrYCoordinate(height, y);
+                int color = makeRGBColor(red, green, blue);
+                RGBTexture5.setRGB(x, y, color);
+            }
+        }
+        return RGBTexture5;
+    }
+
+
+    /**
+     * Create sixth version of RGB texture.
+     * 
+     * @param width
+     *            width of a texture
+     * @param height
+     *            height of a texture
+     * @return buffered image containing texture
+     */
+    private static BufferedImage RGBTexture6Factory(int width, int height)
+    {
+        // if the texture already exists, return it
+        if (RGBTexture6 != null)
+        {
+            return RGBTexture6;
+        }
+
+        // create new texture instead
+        RGBTexture6  = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+
+        // for all lines in a raster image
+        for (int y = 0; y < height; y++)
+        {
+            // for all columns on a line
+            for (int x = 0; x < width; x++)
+            {
+                int red = colorComponentFromXOrYCoordinate(width, x);
+                int green = 0xff;
+                int blue = colorComponentFromXOrYCoordinate(height, y);
+                int color = makeRGBColor(red, green, blue);
+                RGBTexture6.setRGB(x, y, color);
+            }
+        }
+        return RGBTexture6;
+    }
+
+    /**
+     * @param red
+     * @param green
+     * @param blue
+     * @return
+     */
+    private static int makeRGBColor(int red, int green, int blue)
+    {
+        return (0xff << 24) | (red << 16) | (green << 8) | blue;
+    }
+
+    /**
+     * @param width
+     * @param x
+     * @return
+     */
+    private static int colorComponentFromXOrYCoordinate(int width, int x)
+    {
+        return (x - (width >> 1)) & 0xff;
+    }
+
+    /**
      * Return {@link TexturePaint} object containing checker texture.
      * 
      * @param image
@@ -825,4 +970,49 @@
         return new TexturePaint(RGBTexture3Factory(image.getWidth(), image.getHeight()), anchor);
     }
 
+    /**
+     * Return {@link TexturePaint} object containing texture with various RGB colors.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param anchor
+     *            the Rectangle2D in user space used to anchor and replicate the
+     *            texture
+     * @return {@link TexturePaint} object containing gradient texture
+     */
+    public static TexturePaint getRGBTexture4Paint(TestImage image, Rectangle2D anchor)
+    {
+        return new TexturePaint(RGBTexture4Factory(image.getWidth(), image.getHeight()), anchor);
+    }
+
+    /**
+     * Return {@link TexturePaint} object containing texture with various RGB colors.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param anchor
+     *            the Rectangle2D in user space used to anchor and replicate the
+     *            texture
+     * @return {@link TexturePaint} object containing gradient texture
+     */
+    public static TexturePaint getRGBTexture5Paint(TestImage image, Rectangle2D anchor)
+    {
+        return new TexturePaint(RGBTexture5Factory(image.getWidth(), image.getHeight()), anchor);
+    }
+
+    /**
+     * Return {@link TexturePaint} object containing texture with various RGB colors.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param anchor
+     *            the Rectangle2D in user space used to anchor and replicate the
+     *            texture
+     * @return {@link TexturePaint} object containing gradient texture
+     */
+    public static TexturePaint getRGBTexture6Paint(TestImage image, Rectangle2D anchor)
+    {
+        return new TexturePaint(RGBTexture6Factory(image.getWidth(), image.getHeight()), anchor);
+    }
+
 }



More information about the distro-pkg-dev mailing list