> On 25-Mar-2020, at 5:22 AM, Sergey Bylokhov <[email protected]>
> wrote:
>
> On 3/23/20 10:04 pm, Prasanta Sadhukhan wrote:
>> On 24-Mar-20 10:17 AM, Sergey Bylokhov wrote:
>>> On 3/23/20 9:36 pm, Prasanta Sadhukhan wrote:
>>>> I did not get this point. "apple.awt.brushMetalLook" and "window.style"
>>>> both set TEXTURED property of NSWindow so it's gradient should be the
>>>> same, no?
>>>>
>>>> So, at what time do you think they will not be same?
>>>
>>> It seems every time the window becomes visible the background gradient
>>> draws slightly differently(it is drawn by the macOS, not java). It fails
>>> even if the "apple.awt.brushMetalLook" used twice.
>>>
>> There's a 2 sec gap between window being visible and image is captured by
>> robot, so if it is momentary macos draw problem, it should not have been
>> there as we wait long enough after the window is visible. If it's permanent
>> macos draw problem, then do we need to file a bug to apple?
>
> I am not sure this is a bug, it looks like the gradient is generated on the
> fly,
> and it is different every time. But it will be helpful to compare the diff
> pixel by pixel.
>
>
It seems there is a difference of 1 in all the color components
x 0 y 1 img1.getRGB(x,y) ff9e9e9e img2.getRGB(x,y) ff9f9f9f
x 0 y 2 img1.getRGB(x,y) ffa2a2a2 img2.getRGB(x,y) ffa1a1a1
x 1 y 0 img1.getRGB(x,y) fff8f8f8 img2.getRGB(x,y) fff7f7f7
x 1 y 1 img1.getRGB(x,y) ff9d9d9d img2.getRGB(x,y) ff9e9e9e
x 2 y 0 img1.getRGB(x,y) fff7f7f7 img2.getRGB(x,y) fff6f6f6
x 2 y 1 img1.getRGB(x,y) ff9d9d9d img2.getRGB(x,y) ff9e9e9e
x 2 y 3 img1.getRGB(x,y) ffdadada img2.getRGB(x,y) ffd9d9d9
x 3 y 0 img1.getRGB(x,y) fff5f5f5 img2.getRGB(x,y) fff6f6f6
x 3 y 3 img1.getRGB(x,y) ffd9d9d9 img2.getRGB(x,y) ffdadada
x 4 y 2 img1.getRGB(x,y) ffa1a1a1 img2.getRGB(x,y) ff9f9f9f
x 5 y 0 img1.getRGB(x,y) fff4f4f4 img2.getRGB(x,y) fff3f3f3
…….
…...
so I added a tolerance check for each color. The test now passes in osx10.14
and without the fix of 7124513, the test fails.
diff -r 20374b37dd01
test/jdk/javax/swing/JFrame/NSTexturedJFrame/NSTexturedJFrame.java
--- a/test/jdk/javax/swing/JFrame/NSTexturedJFrame/NSTexturedJFrame.java
Thu Mar 19 22:22:39 2020 -0700
+++ b/test/jdk/javax/swing/JFrame/NSTexturedJFrame/NSTexturedJFrame.java
Wed Mar 25 19:36:05 2020 +0530
@@ -23,6 +23,7 @@
import java.awt.Rectangle;
import java.awt.Toolkit;
+import java.awt.Color;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;
@@ -78,9 +79,16 @@
private static void testImages(BufferedImage img1, BufferedImage img2,
boolean shouldbeDifferent) {
boolean different = false;
+ int tol = 5;
for (int x = 0; x < img1.getWidth(); ++x) {
for (int y = 0; y < img1.getHeight(); ++y) {
- if (img1.getRGB(x, y) != img2.getRGB(x, y)) {
+ Color c1 = new Color(img1.getRGB(x, y));
+ Color c2 = new Color(img2.getRGB(x, y));
+
+ if ((Math.abs(c1.getRed() - c2.getRed()) > tol) &&
+ (Math.abs(c1.getBlue() - c2.getBlue()) > tol) &&
+ (Math.abs(c1.getGreen() - c2.getGreen()) > tol )) {
+
different = true;
}
> --
> Best regards, Sergey.