# HG changeset patch
# User alexsch
# Date 1447419746 28800
# Node ID 259d6e4e09781bc8b2c5f95181fd466c4d8a88bc
# Parent 171a07c89136161e44a9ff8a622d7a0623140c67
8073320: Windows HiDPI Graphics support
Reviewed-by: flar, serb
diff -r 171a07c89136 -r 259d6e4e0978 jdk/src/java.base/windows/native/launcher/java.manifest
--- a/jdk/src/java.base/windows/native/launcher/java.manifest Thu Nov 12 12:27:36 2015 -0600
+++ b/jdk/src/java.base/windows/native/launcher/java.manifest Fri Nov 13 05:02:26 2015 -0800
@@ -37,7 +37,7 @@
- true
+ true/PM
diff -r 171a07c89136 -r 259d6e4e0978 jdk/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLSurfaceData.java
--- a/jdk/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLSurfaceData.java Thu Nov 12 12:27:36 2015 -0600
+++ b/jdk/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLSurfaceData.java Fri Nov 13 05:02:26 2015 -0800
@@ -166,7 +166,12 @@
}
@Override
- public int getDefaultScale() {
+ public double getDefaultScaleX() {
+ return scale;
+ }
+
+ @Override
+ public double getDefaultScaleY() {
return scale;
}
diff -r 171a07c89136 -r 259d6e4e0978 jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java Thu Nov 12 12:27:36 2015 -0600
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java Fri Nov 13 05:02:26 2015 -0800
@@ -1156,7 +1156,9 @@
&& !(dst instanceof NullSurfaceData)
&& !(src instanceof NullSurfaceData)
&& src.getSurfaceType().equals(dst.getSurfaceType())
- && src.getDefaultScale() == dst.getDefaultScale()) {
+ && src.getDefaultScaleX() == dst.getDefaultScaleX()
+ && src.getDefaultScaleY() == dst.getDefaultScaleY())
+ {
final Rectangle size = src.getBounds();
final Blit blit = Blit.locate(src.getSurfaceType(),
CompositeType.Src,
diff -r 171a07c89136 -r 259d6e4e0978 jdk/src/java.desktop/share/classes/sun/awt/image/BufImgSurfaceData.java
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/BufImgSurfaceData.java Thu Nov 12 12:27:36 2015 -0600
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/BufImgSurfaceData.java Fri Nov 13 05:02:26 2015 -0800
@@ -50,6 +50,8 @@
BufferedImage bufImg;
private BufferedImageGraphicsConfig graphicsConfig;
RenderLoops solidloops;
+ private final double scaleX;
+ private final double scaleY;
private static native void initIDs(Class> ICM, Class> ICMColorData);
@@ -73,6 +75,12 @@
}
public static SurfaceData createData(BufferedImage bufImg) {
+ return createData(bufImg, 1, 1);
+ }
+
+ public static SurfaceData createData(BufferedImage bufImg,
+ double scaleX, double scaleY)
+ {
if (bufImg == null) {
throw new NullPointerException("BufferedImage cannot be null");
}
@@ -82,31 +90,36 @@
// REMIND: Check the image type and pick an appropriate subclass
switch (type) {
case BufferedImage.TYPE_INT_BGR:
- sData = createDataIC(bufImg, SurfaceType.IntBgr);
+ sData = createDataIC(bufImg, SurfaceType.IntBgr, scaleX, scaleY);
break;
case BufferedImage.TYPE_INT_RGB:
- sData = createDataIC(bufImg, SurfaceType.IntRgb);
+ sData = createDataIC(bufImg, SurfaceType.IntRgb, scaleX, scaleY);
break;
case BufferedImage.TYPE_INT_ARGB:
- sData = createDataIC(bufImg, SurfaceType.IntArgb);
+ sData = createDataIC(bufImg, SurfaceType.IntArgb, scaleX, scaleY);
break;
case BufferedImage.TYPE_INT_ARGB_PRE:
- sData = createDataIC(bufImg, SurfaceType.IntArgbPre);
+ sData = createDataIC(bufImg, SurfaceType.IntArgbPre, scaleX, scaleY);
break;
case BufferedImage.TYPE_3BYTE_BGR:
- sData = createDataBC(bufImg, SurfaceType.ThreeByteBgr, 2);
+ sData = createDataBC(bufImg, SurfaceType.ThreeByteBgr, 2,
+ scaleX, scaleY);
break;
case BufferedImage.TYPE_4BYTE_ABGR:
- sData = createDataBC(bufImg, SurfaceType.FourByteAbgr, 3);
+ sData = createDataBC(bufImg, SurfaceType.FourByteAbgr, 3,
+ scaleX, scaleY);
break;
case BufferedImage.TYPE_4BYTE_ABGR_PRE:
- sData = createDataBC(bufImg, SurfaceType.FourByteAbgrPre, 3);
+ sData = createDataBC(bufImg, SurfaceType.FourByteAbgrPre, 3,
+ scaleX, scaleY);
break;
case BufferedImage.TYPE_USHORT_565_RGB:
- sData = createDataSC(bufImg, SurfaceType.Ushort565Rgb, null);
+ sData = createDataSC(bufImg, SurfaceType.Ushort565Rgb, null,
+ scaleX, scaleY);
break;
case BufferedImage.TYPE_USHORT_555_RGB:
- sData = createDataSC(bufImg, SurfaceType.Ushort555Rgb, null);
+ sData = createDataSC(bufImg, SurfaceType.Ushort555Rgb, null,
+ scaleX, scaleY);
break;
case BufferedImage.TYPE_BYTE_INDEXED:
{
@@ -128,14 +141,16 @@
default:
throw new InternalError("Unrecognized transparency");
}
- sData = createDataBC(bufImg, sType, 0);
+ sData = createDataBC(bufImg, sType, 0, scaleX, scaleY);
}
break;
case BufferedImage.TYPE_BYTE_GRAY:
- sData = createDataBC(bufImg, SurfaceType.ByteGray, 0);
+ sData = createDataBC(bufImg, SurfaceType.ByteGray, 0,
+ scaleX, scaleY);
break;
case BufferedImage.TYPE_USHORT_GRAY:
- sData = createDataSC(bufImg, SurfaceType.UshortGray, null);
+ sData = createDataSC(bufImg, SurfaceType.UshortGray, null,
+ scaleX, scaleY);
break;
case BufferedImage.TYPE_BYTE_BINARY:
{
@@ -154,7 +169,7 @@
default:
throw new InternalError("Unrecognized pixel size");
}
- sData = createDataBP(bufImg, sType);
+ sData = createDataBP(bufImg, sType, scaleX, scaleY);
}
break;
case BufferedImage.TYPE_CUSTOM:
@@ -191,7 +206,7 @@
sType = SurfaceType.AnyDcm;
}
}
- sData = createDataIC(bufImg, sType);
+ sData = createDataIC(bufImg, sType, scaleX, scaleY);
break;
} else if (raster instanceof ShortComponentRaster &&
raster.getNumDataElements() == 1 &&
@@ -233,11 +248,12 @@
icm = null;
}
}
- sData = createDataSC(bufImg, sType, icm);
+ sData = createDataSC(bufImg, sType, icm, scaleX, scaleY);
break;
}
- sData = new BufImgSurfaceData(raster.getDataBuffer(),
- bufImg, SurfaceType.Custom);
+ sData = new BufImgSurfaceData(raster.getDataBuffer(), bufImg,
+ SurfaceType.Custom,
+ scaleX, scaleY);
}
break;
}
@@ -250,11 +266,15 @@
}
public static SurfaceData createDataIC(BufferedImage bImg,
- SurfaceType sType) {
+ SurfaceType sType,
+ double scaleX,
+ double scaleY)
+ {
IntegerComponentRaster icRaster =
(IntegerComponentRaster)bImg.getRaster();
BufImgSurfaceData bisd =
- new BufImgSurfaceData(icRaster.getDataBuffer(), bImg, sType);
+ new BufImgSurfaceData(icRaster.getDataBuffer(), bImg, sType,
+ scaleX, scaleY);
bisd.initRaster(icRaster.getDataStorage(),
icRaster.getDataOffset(0) * 4, 0,
icRaster.getWidth(),
@@ -267,11 +287,14 @@
public static SurfaceData createDataSC(BufferedImage bImg,
SurfaceType sType,
- IndexColorModel icm) {
+ IndexColorModel icm,
+ double scaleX, double scaleY)
+ {
ShortComponentRaster scRaster =
(ShortComponentRaster)bImg.getRaster();
BufImgSurfaceData bisd =
- new BufImgSurfaceData(scRaster.getDataBuffer(), bImg, sType);
+ new BufImgSurfaceData(scRaster.getDataBuffer(), bImg, sType,
+ scaleX, scaleY);
bisd.initRaster(scRaster.getDataStorage(),
scRaster.getDataOffset(0) * 2, 0,
scRaster.getWidth(),
@@ -284,11 +307,14 @@
public static SurfaceData createDataBC(BufferedImage bImg,
SurfaceType sType,
- int primaryBank) {
+ int primaryBank,
+ double scaleX, double scaleY)
+ {
ByteComponentRaster bcRaster =
(ByteComponentRaster)bImg.getRaster();
BufImgSurfaceData bisd =
- new BufImgSurfaceData(bcRaster.getDataBuffer(), bImg, sType);
+ new BufImgSurfaceData(bcRaster.getDataBuffer(), bImg, sType,
+ scaleX, scaleY);
ColorModel cm = bImg.getColorModel();
IndexColorModel icm = ((cm instanceof IndexColorModel)
? (IndexColorModel) cm
@@ -304,11 +330,14 @@
}
public static SurfaceData createDataBP(BufferedImage bImg,
- SurfaceType sType) {
+ SurfaceType sType,
+ double scaleX, double scaleY)
+ {
BytePackedRaster bpRaster =
(BytePackedRaster)bImg.getRaster();
BufImgSurfaceData bisd =
- new BufImgSurfaceData(bpRaster.getDataBuffer(), bImg, sType);
+ new BufImgSurfaceData(bpRaster.getDataBuffer(), bImg, sType,
+ scaleX, scaleY);
ColorModel cm = bImg.getColorModel();
IndexColorModel icm = ((cm instanceof IndexColorModel)
? (IndexColorModel) cm
@@ -350,15 +379,22 @@
IndexColorModel icm);
public BufImgSurfaceData(DataBuffer db,
- BufferedImage bufImg, SurfaceType sType)
+ BufferedImage bufImg,
+ SurfaceType sType,
+ double scaleX,
+ double scaleY)
{
super(SunWritableRaster.stealTrackable(db),
sType, bufImg.getColorModel());
this.bufImg = bufImg;
+ this.scaleX = scaleX;
+ this.scaleY = scaleY;
}
protected BufImgSurfaceData(SurfaceType surfaceType, ColorModel cm) {
super(surfaceType, cm);
+ this.scaleX = 1;
+ this.scaleY = 1;
}
public void initSolidLoops() {
@@ -395,7 +431,8 @@
public synchronized GraphicsConfiguration getDeviceConfiguration() {
if (graphicsConfig == null) {
- graphicsConfig = BufferedImageGraphicsConfig.getConfig(bufImg);
+ graphicsConfig = BufferedImageGraphicsConfig
+ .getConfig(bufImg, scaleX, scaleY);
}
return graphicsConfig;
}
@@ -418,6 +455,16 @@
return bufImg;
}
+ @Override
+ public double getDefaultScaleX() {
+ return scaleX;
+ }
+
+ @Override
+ public double getDefaultScaleY() {
+ return scaleY;
+ }
+
public static final class ICMColorData {
private long pData = 0L;
diff -r 171a07c89136 -r 259d6e4e0978 jdk/src/java.desktop/share/classes/sun/awt/image/BufferedImageGraphicsConfig.java
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/BufferedImageGraphicsConfig.java Thu Nov 12 12:27:36 2015 -0600
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/BufferedImageGraphicsConfig.java Fri Nov 13 05:02:26 2015 -0800
@@ -45,19 +45,32 @@
extends GraphicsConfiguration
{
private static final int numconfigs = BufferedImage.TYPE_BYTE_BINARY;
- private static BufferedImageGraphicsConfig configs[] =
+ private static BufferedImageGraphicsConfig standardConfigs[] =
+ new BufferedImageGraphicsConfig[numconfigs];
+ private static BufferedImageGraphicsConfig scaledConfigs[] =
new BufferedImageGraphicsConfig[numconfigs];
public static BufferedImageGraphicsConfig getConfig(BufferedImage bImg) {
+ return getConfig(bImg, 1, 1);
+ }
+
+ public static BufferedImageGraphicsConfig getConfig(BufferedImage bImg,
+ double scaleX,
+ double scaleY)
+ {
BufferedImageGraphicsConfig ret;
int type = bImg.getType();
+
+ BufferedImageGraphicsConfig[] configs = (scaleX == 1 && scaleY == 1)
+ ? standardConfigs : scaledConfigs;
+
if (type > 0 && type < numconfigs) {
ret = configs[type];
- if (ret != null) {
+ if (ret != null && ret.scaleX == scaleX && ret.scaleY == scaleY) {
return ret;
}
}
- ret = new BufferedImageGraphicsConfig(bImg, null);
+ ret = new BufferedImageGraphicsConfig(bImg, null, scaleX, scaleY);
if (type > 0 && type < numconfigs) {
configs[type] = ret;
}
@@ -67,8 +80,16 @@
GraphicsDevice gd;
ColorModel model;
Raster raster;
+ private final double scaleX;
+ private final double scaleY;
public BufferedImageGraphicsConfig(BufferedImage bufImg, Component comp) {
+ this(bufImg, comp, 1, 1);
+ }
+
+ public BufferedImageGraphicsConfig(BufferedImage bufImg, Component comp,
+ double scaleX, double scaleY)
+ {
if (comp == null) {
this.gd = new BufferedImageDevice(this);
} else {
@@ -77,6 +98,8 @@
}
this.model = bufImg.getColorModel();
this.raster = bufImg.getRaster().createCompatibleWritableRaster(1, 1);
+ this.scaleX = scaleX;
+ this.scaleY = scaleY;
}
/**
@@ -138,7 +161,7 @@
* For image buffers, this Transform will be the Identity transform.
*/
public AffineTransform getDefaultTransform() {
- return new AffineTransform();
+ return AffineTransform.getScaleInstance(scaleX, scaleY);
}
/**
diff -r 171a07c89136 -r 259d6e4e0978 jdk/src/java.desktop/share/classes/sun/awt/image/SunVolatileImage.java
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/SunVolatileImage.java Thu Nov 12 12:27:36 2015 -0600
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/SunVolatileImage.java Fri Nov 13 05:02:26 2015 -0800
@@ -233,8 +233,17 @@
* or a backup surface.
*/
public BufferedImage getBackupImage() {
- return graphicsConfig.createCompatibleImage(getWidth(), getHeight(),
- getTransparency());
+ return getBackupImage(1, 1);
+ }
+
+ /**
+ * This method creates a BufferedImage intended for use as a "snapshot"
+ * or a backup surface with the given horizontal and vertical scale factors.
+ */
+ public BufferedImage getBackupImage(double scaleX, double scaleY) {
+ int w = (int) Math.ceil(getWidth() * scaleX);
+ int h = (int) Math.ceil(getHeight() * scaleY);
+ return graphicsConfig.createCompatibleImage(w, h, getTransparency());
}
public BufferedImage getSnapshot() {
diff -r 171a07c89136 -r 259d6e4e0978 jdk/src/java.desktop/share/classes/sun/awt/image/SurfaceManager.java
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/SurfaceManager.java Thu Nov 12 12:27:36 2015 -0600
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/SurfaceManager.java Fri Nov 13 05:02:26 2015 -0800
@@ -290,16 +290,30 @@
}
/**
- * Returns a scale factor of the image. This is utility method, which
- * fetches information from the SurfaceData of the image.
+ * Returns a horizontal scale factor of the image. This is utility method,
+ * which fetches information from the SurfaceData of the image.
*
- * @see SurfaceData#getDefaultScale
+ * @see SurfaceData#getDefaultScaleX
*/
- public static int getImageScale(final Image img) {
+ public static double getImageScaleX(final Image img) {
if (!(img instanceof VolatileImage)) {
return 1;
}
final SurfaceManager sm = getManager(img);
- return sm.getPrimarySurfaceData().getDefaultScale();
+ return sm.getPrimarySurfaceData().getDefaultScaleX();
+ }
+
+ /**
+ * Returns a vertical scale factor of the image. This is utility method,
+ * which fetches information from the SurfaceData of the image.
+ *
+ * @see SurfaceData#getDefaultScaleY
+ */
+ public static double getImageScaleY(final Image img) {
+ if (!(img instanceof VolatileImage)) {
+ return 1;
+ }
+ final SurfaceManager sm = getManager(img);
+ return sm.getPrimarySurfaceData().getDefaultScaleY();
}
}
diff -r 171a07c89136 -r 259d6e4e0978 jdk/src/java.desktop/share/classes/sun/awt/image/VolatileSurfaceManager.java
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/VolatileSurfaceManager.java Thu Nov 12 12:27:36 2015 -0600
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/VolatileSurfaceManager.java Fri Nov 13 05:02:26 2015 -0800
@@ -25,18 +25,16 @@
package sun.awt.image;
-import java.awt.Color;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;
import java.awt.ImageCapabilities;
+import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.awt.image.VolatileImage;
import sun.awt.DisplayChangedListener;
-import sun.awt.image.SunVolatileImage;
import sun.java2d.SunGraphicsEnvironment;
import sun.java2d.SurfaceData;
-import sun.java2d.loops.CompositeType;
import static sun.java2d.pipe.hw.AccelSurface.*;
/**
@@ -260,12 +258,16 @@
*/
protected SurfaceData getBackupSurface() {
if (sdBackup == null) {
- BufferedImage bImg = vImg.getBackupImage();
+ GraphicsConfiguration gc = vImg.getGraphicsConfig();
+ AffineTransform tx = gc.getDefaultTransform();
+ double scaleX = tx.getScaleX();
+ double scaleY = tx.getScaleY();
+ BufferedImage bImg = vImg.getBackupImage(scaleX, scaleY);
// Sabotage the acceleration capabilities of the BufImg surface
SunWritableRaster.stealTrackable(bImg
.getRaster()
.getDataBuffer()).setUntrackable();
- sdBackup = BufImgSurfaceData.createData(bImg);
+ sdBackup = BufImgSurfaceData.createData(bImg, scaleX, scaleY);
}
return sdBackup;
}
diff -r 171a07c89136 -r 259d6e4e0978 jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java
--- a/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java Thu Nov 12 12:27:36 2015 -0600
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java Fri Nov 13 05:02:26 2015 -0800
@@ -61,7 +61,6 @@
import java.awt.Rectangle;
import java.text.AttributedCharacterIterator;
import java.awt.Font;
-import java.awt.Point;
import java.awt.image.ImageObserver;
import java.awt.Transparency;
import java.awt.font.GlyphVector;
@@ -99,6 +98,7 @@
import static java.awt.geom.AffineTransform.TYPE_FLIP;
import static java.awt.geom.AffineTransform.TYPE_MASK_SCALE;
import static java.awt.geom.AffineTransform.TYPE_TRANSLATION;
+import java.awt.image.VolatileImage;
import sun.awt.image.MultiResolutionToolkitImage;
import sun.awt.image.ToolkitImage;
@@ -3086,30 +3086,50 @@
}
// end of text rendering methods
- private boolean isHiDPIImage(final Image img) {
- return (SurfaceManager.getImageScale(img) != 1)
- || img instanceof MultiResolutionImage;
- }
-
- private boolean drawHiDPIImage(Image img, int dx1, int dy1, int dx2,
- int dy2, int sx1, int sy1, int sx2, int sy2,
- Color bgcolor, ImageObserver observer) {
-
- if (SurfaceManager.getImageScale(img) != 1) { // Volatile Image
- final int scale = SurfaceManager.getImageScale(img);
- sx1 = Region.clipScale(sx1, scale);
- sx2 = Region.clipScale(sx2, scale);
- sy1 = Region.clipScale(sy1, scale);
- sy2 = Region.clipScale(sy2, scale);
- } else if (img instanceof MultiResolutionImage) {
+ private Boolean drawHiDPIImage(Image img,
+ int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2,
+ Color bgcolor, ImageObserver observer,
+ AffineTransform xform) {
+
+ if (img instanceof VolatileImage) {
+ final SurfaceData sd = SurfaceManager.getManager(img)
+ .getPrimarySurfaceData();
+ final double scaleX = sd.getDefaultScaleX();
+ final double scaleY = sd.getDefaultScaleY();
+ if (scaleX == 1 && scaleY == 1) {
+ return null;
+ }
+ sx1 = Region.clipScale(sx1, scaleX);
+ sx2 = Region.clipScale(sx2, scaleX);
+ sy1 = Region.clipScale(sy1, scaleY);
+ sy2 = Region.clipScale(sy2, scaleY);
+
+ AffineTransform tx = null;
+ if (xform != null) {
+ tx = new AffineTransform(transform);
+ transform(xform);
+ }
+ boolean result = scaleImage(img, dx1, dy1, dx2, dy2,
+ sx1, sy1, sx2, sy2,
+ bgcolor, observer);
+ if (tx != null) {
+ transform.setTransform(tx);
+ invalidateTransform();
+ }
+ return result;
+ } else if (resolutionVariantHint != SunHints.INTVAL_RESOLUTION_VARIANT_BASE
+ && (img instanceof MultiResolutionImage)) {
// get scaled destination image size
int width = img.getWidth(observer);
int height = img.getHeight(observer);
- Image resolutionVariant = getResolutionVariant(
- (MultiResolutionImage) img, width, height,
- dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2);
+ MultiResolutionImage mrImage = (MultiResolutionImage) img;
+ Image resolutionVariant = getResolutionVariant(mrImage, width, height,
+ dx1, dy1, dx2, dy2,
+ sx1, sy1, sx2, sy2,
+ xform);
if (resolutionVariant != img && resolutionVariant != null) {
// recalculate source region for the resolution variant
@@ -3123,8 +3143,8 @@
if (0 < width && 0 < height && 0 < rvWidth && 0 < rvHeight) {
- float widthScale = ((float) rvWidth) / width;
- float heightScale = ((float) rvHeight) / height;
+ double widthScale = ((double) rvWidth) / width;
+ double heightScale = ((double) rvHeight) / height;
sx1 = Region.clipScale(sx1, widthScale);
sy1 = Region.clipScale(sy1, heightScale);
@@ -3133,10 +3153,29 @@
observer = rvObserver;
img = resolutionVariant;
+
+ if (xform != null) {
+ assert dx1 == 0 && dy1 == 0;
+ assert dx2 == img.getWidth(observer);
+ assert dy2 == img.getHeight(observer);
+ AffineTransform renderTX = new AffineTransform(xform);
+ renderTX.scale(1 / widthScale, 1 / heightScale);
+ return transformImage(img, renderTX, observer);
+ }
+
+ return scaleImage(img, dx1, dy1, dx2, dy2,
+ sx1, sy1, sx2, sy2,
+ bgcolor, observer);
}
}
}
-
+ return null;
+ }
+
+ private boolean scaleImage(Image img, int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2,
+ Color bgcolor, ImageObserver observer)
+ {
try {
return imagepipe.scaleImage(this, img, dx1, dy1, dx2, dy2, sx1, sy1,
sx2, sy2, bgcolor, observer);
@@ -3156,9 +3195,30 @@
}
}
+ private boolean transformImage(Image img,
+ AffineTransform xform,
+ ImageObserver observer)
+ {
+ try {
+ return imagepipe.transformImage(this, img, xform, observer);
+ } catch (InvalidPipeException e) {
+ try {
+ revalidateAll();
+ return imagepipe.transformImage(this, img, xform, observer);
+ } catch (InvalidPipeException e2) {
+ // Still catching the exception; we are not yet ready to
+ // validate the surfaceData correctly. Fail for now and
+ // try again next time around.
+ return false;
+ }
+ } finally {
+ surfaceData.markDirty();
+ }
+ }
+
private Image getResolutionVariant(MultiResolutionImage img,
int srcWidth, int srcHeight, int dx1, int dy1, int dx2, int dy2,
- int sx1, int sy1, int sx2, int sy2) {
+ int sx1, int sy1, int sx2, int sy2, AffineTransform xform) {
if (srcWidth <= 0 || srcHeight <= 0) {
return null;
@@ -3171,7 +3231,16 @@
return null;
}
- int type = transform.getType();
+ AffineTransform tx;
+
+ if (xform == null) {
+ tx = transform;
+ } else {
+ tx = new AffineTransform(transform);
+ tx.concatenate(xform);
+ }
+
+ int type = tx.getType();
int dw = dx2 - dx1;
int dh = dy2 - dy1;
@@ -3198,13 +3267,13 @@
destRegionWidth = dw;
destRegionHeight = dh;
} else if ((type & ~(TYPE_TRANSLATION | TYPE_FLIP | TYPE_MASK_SCALE)) == 0) {
- destRegionWidth = dw * transform.getScaleX();
- destRegionHeight = dh * transform.getScaleY();
+ destRegionWidth = dw * tx.getScaleX();
+ destRegionHeight = dh * tx.getScaleY();
} else {
destRegionWidth = dw * Math.hypot(
- transform.getScaleX(), transform.getShearY());
+ tx.getScaleX(), tx.getShearY());
destRegionHeight = dh * Math.hypot(
- transform.getShearX(), transform.getScaleY());
+ tx.getShearX(), tx.getScaleY());
}
destImageWidth = Math.abs(srcWidth * destRegionWidth / sw);
destImageHeight = Math.abs(srcHeight * destRegionHeight / sh);
@@ -3277,9 +3346,11 @@
final int imgW = img.getWidth(null);
final int imgH = img.getHeight(null);
- if (isHiDPIImage(img)) {
- return drawHiDPIImage(img, x, y, x + width, y + height, 0, 0, imgW,
- imgH, bg, observer);
+ Boolean hidpiImageDrawn = drawHiDPIImage(img, x, y, x + width, y + height,
+ 0, 0, imgW, imgH, bg, observer,
+ null);
+ if (hidpiImageDrawn != null) {
+ return hidpiImageDrawn;
}
if (width == imgW && height == imgH) {
@@ -3323,11 +3394,13 @@
return true;
}
- if (isHiDPIImage(img)) {
- final int imgW = img.getWidth(null);
- final int imgH = img.getHeight(null);
- return drawHiDPIImage(img, x, y, x + imgW, y + imgH, 0, 0, imgW,
- imgH, bg, observer);
+ final int imgW = img.getWidth(null);
+ final int imgH = img.getHeight(null);
+ Boolean hidpiImageDrawn = drawHiDPIImage(img, x, y, x + imgW, y + imgH,
+ 0, 0, imgW, imgH, bg, observer,
+ null);
+ if (hidpiImageDrawn != null) {
+ return hidpiImageDrawn;
}
try {
@@ -3378,9 +3451,12 @@
return true;
}
- if (isHiDPIImage(img)) {
- return drawHiDPIImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2,
- bgcolor, observer);
+ Boolean hidpiImageDrawn = drawHiDPIImage(img, dx1, dy1, dx2, dy2,
+ sx1, sy1, sx2, sy2,
+ bgcolor, observer, null);
+
+ if (hidpiImageDrawn != null) {
+ return hidpiImageDrawn;
}
if (((sx2 - sx1) == (dx2 - dx1)) &&
@@ -3461,33 +3537,16 @@
return drawImage(img, 0, 0, null, observer);
}
- if (isHiDPIImage(img)) {
- final int w = img.getWidth(null);
- final int h = img.getHeight(null);
- final AffineTransform tx = new AffineTransform(transform);
- transform(xform);
- boolean result = drawHiDPIImage(img, 0, 0, w, h, 0, 0, w, h, null,
- observer);
- transform.setTransform(tx);
- invalidateTransform();
- return result;
+ final int w = img.getWidth(null);
+ final int h = img.getHeight(null);
+ Boolean hidpiImageDrawn = drawHiDPIImage(img, 0, 0, w, h, 0, 0, w, h,
+ null, observer, xform);
+
+ if (hidpiImageDrawn != null) {
+ return hidpiImageDrawn;
}
- try {
- return imagepipe.transformImage(this, img, xform, observer);
- } catch (InvalidPipeException e) {
- try {
- revalidateAll();
- return imagepipe.transformImage(this, img, xform, observer);
- } catch (InvalidPipeException e2) {
- // Still catching the exception; we are not yet ready to
- // validate the surfaceData correctly. Fail for now and
- // try again next time around.
- return false;
- }
- } finally {
- surfaceData.markDirty();
- }
+ return transformImage(img, xform, observer);
}
public void drawImage(BufferedImage bImg,
diff -r 171a07c89136 -r 259d6e4e0978 jdk/src/java.desktop/share/classes/sun/java2d/SunGraphicsEnvironment.java
--- a/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphicsEnvironment.java Thu Nov 12 12:27:36 2015 -0600
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphicsEnvironment.java Fri Nov 13 05:02:26 2015 -0800
@@ -66,6 +66,8 @@
import sun.font.FontManagerFactory;
import sun.font.FontManagerForSGE;
import sun.font.NativeFont;
+import java.security.AccessController;
+import sun.security.action.GetPropertyAction;
/**
* This is an implementation of a GraphicsEnvironment object for the
@@ -80,6 +82,15 @@
public static boolean isOpenSolaris;
private static Font defaultFont;
+ private static final boolean uiScaleEnabled;
+ private static final double debugScale;
+
+ static {
+ uiScaleEnabled = "true".equals(AccessController.doPrivileged(
+ new GetPropertyAction("sun.java2d.uiScale.enabled", "true")));
+ debugScale = uiScaleEnabled ? getScaleFactor("sun.java2d.uiScale") : -1;
+ }
+
public SunGraphicsEnvironment() {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction