8023483: sun/java2d/DirectX/TransformedPaintTest/TransformedPaintTest.java failed with jdk8 on linux platforms
Reviewed-by: prr, bae
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRBackend.java Tue Oct 22 13:28:44 2013 +0400
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRBackend.java Tue Oct 22 13:47:45 2013 -0700
@@ -100,14 +100,13 @@
int xSrc, int ySrc, int xDst, int yDst,
int glyphset, GrowableEltArray elts);
- public int createRadialGradient(Point2D inner, Point2D outer,
+ public int createRadialGradient(float centerX, float centerY,
float innerRadius, float outerRadius,
float[] fractions, int[] pixels,
- int repeat, AffineTransform transform);
+ int repeat);
public int createLinearGradient(Point2D p1, Point2D p2, float[] fractions,
- int[] pixels, int repeat,
- AffineTransform transform);
+ int[] pixels, int repeat);
public void setGCMode(long gc, boolean copy);
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRBackendNative.java Tue Oct 22 13:28:44 2013 +0400
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRBackendNative.java Tue Oct 22 13:47:45 2013 -0700
@@ -105,17 +105,14 @@
XRCreateLinearGradientPaintNative(float[] fractionsArray,
short[] pixelsArray,
int x1, int y1, int x2, int y2,
- int numStops, int repeat,
- int m00, int m01, int m02,
- int m10, int m11, int m12);
+ int numStops, int repeat);
private native static int
XRCreateRadialGradientPaintNative(float[] fractionsArray,
short[] pixelsArray, int numStops,
+ int centerX, int centerY,
int innerRadius, int outerRadius,
- int repeat,
- int m00, int m01, int m02,
- int m10, int m11, int m12);
+ int repeat);
public native void setFilter(int picture, int filter);
@@ -175,40 +172,29 @@
}
public int createLinearGradient(Point2D p1, Point2D p2, float[] fractions,
- int[] pixels, int repeat, AffineTransform trx) {
+ int[] pixels, int repeat) {
short[] colorValues = getRenderColors(pixels);
int gradient =
XRCreateLinearGradientPaintNative(fractions, colorValues,
XDoubleToFixed(p1.getX()), XDoubleToFixed(p1.getY()),
XDoubleToFixed(p2.getX()), XDoubleToFixed(p2.getY()),
- fractions.length, repeat,
- XDoubleToFixed(trx.getScaleX()),
- XDoubleToFixed(trx.getShearX()),
- XDoubleToFixed(trx.getTranslateX()),
- XDoubleToFixed(trx.getShearY()),
- XDoubleToFixed(trx.getScaleY()),
- XDoubleToFixed(trx.getTranslateY()));
+ fractions.length, repeat);
return gradient;
}
- public int createRadialGradient(Point2D inner, Point2D outer,
+ public int createRadialGradient(float centerX, float centerY,
float innerRadius, float outerRadius,
- float[] fractions, int[] pixels, int repeat,
- AffineTransform trx) {
+ float[] fractions, int[] pixels, int repeat) {
short[] colorValues = getRenderColors(pixels);
return XRCreateRadialGradientPaintNative
(fractions, colorValues, fractions.length,
+ XDoubleToFixed(centerX),
+ XDoubleToFixed(centerY),
XDoubleToFixed(innerRadius),
XDoubleToFixed(outerRadius),
- repeat,
- XDoubleToFixed(trx.getScaleX()),
- XDoubleToFixed(trx.getShearX()),
- XDoubleToFixed(trx.getTranslateX()),
- XDoubleToFixed(trx.getShearY()),
- XDoubleToFixed(trx.getScaleY()),
- XDoubleToFixed(trx.getTranslateY()));
+ repeat);
}
public void setGCClipRectangles(long gc, Region clip) {
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRCompositeManager.java Tue Oct 22 13:28:44 2013 +0400
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRCompositeManager.java Tue Oct 22 13:47:45 2013 -0700
@@ -116,7 +116,7 @@
con.renderRectangle(solidSrcPictXID, XRUtils.PictOpSrc,
XRColor.FULL_ALPHA, 0, 0, 1, 1);
solidSrcPict = new XRSurfaceData.XRInternalSurfaceData(con,
- solidSrcPictXID, null);
+ solidSrcPictXID);
setForeground(0);
int extraAlphaMask = con.createPixmap(parentXid, 8, 1, 1);
@@ -198,7 +198,7 @@
} catch (NoninvertibleTransformException e) {
at.setToIdentity();
}
- src.validateAsSource(at, -1, -1);
+ src.validateAsSource(at, -1, XRUtils.ATransOpToXRQuality(sg2d.interpolationType));
}
}
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRPaints.java Tue Oct 22 13:28:44 2013 +0400
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRPaints.java Tue Oct 22 13:47:45 2013 -0700
@@ -29,10 +29,9 @@
import java.awt.MultipleGradientPaint.*;
import java.awt.geom.*;
import java.awt.image.*;
-
import sun.java2d.*;
import sun.java2d.loops.*;
-import sun.java2d.pipe.*;
+import sun.java2d.xr.XRSurfaceData.XRInternalSurfaceData;
abstract class XRPaints {
static XRCompositeManager xrCompMan;
@@ -108,27 +107,16 @@
void setXRPaint(SunGraphics2D sg2d, Paint pt) {
GradientPaint paint = (GradientPaint) pt;
- int[] pixels = convertToIntArgbPixels(new Color[] { paint.getColor1(), paint.getColor2() }, false);
-
- float fractions[] = new float[2];
- fractions[0] = 0;
- fractions[1] = 1;
+ int repeat = paint.isCyclic() ? XRUtils.RepeatReflect : XRUtils.RepeatPad;
+ float fractions[] = {0, 1};
+ int[] pixels = convertToIntArgbPixels(new Color[] { paint.getColor1(), paint.getColor2() });
Point2D pt1 = paint.getPoint1();
Point2D pt2 = paint.getPoint2();
- AffineTransform at = (AffineTransform) sg2d.transform.clone();
- try {
- at.invert();
- } catch (NoninvertibleTransformException ex) {
- at.setToIdentity();
- }
-
- int repeat = paint.isCyclic() ? XRUtils.RepeatReflect : XRUtils.RepeatPad;
-
XRBackend con = xrCompMan.getBackend();
- int gradient = con.createLinearGradient(pt1, pt2, fractions, pixels, repeat, at);
- xrCompMan.setGradientPaint(new XRSurfaceData.XRInternalSurfaceData(con, gradient, at));
+ int gradient = con.createLinearGradient(pt1, pt2, fractions, pixels, repeat);
+ xrCompMan.setGradientPaint(new XRSurfaceData.XRInternalSurfaceData(con, gradient));
}
}
@@ -142,26 +130,22 @@
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
- return true;
+ return ((LinearGradientPaint) sg2d.getPaint()).getColorSpace() == ColorSpaceType.SRGB;
}
@Override
void setXRPaint(SunGraphics2D sg2d, Paint pt) {
LinearGradientPaint paint = (LinearGradientPaint) pt;
- boolean linear = (paint.getColorSpace() == ColorSpaceType.LINEAR_RGB);
Color[] colors = paint.getColors();
Point2D pt1 = paint.getStartPoint();
Point2D pt2 = paint.getEndPoint();
+ int repeat = XRUtils.getRepeatForCycleMethod(paint.getCycleMethod());
+ float[] fractions = paint.getFractions();
+ int[] pixels = convertToIntArgbPixels(colors);
AffineTransform at = paint.getTransform();
- at.preConcatenate(sg2d.transform);
-
- int repeat = XRUtils.getRepeatForCycleMethod(paint.getCycleMethod());
- float[] fractions = paint.getFractions();
- int[] pixels = convertToIntArgbPixels(colors, linear);
-
try {
at.invert();
} catch (NoninvertibleTransformException ex) {
@@ -169,8 +153,10 @@
}
XRBackend con = xrCompMan.getBackend();
- int gradient = con.createLinearGradient(pt1, pt2, fractions, pixels, repeat, at);
- xrCompMan.setGradientPaint(new XRSurfaceData.XRInternalSurfaceData(con, gradient, at));
+ int gradient = con.createLinearGradient(pt1, pt2, fractions, pixels, repeat);
+ XRInternalSurfaceData x11sd = new XRSurfaceData.XRInternalSurfaceData(con, gradient);
+ x11sd.setStaticSrcTx(at);
+ xrCompMan.setGradientPaint(x11sd);
}
}
@@ -179,136 +165,101 @@
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
RadialGradientPaint grad = (RadialGradientPaint) sg2d.paint;
- return grad.getFocusPoint().equals(grad.getCenterPoint());
+ return grad.getFocusPoint().equals(grad.getCenterPoint())
+ && grad.getColorSpace() == ColorSpaceType.SRGB;
}
@Override
void setXRPaint(SunGraphics2D sg2d, Paint pt) {
RadialGradientPaint paint = (RadialGradientPaint) pt;
- boolean linear = (paint.getColorSpace() == ColorSpaceType.LINEAR_RGB);
Color[] colors = paint.getColors();
Point2D center = paint.getCenterPoint();
- Point2D focus = paint.getFocusPoint();
int repeat = XRUtils.getRepeatForCycleMethod(paint.getCycleMethod());
float[] fractions = paint.getFractions();
- int[] pixels = convertToIntArgbPixels(colors, linear);
+ int[] pixels = convertToIntArgbPixels(colors);
float radius = paint.getRadius();
- // save original (untransformed) center and focus points
- double cx = center.getX();
- double cy = center.getY();
- double fx = focus.getX();
- double fy = focus.getY();
+ float cx = (float) center.getX();
+ float cy = (float) center.getY();
AffineTransform at = paint.getTransform();
- at.preConcatenate(sg2d.transform);
- focus = at.transform(focus, focus);
-
- // transform unit circle to gradient coords; we start with the
- // unit circle (center=(0,0), focus on positive x-axis, radius=1)
- // and then transform into gradient space
- at.translate(cx, cy);
- at.rotate(fx - cx, fy - cy);
- // at.scale(radius, radius);
-
- // invert to get mapping from device coords to unit circle
try {
at.invert();
- } catch (Exception e) {
- at.setToScale(0.0, 0.0);
+ } catch (NoninvertibleTransformException ex) {
+ ex.printStackTrace();
}
- focus = at.transform(focus, focus);
-
- // clamp the focus point so that it does not rest on, or outside
- // of, the circumference of the gradient circle
- fx = Math.min(focus.getX(), 0.99);
XRBackend con = xrCompMan.getBackend();
- int gradient = con.createRadialGradient(new Point2D.Float(0, 0), new Point2D.Float(0, 0), 0, radius, fractions, pixels, repeat, at);
- xrCompMan.setGradientPaint(new XRSurfaceData.XRInternalSurfaceData(con, gradient, at));
+ int gradient = con.createRadialGradient(cx, cy, 0, radius, fractions, pixels, repeat);
+ XRInternalSurfaceData x11sd = new XRSurfaceData.XRInternalSurfaceData(con, gradient);
+ x11sd.setStaticSrcTx(at);
+ xrCompMan.setGradientPaint(x11sd);
}
}
private static class XRTexture extends XRPaints {
+ private XRSurfaceData getAccSrcSurface(XRSurfaceData dstData, BufferedImage bi) {
+ // REMIND: this is a hack that attempts to cache the system
+ // memory image from the TexturePaint instance into an
+ // XRender pixmap...
+ SurfaceData srcData = dstData.getSourceSurfaceData(bi, SunGraphics2D.TRANSFORM_ISIDENT, CompositeType.SrcOver, null);
+ if (!(srcData instanceof XRSurfaceData)) {
+ srcData = dstData.getSourceSurfaceData(bi, SunGraphics2D.TRANSFORM_ISIDENT, CompositeType.SrcOver, null);
+ if (!(srcData instanceof XRSurfaceData)) {
+ throw new InternalError("Surface not cachable");
+ }
+ }
+
+ return (XRSurfaceData) srcData;
+ }
+
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
TexturePaint paint = (TexturePaint) sg2d.paint;
BufferedImage bi = paint.getImage();
XRSurfaceData dstData = (XRSurfaceData) sg2d.getDestSurface();
- SurfaceData srcData = dstData.getSourceSurfaceData(bi, SunGraphics2D.TRANSFORM_ISIDENT, CompositeType.SrcOver, null);
- if (!(srcData instanceof XRSurfaceData)) {
- // REMIND: this is a hack that attempts to cache the system
- // memory image from the TexturePaint instance into an
- // OpenGL texture...
- srcData = dstData.getSourceSurfaceData(bi, SunGraphics2D.TRANSFORM_ISIDENT, CompositeType.SrcOver, null);
- if (!(srcData instanceof XRSurfaceData)) {
- return false;
- }
- }
-
- return true;
+ return getAccSrcSurface(dstData, bi) != null;
}
@Override
void setXRPaint(SunGraphics2D sg2d, Paint pt) {
TexturePaint paint = (TexturePaint) pt;
-
BufferedImage bi = paint.getImage();
- SurfaceData dstData = sg2d.surfaceData;
- SurfaceData srcData = dstData.getSourceSurfaceData(bi, SunGraphics2D.TRANSFORM_ISIDENT, CompositeType.SrcOver, null);
+ Rectangle2D anchor = paint.getAnchorRect();
- // REMIND: this hack tries to ensure that we have a cached texture
- if (!(srcData instanceof XRSurfaceData)) {
- srcData = dstData.getSourceSurfaceData(paint.getImage(), SunGraphics2D.TRANSFORM_ISIDENT, CompositeType.SrcOver, null);
- if (!(srcData instanceof XRSurfaceData)) {
- throw new InternalError("Surface not cachable");
- }
- }
+ XRSurfaceData dstData = (XRSurfaceData) sg2d.surfaceData;
+ XRSurfaceData srcData = (XRSurfaceData) getAccSrcSurface(dstData, bi);
- XRSurfaceData x11SrcData = (XRSurfaceData) srcData;
-
- AffineTransform at = (AffineTransform) sg2d.transform.clone();
- Rectangle2D anchor = paint.getAnchorRect();
+ AffineTransform at = new AffineTransform();
at.translate(anchor.getX(), anchor.getY());
at.scale(anchor.getWidth() / ((double) bi.getWidth()), anchor.getHeight() / ((double) bi.getHeight()));
try {
at.invert();
} catch (NoninvertibleTransformException ex) {
- at.setToIdentity(); /* TODO: Right thing to do in this case? */
+ at.setToIdentity();
}
+ srcData.setStaticSrcTx(at);
- x11SrcData.validateAsSource(at, XRUtils.RepeatNormal, XRUtils.ATransOpToXRQuality(sg2d.interpolationType));
- xrCompMan.setTexturePaint(((XRSurfaceData) srcData));
+ srcData.validateAsSource(at, XRUtils.RepeatNormal, XRUtils.ATransOpToXRQuality(sg2d.interpolationType));
+ xrCompMan.setTexturePaint(srcData);
}
}
- public int[] convertToIntArgbPixels(Color[] colors, boolean linear) {
+ public int[] convertToIntArgbPixels(Color[] colors) {
int[] pixels = new int[colors.length];
for (int i = 0; i < colors.length; i++) {
- pixels[i] = colorToIntArgbPixel(colors[i], linear);
+ pixels[i] = colorToIntArgbPixel(colors[i]);
}
return pixels;
}
- public int colorToIntArgbPixel(Color c, boolean linear) {
+ public int colorToIntArgbPixel(Color c) {
int rgb = c.getRGB();
-
- int a = rgb >>> 24;
- int r = (rgb >> 16) & 0xff;
- int g = (rgb >> 8) & 0xff;
- int b = (rgb) & 0xff;
- if (linear) {
- r = BufferedPaints.convertSRGBtoLinearRGB(r);
- g = BufferedPaints.convertSRGBtoLinearRGB(g);
- b = BufferedPaints.convertSRGBtoLinearRGB(b);
- }
-
- a *= xrCompMan.getExtraAlpha();
-
- return ((a << 24) | (r << 16) | (g << 8) | (b));
+ int a = (int) Math.round(xrCompMan.getExtraAlpha() * (rgb >>> 24));
+ return ((a << 24) | (rgb & 0x00FFFFFF));
}
}
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java Tue Oct 22 13:28:44 2013 +0400
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java Tue Oct 22 13:47:45 2013 -0700
@@ -395,6 +395,7 @@
boolean transformInUse = false;
AffineTransform validatedSourceTransform = new AffineTransform();
+ AffineTransform staticSrcTx = null;
int validatedRepeat = XRUtils.RepeatNone;
int validatedFilter = XRUtils.FAST;
@@ -423,13 +424,24 @@
}
} else if (!transformInUse ||
(transformInUse && !sxForm.equals(validatedSourceTransform))) {
+
validatedSourceTransform.setTransform(sxForm.getScaleX(),
sxForm.getShearY(),
sxForm.getShearX(),
sxForm.getScaleY(),
sxForm.getTranslateX(),
sxForm.getTranslateY());
- renderQueue.setPictureTransform(picture, validatedSourceTransform);
+
+ AffineTransform srcTransform = validatedSourceTransform;
+ if(staticSrcTx != null) {
+ // Apply static transform set when used as texture or gradient.
+ // Create a copy to not modify validatedSourceTransform as
+ // this would confuse the validation logic.
+ srcTransform = new AffineTransform(validatedSourceTransform);
+ srcTransform.preConcatenate(staticSrcTx);
+ }
+
+ renderQueue.setPictureTransform(picture, srcTransform);
transformInUse = true;
}
@@ -547,15 +559,10 @@
}
public static class XRInternalSurfaceData extends XRSurfaceData {
- public XRInternalSurfaceData(XRBackend renderQueue, int pictXid,
- AffineTransform transform) {
+ public XRInternalSurfaceData(XRBackend renderQueue, int pictXid) {
super(renderQueue);
this.picture = pictXid;
- this.validatedSourceTransform = transform;
-
- if (validatedSourceTransform != null) {
- transformInUse = true;
- }
+ this.transformInUse = false;
}
public boolean canSourceSendExposures(int x, int y, int w, int h) {
@@ -677,4 +684,8 @@
public XRGraphicsConfig getGraphicsConfig() {
return graphicsConfig;
}
+
+ public void setStaticSrcTx(AffineTransform staticSrcTx) {
+ this.staticSrcTx = staticSrcTx;
+ }
}
--- a/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c Tue Oct 22 13:28:44 2013 +0400
+++ b/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c Tue Oct 22 13:47:45 2013 -0700
@@ -523,12 +523,10 @@
Java_sun_java2d_xr_XRBackendNative_XRCreateLinearGradientPaintNative
(JNIEnv *env, jclass xsd, jfloatArray fractionsArray,
jshortArray pixelsArray, jint x1, jint y1, jint x2, jint y2,
- jint numStops, jint repeat,
- jint m00, jint m01, jint m02, jint m10, jint m11, jint m12) {
+ jint numStops, jint repeat) {
jint i;
jshort* pixels;
jfloat* fractions;
- XTransform tr;
XRenderPictureAttributes pict_attr;
Picture gradient = 0;
XRenderColor *colors;
@@ -594,8 +592,6 @@
(*env)->ReleasePrimitiveArrayCritical(env, fractionsArray, fractions, JNI_ABORT);
if (gradient != 0) {
- BUILD_TRANSFORM_MATRIX(tr, m00, m01, m02, m10, m11, m12);
- XRenderSetPictureTransform (awt_display, gradient, &tr);
pict_attr.repeat = repeat;
XRenderChangePicture (awt_display, gradient, CPRepeat, &pict_attr);
}
@@ -608,12 +604,11 @@
Java_sun_java2d_xr_XRBackendNative_XRCreateRadialGradientPaintNative
(JNIEnv *env, jclass xsd, jfloatArray fractionsArray,
jshortArray pixelsArray, jint numStops,
- jint innerRadius, jint outerRadius, jint repeat,
- jint m00, jint m01, jint m02, jint m10, jint m11, jint m12) {
+ jint centerX, jint centerY,
+ jint innerRadius, jint outerRadius, jint repeat) {
jint i;
jshort* pixels;
jfloat* fractions;
- XTransform tr;
XRenderPictureAttributes pict_attr;
Picture gradient = 0;
XRenderColor *colors;
@@ -637,11 +632,11 @@
return -1; //TODO release pixels first
}
- grad.inner.x = 0;
- grad.inner.y = 0;
+ grad.inner.x = centerX;
+ grad.inner.y = centerY;
grad.inner.radius = innerRadius;
- grad.outer.x = 0;
- grad.outer.y = 0;
+ grad.outer.x = centerX;
+ grad.outer.y = centerY;
grad.outer.radius = outerRadius;
/*TODO optimized & malloc check*/
@@ -682,8 +677,6 @@
if (gradient != 0) {
- BUILD_TRANSFORM_MATRIX(tr, m00, m01, m02, m10, m11, m12);
- XRenderSetPictureTransform (awt_display, gradient, &tr);
pict_attr.repeat = repeat;
XRenderChangePicture (awt_display, gradient, CPRepeat, &pict_attr);
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/GradientPaint/GradientTransformTest.java Tue Oct 22 13:47:45 2013 -0700
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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.
+ */
+
+import java.awt.*;
+import java.awt.MultipleGradientPaint.*;
+import java.awt.geom.*;
+import java.awt.image.*;
+
+/**
+ * @test
+ * @bug 8023483
+ * @summary tests if the transform-parameter is applied correctly when creating
+ * a gradient.
+ * @author ceisserer
+ */
+public class GradientTransformTest extends Frame {
+ BufferedImage srcImg;
+ Image dstImg;
+
+ public GradientTransformTest() {
+ srcImg = createSrcImage();
+ dstImg = getGraphicsConfiguration().createCompatibleVolatileImage(20,
+ 20);
+ }
+
+ protected void renderToVI(BufferedImage src, Image dst) {
+ Graphics2D g = (Graphics2D) dst.getGraphics();
+
+ g.setColor(Color.WHITE);
+ g.fillRect(0, 0, dst.getWidth(null), dst.getHeight(null));
+
+ AffineTransform at = new AffineTransform();
+ at.translate(-100, 0);
+
+ g.setPaint(new LinearGradientPaint(new Point2D.Float(100, 0),
+ new Point2D.Float(120, 0), new float[] { 0.0f, 0.75f, 1.0f },
+ new Color[] { Color.red, Color.green, Color.blue },
+ CycleMethod.NO_CYCLE, ColorSpaceType.SRGB, at));
+
+ g.fillRect(-10, -10, 30, 30);
+ }
+
+ public void paint(Graphics g1) {
+ Graphics2D g = (Graphics2D) g1;
+ renderToVI(createSrcImage(), dstImg);
+ g.drawImage(dstImg, 20, 20, null);
+ }
+
+ public void showFrame() {
+ setSize(500, 500);
+ setVisible(true);
+ }
+
+ public void test() {
+ renderToVI(createSrcImage(), dstImg);
+
+ BufferedImage validationImg = new BufferedImage(20, 20,
+ BufferedImage.TYPE_INT_RGB);
+ Graphics2D valG = (Graphics2D) validationImg.getGraphics();
+ valG.drawImage(dstImg, 0, 0, null);
+
+ // Loop over all pixel, and count the different pixel values
+ // encountered.
+ boolean gradientTranslated = false;
+ for (int x = 0; x < validationImg.getWidth() && !gradientTranslated; x++) {
+ for (int y = 0; y < validationImg.getHeight()
+ && !gradientTranslated; y++) {
+ int rgb = validationImg.getRGB(x, y);
+ if (rgb != -65279) {
+ gradientTranslated = true;
+ }
+ }
+ }
+
+ if (gradientTranslated) {
+ System.out.println("Passed!");
+ } else {
+ throw new RuntimeException("Test FAILED!");
+ }
+ }
+
+ protected BufferedImage createSrcImage() {
+ BufferedImage bi = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);
+ Graphics2D g = (Graphics2D) bi.getGraphics();
+ g.setColor(Color.YELLOW);
+ g.fillRect(0, 0, 10, 10);
+ g.setColor(Color.black);
+ g.drawLine(0, 0, 10, 10);
+ return bi;
+ }
+
+ public static void main(String[] args) throws Exception {
+ boolean show = (args.length > 0 && "-show".equals(args[0]));
+ final GradientTransformTest t = new GradientTransformTest();
+
+ if (show) {
+ EventQueue.invokeAndWait(new Runnable() {
+ public void run() {
+ t.showFrame();
+ }
+ });
+ } else {
+ t.test();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/GradientPaint/LinearColorSpaceGradientTest.java Tue Oct 22 13:47:45 2013 -0700
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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.
+ */
+
+import java.awt.*;
+import java.awt.MultipleGradientPaint.*;
+import java.awt.geom.*;
+import java.awt.image.*;
+
+/**
+ * @test
+ * @bug 8023483
+ * @summary tests wether the colorspace-parameter is applied correctly when
+ * creating a gradient.
+ * @author ceisserer
+ */
+public class LinearColorSpaceGradientTest extends Frame {
+ BufferedImage srcImg;
+ Image dstImg;
+
+ public LinearColorSpaceGradientTest() {
+ srcImg = createSrcImage();
+ dstImg = getGraphicsConfiguration().createCompatibleVolatileImage(20,
+ 20);
+ }
+
+ protected void renderToVI(BufferedImage src, Image dst) {
+ Graphics2D g = (Graphics2D) dst.getGraphics();
+
+ g.setColor(Color.WHITE);
+ g.fillRect(0, 0, dst.getWidth(null), dst.getHeight(null));
+
+ AffineTransform at = new AffineTransform();
+ g.setPaint(new LinearGradientPaint(new Point2D.Float(0, 0),
+ new Point2D.Float(20, 0), new float[] { 0.0f, 1.0f },
+ new Color[] { Color.green, Color.blue }, CycleMethod.NO_CYCLE,
+ ColorSpaceType.LINEAR_RGB, at));
+
+ g.fillRect(-10, -10, 30, 30);
+ }
+
+ public void paint(Graphics g1) {
+ Graphics2D g = (Graphics2D) g1;
+ renderToVI(createSrcImage(), dstImg);
+ g.drawImage(dstImg, 20, 20, null);
+ }
+
+ public void showFrame() {
+ setSize(500, 500);
+ setVisible(true);
+ }
+
+ public void test() {
+ renderToVI(createSrcImage(), dstImg);
+
+ BufferedImage validationImg = new BufferedImage(20, 20,
+ BufferedImage.TYPE_INT_RGB);
+ Graphics2D valG = (Graphics2D) validationImg.getGraphics();
+ valG.drawImage(dstImg, 0, 0, null);
+
+ int b = validationImg.getRGB(10, 10) & 0x000000FF;
+
+ if (b > 150) {
+ System.out.println("Passed!");
+ } else {
+ throw new RuntimeException("Test FAILED!");
+ }
+ }
+
+ protected BufferedImage createSrcImage() {
+ BufferedImage bi = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);
+ Graphics2D g = (Graphics2D) bi.getGraphics();
+ g.setColor(Color.YELLOW);
+ g.fillRect(0, 0, 10, 10);
+ g.setColor(Color.black);
+ g.drawLine(0, 0, 10, 10);
+ return bi;
+ }
+
+ public static void main(String[] args) throws Exception {
+ boolean show = (args.length > 0 && "-show".equals(args[0]));
+
+ final LinearColorSpaceGradientTest t = new LinearColorSpaceGradientTest();
+ if (show) {
+ EventQueue.invokeAndWait(new Runnable() {
+ public void run() {
+ t.showFrame();
+ }
+ });
+ } else {
+ t.test();
+ }
+ }
+}
--- a/jdk/test/sun/java2d/DirectX/TransformedPaintTest/TransformedPaintTest.java Tue Oct 22 13:28:44 2013 +0400
+++ b/jdk/test/sun/java2d/DirectX/TransformedPaintTest/TransformedPaintTest.java Tue Oct 22 13:47:45 2013 -0700
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6689025
+ * @bug 6689025 8023483
* @summary Tests that transformed Paints are rendered correctly
* @author Dmitri.Trembovetski@sun.com: area=Graphics
* @run main/othervm TransformedPaintTest