--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFDeflateDecompressor.java Thu Sep 01 08:59:47 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFDeflateDecompressor.java Fri Sep 02 21:42:27 2016 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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
@@ -101,13 +101,17 @@
if (predictor ==
BaselineTIFFTagSet.PREDICTOR_HORIZONTAL_DIFFERENCING) {
+ int step = planar || samplesPerPixel == 1 ? 1 : samplesPerPixel;
+ int samplesPerRow = step * srcWidth;
+ int off = bufOffset + step;
for (int j = 0; j < srcHeight; j++) {
- int count = bufOffset + samplesPerPixel * (j * srcWidth + 1);
- for (int i=samplesPerPixel; i<srcWidth*samplesPerPixel; i++) {
- buf[count] += buf[count - samplesPerPixel];
+ int count = off;
+ for (int i = step; i < samplesPerRow; i++) {
+ buf[count] += buf[count - step];
count++;
}
+ off += samplesPerRow;
}
}
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFLZWDecompressor.java Thu Sep 01 08:59:47 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFLZWDecompressor.java Fri Sep 02 21:42:27 2016 +0000
@@ -162,16 +162,18 @@
if (predictor ==
BaselineTIFFTagSet.PREDICTOR_HORIZONTAL_DIFFERENCING) {
+ int step = planar || samplesPerPixel == 1 ? 1 : samplesPerPixel;
- for (int j = 0; j < srcHeight; j++) {
+ int samplesPerRow = step * srcWidth;
- int count = dstOffset + samplesPerPixel * (j * srcWidth + 1);
-
- for (int i = samplesPerPixel; i < srcWidth * samplesPerPixel; i++) {
-
- dstData[count] += dstData[count - samplesPerPixel];
+ int off = dstOffset + step;
+ for (int j = 0; j < srcHeight; j++) {
+ int count = off;
+ for (int i = step; i < samplesPerRow; i++) {
+ dstData[count] += dstData[count - step];
count++;
}
+ off += samplesPerRow;
}
}
--- a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java Thu Sep 01 08:59:47 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java Fri Sep 02 21:42:27 2016 +0000
@@ -208,7 +208,7 @@
/**
* Returns whether dynamic layout of Containers on resize is currently
- * enabled on the underlying operating system and/or window manager). If the
+ * enabled on the underlying operating system and/or window manager. If the
* platform supports it, {@code setDynamicLayout(boolean)} may be used to
* programmatically enable or disable platform dynamic layout. Regardless of
* whether that toggling is supported, or whether {@code true} or {@code
--- a/jdk/src/java.desktop/share/classes/javax/swing/SortingFocusTraversalPolicy.java Thu Sep 01 08:59:47 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/SortingFocusTraversalPolicy.java Fri Sep 02 21:42:27 2016 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, 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
@@ -26,15 +26,11 @@
import java.awt.Component;
import java.awt.Container;
-import java.awt.Window;
import java.util.*;
import java.awt.FocusTraversalPolicy;
import sun.util.logging.PlatformLogger;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import sun.security.action.GetPropertyAction;
import java.security.AccessController;
-import java.security.PrivilegedAction;
/**
* A FocusTraversalPolicy that determines traversal order by sorting the
@@ -100,27 +96,10 @@
* See: JDK-8048887
*/
private static final boolean legacySortingFTPEnabled;
- private static final Method legacyMergeSortMethod;
static {
legacySortingFTPEnabled = "true".equals(AccessController.doPrivileged(
new GetPropertyAction("swing.legacySortingFTPEnabled", "true")));
- legacyMergeSortMethod = legacySortingFTPEnabled ?
- AccessController.doPrivileged(new PrivilegedAction<Method>() {
- public Method run() {
- try {
- Method m = java.util.Arrays.class.getDeclaredMethod("legacyMergeSort",
- new Class<?>[]{Object[].class,
- Comparator.class});
- m.setAccessible(true);
- return m;
- } catch (NoSuchMethodException e) {
- // using default sorting algo
- return null;
- }
- }
- }) :
- null;
}
/**
@@ -169,30 +148,25 @@
private void enumerateAndSortCycle(Container focusCycleRoot, List<Component> cycle) {
if (focusCycleRoot.isShowing()) {
enumerateCycle(focusCycleRoot, cycle);
- if (!legacySortingFTPEnabled ||
- !legacySort(cycle, comparator))
- {
- Collections.sort(cycle, comparator);
+ if (legacySortingFTPEnabled) {
+ legacySort(cycle, comparator);
+ } else {
+ cycle.sort(comparator);
}
}
}
- private boolean legacySort(List<Component> l, Comparator<? super Component> c) {
- if (legacyMergeSortMethod == null)
- return false;
-
- Object[] a = l.toArray();
- try {
- legacyMergeSortMethod.invoke(null, a, c);
- } catch (IllegalAccessException | InvocationTargetException e) {
- return false;
+ private void legacySort(List<Component> l,
+ Comparator<? super Component> c) {
+ if (c != null && l.size() > 1) {
+ Component[] a = l.toArray(new Component[l.size()]);
+ mergeSort(a.clone(), a, 0, a.length, 0, c);
+ ListIterator<Component> i = l.listIterator();
+ for (Component e : a) {
+ i.next();
+ i.set(e);
+ }
}
- ListIterator<Component> i = l.listIterator();
- for (Object e : a) {
- i.next();
- i.set((Component)e);
- }
- return true;
}
@SuppressWarnings("deprecation")
@@ -665,6 +639,48 @@
protected boolean accept(Component aComponent) {
return fitnessTestPolicy.accept(aComponent);
}
+
+ // merge sort implementation copied from java.utils.Arrays
+ private <T> void mergeSort(T[] src, T[] dest,
+ int low, int high, int off,
+ Comparator<? super T> c) {
+ int length = high - low;
+
+ // Insertion sort on smallest arrays
+ if (length < 7) {
+ for (int i=low; i<high; i++)
+ for (int j=i; j>low && c.compare(dest[j-1], dest[j])>0; j--) {
+ T t = dest[j];
+ dest[j] = dest[j-1];
+ dest[j-1] = t;
+ }
+ return;
+ }
+
+ // Recursively sort halves of dest into src
+ int destLow = low;
+ int destHigh = high;
+ low += off;
+ high += off;
+ int mid = (low + high) >>> 1;
+ mergeSort(dest, src, low, mid, -off, c);
+ mergeSort(dest, src, mid, high, -off, c);
+
+ // If list is already sorted, just copy from src to dest. This is an
+ // optimization that results in faster sorts for nearly ordered lists.
+ if (c.compare(src[mid-1], src[mid]) <= 0) {
+ System.arraycopy(src, low, dest, destLow, length);
+ return;
+ }
+
+ // Merge sorted halves (now in src) into dest
+ for(int i = destLow, p = low, q = mid; i < destHigh; i++) {
+ if (q >= high || p < mid && c.compare(src[p], src[q]) <= 0)
+ dest[i] = src[p++];
+ else
+ dest[i] = src[q++];
+ }
+ }
}
// Create our own subclass and change accept to public so that we can call
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java Thu Sep 01 08:59:47 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java Fri Sep 02 21:42:27 2016 +0000
@@ -1570,6 +1570,10 @@
Integer.valueOf(getMultiClickTime()));
desktopProperties.put("awt.mouse.numButtons",
Integer.valueOf(getNumberOfButtons()));
+ if(SunGraphicsEnvironment.isUIScaleEnabled()) {
+ addPropertyChangeListener("gnome.Xft/DPI", evt ->
+ localEnv.displayChanged());
+ }
}
}
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java Thu Sep 01 08:59:47 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java Fri Sep 02 21:42:27 2016 +0000
@@ -63,7 +63,7 @@
private SunDisplayChanger topLevels = new SunDisplayChanger();
private DisplayMode origDisplayMode;
private boolean shutdownHookRegistered;
- private final int scale;
+ private int scale;
public X11GraphicsDevice(int screennum) {
this.screen = screennum;
@@ -488,6 +488,7 @@
* X11GraphicsEnvironment when the display mode has been changed.
*/
public synchronized void displayChanged() {
+ scale = initScaleFactor();
// On X11 the visuals do not change, and therefore we don't need
// to reset the defaultConfig, config, doubleBufferVisuals,
// neither do we need to reset the native data.
--- a/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.c Thu Sep 01 08:59:47 2016 -0700
+++ b/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.c Fri Sep 02 21:42:27 2016 +0000
@@ -148,7 +148,7 @@
void *scale = fp_g_variant_get_child_value(entry, 1);
if (screen && scale) {
char *name = fp_g_variant_get_string(screen, NULL);
- if (name && strcmp(name, output_name)) {
+ if (name && !strcmp(name, output_name)) {
result = fp_g_variant_get_int32(scale) / 8.;
}
fp_g_variant_unref(screen);
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c Thu Sep 01 08:59:47 2016 -0700
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c Fri Sep 02 21:42:27 2016 +0000
@@ -2181,7 +2181,8 @@
JNIEXPORT jdouble JNICALL
Java_sun_awt_X11GraphicsDevice_getNativeScaleFactor
(JNIEnv *env, jobject this, jint screen) {
- char *name = get_output_screen_name(env, screen);
+ // in case of Xinerama individual screen scales are not supported
+ char *name = get_output_screen_name(env, usingXinerama ? 0 : screen);
double scale = getNativeScaleFactor(name);
if (name) {
free(name);
--- a/jdk/test/java/awt/Focus/SortingFPT/JDK8048887.java Thu Sep 01 08:59:47 2016 -0700
+++ b/jdk/test/java/awt/Focus/SortingFPT/JDK8048887.java Fri Sep 02 21:42:27 2016 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -23,7 +23,7 @@
/*
@test
- @bug 8048887
+ @bug 8048887 8164937
@summary Tests SortingFTP for an exception caused by the tim-sort algo.
@author anton.tarasov: area=awt.focus
@run main JDK8048887