mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-11 05:59:52 +00:00
8274939: Incorrect size of the pixel storage is used by the robot on macOS
Reviewed-by: aivanov, prr
This commit is contained in:
parent
8acfbc2e21
commit
eff5dafba9
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2022, 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
|
||||
@ -168,9 +168,9 @@ final class CRobot implements RobotPeer {
|
||||
*/
|
||||
@Override
|
||||
public int getRGBPixel(int x, int y) {
|
||||
int[] c = new int[1];
|
||||
double scale = fDevice.getScaleFactor();
|
||||
getScreenPixels(new Rectangle(x, y, (int) scale, (int) scale), c);
|
||||
int scale = fDevice.getScaleFactor();
|
||||
int[] c = new int[scale * scale];
|
||||
getScreenPixels(new Rectangle(x, y, scale, scale), c);
|
||||
return c[0];
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2022, 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
|
||||
@ -321,6 +321,11 @@ Java_sun_lwawt_macosx_CRobot_nativeGetScreenPixels
|
||||
jint picY = y;
|
||||
jint picWidth = width;
|
||||
jint picHeight = height;
|
||||
jsize size = (*env)->GetArrayLength(env, pixels);
|
||||
if (size < (long) picWidth * picHeight || picWidth < 0 || picHeight < 0) {
|
||||
JNU_ThrowInternalError(env, "Invalid arguments to get screen pixels");
|
||||
return;
|
||||
}
|
||||
|
||||
CGRect screenRect = CGRectMake(picX / scale, picY / scale,
|
||||
picWidth / scale, picHeight / scale);
|
||||
|
||||
@ -42,6 +42,8 @@ import javax.imageio.ImageIO;
|
||||
* @key headful
|
||||
* @bug 8215105 8211999
|
||||
* @summary tests that Robot can capture the common colors without artifacts
|
||||
* @run main/othervm CheckCommonColors
|
||||
* @run main/othervm -Xcheck:jni CheckCommonColors
|
||||
*/
|
||||
public final class CheckCommonColors {
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user