# HG changeset patch # User yan # Date 1382094924 -14400 # Node ID e061c26c0f50cc22eefdd90065a1422784f9f45b # Parent d037a0675f8d036ec70e950879f5d6de5a8d81d2 7002846: Fix for 6989505 may be incomplete Reviewed-by: anthony, art Contributed-by: Andrei Eremeev diff -r d037a0675f8d -r e061c26c0f50 jdk/src/windows/classes/sun/awt/windows/WRobotPeer.java --- a/jdk/src/windows/classes/sun/awt/windows/WRobotPeer.java Thu Oct 17 21:22:05 2013 +0400 +++ b/jdk/src/windows/classes/sun/awt/windows/WRobotPeer.java Fri Oct 18 15:15:24 2013 +0400 @@ -56,9 +56,9 @@ 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 -r d037a0675f8d -r e061c26c0f50 jdk/src/windows/native/sun/windows/awt_Robot.cpp --- a/jdk/src/windows/native/sun/windows/awt_Robot.cpp Thu Oct 17 21:22:05 2013 +0400 +++ b/jdk/src/windows/native/sun/windows/awt_Robot.cpp Fri Oct 18 15:15:24 2013 +0400 @@ -192,15 +192,6 @@ 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 @@ 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 -r d037a0675f8d -r e061c26c0f50 jdk/src/windows/native/sun/windows/awt_Robot.h --- a/jdk/src/windows/native/sun/windows/awt_Robot.h Thu Oct 17 21:22:05 2013 +0400 +++ b/jdk/src/windows/native/sun/windows/awt_Robot.h Fri Oct 18 15:15:24 2013 +0400 @@ -44,7 +44,6 @@ 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 );