From 26158306cda2c1d547e85da125fd2b8d38b27322 Mon Sep 17 00:00:00 2001 From: Andrei Eremeev <andrei.eremeev@oracle.com> Date: Fri, 18 Oct 2013 15:15:24 +0400 Subject: [PATCH] 7002846: Fix for 6989505 may be incomplete Reviewed-by: anthony, art --- .../classes/sun/awt/windows/WRobotPeer.java | 4 ++-- .../windows/native/sun/windows/awt_Robot.cpp | 18 ------------------ jdk/src/windows/native/sun/windows/awt_Robot.h | 1 - 3 files changed, 2 insertions(+), 21 deletions(-) diff --git a/jdk/src/windows/classes/sun/awt/windows/WRobotPeer.java b/jdk/src/windows/classes/sun/awt/windows/WRobotPeer.java index 6290eaeac73..e817da6f3b0 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WRobotPeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WRobotPeer.java @@ -56,9 +56,9 @@ class WRobotPeer extends WObjectPeer implements RobotPeer public native void keyRelease( int keycode ); public int getRGBPixel(int x, int y) { - return getRGBPixelImpl(x, y); + // See 7002846: that's ineffective, but works correctly with non-opaque windows + return getRGBPixels(new Rectangle(x, y, 1, 1))[0]; } - public native int getRGBPixelImpl(int x, int y); public int [] getRGBPixels(Rectangle bounds) { int pixelArray[] = new int[bounds.width*bounds.height]; diff --git a/jdk/src/windows/native/sun/windows/awt_Robot.cpp b/jdk/src/windows/native/sun/windows/awt_Robot.cpp index c2d3726fab3..72289b3240a 100644 --- a/jdk/src/windows/native/sun/windows/awt_Robot.cpp +++ b/jdk/src/windows/native/sun/windows/awt_Robot.cpp @@ -192,15 +192,6 @@ inline jint AwtRobot::WinToJavaPixel(USHORT r, USHORT g, USHORT b) return value; } -jint AwtRobot::GetRGBPixel( jint x, jint y) -{ - HDC hdc = ::CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL); - COLORREF ref = ::GetPixel( hdc, x, y ); - ::DeleteDC(hdc); - jint value = WinToJavaPixel(GetRValue(ref), GetGValue(ref), GetBValue(ref)); - return value; -} - void AwtRobot::GetRGBPixels(jint x, jint y, jint width, jint height, jintArray pixelArray) { DASSERT(width > 0 && height > 0); @@ -403,15 +394,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WRobotPeer_mouseWheel( CATCH_BAD_ALLOC; } -JNIEXPORT jint JNICALL Java_sun_awt_windows_WRobotPeer_getRGBPixelImpl( - JNIEnv * env, jobject self, jint x, jint y) -{ - TRY; - - return AwtRobot::GetRobot(self)->GetRGBPixel(x, y); - - CATCH_BAD_ALLOC_RET(0); -} JNIEXPORT void JNICALL Java_sun_awt_windows_WRobotPeer_getRGBPixels( JNIEnv *env, jobject self, jint x, jint y, jint width, jint height, jintArray pixelArray) { diff --git a/jdk/src/windows/native/sun/windows/awt_Robot.h b/jdk/src/windows/native/sun/windows/awt_Robot.h index 167044d760e..0f4fa664d88 100644 --- a/jdk/src/windows/native/sun/windows/awt_Robot.h +++ b/jdk/src/windows/native/sun/windows/awt_Robot.h @@ -44,7 +44,6 @@ class AwtRobot : public AwtObject void MouseWheel(jint wheelAmt); jint getNumberOfButtons(); - jint GetRGBPixel( jint x, jint y); void GetRGBPixels(jint x, jint y, jint width, jint height, jintArray pixelArray); void KeyPress( jint key );