--- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java Sat Feb 16 21:15:33 2019 +0100
+++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java Mon Feb 18 10:45:21 2019 +0530
@@ -208,11 +208,13 @@
CImage cimage = CImage.getCreator().createFromImage(image, observer);
boolean imageAutoSize = target.isImageAutoSize();
- cimage.execute(imagePtr -> {
- execute(ptr -> {
- setNativeImage(ptr, imagePtr, imageAutoSize);
+ if (cimage != null) {
+ cimage.execute(imagePtr -> {
+ execute(ptr -> {
+ setNativeImage(ptr, imagePtr, imageAutoSize);
+ });
});
- });
+ }
}
private native void setNativeImage(final long model, final long nsimage, final boolean autosize);
@@ -357,7 +359,7 @@
class IconObserver implements ImageObserver {
@Override
public boolean imageUpdate(Image image, int flags, int x, int y, int width, int height) {
- if (image != target.getImage()) // if the image has been changed
+ if (target == null || image != target.getImage()) //if the image has been changed
{
return false;
}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java Sat Feb 16 21:15:33 2019 +0100
+++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java Mon Feb 18 10:45:21 2019 +0530
@@ -739,7 +739,8 @@
region == Region.TOOL_BAR_DRAG_WINDOW ||
region == Region.TOOL_TIP ||
region == Region.TREE ||
- region == Region.VIEWPORT) {
+ region == Region.VIEWPORT ||
+ region == Region.TEXT_PANE) {
return true;
}
if (!GTKLookAndFeel.is3()) {
@@ -747,8 +748,7 @@
region == Region.FORMATTED_TEXT_FIELD ||
region == Region.PASSWORD_FIELD ||
region == Region.SPINNER ||
- region == Region.TEXT_FIELD ||
- region == Region.TEXT_PANE) {
+ region == Region.TEXT_FIELD) {
return true;
}
}
@@ -767,6 +767,14 @@
if (classKey != null) {
Object value = getClassSpecificValue(classKey);
if (value != null) {
+ //This is a workaround as the "slider-length" property has been
+ //deprecated for GtkScale from gtk 3.20, so default value of 31
+ //is used and makes redering of slider wrong. Value 14 is being
+ //used as default value for Slider.thumbHeight is 14 and making
+ //width 14 as well makes slider thumb render in proper shape
+ if ("Slider.thumbWidth".equals(key) && value.equals(31)) {
+ return 14;
+ }
return value;
}
}
@@ -779,8 +787,15 @@
return getColorForState(context, ColorType.FOREGROUND);
}
else if (key == "ScrollBar.minimumThumbSize") {
+ //This is a workaround as the "min-slider-length" property has been
+ //deprecated for GtkScrollBar from gtk 3.20, so default value of 21
+ //is used and makes ScrollBar thumb very small. Value 40 is being
+ //used as this is the value mentioned in css files
int len =
getClassSpecificIntValue(context, "min-slider-length", 21);
+ if (len == 21) {
+ len = 40;
+ }
JScrollBar sb = (JScrollBar)context.getComponent();
if (sb.getOrientation() == JScrollBar.HORIZONTAL) {
return new DimensionUIResource(len, 0);
--- a/src/java.desktop/share/classes/java/awt/Font.java Sat Feb 16 21:15:33 2019 +0100
+++ b/src/java.desktop/share/classes/java/awt/Font.java Mon Feb 18 10:45:21 2019 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2019, 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
@@ -495,13 +495,7 @@
private Font2D getFont2D() {
FontManager fm = FontManagerFactory.getInstance();
- if (fm.usingPerAppContextComposites() &&
- font2DHandle != null &&
- font2DHandle.font2D instanceof CompositeFont &&
- ((CompositeFont)(font2DHandle.font2D)).isStdComposite()) {
- return fm.findFont2D(name, style,
- FontManager.LOGICAL_FALLBACK);
- } else if (font2DHandle == null) {
+ if (font2DHandle == null) {
font2DHandle =
fm.findFont2D(name, style,
FontManager.LOGICAL_FALLBACK).handle;
--- a/src/java.desktop/share/classes/sun/awt/AWTSecurityManager.java Sat Feb 16 21:15:33 2019 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 1999, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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.
- */
-
-package sun.awt;
-
-/**
- * The AWTSecurityManager class provides the ability to secondarily
- * index AppContext objects through SecurityManager extensions.
- * As noted in AppContext.java, AppContexts are primarily indexed by
- * ThreadGroup. In the case where the ThreadGroup doesn't provide
- * enough information to determine AppContext (e.g. system threads),
- * if a SecurityManager is installed which derives from
- * AWTSecurityManager, the AWTSecurityManager's getAppContext()
- * method is called to determine the AppContext.
- *
- * A typical example of the use of this class is where an applet
- * is called by a system thread, yet the system AppContext is
- * inappropriate, because applet code is currently executing.
- * In this case, the getAppContext() method can walk the call stack
- * to determine the applet code being executed and return the applet's
- * AppContext object.
- *
- * @author Fred Ecks
- */
-public class AWTSecurityManager extends SecurityManager {
-
- /**
- * Get the AppContext corresponding to the current context.
- * The default implementation returns null, but this method
- * may be overridden by various SecurityManagers
- * (e.g. AppletSecurity) to index AppContext objects by the
- * calling context.
- *
- * @return the AppContext corresponding to the current context.
- * @see sun.awt.AppContext
- * @see java.lang.SecurityManager
- * @since 1.2.1
- */
- public AppContext getAppContext() {
- return null; // Default implementation returns null
- }
-
-} /* class AWTSecurityManager */
--- a/src/java.desktop/share/classes/sun/awt/AppContext.java Sat Feb 16 21:15:33 2019 +0100
+++ b/src/java.desktop/share/classes/sun/awt/AppContext.java Mon Feb 18 10:45:21 2019 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2019, 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
@@ -123,17 +123,6 @@
* therefore safely invoke any of its methods without worry of being
* blocked.
*
- * Note: If a SecurityManager is installed which derives from
- * sun.awt.AWTSecurityManager, it may override the
- * AWTSecurityManager.getAppContext() method to return the proper
- * AppContext based on the execution context, in the case where
- * the default ThreadGroup-based AppContext indexing would return
- * the main "system" AppContext. For example, in an applet situation,
- * if a system thread calls into an applet, rather than returning the
- * main "system" AppContext (the one corresponding to the system thread),
- * an installed AWTSecurityManager may return the applet's AppContext
- * based on the execution context.
- *
* @author Thomas Ball
* @author Fred Ecks
*/
@@ -287,10 +276,7 @@
/**
* Returns the appropriate AppContext for the caller,
- * as determined by its ThreadGroup. If the main "system" AppContext
- * would be returned and there's an AWTSecurityManager installed, it
- * is called to get the proper AppContext based on the execution
- * context.
+ * as determined by its ThreadGroup.
*
* @return the AppContext for the caller.
* @see java.lang.ThreadGroup
@@ -384,18 +370,6 @@
return (ctx != null && ctx == mainAppContext);
}
- private static AppContext getExecutionAppContext() {
- SecurityManager securityManager = System.getSecurityManager();
- if ((securityManager != null) &&
- (securityManager instanceof AWTSecurityManager))
- {
- AWTSecurityManager awtSecMgr = (AWTSecurityManager) securityManager;
- AppContext secAppContext = awtSecMgr.getAppContext();
- return secAppContext; // Return what we're told
- }
- return null;
- }
-
private long DISPOSAL_TIMEOUT = 5000; // Default to 5-second timeout
// for disposal of all Frames
// (we wait for this time twice,
@@ -872,8 +846,7 @@
// context since we don't need it.
if (numAppContexts.get() == 0) return null;
- // Get the context from the security manager
- AppContext ecx = getExecutionAppContext();
+ AppContext ecx = null;
// Not sure we really need to re-check numAppContexts here.
// If all applets have gone away then we could have a
--- a/src/java.desktop/share/classes/sun/font/FontDesignMetrics.java Sat Feb 16 21:15:33 2019 +0100
+++ b/src/java.desktop/share/classes/sun/font/FontDesignMetrics.java Mon Feb 18 10:45:21 2019 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, 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
@@ -25,22 +25,18 @@
package sun.font;
-import java.lang.ref.ReferenceQueue;
-import java.lang.ref.SoftReference;
-
+import java.awt.Font;
import java.awt.FontMetrics;
-import java.awt.Font;
import java.awt.GraphicsEnvironment;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.NoninvertibleTransformException;
-import java.awt.geom.Rectangle2D;
import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
-
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.SoftReference;
import java.util.concurrent.ConcurrentHashMap;
import sun.java2d.Disposer;
@@ -263,7 +259,7 @@
* by this code as they use the metrics of the physical anyway.
*/
SunFontManager fm = SunFontManager.getInstance();
- if (fm.maybeUsingAlternateCompositeFonts() &&
+ if (fm.usingAlternateCompositeFonts() &&
FontUtilities.getFont2D(font) instanceof CompositeFont) {
return new FontDesignMetrics(font, frc);
}
--- a/src/java.desktop/share/classes/sun/font/FontManager.java Sat Feb 16 21:15:33 2019 +0100
+++ b/src/java.desktop/share/classes/sun/font/FontManager.java Mon Feb 18 10:45:21 2019 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, 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
@@ -22,16 +22,12 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
package sun.font;
import java.awt.Font;
import java.awt.FontFormatException;
import java.io.File;
-import java.util.Locale;
-import java.util.TreeMap;
-
-import javax.swing.plaf.FontUIResource;
-
/**
* Interface between Java Fonts (java.awt.Font) and the underlying
@@ -93,13 +89,6 @@
throws FontFormatException;
/**
- * If usingPerAppContextComposites is true, we are in "applet"
- * (eg browser) environment and at least one context has selected
- * an alternate composite font behaviour.
- */
- public boolean usingPerAppContextComposites();
-
- /**
* Creates a derived composite font from the specified font (handle).
*
* @param family the font family of the derived font
--- a/src/java.desktop/share/classes/sun/font/SunFontManager.java Sat Feb 16 21:15:33 2019 +0100
+++ b/src/java.desktop/share/classes/sun/font/SunFontManager.java Mon Feb 18 10:45:21 2019 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2019, 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
@@ -50,7 +50,7 @@
import java.util.concurrent.ConcurrentHashMap;
import javax.swing.plaf.FontUIResource;
-import sun.awt.AppContext;
+
import sun.awt.FontConfiguration;
import sun.awt.SunToolkit;
import sun.awt.util.ThreadGroupUtils;
@@ -256,11 +256,6 @@
return t1Filter;
}
- @Override
- public boolean usingPerAppContextComposites() {
- return _usingPerAppContextComposites;
- }
-
static {
java.security.AccessController.doPrivileged(
@@ -1936,7 +1931,6 @@
public Font2D findFont2D(String name, int style, int fallback) {
String lowerCaseName = name.toLowerCase(Locale.ENGLISH);
String mapName = lowerCaseName + dotStyleStr(style);
- Font2D font;
/* If preferLocaleFonts() or preferProportionalFonts() has been
* called we may be using an alternate set of composite fonts in this
@@ -1944,19 +1938,7 @@
* this is so, and gives access to the alternate composite for the
* name.
*/
- if (_usingPerAppContextComposites) {
- @SuppressWarnings("unchecked")
- ConcurrentHashMap<String, Font2D> altNameCache =
- (ConcurrentHashMap<String, Font2D>)
- AppContext.getAppContext().get(CompositeFont.class);
- if (altNameCache != null) {
- font = altNameCache.get(mapName);
- } else {
- font = null;
- }
- } else {
- font = fontNameCache.get(mapName);
- }
+ Font2D font = fontNameCache.get(mapName);
if (font != null) {
return font;
}
@@ -2161,25 +2143,9 @@
* cache for these.
*/
- if (fontsAreRegistered || fontsAreRegisteredPerAppContext) {
- Hashtable<String, FontFamily> familyTable = null;
- Hashtable<String, Font2D> nameTable;
-
- if (fontsAreRegistered) {
- familyTable = createdByFamilyName;
- nameTable = createdByFullName;
- } else {
- AppContext appContext = AppContext.getAppContext();
- @SuppressWarnings("unchecked")
- Hashtable<String,FontFamily> tmp1 =
- (Hashtable<String,FontFamily>)appContext.get(regFamilyKey);
- familyTable = tmp1;
-
- @SuppressWarnings("unchecked")
- Hashtable<String, Font2D> tmp2 =
- (Hashtable<String,Font2D>)appContext.get(regFullNameKey);
- nameTable = tmp2;
- }
+ if (fontsAreRegistered) {
+ Hashtable<String, FontFamily> familyTable = createdByFamilyName;
+ Hashtable<String, Font2D> nameTable = createdByFullName;
family = familyTable.get(lowerCaseName);
if (family != null) {
@@ -2684,9 +2650,6 @@
* Calling the methods below is "heavyweight" but it is expected that
* these methods will be called very rarely.
*
- * If _usingPerAppContextComposites is true, we are in "applet"
- * (eg browser) environment and at least one context has selected
- * an alternate composite font behaviour.
* If _usingAlternateComposites is true, we are not in an "applet"
* environment and the (single) application has selected
* an alternate composite font behaviour.
@@ -2698,21 +2661,13 @@
* but that may have to wait. The results should be correct, just not
* optimal.
*/
- private static final Object altJAFontKey = new Object();
- private static final Object localeFontKey = new Object();
- private static final Object proportionalFontKey = new Object();
- private boolean _usingPerAppContextComposites = false;
private boolean _usingAlternateComposites = false;
- /* These values are used only if we are running as a standalone
- * application, as determined by maybeMultiAppContext();
- */
private static boolean gAltJAFont = false;
private boolean gLocalePref = false;
private boolean gPropPref = false;
- /* This method doesn't check if alternates are selected in this app
- * context. Its used by the FontMetrics caching code which in such
+ /* Its used by the FontMetrics caching code which in such
* a case cannot retrieve a cached metrics solely on the basis of
* the Font.equals() method since it needs to also check if the Font2D
* is the same.
@@ -2724,26 +2679,8 @@
* logical font definitions we may need to revisit this if GTK reports
* combined metrics instead. For now though this test can be simple.
*/
- public boolean maybeUsingAlternateCompositeFonts() {
- return _usingAlternateComposites || _usingPerAppContextComposites;
- }
-
public boolean usingAlternateCompositeFonts() {
- return (_usingAlternateComposites ||
- (_usingPerAppContextComposites &&
- AppContext.getAppContext().get(CompositeFont.class) != null));
- }
-
- private static boolean maybeMultiAppContext() {
- Boolean appletSM = (Boolean)
- java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction<Object>() {
- public Object run() {
- SecurityManager sm = System.getSecurityManager();
- return sm instanceof sun.awt.AWTSecurityManager;
- }
- });
- return appletSM.booleanValue();
+ return _usingAlternateComposites;
}
/* Modifies the behaviour of a subsequent call to preferLocaleFonts()
@@ -2758,22 +2695,11 @@
if (!FontUtilities.isWindows) {
return;
}
-
- if (!maybeMultiAppContext()) {
- gAltJAFont = true;
- } else {
- AppContext appContext = AppContext.getAppContext();
- appContext.put(altJAFontKey, altJAFontKey);
- }
+ gAltJAFont = true;
}
public boolean usingAlternateFontforJALocales() {
- if (!maybeMultiAppContext()) {
- return gAltJAFont;
- } else {
- AppContext appContext = AppContext.getAppContext();
- return appContext.get(altJAFontKey) == altJAFontKey;
- }
+ return gAltJAFont;
}
public synchronized void preferLocaleFonts() {
@@ -2784,29 +2710,12 @@
if (!FontConfiguration.willReorderForStartupLocale()) {
return;
}
-
- if (!maybeMultiAppContext()) {
- if (gLocalePref == true) {
- return;
- }
- gLocalePref = true;
- createCompositeFonts(fontNameCache, gLocalePref, gPropPref);
- _usingAlternateComposites = true;
- } else {
- AppContext appContext = AppContext.getAppContext();
- if (appContext.get(localeFontKey) == localeFontKey) {
- return;
- }
- appContext.put(localeFontKey, localeFontKey);
- boolean acPropPref =
- appContext.get(proportionalFontKey) == proportionalFontKey;
- ConcurrentHashMap<String, Font2D>
- altNameCache = new ConcurrentHashMap<String, Font2D> ();
- /* If there is an existing hashtable, we can drop it. */
- appContext.put(CompositeFont.class, altNameCache);
- _usingPerAppContextComposites = true;
- createCompositeFonts(altNameCache, true, acPropPref);
+ if (gLocalePref == true) {
+ return;
}
+ gLocalePref = true;
+ createCompositeFonts(fontNameCache, gLocalePref, gPropPref);
+ _usingAlternateComposites = true;
}
public synchronized void preferProportionalFonts() {
@@ -2820,29 +2729,12 @@
if (!FontConfiguration.hasMonoToPropMap()) {
return;
}
-
- if (!maybeMultiAppContext()) {
- if (gPropPref == true) {
- return;
- }
- gPropPref = true;
- createCompositeFonts(fontNameCache, gLocalePref, gPropPref);
- _usingAlternateComposites = true;
- } else {
- AppContext appContext = AppContext.getAppContext();
- if (appContext.get(proportionalFontKey) == proportionalFontKey) {
- return;
- }
- appContext.put(proportionalFontKey, proportionalFontKey);
- boolean acLocalePref =
- appContext.get(localeFontKey) == localeFontKey;
- ConcurrentHashMap<String, Font2D>
- altNameCache = new ConcurrentHashMap<String, Font2D> ();
- /* If there is an existing hashtable, we can drop it. */
- appContext.put(CompositeFont.class, altNameCache);
- _usingPerAppContextComposites = true;
- createCompositeFonts(altNameCache, acLocalePref, true);
+ if (gPropPref == true) {
+ return;
}
+ gPropPref = true;
+ createCompositeFonts(fontNameCache, gLocalePref, gPropPref);
+ _usingAlternateComposites = true;
}
private static HashSet<String> installedNames = null;
@@ -2865,13 +2757,10 @@
return installedNames;
}
- /* Keys are used to lookup per-AppContext Hashtables */
- private static final Object regFamilyKey = new Object();
- private static final Object regFullNameKey = new Object();
+ private static final Object regFamilyLock = new Object();
private Hashtable<String,FontFamily> createdByFamilyName;
private Hashtable<String,Font2D> createdByFullName;
private boolean fontsAreRegistered = false;
- private boolean fontsAreRegisteredPerAppContext = false;
public boolean registerFont(Font font) {
/* This method should not be called with "null".
@@ -2882,7 +2771,7 @@
}
/* Initialise these objects only once we start to use this API */
- synchronized (regFamilyKey) {
+ synchronized (regFamilyLock) {
if (createdByFamilyName == null) {
createdByFamilyName = new Hashtable<String,FontFamily>();
createdByFullName = new Hashtable<String,Font2D>();
@@ -2919,31 +2808,10 @@
}
/* Checks passed, now register the font */
- Hashtable<String,FontFamily> familyTable;
- Hashtable<String,Font2D> fullNameTable;
- if (!maybeMultiAppContext()) {
- familyTable = createdByFamilyName;
- fullNameTable = createdByFullName;
- fontsAreRegistered = true;
- } else {
- AppContext appContext = AppContext.getAppContext();
- @SuppressWarnings("unchecked")
- Hashtable<String,FontFamily> tmp1 =
- (Hashtable<String,FontFamily>)appContext.get(regFamilyKey);
- familyTable = tmp1;
- @SuppressWarnings("unchecked")
- Hashtable<String,Font2D> tmp2 =
- (Hashtable<String,Font2D>)appContext.get(regFullNameKey);
- fullNameTable = tmp2;
-
- if (familyTable == null) {
- familyTable = new Hashtable<String,FontFamily>();
- fullNameTable = new Hashtable<String,Font2D>();
- appContext.put(regFamilyKey, familyTable);
- appContext.put(regFullNameKey, fullNameTable);
- }
- fontsAreRegisteredPerAppContext = true;
- }
+ Hashtable<String, FontFamily> familyTable = createdByFamilyName;
+ Hashtable<String, Font2D> fullNameTable = createdByFullName;
+ fontsAreRegistered = true;
+
/* Create the FontFamily and add font to the tables */
Font2D font2D = FontUtilities.getFont2D(font);
int style = font2D.getStyle();
@@ -2989,12 +2857,6 @@
Hashtable<String,FontFamily> familyTable;
if (fontsAreRegistered) {
familyTable = createdByFamilyName;
- } else if (fontsAreRegisteredPerAppContext) {
- AppContext appContext = AppContext.getAppContext();
- @SuppressWarnings("unchecked")
- Hashtable<String,FontFamily> tmp =
- (Hashtable<String,FontFamily>)appContext.get(regFamilyKey);
- familyTable = tmp;
} else {
return null;
}
@@ -3019,12 +2881,6 @@
Hashtable<String,Font2D> nameTable;
if (fontsAreRegistered) {
nameTable = createdByFullName;
- } else if (fontsAreRegisteredPerAppContext) {
- AppContext appContext = AppContext.getAppContext();
- @SuppressWarnings("unchecked")
- Hashtable<String,Font2D> tmp =
- (Hashtable<String,Font2D>)appContext.get(regFullNameKey);
- nameTable = tmp;
} else {
return null;
}
--- a/src/java.desktop/share/native/liblcms/cmsxform.c Sat Feb 16 21:15:33 2019 +0100
+++ b/src/java.desktop/share/native/liblcms/cmsxform.c Mon Feb 18 10:45:21 2019 +0530
@@ -836,7 +836,7 @@
// Save the day? (Ignore the warning)
if (Plugin->OldXform) {
- p->OldXform = (_cmsTransformFn) p->xform;
+ p->OldXform = (_cmsTransformFn)(void*) p->xform;
p->xform = _cmsTransform2toTransformAdaptor;
}
--- a/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c Sat Feb 16 21:15:33 2019 +0100
+++ b/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c Mon Feb 18 10:45:21 2019 +0530
@@ -258,6 +258,7 @@
static gboolean gtk3_version_3_10 = TRUE;
static gboolean gtk3_version_3_14 = FALSE;
+static gboolean gtk3_version_3_20 = FALSE;
GtkApi* gtk3_load(JNIEnv *env, const char* lib_name)
{
@@ -400,6 +401,18 @@
}
gtk3_version_3_14 = !fp_gtk_check_version(3, 14, 0);
+ if (!fp_gtk_check_version(3, 20, 0)) {
+ gtk3_version_3_20 = TRUE;
+ fp_gtk_widget_path_copy = dl_symbol("gtk_widget_path_copy");
+ fp_gtk_widget_path_new = dl_symbol("gtk_widget_path_new");
+ fp_gtk_widget_path_append_type = dl_symbol("gtk_widget_path_append_type");
+ fp_gtk_widget_path_iter_set_object_name = dl_symbol("gtk_widget_path_iter_set_object_name");
+ fp_gtk_style_context_set_path = dl_symbol("gtk_style_context_set_path");
+ fp_gtk_widget_path_unref = dl_symbol("gtk_widget_path_unref");
+ fp_gtk_style_context_get_path = dl_symbol("gtk_style_context_get_path");
+ fp_gtk_style_context_new = dl_symbol("gtk_style_context_new");
+ }
+
fp_gdk_window_create_similar_surface =
dl_symbol("gdk_window_create_similar_surface");
fp_gtk_settings_get_for_screen =
@@ -561,7 +574,6 @@
"gtk_combo_box_new_with_entry");
fp_gtk_separator_tool_item_new = dlsym(gtk3_libhandle,
"gtk_separator_tool_item_new");
-
fp_g_list_append = dl_symbol("g_list_append");
fp_g_list_free = dl_symbol("g_list_free");
fp_g_list_free_full = dl_symbol("g_list_free_full");
@@ -1362,6 +1374,90 @@
return result;
}
+static void append_element (GtkWidgetPath *path, const gchar *selector)
+{
+ fp_gtk_widget_path_append_type (path, G_TYPE_NONE);
+ fp_gtk_widget_path_iter_set_object_name (path, -1, selector);
+}
+
+static GtkWidgetPath* createWidgetPath(const GtkWidgetPath* path) {
+ if (path == NULL) {
+ return fp_gtk_widget_path_new();
+ } else {
+ return fp_gtk_widget_path_copy(path);
+ }
+}
+
+static GtkStyleContext* get_style(WidgetType widget_type, const gchar *detail)
+{
+ if (!gtk3_version_3_20) {
+ gtk3_widget = gtk3_get_widget(widget_type);
+ GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+ fp_gtk_style_context_save (context);
+ if (detail != 0) {
+ transform_detail_string(detail, context);
+ }
+ return context;
+ } else {
+ gtk3_widget = gtk3_get_widget(widget_type);
+ GtkStyleContext* widget_context = fp_gtk_widget_get_style_context (gtk3_widget);
+ GtkWidgetPath *path = NULL;
+ if (detail != 0) {
+ if (strcmp(detail, "checkbutton") == 0) {
+ path = createWidgetPath (fp_gtk_style_context_get_path (widget_context));
+ append_element(path, "check");
+ } else if (strcmp(detail, "radiobutton") == 0) {
+ path = createWidgetPath (fp_gtk_style_context_get_path (widget_context));
+ append_element(path, "radio");
+ } else if (strcmp(detail, "vscale") == 0 || strcmp(detail, "hscale") == 0) {
+ path = createWidgetPath (fp_gtk_style_context_get_path (widget_context));
+ append_element(path, "slider");
+ } else if (strcmp(detail, "trough") == 0) {
+ //This is a fast solution to the scrollbar trough not being rendered properly
+ if (widget_type == HSCROLL_BAR || widget_type == HSCROLL_BAR_TRACK ||
+ widget_type == VSCROLL_BAR || widget_type == VSCROLL_BAR_TRACK) {
+ path = createWidgetPath (NULL);
+ } else {
+ path = createWidgetPath (fp_gtk_style_context_get_path (widget_context));
+ }
+ append_element(path, detail);
+ } else if (strcmp(detail, "bar") == 0) {
+ path = createWidgetPath (fp_gtk_style_context_get_path (widget_context));
+ append_element(path, "trough");
+ append_element(path, "progress");
+ } else if (strcmp(detail, "vscrollbar") == 0 || strcmp(detail, "hscrollbar") == 0) {
+ path = createWidgetPath (fp_gtk_style_context_get_path (widget_context));
+ append_element(path, "button");
+ } else if (strcmp(detail, "check") == 0) {
+ path = createWidgetPath (NULL);
+ append_element(path, detail);
+ } else if (strcmp(detail, "option") == 0) {
+ path = createWidgetPath (NULL);
+ append_element(path, "radio");
+ } else {
+ path = createWidgetPath (fp_gtk_style_context_get_path (widget_context));
+ append_element(path, detail);
+ }
+ } else {
+ path = createWidgetPath (fp_gtk_style_context_get_path (widget_context));
+ }
+
+ GtkStyleContext *context = fp_gtk_style_context_new ();
+ fp_gtk_style_context_set_path (context, path);
+ fp_gtk_widget_path_unref (path);
+ return context;
+ }
+}
+
+static void disposeOrRestoreContext(GtkStyleContext *context)
+{
+ if (!gtk3_version_3_20) {
+ fp_gtk_style_context_restore (context);
+ } else {
+ fp_g_object_unref (context);
+ }
+}
+
static void gtk3_paint_arrow(WidgetType widget_type, GtkStateType state_type,
GtkShadowType shadow_type, const gchar *detail,
gint x, gint y, gint width, gint height,
@@ -1509,13 +1605,9 @@
*/
gtk3_set_direction(gtk3_widget, dir);
- GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
- fp_gtk_style_context_save (context);
-
- transform_detail_string(detail, context);
+ GtkStyleContext* context = get_style(widget_type, detail);
GtkStateFlags flags = get_gtk_flags(state_type);
-
if (shadow_type == GTK_SHADOW_IN && widget_type != COMBO_BOX_ARROW_BUTTON) {
flags |= GTK_STATE_FLAG_ACTIVE;
}
@@ -1532,23 +1624,31 @@
fp_gtk_style_context_add_class (context, "default");
}
+ if (fp_gtk_style_context_has_class(context, "trough")) {
+ flags |= GTK_STATE_FLAG_BACKDROP;
+ }
+
fp_gtk_style_context_set_state (context, flags);
- if (fp_gtk_style_context_has_class(context, "progressbar")) {
- fp_gtk_render_activity (context, cr, x, y, width, height);
- } else {
- fp_gtk_render_background (context, cr, x, y, width, height);
- if (shadow_type != GTK_SHADOW_NONE) {
- fp_gtk_render_frame(context, cr, x, y, width, height);
- }
+ fp_gtk_render_background (context, cr, x, y, width, height);
+ if (shadow_type != GTK_SHADOW_NONE) {
+ fp_gtk_render_frame(context, cr, x, y, width, height);
}
- fp_gtk_style_context_restore (context);
+ disposeOrRestoreContext(context);
+
/*
* Reset the text direction to the default value so that we don't
* accidentally affect other operations and widgets.
*/
gtk3_set_direction(gtk3_widget, GTK_TEXT_DIR_LTR);
+
+ //This is a fast solution to the scrollbar trough not being rendered properly
+ if ((widget_type == HSCROLL_BAR || widget_type == HSCROLL_BAR_TRACK ||
+ widget_type == VSCROLL_BAR || widget_type == VSCROLL_BAR_TRACK) && detail != 0) {
+ gtk3_paint_box(widget_type, state_type, shadow_type, NULL,
+ x, y, width, height, synth_state, dir);
+ }
}
static void gtk3_paint_box_gap(WidgetType widget_type, GtkStateType state_type,
@@ -1580,23 +1680,19 @@
static void gtk3_paint_check(WidgetType widget_type, gint synth_state,
const gchar *detail, gint x, gint y, gint width, gint height)
{
- gtk3_widget = gtk3_get_widget(widget_type);
-
- GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
-
- fp_gtk_style_context_save (context);
+ GtkStyleContext* context = get_style(widget_type, detail);
GtkStateFlags flags = get_gtk_state_flags(synth_state);
if (gtk3_version_3_14 && (synth_state & SELECTED)) {
- flags = GTK_STATE_FLAG_CHECKED;
+ flags &= ~GTK_STATE_FLAG_SELECTED;
+ flags |= GTK_STATE_FLAG_CHECKED;
}
fp_gtk_style_context_set_state(context, flags);
- fp_gtk_style_context_add_class (context, "check");
-
- fp_gtk_render_check (context, cr, x, y, width, height);
-
- fp_gtk_style_context_restore (context);
+ fp_gtk_render_background(context, cr, x, y, width, height);
+ fp_gtk_render_frame(context, cr, x, y, width, height);
+ fp_gtk_render_check(context, cr, x, y, width, height);
+ disposeOrRestoreContext(context);
}
@@ -1684,7 +1780,6 @@
gtk3_widget = gtk3_get_widget(widget_type);
GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
-
fp_gtk_style_context_save (context);
if (detail != 0) {
@@ -1787,25 +1882,19 @@
static void gtk3_paint_option(WidgetType widget_type, gint synth_state,
const gchar *detail, gint x, gint y, gint width, gint height)
{
- gtk3_widget = gtk3_get_widget(widget_type);
-
- GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
-
- fp_gtk_style_context_save (context);
+ GtkStyleContext* context = get_style(widget_type, detail);
GtkStateFlags flags = get_gtk_state_flags(synth_state);
if (gtk3_version_3_14 && (synth_state & SELECTED)) {
- flags = GTK_STATE_FLAG_CHECKED;
+ flags &= ~GTK_STATE_FLAG_SELECTED;
+ flags |= GTK_STATE_FLAG_CHECKED;
}
fp_gtk_style_context_set_state(context, flags);
- if (detail != 0) {
- transform_detail_string(detail, context);
- }
-
+ fp_gtk_render_background(context, cr, x, y, width, height);
+ fp_gtk_render_frame(context, cr, x, y, width, height);
fp_gtk_render_option(context, cr, x, y, width, height);
-
- fp_gtk_style_context_restore (context);
+ disposeOrRestoreContext(context);
}
static void gtk3_paint_shadow(WidgetType widget_type, GtkStateType state_type,
@@ -1864,15 +1953,7 @@
gint x, gint y, gint width, gint height, GtkOrientation orientation,
gboolean has_focus)
{
- gtk3_widget = gtk3_get_widget(widget_type);
-
- GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
-
- fp_gtk_style_context_save (context);
-
- if (detail) {
- transform_detail_string(detail, context);
- }
+ GtkStyleContext *context = get_style(widget_type, detail);
GtkStateFlags flags = get_gtk_flags(state_type);
@@ -1886,9 +1967,10 @@
fp_gtk_style_context_set_state (context, flags);
+ fp_gtk_render_background (context, cr, x, y, width, height);
+ fp_gtk_render_frame(context, cr, x, y, width, height);
(*fp_gtk_render_slider)(context, cr, x, y, width, height, orientation);
-
- fp_gtk_style_context_restore (context);
+ disposeOrRestoreContext(context);
}
static void gtk3_paint_background(WidgetType widget_type,
@@ -2278,6 +2360,11 @@
init_containers();
+ if (widget_type == TEXT_FIELD && state_type == GTK_STATE_SELECTED &&
+ color_type == TEXT_BACKGROUND) {
+ widget_type = TEXT_AREA;
+ }
+
gtk3_widget = gtk3_get_widget(widget_type);
GtkStyleContext* context = fp_gtk_widget_get_style_context(gtk3_widget);
--- a/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.h Sat Feb 16 21:15:33 2019 +0100
+++ b/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.h Mon Feb 18 10:45:21 2019 +0530
@@ -162,6 +162,7 @@
typedef void GtkRange;
typedef void GtkProgressBar;
typedef void GtkProgress;
+typedef void GtkWidgetPath;
/* Some real structures */
typedef struct
@@ -238,7 +239,6 @@
GType owner_type;
} GParamSpec;
-
static gchar* (*fp_glib_check_version)(guint required_major,
guint required_minor, guint required_micro);
@@ -573,5 +573,18 @@
static void (*fp_gtk_widget_size_request)(GtkWidget *widget,
GtkRequisition *requisition);
static GtkAdjustment* (*fp_gtk_range_get_adjustment)(GtkRange* range);
+static GtkWidgetPath* (*fp_gtk_widget_path_copy)
+ (const GtkWidgetPath *path);
+static const GtkWidgetPath* (*fp_gtk_style_context_get_path)
+ (GtkStyleContext *context);
+static GtkWidgetPath* (*fp_gtk_widget_path_new) (void);
+static gint (*fp_gtk_widget_path_append_type)
+ (GtkWidgetPath *path, GType type);
+static void (*fp_gtk_widget_path_iter_set_object_name)
+ (GtkWidgetPath *path, gint pos, const char *name);
+static void (*fp_gtk_style_context_set_path)
+ (GtkStyleContext *context, GtkWidgetPath *path);
+static void (*fp_gtk_widget_path_unref) (GtkWidgetPath *path);
+static GtkStyleContext* (*fp_gtk_style_context_new) (void);
#endif /* !_GTK3_INTERFACE_H */
--- a/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java Sat Feb 16 21:15:33 2019 +0100
+++ b/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java Mon Feb 18 10:45:21 2019 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, 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
@@ -65,6 +65,7 @@
private Locale currentLocale;
// indicate whether status window is hidden or not.
private boolean statusWindowHidden = false;
+ private boolean hasCompositionString = false;
// attribute definition in Win32 (in IMM.H)
public static final byte ATTR_INPUT = 0x00;
@@ -246,6 +247,7 @@
} else if (locale.getLanguage().equals(Locale.KOREAN.getLanguage())) {
if (subset1 == UnicodeBlock.BASIC_LATIN || subset1 == InputSubset.LATIN_DIGITS) {
setOpenStatus(context, false);
+ setConversionStatus(context, IME_CMODE_ALPHANUMERIC);
} else {
if (subset1 == UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
|| subset1 == InputSubset.HANJA
@@ -263,11 +265,14 @@
} else if (locale.getLanguage().equals(Locale.CHINESE.getLanguage())) {
if (subset1 == UnicodeBlock.BASIC_LATIN || subset1 == InputSubset.LATIN_DIGITS) {
setOpenStatus(context, false);
+ newmode = getConversionStatus(context);
+ newmode &= ~IME_CMODE_FULLSHAPE;
+ setConversionStatus(context, newmode);
} else {
if (subset1 == UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
|| subset1 == InputSubset.TRADITIONAL_HANZI
|| subset1 == InputSubset.SIMPLIFIED_HANZI)
- newmode = IME_CMODE_NATIVE;
+ newmode = IME_CMODE_NATIVE | IME_CMODE_FULLSHAPE;
else if (subset1 == InputSubset.FULLWIDTH_LATIN)
newmode = IME_CMODE_FULLSHAPE;
else
@@ -318,6 +323,15 @@
setLocale(currentLocale, true);
}
+ // Compare IM's composition string with Java's composition string
+ if (hasCompositionString && !isCompositionStringAvailable(context)) {
+ endCompositionNative(context, DISCARD_INPUT);
+ sendInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
+ EventQueue.getMostRecentEventTime(),
+ null, null, null, null, null, 0, 0, 0);
+ hasCompositionString = false;
+ }
+
/* If the status window or Windows language bar is turned off due to
native input method was switched to java input method, we
have to turn it on otherwise it is gone for good until next time
@@ -345,6 +359,7 @@
isLastFocussedActiveClient = haveActiveClient();
}
isActive = false;
+ hasCompositionString = isCompositionStringAvailable(context);
}
/**
@@ -649,4 +664,5 @@
static native Locale getNativeLocale();
static native boolean setNativeLocale(String localeName, boolean onActivate);
private native void openCandidateWindow(WComponentPeer peer, int x, int y);
+ private native boolean isCompositionStringAvailable(int context);
}
--- a/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp Sat Feb 16 21:15:33 2019 +0100
+++ b/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp Mon Feb 18 10:45:21 2019 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2019, 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
@@ -3869,6 +3869,11 @@
return;
}
COMPOSITIONFORM cf = {CFS_DEFAULT, {0, 0}, {0, 0, 0, 0}};
+ LOGFONT lf;
+ HFONT hFont = (HFONT) GetStockObject(DEFAULT_GUI_FONT);
+ if (GetObject(hFont, sizeof(lf), (LPVOID)&lf) == sizeof(lf)) {
+ ImmSetCompositionFont(hIMC, &lf);
+ }
ImmSetCompositionWindow(hIMC, &cf);
ImmReleaseContext(hwnd, hIMC);
}
--- a/src/java.desktop/windows/native/libawt/windows/awt_InputMethod.cpp Sat Feb 16 21:15:33 2019 +0100
+++ b/src/java.desktop/windows/native/libawt/windows/awt_InputMethod.cpp Mon Feb 18 10:45:21 2019 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, 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
@@ -528,6 +528,23 @@
CATCH_BAD_ALLOC_RET(NULL);
}
+/*
+ * Class: sun_awt_windows_WInputMethod
+ * Method: isCompositionStringAvailable
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_sun_awt_windows_WInputMethod_isCompositionStringAvailable
+ (JNIEnv *env, jobject self, jint context)
+{
+ LONG length;
+ length = ImmGetCompositionString((HIMC)IntToPtr(context), GCS_COMPSTR, NULL, 0);
+ if (length > 0) {
+ return JNI_TRUE;
+ } else {
+ return JNI_FALSE;
+ }
+}
+
/**
* Class: sun_awt_windows_WInputMethod
* Method: getNativeIMMDescription
--- a/test/jdk/ProblemList.txt Sat Feb 16 21:15:33 2019 +0100
+++ b/test/jdk/ProblemList.txt Mon Feb 18 10:45:21 2019 +0530
@@ -114,8 +114,6 @@
# jdk_awt
-java/awt/BasicStroke/DashScaleMinWidth.java 8198411 windows-all
-java/awt/BasicStroke/DashZeroWidth.java 8198411 windows-all
java/awt/event/MouseEvent/MouseClickTest/MouseClickTest.html 8168389 windows-all,macosx-all
java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowBlockingTest.java 8168408 windows-all,macosx-all
java/awt/Focus/FocusOwnerFrameOnClick/FocusOwnerFrameOnClick.java 8081489 generic-all
--- a/test/jdk/TEST.groups Sat Feb 16 21:15:33 2019 +0100
+++ b/test/jdk/TEST.groups Mon Feb 18 10:45:21 2019 +0530
@@ -375,7 +375,8 @@
:jdk_swing \
:jdk_sound \
:jdk_imageio \
- :jfc_demo
+ :jfc_demo \
+ :jdk_client_sanity
# SwingSet3 tests.
jdk_client_sanity = \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/BasicStroke/DashOffset.java Mon Feb 18 10:45:21 2019 +0530
@@ -0,0 +1,241 @@
+/*
+ * Copyright (c) 2001, 2019, 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.BasicStroke;
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsEnvironment;
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import java.awt.image.IndexColorModel;
+import java.awt.image.VolatileImage;
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.stream.Collectors;
+import javax.imageio.ImageIO;
+
+import static java.awt.image.BufferedImage.TYPE_INT_RGB;
+
+/*
+ * @test
+ * @bug 4469881 8217263 8218682
+ * @key headful
+ * @summary Verifies that dashed rectangles drawn to the screen line
+ * up with their undashed counterparts
+ * @author flar
+ * @run main/othervm -Dsun.java2d.uiScale=1 DashOffset
+ */
+public class DashOffset {
+
+ private static final BasicStroke dash =
+ new BasicStroke(1.0f, BasicStroke.CAP_BUTT,
+ BasicStroke.JOIN_MITER, 10.0f,
+ new float[] {2.0f, 2.0f}, 0.0f);
+
+ private static final Color COLOR1 = Color.BLUE;
+ private static final Color COLOR2 = Color.GREEN;
+
+ private static final Color BACKGROUND = Color.WHITE;
+
+ private static final int WIDTH = 20;
+ private static final int HEIGHT = 20;
+
+ private static final int OFFSET = 2;
+
+ private static final int MAX_DASH_LENGTH = 3;
+
+ public static void main(String[] argv) throws Exception {
+ final boolean saveImage = argv.length > 0 && "-save".equals(argv[0]);
+
+ final BufferedImage img = new BufferedImage(WIDTH, HEIGHT,
+ TYPE_INT_RGB);
+ try {
+ draw(img);
+ validate(img);
+ } finally {
+ if (saveImage) {
+ save(img, "bufferedImage.png");
+ }
+ }
+
+ BufferedImage snapshot = null;
+ try {
+ final GraphicsConfiguration gc =
+ GraphicsEnvironment.getLocalGraphicsEnvironment()
+ .getDefaultScreenDevice()
+ .getDefaultConfiguration();
+ if (gc.getColorModel() instanceof IndexColorModel) {
+ System.err.println("Skipping VolatileImage because of IndexColorModel");
+ return;
+ }
+
+ VolatileImage vi = gc.createCompatibleVolatileImage(WIDTH, HEIGHT);
+ int attempt = 0;
+ do {
+ vi.validate(gc);
+ draw(vi);
+ snapshot = vi.getSnapshot();
+ } while (vi.contentsLost() && ++attempt <= 10);
+ if (attempt > 10) {
+ throw new RuntimeException("Too many attempts: " + attempt);
+ }
+ validate(snapshot);
+ } finally {
+ if (saveImage && snapshot != null) {
+ save(snapshot, "volatileImage.png");
+ }
+ }
+ }
+
+ private static void draw(final Image img) {
+ Graphics g = img.getGraphics();
+ g.setColor(BACKGROUND);
+ g.fillRect(0, 0, WIDTH, HEIGHT);
+ g.setColor(COLOR1);
+ g.drawRect(OFFSET, OFFSET, WIDTH - OFFSET * 2, HEIGHT - OFFSET * 2);
+ g.setColor(COLOR2);
+ g.clipRect(OFFSET, OFFSET, WIDTH - OFFSET * 2 + 1, HEIGHT - OFFSET * 2 + 1);
+ ((Graphics2D) g).setStroke(dash);
+ g.drawRect(OFFSET, OFFSET, WIDTH - OFFSET * 2, HEIGHT - OFFSET * 2);
+ g.dispose();
+ }
+
+ private static void validate(final BufferedImage img) {
+ checkHorizontalLine(img, OFFSET);
+ checkHorizontalLine(img, HEIGHT - OFFSET);
+ checkVerticalLine(img, OFFSET);
+ checkVerticalLine(img, WIDTH - OFFSET);
+ checkCorners(img);
+ }
+
+ private static void checkHorizontalLine(final BufferedImage img,
+ final int y) {
+ int prev = img.getRGB(OFFSET, y);
+ int curr;
+ int count = 1;
+ checkColor(OFFSET, y, prev, COLOR1, COLOR2);
+ for (int x = OFFSET + 1; x <= WIDTH - OFFSET; x++) {
+ curr = img.getRGB(x, y);
+ if (curr != prev) {
+ checkColor(x, y, curr, COLOR1, COLOR2);
+ checkCount(x, y, count);
+ prev = curr;
+ count = 1;
+ } else {
+ count++;
+ }
+ if (x < WIDTH - OFFSET) {
+ checkColor(x, y - 1, img.getRGB(x, y - 1), BACKGROUND);
+ checkColor(x, y + 1, img.getRGB(x, y + 1), BACKGROUND);
+ }
+ }
+ checkCount(WIDTH - OFFSET, y, count);
+ }
+
+ private static void checkVerticalLine(final BufferedImage img,
+ final int x) {
+ int prev = img.getRGB(x, OFFSET);
+ checkColor(x, OFFSET, prev, COLOR1, COLOR2);
+ int count = 1;
+ for (int y = OFFSET + 1; y <= HEIGHT - OFFSET; y++) {
+ int curr = img.getRGB(x, y);
+ if (curr != prev) {
+ checkColor(x, y, curr, COLOR1, COLOR2);
+ checkCount(x, y, count);
+ prev = curr;
+ count = 1;
+ } else {
+ count++;
+ }
+ if (y < HEIGHT - OFFSET) {
+ checkColor(x - 1, y, img.getRGB(x - 1, y), BACKGROUND);
+ checkColor(x + 1, y, img.getRGB(x + 1, y), BACKGROUND);
+ }
+ }
+ checkCount(x, HEIGHT - OFFSET, count);
+ }
+
+ private static void checkCorners(final BufferedImage img) {
+ int[][] corners = {
+ {OFFSET - 1, OFFSET - 1},
+ {OFFSET, OFFSET - 1},
+ {OFFSET - 1, OFFSET + 1},
+
+ {OFFSET - 1, HEIGHT - OFFSET},
+ {OFFSET - 1, HEIGHT - OFFSET + 1},
+ {OFFSET, HEIGHT - OFFSET + 1},
+
+ {WIDTH - OFFSET, OFFSET - 1},
+ {WIDTH - OFFSET + 1, OFFSET - 1},
+ {WIDTH - OFFSET + 1, OFFSET},
+
+ {WIDTH - OFFSET + 1, HEIGHT - OFFSET},
+ {WIDTH - OFFSET + 1, HEIGHT - OFFSET + 1},
+ {WIDTH - OFFSET, HEIGHT - OFFSET + 1},
+ };
+
+ for (int[] corner : corners) {
+ int color = img.getRGB(corner[0], corner[1]);
+ checkColor(corner[0], corner[1], color, BACKGROUND);
+ }
+ }
+
+ private static void checkColor(final int x, final int y,
+ final int color,
+ final Color... validColors) {
+ checkColor(x, y, color, Arrays.stream(validColors)
+ .mapToInt(Color::getRGB)
+ .toArray());
+ }
+
+ private static void checkColor(final int x, final int y,
+ final int color,
+ final int... validColors) {
+ for (int valid : validColors) {
+ if (color == valid) {
+ return;
+ }
+ }
+ throw new RuntimeException("Unexpected color at " + x + ", " + y
+ + ": " + Integer.toHexString(color) + "; expected: "
+ + Arrays.stream(validColors)
+ .mapToObj(Integer::toHexString)
+ .collect(Collectors.joining(", ")));
+ }
+
+ private static void checkCount(final int x, final int y, final int count) {
+ if (count > MAX_DASH_LENGTH) {
+ throw new RuntimeException("Dash is longer than " + MAX_DASH_LENGTH
+ + " at " + x + ", " + y);
+ }
+ }
+
+ private static void save(final BufferedImage img,
+ final String fileName) throws IOException {
+ ImageIO.write(img, "png", new File(fileName));
+ }
+
+}
--- a/test/jdk/java/awt/BasicStroke/DashScaleMinWidth.java Sat Feb 16 21:15:33 2019 +0100
+++ b/test/jdk/java/awt/BasicStroke/DashScaleMinWidth.java Mon Feb 18 10:45:21 2019 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, 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
@@ -29,13 +29,15 @@
import java.awt.Image;
import java.awt.geom.Line2D;
import java.awt.image.BufferedImage;
+import java.awt.image.IndexColorModel;
import java.awt.image.VolatileImage;
import static java.awt.image.BufferedImage.TYPE_INT_ARGB;
/**
* @test
- * @bug 4917097 8019816
+ * @bug 4917097 8019816 8198411
+ * @key headful
* @summary 1.4.1 REGRESSION: BasicStroke Dashes don't show when scale * line width = 1.0
* @run main/othervm -Dsun.java2d.uiScale=1 DashScaleMinWidth
*/
@@ -46,13 +48,13 @@
draw(img);
validate(img);
- if (GraphicsEnvironment.isHeadless()) {
- return;
- }
-
GraphicsConfiguration gc =
GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice().getDefaultConfiguration();
+ if (gc.getColorModel() instanceof IndexColorModel) {
+ System.err.println("Skipping VolatileImage because of IndexColorModel");
+ return;
+ }
VolatileImage vi = gc.createCompatibleVolatileImage(200, 40);
BufferedImage snapshot;
--- a/test/jdk/java/awt/BasicStroke/DashZeroWidth.java Sat Feb 16 21:15:33 2019 +0100
+++ b/test/jdk/java/awt/BasicStroke/DashZeroWidth.java Mon Feb 18 10:45:21 2019 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, 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
@@ -29,13 +29,15 @@
import java.awt.Image;
import java.awt.geom.Line2D;
import java.awt.image.BufferedImage;
+import java.awt.image.IndexColorModel;
import java.awt.image.VolatileImage;
import static java.awt.image.BufferedImage.TYPE_INT_ARGB;
/**
* @test
- * @bug 4779211 8019816
+ * @bug 4779211 8019816 8198411
+ * @key headful
* @summary REGRESSION: 1.4 Dashed lines disappear if BasicStroke width=0.0
* @run main/othervm -Dsun.java2d.uiScale=1 DashZeroWidth
*/
@@ -46,13 +48,13 @@
draw(img);
validate(img);
- if (GraphicsEnvironment.isHeadless()) {
- return;
- }
-
GraphicsConfiguration gc =
GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice().getDefaultConfiguration();
+ if (gc.getColorModel() instanceof IndexColorModel) {
+ System.err.println("Skipping VolatileImage because of IndexColorModel");
+ return;
+ }
VolatileImage vi = gc.createCompatibleVolatileImage(200, 40);
BufferedImage snapshot;